[Rt-commit] [svn] r1873 - in rt/branches/PLATANO-EXPERIMENTAL-CSS: . etc lib/RT/Action lib/RT/Interface

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Thu Nov 11 03:55:34 EST 2004


Author: jesse
Date: Thu Nov 11 03:55:34 2004
New Revision: 1873

Modified:
   rt/branches/PLATANO-EXPERIMENTAL-CSS/   (props changed)
   rt/branches/PLATANO-EXPERIMENTAL-CSS/etc/RT_Config.pm.in
   rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Action/SendEmail.pm
   rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Email.pm
Log:
 r9135 at tinbook:  jesse | 2004-11-11T04:51:37.057295Z
  r9043 at tinbook:  jesse | 2004-11-10T12:55:28.022711Z
   r9040 at tinbook:  jesse | 2004-11-10T12:52:28.271911Z
   RT-Ticket: 4624
   RT-Status: resolved
   RT-Update: correspond
   
   Provide more control over how autogenerated mail gets sent out via RT.
   
   
   
  
 


Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/etc/RT_Config.pm.in
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/etc/RT_Config.pm.in	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/etc/RT_Config.pm.in	Thu Nov 11 03:55:34 2004
@@ -307,12 +307,18 @@
 # sent in a request (although there is probably more to it than that)
 Set($TrustHTMLAttachments , undef);
 
+# Should RT redistribute correspondence that it identifies as
+# machine generated? A true value (the default) will do so, setting
+# this to '0' will cause no such messages to be redistributed.
+# You can also use 'privileged', which will redistribute only to
+# privileged users. This is seful if you get malformed bounces caused by
+# autocreated requestors with bogus addresses.
+Set($RedistributeAutoGeneratedMessages, 1);
 
 # If PreferRichText is set to a true value, RT will show HTML/Rich text
 # messages in preference to their plaintext alternatives. RT "scrubs" the 
 # html to show only a minimal subset of HTML to avoid possible contamination
 # by cross-site-scripting attacks.
-
 Set($PreferRichText, undef);
 
 # If $WebExternalAuth is defined, RT will defer to the environment's

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Action/SendEmail.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Action/SendEmail.pm	Thu Nov 11 03:55:34 2004
@@ -54,7 +54,7 @@
 
 use MIME::Words qw(encode_mimeword);
 
-use RT::Interface::Email;
+use RT::EmailParser;
 use Mail::Address;
 
 =head1 NAME
@@ -486,28 +486,67 @@
 
     my @blacklist;
 
+    my @types = qw/To Cc Bcc/;
+
     # Weed out any RT addresses. We really don't want to talk to ourselves!
-    @{ $self->{'To'} } =
-      RT::Interface::Email::CullRTAddresses( @{ $self->{'To'} } );
-    @{ $self->{'Cc'} } =
-      RT::Interface::Email::CullRTAddresses( @{ $self->{'Cc'} } );
-    @{ $self->{'Bcc'} } =
-      RT::Interface::Email::CullRTAddresses( @{ $self->{'Bcc'} } );
+    foreach my $type (@types) {
+        @{ $self->{$type} } =
+          RT::EmailParser::CullRTAddresses( "", @{ $self->{$type} } );
+    }
 
     # If there are no recipients, don't try to send the message.
     # If the transaction has content and has the header RT-Squelch-Replies-To
 
-    if ( defined $self->TransactionObj->Attachments->First() ) {
+    if ( $self->TransactionObj->Attachments->First() ) {
+        if (
+            $self->TransactionObj->Attachments->First->GetHeader(
+                'RT-DetectedAutoGenerated')
+          )
+        {
+
+            # What do we want to do with this? It's probably (?) a bounce
+            # caused by one of the watcher addresses being broken.
+            # Default ("true") is to redistribute, for historical reasons.
+
+            if ( !$RT::RedistributeAutoGeneratedMessages ) {
+
+                # Don't send to any watchers.
+                @{ $self->{'To'} }  = ();
+                @{ $self->{'Cc'} }  = ();
+                @{ $self->{'Bcc'} } = ();
+
+            }
+            elsif ( $RT::RedistributeAutoGeneratedMessages eq 'privileged' ) {
+
+                # Only send to "privileged" watchers.
+                #
+
+                foreach my $type (@types) {
+
+                    foreach my $addr ( @{ $self->{$type} } ) {
+                        my $user = RT::User->new($RT::SystemUser);
+                        $user->LoadByEmail($addr);
+                        @{ $self->{$type} } =
+                          grep ( !/^\Q$addr\E$/, @{ $self->{$type} } )
+                          if ( !$user->Privileged );
+
+                    }
+                }
+
+            }
+
+        }
+
         my $squelch =
           $self->TransactionObj->Attachments->First->GetHeader(
             'RT-Squelch-Replies-To');
 
         if ($squelch) {
-            @blacklist = split ( /,/, $squelch );
+            @blacklist = split( /,/, $squelch );
         }
     }
 
-# Let's grab the SquelchMailTo attribue and push those entries into the @blacklist
+    # Let's grab the SquelchMailTo attribue and push those entries into the @blacklist
     my @non_recipients = $self->TicketObj->SquelchMailTo;
     foreach my $attribute (@non_recipients) {
         push @blacklist, $attribute->Content;
@@ -518,10 +557,10 @@
 
     foreach my $person_to_yank (@blacklist) {
         $person_to_yank =~ s/\s//g;
-        @{ $self->{'To'} } = grep ( !/^$person_to_yank$/, @{ $self->{'To'} } );
-        @{ $self->{'Cc'} } = grep ( !/^$person_to_yank$/, @{ $self->{'Cc'} } );
-        @{ $self->{'Bcc'} } =
-          grep ( !/^$person_to_yank$/, @{ $self->{'Bcc'} } );
+        foreach my $type (@types) {
+            @{ $self->{$type} } =
+              grep ( !/^\Q$person_to_yank\E$/, @{ $self->{$type} } );
+        }
     }
 }
 

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Email.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Email.pm	Thu Nov 11 03:55:34 2004
@@ -159,9 +159,14 @@
     if ($Precedence =~ /^(bulk|junk)/i) {
 	return (1);
     }
-    else {
-	return (0);
+    
+    # First Class mailer uses this as a clue.
+    my $FCJunk = $head->get("X-FC-Machinegenerated") || "";
+    if ($FCJunk =~ /^true/i) {
+        return (1);
     }
+
+    return (0);
 }
 
 # }}}
@@ -705,11 +710,15 @@
     }
 
     if ($SquelchReplies) {
-        ## TODO: This is a hack.  It should be some other way to
-        ## indicate that the transaction should be "silent".
 
+        # Squelch replies to the sender, and also leave a clue to
+        # allow us to squelch ALL outbound messages. This way we
+        # can punt the logic of "what to do when we get a bounce"
+        # to the scrip. We might want to notify nobody. Or just
+        # the RT Owner. Or maybe all Privileged watchers.
         my ( $Sender, $junk ) = ParseSenderAddressFromHead($head);
         $head->add( 'RT-Squelch-Replies-To', $Sender );
+        $head->add( 'RT-DetectedAutoGenerated', 'true' );
     }
 
     # }}}


More information about the Rt-commit mailing list