# Decrement the counter for pending reports
self.list.pending_reports -= 1
- # XXX Send a message to the reporter?
+ # Send a message to the reporter?
+ self._send_closing_notification()
# We are done if the report has not been accepted
if not self.accepted:
# Notified At
notified_at: datetime.datetime | None = None
+ def _send_closing_notification(self):
+ """
+ Sends a notification to the reporter when this report gets closed.
+ """
+ # 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
+
+ # Fetch the person who closed the report
+ sender = self.backend.users.get_by_uid(self.closed_by)
+
+ # Fail if we could not find the sender
+ if not sender:
+ raise RuntimeError("Failed to fetch the sender '%s'" % self.closed_by)
+
+ # ACCEPTED
+ if self.accepted:
+ subject = "[IPFire DNSBL] %s" % (_("Your report for %s has been accepted") % self.name)
+
+ lines = (
+ _("Hello,"),
+ "",
+ _("Thank you for taking the time to report %s to our IPFire DNSBL service.") % self.name,
+ "",
+ _("We've reviewed your submission and are pleased to inform you that your report has been ACCEPTED."
+ " The domain has been added to our blocklist and will now be flagged by systems using our service."),
+ "",
+ _("Your contribution helps make the internet safer for everyone."
+ " We appreciate your vigilance in identifying and reporting problematic domains."),
+ "",
+ _("If you have any questions about this decision, please don't hesitate to reach out."),
+ "",
+ _("Best regards,"),
+ "-%s" % sender,
+ )
+
+ # DECLINED
+ else:
+ subject = "[IPFire DNSBL] %s" % (_("Your report for %s has been reviewed") % self.name)
+
+ lines = (
+ _("Hello,"),
+ "",
+ _("Thank you for taking the time to report %s to our IPFire DNSBL service.") % self.name,
+ "",
+ _("We've carefully reviewed your submission."
+ " After investigation, we've determined that this domain does not meet our criteria"
+ " for inclusion in the blocklist at this time, and your report has been DECLINED."),
+ "",
+ _("This decision may be due to various factors, such as insufficient evidence of malicious"
+ " activity, the domain being legitimately used, or the issue having already been resolved."),
+ "",
+ _("We genuinely appreciate you taking the time to help keep the internet safer."
+ " Your vigilance matters, and we encourage you to continue reporting suspicious domains in the future."),
+ "",
+ _("If you believe this decision was made in error or have additional information to share,"
+ " please feel free to reply to this email."),
+ "",
+ _("Best regards,"),
+ "-%s" % sender,
+ )
+
+ # Send the email
+ reporter.sendmail("\n".join(lines), sender=sender, headers={
+ "Subject" : subject,
+ })
+
# URL
@property
"""
return self._get_string("mail")
- def sendmail(self, message, headers=None):
+ def sendmail(self, message, sender=None, headers=None):
"""
Sends the given message to this user
"""
message = email.message.EmailMessage()
message.set_content(content)
+ # no-reply@ipfire.org
+ no_reply = email.utils.formataddr(("IPFire DNSBL", "no-reply@ipfire.org"))
+
# Set the recipient
message["To"] = email.utils.formataddr((self.cn, self.mail))
+ # Set the sender
+ if sender:
+ message["From"] = email.utils.formataddr((sender.cn, sender.mail))
+
+ # Set Sender: because the email is not actually coming from the sender
+ message["Sender"] = no_reply
+
# Set headers
if headers:
for header in headers:
# Set a sender if none set
if not "From" in message:
- message["From"] = email.utils.formataddr(("IPFire DNSBL", "no-reply@ipfire.org"))
+ message["From"] = no_reply
# Log the email
log.debug("Sending email:\n%s" % message.as_string())