Commit Graph

6749 Commits

Author SHA1 Message Date
evazion
2e407fa476 rails: update defaults from 5.1 to 5.2.
protect_from_forgery removed from because it's now on by default.

ref: https://edgeguides.rubyonrails.org/configuring.html
2019-08-22 22:09:05 -05:00
evazion
6ba3d68792 dmails: fix feedback not being left when spammer is autobanned. 2019-08-22 21:29:58 -05:00
evazion
4f5d80bb60 forum post votes: fix conflicting scope name.
Fixes a conflict with `Enumerable#excluding` in Rails 6.

    Rename Array#without and Enumerable#without to Array#excluding and
    Enumerable#excluding. Old method names are retained as aliases.
2019-08-22 21:28:56 -05:00
evazion
97cc873a3f maintenenace: fix db timeouts during vacuuming.
Setting the statement timeout at the beginning didn't work because
`PostPruner.new.prune!` clobbers the timeout (it calls `without_timeout`,
which doesn't restore the timeout properly if the timeout was zero).
2019-08-22 17:03:18 -05:00
evazion
831aa57cad posts/show: fix thresholded comments not being hidden on pageload. 2019-08-22 16:40:45 -05:00
evazion
d05ebfe116 dmails: fix bug preventing members from sending dmails.
Bug: sending dmails failed for members.

Cause: using lambdas with `rakismet_attrs` failed because unexpected
arguments are passed to the lambdas. Using procs works because the
arguments are ignored.

Also fix the tests to actually test akismet. We didn't catch this
because the tests mocked out the `spam?` call.
2019-08-22 00:42:49 -05:00
evazion
44653fb722 Fix errors on /artists/show_or_new, /wiki_pages/show_or_new pages.
Fix these pages to redirect to the new page instead of erroring out when
a name or title isn't given.
2019-08-22 00:09:50 -05:00
evazion
1292e73931 Fix errors on HEAD requests to various index pages.
Various search forms try to do `params[:search][:blah]`, which failed
for HEAD requests because we didn't normalize the `search` param.
2019-08-21 23:37:46 -05:00
evazion
ac259859f9 search: don't error out on source:*pixiv* searches. 2019-08-21 23:33:49 -05:00
evazion
d75d2266c9 users: fix error handling for /users?name=<does_not_exist>. 2019-08-21 23:32:34 -05:00
evazion
7cc31b97c9 pools/show: fix pagination to respect user's posts-per-page setting. 2019-08-21 14:31:58 -05:00
evazion
b283281e5e comments: minimize sql queries.
Certain parts of comment rendering triggered sql queries that we didn't
really need to do. Rework things to avoid this.

* Preload comment creators in order to display commenter names with link_to_user.

* Preload comment votes in order to display "undo vote" links. Only preload
  votes for members since anonymous users can't vote and don't have "undo
  vote" links.

* Rework various conditionals to do the filtering in Ruby so that we
  avoid issuing any extra queries in sql.

* Avoid issuing any queries at all when the post doesn't have any
  comments (when last_commented_at is blank).
2019-08-20 21:55:25 -05:00
evazion
2cf929ad6e comments: show "undo vote" link by default on voted comments (fix #4143). 2019-08-20 21:17:02 -05:00
evazion
6e708dec18 /artists/new: fix artist name input box sizing.
In production the name input is really big because the artist name
column in the production db is `text` rather than `character varying`,
and simpleform treats text columns as textbox inputs.
2019-08-19 19:49:31 -05:00
evazion
0b14146f6a posts: hotfix bug in /posts.json?tags=blah+order:random. 2019-08-19 18:51:33 -05:00
evazion
782d9f3d61 comment votes: fix error handling.
Return the comment itself and a standard error response on failure.
2019-08-19 17:22:36 -05:00
evazion
b8450671f2 /mod_actions: fix N+1 query. 2019-08-19 00:46:31 -05:00
evazion
d4a243c8d1 footer: abbreviate git hash. 2019-08-19 00:46:31 -05:00
evazion
13f4dee59f footer: only show keyboard shortcuts link on desktop. 2019-08-19 00:46:31 -05:00
evazion
dab43d96c9 jobs: migrate mass updates to ActiveJob.
Also fixes a bug where mod actions weren't logged on mass updates.
Creating the mod action silently failed because it was called when
CurrentUser wasn' set.
2019-08-19 00:46:31 -05:00
evazion
48488d04db jobs: migrate bulk reverts to ActiveJob. 2019-08-19 00:46:30 -05:00
evazion
ddcc7eddfb jobs: migrate fixing post counts to ActiveJob. 2019-08-19 00:46:30 -05:00
evazion
a586916cb3 /wiki_page_versions: various usability improvements.
Changes to the /wiki_page_versions global listing:

* Add "diff" links that show you what changed in the given edit.
* Add "?" links that take you to the current version of the wiki.
* Add "»" links next to wiki page titles that take you to the wiki's full edit history.
* Add "»" links next to usernames that take you to the user's full edit history.
* Add a "Status" column that shows whether the wiki page was created,
  deleted, undeleted, or renamed.
* Link to /wiki_page_versions in sidebar, not /wiki_pages?order=time.
2019-08-18 17:08:35 -05:00
evazion
5b27726635 views: fixup regressions in new dmail, new feedback forms.
Fixup regression in 59b277ead. Simpleform expected `to_name`,
`user_name` methods to exist on these models.
2019-08-18 13:33:05 -05:00
evazion
576b4feb3b views: convert mod dashboard + admin user edit page to simple form.
Fixes bug with the user level select dropdown on the mod dashboard page
missing the builder level.
2019-08-18 11:24:42 -05:00
evazion
d7d4a63e69 js: fixup bug in note hiding.
Fixup regression in e000bdb86.
2019-08-18 11:24:42 -05:00
evazion
6019a9fdc4 js: fix eslint warnings. 2019-08-18 11:24:42 -05:00
evazion
f2937e3d27 js: update yarn packages. 2019-08-18 11:24:42 -05:00
evazion
59b277ead1 users: drop id_to_name, name_to_id caching.
Changes:

* Drop Users.id_to_name.
* Don't cache Users.name_to_id.
* Replace calls to name_to_id with find_by_name when possible.
* Don't autodefine creator_name in belongs_to_creator.
* Don't autodefine updater_name in belongs_to_updater.
* Instead manually define creator_name / updater_name only on models that need
  to return these fields in the api.

id_to_name was cached to reduce the impact of N+1 query patterns in
certain places, especially in api responses that return creator_name /
updater_name fields. But it still meant we were doing N calls to
memcache. Using `includes` to prefetch users avoids this N+1 pattern.

name_to_id had no need be cached, it was never used in any performance-
sensitive contexts.

Avoiding caching also avoids the need to keep these caches consistent.
2019-08-18 11:24:42 -05:00
evazion
7871dced00 users: fix find_by_name, name_to_id to strip whitespace.
Fix find_by_name and name_to_id to use normalize_name properly, so that
they ignore leading/trailing whitespace. This fixes various search forms
failing to return results when the username field contains trailing
whitespace (inserted by autocomplete).
2019-08-18 11:24:42 -05:00
evazion
82fbb19e0f users: drop unused code. 2019-08-18 11:24:42 -05:00
evazion
17b2cd38cd dmails: drop unneeded methods. 2019-08-18 11:24:42 -05:00
lllusion3469
b15fd6d017 Fix Ugoiras when image cropping is disabled
since file is nil and has no #close! when Danbooru.config.enable_image_cropping is false
2019-08-17 19:52:23 -05:00
evazion
51ca31ef8d Drop unused tag subscription model. 2019-08-17 02:47:49 -05:00
evazion
868a2256d1 jobs: migrate file deletion jobs to ActiveJob. 2019-08-16 20:49:35 -05:00
evazion
2b6361369e jobs: migrate aliases/implications to ActiveJob. 2019-08-16 20:49:35 -05:00
evazion
2bbdc5d143 jobs: migrate saved searches to ActiveJob.
* Fix tests to run the searches for real instead of mocking everything out.

* Fix SavedSearch.populate to only use the read only database in
  production because in breaks things in tests. Specifically:
  the posts get created in one db connection but searched for in
  another, but the second transaction doesn't see the uncommitted posts
  in the first transaction, so the search doesn't work.
2019-08-16 20:49:35 -05:00
evazion
a68db501c2 jobs: migrate related tag updates to ActiveJob. 2019-08-16 20:49:35 -05:00
evazion
24eb1b155f jobs: migrate pool category updates to ActiveJob. 2019-08-16 20:49:34 -05:00
evazion
4e8b3d9310 jobs: migrate user deletions to ActiveJob. 2019-08-16 20:49:34 -05:00
evazion
822dce20ed jobs: add base ApplicationJob. 2019-08-16 20:49:34 -05:00
evazion
817f5ecf9c jobs: drop favgroup expunge job.
Make `Post#expunge!` remove favgroups synchronously.
2019-08-16 20:49:34 -05:00
evazion
798d524e60 Post#tag_match: clean up read_only param.
* Drop /posts?ro=true param (broken).
* Clean up tag_match (rescuing PG::ConnectionBad didn't do anything, we
  just build the query here, we don't run it).
2019-08-16 00:26:00 -05:00
evazion
bb157f5d5b models: drop various unused #named methods. 2019-08-15 19:18:19 -05:00
evazion
0d7d2cac80 Drop unused AmazonBackup model. 2019-08-15 18:41:57 -05:00
evazion
b9d35eaf2c Fix #3272: Unicode tags are still being allowed.
* Don't allow adding tags with invalid names when they already exist in
  the tags table.
* If an invalid tag is added, show an warning and ignore the tag instead
  of failing with a hard error.
* Move the _(cosplay) tag validation into the tag name validator.
2019-08-15 16:42:23 -05:00
evazion
e85c6c3250 artists.js: replace 'check name' code with tag autocomplete.
Instead of having custom code check whether the artist name is already
in use, just enable autocomplete on the artist name field. This is an
easier and more robust way to indicate tag name conflicts.
2019-08-15 12:51:51 -05:00
evazion
df8391aec0 Make /artists_versions and /artist_commentaries/search visible to all. 2019-08-15 12:51:51 -05:00
evazion
a64cd50be4 profiles: add account upgrade link. 2019-08-15 12:51:51 -05:00
evazion
01c4395105 profiles: add 'refresh' link next to post changes count.
Remove the 'Refresh counts' link from the site map. Put it in the user's
profile instead.
2019-08-15 12:51:51 -05:00