Commit Graph

11483 Commits

Author SHA1 Message Date
evazion
d54ad9103b Merge pull request #5147 from nonamethanks/furaffinity-support
Add furaffinity support
2022-05-01 20:16:17 -05:00
evazion
f4ad1b09da Fix #4444: Pool navigation is broken when post appears twice in same pool.
Don't allow the same post to be added to the same pool twice.

This was only legitimately needed in a handful of cases. It was much
more common for posts to be mistakenly added to the same pool twice.
2022-05-01 01:57:54 -05:00
evazion
4542f38023 users: add 1 password reset per hour rate limit. 2022-05-01 01:11:51 -05:00
evazion
f434abc59a users: add 'show deleted posts' account setting.
Add an account setting to always show deleted posts in searches. This
only applies to searches, not to thumbnails in other places.

Fixes #4512.
2022-05-01 00:47:53 -05:00
evazion
f117049750 users: remove 'hide deleted posts' account setting.
This setting automatically added the `-status:deleted` metatag to all searches. This meant deleted
posts were filtered out at the database level, rather than at the html level. This way searches
wouldn't have less-than-full pages.

The cost was that searches were slower, mainly because post counts weren't cached. Normally when you
search for a tag, we can get the post count from the tags table. If the search is actually like
`touhou -status:deleted`, then we don't know the count and we have to calculate it on demand.

This option is being removed because it did the opposite of what people thought it did. People
thought it made deleted posts visible, when actually it made them more hidden.
2022-05-01 00:47:46 -05:00
evazion
fdc1130aea Fix #5150: rating: metatag doesn't work on betabooru upload page. 2022-04-30 20:22:26 -05:00
evazion
ccd0dde081 Fix #5013: BUR model doesn't validate tags.
Don't allow users to request aliases, implications, or renames for invalid tag names.

As a side effect, it's no longer possible to request shortcut aliases like
`/hr -> hakurei_reimu` (slash abbreviations still exist, but they can't
be overridden with aliases). Tests involving these types of aliases are
removed.
2022-04-30 20:03:04 -05:00
evazion
0920d2ca24 tags: don't allow aliases inside *_(cosplay) tags.
Don't treat *_(cosplay) tags as being invisibly aliased when a character tag is aliased. For example,
if toosaka_rin is aliased to tohsaka_rin, and toosaka_rin_(cosplay) is later added to a post, don't
magically translate the tag to tohsaka_rin_(cosplay). Instead, treat it as an error to create a
*_(cosplay) tag for an aliased character tag.

This removes some of the complexity and magic behavior surrounding *_(cosplay) tags.
2022-04-30 18:12:35 -05:00
evazion
f8aa985a16 Fix #4908: Prevent artist entries from being made on disambiguation tags.
Don't allow artist entries to be created for deprecated tags.
2022-04-30 15:21:10 -05:00
evazion
918f32c554 Fix #4461: Improve posts/index page titles. 2022-04-30 01:52:33 -05:00
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
nonamethanks
8edd5dd810 Add furaffinity support 2022-04-27 03:47:59 +02: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