Commit Graph

1475 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
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
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
c710aa3ffb Fix #4177: Allow all users to change their username. 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
e96d3cba78 autocomplete: fix autocomplete triggering after blank space. 2019-09-23 22:30:56 -05:00
evazion
0a6661d145 uploads: switch to active job.
* Switch upload processing from DelayedJob to ActiveJob.
* Remove remaining references to delayed job from tests.

Closes #4128.
2019-09-23 15:11:18 -05:00
evazion
c1bb88a52a tests: fix mock_saved_search_service! calls (fixup 4e4c4d627) 2019-09-23 03:22:32 -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
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
79c22b8d50 Fix #4174: Don't allow invalid prefix combinations for autocomplete.
* Autocorrect duplicated operators (e.g. complete `--tag` as `-tag`).
* Don't accept invalid metatag + prefix combinations (e.g. don't
  complete `char:rating:s` as `rating:safe`).
2019-09-22 18:58:12 -05:00
evazion
9839f97f9e Fix #4176: Ordering favorite groups errors out. 2019-09-22 15:24:23 -05:00
evazion
02354e83fe tests: add autocomplete system tests. 2019-09-17 18:14:33 -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
c85bbbf8c2 comments: fixup "show hidden comments" link.
Fixup for 896f144eb.
2019-09-17 00:28:40 -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
347aa4b835 Add error pages for tag limit and pagination errors. 2019-09-09 17:43:30 -05:00
evazion
059e061b15 tests: fixup comment vote, post controller tests.
Use git clean to delete stale files from an earlier checkout. These
files interfered with various things (specifically, a comment vote test
failed because there was an old comment_votes/create.json.erb template
hanging around that changed the behavior of the POST /comment_votes endpoint).
2019-09-09 15:06:24 -05:00
evazion
d812a19902 tests: fixup tests. 2019-09-09 11:51:01 -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
22fd90eee9 api: support the expiry param on all GET requests. 2019-09-08 15:32:31 -05:00
evazion
3f7e05316d api: refactor default options for xml responses.
In xml responses, if the result is an empty array we want the response
to look like this:

   <posts type="array"/>

not like this (the default):

   <nil-classes type="array"/>

This refactors controllers so that this is done automatically instead of
having to manually call `@things.to_xml(root: "things")` everywhere. We
do this by overriding the behavior of `respond_with` in `ApplicationResponder`
to set the `root` option by default in xml responses.
2019-09-08 15:32:31 -05:00
evazion
32343303d2 forum posts: raise privilege error when viewing restricted topics.
Raise a privilege error when trying to view a restricted topic instead
of handling it in the controller. This way error handling is standardized.
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
258fa06422 tests: replace workoff_active_jobs with perform_enqueued_jobs. 2019-09-07 22:21:55 -05:00
evazion
6b8515811f tags: drop related_tags column. 2019-09-07 22:21:55 -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
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
1b426fb23f Fix #4150: Nijie strategy fails for mp4 files. 2019-09-03 22:33:09 -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
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
f040233a50 tests: fixup ugoira converter test. 2019-09-02 12:20:37 -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
6e7b882dda tests: skip ugoira tests if ffmpeg/mkvmerge not installed. 2019-09-01 13:10:37 -05:00