[Rt-commit] r11981 - in rt/branches/3.8-TESTING: .
jesse at bestpractical.com
jesse at bestpractical.com
Wed Apr 30 16:08:41 EDT 2008
Author: jesse
Date: Wed Apr 30 16:08:32 2008
New Revision: 11981
Modified:
rt/branches/3.8-TESTING/ (props changed)
rt/branches/3.8-TESTING/lib/RT/Action/SendEmail.pm
Log:
r30278 at 31b: jesse | 2008-04-30 14:15:51 -0400
* Started to unify the logic for removing 'inapropriate' recipients from RT's mail sending routines
Modified: rt/branches/3.8-TESTING/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Action/SendEmail.pm (original)
+++ rt/branches/3.8-TESTING/lib/RT/Action/SendEmail.pm Wed Apr 30 16:08:32 2008
@@ -613,67 +613,55 @@
sub RemoveInappropriateRecipients {
my $self = shift;
- my $msgid = $self->TemplateObj->MIMEObj->head->get ('Message-Id');
-
-
-
- my @blacklist;
+ my @blacklist = ();
my @types = qw/To Cc Bcc/;
# Weed out any RT addresses. We really don't want to talk to ourselves!
- foreach my $type (@types) {
- @{ $self->{$type} } =
- RT::EmailParser::CullRTAddresses( "", @{ $self->{$type} } );
- }
+ @{ $self->{$_} } = RT::EmailParser::CullRTAddresses( "", @{ $self->{$_} } ) for (@types);
# 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 ( my $attachment = $self->TransactionObj->Attachments->First ) {
- if ( $attachment->GetHeader( 'RT-DetectedAutoGenerated') ) {
+ my $msgid = $self->TemplateObj->MIMEObj->head->get('Message-Id');
+
+ if ( $attachment->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->Config->Get('RedistributeAutoGeneratedMessages') ) {
-
# Don't send to any watchers.
- @{ $self->{'To'} } = ();
- @{ $self->{'Cc'} } = ();
- @{ $self->{'Bcc'} } = ();
-
- $RT::Logger->info( $msgid . " The incoming message was autogenerated. Not redistributing this message based on site configuration.\n");
- }
- elsif ( RT->Config->Get('RedistributeAutoGeneratedMessages') eq 'privileged' ) {
+ @{ $self->{$_} } = () for (@types);
+ $RT::Logger->info( $msgid
+ . " The incoming message was autogenerated. "
+ . "Not redistributing this message based on site configuration.\n"
+ );
+ } elsif ( RT->Config->Get('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 );
-
+ push @blacklist, $addr if (!$user->Privileged);
}
}
- $RT::Logger->info( $msgid . " The incoming message was autogenerated. Not redistributing this message to unprivileged users based on site configuration.\n");
-
+ $RT::Logger->info( $msgid
+ . " The incoming message was autogenerated. "
+ . "Not redistributing this message to unprivileged users based on site configuration.\n"
+ );
}
-
}
if ( my $squelch = $attachment->GetHeader('RT-Squelch-Replies-To') ) {
- @blacklist = split( /,/, $squelch );
+ push @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
push @blacklist, map $_->Content, $self->TicketObj->SquelchMailTo;
push @blacklist, $self->SquelchMailTo;
@@ -683,8 +671,7 @@
foreach my $person_to_yank (@blacklist) {
$person_to_yank =~ s/\s//g;
foreach my $type (@types) {
- @{ $self->{$type} } =
- grep !/^\Q$person_to_yank\E$/, @{ $self->{$type} };
+ @{ $self->{$type} } = grep !/^\Q$person_to_yank\E$/, @{ $self->{$type} };
}
}
}
More information about the Rt-commit
mailing list