Commit Graph

10965 Commits

Author SHA1 Message Date
evazion
422dbbc72e Fix #4942: Missing Blacklist Controls. 2022-01-11 10:16:23 -06:00
evazion
33828ec8a4 posts: remove set_tag_string method. 2022-01-11 10:06:46 -06:00
evazion
2e1c7ce6d3 Fix #4951: chartags:0 returning posts with chartags.
* Add fix script to fix posts with incorrect tag_count_* fields.
* Simplify the code for updating tag_count_* fields (no functional change).
2022-01-10 13:33:56 -06:00
evazion
bd7018a3ae rails: update cache format version to 7.0. 2022-01-10 11:39:09 -06:00
evazion
fd2db2ff23 Update Ruby gems and Yarn packages. 2022-01-10 11:32:59 -06:00
evazion
104234126f robots.txt: add more static pages.
Let Google index a few more static pages.
2022-01-10 11:00:13 -06:00
evazion
aedc09f301 bigquery: exclude GoodJob::Job from BigQuery. 2022-01-10 00:12:31 -06:00
evazion
323882dbc4 upgrades: fix unsafe redirect errors in receipt/payment actions. 2022-01-10 00:11:10 -06:00
evazion
85e1ae3c9b favorites: fix posts with incorrect fav_count fields.
There were about 4000 posts with an incorrect fav_count.
2022-01-09 19:31:45 -06:00
evazion
ab4214dc00 emails: mark all invalid emails as undeliverable. 2022-01-09 13:24:53 -06:00
evazion
c09cd9e9fd users: fix incorrect count columns on users table.
Fix incorrect post_upload_count, note_update_count, and
unread_dmail_count columns on the users table.
2022-01-09 12:51:10 -06:00
evazion
5623b139aa db: add foreign key constraints on all tables.
Add foreign key constraints on all foreign keys on all tables.

These constraints are deferrable so that they're checked at the end of
the transaction, rather at the end of the statement. This is to reduce
lock duration and to allow for cyclic relationships.

Constraints are added in one migration then validated in another so that
the entire table isn't locked against reads and writes while the foreign
key constraints are being validated.

A few tables had invalid foreign keys. Add a fix script to fix these tables:

* A couple artist versions belonged to deleted artists.
* One dmail belonged to a deleted user.
* One forum topic visit belonged to that same deleted user.
* A few dozen note versions belonged to nonexistent posts. This came
  from RaisingK moving notes to different posts years ago, back when it
  was possible for users to set a note's post ID in the API.
* Some uploads had their parent ID set to 0.
2022-01-09 11:01:00 -06:00
evazion
3814aa21b3 favorites: delete favorites for expunged posts.
Delete favorites that have an invalid post_id because they belong to an
expunged post.

This bug of not deleting favorites after a post is expunged was fixed
long ago, but old favorites were never cleaned up.

Fixes #4711: Some users have incorrect fav count.
2022-01-08 20:55:55 -06:00
evazion
04d3a04836 favorites: fix users with incorrect favorite counts.
Fix users that have a non-zero favorite count, but no favorites.
Follow-up to 69facb22b.
2022-01-08 14:18:29 -06:00
evazion
69facb22b1 Fix #4265: Negative favorite counts.
There were 2176 users with incorrect favorite counts, and it stopped
after user id 522393, so this must have been an old bug.
2022-01-08 13:42:49 -06:00
evazion
d900e15dcc css: fix stylelint complaints. 2022-01-08 12:30:21 -06:00
evazion
3bf65d1378 css: update browserslist requirement.
Update the minimum browser requirement from browsers released since
2012, to browsers released in the last 5 years.

This means PostCSS won't prefix CSS properties like `flex` or other
properties supported by browsers since 2017. Babel also won't transpile
Javascript syntax that has been supported by browsers since 2017.
2022-01-08 12:09:25 -06:00
evazion
bb60a59001 css: remove postcss-flexbugs-fixes plugin.
Remove a PostCSS plugin used to workaround bugs in the `flex` CSS
property. Most of these bugs are no longer relevant and only affected
ancient browsers like IE 10 or 11.

https://github.com/philipwalton/flexbugs
2022-01-08 11:54:45 -06:00
evazion
52311ad914 css: don't include fallbacks for CSS variables.
Don't include fallback CSS properties for CSS variables. Before we
generated CSS like this:

  a.tag-type-1 {
    color: #c00004;
    color: var(--artist-tag-color);
  }

Now we generate CSS like this:

  a.tag-type-1 {
    color: var(--artist-tag-color);
  }

This means that support for CSS variables is now required for colors to
work properly. All major browsers have supported CSS variables since
2016-2017.
2022-01-08 11:50:02 -06:00
evazion
349f8e098f posts: prevent dragging of thumbnails.
Disable the ability to click and drag thumbnails. This usually happened
by accident when you clicked on a thumbnail and accidentally dragged it,
especially during tag scripting.
2022-01-07 21:33:26 -06:00
evazion
37f2d5925f sessions: fix open redirect in login page.
Fix an open redirect exploit where if you went to <https://danbooru.donmai.us/login?url=//fakebooru.com>,
then after you logged in you would be redirected to https://fakebooru.com.

This was actually fixed by the upgrade to Rails 7.0. `redirect_to` now
raises an `UnsafeRedirectError` on redirect to an offsite URL. Before we
tried to prevent offsite redirects by checking that the URL started with
a slash, but this was insufficient - it allowed protocol-relative URLs
like `//fakebooru.com`.

Add a test case for protocol-relative URLs and return a 403 error on an
offsite redirect.
2022-01-07 21:11:04 -06:00
evazion
841990709d rails: enable Server-Timing HTTP header in production.
This returns a Server-Timing header on all HTTP responses, which
includes details on how long it took the server to render the response.
Browsers can show this timing information in the devtools. In Chrome, go
to the Network panel, then click a HTTP request, then click the Timing tab.
2022-01-07 21:11:04 -06:00
evazion
87dfc66073 rails: update framework files and settings to 7.0.
* Update framework files with `bin/rails app:update`.
* Update to use new Rails 7.0 default settings, except for a couple
  things regarding new cookie and cache formats that would prevent us
  from rolling back to Rails 6.1 if necessary.
2022-01-07 21:10:55 -06:00
evazion
346aeca791 rails: remove sprockets references.
Remove a dummy Sprockets config file needed to get `bin/derailed` to
run. This is no longer necessary since Rails 7.0 no longer depends on
Sprockets.
2022-01-07 14:49:14 -06:00
evazion
450594b803 tests: fix broken tests. 2022-01-07 14:44:24 -06:00
evazion
cae6599631 pagination: fix paginator regression caused by Rails 7.
Fix the paginator not detecting the first or last page correctly during
sequential pagination.

Caused by the fact that we fetch one more record than needed to detect
whether we're on the last page, then throw that record away by
overriding Rails' internal `records` method. An upstream refactoring
meant that the `size` method now counts the number of records *after*
the extra record is thrown away, where before it counted *before* the
extra record was thrown away.
2022-01-07 14:24:57 -06:00
evazion
72ea78e697 searchable: replace find_ordered with in_order_of.
Rails 7 added an `in_order_of` method that does what our `find_ordered`
method did before.
2022-01-07 14:24:57 -06:00
evazion
a26ed9d389 rails: fix #to_s(:human_size) deprecation warnings.
Fix this deprecation warning:

  DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_formatted_s(:human_size) instead.
2022-01-07 14:24:54 -06:00
evazion
3f25ad6dce rails: upgrade to Rails 7.0.1. 2022-01-07 14:24:45 -06:00
evazion
41a095abfe gems: temp disable meta_request gem.
It's not yet compatible with Rails 7.0.
2022-01-07 12:43:39 -06:00
evazion
ea069c7b0d models: remove hack to ignore tsvector columns.
Previously we overrode `ActiveRecord::Base#columns` to make it ignore
tsvector columns so they wouldn't show up in API responses. These
columns have been removed, so this is no longer necessary.
2022-01-07 11:23:53 -06:00
evazion
53527b9b29 posts: remove pool_string, fav_string from ignored columns.
These columns have been removed from the database.
2022-01-07 11:22:10 -06:00
evazion
dbf4e1e98e db: remove unused tsvector triggers.
This was forgotten in 080dbf5a8.
2022-01-06 20:03:50 -06:00
evazion
0f3fc0d697 Fix Twitter widget overlapping Discord widget on Downbooru page. 2022-01-06 12:43:37 -06:00
evazion
e8c52432a4 db: remove unused columns on posts table.
is_note_locked, is_rating_locked, and is_status_locked have been unused
since 126046cb6.

tag_index has been unused since 37a8dc5db.

fav_string has been unused since 165339236.

pool_string has been unused since 7d503f088.
2022-01-06 11:39:18 -06:00
evazion
080dbf5a8c db: remove unused tsvector columns.
These columns have been unused since e3b836b50.
2022-01-06 11:25:51 -06:00
evazion
72d5291a27 bigquery: exclude more GoodJobs classes from BigQuery. 2022-01-06 11:13:55 -06:00
evazion
123edc63a1 bigquery: don't dump good_jobs table to bigquery. 2022-01-06 00:41:26 -06:00
evazion
edd0656b73 tests: fix broken tests. 2022-01-06 00:41:18 -06:00
evazion
b254d6d9d9 jobs: fix searching by name not finding certain jobs.
Fix a bug where /jobs?search[name]=Prune+Posts didn't find jobs named PrunePostsJob.
`"Prune Posts".tr(" ", "_").classify` was wrong because it returned `"PrunePost"`.
2022-01-05 11:14:56 -06:00
evazion
090125e239 Revert "Temp disable dumping favorites table to BigQuery."
This reverts commit 788dcbd87b.
2022-01-04 18:08:54 -06:00
evazion
9000facaf7 Revert "bigquery: temp disable dumping the posts table."
This reverts commit f02b437085.
2022-01-04 18:08:47 -06:00
evazion
7ce81ceccb emails: fix exception when user signs up without an email.
Fix an `ActionView::Template::Error: undefined method 'verification_key'
for nil` error in the welcome_user mailer when a user signs up without
an email address.

Caused by the fact that we now render mail templates regardless of
whether the user has an email address, and then skip sending the email
only after the mail template is rendered.
2022-01-04 17:57:16 -06:00
evazion
1ccc74adca jobs: add ability to order jobs in /jobs listing. 2022-01-04 17:53:35 -06:00
evazion
dc159ed135 jobs: show retried jobs in /jobs listing.
Fix the /jobs listing to show retried jobs. GoodJob::ActiveJobJob has a
default scope that filters out retried jobs; remove it in the index
controller so we can see retried jobs.

Also fix mail delivery jobs not showing up in the dropdown in the /jobs
search form.
2022-01-04 17:46:54 -06:00
evazion
f38910f0a2 jobs: hide job arguments and errors from non-admins.
These can sometimes contain sensitive information, such as IP addresses
or what files a user is trying to upload.
2022-01-04 17:20:43 -06:00
evazion
82211ba935 jobs: add ability to search jobs on /jobs page.
Add ability to search jobs on the /jobs page by job type or by status.

Fixes #2577 (Search filters for delayed jobs). This wasn't possible
before with DelayedJobs because it stored the job data in a YAML string,
which made it difficult to search jobs by type. GoodJobs stores job data
in a JSON object, which is easier to search in Postgres.
2022-01-04 17:18:36 -06:00
evazion
12601e49fd users: fix exception in can_receive_email?. 2022-01-04 16:04:41 -06:00
evazion
3841fba78e jobs: remove DelayedJobs.
Remove the DelayedJobs gem and database table. Completes the transition
to GoodJob started in c06bfa64f and f4953549a.

Downstream users can upgrade as follows:

* Stop the Rails server.
* Stop the DelayedJobs worker (normally running as `bin/delayed_job` or `bin/rails jobs:work`).
* Run `bin/rails jobs:work` to finish any pending delayed jobs.
* Run `bin/rails db:migrate` to create the good_jobs table and drop the delayed_jobs table.
* Start the Rails server again.
* Start the GoodJobs worker with `bin/good_job start`.
2022-01-04 15:58:12 -06:00
evazion
f4953549ae jobs: switch from DelayedJob to GoodJob.
Switch the ActiveJob backend from DelayedJob to GoodJob. Differences:

* The job worker is run with `bin/good_job start` instead of `bin/delayed_job`.
* Jobs have an 8 hour timeout instead of a 4 hour timeout.
* Jobs don't automatically retry on failure.
* Finishing jobs are preserved and pruned after 7 days.
2022-01-04 13:52:08 -06:00