Commit Graph

6809 Commits

Author SHA1 Message Date
evazion
5df3b01ca2 Fix timeouts in source:<url> searches and bookmarklet.
* Change the source index on posts from `(lower(source) gin_trgm_ops) WHERE source != ''`
  to just `(source gin_trgm_ops)`. The WHERE clause prevented the index
  from being used in source:<url> searches because we didn't specify
  the `source != ''` clause in the search itself. Excluding blank
  sources only saved a marginal amount of space anyway. This fixes
  timeouts in source:<url> searches and in the bookmarklet (since we do
  a source dupe check on the upload page too).

* Also switch from indexing `lower(name)` to `name` on pools and users.
  We don't need to lowercase the column because GIN indexes can be used
  with both LIKE and ILIKE queries.
2019-09-02 18:53:27 -05:00
evazion
ffc693ef37 profiles: temp disable saved searches on profile pages. 2019-09-02 13:43:05 -05:00
evazion
3e85ce8110 Fix searching models by id/created_at/updated_at attributes. 2019-09-02 13:38:00 -05:00
evazion
64eb6dbb2a pixiv: possible fix for #4152. 2019-09-02 13:13:58 -05:00
evazion
777eea85dd related tags: disable safe mode while generating related tags.
Also bump timeouts slightly.
2019-09-02 12:17:45 -05:00
evazion
e781c6b608 pixiv: temp disable source strategy (#4152).
Disable use of the Pixiv API until we get it working again.
2019-09-02 11:13:00 -05:00
evazion
95b8420ba2 Drop unused common_searches code. 2019-09-01 15:54:00 -05:00
evazion
dacb21b085 Drop unused users/_login_header template. 2019-09-01 15:54:00 -05:00
evazion
5b468444e7 Tweak signin / signup pages.
* Link to the signup page on the signin page.
* Clarify that emails are optional on the signup page.
2019-09-01 15:54:00 -05:00
evazion
fe4d90c5e0 settings page: add help text, rearrange settings.
* Remove 'Change password' and 'Delete account' tabs.
* Put 'Change password' under the Basic section.
* Put 'Deactivate account' under the Advanced section.
* Add help text to various settings.
2019-09-01 15:53:59 -05:00
evazion
f673552743 users: add /settings page.
Add /settings page and link to it instead of /users/:id/edit.
2019-09-01 15:00:27 -05:00
evazion
ff92b32f02 users: add /profile page (fix #4151).
* Add /profile, /profile.json endpoints.
* Make "My Account" link to /profile.
* Add 'User ID' field to profile page.
2019-09-01 15:00:23 -05:00
evazion
a932b25608 Fix #4142: Missing images after upload. 2019-09-01 13:10:37 -05:00
evazion
67100f26eb Fix #4149: Add missing post search options on applicable models. 2019-09-01 13:10:37 -05:00
evazion
6e7b882dda tests: skip ugoira tests if ffmpeg/mkvmerge not installed. 2019-09-01 13:10:37 -05:00
evazion
3216f83ad8 users: fix deprecation warning in current_user_first.
DEPRECATION WARNING: Dangerous query method (method whose arguments
    are used as raw SQL) called with non-attribute argument(s): "id =
    52664 desc". Non-attribute arguments will be disallowed in Rails
    6.1. This method should not be called with user-provided values,
    such as request parameters or model attributes. Known-safe values
    can be passed by wrapping them in Arel.sql().
2019-09-01 13:10:37 -05:00
evazion
80d881bfcb Fix #4148: Don't prune votes. 2019-08-31 20:09:41 -05:00
evazion
b77eebf136 /favorites: replace favorites view with ordfav: search.
Make /favorites redirect to a ordfav:<user> search instead of having a
separate view just for favorites. This duplicated a lot of code for no
good reason.
2019-08-31 19:58:38 -05:00
evazion
7f7730d249 /favorites: fixup leftover related tags calculator code.
Fixup for 6dd331745.
2019-08-31 19:58:38 -05:00
evazion
ee77b101af comments: change 'Show all comments' to 'Show N hidden comments'. 2019-08-31 16:32:15 -05:00
evazion
be36968b6d Fix #3351: Mod+: Treat deleted comments as below score threshold.
Comments have three states: visible, hidden, and invisible. Visible
comments are always shown. Hidden comments are not shown until the user
clicks 'Show all comments'. Invisible comments are never shown to the
user. Deleted comments are treated as hidden for moderators and
invisible for normal users. Thresholded comments are treated as hidden
for all users.
2019-08-31 16:24:44 -05:00
evazion
836ec02265 Fix #4147: Remove non-relevant bookmarklet info. 2019-08-30 22:19:20 -05:00
evazion
6dd331745a Rewrite related tags implementation.
Rewrite the implementation of related tags to be simpler, faster, and
more accurate:

* The related tags are now calculated by taking a random sample of 1000
  posts, finding the top 250 most frequent tags among those posts, then
  ordering those tags by cosine similarity.

* Related tags can generally be calculated in 50-300ms at these sample
  sizes. Very high sample sizes (25000+ posts) are still relatively fast
  (1-3 seconds), but generally they don't improve accuracy much.

* Related tags are now cached in redis rather than in the tags table.
  The related_tags column in the tags table is no longer used.

* Only the related tags in the search taglist are cached. The related
  tags returned by the 'Related tags' button are not cached.

* The cache lifetime is a fixed 4 hours.

* The 'Related tags' button now works with metatags.

* The /related_tag page now works with metatags and multitag searches.

Fixes #4134, #4146.
2019-08-30 20:03:36 -05:00
evazion
7b8584e3b0 Model#search: refactor searching for attributes. 2019-08-29 20:44:33 -05:00
evazion
6fc4b63fa8 Model#search: factor out post_tags_match. 2019-08-29 20:44:33 -05:00
evazion
c3ad7f6112 Model#search: factor out username search. 2019-08-29 20:44:27 -05:00
evazion
9a3e9747d8 users: replace scopes with associations. 2019-08-29 20:42:50 -05:00
evazion
8756480500 search: drop special case for pixiv urls in source: metatag.
* Drop support for `source:pixiv/artist-name` searches. This was a hack
  that only worked on old pixiv urls that haven't been used for years.
* Replace the old SourcePattern(lower(source)) index with a trigram index.
2019-08-29 02:06:35 -05:00
evazion
65e53b86b3 Drop support for /cache/tag.json.
Drop support for https://danbooru.donmai.us/cache/tags.json. This was a
nightly dump of the tags table that was originally added in #1012. It
was never documented and never really used except for by the DanbooruUp
extension.
2019-08-29 00:52:23 -05:00
evazion
d56b56a6a1 Drop post updates table. 2019-08-29 00:52:23 -05:00
evazion
d73895312e Avoid swallowing exceptions unnecessarily. 2019-08-29 00:51:52 -05:00
evazion
eba6440b8b Fix #4144: Deviantart Eclipse update broke strategy. 2019-08-28 23:40:29 -05:00
evazion
eb94bf366b newrelic: fixup nil derefs during SessionLoader::AuthenticationFailed errors. 2019-08-27 22:53:39 -05:00
evazion
0cf9f845d0 newrelic: fix tracking of api auth failure errors.
Fixes user params not being recorded on SessionLoader::AuthenticationFailed errors.
2019-08-27 21:19:56 -05:00
evazion
371182b102 sessions: fix session started_at tracking. 2019-08-27 14:22:50 -05:00
evazion
27be15ce7a related tags: disable csrf protection for update action.
This fixes InvalidAuthenticityToken errors caused by Reportbooru trying to
use this endpoint to update related tags. Reportbooru uses a secret key
to authenticate rather than using apikey-based authentication, which
makes it fail the CSRF protection.
2019-08-27 14:20:20 -05:00
evazion
a3d748e300 Fix #4145: Unable to view deleted comments from post page.
Bug: if all the comments on a post were deleted then the deleted
comments wouldn't be visible to moderators.

This was because we assumed that if `last_commented_at` was nil it meant
that the post had no comments, but this was wrong. `last_commented_at`
only counts undeleted comments. It's reset to nil if all the commnets
have been deleted.
2019-08-26 13:50:42 -05:00
evazion
fa37d7c156 pool orders: raise limit for order page to <1000 posts. 2019-08-26 13:50:02 -05:00
evazion
e147a34664 pool orders: disable drag-and-drop ordering for pools with >100 posts.
Previously if a pool had >100 posts then the 'Order' link wouldn't
appear in the navbar, but it was still possible to visit the pool order
page directly. If a user did so, only the first 100 posts in the pool
would be shown in the drag-and-drop widget. If they tried to reorder the
pool anyway, then everything beyond the first 100 posts would be
silently removed from the pool.

Now we always show the 'Order' link, but we disable the drag-and-drop
reordering widget when the pool has >100 posts to prevent posts from
being silently removed.
2019-08-25 21:28:32 -05:00
evazion
edc0c9df32 Fix exception in /pools/:id/order/edit. 2019-08-25 21:06:16 -05:00
evazion
86fa502c71 login page: remove 'sign in securely' link.
This link is unnecessary since Danbooru is now HTTPS-only.
2019-08-25 20:32:25 -05:00
evazion
0df5c0fd2b Replace deprecated update_attributes with update.
https://rubyinrails.com/2019/04/09/rails-6-1-activerecord-deprecates-update-attributes-methods/

DEPRECATION WARNING: update_attributes! is deprecated and will be removed from Rails 6.1 (please, use update! instead)
2019-08-25 20:29:32 -05:00
evazion
62875eabb2 /posts.atom: fix banned posts being visible to Members.
Bug: /posts.atom only hid loli/shota, not banned posts and not unsafe
posts when safe mode was on.
2019-08-25 20:29:32 -05:00
evazion
0101b5f5f4 danbooru default config: remove unused config settings. 2019-08-25 20:29:32 -05:00
evazion
8e39985d66 app controller: fix api responses on access denied errors.
Bug: A .json/.xml/.js request that resulted in an access denied error
returned a html response instead of a .json/.xml/.js response.
2019-08-25 20:29:32 -05:00
evazion
c7f8fbbec2 app controller: standardize access denied error handling.
Refactor to use `render_error_page` to handle User::PrivilegeError
exceptions. This way these exceptions are logged to New Relic.

Changes:

* Anonymous users aren't automatically redirected to the login page.
  Instead they're taken to the access denied page, which links to the
  login/signup pages.

* JSON/XML error responses return `message` instead of `reason`.
2019-08-24 23:10:22 -05:00
evazion
d4c43af1dd app controller: replace calls to access_denied with PrivilegeError.
Standardize controllers to raise User::PrivilegeError instead of calling
`access_denied` directly.
2019-08-24 23:10:22 -05:00
evazion
fda9843a55 app controller: standardize auth failure error handling. 2019-08-24 22:55:36 -05:00
evazion
bb7c993f4a app controller: clean up helpers.
* Move `show_moderation_notice?` out.
* Don't need to declare `helper :pagination` manually.
2019-08-24 22:55:36 -05:00
evazion
491cae6c60 app controller: standardize api limit error handling.
* Refactor api_check to use render_error_page so that api limit errors
  get logged to New Relic for analysis.

* Also standardize json error responses to return the error message in
  `message` instead of `reason`.
2019-08-24 22:55:36 -05:00