1 Patch to add References and In-Reply-To parsing and handling to OTRS.
3 Created 2004-01-09 by Petter Reinholdtsen <pere@hungry.com>
5 --- Kernel/Config/Defaults.pm.orig 2003-07-13 21:23:21.000000000 +0200
6 +++ Kernel/Config/Defaults.pm 2004-01-09 15:21:43.000000000 +0100
16 --- Kernel/System/PostMaster.pm.orig 2003-06-22 20:37:36.000000000 +0200
17 +++ Kernel/System/PostMaster.pm 2004-01-09 16:57:48.000000000 +0100
21 my $Subject = $Param{Subject} || '';
22 - if (my $Tn = $Self->{TicketObject}->GetTNByString($Subject)) {
23 - my $TicketID = $Self->{TicketObject}->CheckTicketNr(Tn => $Tn);
26 + if ($Tn = $Self->{TicketObject}->GetTNByString($Subject)) {
27 + $TicketID = $Self->{TicketObject}->CheckTicketNr(Tn => $Tn);
28 if ($Self->{Debug} > 1) {
29 $Self->{LogObject}->Log(
31 Message => "CheckFollowUp: Tn: $Tn found or forward!",
35 - if ($Self->{Debug} > 1) {
36 - $Self->{LogObject}->Log(
38 + # Based on info from <URL:http://www.jwz.org/doc/threading.html>
41 + # Extract Message-id(s) from References and In-Reply-to
42 + my $references = $Param{References};
43 + my $inreplyto = $Param{'In-Reply-To'}; # XXX Check capitalisation
45 + push(@msgids, split(/\s+/, $references)) if ($references);
48 + if ($inreplyto =~ m/(<[^>]+>)/) {
51 + $Self->{LogObject}->Log(
52 + Priority => 'debug',
53 + Message => "CheckFollowUp: Unhandled In-Reply-To: '$inreplyto'",
58 + # Look up Message-id(s) using Article::ArticleMsgIdLookup
62 + for $msgid (@msgids) {
63 + next if $checked{$msgid};
65 + $Self->{TicketObject}->ArticleMsgIdLookup(MessageID => $msgid);
68 + for $aid (@ArticleIDs) {
70 + $Self->{TicketObject}->GetArticle(ArticleID => $aid);
71 + my $tn = $Self->{TicketObject}->GetTNOfId(ID => $data{TicketID});
72 + push(@TicketIDs, $tn);
74 + push(@ids, @TicketIDs) if (@TicketIDs);
75 + $checked{$msgid} = 1;
78 + # Reduce list of IDs to unique IDs only
81 + for $id (sort @ids) {
84 + @ids = sort keys %idhash;
86 + # If the Message-id(s) are already in the database, use their
89 + if ($Self->{Debug} > 1) {
90 + $Self->{LogObject}->Log(
91 + Priority => 'debug',
92 + Message => "CheckFollowUp: Several possible ticket ids",
97 + # Just pick the first. Not sure how we should handle several
101 + $TicketID = $Self->{TicketObject}->CheckTicketNr(Tn => $Tn);
105 + if ($Self->{Debug} > 1) {
106 + $Self->{LogObject}->Log(
108 - Message => "CheckFollowUp: ja, it's a follow up ($Tn/$TicketID)",
109 + Message => "CheckFollowUp: yes, it's a follow up ($Tn/$TicketID)",
112 - return ($Tn, $TicketID);
115 + return ($Tn, $TicketID);
119 --- Kernel/System/Ticket/Article.pm.orig 2003-06-19 00:40:35.000000000 +0200
120 +++ Kernel/System/Ticket/Article.pm 2004-01-09 15:21:15.000000000 +0100
125 +sub ArticleMsgIdLookup {
130 + # check needed stuff
132 + if (!$Param{MessageID}) {
133 + $Self->{LogObject}->Log(Priority => 'error', Message => "Need MessageID!");
139 + my $SQL = "SELECT id" .
143 + " a_message_id = '$Param{MessageID}' " .
144 + " ORDER BY incoming_time";
145 + $Self->{DBObject}->Prepare(SQL => $SQL);
146 + while (my @Row = $Self->{DBObject}->FetchrowArray()) {
147 + push (@Index, $Row[0]);