[Rt-commit] r7313 - in rt/branches/3.6-RELEASE: .

jesse at bestpractical.com jesse at bestpractical.com
Wed Mar 21 23:16:05 EDT 2007


Author: jesse
Date: Wed Mar 21 23:16:05 2007
New Revision: 7313

Modified:
   rt/branches/3.6-RELEASE/   (props changed)
   rt/branches/3.6-RELEASE/lib/RT/Interface/Email.pm

Log:
 r53777 at pinglin:  jesse | 2007-03-21 23:15:06 -0400
 RT-Ticket: 8256
 RT-Status: resolved
 RT-Update: correspond
 
 * New API from pere at hungry.com to Avoid mail loop when using RT-Extension-CommandByMail
 


Modified: rt/branches/3.6-RELEASE/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT/Interface/Email.pm	(original)
+++ rt/branches/3.6-RELEASE/lib/RT/Interface/Email.pm	Wed Mar 21 23:16:05 2007
@@ -572,14 +572,21 @@
     chomp $Subject;
     
     # {{{ Lets check for mail loops of various sorts.
-    my ($message_is_not_machine_generated, $result);
-     ( $message_is_not_machine_generated, $ErrorsTo, $result ) = _HandleMachineGeneratedMail(
+    my ($should_store_machine_generated_message, $IsALoop, $result);
+    ( $should_store_machine_generated_message, $ErrorsTo, $result, $IsALoop ) =
+      _HandleMachineGeneratedMail(
         Message  => $Message,
         ErrorsTo => $ErrorsTo,
         Subject  => $Subject,
         MessageId => $MessageId
     );
 
+    # Do not pass loop messages to MailPlugins, to make sure the loop
+    # is broken, unless $RT::StoreLoops is set.
+    if ($IsALoop && !$should_store_machine_generated_message) {
+        return ( 0, $result, undef );
+    }
+
     $args{'ticket'} ||= ParseTicketId($Subject);
 
     $SystemTicket = RT::Ticket->new($RT::SystemUser);
@@ -695,7 +702,7 @@
     }
 
 
-    unless ($message_is_not_machine_generated) {
+    unless ($should_store_machine_generated_message) {
         return ( 0, $result, undef );
     }
     
@@ -886,7 +893,8 @@
     Subject
 
 Checks the message to see if it's a bounce, if it looks like a loop, if it's autogenerated, etc.
-Returns a triple of ("Should we continue (boolean)", "New value for $ErrorsTo", "Status message");
+Returns a triple of ("Should we continue (boolean)", "New value for $ErrorsTo", "Status message",
+"This message appears to be a loop (boolean)" );
 
 =cut
 
@@ -914,7 +922,7 @@
 
     # Warn someone if it's a loop, before we drop it on the ground
     if ($IsALoop) {
-        $RT::Logger->crit("RT Recieved mail (".$args{MessageId}.") from itself.");
+        $RT::Logger->crit("RT Received mail (".$args{MessageId}.") from itself.");
 
         #Should we mail it to RTOwner?
         if ($RT::LoopsToRTOwner) {
@@ -927,7 +935,7 @@
         }
 
         #Do we actually want to store it?
-        return ( 0, $ErrorsTo, "Message Bounced" ) unless ($RT::StoreLoops);
+        return ( 0, $ErrorsTo, "Message Bounced", $IsALoop ) unless ($RT::StoreLoops);
     }
 
     # Squelch replies if necessary
@@ -951,7 +959,7 @@
         $head->add( 'RT-Squelch-Replies-To',    $Sender );
         $head->add( 'RT-DetectedAutoGenerated', 'true' );
     }
-    return ( 1, $ErrorsTo, "Handled machine detection" );
+    return ( 1, $ErrorsTo, "Handled machine detection", $IsALoop );
 }
 
 =head2 IsCorrectAction


More information about the Rt-commit mailing list