Commit Graph

50 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
e3af738371 tests: fix broken tests. 2022-08-24 02:03:37 -05:00
evazion
3ae62d08eb favorites: show favlist when hovering over favcount.
Changes:

* Make it so you can click or hover over a post's favorite count to see
  the list of public favorites.
* Remove the "Show »" button next to the favorite count.
* Make the favorites list visible to all users. Before favorites were
  only visible to Gold users.
* Make the /favorites page show the list of all public favorites,
  instead of redirecting to the current user's favorites.
* Add /posts/:id/favorites endpoint.
* Add /users/:id/favorites endpoint.

This is for several reasons:

* To make viewing favorites work the same way as viewing upvotes.
* To make posts load faster for Gold users. Before, we loaded all the
  favorites when viewing a post, even when the user didn't look at them.
  This made pageloads slower for posts that had hundreds or thousands of
  favorites. Now we only load the favlist if the user hovers over the favcount.
* To make the favorite list visible to all users. Before, it wasn't
  visible to non-Gold users, because of the performance issue listed above.
* To make it more obvious that favorites are public by default. Before,
  since regular users could only see the favcount, they may have
  mistakenly believed other users couldn't see their favorites.
2021-11-20 02:40:18 -06: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
1653392361 posts: stop updating fav_string attribute.
Stop updating the fav_string attribute on posts. The column still exists
on the table, but is no longer used or updated.

Like the pool_string in 7d503f08, the fav_string was used in the past to
facilitate `fav:X` searches. Posts had a hidden fav_string column that
contained a list of every user who favorited the post. These were
treated like fake hidden tags on the post so that a search for `fav:X`
was treated like a tag search.

The fav_string attribute has been unused for search purposes for a while
now. It was only kept because of technicalities that required
departitioning the favorites table first (340e1008e) before it could be
removed. Basically, removing favorites with `@favorite.destroy` was
slow because Rails always deletes object by ID, but we didn't have an
index on favorites.id, and we couldn't easily add one until the
favorites table was departitioned.

Fixes #4652. See https://github.com/danbooru/danbooru/issues/4652#issuecomment-754993802
for more discussion of issues caused by the fav_string (in short: write
amplification, post table bloat, and favorite inconsistency problems).
2021-10-09 22:36:26 -05:00
evazion
e5cfb7904c CurrentUser: remove #as method.
Replace with CurrentUser#scoped.
2021-06-22 23:39:30 -05:00
evazion
9efb374ae5 comments: allow swapping votes.
Allow users to upvote a comment, then downvote it, without raising an
error or having to manually remove the upvote first. The upvote is
automatically removed and replaced by the downvote.

Changes to the /comment_votes API:

* `POST /comment_votes` and `DELETE /comment_votes` now return a comment
  vote instead of a comment.
* The `score` param in `POST /comment_votes` is now 1 or -1, not
  `up` or `down.`
2021-01-21 07:58:50 -06: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
evazion
99a9149fc4 tests: eliminate as_user helper. 2020-06-11 01:02:01 -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
d51b0dfe17 pundit: convert moderator/post/posts 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
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
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
60ff2ae929 models: rename post/pool archives to post/pool versions. 2020-02-15 06:52:10 -06:00
evazion
ec163f96a8 posts: remove unused appeal! method. 2020-01-24 23:51:37 -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
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -06: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
Albert Yi
7dbeffbfa2 fix test 2018-05-10 15:09:04 -07:00
Albert Yi
76eeafca2c fix for tests 2018-05-10 11:24:17 -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
ba517af1db fix functional tests 2017-11-20 16:30:07 -08:00
evazion
c0e5c400a7 tests: fix tests for Rails.cache. 2017-04-16 16:48:36 -05:00
r888888888
0b8d4105aa fix tests 2017-04-04 12:39:17 -07:00
Albert Yi
5404c1d231 implement postarchive 2017-02-21 13:40:52 -08:00
evazion
73e274b2e0 tests: add more moderator/post/queues controller tests. 2017-02-06 18:48:38 -06:00
evazion
a120a63d3b tests: add more moderator/post/posts controller tests. 2017-02-06 18:48:38 -06:00
r888888888
6480864718 fixes #2469 2015-10-15 15:24:24 -07:00
Toks
095d02414c Exempt deletions from dupe flag checking 2014-10-31 20:01:42 -04:00
r888888888
9ec746b952 fix functional tests 2013-04-18 21:10:57 -07:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
f16a70ab7e fix test 2013-02-23 21:09:55 -05:00
albert
8749c43b3e refactored search 2013-01-10 17:45:52 -05:00
albert
17881068e1 * Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3
* Fixed tests
2012-06-01 19:22:58 -04:00
albert
4283bce8b9 fix functional tests 2012-01-15 17:04:22 -05:00
albert
3463e45675 fix tests 2011-12-14 11:28:05 -05:00
albert
a536a2699b * Renamed moderator/post/dashboard to moderator/post/queue
* Fixed bug with more overlay links being out of place if news listing is closed
2011-10-26 18:00:48 -04:00
albert
09d7bba90a added moderator/tag 2011-08-03 18:40:37 -04:00
albert
04103c3352 added invites 2011-07-29 19:42:25 -04:00
albert
c8afd34d15 added ip addr search 2011-07-29 18:04:50 -04:00
albert
d0e8084f0f implemented moderator dashboard queue 2011-07-22 17:34:43 -04:00
albert
4828cef27d refactored post mod queue 2011-07-22 13:35:40 -04:00