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

Ruslan Zakirov ruz at bestpractical.com
Tue Aug 14 12:39:50 EDT 2012


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

- Log -----------------------------------------------------------------
commit 139f5da162ceb64bf33a31d7013e8b98d6866d18
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..9270462 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->get('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