Commit Graph

112 Commits

Author SHA1 Message Date
evazion
34057b25e1 mod actions: record the subject of the mod action.
Add a polymorphic `subject` field that records the subject of the mod
action. The subject is the post, user, comment, artist, etc the mod
action is for.

* The subject for the user ban and unban actions is the user, not the ban itself.
* The subject for the user feedback update and deletion actions is the user,
  not the feedback itself.
* The subject for the post undeletion action is the post, not the approval itself.
* The subject for the move favorites action is the source post where the
  favorites were moved from, not the destination post where the favorites
  were moved to.
* The subject for the post permanent delete action is nil, because the
  post itself is hard deleted.
* When a post is permanently deleted, all mod actions related to the
  post are deleted as well.
2022-09-25 04:04:28 -05:00
evazion
e2a3265daf mod dashboard: remove ip address search.
Remove the IP address search option from the /moderator/dashboard page.
This was an obsolete way of searching for sockpuppet accounts by IP.
The /user_events page should be used instead.
2022-09-13 00:14:19 -05:00
evazion
a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -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
evazion
f2e262d5fd Merge pull request #4556 from nonamethanks/fix_unban
Post unbans: fix typo
2020-08-07 09:59:44 -05:00
evazion
bca1f122d0 posts: rework post deletion to use dialog box.
Rework post deletion from using a separate page to using a dialog box,
like flagging.

* Add `DELETE /posts/:id` endpoint.
* Remove `POST /moderator/post/posts/:id/delete` endpoint.
2020-08-03 20:21:28 -05:00
nonamethanks
cc5037d835 Post unbans: fix typo 2020-07-25 12:47:48 +02: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
be59e85d25 pundit: convert ip addresses to pundit. 2020-03-20 18:03:01 -05:00
evazion
475d6ae7cf modqueue: move url from /moderator/post/queue to /modqueue. 2020-02-29 17:46:58 -06:00
evazion
72210c0226 modqueue: remove posts per page cookie. 2020-02-29 17:46:57 -06:00
evazion
980103e443 modqueue: optimize sql queries.
* Include appeals and flags.
* Avoid an existence query for pools.
* Avoid a query checking if the user has previously approved the post.
  This is a rare condition and it will be prevented anyway if the user
  tries to reapprove the post.
2020-02-29 17:46:57 -06:00
evazion
cded0f763b approvers: remove "you haven't moderated in awhile" notice.
Remove the nag message when an approver hasn't approved anything
recently. Also remove the modqueue random posts page. As of 3d410398a,
inactive approvers are now warned via dmails.
2020-02-28 14:28:08 -06:00
evazion
e1fd3f6ed9 mods: remove ability to manually perform mass edits.
Remove the ability for mods to manually perform mass edits without going
through the forum.
2020-02-28 14:21:31 -06:00
evazion
e29e9eda49 posts: remove ban confirmation page.
Use a dialog instead of a separate page to confirm bans.
2020-02-27 00:19:03 -06:00
evazion
faf852d18e approvals: remove post undelete endpoint.
Remove `POST /moderator/post/undelete` endpoint. Replace it with
`POST /post_approvals` instead.

Fixes it so that undeleting a post has the same behavior as approving a
post. Namely, it reloads the page instead of just flashing a "Post was
undeleted" message.
2020-02-20 15:49:31 -06:00
evazion
f47c56d976 approvals: move post approval endpoint to /post_approvals.
Move the post approval endpoint from `POST /moderator/post/approval` to
`POST /post_approvals`.
2020-02-20 15:49:18 -06:00
evazion
a214989447 controllers: move /moderator/post/disapprovals to /post_disapprovals. 2020-02-15 07:10:45 -06:00
evazion
2564e885c8 controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
2020-02-15 06:17:22 -06:00
BrokenEagle
63b3503bfc Add ability to use nested only parameter
- The only string works much the same as before with its comma separation
-- Nested includes are indicated with square brackets "[ ]"
-- The nested include is the value immediately preceding the square brackets
-- The only string is the comma separated string inside those brackets
- Default includes are split between format types when necessary
-- This prevents unnecessary includes from being added on page load
- Available includes are those items which are allowed to be accessible to the user
-- Some aren't because they are sensitive, such as the creator of a flag
-- Some aren't because the number of associated items is too large
- The amount of times the same model can be included to prevent recursions
-- One exception is the root model may include the same model once
--- e.g. the user model can include the inviter which is also the user model
-- Another exception is if the include is a has_many association
--- e.g. artist urls can include the artist, and then artist urls again
2020-02-12 23:58:53 +00:00
evazion
ccb87e13b1 Fix #4282: Related tag search no longer allows the JSON/XML formats. 2020-02-05 14:38:32 -06:00
evazion
fcfdd94fe9 controllers: temp fix exception in show actions.
Temp fix a regression caused by c7185724d.
2020-02-04 03:51:59 -06:00
evazion
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -06:00
evazion
f865cd8aeb modqueue: bump "You haven't moderated any posts..." notice to 72 hours. 2019-10-30 10:49:14 -05:00
evazion
a5ab25d0ba pagination: avoid counting pages outside searches.
Replace this common pattern in controllers:

    @tags = Tag.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])

with this:

    @tags = Tag.paginated_search(params)

`search_count` is used to skip doing a full page count when we're not
doing a search (on the assumption that the number of results will be
high when not constrained by a search). We didn't do this consistently
though. Refactor to do this in every controller.
2019-10-07 22:02:03 -05:00
evazion
f2dccf8cf1 Remove mod-only bulk revert system (#4178).
The mass undo system added in #4178 is a replacement for the mod-only
bulk revert system.
2019-09-27 21:12:53 -05:00
evazion
312adb772d views: refactor post flag and appeal reasons.
* Prefer partials over helpers.
* Add css classes to flag/appeal reason lists.
* Wrap dtext in span.prose container.
2019-09-18 03:20:26 -05:00
evazion
a1b48f5e3f views: migrate search forms to use simple form.
Migrate various forms to be built using simple form instead of raw html.
Also adds autocomplete="off" to these forms (#4162).
2019-09-10 14:33:18 -05:00
evazion
d73895312e Avoid swallowing exceptions unnecessarily. 2019-08-29 00:51:52 -05:00
evazion
dab43d96c9 jobs: migrate mass updates to ActiveJob.
Also fixes a bug where mod actions weren't logged on mass updates.
Creating the mod action silently failed because it was called when
CurrentUser wasn' set.
2019-08-19 00:46:31 -05:00
evazion
48488d04db jobs: migrate bulk reverts to ActiveJob. 2019-08-19 00:46:30 -05:00
evazion
576b4feb3b views: convert mod dashboard + admin user edit page to simple form.
Fixes bug with the user level select dropdown on the mod dashboard page
missing the builder level.
2019-08-18 11:24:42 -05:00
evazion
39bd766b34 Fix #4053: Add disapproval index improvements.
Add search form to /moderator/post/disapprovals.
2019-08-02 22:03:03 -05:00
Albert Yi
0a058dd52b fixes #4080: Status code 500 when disapproving through API 2019-05-17 12:09:03 -07:00
Albert Yi
33063a72de Add a listing page for post disapprovals (accessible to approvers only) 2019-01-24 16:14:57 -08:00
evazion
3dafca9aec Fix #3842: Mods can demote other mods or admins. 2018-08-25 13:52:50 -05:00
r888888888
4739c45da0 fixes #3729 2018-05-26 13:13:07 -07:00
Albert Yi
320f1a426e fixes #3704 2018-05-10 10:20:51 -07:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
r888888888
4e9ebbd02e include creator in bulk revert messages 2017-11-16 14:44:57 -08:00
r888888888
3356ef3457 scope bulk reverts to admin 2017-11-15 17:30:40 -08:00
r888888888
d29f2f6a13 fix bulk revert 2017-11-15 10:13:13 -08:00
r888888888
676a991bb2 fix path for bulk revert creation #3342 2017-10-25 18:08:52 -07:00
evazion
fdf8e7d5d7 Fix mode menu 'approve' option.
* Fix routing error in respond_with (didn't use /moderator namespace).

* Fix /moderator/posts/approvals.json response to return full
  PostApproval object, not just a success/failure message.

* Simplify the javascript a bit (use $.post instead of $.ajax).
2017-06-04 12:14:35 -05:00
evazion
565945ab7b flags: move flagging inside Post#delete! 2017-05-17 23:48:37 -05:00
evazion
648cc9ecb7 Move post replacement create action to post replacements controller. 2017-05-14 21:31:01 -05:00
evazion
df7cd67a7d post replacement: add POST /moderator/post/posts/replace endpoint. 2017-05-02 20:41:18 -05:00
evazion
70a7f77a48 Post#approve!: signal errors with invalid object instead of exception. 2017-04-03 17:18:32 -05:00
r888888888
bd3dfc73c0 fix queue for bulk reverts 2017-03-21 17:13:51 -07:00