From 20defce694748e4f6eed151d89b5d1b9fc8838f2 Mon Sep 17 00:00:00 2001 From: Ruslan Zakirov <ruz@bestpractical.com> Date: Wed, 17 May 2006 04:56:41 +0000 Subject: [PATCH] more patches, down to RT-3.4.2 --- patch/command_by_email-0.1-RT-3.4.2.patch | 71 +++++++++++++++++++++++ patch/command_by_email-0.1-RT-3.4.3.patch | 53 +++++++++++++++++ patch/command_by_email-0.1-RT-3.4.4.patch | 53 +++++++++++++++++ patch/command_by_email-0.1-RT-3.4.5.patch | 27 ++++----- 4 files changed, 191 insertions(+), 13 deletions(-) create mode 100644 patch/command_by_email-0.1-RT-3.4.2.patch create mode 100644 patch/command_by_email-0.1-RT-3.4.3.patch create mode 100644 patch/command_by_email-0.1-RT-3.4.4.patch diff --git a/patch/command_by_email-0.1-RT-3.4.2.patch b/patch/command_by_email-0.1-RT-3.4.2.patch new file mode 100644 index 0000000..39373d3 --- /dev/null +++ b/patch/command_by_email-0.1-RT-3.4.2.patch @@ -0,0 +1,71 @@ +--- 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( diff --git a/patch/command_by_email-0.1-RT-3.4.3.patch b/patch/command_by_email-0.1-RT-3.4.3.patch new file mode 100644 index 0000000..736009e --- /dev/null +++ b/patch/command_by_email-0.1-RT-3.4.3.patch @@ -0,0 +1,53 @@ +--- 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 diff --git a/patch/command_by_email-0.1-RT-3.4.4.patch b/patch/command_by_email-0.1-RT-3.4.4.patch new file mode 100644 index 0000000..736009e --- /dev/null +++ b/patch/command_by_email-0.1-RT-3.4.4.patch @@ -0,0 +1,53 @@ +--- 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 diff --git a/patch/command_by_email-0.1-RT-3.4.5.patch b/patch/command_by_email-0.1-RT-3.4.5.patch index e658a3b..efffbf3 100644 --- a/patch/command_by_email-0.1-RT-3.4.5.patch +++ b/patch/command_by_email-0.1-RT-3.4.5.patch @@ -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 ); } -- GitLab