]> git.ipfire.org Git - dbl.git/commitdiff
reports: Automatically close any reports from trusted reporters
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Mar 2026 15:24:44 +0000 (15:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Mar 2026 15:24:44 +0000 (15:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dbl/reports.py

index e37b676b1efb546e234fc0721196bf188bbb02ed..685ce5a40e967f2b4281892270fdb45db2eeefc3 100644 (file)
@@ -154,6 +154,18 @@ class Reports(object):
                if notify:
                        await report._send_opening_notification()
 
+               # Fetch the reporter
+               reporter = self.backend.users.get_by_uid(report.reported_by)
+
+               # Has this report been filed by a trusted reporter?
+               if reporter and reporter.is_trusted():
+                       # Automatically close any reports from trusted reporters
+                       await report.close(
+                               closed_by = reporter,
+                               accept    = True,
+                               notify    = notify,
+                       )
+
                return report
 
        async def notify(self):
@@ -347,7 +359,7 @@ class Report(sqlmodel.SQLModel, database.BackendMixin, table=True):
 
        # Close!
 
-       async def close(self, closed_by=None, accept=True, update_stats=True):
+       async def close(self, closed_by=None, accept=True, notify=True, update_stats=True):
                """
                        Called when a moderator has made a decision
                """
@@ -371,7 +383,8 @@ class Report(sqlmodel.SQLModel, database.BackendMixin, table=True):
                self.accepted = accept
 
                # Send a message to the reporter?
-               await self._send_closing_notification()
+               if notify:
+                       await self._send_closing_notification()
 
                # We are done if the report has not been accepted
                if not self.accepted: