Commit Graph

2543 Commits

Author SHA1 Message Date
evazion
d29bbbbd71 Fix #4178: add ability to mass undo tag edits.
Adds checkboxes to the /post_versions index allowing you to select and
undo multiple versions at once.
2019-09-27 21:02:32 -05:00
evazion
9000bc5cc6 Fix ApplicationRecord#search_attribute (fixup 2b4ee0ee).
`column.array?` failed when the column was actually an association.
2019-09-27 21:02:32 -05:00
evazion
6f0b58ad49 tags: fix typo in order_similarity (fixup 8de692580). 2019-09-26 22:14:48 -05:00
evazion
2b4ee0ee8f post versions: add ability to search post versions by tags.
* Add ability to search /post_versions by added tags, removed tags, or
  changed tags (added or removed).

* Add 'History' link to the sidebar of the /posts index. This is a
  shortcut for a /post_versions search of the current tag.
2019-09-26 22:14:29 -05:00
evazion
12de26d2cf post versions: add more search options to /post_versions/search. 2019-09-26 16:35:05 -05:00
evazion
eff6480699 user name changes: require confirmation of new name. 2019-09-25 22:16:06 -05:00
evazion
07f706e75f user name changes: don't create feedback or modaction.
Don't create a neutral feedback, create a mod action, or dmail the user
after changing a user's name. The name change is already recorded in
/user_name_change_requests, so creating feedbacks and mod actions is
redundant. They also expose private information (when a user deletes
their account, old name changes aren't supposed to be visible any more).
2019-09-25 21:43:01 -05:00
evazion
3b63f94968 user name changes: remove unused reason, status fields.
Remove all infrastructure around approving or rejecting user name
changes. Name changes haven't been moderated for several years.

* Remove status, approver_id, change_reason, and rejection_reason fields.
* Remove approve and reject controller actions.
2019-09-25 21:43:01 -05:00
evazion
bc34fb16a4 tags: automatically fix incorrect tag counts during maintenance.
* Automatically fix all tags with incorrect counts during daily
  maintenance (previously only tags with negative counts were fixed).
* Log fixed tags to NewRelic.
* Remove the ability to manually fix tag counts with the "Fix" button on
  the /tags listing. This is no longer necessary now that tags are
  fixed automatically.
2019-09-25 17:57:11 -05:00
evazion
03d9b3feca pixiv: support new https://www.pixiv.net/artworks/:id urls. 2019-09-24 03:33:21 -05:00
evazion
8de6925807 Fix raw sql deprecation warning in tag autocomplete.
DEPRECATION WARNING: Dangerous query method (method whose arguments
    are used as raw SQL) called with non-attribute argument(s): "trunc(3
    * similarity(name, 'two')) 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(). (called from order_similarity at
    /home/admin/src/danbooru/app/models/tag.rb:817)
2019-09-23 13:52:21 -05:00
evazion
05e754eba3 users: change default user level to member in database.
Fixup for 9c34d5cc3. Default to member level in the database because
setting it in `customize_new_user` clobbered user levels set by factory
bot in tests, which broke the test suite.
2019-09-23 02:22:54 -05:00
evazion
09972477cd users: fix find_by_name for names with special characters.
`User.find_by_name` used `where_ilike` to do a case-insensitve name
search, but it didn't escape `*` or `\` characters first, so it didn't
handle names containing these characters properly.
2019-09-23 00:03:11 -05:00
evazion
a164951b54 saved searches: add more order options (#4171). 2019-09-22 23:38:48 -05:00
evazion
a5949a4b28 saved searches: always show 'Saved searches' link in navbar.
* Always display 'Saved searches' link in subnav bar, even if the user
  hasn't created any saved searches yet.
* Eliminate use of `has_saved_searches` bitpref on users.
2019-09-22 23:14:55 -05:00
evazion
4e4c4d627e saved searches: remove option to disable saved searches.
Remove `SavedSearch.enabled?` checks. There's no need to make saved
searches optional, since Redis is now required to run Danbooru.
2019-09-22 23:04:22 -05:00
evazion
5f43401b7b Fix #4175: Twitter no longer redirects tweet links for non-existent handles. 2019-09-22 02:58:09 -05:00
evazion
d15b29c0cc users: include current theme in /profile.json. 2019-09-19 15:57:53 -05:00
evazion
bf51d68f15 users: add dark mode account setting (fix #4158). 2019-09-19 13:20:06 -05:00
evazion
ca4cba7635 views: remove tag size indicator bars from /tags.
Remove tag size indicator bars. These bars don't play nicely with dark
mode and aren't all that useful to begin with.
2019-09-19 12:57:56 -05:00
evazion
9c34d5cc39 users: fix default user level in test env.
Bug: in the test environment, new users defaulted to the Anonymous level
instead of the Member level. This broke signing up as a new user with
Capybara during system tests.
2019-09-17 18:15:36 -05:00
evazion
e3ae87cff7 Fix #4168: Ignore validations when rejecting tag changes.
* Only check for conflicts with existing aliases/implications when
  requests are created or approved, not when requests are rejected.

* Use `update!(status: "deleted")` instead of `update(status: "deleted")`
  so that if rejecting the request fails we fail immediately instead of
  continuing on and updating the forum topic.

* Wrap `reject!` and `TagChangeRequestPruner.reject_expired` in
  transactions so that if updating either the request or the forum
  fails, they both get rolled back.
2019-09-17 01:30:28 -05:00
evazion
372fd7df1b /pool_versions: fix exception in pool diffs.
https://danbooru.donmai.us/forum_topics/9127?page=280#forum_post_159633
2019-09-10 15:13:06 -05:00
evazion
d812a19902 tests: fixup tests. 2019-09-09 11:51:01 -05:00
evazion
6595a9f87e users: raise max posts per page to 200. 2019-09-08 23:34:49 -05:00
evazion
964a073ec3 Fix #4159: Add pool history to post show pages. 2019-09-08 23:28:02 -05:00
evazion
763ac1a7e0 pools: stop maintaining pool category pseudotags in pool strings (#4160)
Stop maintaining pool category pseudo tags (pool:series, pool:collection)
in pool strings. They're no longer used and the changes to the
`Post#pools` method in dc4d2e54b caused issues with this.

Also allow Members to change the category of large pools again. This was
only restricted because maintaining these pseudotags forced us to update
every post in the pool whenever a pool's category was changed.
2019-09-08 23:28:02 -05:00
evazion
d0f060d8eb api: refactor api attribute declarations.
Replace the `method_attributes` and `hidden_attributes` methods with
`api_attributes`. `api_attributes` can be used as a class macro:

    # include only the given attributes.
    api_attributes :id, :created_at, :creator_name, ...

    # include all default attributes plus the `creator_name` method.
    api_attributes including: [:creator_name]

or as an instance method:

    def api_attributes
       [:id, :created_at, :creator_name, ...]
    end

By default, all attributes are included except for IP addresses and
tsvector columns.
2019-09-08 23:28:02 -05:00
evazion
19f2cc1e74 api: refactor only param. 2019-09-08 23:28:02 -05:00
evazion
24202d51f0 api: support the expires_in param on all GET requests.
`expires_in` is an alternative to `expiry` that supports durations other
than days:

* https://danbooru.donmai.us/posts.json?expires_in=30s
* https://danbooru.donmai.us/posts.json?expires_in=5min
* https://danbooru.donmai.us/posts.json?expires_in=1hour
* https://danbooru.donmai.us/posts.json?expires_in=1week
* https://danbooru.donmai.us/posts.json?expires_in=1month
2019-09-08 15:32:31 -05:00
evazion
31c7386b9e posts: fixup set_pool_category_pseudo_tags on new posts.
Calling set_pool_category_pseudo_tags before saving the post doesn't
work on new posts because they don't have an id yet, so trying to get
the pools by post id in `Post#pools` fails.
2019-09-08 15:32:31 -05:00
evazion
dc4d2e54b2 pools: stop using the pool_string field (#4160).
Stop using the pool_string field internally, but keep maintaining it
until we can drop it later.

* Stop using the pool_string for `pool:<name>` metatag searches.
* Stop using the pool_string in the `Post#pools` method. This is used to
  get the list of pools on post show pages.
2019-09-08 00:11:57 -05:00
evazion
57a61ca586 posts/show: avoid extra queries when rendering pool list. 2019-09-07 22:30:04 -05:00
evazion
4fc1e16731 pools: add more name validations.
These validations should never fail because normalize_name strips
leading/trailing underscores, consecutive underscores, and unicode
whitespace.
2019-09-07 22:10:25 -05:00
evazion
886ee16911 pools: allow searching pools by post tags.
Find all pools containing at least one post tagged 'translated':

    https://danbooru.donmai.us/pools?search[post_tags_match]=translated
2019-09-06 17:54:07 -05:00
evazion
a9b7503aa7 pools: allow searching pools by post id or post count.
All pools containing post #1:

    https://danbooru.donmai.us/pools?search[post_ids_include]=1

All pools containing either post #1 or #2:

    https://danbooru.donmai.us/pools?search[post_ids_include]=1,2
    https://danbooru.donmai.us/pools?search[post_ids_include]=1+2

Pools with 1-100 posts:

    https://danbooru.donmai.us/pools?search[post_id_count]=1..100

Pools with no posts (empty pools):

    https://danbooru.donmai.us/pools?search[post_id_count]=0
2019-09-06 16:18:29 -05:00
evazion
7d07b5f289 artist: drop unused member_names method. 2019-09-06 16:18:29 -05:00
evazion
3af352c76a Fix #4154: Saved searches can be cached indefinitely. 2019-09-05 00:08:00 -05:00
evazion
fc3b822bdf artists: reduce queries in artist summaries.
Avoid a few queries when searching for single artist tags.
2019-09-05 00:00:15 -05:00
evazion
416f817f6d Post.fast_count: fix incorrect counts for aliased tags.
Revert optimization from a6163258b. Turns out that we have to resolve
aliases in fast_count, otherwise for aliased tags we'll return an empty
count.

Fixes #4156.
2019-09-04 23:56:12 -05:00
evazion
0ec36785f0 uploads: don't clean up replaced files too early.
Don't try delete files belonging to completed uploads during pruning. If
an uploaded post was replaced shortly after upload, then the original
file could get deleted during pruning since it's no longer in use, but
this isn't supposed to happen until the replacement grace period (30
days) is over.
2019-09-04 14:49:52 -05:00
evazion
3e2affb501 saved searches: fix refreshed_at, cached_size to use right key. 2019-09-03 11:48:00 -05:00
evazion
d5a2ed65f8 saved searches: add 'created' and 'posts' columns to index page. 2019-09-02 22:27:25 -05:00
evazion
05d8a05106 saved searches: add 'last refreshed' column to index page. 2019-09-02 22:10:16 -05:00
evazion
2841f0742c saved searches: fix failure when search returns no results.
* Don't try to call `sadd` when a search returns no results (`sadd`
  fails in this case).
* Add a timeout when populating the search.
* Don't offload the search to read replica. The main db is fine.
* Disable synchronous population of searches. This was too slow.
2019-09-02 22:10:10 -05:00
evazion
4abffc7faa saved searches: paginate index page + add search form. 2019-09-02 22:10:03 -05:00
evazion
1e0aadb6e7 Fix /uploads?search[uploader_name] not filtering by uploader name.
Caused by `relation = self` in `search_post_id_attribute`.
2019-09-02 19:53:47 -05:00
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
3e85ce8110 Fix searching models by id/created_at/updated_at attributes. 2019-09-02 13:38:00 -05:00
evazion
a932b25608 Fix #4142: Missing images after upload. 2019-09-01 13:10:37 -05:00