From: Michael Tremer Date: Fri, 9 Jan 2026 16:34:08 +0000 (+0000) Subject: reports: Send an email to the reporter when a report is being opened X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6aaa13ca9aef3e60668fc5d211f16966ca80dcf6;p=dbl.git reports: Send an email to the reporter when a report is being opened Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/reports.py b/src/dnsbl/reports.py index 2c68a11..bb0bb55 100644 --- a/src/dnsbl/reports.py +++ b/src/dnsbl/reports.py @@ -75,6 +75,9 @@ class Reports(object): # Increment the counter of the list report.list.pending_reports += 1 + # Send a notification to the reporter + report._send_opening_notification() + return report def notify(self): @@ -229,6 +232,10 @@ class Report(sqlmodel.SQLModel, database.BackendMixin, table=True): """ Called when a moderator has made a decision """ + # Prevent a report from being closed again + if self.closed_by: + raise RuntimeError("Report %s has already been closed" % self) + # Mark this report as closed self.closed_at = sqlmodel.func.current_timestamp() self.closed_by = closed_by @@ -269,6 +276,40 @@ class Report(sqlmodel.SQLModel, database.BackendMixin, table=True): # Notified At notified_at: datetime.datetime | None = None + def _send_opening_notification(self): + """ + Sends a notification to the reporter when this report is opened. + """ + # Fetch the reporter + reporter = self.backend.users.get_by_uid(self.reported_by) + + # Do nothing if we could not find the reporter + if not reporter: + return + + # Compose the body + lines = ( + _("Hello,"), + "", + _("Thank you for submitting a report to the IPFire DNSBL service."), + "", + _("We have received your report regarding %s and wanted to confirm that it's now in our moderation queue.") % self.name, + "", + _("Our moderation team will carefully review your submission and you'll receive an update via email" + " once a decision has been made. Please note that review times may vary depending on the volume of reports we receive."), + "", + _("We appreciate your contribution to keeping the internet safer." + " Reports like yours are essential to maintaining the effectiveness of our service."), + "", + _("Best regards,"), + "-%s" % _("DNSBL Moderation Team"), + ) + + # Send the email + reporter.sendmail("\n".join(lines), headers={ + "Subject" : _("Your DNSBL Report Has Been Received"), + }) + def _send_closing_notification(self): """ Sends a notification to the reporter when this report gets closed.