Commit Graph

10387 Commits

Author SHA1 Message Date
evazion
b8f7c3795c Merge pull request #4767 from nonamethanks/pixiv-other-names
Pixiv: don't add auto-generated usernames to the other names field
2021-03-18 21:29:21 -05:00
evazion
29d2e7fed2 storage manager: remove hierarchical option.
Remove the `hierarchical` file storage option. This means that image
files are always stored in MD5-based subdirectories, like this:

   https://danbooru.donmai.us/data/original/f3/a7/f3a70a89c350b5ed4db22dbb25b934bb.jpg
   https://danbooru.donmai.us/data/sample/f3/a7/sample-f3a70a89c350b5ed4db22dbb25b934bb.jpg
   https://danbooru.donmai.us/data/preview/f3/a7/f3a70a89c350b5ed4db22dbb25b934bb.jpg

instead of in a single flat directory, like this:

   https://danbooru.donmai.us/data/original/f3a70a89c350b5ed4db22dbb25b934bb.jpg

This option is removed because storing files in a single directory is a
bad idea for large installations, and migrating from a single directory
to subdirectories later is a pain.

Downstream boorus who still have files in the old layout can migrate by
running this script:

   `./script/fixes/077_symlink_subdirectories.rb`

This will create symlinks that redirect the 00-ff subdirectories back to
the current directory, so that you can still store files in a single
directory, but use URLs containing subdirectories.

You should also make sure to remove the `hierarchical` option from
`storage_manager` in `config/danbooru_local_config.rb` if you set it
there.
2021-03-18 01:33:56 -05:00
evazion
a620a71b59 storage manager: remove original_subdir option.
Always store original files in `public/data/original` instead of directly in
`public/data`. Previously this was optional and defaulted to off.

Downstream boorus will need to either move all images in the
`public/data` directory to `public/data/original`, or symlink the
`public/data/original` directory to the toplevel `public/data` directory:

    ln -s . /path/to/danbooru/public/data/original

This to simplify file layout. This option existed because in the past we
stored original files in different locations on different servers (for
no particular reason).
2021-03-16 23:37:07 -05:00
evazion
0f90ae0fed storage manager: use canonical URL for image URLs.
Generate image URLs relative to the site's canonical URL instead of
relative to the domain of the current request.

This means that all subdomains of Danbooru - safebooru.donmai.us,
shima.donmai.us, saitou.donmai.us, and kagamihara.donmai.us - will use
image URLs from https://danbooru.donmai.us, instead of from the current
domain.

The main reason we did this before was so that we could generate either
http:// or https:// image URLs, depending on whether the current request
was HTTP or HTTPS, back when we tried to support both at the same time.
Now we support only HTTPS in production, so there's no need for this. It
was also pretty hacky, since it required storing the URL of the current
request in a per-request global variable in `CurrentUser`.

This also improves caching slightly, since users of safebooru.donmai.us
will receive cached images from danbooru.donmai.us.

Downstream boorus should make sure that the `canonical_url` and
`storage_manager` config options are set correctly. If you don't support
https:// in development, you should make sure to set the canonical_url
option to http:// instead of https://.
2021-03-16 23:30:29 -05:00
evazion
f93b1fe478 custom css: don't add !important to every line.
Fixes #4398.
2021-03-16 20:04:09 -05:00
BrokenEagle
79a70083ef Add support for determining stack order of embedded notes 2021-03-16 04:02:47 +00:00
nonamethanks
073f63cfa7 Pixiv: don't add auto-generated usernames to the other names field 2021-03-16 02:44:49 +01:00
evazion
28c0a48117 discord: fix tag search commands being limited to 2 tags. 2021-03-14 16:42:07 -05:00
nonamethanks
0cae2e75b9 Artist finder: add skeb.jp root to blacklist 2021-03-14 04:13:55 +01:00
evazion
808c039f03 db/structure.sql: fixup ban duration field from 81fe68d39. 2021-03-12 23:33:51 -06:00
evazion
4878ecffe8 /wiki_page_versions/diff: fix regression in 5a790ee25. 2021-03-12 23:31:50 -06:00
evazion
d7a32ca930 Update CHANGELOG.md. 2021-03-12 22:51:22 -06:00
evazion
3711733959 Merge pull request #4759 from nonamethanks/fix-burs
BURs: don't check for category when implicating empty tags
2021-03-12 22:49:17 -06:00
evazion
0f39ea1ff4 Merge pull request #4758 from nonamethanks/fix-mastodon
Mastodon: fix strategy raising an exception for direct links
2021-03-12 22:48:12 -06:00
evazion
f8ae7a5836 Merge pull request #4761 from nonamethanks/fix-edit-link
User profiles: use name instead of id in links to post edits
2021-03-12 22:47:28 -06:00
evazion
f219fc09ec discord: add /wiki command. 2021-03-12 22:44:57 -06:00
evazion
698be2d0e4 discord: add /random command. 2021-03-11 21:23:20 -06:00
nonamethanks
ce86f6d274 User profiles: use name instead of id in links to post edits 2021-03-12 03:10:44 +01:00
evazion
b79bd8407f Remove FalseClass#to_i core extension.
Remove a monkey patch that added a `to_i` method to `FalseClass` so that
`false.to_i` returned 0. This is legacy code that shouldn't still be in
use anywhere. It doesn't really work anyway, because `true.to_i` isn't
defined.
2021-03-11 17:34:05 -06:00
nonamethanks
7dd83a12e2 BURs: don't check for category when implicating empty tags
The default category for empty tags is general, so implications are otherwise
always going to be rejected when the tag is created via BUR beforehand.

Ref: https://danbooru.donmai.us/forum_topics/18013?page=2#forum_post_182107
2021-03-11 17:58:02 +01:00
evazion
2c8c7ff80a discord: add initial slash command integration.
Add initial support for the `/count <tags>` and `/posts <tags>` slash commands.

Slash commands are basically like webhooks; we register a command, and
when anybody types that command in Discord, Discord sends us a HTTP
request that we respond to.

* https://discord.com/developers/docs/interactions/slash-commands
* https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ
2021-03-11 03:04:10 -06:00
evazion
1c2f3abe56 discord: rename DiscordApiClient to DiscordWebhookService. 2021-03-11 03:02:50 -06:00
evazion
7bdec9b5fa config: whitelist ngrok.io for development.
Add ngrok.io (plus a few more domains) to the hostname whitelist so that
it can be used as a hostname in development. Useful for testing
webhooks.

* https://ngrok.com
2021-03-11 03:02:50 -06:00
evazion
81fe68d392 bans: change expires_at field to duration.
Changes:

* Change the `expires_at` field to `duration`.
* Make moderators choose from a fixed set of standard ban lengths,
  instead of allowing arbitrary ban lengths.
* List `duration` in seconds in the /bans.json API.
* Dump bans to BigQuery.

Note that some old bans have a negative duration. This is because their
expiration date was before their creation date, which is because in 2013
bans were migrated to Danbooru 2 and the original ban creation dates
were lost.
2021-03-11 02:59:58 -06:00
evazion
791b8c61f6 post disapprovals: fix disapprovers being visible in API. 2021-03-11 02:59:56 -06:00
evazion
5a790ee25a wiki pages: remove category_name field from API.
Remove the `category_name` field from the `/wiki_page.json` API. This
field was originally added only because it was needed by our autocomplete
Javascript. It was also misnamed, it wasn't the tag's category name, it
was the category's ID.

Users should use `https://danbooru.donmai.us/wiki_pages.json?only=title,tag`
instead if they need this.

This triggered a N+1 query pattern when dumping wiki pages to BigQuery,
which made dumping wiki pages very slow. It also meant this field was
included in the database dump, even though it wasn't a real database
column.
2021-03-10 03:08:49 -06:00
evazion
4320e2ef70 dtext links: fix links from mod-only forum posts being exposed.
Fix links from mod-only forum posts being publicly visible in the
/dtext_links page.
2021-03-10 03:08:49 -06:00
evazion
b169d60f64 Fix saved searces, news updates, ip bans being dumped to BigQuery.
Prevent saved searches, news updates, and ip bans from being publicly
dumped to BigQuery. They didn't override the `visible` method to
restrict their visibility for anonymous users.
2021-03-10 03:08:49 -06:00
evazion
f235b72b3f Export public database dumps to BigQuery.
* Export daily public database dumps to BigQuery and Google Cloud Storage.
* Only data visible to anonymous users is exported. Some tables have
  null or missing fields because of this.
* The bans table is excluded because some bans have an expires_at
  timestamp set beyond year 9999, which BigQuery doesn't support.
* The favorites table is excluded because it's too slow to dump (it
  doesn't have an id index, which is needed by find_each).
* Version tables are excluded because dumping them every day is
  inefficient, streaming insertions should be used instead.

Links:

* https://console.cloud.google.com/bigquery?project=danbooru1
* https://console.cloud.google.com/storage/browser/danbooru_public
* https://storage.googleapis.com/danbooru_public/data/posts.json
2021-03-10 02:52:16 -06:00
nonamethanks
a123bf0ee8 Mastodon: fix strategy not working for direct or dead links 2021-03-09 22:35:36 +01:00
evazion
5623cfb145 Add max lengths to comments, dmails, and forum posts.
* Max comment length: 15,000 characters.
* Max forum post length: 200,000 characters.
* Max forum topic title length: 200 characters.
* Max dmail length: 50,000 characters.
* Max dmail title length: 200 characters.
2021-03-08 18:46:49 -06:00
evazion
0249c290fd skeb: remove skeb from site_name in base strategy.
Fixup a mistake with the way the merge conflict was resolved in 9dd903d21.
2021-03-08 03:56:44 -06:00
evazion
ba9313c0d7 gems: add benchmark-ips gem to development group. 2021-03-08 03:51:29 -06:00
evazion
242e5689b6 Merge pull request #4751 from nonamethanks/skeb
Add skeb support
2021-03-08 03:51:20 -06:00
evazion
9dd903d212 Merge branch 'master' into skeb 2021-03-08 03:43:15 -06:00
evazion
66af4986c6 Merge pull request #4754 from nonamethanks/lazymap
Optimize Sources::Strategies.find()
2021-03-08 03:40:28 -06:00
evazion
da2cbefbec users: add back promoter field.
Add back promoter field removed in 7ed674f68 (cf #4750).
2021-03-08 03:17:21 -06:00
evazion
921dde6522 users: don't set inviter field; clear inviter field for most users.
* Don't set the inviter field for newly promoted users, or for Gold/Plat
  upgrades.

* Clear the inviter field for paid Gold/Plat upgrades, and for users who
  have a feedback or a modaction listing who invited them. This leaves
  about 600 remaining users with an inviter field with no other record
  of who invited them.

See #4750.
2021-03-08 03:16:34 -06:00
evazion
d9d090af2b Merge pull request #4750 from smowtenshi/patch-1
Change "Inviter" to "Promoter"
2021-03-08 01:53:31 -06:00
evazion
64440757c1 Merge pull request #4737 from nonamethanks/fix-mastodon-page-url
Sources: get correct mastodon page url
2021-03-08 01:49:56 -06:00
evazion
224d4932bf Merge pull request #4745 from nonamethanks/twitter-common-regexes
Twitter: update common hashtag regexes
2021-03-08 01:49:30 -06:00
evazion
e17cefe3ab Merge pull request #4753 from nonamethanks/fix-baraag-regex
Baraag: fix image regex
2021-03-08 01:49:15 -06:00
evazion
d478d72e0b tests: fix ip geolocation test. 2021-03-08 01:30:02 -06:00
evazion
1716cc5bf9 artists: add more artist url icons. 2021-03-08 01:30:02 -06:00
evazion
869a99d9a3 nijie: clear session cookie if it's expired (#4665).
If we detect that the session cookie has expired (by the presence of the
`#login_illust` element on the page), then clear the cached session
cookie. The current source fetch will still fail, but the next fetch
will try to login again and hopefully succeed.
2021-03-08 01:30:02 -06:00
evazion
5e4865701c nijie: reduce login cookie cache duration to 60 minutes (#4665). 2021-03-08 01:30:02 -06:00
evazion
27e62de316 css: fix paginator position on most viewed posts page, top searches page.
Fix the paginator not being centered on the /explore/posts/viewed and
/explore/posts/searches pages.
2021-03-08 01:30:02 -06:00
evazion
53fdf66922 Fix #4755: No navigation bar (prev/next button) when favgroup in query.
Fix the favgroup navbar not being shown when doing a `favgroup:<id>`
search for a public favgroup belonging to another user.
2021-03-08 01:30:00 -06:00
evazion
28d101eaa7 bans: fix exception when username is blank.
Fix exception when submitting the ban form and the username is blank.
2021-03-07 21:19:32 -06:00
evazion
5b37ac3adb favgroups: validate that name is present. 2021-03-07 21:15:33 -06:00