Commit Graph
100 Commits
Author SHA1 Message Date
evazion ca2e2c92b9 artist versions: fix uninitialized constant error.
Error appears intermittently depending on module load order.
2019-08-13 21:30:20 -05:00
evazion 0a5e04f015 dmail filters: fix uninitialized constant error. 2019-08-13 21:30:20 -05:00
evazion 28a88cfa85 application controller: fix errors in normalize_search.
Fix exceptions in `normalize_search` on e.g. `https://danbooru.donmai.us/users?search=blah`.
Caused when the `search` param is not a hash.
2019-08-13 21:30:20 -05:00
evazion d7fce22ee5 application controller: rescue Post::SearchError.
Raised when a member does a >2 tag search.
2019-08-13 21:30:20 -05:00
evazion e70cae457d application controller: clean up exception handling.
* Simplify code.
* Show backtraces for all users, not just builders.
* Show backtraces only for unexpected server errors (status 5xx), not
  for normal client errors (status 4xx).
* Log expected errors at info level (reduce noise in production logs).
2019-08-13 21:30:20 -05:00
evazion 84d311f366 autocomplete: add username autocomplete to /uploads search page. 2019-08-12 21:33:07 -05:00
evazion 434f1a0b85 favorites: fix LockWaitTimeout errors.
Favoriting posts sometimes fails with ActiveRecord::LockWaitTimeout
errors. This happens when a user tries to favorite multiple posts in
short succession. In that case we want the lock to block and wait for
the other favorite to go through, not to immediately fail.
2019-08-12 19:20:33 -05:00
evazion 601e58d5c5 Fix exception in legacy /post/index.xml endpoint.
Fixes intermittent `uninitialized constant LegacyController::Builder` exceptions.
2019-08-12 19:20:33 -05:00
evazion 9b57631046 capistrano: fix newrelic deployment tagging.
Override the appname in config/newrelic.yml so that we don't
accidentally tag deployments under the wrong app.
2019-08-12 19:20:33 -05:00
evazion 5acc75d21b capistrano: fix sleep calls.
Minor optimization for `cap production deploy --dry-run`. Sleep on the
server instead of in the client.
2019-08-12 18:22:44 -05:00
evazion d0d71fcdc8 posts/index: disable next page prefetching.
This causes the browser to prefetch the next page in a search, which may
make browsing seem faster to the end user, but it effectively doubles
the load on the server.
2019-08-12 18:17:04 -05:00
evazion b50b7f2a91 tag aliases: fix bug in alias resolution.
Bug: Searching for an aliased tag returns an empty page instead of
showing the results for the real tag.

Cause: The query parsing code runs the search string through
`.mb_chars.downcase` before calling `TagAlias.to_aliased`, so the input
to `to_aliased` is actually a ActiveSupport::Multibyte::Chars object.
This breaks the `aliases[name]` hash lookup because `name` is not a
plain string.

Fixup for c7bcce429.
2019-08-12 18:10:49 -05:00
evazion a71899559a tests: fix ip ban test regression. 2019-08-12 14:17:00 -05:00
evazion a28a58c1f6 tests: add more posts/index controller tests. 2019-08-12 13:38:45 -05:00
evazion d8749e7dfe search: save a query in fast_count (#4120).
During single-tag searches we look up the tag once in Post.fast_count
and later on when rendering the wiki excerpt. Doing a raw query here
meant that Rails couldn't cache the query, so it got ran again when
rendering the excerpt.
2019-08-12 13:38:45 -05:00
evazion 43e8a8a01b search: reduce queries in wiki excerpts (#4120).
Using `any?` here translated each lookup into two queries, one to check
if the aliases/implications existed and one to actually load them. Using
`present?` avoids the existence check.
2019-08-12 13:38:45 -05:00
evazion 14da425564 search: reduce queries in single tag searches (#4120).
Avoid some queries used in wiki page excerpts:

* Only try to load the artist if the tag is an artist tag.
* Avoid using `exists?` queries for wiki pages.
* Bugfix: don't show wiki excerpts for deleted wikis.
2019-08-12 13:38:45 -05:00
evazion bda69315ff search: optimize related tag calc in multi-tag searches (#4120).
In multi-tag searches, we calculated the tags in the sidebar by sampling
300 random posts from within the search and finding the most frequently
used tags. This meant we were effectively doing two searches on every
page load, one for the actual search and one for the sidebar. This is
not so bad for fast searches, but very bad for slow searches.

Instead, now we calculate the related tags from the current page of
results. This is much faster, at the cost of slightly lower accuracy and
the tag list changing slightly as you browse between pages.

We could use caching here, which would help when browsing between pages,
but we would still have to calculate the tags on the first page load,
which can be very slow in the worst case.
2019-08-12 13:38:45 -05:00
evazion a6163258bf Post.fast_count: skip alias normalization.
Post.fast_count calls Tag.normalize_query to normalize the tag string
used for the pfc cache key. This slightly improves cache sharing at the
expense of an extra query during tag searches. The extra query isn't
worth it.
2019-08-12 13:38:45 -05:00
evazion 30a378865e TagAlias.to_aliased: avoid query on blank arguments.
PostQueryBuilder calls `to_aliased` with empty arguments in some cases.
Return early to avoid a query in those cases.
2019-08-12 13:38:45 -05:00
evazion f268293105 delayed jobs: log to stdout.
Log to stdout because we now run workers under systemd and we want
errors to go to the journal, not to log/production.log.
2019-08-12 13:38:45 -05:00
evazion 7316f41d1d Fix #4106: Allow moderators to IP ban subnets. 2019-08-12 02:12:56 -05:00
evazion 9729eeb829 ip bans: remove unused code. 2019-08-11 23:38:03 -05:00
evazion fa19047220 autocomplete: add username autocompletion sitewide. 2019-08-11 15:38:39 -05:00
evazion cab36c307f upload tags report: clean up tag list rendering. 2019-08-10 23:49:36 -05:00
evazion d76be490f2 Remove tag alias corrections controller tests (fixup 18a216c67). 2019-08-10 23:49:32 -05:00
evazion 18a216c67a Fix #4130: Remove tag alias corrections. 2019-08-10 22:46:49 -05:00
evazion c7bcce429e Fix #4129: Remove tag alias caching. 2019-08-10 22:04:55 -05:00
evazion 96b28a77e7 delayed jobs: drop failed jobs email alert.
Usually when jobs aren't working it's not because the jobs themselves
are failing, it's because the workers crashed and aren't processing jobs
at all.
2019-08-10 12:06:23 -05:00
evazion 072885bbf8 delayed jobs: run dj workers under systemd (fix #4108). 2019-08-10 02:57:32 -05:00
evazion 30401f6599 aliases, implications: fix N+1 query in listing pages. 2019-08-09 00:05:50 -05:00
evazion 4f024d2360 pools/show: fix N+1 query on pool show page.
Fix a N+1 query when fetching posts to render thumbnails. Also adds
support for the `limit` url param on the posts show page.
2019-08-09 00:05:50 -05:00
evazion 6d171f44c4 pools/show: remove unused related tags calculation. 2019-08-09 00:05:50 -05:00
evazion 266259de54 gems: add pry-rails, meta_request, rack-mini-profiler. 2019-08-09 00:05:50 -05:00
evazion 48a4f3c26c application controller: catch more common exceptions. 2019-08-08 22:16:39 -05:00
evazion df433bda9c newrelic: log more request context. 2019-08-08 22:16:39 -05:00
evazion 9a6add9730 newrelic: refactor error logging.
* Factor out New Relic logging to DanbooruLogger class.
* Log all exceptions to New Relic, not just statement timeouts.
2019-08-08 22:16:39 -05:00
evazion 35dfc704bc application controller: fix bad file extension errors.
Fix requests with bad file extensions not always returning errors correctly:

* https://danbooru.donmai.us/posts.jpg
* https://danbooru.donmai.us/posts.blah
* https://danbooru.donmai.us/posts/bad.jpg
* https://danbooru.donmai.us/posts/bad.blah
2019-08-08 22:16:39 -05:00
evazion 8d706f4fd7 session controller: remove dead session[:previous_uri] cookie.
session[:previous_uri] is never set so it's always nil.
2019-08-08 14:00:46 -05:00
evazion 083283906e application controller: remove unused secure_cookies_check. 2019-08-08 14:00:46 -05:00
evazion 50fdb9fe92 Update gems. 2019-08-08 14:00:46 -05:00
evazion 853becbcfc circleci: try to fix the build. 2019-08-08 01:07:57 -05:00
evazion d45e199586 Merge branch 'fix-4123' 2019-08-07 22:39:03 -05:00
evazion bfffb57c13 capistrano: clean up unicorn:terminate task.
Do a SIGQUIT (graceful shutdown, allow workers to finish current
request) before doing a SIGTERM (immediate shutdown).
2019-08-07 22:36:12 -05:00
evazion 5231371100 posts: drop img.ly source normalization.
There are only two posts from this site and the site itself is defunct:

* https://danbooru.donmai.us/posts/1561685
* https://danbooru.donmai.us/posts/1412508
* https://img.ly/ofxl
2019-08-07 22:11:07 -05:00
evazion c225d54de1 capistrano: add deploy:rolling task (fix #4123). 2019-08-07 22:11:07 -05:00
evazion c7cd43d30e Drop unused mrtg view. 2019-08-07 22:11:07 -05:00
evazion 223e5f1e81 capistrano: enable conditional migrations. 2019-08-07 22:11:07 -05:00
evazion 1be4ca5a98 Drop unused gems. 2019-08-07 22:11:07 -05:00
evazion 9996dd40bb capistrano: only log newrelic deployment in production.
Fix local development deployments getting logged in New Relic.
2019-08-07 22:11:07 -05:00
evazion ef68d42dbe Drop unused query tracer code + term-ansicolor gem. 2019-08-07 22:11:07 -05:00
evazion 2beb79166e capistrano: fix git deprecation warning. 2019-08-07 22:11:07 -05:00
evazion 8db9d700ef daily maintenance: fix 'vacuum analyze' failure during tests.
Fixup for 2df6bf41f.
2019-08-06 15:22:08 -05:00
evazion 7f482dc35b deviantart: normalize wixmp.com sources to page urls.
Normalize sources like this:

   https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/ab917938-d8c1-4b58-933d-0d38c390461f/ddcyi98-cbd39da2-f528-4b26-aadb-a16fe91442b2.jpg/v1/fill/w_1280,h_1760,q_100,strp/tifa_by_chubymi_ddcyi98-fullview.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTc2MCIsInBhdGgiOiJcL2ZcL2FiOTE3OTM4LWQ4YzEtNGI1OC05MzNkLTBkMzhjMzkwNDYxZlwvZGRjeWk5OC1jYmQzOWRhMi1mNTI4LTRiMjYtYWFkYi1hMTZmZTkxNDQyYjIuanBnIiwid2lkdGgiOiI8PTEyODAifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6aW1hZ2Uub3BlcmF0aW9ucyJdfQ.Uochlma4QJmLwL2ZGMmvTr4HMva4m4bCeF3vnyPSw4I

to this:

   https://www.deviantart.com/chubymi/art/Tifa-807825644

on the sidebar of the posts show page.
2019-08-06 12:04:05 -05:00
evazion a8896b664d twitter: fix batch bookmarklet selecting wrong image.
Fix regression in 7e465aeda.

https://danbooru.donmai.us/forum_topics/9127?page=276#forum_post_158779
2019-08-06 10:42:45 -05:00
evazion 0c6d9f60bd Remove unused mailers. 2019-08-06 10:42:45 -05:00
evazion b0da649b09 Remove obsolete scripts.
These are mostly old files mostly related to maintenance of Danbooru 1
or the upgrade to Danbooru 2.
2019-08-06 10:42:45 -05:00
evazion 2df6bf41f6 cron: move 'vacuum analyze' to daily maintenance. 2019-08-06 10:42:45 -05:00
evazion 060a585e34 stale.yml: bump timeouts, change wontfix -> stale 2019-08-05 17:52:15 -05:00
evazion 017d7049e7 Merge pull request #4122 from nothink/nginx-configuration-fix
Fix typo in nginx.danbooru.conf
2019-08-05 17:50:19 -05:00
evazion d0c28d79f0 tests: temp disable broken tests.
Broken by bug in shoulda-context-1.2.2. Uncomment after upgrading to
shoulda-context-2.0.0.
2019-08-05 13:41:06 -05:00
evazion 06ad1cbbc1 Fix #3685: Bare layout for error pages. 2019-08-05 11:03:10 -05:00
evazion 3b7ab86750 Fix "You are now logged in.." flash message.
The flash message when logging in contained an extra period.
2019-08-05 11:02:40 -05:00
evazion c03a3b9ce0 Merge pull request #4119 from nothink/debian9_installation
Update INSTALL.debian, for Debian 9(stretch)
2019-08-05 10:02:31 -05:00
evazion b9bb5467b8 Fix #4117: Use memcache for fragment caching. 2019-08-04 21:10:57 -05:00
evazion 7e465aedae Fix #4110: New Twitter image urls are broken in bookmarklet. 2019-08-04 20:23:10 -05:00
evazion f77d305f83 Fix #3250: Show unvote link as applicable upon page load. 2019-08-04 18:58:25 -05:00
evazion 9ecf36585c nijie: update for new image urls.
Nijie moved from this:

    https://pic03.nijie.info/nijie_picture/236014_20170620101426_0.png (page: https://www.nijie.info/view.php?id=218856)

to this:

    https://pic.nijie.net/03/nijie_picture/236014_20170620101426_0.png (page: https://www.nijie.info/view.php?id=218856)
2019-08-04 17:49:54 -05:00
evazion 9163b3cb1c validations: drop superfluous return statements.
Returning true or false in a validation callback doesn't do anything, so
drop these superfluous return statements.
2019-08-04 15:45:05 -05:00
evazion a926b162be models: drop unnecessary presence validations.
In rails 5, belongs_to associations automatically validate that the
associated item is present, meaning that we don't need to validate these
things manually any more.
2019-08-04 14:40:37 -05:00
evazion 7c8c4e9f82 tests: fix null uploader_ip_addr exceptions in create(:post).
Caused by a change in FactoryBot 5. Associations in factories are now
constructed using the same strategy as the base object, meaning that
using `build` to construct an object will also construct the
associations using `build`. This meant that overriding `create` to do
`build` + `save` broke the way that associations were constructed.

https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations
2019-08-04 12:43:12 -05:00
evazion fc4fa9dc6c Fix #4077: Migrate CurrentUser and safe_mode to use RequestStore. 2019-08-04 10:12:59 -05:00
evazion 98d80a0cca Fix #4116: "Couldn't find template for digesting" errors.
Specify full path to shared partial to work around bug in the template
digesting system in Rails.
2019-08-03 17:40:45 -05:00
evazion 39bd766b34 Fix #4053: Add disapproval index improvements.
Add search form to /moderator/post/disapprovals.
2019-08-02 22:03:03 -05:00
evazion 6c69165780 Fix #4105: IP bans leak banned IPs in /mod_actions. 2019-08-01 21:21:18 -05:00
evazion 065609ff4f artists: prevent creating artist entries for non-artist tags (#4107, 2717).
Validate that artist entries belong to an artist tag. Don't allow
creating artist entries for character/copyright/meta tags, but do allow
entries for general tags (the gentag will be automatically changed to an
artist tag).
2019-08-01 20:20:06 -05:00
evazion bcaefa0a7e Fix #4107: Can't create artist entry if tag already has a wiki #4107 2019-08-01 19:34:21 -05:00
evazion 692981e964 Fix #4111: Cache custom CSS. 2019-08-01 00:06:18 -05:00
evazion efc5487dd6 Fix #4109: Censored images leaked in og:image attribute. 2019-07-31 21:47:31 -05:00
evazion 92504cb8f3 Fix #4075: Add non-web_source to default tags removed by replacement. 2019-07-31 20:17:32 -05:00
evazion 504f785edc Fix #4115: Upgrade to webpack 4.x.
https://github.com/rails/webpacker/blob/master/docs/v4-upgrade.md
2019-07-31 20:17:14 -05:00
evazion 9fda456b7d /admin/dashboard: fix exception when rendering BURs.
Fix regression in 6b167d605.
2019-01-26 14:41:33 -06:00
evazion a118ec95a7 dynamic requests: fix editing forum posts containing requests (#3824).
Bug: When editing a forum post (other than the OP) that contained a
dynamic request, the edit form didn't contain the [bur:1234] syntax.
Instead it contained the full body of the request.

This happened because `forum_post.body` was inadvertantly mutated while
rendering the request.

Fixes https://github.com/r888888888/danbooru/issues/3824#issuecomment-454884235.
2019-01-24 14:49:38 -06:00
evazion 1292717c52 dynamic requests: handle deleted/processing/queued statuses (#3824)
Fix bug where [ta:1234] didn't render if the request's status was
'deleted', 'queued', or 'processing'.
2019-01-24 13:52:16 -06:00
evazion 6b167d6055 BURs: add edit and reject links to the BUR show page (#3824). 2019-01-15 21:23:01 -06:00
evazion a284d3fb4a BURs: allow only pending BURs to be rejected.
Fix it being possible to reject approved BURs, or to re-reject already
rejected BURs.

Rejecting an approved BUR wouldn't revert the aliases/implications, but
it would change the BUR's status to rejected.
2019-01-15 21:20:28 -06:00
evazion 971281949f artist versions: tune url similarity threshold (#4036) 2019-01-13 15:40:36 -06:00
evazion 54f562bf1c Fix #4042: Remove source_request by default when replacing posts. 2019-01-13 15:06:30 -06:00
evazion 13dff046f7 pixiv: fix illust id parsing (fixup 8cadef2dd) 2019-01-13 15:02:51 -06:00
evazion 8cadef2dd7 pixiv: fix illust id parsing (fix #4043).
* Tighten up illust id parsing to avoid misparsing ids from
  non-illust urls (sketch urls and novel urls).

* Move id parsing tests from post_test.rb to sources/pixiv_test.rb.

* Drop support for touch.pixiv.net urls. These urls are no longer used
  by Pixiv and aren't present as the source of any posts on Danbooru.
2019-01-13 14:28:51 -06:00
evazion 80f43f9a7c Fix #4038: Attempting to create an IP-ban bans the creator.
* Rename comments.ip_addr to comments.creator_ip_addr.
* Fix belongs_to_creator to not clobber ip_addr field.
2019-01-09 16:20:34 -06:00
evazion 5c54c61d65 Fix #4035: The Related Tag JSON endpoint is returning the wrong information
* Fix /related_tags.json to return a list of tags in the `other_wikis` field.

* Add support for /related_tags.xml.
2019-01-07 13:30:10 -06:00
evazion 04d5b16da7 pixiv: fix failure to upload bad pixiv id images (fix #4031)
Bug: Uploading bad pixiv id images failed because the pixiv strategy
raised a BadIDError exception when the upload service checked for the
ugoira frame data.
2019-01-03 18:01:20 -06:00
evazion 7478c7a913 Fix #4034: Several keyboard shortcuts are missing an ID. 2019-01-03 17:19:16 -06:00
evazion 886096b47a BURs: fix remove alias command removing inactive aliases.
Fix the `remove alias` and `remove implication` commands to only remove
active aliases or implications, not pending/deleted/retired ones.
2019-01-03 16:30:39 -06:00
evazion 82b09860f2 Fix #4032: /tag_aliases page is broken. 2019-01-02 15:55:24 -06:00
evazion d32882e1ee aliases/implications: fix controller tests. 2018-12-31 19:08:15 -06:00
evazion 0ab2dfc5d2 aliases/implications: fix conflicting definitions of active scope. 2018-12-31 19:03:01 -06:00
evazion 17a5db72a6 aliases/implications: allow searching by antecedent or consequent tag type. 2018-12-31 18:55:36 -06:00
evazion fd1c9dbf30 aliases/implications: add active/deleted/processing statuses to search form. 2018-12-31 18:29:25 -06:00