Skip to content

Auto resolve reports trigger#3871

Merged
Nutomic merged 8 commits intomainfrom
auto-resolve-reports-trigger
Sep 5, 2023
Merged

Auto resolve reports trigger#3871
Nutomic merged 8 commits intomainfrom
auto-resolve-reports-trigger

Conversation

@Nutomic
Copy link
Copy Markdown
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.

Comment thread crates/db_views/src/post_report_view.rs
@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@Nutomic Nutomic force-pushed the auto-resolve-reports-trigger branch from 5d10e8e to b9d2bdd Compare September 1, 2023 12:46
Copy link
Copy Markdown
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
@Nothing4You Nothing4You deleted the auto-resolve-reports-trigger branch September 11, 2025 17:28
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.

2 participants