]> git.proxmox.com Git - pmg-api.git/commitdiff
MailQueue.pm: create new TicketID when inserting data to CMSReceivers
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 28 Dec 2017 10:30:08 +0000 (11:30 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 28 Dec 2017 10:30:08 +0000 (11:30 +0100)
PMG/MailQueue.pm

index b7dcb6cf4c8de575dffa0c6ffb7761eed50296f1..37d30d7efdb7f35cdaed3991a4d4179998a57c2f 100644 (file)
@@ -170,6 +170,8 @@ sub quarantinedb_insert {
 
        my $now = time();
 
+       my $tid = int(rand(0x0fffffff));
+
        foreach my $r (@$targets) {
            my $pmail = get_primary_mail ($ldap, $r);
            my $receiver;
@@ -182,8 +184,11 @@ sub quarantinedb_insert {
 
            $pmail = $dbh->quote ($pmail);
            $insert_cmds .= "INSERT INTO CMSReceivers " .
-               "(CMailStore_CID, CMailStore_RID, PMail, Receiver, Status, MTime) " .
-               "VALUES ($lcid, currval ('cmailstore_id_seq'), $pmail, $receiver, 'N', $now); ";
+               "(CMailStore_CID, CMailStore_RID, PMail, Receiver, TicketID, Status, MTime) " .
+               "VALUES ($lcid, currval ('cmailstore_id_seq'), $pmail, $receiver, $tid, 'N', $now); ";
+
+           # Note: Tuple (CID, RID, TicketID) must be unique
+           $tid = ($tid + 1) & 0x0fffffff;
        }
 
        $dbh->do ($insert_cmds);