New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto resolve reports trigger #3871
Conversation
4e8c316
to
5d10e8e
Compare
@@ -0,0 +1,51 @@ | |||
-- Automatically resolve all reports for a given post once it is marked as removed | |||
-- TODO: how to set `resolver_id`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using the post
table as the triggering one, use an insert on the mod_remove_post
table, and mod_remove_comment
tables. A few benefits:
- It has the
mod_person_id
, that you can use to set theresolver_id
. - It has a
removed
column, meaning you could resolve or unresolve reports based on an insert to that table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right that makes sense, changed it. Though Im not unresolving reports, it seems unnecessary.
$$; | ||
|
||
CREATE OR REPLACE TRIGGER post_removed_resolve_reports | ||
AFTER UPDATE OF removed ON post |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will change to Insert
on the mod_remove_post
table.
5d10e8e
to
b9d2bdd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just needs a clippy fix, then feel free to merge.
Use a database trigger to auto-resolve reports for removed posts/comments. This way no extra Rust code is necessary, and it also works in case of banning a user with "remove content" checkbox.