Commit Graph

16 Commits

Author SHA1 Message Date
nonamethanks
ca31e7a47c Users: add Contributor and Approver user levels 2022-10-21 20:52:31 +02:00
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
88ac91f5f3 search: refactor to pass in the current user explicitly. 2022-09-22 04:31:21 -05:00
evazion
acc4a21687 posts: allow admins to approve the same post twice.
This is so admins can overrule flags and always have the final say in whether a
post is approved, even in the event of coordinated or sockpuppet flagging.

Fixes #4980: Way to mark flags as invalid for admins
2022-06-05 15:51:58 -05:00
evazion
341be51f95 posts: remove unused flag! and approve! methods.
These methods were unused outside of the test suite
2021-10-11 20:05:09 -05:00
evazion
3210da1a23 flags: raise flag limits.
The old flag limits were:

* 1 flag per day for regular members.
* 10 flags per day for Gold users.
* Unlimited flags for approvers.

The new flag limits are:

* 10 flags in the modqueue at once for regular users.
* Unlimited flags for approvers.
* Unlimited flags for users with a high enough flag success rate. If you
  have at least 30 flags in the last 3 months, and you have at least a
  70% flag success rate, then you get unlimited flags.

10 flags at once means you can have up to 10 flagged posts in the
modqueue at the same time. Because flags stay in the modqueue for 3
days, this means you can flag on average 10 posts every 3 days, or just
over 3 posts per day.
2020-08-08 15:22:13 -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
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
b4ce2d83a6 models: remove belongs_to_creator macro.
The belongs_to_creator macro was used to initialize the creator_id field
to the CurrentUser. This made tests complicated because it meant you had
to create and set the current user every time you wanted to create an
object, when lead to the current user being set over and over again. It
also meant you had to constantly be aware of what the CurrentUser was in
many different contexts, which was often confusing. Setting creators
explicitly simplifies everything greatly.
2020-01-21 00:09:38 -06:00
evazion
27a118dfc8 tests: drop timecop gem. 2019-08-18 11:24:41 -05:00
evazion
7c1d5e25fb post approvals: add index page + search options (fix #3579). 2018-05-05 14:00:49 -05: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
evazion
31a38ea39a flags: add flag cooldown test. 2017-05-04 17:37:59 -05:00
evazion
5db39f308a tests: fix post approval tests. 2017-04-03 17:18:32 -05:00
evazion
7c8135609b post_approval_test.rb: tabs to spaces. 2017-04-03 17:18:32 -05:00
evazion
e6328b8d30 post_approval_test.rb: move to test/unit. 2017-04-03 17:18:32 -05:00