Commit Graph

10325 Commits

Author SHA1 Message Date
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
evazion
52d76a4f22 artists: fix error messages for invalid artist names.
* When trying to create an artist entry for a non-artist tag, set the
  error on the name attribute so that the artist name gets marked
  as incorrect in the artist edit form.

* Fix a bad `Name '' cannot be blank` error message when the artist name
  is blank.

* Fix showing wiki pages of non-artist tags in the artist edit form when
  the artist name conflicts with a non-artist tag (e.g. if you try to
  create an artist named '1girl', don't show the wiki for 1girl in the
  artist edit form).
2021-03-07 21:07:44 -06:00
evazion
fee7ed506b comments: put sticky option in popup menu instead of in edit form.
Put the option to sticky a comment in the "..." popup menu instead of
in the comment edit form. This makes it more consistent with deleting or
undeleting a comment.

Also fix a bug where the comment undelete icon didn't show up due to a
typo.
2021-03-07 20:13:38 -06:00
evazion
e6a501393a comments: change error message when body is blank.
Change error from "Body has no content" to "Body can't be blank" when a
user tries to submit an empty comment. This makes it consistent with
error messages in other models when someone tries to submit blank content.
2021-03-07 20:13:16 -06:00
evazion
4b61a9c73c /robots.txt: enable HTTP caching.
Cache /robots.txt at the HTTP level because it rarely changes but it
gets requested by bots relatively frequently.
2021-03-07 18:35:37 -06:00
evazion
250e7657b5 Update Ruby gems and Yarn packages. 2021-03-07 18:34:40 -06:00
nonamethanks
a4ae07416a Optimize Sources::Strategies.find()
Use lazy.map instead of map, so that we do not run every single
strategy's match method for every source
2021-03-07 18:20:10 +01:00
nonamethanks
4118a3f3c9 Baraag: fix image regex
Fixes a bug for Baraag.net that caused the batch bookmarklet to always pick the first picture in multi-image posts.
2021-03-06 08:50:08 +01:00
evazion
bb0540e1a1 Fix #4747: BUR layout partly broken on iOS.
Move the BUR help text from the <textarea> placeholder attribute to a
<details> tag that embeds the [[help:bur_notice]] wiki page.

Also update some CSS for the <details> tag that was meant to only apply
to the user upgrades page and didn't look good here.
2021-03-05 19:53:42 -06:00
evazion
be162a8ae9 Fix #4746: Related tags checkboxes don't work properly on some phones (iOS).
Only use hover to hide the checkboxes on devices that support hovering
(i.e. computers with a mouse). On some mobile devices, a tap is used to
emulate hovering, which meant the tag had to be tapped twice.
2021-03-05 18:22:47 -06:00
evazion
58e42ee8d3 rate limits: add /rate_limits endpoint.
Allow users to view their own rate limits with /rate_limits.json.

Note that rate limits are only updated after every API call, so this
page only shows the state of the limits after the last call, not the
current state.
2021-03-05 16:47:20 -06:00
evazion
1ee1e807cf rate limits: penalize user if they keep making requests while limited.
If the user makes a request while rate limited, penalize them 1 second
for that request, up to a maximum of 30 seconds. This means that if a
user doesn't stop making requests after being rate limited, then they
will stay rate limited forever until they stop.

This is to temp ban bots, especially spam bots, that flood requests
while ignoring HTTP errors or rate limits.

(Note that this is on a per-endpoint basis. Being rate limited on one
endpoint won't penalize you for making calls to other endpoints.)
2021-03-05 16:04:48 -06:00
evazion
413cd34c45 rate limits: adjust limits for various actions.
* Tie rate limits to both the user's ID and their IP address.

* Make each endpoint have separate rate limits. This means that, for
  example, your post edit rate limit is separate from your post vote
  rate limit. Before all write actions had a shared rate limit.

* Make all write endpoints have rate limits. Before some endpoints, such
  as voting, favoriting, commenting, or forum posting, weren't subject
  to rate limits.

* Add stricter rate limits for some endpoints:

** 1 per 5 minutes for creating new accounts.
** 1 per minute for login attempts, changing your email address, or
   for creating mod reports.
** 1 per minute for sending dmails, creating comments, creating forum
   posts, or creating forum topics.
** 1 per second for voting, favoriting, or disapproving posts.
** These rate limits all have burst factors high enough that they
   shouldn't affect normal, non-automated users.

* Raise the default write rate limit for Gold users from 2 per second to
  4 per second, for all other actions not listed above.

* Raise the default burst factor to 200 for all other actions not listed
  above. Before it was 10 for Members, 30 for Gold, and 60 for Platinum.
2021-03-05 16:02:57 -06:00