[Rt-commit] rt branch, 4.0/extract-ticket-id-function, created. rt-4.0.6-250-g4524256

Ruslan Zakirov ruz at bestpractical.com
Thu Jul 26 12:12:54 EDT 2012


The branch, 4.0/extract-ticket-id-function has been created
        at  45242569d1789c915e8b7a9660a82786536fb8bb (commit)

- Log -----------------------------------------------------------------
commit 45242569d1789c915e8b7a9660a82786536fb8bb
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Jul 26 20:08:49 2012 +0400

    factor out ExtractTicketId function on top of ParseTicketId
    
    it would be very handy for any extension that wants
    to implement different algorithms for attaching
    messages to tickets, for example by reference
    headers or by ids from external systems.
    
    First idea was to pass MIME::Entity right into
    ParseTicketId function as second argument, but
    this variant is more flexible. With this change
    ExtractTicketId can be overriden to change where
    id searched, but still have access to RT's
    ParseTicketId that just finds id in any string.

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 2594e99..11ab254 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1210,6 +1210,14 @@ sub SetInReplyTo {
     $mail->head->set( 'References' => Encode::encode_utf8(join ' ', @references) );
 }
 
+sub ExtractTicketId {
+    my $entity = shift;
+
+    my $subject = $entity->head('Subject') || '';
+    chomp $subject;
+    return ParseTicketId( $subject );
+}
+
 sub ParseTicketId {
     my $Subject = shift;
 
@@ -1433,7 +1441,7 @@ sub Gateway {
     }
     # }}}
 
-    $args{'ticket'} ||= ParseTicketId( $Subject );
+    $args{'ticket'} ||= ExtractTicketId( $Message );
 
     $SystemTicket = RT::Ticket->new( RT->SystemUser );
     $SystemTicket->Load( $args{'ticket'} ) if ( $args{'ticket'} ) ;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list