all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api 2/2] fix #6126: do not deliver/delete quarantined mails multiple times
Date: Thu, 30 Jan 2025 12:21:40 +0100	[thread overview]
Message-ID: <20250130112140.42219-3-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20250130112140.42219-1-s.ivanov@proxmox.com>

This was reported through our enterprise support and was easy to
reproduce.

When clicking on the action-links in the spamreport multiple times the
action was equally done multiple times, which was surprising
especially when you deliver a quarantined mail more than once.

As quarantined mail-files are not deleted upon deliver/delete (mails
can have multiple recipients), but asynchronously after the quarantine
lifetime they are only marked with status 'D'.

Use this information to prevent multiple deliveries and superfluous
database updates.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/PMG/Quarantine.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/PMG/Quarantine.pm b/src/PMG/Quarantine.pm
index 28138ba..77f64a0 100644
--- a/src/PMG/Quarantine.pm
+++ b/src/PMG/Quarantine.pm
@@ -95,6 +95,12 @@ sub deliver_quarantined_mail {
 
     my $id = 'C' . $ref->{cid} . 'R' . $ref->{rid} . 'T' . $ref->{ticketid};;
 
+    if ($ref->{status} eq 'D') {
+	syslog('info', "quarantined mail '$id' ($path) has already been delivered or marked as " .
+	    "deleted for $receiver!");
+	return 1;
+    }
+
     my $parser = PMG::MIMEUtils::new_mime_parser({
 	nested => 1,
 	decode_bodies => 0,
@@ -148,6 +154,12 @@ sub delete_quarantined_mail {
 
     my $id = 'C' . $ref->{cid} . 'R' . $ref->{rid} . 'T' . $ref->{ticketid};;
 
+    if ($ref->{status} eq 'D') {
+	syslog('info', "quarantined mail '$id' ($path) has already been delivered or marked as " .
+	    "deleted for $pmail");
+	return 1;
+    }
+
     eval {
 	my $sth = $dbh->prepare(
 	    "UPDATE CMSReceivers SET Status='D', MTime = ? WHERE " .
-- 
2.39.5



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


  parent reply	other threads:[~2025-01-30 11:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 11:21 [pmg-devel] [PATCH pmg-api 0/2] fix #6126 and improve logging for quarantine actions Stoiko Ivanov
2025-01-30 11:21 ` [pmg-devel] [PATCH pmg-api 1/2] quarantine: add receiver to delivery/delete log-messages Stoiko Ivanov
2025-01-30 11:21 ` Stoiko Ivanov [this message]
2025-02-18  9:37 ` [pmg-devel] [PATCH pmg-api 0/2] fix #6126 and improve logging for quarantine actions Christian Ebner
2025-02-21 16:59 ` [pmg-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250130112140.42219-3-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal