[Rt-commit] r2845 - in rt/branches/QUEBEC-EXPERIMENTAL: .
html/Ticket lib/RT/Action lib/RT/Interface
jesse at bestpractical.com
jesse at bestpractical.com
Fri May 6 16:43:19 EDT 2005
Author: jesse
Date: Fri May 6 16:43:17 2005
New Revision: 2845
Modified:
rt/branches/QUEBEC-EXPERIMENTAL/ (props changed)
rt/branches/QUEBEC-EXPERIMENTAL/html/Ticket/Update.html
rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Action/SendEmail.pm
rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Interface/Web.pm
Log:
r15839 at hualien: jesse | 2005-05-06 16:35:10 -0400
r14617 at hualien: jesse | 2005-04-28 22:56:56 -0400
* Enabled proper message threading with RT
Modified: rt/branches/QUEBEC-EXPERIMENTAL/html/Ticket/Update.html
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/html/Ticket/Update.html (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/html/Ticket/Update.html Fri May 6 16:43:17 2005
@@ -121,12 +121,15 @@
</td></tr>
<tr><td align="right" valign="top"><&|/l&>Message</&>:</td><td>
<& /Elements/Callback, _CallbackName => 'BeforeMessageBox', %ARGS &>
+% { # localize %ARGS
+% local (%ARGS);
% if (exists $ARGS{UpdateContent}) {
% delete $ARGS{'QuoteTransaction'};
<& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
% } else {
<& /Elements/MessageBox, Name=>"UpdateContent", %ARGS &>
% }
+% }
</td></tr>
</table>
Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Action/SendEmail.pm (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Action/SendEmail.pm Fri May 6 16:43:17 2005
@@ -431,15 +431,9 @@
$self->SetHeaderAsEncoding( 'Subject', $RT::EmailOutputEncoding )
if ($RT::EmailOutputEncoding);
$self->SetReturnAddress();
+ $self->SetReferencesHeaders();
- # TODO: this one is broken. What is this email really a reply to?
- # If it's a reply to an incoming message, we'll need to use the
- # actual message-id from the appropriate Attachment object. For
- # incoming mails, we would like to preserve the In-Reply-To and/or
- # References.
- $self->SetHeader( 'In-Reply-To',
- "<rt-" . $self->TicketObj->id() . "\@" . $RT::rtname . ">" );
# TODO We should always add References headers for all message-ids
# of previous messages related to this ticket.
@@ -714,6 +708,78 @@
# }}}
+=head2 SetReferencesHeaders
+
+Set References and In-Reply-To headers for this message.
+
+=cut
+
+sub SetReferencesHeaders {
+
+ my $self = shift;
+ my ( @in_reply_to, @references, @msgid );
+
+ my $attachments = $self->TransactionObj->Message;
+
+ if ( my $top = $attachments->First() ) {
+ @in_reply_to = split(/\s+/m, $top->GetHeader('In-Reply-To') );
+ @references = split(/\s+/m, $top->GetHeader('References') );
+ @msgid = split(/\s+/m,$top->GetHeader('Message-Id'));
+ }
+ else {
+ return (undef);
+ }
+
+ # RFC 2822 - Section 3.6.4
+ #
+ # The "In-Reply-To:" field will contain the contents of the "Message-
+ # ID:" field of the message to which this one is a reply (the "parent
+ # message"). If there is more than one parent message, then the "In-
+ # Reply-To:" field will contain the contents of all of the parents'
+ # "Message-ID:" fields. If there is no "Message-ID:" field in any of
+ # the parent messages, then the new message will have no "In-Reply-To:"
+ # field.
+
+ # We interpret this section to mean that since this outgoing message is
+ # a child both of whatever the user was replying to and that user's reply,
+ # we want both headers.
+
+ # Scenario:
+ # RT sends joe messageid "A".
+ # Joe replies with message "B"
+ # RT forwards that to the team as "C"
+
+ # Message A has an unspecified reply-to
+ # Message B is in-reply-to A
+ # Message C is in-reply-to A and B
+
+ # XXX FIXME TODO Sadly, MUAs hate can't cope with multiple in-reply-to
+ $self->SetHeader( 'In-Reply-To', join( " ", ( @in_reply_to ))); # , @msgid ) ) );
+
+ # RFC 2822 - Section 3.6.4
+ #
+ # The "References:" field will contain the contents of the parent's
+ # "References:" field (if any) followed by the contents of the parent's
+ # "Message-ID:" field (if any). If the parent message does not contain
+ # a "References:" field but does have an "In-Reply-To:" field
+ # containing a single message identifier, then the "References:" field
+ # will contain the contents of the parent's "In-Reply-To:" field
+ # followed by the contents of the parent's "Message-ID:" field (if
+ # any). If the parent has none of the "References:", "In-Reply-To:",
+ # or "Message-ID:" fields, then the new message will have no
+ # "References:" field.
+
+ if ( !@references && scalar(@in_reply_to) ) {
+ @references = @in_reply_to;
+ }
+
+ my $pseudo_ref = '<RT-Ticket-'.$self->TicketObj->id .'@'.$RT::Organization .'>';
+ @references = grep { $_ ne $pseudo_ref } @references;
+
+ $self->SetHeader( 'References', join( " ", ( @references, @msgid, $pseudo_ref )));
+
+}
+
# }}}
# {{{ SetHeadingAsEncoding
Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Interface/Web.pm (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Interface/Web.pm Fri May 6 16:43:17 2005
@@ -459,6 +459,15 @@
Body => $args{ARGSRef}->{'UpdateContent'},
);
+ if ($args{ARGSRef}->{'QuoteTransaction'} ) {
+ my $old_txn = RT::Transaction->new($session{'CurrentUser'});
+ $old_txn->Load($args{ARGSRef}->{'QuoteTransaction'} );
+ if ($old_txn->Message->First) {
+ $Message->head->replace('In-Reply-To',$old_txn->Message->First->GetHeader('Message-Id'));
+ $Message->head->replace('References',$old_txn->Message->First->GetHeader('Message-Id'). " ".$old_txn->Message->First->GetHeader('References') );
+ }
+
+ }
if ($args{ARGSRef}->{'UpdateAttachments'}) {
$Message->make_multipart;
$Message->add_part($_) foreach values %{$args{ARGSRef}->{'UpdateAttachments'}};
More information about the Rt-commit
mailing list