[Rt-commit] rt branch, 4.0/dont-squelch-one-time-recipients, created. rt-4.0.0rc6-126-g3933f28
Ruslan Zakirov
ruz at bestpractical.com
Tue Mar 8 02:35:39 EST 2011
The branch, 4.0/dont-squelch-one-time-recipients has been created
at 3933f28a6870ed2b338d07ba1bbce7159e8e0ca5 (commit)
- Log -----------------------------------------------------------------
commit 0f467ba798c3c3da7cb0e3f6daf4836b823a8dd3
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Apr 21 01:05:55 2010 +0400
use `eq` op instead of regexp
diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index 1559a07..41c2d03 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -813,7 +813,7 @@ sub RemoveInappropriateRecipients {
$RT::Logger->info( $msgid . "$addr appears to point to this RT instance. Skipping" );
next;
}
- if ( grep /^\Q$addr\E$/, @blacklist ) {
+ if ( grep $addr eq $_, @blacklist ) {
$RT::Logger->info( $msgid . "$addr was blacklisted for outbound mail on this transaction. Skipping");
next;
}
commit 1f804aecf3023ed6d7aca890dd11d7d3f4692eaf
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Apr 21 03:20:54 2010 +0400
No squelch mode and no NotifyActor affect for One-time recipients
diff --git a/lib/RT/Action/Notify.pm b/lib/RT/Action/Notify.pm
index b999426..2dbad8e 100644
--- a/lib/RT/Action/Notify.pm
+++ b/lib/RT/Action/Notify.pm
@@ -87,17 +87,6 @@ sub SetRecipients {
my ( @To, @PseudoTo, @Cc, @Bcc );
- if ( $arg =~ /\bOtherRecipients\b/ ) {
- if ( my $attachment = $self->TransactionObj->Attachments->First ) {
- push @Cc, map { $_->address } Email::Address->parse(
- $attachment->GetHeader('RT-Send-Cc')
- );
- push @Bcc, map { $_->address } Email::Address->parse(
- $attachment->GetHeader('RT-Send-Bcc')
- );
- }
- }
-
if ( $arg =~ /\bRequestor\b/ ) {
push @To, $ticket->Requestors->MemberEmailAddresses;
}
@@ -162,7 +151,14 @@ sub SetRecipients {
}
@{ $self->{'PseudoTo'} } = @PseudoTo;
-
+ if ( $arg =~ /\bOtherRecipients\b/ ) {
+ if ( my $attachment = $self->TransactionObj->Attachments->First ) {
+ push @{ $self->{'NoSquelch'}{'Cc'} ||= [] }, map $_->address,
+ Email::Address->parse( $attachment->GetHeader('RT-Send-Cc') );
+ push @{ $self->{'NoSquelch'}{'Bcc'} ||= [] }, map $_->address,
+ Email::Address->parse( $attachment->GetHeader('RT-Send-Bcc') );
+ }
+ }
}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index 41c2d03..e7331a2 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -819,6 +819,14 @@ sub RemoveInappropriateRecipients {
}
push @addrs, $addr;
}
+ foreach my $addr ( @{ $self->{'NoSquelch'}{$type} || [] } ) {
+ # never send email to itself
+ if ( !RT::EmailParser->CullRTAddresses($addr) ) {
+ $RT::Logger->info( $msgid . "$addr appears to point to this RT instance. Skipping" );
+ next;
+ }
+ push @addrs, $addr;
+ }
@{ $self->{$type} } = @addrs;
}
}
commit 4906eca28dbd901c721271e8625fd97add86669b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Apr 21 03:22:32 2010 +0400
minor
diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index e7331a2..f60f697 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -801,7 +801,8 @@ sub RemoveInappropriateRecipients {
# system blacklist
# Trim leading and trailing spaces.
- @blacklist = map { RT::User->CanonicalizeEmailAddress( $_->address ) } Email::Address->parse(join(', ', grep {defined} @blacklist));
+ @blacklist = map { RT::User->CanonicalizeEmailAddress( $_->address ) }
+ Email::Address->parse( join ', ', grep defined, @blacklist );
foreach my $type (@EMAIL_RECIPIENT_HEADERS) {
my @addrs;
commit 3933f28a6870ed2b338d07ba1bbce7159e8e0ca5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Mar 8 10:32:05 2011 +0300
test one time recipients vs. NotifyActor and Squelching
diff --git a/t/mail/one-time-recipients.t b/t/mail/one-time-recipients.t
new file mode 100644
index 0000000..985f955
--- /dev/null
+++ b/t/mail/one-time-recipients.t
@@ -0,0 +1,209 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use utf8;
+
+use RT::Test tests => 38;
+
+my $queue = RT::Test->load_or_create_queue(
+ Name => 'General',
+ CorrespondAddress => 'rt-recipient at example.com',
+ CommentAddress => 'rt-recipient at example.com',
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+my $user = RT::Test->load_or_create_user(
+ Name => 'root',
+ EmailAddress => 'root at localhost',
+);
+ok $user && $user->id, 'loaded or created user';
+
+diag "Reply to ticket with actor as one time cc";
+{
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
+ my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => 'root at localhost',
+ );
+ ok $status, "created ticket";
+
+ my @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('To');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'root at localhost', 'got mail'
+ }
+
+ RT->Config->Set( NotifyActor => 1 );
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('To');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'root at localhost', 'got mail'
+ }
+
+ RT->Config->Set( NotifyActor => 0 );
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok !@mails, "no mail - don't notify actor";
+
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ CcMessageTo => 'root at localhost',
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('Cc');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'root at localhost', 'got mail'
+ }
+}
+
+diag "Reply to ticket with requestor squelched";
+{
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
+ my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => 'test at localhost',
+ );
+ ok $status, "created ticket";
+
+ my @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('To');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'test at localhost', 'got mail'
+ }
+
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('To');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'test at localhost', 'got mail'
+ }
+
+ $ticket->SquelchMailTo('test at localhost');
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok !@mails, "no mail - squelched";
+
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ CcMessageTo => 'test at localhost',
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('Cc');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'test at localhost', 'got mail'
+ }
+}
+
+diag "Reply to ticket with requestor squelched";
+{
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
+ my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => 'test at localhost',
+ );
+ ok $status, "created ticket";
+
+ my @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('To');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'test at localhost', 'got mail'
+ }
+
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('To');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'test at localhost', 'got mail'
+ }
+
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ SquelchMailTo => ['test at localhost'],
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok !@mails, "no mail - squelched";
+
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('To');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'test at localhost', 'got mail'
+ }
+
+ ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ CcMessageTo => 'test at localhost',
+ SquelchMailTo => ['test at localhost'],
+ );
+ ok $status, "replied to a ticket";
+
+ @mails = RT::Test->fetch_caught_mails;
+ ok @mails, "got some outgoing emails";
+ foreach my $mail ( @mails ) {
+ my $entity = parse_mail( $mail );
+ my $to = $entity->head->get('Cc');
+ $to =~ s/^\s+|\s+$//;
+ is $to, 'test at localhost', 'got mail'
+ }
+}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list