[Rt-commit] r4424 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Fri Jan 20 07:31:10 EST 2006
Author: ruz
Date: Fri Jan 20 07:31:09 2006
New Revision: 4424
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm
Log:
r1639 at cubic-pc: cubic | 2006-01-20 09:32:02 +0300
* config options handling change
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm Fri Jan 20 07:31:09 2006
@@ -108,16 +108,16 @@
sub CheckForLoops {
my $head = shift;
- #If this instance of RT sent it our, we don't want to take it in
+ # If this instance of RT sent it our, we don't want to take it in
my $RTLoop = $head->get("X-RT-Loop-Prevention") || "";
- chomp ($RTLoop); #remove that newline
- if ($RTLoop eq "RT->Config->Get('rtname')") {
- return (1);
+ chomp ($RTLoop); # remove that newline
+ if ( $RTLoop eq RT->Config->Get('rtname') ) {
+ return 1;
}
-
+
# TODO: We might not trap the case where RT instance A sends a mail
# to RT instance B which sends a mail to ...
- return (undef);
+ return undef;
}
# }}}
@@ -176,7 +176,7 @@
=head2 IsRTAddress ADDRESS
Takes a single parameter, an email address.
-Returns true if that address matches the RT->Config->Get('RTAddressRegexp').
+Returns true if that address matches the C<RTAddressRegexp> config option.
Returns false, otherwise.
=cut
@@ -184,14 +184,13 @@
sub IsRTAddress {
my $address = shift || '';
- # Example: the following rule would tell RT not to Cc
+ # Example: the following rule would tell RT not to Cc
# "tickets at noc.example.com"
- if ( defined(RT->Config->Get('RTAddressRegexp')) &&
- $address =~ /RT->Config->Get('RTAddressRegexp')/ ) {
- return(1);
- } else {
- return (undef);
+ my $re_address = RT->Config->Get('RTAddressRegexp');
+ if ( $re_address && $address =~ /$re_address/ ) {
+ return 1;
}
+ return undef;
}
# }}}
@@ -213,7 +212,8 @@
# {{{ sub MailError
sub MailError {
- my %args = (To => RT->Config->Get('OwnerEmail'),
+ my %args = (
+ To => RT->Config->Get('OwnerEmail'),
Bcc => undef,
From => RT->Config->Get('CorrespondAddress'),
Subject => 'There has been an error',
@@ -255,7 +255,7 @@
close(MAIL);
}
else {
- $entity->send(RT->Config->Get('MailCommand'), $RT::MailParams);
+ $entity->send(RT->Config->Get('MailCommand'), RT->Config->Get('MailParams'));
}
}
@@ -436,15 +436,16 @@
my $Subject = shift;
my $id;
- my $test_name = $RT::EmailSubjectTagRegex || qr/\QRT->Config->Get('rtname')\E/;
+ my $rtname = RT->Config->Get('rtname');
+ my $test_name = RT->Config->Get('EmailSubjectTagRegex') || qr/\Q$rtname\E/;
if ( $Subject =~ s/\[$test_name\s+\#(\d+)\s*\]//i ) {
my $id = $1;
$RT::Logger->debug("Found a ticket ID. It's $id");
- return ($id);
+ return $id;
}
else {
- return (undef);
+ return undef;
}
}
@@ -532,7 +533,7 @@
my $ErrorsTo = ParseErrorsToAddressFromHead($head);
my $MessageId = $head->get('Message-ID')
- || "<no-message-id-" . time . rand(2000) . "\@.RT->Config->Get('Organization')>";
+ || "<no-message-id-". time . rand(2000) .'@'. RT->Config->Get('Organization') .'>';
#Pull apart the subject line
my $Subject = $head->get('Subject') || '';
@@ -564,18 +565,19 @@
# 1 - Normal user
# 2 - User is allowed to specify status updates etc. a la enhanced-mailgate
- push @RT::MailPlugins, "Auth::MailFrom" unless @RT::MailPlugins;
+ my @mail_plugins = RT->Config->Get('MailPlugins');
+ push @mail_plugins, "Auth::MailFrom" unless @mail_plugins;
# Since this needs loading, no matter what
- foreach (@RT::MailPlugins) {
+ foreach ( @mail_plugins ) {
my $Code;
my $NewAuthStat;
if ( ref($_) eq "CODE" ) {
$Code = $_;
}
else {
- $_ = "RT::Interface::Email::".$_ unless $_ =~ /^RT::Interface::Email::/;
+ $_ = "RT::Interface::Email::".$_ unless $_ =~ /^RTx?::Interface::Email::/;
eval "require $_;";
if ($@) {
$RT::Logger->crit("Couldn't load module '$_': $@");
@@ -781,11 +783,12 @@
Explanation => $message,
MIMEObj => $Message
);
-
+
return ( 0, $message );
}
# }}}
+ my $unsafe_actions = RT->Config->Get('UnsafeEmailCommands');
foreach my $action( @actions ) {
# If the action is comment, add a comment.
if ( $action =~ /^(comment|correspond)$/i ) {
@@ -808,7 +811,7 @@
return ( 0, "Message not recorded", $Ticket );
}
}
- elsif ($RT::UnsafeEmailCommands && $action =~ /^take$/i ) {
+ elsif ( $unsafe_actions && $action =~ /^take$/i ) {
my ( $status, $msg ) = $Ticket->SetOwner( $CurrentUser->id );
unless ($status) {
@@ -822,7 +825,7 @@
return ( 0, "Ticket not taken", $Ticket );
}
}
- elsif ( $RT::UnsafeEmailCommands && $action =~ /^resolve$/i ) {
+ elsif ( $unsafe_actions && $action =~ /^resolve$/i ) {
my ( $status, $msg ) = $Ticket->SetStatus( 'resolved' );
unless ($status) {
#Warn the sender that we couldn't actually submit the comment.
@@ -857,7 +860,6 @@
. " not a recognized action",
$Ticket
);
-
}
}
More information about the Rt-commit
mailing list