Compare commits
No commits in common. "9831a87844c4d57f1db0f3878322530ee8eae705" and "94cdfd39ffbf7bbc59efca2057e2d52d996d33d8" have entirely different histories.
9831a87844
...
94cdfd39ff
4 changed files with 23 additions and 124 deletions
16
.gitignore
vendored
16
.gitignore
vendored
|
@ -1,15 +1 @@
|
|||
blib*
|
||||
Makefile
|
||||
Makefile.old
|
||||
pm_to_blib*
|
||||
*.tar.gz
|
||||
.lwpcookies
|
||||
cover_db
|
||||
pod2htm*.tmp
|
||||
/RT-Extension-References*
|
||||
*.bak
|
||||
*.swp
|
||||
/MYMETA.*
|
||||
/t/tmp
|
||||
/xt/tmp
|
||||
*~
|
||||
*~
|
11
Makefile.PL
11
Makefile.PL
|
@ -1,11 +0,0 @@
|
|||
use inc::Module::Install;
|
||||
|
||||
RTx 'RT-Extension-ThreadByReference';
|
||||
license 'perl';
|
||||
repository 'https://github.com/akamai/rt-extension-threadbyreference';
|
||||
|
||||
requires_rt '4.0.0';
|
||||
rt_too_new '4.4.0';
|
||||
|
||||
sign;
|
||||
WriteAll;
|
|
@ -1,80 +0,0 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
package RT::Extension::ThreadByReference;
|
||||
|
||||
our $VERSION = '0.01';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
RT-Extension-ThreadByReference - Use the MIME Reference header to try and thread messages to tickets
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
When an RT ticketing queue is CCed on a message thread, it can be very
|
||||
difficult to get the subject lines correct in all parts of the
|
||||
message. This can cause a single thread to spawn off tens of
|
||||
different tickets that need manual merging.
|
||||
|
||||
This extension uses the MIME Reference header to search for threads
|
||||
to associate a message with.
|
||||
|
||||
=head1 RT VERSION
|
||||
|
||||
Works with RT 4.0 and greater.
|
||||
|
||||
=head1 INSTALLATION
|
||||
|
||||
=over
|
||||
|
||||
=item C<perl Makefile.PL>
|
||||
|
||||
=item C<make>
|
||||
|
||||
=item C<make install>
|
||||
|
||||
May need root permissions
|
||||
|
||||
=item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
|
||||
|
||||
If you are using RT 4.2 or greater, add this line:
|
||||
|
||||
Plugin('RT::Extension::ThreadByReference');
|
||||
|
||||
For RT 4.0, add this line:
|
||||
|
||||
Set(@Plugins, qw(RT::Extension::ThreadByReference));
|
||||
|
||||
or add C<RT::Extension::ThreadByReference> to your existing C<@Plugins> line.
|
||||
|
||||
=item Clear your mason cache
|
||||
|
||||
rm -rf /opt/rt4/var/mason_data/obj
|
||||
|
||||
=item Restart your webserver
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Harlan Lieberman-Berg C<< <hlieberm@akamai.com> >>
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
All bugs should be reported via email to
|
||||
|
||||
L<bug-RT-Extension-ThreadByReference@rt.cpan.org|mailto:bug-RT-Extension-ThreadByReference@rt.cpan.org>
|
||||
|
||||
or via the web at
|
||||
|
||||
L<rt.cpan.org|http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-ThreadByReference>.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Copyright (c) 2015-2016 by Akamai Technologies, Inc.
|
||||
|
||||
This software is free software; you can redistribute and/or modify it
|
||||
under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
||||
1;
|
|
@ -1,12 +1,18 @@
|
|||
package RT::Interface::Email::ThreadByReference;
|
||||
package RT::Interface::Email::TryThreading;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use RT::Interface::Email ();
|
||||
|
||||
=head1 NAME
|
||||
|
||||
RT::Interface::Email::TryThreading - Use In-Reply-To and other headers to try and find a ticket
|
||||
|
||||
=cut
|
||||
|
||||
sub GetCurrentUser {
|
||||
$RT::Logger->debug("Entering ThreadByReference");
|
||||
$RT::Logger->debug("Entering TryThreading");
|
||||
|
||||
my %args = (
|
||||
Message => undef,
|
||||
|
@ -19,13 +25,13 @@ sub GetCurrentUser {
|
|||
@_
|
||||
);
|
||||
|
||||
if ($args{'Ticket'}->id) {
|
||||
$RT::Logger->debug(sprintf("Ticket %s already assigned. You don't need my help!",
|
||||
$args{'Ticket'}->id));
|
||||
if ($args{'Ticket'}) {
|
||||
$RT::Logger->debug("Ticket %s already assigned. You don't need my help!",
|
||||
$args{'Ticket'});
|
||||
return ($args{'CurrentUser'}, $args{'AuthLevel'});
|
||||
}
|
||||
|
||||
$RT::Logger->debug(sprintf("Operating on queue %s", $args{'Queue'}));
|
||||
$RT::Logger->debug("Operating on queue %s", $args{'Queue'});
|
||||
|
||||
my @messageids = FetchPossibleHeaders($args{'Message'});
|
||||
|
||||
|
@ -35,9 +41,9 @@ sub GetCurrentUser {
|
|||
}
|
||||
|
||||
my %tickets = ();
|
||||
foreach my $messageid (@messageids) {
|
||||
if (my $ids = MessageIdToTicket($messageid)) {
|
||||
foreach my $ticket ($ids) {
|
||||
foreach $messageid (@messageids) {
|
||||
if (MessageIdToTicket($messageid)) {
|
||||
foreach $ticket ($_) {
|
||||
$tickets{$ticket} = undef;
|
||||
}
|
||||
}
|
||||
|
@ -51,11 +57,11 @@ sub GetCurrentUser {
|
|||
}
|
||||
elsif (scalar(@tickets) > 1) {
|
||||
$RT::Logger->warning("Email maps to more than one ticket.");
|
||||
$RT::Logger->warning(sprintf("Tickets: %s", @tickets));
|
||||
$RT::Logger->warning("Tickets: %s", @tickets);
|
||||
}
|
||||
|
||||
# We have the ticket. Set it.
|
||||
$RT::Logger->debug(sprintf("Threading email in ticket %s", $tickets[0]));
|
||||
$RT::Logger->debug("Threading email in ticket %s", $tickets[0]);
|
||||
$args{'Ticket'}->Load($tickets[0]);
|
||||
|
||||
return ($args{'CurrentUser'}, $args{'AuthLevel'});
|
||||
|
@ -72,22 +78,21 @@ sub FetchPossibleHeaders {
|
|||
# There may be multiple references
|
||||
# In practice, In-Reply-To seems to no longer be worth parsing, as
|
||||
# it seems to usually just be a repeat of the References.
|
||||
if (my $refs = $head->get('References')) {
|
||||
if ($head->get('References')) {
|
||||
chomp();
|
||||
|
||||
foreach my $ref (split(/\s+/, $refs)) {
|
||||
foreach my $ref (split(/\s+/, $_)) {
|
||||
$ref =~ /,?<([^>]+)>/;
|
||||
if ($1) {
|
||||
push(@msgids, $1);
|
||||
$RT::Logger->debug(sprintf("Found reference: %s", $1));
|
||||
$RT::Logger->debug("Found reference: %s", $1);
|
||||
}
|
||||
else {
|
||||
$RT::Logger->debug(sprintf("Reference with borked syntax: %s", $ref));
|
||||
$RT::Logger->debug("Reference with borked syntax: %s", $ref);
|
||||
next;
|
||||
}
|
||||
}
|
||||
}
|
||||
return @msgids;
|
||||
}
|
||||
|
||||
sub MessageIdToTicket {
|
||||
|
@ -131,11 +136,10 @@ sub MessageIdToTicket {
|
|||
);
|
||||
|
||||
my %tickets;
|
||||
while (my $attach = $attachments->Next) {
|
||||
while (my $attach => $attachments->Next) {
|
||||
$tickets{$attach->TransactionObj()->Ticket} = undef;
|
||||
}
|
||||
|
||||
return keys(%tickets);
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in a new issue