[rt-users] Email threading in RT 3.0.2: worse than in RT 2

Dirk Pape pape-rt at inf.fu-berlin.de
Thu May 15 05:09:10 EDT 2003


Hello Jesse,

--Am Dienstag, 13. Mai 2003 8:47 Uhr +0200 schrieb Dirk Pape 
<pape-rt at inf.fu-berlin.de>:

> I am sure, I were not runnig a third party patch. Perhaps RT2 was
> different in *not stripping* In-Reply-To- and Reference-Headers form
> mails, when external MUAs created them.
>
> This would be a *step one* to restore threading functionality in RT3.

I attach a patch that make me almost happy. It

a) preserves all threading information, if RT is used as "gateway" between 
customer's and admin's MUAs.
b) it always adds a reference to the first message of a ticket, so basic 
threading also works, if correspondance is through the web interface.

to do: support creating more appropriate headers for correspondance from 
web interface (tracking which part of a ticket is replied to).

Dirk.
-------------- next part --------------
use strict;
use vars qw/@ISA/;

sub SetReferences {
    # by Dirk Pape, pape at inf.fu-berin.de
    my $self = shift;

    if ( ! $self->TransactionObj
         || ! $self->TransactionObj->Attachments
         || ! ( my $inMessage = $self->TransactionObj->Attachments->First ) ) {
        # when will this happen, and what ist to be done then???
        # $self->SetHeader( 'In-Reply-To',
        #                   "<rt-" . $self->TicketObj->id() . "\@" . $RT::rtname . ">" );
    }
    else {
        # handle references header
        my $references = $inMessage->GetHeader( 'References');
        my $inMessageId = $inMessage->GetHeader( 'Message-ID');
        # put all refs in a hash to avoid doublets
        my %refs=();
        map { $refs{$_}=1 } (split (/\s+/,$references));
        # always add a reference to the first message of the Ticket
        # to be done!!
        if ( $self->TicketObj
             && $self->TicketObj->Transactions
             && (my $firstTransaction = $self->TicketObj->Transactions->First) ) {
            if ( $firstTransaction->Attachments
                 && $firstTransaction->Attachments->First
                 && (my $initialRef = $firstTransaction->Attachments->First->GetHeader( 'Message-ID') ) ) {
                $refs{$initialRef}=1;
            }
        }
        # add a reference to the message id of the inMessage
        if ( $inMessageId ) {
            $refs{ $inMessageId }=1;
        }
        # expand the hash
        $references = join(" ",keys(%refs));
        # copy the header into the outgoing message
        if ( $references ) {
            $self->SetHeader( 'References', $references );
        }

        # handle in-reply-to header
        # if the inmessage is a reply we assume correspondence that
        # will be forwarded, hence we copy the header into the outgoing message
        if ( my $inreplyto = $inMessage->GetHeader( 'In-Reply-To') ) {
            $self->SetHeader( 'In-Reply-To', $inreplyto );
        } else {
            # otherwise we reply to the incoming message
            if ( $inMessageId ) {
                $self->SetHeader( 'In-Reply-To', $inMessageId );
            }
        }
    }
}


More information about the rt-users mailing list