From: mark Date: Wed, 7 Dec 2011 00:58:11 +0000 (+0000) Subject: RT option to exclude certain Cc addresses, #15451 X-Git-Tag: freeside_2_3_1~111 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=ff4e86db92ebc49762302c40dd31e0325f9afd1c RT option to exclude certain Cc addresses, #15451 --- diff --git a/rt/etc/RT_Config.pm b/rt/etc/RT_Config.pm index 996bc0bc6..499505371 100644 --- a/rt/etc/RT_Config.pm +++ b/rt/etc/RT_Config.pm @@ -293,6 +293,17 @@ can generate a naive first pass regexp by using Set($RTAddressRegexp , undef); +=item C<$IgnoreCcRegexp> + +C<$IgnoreCcRegexp> is a regexp to exclude addresses from automatic addition +to the Cc list. Use this for addresses that are I received by RT but +are sometimes added to Cc lists by mistake. Unlike C<$RTAddressRegexp>, +these addresses can still receive email from RT otherwise. + +=cut + +Set($IgnoreCcRegexp, undef); + =item C<$CanonicalizeEmailAddressMatch>, C<$CanonicalizeEmailAddressReplace> RT provides functionality which allows the system to rewrite diff --git a/rt/etc/RT_Config.pm.in b/rt/etc/RT_Config.pm.in index 575a94fce..ae1bc888d 100644 --- a/rt/etc/RT_Config.pm.in +++ b/rt/etc/RT_Config.pm.in @@ -293,6 +293,17 @@ can generate a naive first pass regexp by using Set($RTAddressRegexp , undef); +=item C<$IgnoreCcRegexp> + +C<$IgnoreCcRegexp> is a regexp to exclude addresses from automatic addition +to the Cc list. Use this for addresses that are I received by RT but +are sometimes added to Cc lists by mistake. Unlike C<$RTAddressRegexp>, +these addresses can still receive email from RT otherwise. + +=cut + +Set($IgnoreCcRegexp, undef); + =item C<$CanonicalizeEmailAddressMatch>, C<$CanonicalizeEmailAddressReplace> RT provides functionality which allows the system to rewrite diff --git a/rt/lib/RT/Interface/Email.pm b/rt/lib/RT/Interface/Email.pm index 401e970e8..9216887cd 100755 --- a/rt/lib/RT/Interface/Email.pm +++ b/rt/lib/RT/Interface/Email.pm @@ -997,13 +997,28 @@ sub ParseCcAddressesFromHead { my $user = $args{'CurrentUser'}->UserObj; return - grep $_ ne $current_address && !RT::EmailParser->IsRTAddress( $_ ), + grep { $_ ne $current_address + && !RT::EmailParser->IsRTAddress( $_ ) + && !IgnoreCcAddress( $_ ) + } map lc $user->CanonicalizeEmailAddress( $_->address ), map Email::Address->parse( $args{'Head'}->get( $_ ) ), qw(To Cc); } +=head2 IgnoreCcAddress ADDRESS +Returns true if ADDRESS matches the $IgnoreCcRegexp config variable. + +=cut + +sub IgnoreCcAddress { + my $address = shift; + if ( my $address_re = RT->Config->Get('IgnoreCcRegexp') ) { + return 1 if $address =~ /$address_re/i; + } + return undef; +} =head2 ParseSenderAddressFromHead HEAD