post events: show post-related mod actions on post event page.

Show the following actions on the post events page:

* Post bans and unbans
* Post deletions and undeletions
* Thumbnail regenerations and IQDB regenerations
* Favorites moves
* Rating locks and unlocks
* Note locks and unlocks

Fixes #3825: Events/Moderation page for each post should show eventual ban actions
This commit is contained in:
evazion
2022-09-26 03:24:50 -05:00
parent 75a2814f18
commit 67c992bfbf
8 changed files with 138 additions and 7 deletions

View File

@@ -24,8 +24,13 @@ class PostEventPolicy < ApplicationPolicy
attr = attr.to_s.gsub("creator", "uploader").to_sym if type == "Post"
attr = attr.to_s.gsub("creator", "user").to_sym if type in "PostApproval" | "PostDisapproval"
# XXX ordering by created_at desc is a query planner hack to make Postgres use the right indexes.
events.where(model: type.constantize.visible_for_search(attr, user).order(created_at: :desc))
if type == "ModAction"
# XXX don't apply visible_for_search to mod actions because it's slow and we know all mod actions are visible
events.where(model_type: "ModAction")
else
# XXX ordering by created_at desc is a query planner hack to make Postgres use the right indexes.
events.where(model: type.constantize.visible_for_search(attr, user).order(created_at: :desc))
end
end.reduce(:or)
else
events