Skip to content
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

Merged
merged 8 commits into from Sep 5, 2023
Merged

Auto resolve reports trigger #3871

merged 8 commits into from Sep 5, 2023

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Aug 11, 2023

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.

@Nutomic Nutomic force-pushed the auto-resolve-reports-trigger branch from 4e8c316 to 5d10e8e Compare August 16, 2023 13:31
@@ -0,0 +1,51 @@
-- Automatically resolve all reports for a given post once it is marked as removed
-- TODO: how to set `resolver_id`?
Copy link
Member

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 the resolver_id .
  • It has a removed column, meaning you could resolve or unresolve reports based on an insert to that table.

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member

@dessalines dessalines left a 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.

@Nutomic Nutomic enabled auto-merge (squash) September 5, 2023 09:17
@Nutomic Nutomic merged commit a0ea8db into main Sep 5, 2023
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants