Commit Graph
100 Commits
Author SHA1 Message Date
evazion ab1839c613 uploads: fix exception with preprocessed uploads.
Fix exception when submitting an upload and an in-progress preprocessed
upload already exists. In this case we forgot to pass the upload params
when calling UploadService#delayed_start.
2020-03-31 21:57:34 -05:00
evazion 3051daf5eb password resets: fix exception when given user does not exist. 2020-03-31 21:57:34 -05:00
evazion 25776a062c posts/random: fix pundit exception when no post is found. 2020-03-31 21:57:34 -05:00
evazion 08ce5a71c4 Eliminate various dead code. 2020-03-31 21:57:34 -05:00
evazion e0a72ef135 tests: add more controller tests.
* Fix an exception in /artists/show_or_new.
2020-03-31 19:00:32 -05:00
evazion a272453bd0 wikis: redirect legacy title param to show page.
Redirect /wiki_pages?title=touhou to /wiki_pages/touhou.
2020-03-31 18:13:41 -05:00
evazion 81488c7608 controllers: declare search_params helper in app controller. 2020-03-31 18:10:27 -05:00
evazion 9def8c5c0d notes: prevent notes appearing above site notices. 2020-03-31 01:23:16 -05:00
evazion cc385fa9e4 notes: better fix for note body sizing (#4375).
Setting max-width causes notes to overflow the note body if they set a
fixed `width` or they use `white-space: nowrap` and the line is wider
than the max-width. Using `width: min-content` instead makes the note
shrink to fit but doesn't prevent it from expanding if it needs to.
2020-03-31 01:18:23 -05:00
evazion 91e5ed67b7 Remove dead TagCorrection code.
Dead since bc34fb16a.
2020-03-30 12:39:26 -05:00
evazion 4e2fd82ef6 tests: add missing controller tests. 2020-03-30 12:36:06 -05:00
evazion 83c2abf1ae delayed jobs: fix exception on index page. 2020-03-30 12:36:06 -05:00
evazion 353c2e4bae Update ruby gems and yarn packages. 2020-03-29 15:58:04 -05:00
evazion c44267b848 Fix #4375: The popup note boxes are very long 2020-03-29 02:53:50 -05:00
evazion 919a2868be Fix #4374: Unvoting comments is broken. 2020-03-28 21:15:51 -05:00
evazion c5260f4927 posts: don't cache rendered notes.
Don't cache rendered notes in Redis. Rendering notes shouldn't be
expensive normally.
2020-03-28 18:25:30 -05:00
evazion 70aac1d4b8 Fix #4372: Wrong attribute name in opengraph tags. 2020-03-28 15:38:15 -05:00
evazion 71e1d7c2a5 notes: fix note mispositioning when image is blacklisted.
If the image is blacklisted on initial page load then unblacklisted
after the image is loaded, then the notes will be mispositioned at the
bottom of the image. This is because we relied on $image.height() to
calculate the note position, but the image height is zero when the image
is hidden.

Potential fix for #4370.
2020-03-28 14:56:38 -05:00
evazion 5d12081e58 posts: add » links for uploaders and approvers. 2020-03-28 00:26:31 -05:00
evazion f1ffc016b8 posts: fix tagged filenames disappearing after viewing original.
The file url in the data attributes on the image container doesn't
contain the tags for performance reasons. The post data attributes are
used for thumbnails too and we don't want to include tagged filenames
for those because it requires looking up tag categories, which triggers
a lot of redis calls on the post index page.
2020-03-27 21:34:16 -05:00
evazion da235cec05 uploads: fix preview image resizing.
* Fix preview images not being resized to fit the screen when using the
  bookmarklet.

* Fit images to both screen width and height by default. Previously we
  fit to screen width only, so tall images were hard to see.

* Allow clicking on the image or pressing Z to toggle image size.

* Move size information to above the image and add resize links:
** small: fit width and height
** large: fit width
** full: fit none

* Bind the image error handler in an onerror attribute on the image
  itself so that it will always fire. Before it wouldn't fire if the image
  failed immediately on pageload before we could bind the error handler.
2020-03-27 21:16:46 -05:00
evazion cbfa8c4904 email validator: fix undeliverable? method always returning false.
`undeliverable?` calls `smtp_enabled?` which we forgot to define. It
swallowed the error so it didn't fail but it always returned false.
2020-03-27 12:47:35 -05:00
evazion d24c746417 Fix #4360: Something broke random=true.
When random mode is enabled @post_set.posts returns an array, which
caused `authorize` to try to lookup the wrong policy.

This only happens when `authorize` is given an array with more than one
element, which is why it wasn't caught by the tests.
2020-03-27 04:23:32 -05:00
evazion 557c15123b comments: fix exception with group_by=comment param. 2020-03-27 01:34:54 -05:00
evazion 597d1304fd sessions: fixup bugs in b2cf765d6.
Deal with the cases where either the `login` param is given without the
`api_key`, or the `api_key` is given with the `login`.
2020-03-26 23:53:48 -05:00
evazion 578f99f3c2 notes: remove dead resize_inner_border method.
Followup to e844a06e6. Also remove a dead reference to
`#original-file-link` (removed years ago).
2020-03-26 22:04:36 -05:00
evazion 269c20d6ee notes: clean up note visibility toggling. 2020-03-26 22:04:36 -05:00
evazion 1af6850c7c posts: add "view original" sidebar option.
* Add a "View original" sidebar option.
* Rename the "View large" sidebar option to "View smaller".
* Remove the "Loading..." message when switching image sizes.
* Fix the V hotkey not working after using it once.
* Change #image-resize-link to .image-view-original link (note that
  there are two of these links now, one in the notice bar and one in the
  sidebar).
* Add a `data-post-current-image-size` attribute on the <body> element
  and use it to control visibility of links and notices.
2020-03-26 22:03:47 -05:00
evazion 87a51129b8 posts: add back "resize to window" link.
* Add back "Resize to window" link.
* Add Z shortcut for resize to window link (mnemonic: Z for zoom image).
* Resize images to screen width by default on both desktop and mobile.
* Make it so that notes are nested directly inside the .image-container
  element with the image, instead of inside a separate .note-container
  element. This means .image-container and .note-container are now the
  same element. This is so that the size of the .note-container is
  driven by the size of the image, which ensures that notes are
  automatically resized as the image is resized.
2020-03-26 21:55:59 -05:00
evazion 1126147dee posts: change #image-container, #note-container to classes.
Change #image-container and #note-container from IDs to classes. This is
necessary so that we can use one container element for both the image
container and the note container. This may break custom CSS and
userscripts.
2020-03-26 18:17:13 -05:00
evazion e9b33dbd48 api: remove legacy password_hash login method.
Remove the ability to authenticate to the API with the `login` and
`password_hash` url parameters. This is a legacy authentication method
from Danbooru 1. How to actually generate the password_hash for this
method hasn't been fully documented for many years now. It required
taking the SHA1 hash of your password combined with an undocumented salt
value (i.e., password_hash = sha1("choujin-steiner--#{password}")).

This authentication method was also slow because it required checking
the password on every API call. Checking passwords is deliberately slow
because passwords are hashed with BCrypt. BCrypt takes about ~200ms per
request, so using this method effectively limited you to ~5 requests per
second in a single thread.
2020-03-25 18:48:43 -05:00
evazion b2cf765d6d users: refactor login and authentication logic.
* Make authentication methods into User instance methods instead of
  class methods.
* Fix API key authentication to use a secure string comparison. Fixes a
  hypothetical (unlikely to be exploitable) timing attack.
* Move login logic from SessionCreator to SessionLoader.
2020-03-25 18:48:43 -05:00
evazion 64af957031 tests: remove old password change tests.
Followup to 5faa32372. Equivalent tests exist in
tests/functional/passwords_controller_test.rb
2020-03-25 18:48:43 -05:00
evazion 9e455695a1 sessions: remove legacy user_name / password_hash cookies.
Remove support for logging in with the deprecated user_name /
password_hash cookies. Followup to 320ff01e0.
2020-03-25 18:48:43 -05:00
evazion 4b1114b4a4 users: drop email column. 2020-03-25 18:48:42 -05:00
evazion ea8cdadce9 commentary versions: migrate columns to non-null.
Fixes #4355.
2020-03-25 18:48:21 -05:00
evazion cbd713dea8 users: move sockpuppet detection from model to controller. 2020-03-24 18:41:27 -05:00
evazion 50b0b79891 comments: adjust link to howto:comment.
Replace the giant banner about reading the comment guidelines with a
smaller link to howto:comment beneath the comment text box.
2020-03-24 18:32:30 -05:00
evazion 18e11f77be post disapprovals: add username autocompletion to search form. 2020-03-24 18:16:48 -05:00
evazion 89a3c0b09d users: update explanation on account deactivation page.
* Refer to it as deactivating your account, not deleting your account.
* Update explanation to clarify what is and is not deleted.
* Warn that deactivation cannot be undone.
2020-03-24 18:00:06 -05:00
evazion b7bd6c8fdd users: require email verification for signups from proxies.
Require users who signup using proxies to verify their email addresses
before they can perform any edits. For verification purposes, the email
must be a nondisposable address from a whitelist of trusted email
providers.
2020-03-24 17:25:35 -05:00
evazion 5faa323729 users: clean up password update logic.
Pull the password reauthentication logic out of the user model and put
it in the password update controller where it belongs.

This fixes an issue where when a new user was created the user model had
an incorrect password error set on it by `encrypt_password_on_update`.
It was trying to verify the old password even though we don't have one
when creating a new user. This error caused the user create action to
redirect back to the signup page because `respond_with` thought that
creating the user failed.
2020-03-24 17:25:35 -05:00
evazion 5cb7167a45 ip bans, user feedbacks: fix links to bans page in secondary links. 2020-03-24 00:39:22 -05:00
evazion 0ad5619484 pundit: add missing authorize calls. 2020-03-24 00:38:07 -05:00
evazion 4a5bec71f6 signup: don't send welcome emails to invalid addresses.
Fix attempting to send welcome emails when user didn't provide a valid
email address.
2020-03-24 00:26:47 -05:00
evazion e79910431f emails: validate that email addresses are deliverable.
Reject email addresses that known to be undeliverable during signup.
Some users signup with invalid email addresses, which causes the welcome
email (which contains the email confirmation link) to bounce. Too many
bounces hurt our ability to send mail.

We check that an email address is undeliverable by checking if the
domain has a mail server and if the server returns an invalid address
error when attempting to send mail. This isn't foolproof since some
servers don't return an error if the address doesn't exist. If the
checks fail we know the address is bad, but if the checks pass that
doesn't guarantee the address is good. However, this is still good
enough to filter out bad addresses for popular providers like Gmail and
Microsoft that do return nonexistent address errors.

The address existence check requires being able to connect to mail
servers over port 25. This may fail if your network blocks port 25,
which many home ISPs and hosting providers do by default.
2020-03-23 23:45:18 -05:00
evazion 27f10d53d6 Update ruby gems and yarn packages. 2020-03-23 01:48:59 -05:00
evazion a45c7f46be Interlink bans, ip bans, and user feedbacks pages.
* Make the bans, ip bans, ip addresses, and user feedbacks pages all
  link to one another in the secondary links.
* Add quick search bars to the secondary links on these pages.
2020-03-23 01:48:59 -05:00
evazion c24ae0a2a6 ip addresses: add secondary links. 2020-03-23 01:48:59 -05:00
evazion f23df47c09 ip addresses: add ip address show page.
* Add IP address show page at /ip_addresses/1.2.3.4.
* Add "Details", "Ban IP", "Ban User" options to the /ip_addresses listing.
2020-03-23 01:48:59 -05:00
evazion 13dab1510c ip addresses: add ip lookup api client. 2020-03-23 01:48:59 -05:00
evazion 6a0799fec0 posts: allow approvers to see uploader names. 2020-03-22 15:25:45 -05:00
evazion 8492979ecb post policy: fix typo in is_note_locked. 2020-03-21 23:21:16 -05:00
evazion f464163885 users: allow all users to use the posts per page setting. 2020-03-21 23:06:50 -05:00
evazion 88a8f459ed comments: remove 10 comment votes per hour limit. 2020-03-21 23:06:47 -05:00
evazion 63f7311489 comments: allow new users to comment.
Remove the rule that users less than a week old can't leave comments.
2020-03-21 23:06:47 -05:00
evazion aefbed57b8 pools: allow new users to remove posts from pools.
Remove the rule that users less than a week old can't remove posts from
pools.
2020-03-21 23:06:47 -05:00
evazion 92e4635af8 ip addresses: fix reference to CurrentUser inside visible. 2020-03-21 23:06:42 -05:00
evazion 94aff2c777 moderation reports: pass CurrentUser to visible explicitly.
This is for consistency with how `visible` works in other models.
2020-03-21 23:06:42 -05:00
evazion 2445e8b82f favorites: convert user.hide_favorites? to pundit. 2020-03-21 23:06:42 -05:00
evazion 5bc82bf07b users: remove user is not ip banned validation.
This is handled on the controller level now.
2020-03-21 23:06:42 -05:00
evazion b21e1d219c users: remove as_admin and as_current methods. 2020-03-21 23:06:42 -05:00
evazion 94d78287eb bulk update request pruner: fix forum posts reference. 2020-03-21 23:06:42 -05:00
evazion e4d63eb0da post versions: fix index action when no versions exist.
Fix a nil dereference error during testing when no post versions exist.
2020-03-21 23:06:42 -05:00
evazion 41ab3c9f63 post versions: fix undo action. 2020-03-21 23:06:42 -05:00
evazion ca27929249 tests: add more posts/show tests. 2020-03-21 23:06:42 -05:00
evazion 3656063a6b tests: fix unit tests.
* Move old post archive tests to post version tests.

* Fix pool tests that assumed that multiple edits by the same user
  weren't merged.

* Fix references to `is_active` and `notes` on artist model.
2020-03-21 21:07:35 -05:00
evazion 94ae10b1a6 tests: fix post and pool version tests helpers.
* Fix the pool version SQS service to always be mocked before every
  test. Before we had to manually set it up before every test dealing
  with pool versions.

* Fix it so that we reconnect to the post/pool version databases before
  every test. Before using $ARCHIVE_DATABASE_URL to set the database url
  failed because environment variables weren't loaded by dotenv yet when
  connections were first established.
2020-03-21 19:28:10 -05:00
evazion 3cb2c10be8 Merge pull request #4349 from danbooru/refactor-pundit
Refactor authorization logic to use Pundit
2020-03-20 18:47:33 -05:00
evazion d775c625bb application controller: remove role_only! methods. 2020-03-20 18:03:50 -05:00
evazion 79e7b9308e pundit: convert misc privilege checks in views to pundit. 2020-03-20 18:03:50 -05:00
evazion 7f742242e4 pundit: convert uploads to pundit. 2020-03-20 18:03:01 -05:00
evazion d51b0dfe17 pundit: convert moderator/post/posts to pundit. 2020-03-20 18:03:01 -05:00
evazion 1344d4c161 pundit: convert moderator/dashboard to pundit.
Make it visible to everyone since there's no non-public information here.
2020-03-20 18:03:01 -05:00
evazion a5418abb31 pundit: convert posts to pundit. 2020-03-20 18:03:01 -05:00
evazion dd39913e55 pundit: convert post replacements to pundit. 2020-03-20 18:03:01 -05:00
evazion 3bb3c0b990 pundit: convert saved searches to pundit. 2020-03-20 18:03:01 -05:00
evazion 415d9591c5 pundit: convert post votes to pundit.
Side effects:

* The data-current-user-is-voter <body> attribute has been removed.
* {{upvote:self}} no longer works. {{upvote:<name>}} should be used instead.
2020-03-20 18:03:01 -05:00
evazion 33d81d0d1b pundit: convert post flags to pundit. 2020-03-20 18:03:01 -05:00
evazion ffae64f127 pundit: convert post versions to pundit. 2020-03-20 18:03:01 -05:00
evazion ba0a5dda8a pundit: convert post disapprovals to pundit. 2020-03-20 18:03:01 -05:00
evazion 84c654464d pundit: convert post approvals to pundit. 2020-03-20 18:03:01 -05:00
evazion cbee23f9ad pundit: convert post appeals to pundit. 2020-03-20 18:03:01 -05:00
evazion ab5432d149 pundit: convert pools to pundit. 2020-03-20 18:03:01 -05:00
evazion 83eae1bf11 pundit: convert passwords to pundit. 2020-03-20 18:03:01 -05:00
evazion 62835ac9fc pundit: convert notes to pundit. 2020-03-20 18:03:01 -05:00
evazion 2c4c29b81a pundit: convert favorite groups to pundit. 2020-03-20 18:03:01 -05:00
evazion 50fa674a3e pundit: convert emails to pundit. 2020-03-20 18:03:01 -05:00
evazion a440c56ed8 pundit: convert comment votes to pundit. 2020-03-20 18:03:01 -05:00
evazion ce1133dd69 pundit: convert artist commentaries to pundit. 2020-03-20 18:03:01 -05:00
evazion 3d83c3154e pundit: convert forum topic visits to pundit. 2020-03-20 18:03:01 -05:00
evazion f1f489c40b pundit: convert favorites to pundit. 2020-03-20 18:03:01 -05:00
evazion cc2b4abd09 pundit: convert forum post votes to pundit. 2020-03-20 18:03:01 -05:00
evazion be59e85d25 pundit: convert ip addresses to pundit. 2020-03-20 18:03:01 -05:00
evazion 92aeb8728f pundit: convert ip bans to pundit. 2020-03-20 18:03:01 -05:00
evazion 9242bf522b pundit: convert moderation reports to pundit. 2020-03-20 18:03:01 -05:00
evazion 480f39c34a pundit: convert dmails to pundit. 2020-03-20 18:03:01 -05:00
evazion 15ba2f6cd7 tests: fix email delivery tests.
Setting deliver_later_queue_name inside config/application.rb broke
tests because assert_enqueued_email_with assumes that the deliver_later
queue is called `mailers`.
2020-03-20 18:03:00 -05:00
evazion 19817a6f85 pundit: convert modqueue to pundit. 2020-03-20 18:03:00 -05:00
evazion 3d72e62c77 pundit: convert bans to pundit. 2020-03-20 18:03:00 -05:00