[rt-devel] Duplicate message elimination.

J. Sloan js138 at eng.cam.ac.uk
Tue Mar 11 12:38:29 EST 2003


We have several queues on our RT2 system.  However we also often get the
case where someone replies to an RT correspondance and Ccs another queue -
the net effect is that two (or sometimes more) copies of that message end
up being attached to the existing ticket.

This is undesireable.

Part of my workaround for this was to add code to discard duplicates
(based on Message-Id) to rt-mailgate.

Here is my RT3 version of the same - nicely paramaterised an all.  Share
an enjoy.

(part two of my workaround might take longer as I try to work out how to
suitablely make it trigger a ScripCondition when there is no Transaction
to play with)

John
-------------- next part --------------
diff -c Email.pm Email.pm.orig
*** Email.pm    2003-03-11 17:29:36.000000000 +0000
--- Email.pm.orig       2003-03-10 04:47:54.000000000 +0000
***************
*** 407,413 ****

      my $MessageId = $head->get('Message-Id')
        || "<no-message-id-" . time . rand(2000) . "\@.$RT::Organization>";
-     chomp $MessageId;

      #Pull apart the subject line
      my $Subject = $head->get('Subject') || '';
--- 407,412 ----
***************
*** 598,621 ****

      # }}}

!     # OK we know we have a ticketID now.
      elsif ( $args{'action'} =~ /^(comment|correspond)$/i ) {
-       # Check for duplicates in this Ticket.
-       my $Transactions = $SystemTicket->Transactions;
-       while ($RT::DiscardDuplicates &&
-               (my $Transaction = $Transactions->Next)) {
-           next unless $Transaction;
-           while (my $Message = $Transaction->Message->Next) {
-               next unless my $msgid = $Message->GetHeader ('Message-Id');
-               if ($MessageId eq $msgid) {
-                   my $message = "MessageId $MessageId seen on this ticket already - discarding duplicate";
-                   $RT::Logger->debug ($message);
-                   return (0, $message);
-               }
-           }
-       }
-
-       #
          $Ticket->Load($args{'ticket'});
          unless ( $Ticket->Id ) {
              my $message = "Could not find a ticket with id ".$args{'ticket'};
--- 597,604 ----

      # }}}

!     #   If the action is comment, add a comment.
      elsif ( $args{'action'} =~ /^(comment|correspond)$/i ) {
          $Ticket->Load($args{'ticket'});
          unless ( $Ticket->Id ) {
              my $message = "Could not find a ticket with id ".$args{'ticket'};


More information about the Rt-devel mailing list