Commit Graph

9983 Commits

Author SHA1 Message Date
evazion
1d15ce2bcd Remove Danbooru Winter Sale. 2021-01-01 04:16:38 -06:00
evazion
5b7894a8b2 autocomplete: fix exception when type param is missing. 2021-01-01 04:06:38 -06:00
evazion
430ba5dced users: fix exception during signup for IPv6 addresses.
`ip_address.private?` failed on IPv6 addresses.
2021-01-01 03:57:17 -06:00
evazion
83d6cd5980 Update Winter Sale banner for last day. 2020-12-31 06:50:10 -06:00
evazion
d9a8fc99bc javascript: change Cookie.put to take expiry in seconds. 2020-12-31 06:50:10 -06:00
evazion
d0bb4ed398 user upgrades: add bank payment methods for European countries.
Add the following bank redirect payment methods:

* https://stripe.com/docs/payments/bancontact
* https://stripe.com/docs/payments/eps
* https://stripe.com/docs/payments/giropay
* https://stripe.com/docs/payments/ideal
* https://stripe.com/docs/payments/p24

These methods are used in Austria, Belgium, Germany, the Netherlands,
and Poland.

These methods require payments to be denominated in EUR, which means we
have to set prices in both USD and EUR, and we have to automatically
detect which currency to use based on the user's country. We also have
to automatically detect which payment methods to offer based on the
user's country. We do this by using Cloudflare's CF-IPCountry header to
geolocate the user's country.

This also switches to using prices and products defined in Stripe
instead of generated on-the-fly when creating the checkout.
2020-12-31 06:50:10 -06:00
evazion
bf09940a55 debug mode: re-raise exceptions in controller.
Fixes exception information not reaching the console during failed
controller tests.
2020-12-31 06:50:10 -06:00
evazion
ae5c0d1034 newrelic: log request path. 2020-12-31 06:50:10 -06:00
evazion
9e9ac8f4bf sessions: store geolocated country in CurrentUser. 2020-12-31 04:54:00 -06:00
evazion
4b171bf97e user upgrades: add ability to refund upgrades. 2020-12-29 04:17:32 -06:00
evazion
87af02f689 user upgrades: add links to Stripe payment & receipt page.
Add links to the Stripe payment page and the Stripe receipt page on
completed user upgrades.

The Stripe payment link is a link to the payment details on the Stripe
dashboard and is only visible to the owner.
2020-12-29 00:19:52 -06:00
evazion
e29e2da8be /user_upgrades: add json/xml api support. 2020-12-28 19:50:17 -06:00
evazion
7fc5845e72 /emails: add more search options.
Add options to search for invalid emails and emails from restricted
domains.
2020-12-28 19:31:40 -06:00
evazion
a69ef8fa89 routes: add /user_upgrade/new redirect.
Redirect the old user upgrade page, /user_upgrade/new, to the new
user upgrade page, /user_upgrades/new page. Some old forum posts still
link to the old page.
2020-12-28 16:36:52 -06:00
evazion
0b6fca7ff8 Update ruby gems and yarn packages. 2020-12-28 16:32:58 -06:00
evazion
6a52216631 newrelic: log additional request headers.
Log the Referer header, as well as the Sec-Fetch-* headers. These are
only sent by recent versions of Chrome; see https://www.w3.org/TR/fetch-metadata.
2020-12-28 01:53:22 -06:00
evazion
59c61f249f posts helper: remove dupe nav_params_for method.
Already defined in PaginationHelper.
2020-12-28 00:57:18 -06:00
evazion
805bbc8a33 users: add config option to disable verification of new accounts.
Fixes #4618.
2020-12-28 00:01:35 -06:00
evazion
9dc788c0ce users: improve sockpuppet detection on signup.
Require new accounts to verify their email address if any of the
following conditions are true:

* Their IP is a proxy.
* Their IP is under a partial IP ban.
* They're creating a new account while logged in to another account.
* Somebody recently created an account from the same IP in the last week.

Changes from before:

* Allow logged in users to view the signup page and create new accounts.
  Creating a new account while logged in to your old account is now
  allowed, but it requires email verification. This is a honeypot.
* Creating multiple accounts from the same IP is now allowed, but they
  require email verification. Previously the same IP check was only for
  the last day (now it's the last week), and only for an exact IP match
  (now it's a subnet match, /24 for IPv4 or /64 for IPv6).
* New account verification is disabled for private IPs (e.g. 127.0.0.1,
  192.168.0.1), to make development or running personal boorus easier
  (fixes #4618).
2020-12-27 23:41:07 -06:00
evazion
7e8f859b24 tags: eliminate Tag.category_for method.
Tag.category_for looked up a tag's category in the Redis cache. This was
only used in a few places (in related tags, and on the popular/missed
search pages). Get rid of this method so we can work towards getting rid
of caching tag categories in Redis.
2020-12-27 21:03:26 -06:00
evazion
1047b1f8af Fix #4427: Opening a post from a profile's favorites brings up a fav: search. 2020-12-27 17:14:55 -06:00
evazion
7f1b798b05 searchable: refactor search_boolean_attribute. 2020-12-27 05:26:21 -06:00
evazion
4756141156 emails: add script to delete invalid emails.
We used to not validate user email addresses, which means we have a lot
of users with invalid emails. This script deletes all emails that are
missing both an `@` and a `.` This amounts to about 3000 invalid emails.

There are an additional ~1000 emails that are missing just the `@` sign.
Many of these are simple typos, for example skipping the `@` or typing a
2 instead. Some of these may be manually fixable.

This fixes an issue where upgrading to Gold could fail if you had an
invalid email address, because we prefilled the buyer's email address on
the Stripe checkout page and an invalid email would cause Stripe to
throw an error.
2020-12-27 04:45:46 -06:00
evazion
ddd149e22b seo: mark login links as nofollow.
Mark links to the login page as rel="nofollow" so that search crawlers
don't constantly try to crawl it. Otherwise the fact the login url is
different on every page (/login?url=<current_url>) confuses crawlers.

Also strip the url param from the canonical url (<link rel="canonical">)
on the login page.
2020-12-27 04:41:49 -06:00
evazion
57e70e5b82 /users: fix exception when last_ip_addr is nil. 2020-12-26 11:16:19 -06:00
evazion
fd18291382 Add Danbooru Winter Sale. 2020-12-25 06:07:21 -06:00
evazion
ae49ed2b1a api: fix legacy /post/index and /tag/index endpoints.
Fixup for a1cd9d2b5. The route order matters here, the legacy endpoints
need to go first.
2020-12-25 02:43:56 -06:00
evazion
d9db32640a user upgrades: fix checkout form leaking recipient's email.
The checkout form should be prefilled with the purchaser's email
address, not the recipient's.
2020-12-25 02:01:42 -06:00
evazion
e030a07816 user upgrades: add index action. 2020-12-25 01:21:54 -06:00
evazion
2d50ba6fd5 posts: fix /posts/random route.
Fixup for 039ccfa3a.
2020-12-25 00:59:48 -06:00
evazion
96f08b78c5 /contact: update contact page with more contact methods. 2020-12-25 00:47:08 -06:00
evazion
069231a33b user upgrades: update upgrade landing page.
* Add a frequently asked questions section.
* Add nicer looking upgrade buttons.
* Format the page nicer.
* Prevent users from attempting invalid upgrades on users that are
  already Platinum or above.
2020-12-25 00:47:08 -06:00
evazion
058d71aa30 user upgrades: send dmail to purchaser for gifted upgrades.
* Refactor to move upgrade logic from UserPromotion to UserUpgrade.
* Send the recipient and the purchaser of a gifted upgrade separate
  dmail notifications.
2020-12-25 00:43:58 -06:00
evazion
74ed2a8b96 user upgrades: add UserUpgrade model.
Add a model to store the status of user upgrades.

* Store the upgrade purchaser and the upgrade receiver (these are
  different for a gifted upgrade, the same for a self upgrade).
* Store the upgrade type: gold, platinum, or gold-to-platinum upgrades.
* Store the upgrade status:
** pending: User is still on the Stripe checkout page, no payment
   received yet.
** processing: User has completed checkout, but the checkout status in
   Stripe is still 'unpaid'.
** complete: We've received notification from Stripe that the payment
   has gone through and the user has been upgraded.
* Store the Stripe checkout ID, to cross-reference the upgrade record on
  Danbooru with the checkout record on Stripe.

This is the upgrade flow:

* When the user clicks the upgrade button on the upgrade page, we call
  POST /user_upgrades and create a pending UserUpgrade.
* We redirect the user to the checkout page on Stripe.
* When the user completes checkout on Stripe, Stripe sends us a webhook
  notification at POST /webhooks/receive.
* When we receive the webhook, we check the payment status, and if it's
  paid we mark the UserUpgrade as complete and upgrade the user.
* After Stripe sees that we have successfully processed the webhook,
  they redirect the user to the /user_upgrades/:id page, where we show
  the user their upgrade receipt.
2020-12-24 21:15:04 -06:00
evazion
7762489d7d user upgrades: upgrade to new Stripe checkout system.
This upgrades from the legacy version of Stripe's checkout system to the
new version:

> The legacy version of Checkout presented customers with a modal dialog
> that collected card information, and returned a token or a source to
> your website. In contrast, the new version of Checkout is a smart
> payment page hosted by Stripe that creates payments or subscriptions. It
> supports Apple Pay, Dynamic 3D Secure, and many other features.

Basic overview of the new system:

* We send the user to a checkout page on Stripe.
* Stripe collects payment and sends us a webhook notification when the
  order is complete.
* We receive the webhook notification and upgrade the user.

Docs:

* https://stripe.com/docs/payments/checkout
* https://stripe.com/docs/payments/checkout/migration#client-products
* https://stripe.com/docs/payments/handling-payment-events
* https://stripe.com/docs/payments/checkout/fulfill-orders
2020-12-24 19:58:29 -06:00
evazion
c17678d509 routes: add a new 404 page.
* Fix a bug where non-GET 404 requests weren't handled.
* Fix a bug where non-HTML 404 requests weren't handled.
* Show a random image from a specified pool on the 404 page.
2020-12-24 00:17:35 -06:00
evazion
039ccfa3af routes: optimize route order.
Put the most used routes at the top of the file to optimize route
performance.
2020-12-24 00:17:35 -06:00
evazion
a1cd9d2b5c routes: remove unused Danbooru 1 redirects.
Remove various redirects for old Danbooru 1 links. Most of these
received little to no traffic and were only used in a small number of
places in old comments or forum posts.
2020-12-24 00:17:35 -06:00
evazion
ca742db07a routes: remove legacy /user/index and /artist/index API endpoints.
These endpoints get zero traffic.
2020-12-24 00:17:26 -06:00
evazion
dbb66ace90 routes: replace hardcoded routes in models with route helpers.
Add a Routes module that gives models access to route helpers outside of
views, and use it to replace various hardcoded routes.
2020-12-24 00:17:19 -06:00
evazion
a947a10c53 config: add debug_mode option.
Add a debug mode option. This is useful when debugging failed tests.

Debug mode disables parallel testing so you can set breakpoints in tests
with binding.pry (normally parallel testing makes it hard to set
breakpoints).

Debug mode also disables global exception handling for controllers. This
lets exceptions bubble up to the console during controller tests
(normally exceptions are swallowed by the controller, which prevents you
from seeing backtraces in failed controller tests).
2020-12-24 00:17:19 -06:00
evazion
a084da2dbe artists: hide other names of banned artists on index page.
Don't show other names of banned artists on the /artists page to
anonymous users. Hides potentially sensitive information from Google and
logged out users.
2020-12-22 02:15:21 -06:00
evazion
fbb4cfb807 users: let mods see users' last login time. 2020-12-21 22:42:50 -06:00
evazion
3c4781f6d8 users: update last_logged_in_at hourly.
Update last_logged_in_at on an hourly basis instead of a weekly basis.
2020-12-21 22:42:50 -06:00
evazion
025631ee64 users: show IPs to mods on /users page. 2020-12-21 22:42:50 -06:00
evazion
8221c8dcba users: inline search form on /users index page.
* Add the user search form to the /users page.
* Remove the /users/search page.
2020-12-21 22:42:50 -06:00
evazion
7a2f72ce98 ip bans: fix /ip_bans listing not showing subnet. 2020-12-21 22:42:50 -06:00
evazion
db488c247d ip bans: fix deleted field in /ip_bans search form.
Fix the value not being remembered in the search form because we
accidentally used `input_html` instead of `selected`.
2020-12-21 22:42:50 -06:00
evazion
0be9c8dc8b emails: optimize /emails listing.
Fix a suboptimal query that made the /emails page really slow.
2020-12-21 22:42:50 -06:00
evazion
f3880569e1 rails: update settings to 6.1 defaults.
Most of the new settings aren't relevant to us. We do have to fix some
tests to work around a Rails bug. `assert_enqueued_email_with` uses the
wrong queue, so we have to specify it explicitly. This is fixed in Rails
HEAD but not yet released.
2020-12-21 22:42:50 -06:00