Skip to content
Snippets Groups Projects
Commit 20defce6 authored by Ruslan Zakirov's avatar Ruslan Zakirov
Browse files

more patches, down to RT-3.4.2

parent 5665c0c5
No related branches found
No related tags found
No related merge requests found
--- lib/RT/Interface/Email.pm 2006-05-17 06:05:17.000000000 +0400
+++ lib/RT/Interface/Email.pm 2006-05-17 06:29:42.000000000 +0400
@@ -544,10 +544,9 @@
$args{'ticket'} ||= ParseTicketId($Subject);
- my $SystemTicket;
+ my $SystemTicket = RT::Ticket->new($RT::SystemUser);
my $Right = 'CreateTicket';
if ( $args{'ticket'} ) {
- $SystemTicket = RT::Ticket->new($RT::SystemUser);
$SystemTicket->Load( $args{'ticket'} );
# if there's an existing ticket, this must be a reply
$Right = 'ReplyToTicket';
@@ -570,6 +569,10 @@
push @RT::MailPlugins, "Auth::MailFrom" unless @RT::MailPlugins;
+ # if plugin returns AuthStat -2 we skip action
+ # NOTE: this is experimental API and it would be changed
+ my %skip_action = ();
+
# Since this needs loading, no matter what
foreach (@RT::MailPlugins) {
@@ -604,11 +607,12 @@
# If a module returns a "-1" then we discard the ticket, so.
- $AuthStat = -1 if $NewAuthStat == -1;
+ $AuthStat = $NewAuthStat if $NewAuthStat == -1 or $NewAuthStat == -2;
# You get the highest level of authentication you were assigned.
$AuthStat = $NewAuthStat if $NewAuthStat > $AuthStat;
last if $AuthStat == -1;
+ $skip_action{ $args{'action'} }++ if $AuthStat == -2;
}
# {{{ If authentication fails and no new user was created, get out.
@@ -730,7 +734,7 @@
my $Ticket = RT::Ticket->new($CurrentUser);
# {{{ If we don't have a ticket Id, we're creating a new ticket
- if ( !$SystemTicket || !$SystemTicket->Id) {
+ if ( (!$SystemTicket || !$SystemTicket->Id) && !$skip_action{ $args{'action'} } ) {
# {{{ Create a new ticket
@@ -769,10 +773,10 @@
# }}}
# If the action is comment, add a comment.
- elsif ( $args{'action'} =~ /^(comment|correspond)$/i ) {
- $Ticket->Load( $args{'ticket'} );
+ elsif ( $args{'action'} =~ /^(comment|correspond)$/i && !$skip_action{ $args{'action'} } ) {
+ $Ticket->Load( $SystemTicket->Id );
unless ( $Ticket->Id ) {
- my $message = "Could not find a ticket with id " . $args{'ticket'};
+ my $message = "Could not find a ticket with id " . $SystemTicket->Id || $args{'ticket'};
MailError(
To => $ErrorsTo,
Subject => "Message not recorded",
@@ -803,7 +807,7 @@
}
}
- else {
+ elsif ( !$skip_action{ $args{'action'} } ) {
#Return mail to the sender with an error
MailError(
--- lib/RT/Interface/Email.pm 2005-08-03 04:18:54.000000000 +0400
+++ lib/RT/Interface/Email.pm 2006-05-17 07:39:13.000000000 +0400
@@ -540,10 +540,9 @@
$args{'ticket'} ||= ParseTicketId($Subject);
- my $SystemTicket;
+ my $SystemTicket = RT::Ticket->new($RT::SystemUser);
my $Right = 'CreateTicket';
if ( $args{'ticket'} ) {
- $SystemTicket = RT::Ticket->new($RT::SystemUser);
$SystemTicket->Load( $args{'ticket'} );
# if there's an existing ticket, this must be a reply
$Right = 'ReplyToTicket';
@@ -566,6 +565,10 @@
push @RT::MailPlugins, "Auth::MailFrom" unless @RT::MailPlugins;
+ # if plugin returns AuthStat -2 we skip action
+ # NOTE: this is experimental API and it would be changed
+ my %skip_action = ();
+
# Since this needs loading, no matter what
foreach (@RT::MailPlugins) {
@@ -602,12 +605,13 @@
# If a module returns a "-1" then we discard the ticket, so.
- $AuthStat = -1 if $NewAuthStat == -1;
+ $AuthStat = $NewAuthStat if $NewAuthStat == -1 or $NewAuthStat == -2;
# You get the highest level of authentication you were assigned.
$AuthStat = $NewAuthStat if $NewAuthStat > $AuthStat;
last if $AuthStat == -1;
+ $skip_action{ $args{'action'} }++ if $AuthStat == -2;
}
last if $AuthStat == -1;
@@ -729,6 +733,12 @@
# }}}
+ # strip skipped actions
+ @actions = grep !$skip_action{$_}, @actions;
+
+ # if plugin changed system ticket then we should update ticket
+ $args{'ticket'} = $SystemTicket->Id if $SystemTicket && $SystemTicket->Id;
+
my $Ticket = RT::Ticket->new($CurrentUser);
# {{{ If we don't have a ticket Id, we're creating a new ticket
--- lib/RT/Interface/Email.pm 2005-08-03 04:18:54.000000000 +0400
+++ lib/RT/Interface/Email.pm 2006-05-17 07:39:13.000000000 +0400
@@ -540,10 +540,9 @@
$args{'ticket'} ||= ParseTicketId($Subject);
- my $SystemTicket;
+ my $SystemTicket = RT::Ticket->new($RT::SystemUser);
my $Right = 'CreateTicket';
if ( $args{'ticket'} ) {
- $SystemTicket = RT::Ticket->new($RT::SystemUser);
$SystemTicket->Load( $args{'ticket'} );
# if there's an existing ticket, this must be a reply
$Right = 'ReplyToTicket';
@@ -566,6 +565,10 @@
push @RT::MailPlugins, "Auth::MailFrom" unless @RT::MailPlugins;
+ # if plugin returns AuthStat -2 we skip action
+ # NOTE: this is experimental API and it would be changed
+ my %skip_action = ();
+
# Since this needs loading, no matter what
foreach (@RT::MailPlugins) {
@@ -602,12 +605,13 @@
# If a module returns a "-1" then we discard the ticket, so.
- $AuthStat = -1 if $NewAuthStat == -1;
+ $AuthStat = $NewAuthStat if $NewAuthStat == -1 or $NewAuthStat == -2;
# You get the highest level of authentication you were assigned.
$AuthStat = $NewAuthStat if $NewAuthStat > $AuthStat;
last if $AuthStat == -1;
+ $skip_action{ $args{'action'} }++ if $AuthStat == -2;
}
last if $AuthStat == -1;
@@ -729,6 +733,12 @@
# }}}
+ # strip skipped actions
+ @actions = grep !$skip_action{$_}, @actions;
+
+ # if plugin changed system ticket then we should update ticket
+ $args{'ticket'} = $SystemTicket->Id if $SystemTicket && $SystemTicket->Id;
+
my $Ticket = RT::Ticket->new($CurrentUser);
# {{{ If we don't have a ticket Id, we're creating a new ticket
......@@ -512,7 +512,7 @@
}
last if $AuthStat == -1;
@@ -624,132 +646,60 @@
@@ -624,132 +646,64 @@
last if $AuthStat == -1;
}
......@@ -658,23 +658,26 @@
}
- # }}}
-
my $Ticket = RT::Ticket->new($CurrentUser);
+ # strip actions we should skip
+ @actions = grep !$skip_action{$_}, @actions;
- my $Ticket = RT::Ticket->new($CurrentUser);
+ # if plugin's updated SystemTicket then update arguments
+ $args{'ticket'} = $SystemTicket->Id if $SystemTicket && $SystemTicket->Id;
- # {{{ If we don't have a ticket Id, we're creating a new ticket
- if ( (!$SystemTicket || !$SystemTicket->Id) &&
- grep /^(comment|correspond)$/, @actions ) {
-
+ my $Ticket = RT::Ticket->new($CurrentUser);
- # {{{ Create a new ticket
+ if (( !$SystemTicket || !$SystemTicket->Id )
+ && grep /^(comment|correspond)$/ && !$skip_action{$_},
+ @actions
+ )
+ && grep /^(comment|correspond)$/, @actions )
+ {
my @Cc;
my @Requestors = ( $CurrentUser->id );
@@ -776,38 +726,40 @@
@@ -776,38 +730,39 @@
Explanation => $ErrStr,
MIMEObj => $Message
);
......@@ -692,11 +695,10 @@
- }
+ } else {
- $Ticket->Load( $args{'ticket'} );
+ $Ticket->Load( $SystemTicket->id );
$Ticket->Load( $args{'ticket'} );
unless ( $Ticket->Id ) {
- my $message = "Could not find a ticket with id " . $args{'ticket'};
+ my $error = "Could not find a ticket with id " . $SystemTicket->id || $args{'ticket'};
+ my $error = "Could not find a ticket with id " . $args{'ticket'};
MailError(
To => $ErrorsTo,
Subject => "Message not recorded",
......@@ -713,7 +715,6 @@
# }}}
- foreach my $action( @actions ) {
+ foreach my $action (@actions) {
+ next if $skip_action{ $action };
+
# If the action is comment, add a comment.
- if ( $action =~ /^(comment|correspond)$/i ) {
......@@ -729,7 +730,7 @@
( $status, $msg ) = $Ticket->Comment( MIMEObj => $Message );
}
unless ($status) {
@@ -821,77 +773,196 @@
@@ -821,77 +776,196 @@
);
return ( 0, "Message not recorded", $Ticket );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment