Last active
October 31, 2016 14:16
-
-
Save nileshgr/637cdacd1aa7710343aede20cabb66a6 to your computer and use it in GitHub Desktop.
In-reply-to patch for Request Tracker ticket system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
no warnings qw(redefine); | |
package RT::Interface::Email; | |
sub ParseInReplyTo { | |
my $MessageId = shift; | |
$MessageId =~ s/<(.+)>/$1/; | |
chomp $MessageId; | |
if($MessageId ne '') { | |
$RT::Logger->info("Looking for ticket with message id: $MessageId"); | |
my $query = "SELECT ObjectId FROM Transactions JOIN Attachments " . | |
"ON Attachments.TransactionId = Transactions.Id " . | |
"WHERE ObjectType = 'RT::Ticket' " . | |
"AND MessageId = ?;"; | |
my @result = $RT::Handle->FetchResult($query, $MessageId); | |
if($#result >= 0) { | |
$RT::Logger->info("Found ticketID using In-Reply-To: " . $result[0]); | |
return $result[0]; | |
} | |
} | |
return undef; | |
} | |
*_ExtractTicketId = \&ExtractTicketId; | |
*ExtractTicketId = sub { | |
my $message = shift; | |
my $head = $message->head; | |
if(defined($head->get('In-Reply-To'))) { | |
my $ticketid = &ParseInReplyTo($head->get('In-Reply-To')); | |
return $ticketid if(defined($ticketid)); | |
} | |
$RT::Logger->info("Did not find ticket id using in-reply-to, calling _ExtractTicketId"); | |
return &_ExtractTicketId($message); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment