Commit Graph

11472 Commits

Author SHA1 Message Date
evazion
906ac25221 autocomplete: fix metatags not completing until a character is typed.
Fix metatags not showing autocomplete results until after the first
letter was typed. For example, typing `filetype:` didn't show any
completions until another letter was typed. Now typing `filetype:` shows
all available file types.

This was because `filetype:` by itself wasn't recognized as a valid
search before, since metatags always required a value. Now it is a valid
search, so it's technically possible to search for `filetype:` by
itself. In this case the metatag value will be the empty string, which
will return no results because there are no posts where the filetype is
the empty string.

This sounds nonsensical, but it's potentially useful for metatags like
the `source:` metatag, where searching for posts with an empty source
does make sense. It was also technically possible before by searching
for `source:""`, so making the value optional doesn't change anything.
2022-04-29 22:22:11 -05:00
evazion
031ab1e833 Fix #4752: Category metatags show up as errors in tag edit box.
Fix category prefix metatags not working in autocomplete. Now typing
e.g. `copy:t` will show tags starting with 't' in autocomplete.

Also fix it so that tags beginning with a '(' work in autocomplete.
Typing e.g. `-(tou` will show `touhou` in autocomplete.

This also fixes it so that when you type a negated tag in autocomplete,
e.g. `-touhou`, it sends `touhou` in the autocomplete API call, rather
than `-touhou`. This makes caching more effective since negated tags
will be cached the same as non-negated tags.
2022-04-29 21:47:41 -05:00
evazion
bbe748bd2b posts: factor out post edit logic.
Factor out most of the tag edit logic from the Post class to a new
PostEdit class. The PostEdit class contains the logic for parsing tags
and metatags from the tag edit string, and for determining which tags
were added or removed by the edit.

Fixes various bugs caused by not calculating the set of added or removed
tags correctly, for example when tag category prefixes were used (e.g.
`copy:touhou`) or when the same tag was added and removed in the same
edit (e.g. `touhou -touhou`).

Fixes #5123: Tag categorization prefixes bypass deprecation check
Fixes #5126: Negating a deprecated tag will still cause the warning to show
Fixes #3477: Remove tag validator triggering on tag category changes
Fixes #4848: newpool: metatag doesn't parse correctly
2022-04-29 17:13:33 -05:00
evazion
6ac6f60b1b users: give platinum users unlimited tags.
May as well do this now since Platinum upgrades are disabled.
2022-04-27 23:26:28 -05:00
evazion
83e0ce9dee users: fix platinum having less saved searches than gold. 2022-04-27 23:25:35 -05:00
evazion
d4b448dd94 Factor out StringParser from PostQuery::Parser.
Factor out StringParser class from PostQuery::Parser so it can be used
for other parsing tasks.
2022-04-26 22:14:14 -05:00
evazion
9eaea22fac rails: disable Server-Timing header in production.
This produces random `nil can't be coerced into Float (TypeError)`
errors in production because of a Rails bug. This may also be the cause
of random `An unhandled lowlevel error occurred. The application logs
may have details` errors.

https://github.com/rails/rails/issues/44167
2022-04-26 20:29:00 -05:00
evazion
ba2306919d Update Rails to 7.0.2.4. 2022-04-26 20:27:30 -05:00
evazion
47b4e6df2f Update Ruby gems and Yarn packages. 2022-04-25 18:43:17 -05:00
evazion
0d4e2059d7 users: raise favgroup limit to 10 for Members, unlimited for Gold. 2022-04-24 21:43:42 -05:00
evazion
7d650a5dae users: raise saved search limit to 1000 for Gold. 2022-04-24 21:43:42 -05:00
evazion
1e4c0ffe78 users: disable upgrading to platinum.
Disable the ability to upgrade to Platinum. The Platinum level still
exists, but users can no longer upgrade to it. Sales of Platinum are
being disabled in preparation of increasing the tag limit for Gold
users.
2022-04-24 21:43:42 -05:00
evazion
2b387bdc41 docker: add Docker image for ARM.
* Have CI build Docker images for both x86 and ARM.
* Add a `bin/rails danbooru:docker:build-arm` command for building a Docker image locally for ARM.

Usage:

* Test the image:

  docker run --rm -it --platform linux/arm64 ghcr.io/danbooru/danbooru bash

* Build the image:

  bin/rails danbooru:docker:build-arm

* Build the image by hand:

  git archive HEAD | docker buildx build - --platform linux/amd64 --build-arg SOURCE_COMMIT=$(git rev-parse HEAD) -t danbooru -f Dockerfile --load
2022-04-24 21:42:51 -05:00
evazion
e698bf91ee gems: replace pry with debug.
Replace the 'pry' gem with the 'debug' gem. The debug gem is the new
standard debugger in Ruby 3.1.

Use `binding.break` instead of `binding.pry` to set breakpoints.

Install the extension below for VS Code support.

https://github.com/ruby/debug#how-to-use
https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg
2022-04-23 21:16:37 -05:00
evazion
b0437efe6c docker: fix mkvmerge not being installed.
Fix mkvmerge being uninstalled when shared-mime-info was removed.
mkvmerge is necessary for generating webm samples for ugoira.
2022-04-23 19:13:15 -05:00
evazion
80da1791df docker: upgrade base image to Ubuntu 22.04.
The Danbooru image now requires at least Docker 20.10.10 to run. If you
get weird errors, check `docker version` and make sure you're running a
recent enough version of Docker.

This is because Ubuntu 22.04 uses Glibc 2.34, which uses the clone3
syscall, which was blocked by Docker's default seccomp policy up until
20.10.10 [1].

You may have to upgrade your distro or install Docker manually [2] if
your distro doesn't ship a recent enough version of Docker.

A workaround for older versions of Docker is to use the
`--security-opt seccomp=unconfined` option to disable seccomp [3].

[1] https://pascalroeleven.nl/2021/09/09/ubuntu-21-10-and-fedora-35-in-docker/
[2] https://docs.docker.com/engine/install/
[3] https://docs.docker.com/engine/security/seccomp/
2022-04-23 18:10:00 -05:00
evazion
76d9e86724 Fix #5140: Unexpected error: PublicSuffix::DomainInvalid for searching some newgrounds urls in /artists
When the artist name couldn't found for a Newgrounds URL, for example
for `https://www.newgrounds.com/dump/item`, then the `profile_url`
method erroneously returned `https://.newgrounds.com`. This led to an
error later on when the artist finder tried to parse the invalid URL.

Also fix `strategy_should_work` to test that the profile URL is a valid
URL, and not to try to download the file when image_urls is empty.
2022-04-22 23:16:41 -05:00
evazion
db6bb2ccac Fix #5136: Regular tags are now case-sensitive.
* Fix `AST.tag` to downcase the tag name.
* Change PostQuery::Parser to use build nodes using `AST.tag`,
  `AST.metatag`, `AST.wildcard`, etc methods instead of building nodes
  directly. This way all the normalization happens in the node
  constructor methods instead of in the parser.
2022-04-22 02:14:07 -05:00
evazion
90182148aa Merge pull request #5137 from nonamethanks/foundation-videos
Foundation: fix some video posts not being extracted
2022-04-22 01:50:26 -05:00
evazion
57a92ad336 Fix #5072: Fandom source normalization is wrong 2022-04-22 01:27:17 -05:00
evazion
40dda8a672 Merge pull request #5138 from nonamethanks/fix-fandom-links
Fix normalization for fandom sources
2022-04-22 00:36:11 -05:00
evazion
5f70cf1eab Merge pull request #5139 from nonamethanks/no-empty-else
Sources: do not use an empty else in case blocks
2022-04-22 00:35:40 -05:00
evazion
2ae2c23eef Upgrade Bundler to 2.3.12.
Fixes this warning:

    Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated.
    Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
2022-04-21 21:43:17 -05:00
evazion
7701fe2e17 Upgrade Ruby to 3.1.2.
Also fix a call to `Time.utc` that fails in Ruby 3.1.2 (can't pass a
string to Time.utc).
2022-04-21 21:43:06 -05:00
nonamethanks
e1b9166a56 Sources: do not use an empty else in case blocks 2022-04-22 03:53:18 +02:00
nonamethanks
3b055138ff Fix normalization for fandom sources 2022-04-22 03:27:05 +02:00
nonamethanks
e6cb255a7a Foundation: fix some video posts not being extracted
Also adjusts SourceTestHelper to not autogenerate contexts, so that
tests can be launched individually.
2022-04-21 17:54:22 +02:00
evazion
29e0139583 Fix #5135: /count Discord slash command broken with aliases and shortcuts. 2022-04-20 22:30:23 -05:00
evazion
d44bb779fe Merge pull request #5134 from nonamethanks/fix-for-button-fix
Fix regression in 7486836b0f that removed the delete button from pending posts
2022-04-20 16:09:31 -05:00
nonamethanks
e4a24d000f Fix regression in 7486836b0f that removed the delete button from pending posts 2022-04-20 19:33:17 +02:00
evazion
edb67b1b81 Merge pull request #5131 from nonamethanks/fix-mod-action-for-post-ban
Posts: don't try to ban/unban a post that is already banned/unbanned
2022-04-19 16:37:13 -05:00
nonamethanks
234ac98640 Posts: don't try to ban/unban a post that is already banned/unbanned 2022-04-19 21:40:47 +02:00
nonamethanks
c5e6044c23 Anifty: regex fixup for c9227645d9 2022-04-19 15:54:56 +02:00
evazion
fdb259f67d apm: record user preference cookies in apm. 2022-04-19 06:59:24 -05:00
evazion
957076d93b apm: don't record unknown url params in the apm.
Don't record unknown url params that don't come from our app. This
includes typos, url params from userscripts, and weird params from
broken bots, crawlers, or other unknown sources. Indexing too many
params can lead to a mapping explosion.

https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html
2022-04-19 06:59:24 -05:00
evazion
c187d56cce apm: record only select http headers in the apm.
Don't record most HTTP request and response headers in the APM, except
for the User-Agent, Referer, Save-Data, X-Forwarded-For, Accept-Language,
and Content-Type headers. Recording every HTTP header for every request
takes up a lot of space and most of them aren't very useful.
2022-04-19 06:59:24 -05:00
evazion
d3294364e1 Merge pull request #5129 from nonamethanks/anifty-support
Add anifty.jp support
2022-04-19 06:54:21 -05:00
evazion
9a62bb673f Merge pull request #5130 from nonamethanks/readd-approve-button
Readd approval button to the sidebar
2022-04-19 06:34:34 -05:00
evazion
14c8146a5d stripe: notify site owner when a chargeback is created.
Send a notification Dmail to the site owner when a chargeback is
created, or when an impending chargeback warning is received.
2022-04-18 19:46:44 -05:00
nonamethanks
7486836b0f Readd approval button to the sidebar
The quick mod buttons are also used in the modqueue so it's not
possible to bind the shift-o shortcut to them, hence the need
for this button.
2022-04-18 19:50:35 +02:00
nonamethanks
c9227645d9 Add anifty.jp support 2022-04-18 16:50:26 +02:00
evazion
a45b18ed36 views: inline notes partial into posts show page. 2022-04-18 04:30:01 -05:00
evazion
dff0b0e48b posts: add back option to undelete posts in sidebar.
This was removed in 1a990d5ab, but that left no way to undelete posts
that haven't been appealed since the quickmod bar isn't shown in that
case.
2022-04-18 04:28:54 -05:00
evazion
089adc085b Fix #5119: /counts/posts ignores aliased tags on betabooru 2022-04-18 00:52:08 -05:00
evazion
6c5dd5ffed tests: fix broken tests. 2022-04-18 00:31:31 -05:00
evazion
cd22c8eb1a posts: eliminate unnecessary favgroup query on posts show page.
Eliminate a SQL query loading the post's favgroups if the current user
is anonymous (and therefore can't have favgroups).
2022-04-18 00:18:54 -05:00
evazion
5050ca527d posts: eager load uploader and media asset on posts show page.
Eliminate a couple SQL queries by loading the uploader and media asset
in the same query as the post.
2022-04-18 00:18:54 -05:00
evazion
436f3eaf5d posts: eliminate redundant tag load on posts show page.
Eliminate an unnecessary `SELECT name, post_count, category FROM tags WHERE name IN (?)`
query on the post show page. This query was used by `humanized_essential_tag_string`
when generating the page title. This query was redundant because we already use
another query to load the tag list with `SELECT * FROM tags WHERE name IN (?)`.
2022-04-18 00:18:50 -05:00
evazion
219a0959a5 saved searches: fix to use new PostQuery class. 2022-04-17 23:20:22 -05:00
evazion
ca5dd61728 post queries: optimize zero tag and single tag searches.
Avoid going through the full post query parser for empty searches or
simple single-tag searches.
2022-04-17 23:20:22 -05:00