[Rt-commit] r5253 - RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter

ruz at bestpractical.com ruz at bestpractical.com
Thu May 18 19:02:45 EDT 2006


Author: ruz
Date: Thu May 18 19:02:44 2006
New Revision: 5253

Modified:
   RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm

Log:
* do comment/reply in plugin and before status change

Modified: RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm
==============================================================================
--- RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm	(original)
+++ RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm	Thu May 18 19:02:44 2006
@@ -5,8 +5,8 @@
 
 use RT::Interface::Email;
 
-our @REGULAR_ATTRIBUTES = qw(Queue Status Priority FinalPriority
-                             TimeWorked TimeLeft TimeEstimated Subject );
+our @REGULAR_ATTRIBUTES = qw(Queue Subject Status Priority FinalPriority);
+our @TIME_ATTRIBUTES    = qw(TimeWorked TimeLeft TimeEstimated);
 our @DATE_ATTRIBUTES    = qw(Due Starts Started Resolved Told);
 our @LINK_ATTRIBUTES    = qw(MemberOf Parents Members Children
             HasMember RefersTo ReferredToBy DependsOn DependedOnBy);
@@ -143,9 +143,10 @@
     if ( $args{'Ticket'}->id ) {
         $ticket_as_user->Load( $args{'Ticket'}->id );
 
-        foreach my $attribute (@REGULAR_ATTRIBUTES) {
-            next unless ( defined $cmds{ lc $attribute }
-                and ( $ticket_as_user->$attribute() ne $cmds{ lc $attribute } ) );
+        # we set status later as correspond can reopen ticket
+        foreach my $attribute (grep $_ ne 'Status', @REGULAR_ATTRIBUTES, @TIME_ATTRIBUTES) {
+            next unless defined $cmds{ lc $attribute };
+            next if $ticket_as_user->$attribute() eq $cmds{ lc $attribute };
 
             _SetAttribute(
                 $ticket_as_user,        $attribute,
@@ -155,10 +156,11 @@
 
         foreach my $attribute (@DATE_ATTRIBUTES) {
             next unless ( $cmds{ lc $attribute } );
+
             my $date = RT::Date->new( $args{'CurrentUser'} );
             $date->Set(
                 Format => 'unknown',
-                Value  => $cmds{ lc $attribute }
+                Value  => $cmds{ lc $attribute },
             );
             _SetAttribute( $ticket_as_user, $attribute, $date->ISO,
                 \%results );
@@ -199,6 +201,17 @@
             }
         }
 
+        {
+            my $method = ucfirst $args{'Action'};
+            my ($status, $msg) = $ticket_as_user->$method( MIMEObj => $args{'Message'} );
+            unless ( $status ) {
+                $RT::Logger->warning(
+                    "Couldn't write $args{'Action'}."
+                    ." Fallback to standard mailgate. Error: $msg");
+                return ( $args{'CurrentUser'}, $args{'AuthLevel'} );
+            }
+        }
+
         foreach my $type ( @LINK_ATTRIBUTES ) {
             my %tmp = _ParseAdditiveCommand( \%cmds, 1, $type );
             next unless keys %tmp;
@@ -281,17 +294,27 @@
             }
         }
 
+        foreach my $attribute (grep $_ eq 'Status', @REGULAR_ATTRIBUTES) {
+            next unless defined $cmds{ lc $attribute };
+            next if $ticket_as_user->$attribute() eq $cmds{ lc $attribute };
+
+            _SetAttribute(
+                $ticket_as_user,        $attribute,
+                $cmds{ lc $attribute }, \%results
+            );
+        }
+
         _ReportResults(
             Ticket => $args{'Ticket'},
             Results => \%results,
             Message => $args{'Message'}
         );
-        return ( $args{'CurrentUser'}, $args{'AuthLevel'} );
+        return ( $args{'CurrentUser'}, -2 );
 
     } else {
 
         my %create_args = ();
-        foreach my $attr (@REGULAR_ATTRIBUTES) {
+        foreach my $attr (@REGULAR_ATTRIBUTES, @TIME_ATTRIBUTES) {
             next unless exists $cmds{ lc $attr };
             $create_args{$attr} = $cmds{ lc $attr };
         }


More information about the Rt-commit mailing list