Commit Graph

9446 Commits

Author SHA1 Message Date
evazion
35824c9e45 posts: remove AddThis widget.
AddThis apparently pulls in a script from z.moatads.com now. Fuck that.
2020-04-23 13:38:24 -05:00
evazion
18685ae5ae search: fixup broken class method references.
Fixup for 3dab648d0.
2020-04-23 13:38:19 -05:00
evazion
dd0d9dff4a search: move misc search parsing helpers to PostQueryBuilder.
* Move various search parser helper methods (`has_metatag?`,
  `is_single_tag?` et al) from PostSets and the Tag model to
  PostQueryBuilder.

* Fix various minor bugs stemming from trying to check if a search query
  contains certain metatags using regexes or other adhoc techniques.
2020-04-23 01:51:30 -05:00
evazion
3dab648d0e search: refactor PostQueryBuilder class methods into instance methods.
* Make scan_query, parse_query, normalize_query into instance methods
  instead of class methods. This is to a) clean up the API and b)
  prepare for moving certain tag utility methods into PostQueryBuilder.

* Fix a few cases where a caller used scan_query when they should have
  used split_query or parse_tag_edit.
2020-04-22 19:38:17 -05:00
evazion
d355c0e221 search: fix various metatag search issues.
* Support negating the child: and embedded: metatags.
* Fix approver:<any|none>, disapproved:<reason>, commentary:<type> being
  case sensitive.
* Fix child:garbage, locked:garbage, embedded:garbage returning all
  posts instead of no posts.
* Fix not being able to use source:, locked:, or -id: twice in the same
  search.
2020-04-22 18:28:19 -05:00
evazion
a471cdd81e tests: fix email verification tests. 2020-04-21 16:06:42 -05:00
evazion
a93a902982 posts/index: only show tag change notices for members.
This is to reduce Redis calls per second.
2020-04-21 15:06:25 -05:00
evazion
626c2723d7 search: fix scan_query performance regression.
Fix a severe performance regression on the posts/index page introduced
by 6ca42947.

Short answer: scan_query dynamically allocated a regex inside an
inner loop that was called thousands of times per pageload.

Long answer:

* The post index page checks each post to see if they're tagged loli/shota,
* This triggers a call to Post#tag_array for every post.
* Post#tag_array called scan_query to split the tag string.
* scan_query loops over the tag string, checking if each tag matches the
  regex /#{METATAGS.join("|")}:/.
* This regex uses string interpolation, which makes Ruby treat as a
  dynamic value rather than a static value. Ruby doesn't know the
  interpolation is static here. This causes the regex to be reallocated
  on every iteration of the loop, or in other words, for every tag in
  the tag string.
* This caused us to do thousands of regex allocations per pageload. On
  average, a posts/index pageload contains 20 posts with ~35 tags per
  post, or 7000+ total tags. Doing this many allocations killed performance.

The fix:

* Don't use scan_query for Post#tag_array. We don't have to fully parse
  the tag_string here, we can use a simple split.
* Use the /o regex flag to tell Ruby to treat the regex as static and
  only evaluate the interpolation once.
2020-04-21 14:59:30 -05:00
evazion
5bbaa3bdf0 Fix #4418: Can't migrate mail addresses when email_domain_verification_list is nil.
Don't perform email domain verification if email_domain_verification_list is nil or empty.
2020-04-21 00:47:41 -05:00
evazion
c6d096a15f art station: add tests for #4416. 2020-04-21 00:32:52 -05:00
evazion
4abff072b7 test: fix broken tests. 2020-04-21 00:31:16 -05:00
evazion
4041ff6f7e search: fix bug in normalize_query. 2020-04-21 00:31:16 -05:00
evazion
6eb98c6572 search: clean up saved search: metatag.
* Fix not being able to negate the search: metatag.
* Fix not being able to use the search: metatag twice in the same search.
2020-04-21 00:31:16 -05:00
evazion
f6fb3c0169 search: clean up pool: metatag. 2020-04-21 00:31:16 -05:00
evazion
34d4344eaf search: fix exception on nil searches.
6ca42947bd (commitcomment-38622036)
2020-04-21 00:31:16 -05:00
evazion
8c3d979a8d Update ruby gems and yarn packages. 2020-04-21 00:31:16 -05:00
evazion
ee13a56499 Merge pull request #4416 from nonamethanks/fix_artstation_underscore
Artstation: artists can have underscore in their name
2020-04-21 00:30:33 -05:00
evazion
fef90b46ee search: clean up filetype: metatag.
* Fix not being able to use the filetype: metatag twice in the same search.
* Support comma-separated filetypes (filetype:png,jpg).
2020-04-20 04:14:24 -05:00
evazion
c92ac9ab89 search: clean up status: metatag.
* Fix not being able to use the status: metatag twice in the same search.
* Fix status:active excluding banned posts.
* Fix status:garbage returning all posts.
2020-04-20 04:14:24 -05:00
evazion
c452aa6c78 search: add exclusive range syntax (id:5...10).
Support exclusive ranges for numeric metatags. For example, `id:5...10`
is equivalent to `id:>=5 id:<10`. Useful for splitting searches into id
ranges without the endpoints overlapping: id:100...200, id:200...300,
id:300...400.
2020-04-20 04:13:01 -05:00
evazion
25159bb21c search: support backwards ranges.
Fix things like age:1y..2y or score:5..0 returning no results.
2020-04-20 02:44:09 -05:00
evazion
172095730c search: support repeated numeric-valued metatags.
Support using the same numeric-valued metatag twice in the same search.
Numeric-valued metatags are those taking an integer, float, filesize, or
date argument. Previously using the same metatag twice would cause the
second metatag to overwrite the first metatag.

Examples:

* "id:>5 id:<10"
* "width:>500 width:<1000"
* "date:>2019-01-01 date:<2020-01-01"
2020-04-20 02:44:09 -05:00
evazion
53e5d96bb0 search: support repeated parent: metatags.
Support using the parent: metatag twice in the same search ("parent:1 parent:2").
2020-04-20 02:08:22 -05:00
evazion
43067703b0 search: clean up date range parsing. 2020-04-19 13:48:07 -05:00
evazion
6ca42947bd search: support quoted values for all metatags.
Support using quoted values with all metatags. For example: user:"blah blah",
pool:"blah blah", commentary:"blah blah", etc. Things like rating:"safe",
id:"42" also work. Both single and double quotes are supported.

Also make the status: and rating: metatags fully free. Before only
status:deleted and rating:s were free.
2020-04-19 02:54:44 -05:00
evazion
7726563733 search: refactor scan_query callers to use split_query.
Refactor to use split_query instead of scan_query to split a query on
spaces. Preparation for refactoring scan_query into something smarter.
2020-04-19 02:54:44 -05:00
evazion
d0c68e68c2 search: move search tests to own file. 2020-04-19 02:54:39 -05:00
evazion
621b22111e search: clean up pixiv:<any|none> handling.
Refactor so that all metatags that use parse_helper (which is most
integer-valued metatags) support the special "any" and "none" keywords.

This is mainly for consistency, since it's really only useful for using
width:none and height:none to find for certain old unsupported filetypes
that have null width/height values.
2020-04-19 01:34:14 -05:00
evazion
824d0d8edb search: clean up mpixels:, filesize: tolerance handling.
Fold parse_helper_fudged into parse_helper. This is used to make
mpixels:N and filesize:N do an inexact match with a 5% error tolerance.
For example, filesize:1mb is really equivalent to filesize:0.95mb..1.05mb
because an exact filesize:1mb search is unlikely to match anything.
2020-04-19 01:34:14 -05:00
evazion
fdaaf6e371 ip bans: fix wrong name being logged when bans are deleted. 2020-04-19 01:34:14 -05:00
evazion
ab4d596ac2 Fix #4405: Post version table css doesn't keep ratio at smaller resolutions.
Bug: extremely long sources cause the Tags column to become extremely
wide. Caused by the source link not having the word-break property set.

Fix: use post_source_tag, which lets the `a[rel=external] { word-break: break-word; }`
rule take effect.

Example: https://danbooru.donmai.us/post_versions?search%5Bpost_id%5D=3809742
2020-04-17 01:46:14 -05:00
evazion
94180d77b4 dark mode: fix <kbd> tag colors.
Use a light background for <kbd> tags on the keyboard shortcuts page for
better contrast with the page backgorund.
2020-04-17 00:39:16 -05:00
evazion
698f742046 keyboard shortcuts: document 'Z' key (fix #4390). 2020-04-17 00:35:47 -05:00
evazion
c1ce5024e4 search: fix bug with negated user metatags.
Bug: searching for "filetype:jpg -user:evazion" would negate the
filetype:jpg metatag too. This was because the -user:<name> metatag was
negating the entire cumulative relation instead of just the user:<name>
clause.
2020-04-17 00:29:09 -05:00
evazion
99e7e359af flags/appeals: limit flag/appeal reasons to 140 characters. 2020-04-17 00:13:06 -05:00
evazion
e848011080 Fix #4406: Add "commentary:" metasearch.
Add:

* commentary:true (posts with commentary)
* commentary:false (posts without commentary)
* commentary:translated (posts with translated commentary)
* commentary:untranslated (posts with untranslated commentary)
* commentary:"text" (posts where any commentary field matches "text")

Known issues:

* There's no way to escape the true, false, translated, or
  untranslated keywords to do a literal text search for commentaries
  containing one of these keywords.

* Negated searches may be slow. Using a left outer join instead of a
  subquery would be faster in most cases, but negating it is harder.
2020-04-17 00:11:00 -05:00
evazion
9901161bbf search: rename artcomm metatag to commentaryupdater.
* Rename the artcomm:<user> metatag to commentaryupdater:<user>.
* Add support for negated -commentaryupdater:<user> searches.
2020-04-16 21:06:51 -05:00
evazion
8009699cf7 search: fix searches for private favorites raising privilege errors.
* Fix fav:<user> searches to return no results instead of raising a
  UserPrivilege error when the user has private favorites.

* Fix fav:<nonexistent_user> raising a UserPrivilege error instead of
  returning no results.

* Fix -ordfav:<user> not being supported.
2020-04-16 21:06:15 -05:00
evazion
f8d420d6c0 search: fix searches for private favgroups raising privilege errors.
Change favgroup:<name> searches to return no results instead of raising
a UserPrivilege error when an unpermitted user searches for a private
favgroup.

Partial fix for #4389.
2020-04-16 21:05:50 -05:00
nonamethanks
804c87a0ea Artstation: artists can have underscores in their name 2020-04-17 01:10:23 +02:00
evazion
3aa80c8dc4 Fix #4404: Wrong error message when disapproving an already active post. 2020-04-15 01:18:41 -05:00
evazion
432668ddef Update ruby gems and yarn packages. 2020-04-15 01:18:41 -05:00
evazion
3691404a8d search: fix invalid rating searches returning wrong results.
Partial fix for #4389.

* Fix "rating:asdf" returning all posts.
* Fix "rating:s rating:q" returning results for rating:q.
2020-04-15 01:18:41 -05:00
evazion
be27423afd search: fix invalid username searches returning wrong results.
Partial fix for #4389.

* Fix invalid username searches returning all posts instead of no posts.
* Fix "user:A user:B" returning results for user:B instead of no results.
* Fix "approver:A approver:B" returning results for approver:B instead of no results.
* Add support for negated -commenter, -noter, -noteupdater, -upvote, -downvote metatags.
* Add support for "any" and "none" values for all username metatags,
  including negated metatags that didn't support "any" or "none" before.
* Change noter:any and commenter:any to include posts with deleted notes
  or comments. Note that commenter:<username> already included deleted
  comments before. This is so that commenter:any has the same behavior
  as commenter:<username>
2020-04-15 01:18:41 -05:00
evazion
dc6575dc76 uploads: fix corrupted image detection.
* Fix corrupted image detection. We were shelling out to vips and trying
  to grep for error messages, but the error message for jpeg files changed.
  Now we load the file in ruby vips, which raises an error on failure.

* Don't attempt to redownload corrupted images. If a download completes
  without any errors yet the downloaded file is corrupt, then something is
  wrong at the source and redownloading is unlikely to help. Let the
  upload fail and the user retry if necessary.

* Validate that all uploads are uncorrupted, including files uploaded
  from a computer, not just files uploaded from a source.
2020-04-13 15:30:17 -05:00
evazion
cc31eeafa4 Merge pull request #4401 from lllusion3469/tumblr_2048
tumblr: pick biggest image based on resolution
2020-04-09 23:46:24 -05:00
evazion
04fa913362 Merge pull request #4399 from nonamethanks/master
Post#normalized_source: Normalize more twitter urls
2020-04-09 23:38:49 -05:00
evazion
17abfafe4d Merge pull request #4394 from lllusion3469/fav-vote-buttons
Show or hide post vote buttons when (un)favoriting
2020-04-09 23:34:03 -05:00
evazion
11da2090b5 Merge pull request #4400 from lllusion3469/favgroup-show-deleted
Show deleted posts for favorite groups
2020-04-09 23:25:14 -05:00
lllusion3469
65fb0cf510 tumblr: pick biggest image based on resolution
photo[:alt_sizes] may contain a bigger image than
photo[:original_size]

fixes #4324
2020-04-08 16:42:17 +02:00