Commit Graph

2187 Commits

Author SHA1 Message Date
evazion
dc712258cf Revert "Temp disable popular tags and news banner."
This reverts commit f9a44ab192.
2020-11-12 20:15:45 -06:00
evazion
7f90bc4216 BURs: remove ability to skip secondary validations.
Remove the ability to skip secondary validations when creating a BUR.
The only skippable validation that still existed was the requirement
that both tags in an implication must have wiki pages. It's now
mandatory to write wiki pages for tags before you can request an
implication. This doesn't apply to empty tags.
2020-11-12 20:15:14 -06:00
evazion
25cba710bf BURs: don't allow requesting implications that already exist.
Fix it being possible to request duplicate implications.
2020-11-12 20:15:14 -06:00
evazion
654d2175b6 aliases/implications: remove processing state.
Remove the `processing` state from aliases and implications. This state
was used to mark when an alias or implication had been approved but the
alias or implication was still being processed. Aliases in the
processing state were still considered active, so there was no
functional difference between the active state and the processing state.

This fixes a problem where it was possible for implications to get stuck
in the processing state. This happened when a BUR contained a duplicate
implication. Transitioning from the processing state to the active state
failed in this case because we used `update` instead of `update!`, which
meant validation errors were silently ignored.
2020-11-12 18:22:51 -06:00
evazion
5844f16ed6 BURs: make rename command move aliases/implications.
Make the tag rename command also move any aliases or implications from
the old tag to the new tag. Previously only the create alias command
moved aliases and implications.
2020-11-12 17:12:09 -06:00
evazion
9a287cd71f Fix #4483: Wrong order for BUR caused 12k mistags.
Bug: if a BUR contained a mass update followed by an alias, then the
alias would become active before the mass update, which could cause
the mass update to return incorrect results if both the alias and mass
update touched the same tags.

This happened because all aliases and implications in the BUR were set
to a queued state before the mass update was processed, but putting an
alias in the queued state effectively made it active.

The fix is to remove the queued state. This was only used anyway as a
debugging tool anyway to monitor the state of BURs as they were being
processed.
2020-11-12 16:09:56 -06:00
evazion
f9a44ab192 Temp disable popular tags and news banner.
Emergency measure to to reduce load on Redis.
2020-11-09 13:33:24 -06:00
evazion
f2d611ba69 reportbooru: raise http timeout.
Fetching missed searches from Reportbooru sometimes failed because the
0.5 second HTTP timeout was too low.
2020-09-21 13:29:53 -05:00
evazion
0e688f8e65 reportbooru: decrease http timeout, increase cache length.
Decrease the HTTP timeout to 0.5 seconds when fetching popular tags from
Reportbooru. Increase the length of time that popular tags are cached
from 1 minute to 1 hour. This is for the list of popular searches in the
front page sidebar.
2020-09-14 12:53:41 -05:00
evazion
5dd3027d0c Revert "posts: disable popular searches in sidebar."
This reverts commit c830973bd4.
2020-09-14 12:49:22 -05:00
evazion
c830973bd4 posts: disable popular searches in sidebar. 2020-09-04 14:25:51 -05:00
evazion
6320db2541 BURs: fix rewriting wiki links with qualifiers.
When renaming a tag and the new tag has a qualifier, use the pipe trick
to hide the qualifier in wiki links. For example, renaming Fallout to
Fallout_(series) should change wiki links from [[Fallout]] to [[Fallout
(series)|]].
2020-08-28 13:57:18 -05:00
evazion
b37fa87d4b posts: fix bug preventing *_(cosplay) tags from being added.
Bug: if `hatsune_miku` is an empty general tag, then tagging a post with
`hatsune_miku_(cosplay)` would fail because `hatsune_miku` wasn't a
character tag. This could cause tagging posts to fail when aliasing a
character tag back to an old name that was used in the past, but was now
an empty general tag.

Fix: only treat the *_(cosplay) tag as being in conflict with the base
tag when the base tag is nonempty.
2020-08-27 22:39:16 -05:00
evazion
b9d904ac76 BURs: move cosplay tags when moving character tags.
When aliasing or renaming a character tag, move the corresponding
*_(cosplay) tag if it exists.
2020-08-27 21:38:26 -05:00
evazion
23944a1794 Fix #4491: Have tag rename option for bulk update requests.
* Add a `rename A -> B` command for bulk update requests.
* Change mass updates to only retag the posts, not to move saved
  searches or blacklists.

A tag rename does the same thing an alias does, except it doesn't
create a permanent alias. More precisely, a tag rename:

* Moves the wiki.
* Moves the artist entry.
* Moves saved searches.
* Moves blacklists.
* Merges the wikis, if both tags have wiki pages.
* Merges the artist entries, if both tags have artist pages.
* Fixes links in wiki pages to point to the new tag.
* Retags the posts.
2020-08-26 19:53:04 -05:00
evazion
bbf2b53d83 aliases: fix broken wiki links when aliasing tags.
When aliasing A to B, update any wikis linking to [[A]] to link to [[B]]
instead.

This is a best-effort process based on rough heuristics. There are a few
known problems:

* We don't always know how to capitalize the new tag. We try to mimic
  the capitalization of the old tag, such that if the old tag was
  capitalized (because it was at the beginning of a sentence), or if
  every word in the old link was capitalized (because it's a proper
  noun), then the new link will be capitalized in the same way. This can
  handle simple general tags and character tags, but will fail for
  copyright tags with mixed capitalization. For example, we don't know
  that [[jojo_no_kimyou_na_bouken]] should be capitalized as [[JoJo no
  Kimyou na Bouken]]. If we don't know how to capitalize the new tag, we
  leave the old tag as-is so it can manually be fixed.

* Some aliases might require changing how a tag is pluralized. If we
  changed [[rat]] to [[mouse]], then we should change `[[rat]]s` to
  [[mice]]. We don't try to deal with this.

* In general, some changes might require entire sentences to be
  rewritten to keep the grammar correct. Changing something like
  [[skirt lift]] to [[lifting skirt]] could break the grammar of the
  sentence. We don't try to deal with this.
2020-08-26 19:02:19 -05:00
evazion
f4f25cf0c8 aliases: fix blacklists when aliasing tags.
When aliasing a tag, update any blacklists containing the old tag to use
the new tag.
2020-08-26 17:06:00 -05:00
evazion
f0299a8945 aliases: refactor tag moving code.
* Factor out the code for moving tags from tag aliases to a separate
  TagMover class.

* When aliasing two tags that have conflicting wikis, merge the old wiki
  into the new one instead of failing with an error. Merge the other names
  fields, replace the old wiki body with a message linking to the new
  wiki, and mark the old wiki as deleted.

* When aliasing two tags that have conflicting artist entries, merge the
  old artist into the new one instead of silently ignore the conflict.
  Merge the group name, other names, and urls fields, and mark the old
  artist as deleted.

* When two tags have conflicting wikis or artist entries, but the old
  wiki or artist entry is deleted, then just ignore the old wiki or
  artist and don't try to merge it.

* Fix it so that when saved searches are rewritten, we rewrite negated
  searches too.
2020-08-26 17:05:41 -05:00
evazion
44402299ec BURs: remove unused alternate forms of commands.
Remove the following alternate forms of commands:

* aliasing A -> B
* unaliasing A -> B
* implicating A -> B
* implicate A -> B
* unimplicating A -> B
* unimplicate A -> B
* updating A -> B
* change A -> B

The following forms are accepted:

* create alias A -> B
* alias A -> B
* create implication A -> B
* imply A -> B
* remove alias A -> B
* unalias A -> B
* remove implication A -> B
* unimply A -> B
* update A -> B
2020-08-24 18:00:35 -05:00
evazion
d9085877be BURs: fix normalization of uppercase characters in scripts.
Only downcase tags in aliases, implications, and category change
commands. Don't downcase mass update commands. Mass updates are
potentially case sensitive (for example: `mass update source:imageboard -> source:Imageboard`).
2020-08-24 17:54:53 -05:00
evazion
1ddcc661e1 BURs: clean up parsing and error handling.
* Don't raise exceptions when a BUR is invalid. Instead, use Rails
  validations to return errors. Fixes invalid BURs potentially raising
  exceptions in views. Also makes it so that each error in a BUR is
  reported, not just the first one.

* Revalidate the BUR whenever the script is edited, not just when the
  BUR is created. Ensures the BUR can't be broken by editing. Fixes a bug
  where forum threads could be broken by someone editing a BUR and
  breaking the syntax, thereby causing the BUR to raise an unparseable
  script error when the forum thread was viewed.

* Validate that removed aliases and implication actually exist.

* Validate that the tag actually exists when changing a tag's category.

* Combine bulk update request processor unit tests with main bulk update
  request unit tests.
2020-08-24 17:10:48 -05:00
evazion
49c15e1de7 artists: blacklist reddit.com from artist finder. 2020-08-20 20:09:07 -05:00
evazion
1d2a8a7898 fanbox: don't raise error on age-restricted posts.
Prevent age-restricted fanbox posts from raising errors when source data
is fetched. This prevents error messages from being shown to users when
switching to the edit tab on a post.

This will cause uploads of age-restricted posts to fail with an
unrelated error because we either can't find the image url (if we were
given only the html page) or we can't download the image (because we're
not logged in to Fanbox).
2020-08-18 15:34:12 -05:00
evazion
70b82010a7 search: fix info leak when searching nested associations.
Fix an exploit in #4553. It was possible to use nested searches to infer
the contents of private forum posts.

For example:

* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=h*
* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=he*
* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=hel*
* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=hell*
* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=hello*

The above searches returned the user 'albert', indicating that the
private forum post with id 121683 starts with the word 'hello'.

By guessing the id of a private forum post (which can be done by
searching for gaps in the id sequence), and by guessing text within the
post (which can be done by sequentially guessing characters with
wildcard searches), one could eventually infer the full text of a
private forum post.

The fix is to make nested searches only return records that are visible
to the current user.
2020-08-18 15:21:39 -05:00
evazion
86c376e90d Merge pull request #4590 from nonamethanks/nijie_doujinshi
Nijie: Add doujin support
2020-08-18 14:59:18 -05:00
evazion
0c96c2172c Merge pull request #4577 from nonamethanks/fanbox
Add (partial) fanbox support
2020-08-18 14:13:43 -05:00
BrokenEagle
36fa8efcd5 Fix parameter hash detection
Hash-like objects will respond to each_value, whereas arrays do not.
2020-08-18 05:34:14 +00:00
evazion
4b18361aaf tumblr: fix uses of $ in regexes. 2020-08-17 15:31:18 -05:00
evazion
160b099445 sources: use http client from base strategy. 2020-08-17 15:30:01 -05:00
evazion
5db11a0b5f Merge branch 'master' into attribute-searching 2020-08-17 14:23:00 -05:00
evazion
d9f0a1c5e3 Merge pull request #4585 from nonamethanks/fix_tumblr
Tumblr: support highest res for new image urls
2020-08-17 14:11:48 -05:00
evazion
8f1276b013 appeals: crosspost appeals to deletion appeal thread.
Crosspost pending appeals to the deletion appeal thread. We do this once
per hour so we can batch together multiple appeals into one post.
2020-08-16 17:19:04 -05:00
nonamethanks
e3fd3f42cc Nijie: Add doujin support 2020-08-15 09:29:29 +02:00
evazion
c002166801 Fix #4584: Disable deleted post filter when searching for status:appealed. 2020-08-14 22:05:19 -05:00
nonamethanks
5615719218 Tumblr: support highest res for new image urls 2020-08-14 01:23:27 +02:00
evazion
fbac2cd167 uploads: make early deletions cost more upload slots.
If a pending post is manually deleted before the 3 day moderation period
is up, then make it cost 5 upload slots until the 3 day period is up.
This means that if a new user uploads 3 bad posts that get manually
deleted, then all of their upload slots will be used and they won't be
able to upload again until 3 days have passed.
2020-08-12 21:31:30 -05:00
evazion
78b9613498 Fix #4554: Searches with "-status:active" not showing deleted posts.
Also fixes #4542: Quoted search metatag status:"deleted" yields no results.
2020-08-12 20:53:14 -05:00
evazion
d884cb6642 search: fix parsing of quoted metatag values.
* Fix #4552: Multiple quoted search terms not parsed correctly.
* Allow quotes to be escaped in quoted metatags.
* Allow spaces to be escaped in unquoted metatags.
* Allow the empty string to be used in metatags.

Examples:

* `source:""` and `source:''` (same as `source:none`)
* `source:foo\ bar\ baz` (same as `source:"foo bar baz"`)
* `source:"don't say \"lazy\""` (use \" to write a literal ")
* `source:'don\'t say "lazy"'` (use \' to write a literal ')
* `source:"C:\\Windows"` (use \\ to write a literal \)
2020-08-12 18:12:16 -05:00
evazion
5917587fd5 http: add logger for debugging purposes.
Usage: Danbooru::Http.new.use(:logger).get(url).
2020-08-12 13:11:33 -05:00
evazion
0297b631fb moderation: extract 3 day modqueue length to config. 2020-08-12 13:11:22 -05:00
evazion
58179fce00 Merge pull request #4579 from nonamethanks/fix_4564
Upload limit: don't display progress in tooltip when maxed out
2020-08-12 09:46:44 -05:00
evazion
a70c4a72e6 Merge pull request #4570 from nonamethanks/fix_4543
Nijie: fix login
2020-08-12 09:46:09 -05:00
nonamethanks
bc8fc1839f Upload limit: don't display progress when maxed out 2020-08-11 04:24:16 +02:00
nonamethanks
9a7a1e20ca Add fanbox support 2020-08-09 00:21:57 +02:00
evazion
e8dcc9c56e appeals: raise appeal limits.
The old limit was one appeal per day. The new limit is based on your
upload limit. Each appeal costs 3 upload slots. If you have 15 upload
slots, then you can appeal up to 5 posts at once, but you won't be able
to appeal or upload more until your appeals are approved or rejected. If
you have unlimited uploads, then you have unlimited appeals.
2020-08-08 12:39:20 -05:00
evazion
3a17b5a13e flags/appeals: replace is_resolved flag with statuses.
Replace references to the `is_resolved` field with the `status` field.
Post flags were marked as resolved when a post was approved (but not
when the post was deleted because it went unapproved). The status field
supercedes the resolved field.
2020-08-07 19:24:57 -05:00
evazion
2b0cd3c90b searchable: add support for searching enum fields.
Allow searching enum fields by string, by id, or by array of
comma-separated values. The category field in modactions is an example
of an enum field that can be searched this way.
2020-08-07 19:24:57 -05:00
evazion
85b04887d2 maintenance: fix tag counts hourly instead of daily (#4572). 2020-08-07 09:14:31 -05:00
evazion
8917cc3035 maintenance: prune posts hourly instead of daily. 2020-08-07 09:10:00 -05:00
evazion
3b73861d05 maintenance: fix undefined current user exception.
Possible fix for this exception that happens in production for unclear
reasons:

    NoMethodError: undefined method `is_admin?' for nil:NilClass
    …oru/releases/20200805193154/app/policies/tag_policy.rb:    3:in `can_change_category?'
    …www/danbooru/releases/20200805193154/app/models/tag.rb:  216:in `find_or_create_by_name'
    …www/danbooru/releases/20200805193154/app/models/tag.rb:  193:in `block in create_for_list'
    …www/danbooru/releases/20200805193154/app/models/tag.rb:  193:in `map'
    …www/danbooru/releases/20200805193154/app/models/tag.rb:  193:in `create_for_list'
    …ww/danbooru/releases/20200805193154/app/models/post.rb:  463:in `normalize_tags'
2020-08-07 09:06:23 -05:00