[Rt-commit] r3464 - in rt/branches/3.4-RELEASE: . html/Elements
lib/RT lib/RT/Action lib/RT/Interface
alexmv at bestpractical.com
alexmv at bestpractical.com
Tue Jul 12 12:22:02 EDT 2005
Author: alexmv
Date: Tue Jul 12 12:22:01 2005
New Revision: 3464
Modified:
rt/branches/3.4-RELEASE/ (props changed)
rt/branches/3.4-RELEASE/html/Elements/PageLayout
rt/branches/3.4-RELEASE/lib/RT/Action/Generic.pm
rt/branches/3.4-RELEASE/lib/RT/Action/SendEmail.pm
rt/branches/3.4-RELEASE/lib/RT/Attachment_Overlay.pm
rt/branches/3.4-RELEASE/lib/RT/Interface/Email.pm
rt/branches/3.4-RELEASE/lib/RT/Interface/Web.pm
rt/branches/3.4-RELEASE/lib/RT/ScripAction_Overlay.pm
rt/branches/3.4-RELEASE/lib/RT/Ticket_Overlay.pm
Log:
r4959 at zoq-fot-pik: chmrr | 2005-07-12 12:22:32 -0400
* Better threading support; Message-IDs of emails are based on the
transaction which spawned them.
* Support for ScripActionObj in Action::Generic (argument was being
passed in but never used)
* Standardize on case of 'Message-ID' per RFC
* Remove newline from Message-ID before inserting into DB
* Fixed minor HTML nit in PageLayout
Modified: rt/branches/3.4-RELEASE/html/Elements/PageLayout
==============================================================================
--- rt/branches/3.4-RELEASE/html/Elements/PageLayout (original)
+++ rt/branches/3.4-RELEASE/html/Elements/PageLayout Tue Jul 12 12:22:01 2005
@@ -76,7 +76,7 @@
% if ($actions->{"$action"}->{'html'}) {
% push @actions, $actions->{"$action"}->{'html'};
% } else {
-% push @actions, "<A class='nav' HREF=\"".$RT::WebPath."/".$actions->{$action}->{'path'}."\">".$actions->{$action}->{'title'}."</A>";
+% push @actions, qq|<a class="nav" href="|.$RT::WebPath."/".$actions->{$action}->{'path'}.qq|">|.$actions->{$action}->{'title'}."</a>";
% }
% }
<% join(" | ", @actions) | n %>
Modified: rt/branches/3.4-RELEASE/lib/RT/Action/Generic.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Action/Generic.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Action/Generic.pm Tue Jul 12 12:22:01 2005
@@ -85,31 +85,31 @@
# {{{ sub _Init
sub _Init {
my $self = shift;
- my %args = ( TransactionObj => undef,
- TicketObj => undef,
- ScripObj => undef,
- TemplateObj => undef,
- Argument => undef,
- Type => undef,
- CurrentUser => undef,
- @_ );
-
-
+ my %args = ( Argument => undef,
+ CurrentUser => undef,
+ ScripActionObj => undef,
+ ScripObj => undef,
+ TemplateObj => undef,
+ TicketObj => undef,
+ TransactionObj => undef,
+ Type => undef,
+
+ @_ );
+
$self->{'Argument'} = $args{'Argument'};
+ $self->CurrentUser( $args{'CurrentUser'});
+ $self->{'ScripActionObj'} = $args{'ScripActionObj'};
$self->{'ScripObj'} = $args{'ScripObj'};
+ $self->{'TemplateObj'} = $args{'TemplateObj'};
$self->{'TicketObj'} = $args{'TicketObj'};
$self->{'TransactionObj'} = $args{'TransactionObj'};
- $self->{'TemplateObj'} = $args{'TemplateObj'};
$self->{'Type'} = $args{'Type'};
- $self->CurrentUser( $args{'CurrentUser'});
- Scalar::Util::weaken($self->{'ScripObj'});
- Scalar::Util::weaken($self->{'TicketObj'});
- Scalar::Util::weaken($self->{'TemplateObj'});
- Scalar::Util::weaken($self->{'TransactionObj'});
-
-
-
+ Scalar::Util::weaken($self->{'ScripActionObj'});
+ Scalar::Util::weaken($self->{'ScripObj'});
+ Scalar::Util::weaken($self->{'TemplateObj'});
+ Scalar::Util::weaken($self->{'TicketObj'});
+ Scalar::Util::weaken($self->{'TransactionObj'});
}
# }}}
@@ -151,6 +151,13 @@
}
# }}}
+# {{{ sub ScripActionObj
+sub ScripActionObj {
+ my $self = shift;
+ return($self->{'ScripActionObj'});
+}
+# }}}
+
# {{{ sub Type
sub Type {
my $self = shift;
@@ -206,13 +213,11 @@
# We need to clean up all the references that might maybe get
# oddly circular
+ $self->{'ScripActionObj'} = undef;
+ $self->{'ScripObj'} = undef;
$self->{'TemplateObj'} =undef
$self->{'TicketObj'} = undef;
$self->{'TransactionObj'} = undef;
- $self->{'ScripObj'} = undef;
-
-
-
}
# }}}
Modified: rt/branches/3.4-RELEASE/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Action/SendEmail.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Action/SendEmail.pm Tue Jul 12 12:22:01 2005
@@ -229,9 +229,11 @@
my $self = shift;
my $MIMEObj = shift;
- my $msgid = $MIMEObj->head->get('Message-Id');
+ my $msgid = $MIMEObj->head->get('Message-ID');
chomp $msgid;
+ $self->ScripActionObj->{_Message_ID}++;
+
$RT::Logger->info( $msgid . " #"
. $self->TicketObj->id . "/"
. $self->TransactionObj->id
@@ -398,12 +400,13 @@
$type = 'EmailRecord';
}
+ my $msgid = $MIMEObj->head->get('Message-ID');
+ chomp $msgid;
-
my ( $id, $msg ) = $transaction->Create(
Ticket => $self->TicketObj->Id,
Type => $type,
- Data => $MIMEObj->head->get('Message-Id'),
+ Data => $msgid,
MIMEObj => $MIMEObj,
ActivateScrips => 0
);
@@ -433,20 +436,36 @@
$self->SetReturnAddress();
$self->SetReferencesHeaders();
-
-
- # TODO We should always add References headers for all message-ids
- # of previous messages related to this ticket.
-
- $self->SetHeader( 'Message-ID',
- "<rt-"
- . $RT::VERSION . "-"
- . $self->TicketObj->id() . "-"
- . $self->TransactionObj->id() . "-"
- . $self->ScripObj->Id . "."
- . rand(20) . "\@"
- . $RT::Organization . ">" )
- unless $self->TemplateObj->MIMEObj->head->get('Message-ID');
+ unless ($self->TemplateObj->MIMEObj->head->get('Message-ID')) {
+ # Get Message-ID for this txn
+ my $msgid = "";
+ $msgid = $self->TransactionObj->Message->First->GetHeader("RT-Message-ID")
+ || $self->TransactionObj->Message->First->GetHeader("Message-ID")
+ if $self->TransactionObj->Message && $self->TransactionObj->Message->First;
+
+ # If there is one, and we can parse it, then base our Message-ID on it
+ if ($msgid
+ and $msgid =~ s/<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@$RT::Organization>$/
+ "<$1." . $self->TicketObj->id
+ . "-" . $self->ScripObj->id
+ . "-" . $self->ScripActionObj->{_Message_ID}
+ . "@" . $RT::Organization . ">"/eg
+ and $2 == $self->TicketObj->id) {
+ $self->SetHeader( "Message-ID" => $msgid );
+ } else {
+ $self->SetHeader( 'Message-ID',
+ "<rt-"
+ . $RT::VERSION . "-"
+ . $$ . "-"
+ . CORE::time() . "-"
+ . int(rand(2000)) . '.'
+ . $self->TicketObj->id . "-"
+ . $self->ScripObj->id . "-" # Scrip
+ . $self->ScripActionObj->{_Message_ID} . "@" # Email sent
+ . $RT::Organization
+ . ">" );
+ }
+ }
$self->SetHeader( 'Precedence', "bulk" )
unless ( $self->TemplateObj->MIMEObj->head->get("Precedence") );
@@ -722,73 +741,58 @@
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') || '');
+ @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. (should be A and B
- # XXX FIXME TODO Sadly, MUAs hate can't cope with multiple in-reply-to)
-
- my @source_msg;
- if ( @in_reply_to) {
- @source_msg = @in_reply_to;
- }
- else {
- @source_msg = @msgid;
- }
- $self->SetHeader( 'In-Reply-To', join( " ", ( @source_msg ))); # , @msgid ) ) );
+ # There are two main cases -- this transaction was created with
+ # the RT Web UI, and hence we want to *not* append its Message-ID
+ # to the References and In-Reply-To. OR it came from an outside
+ # source, and we should treat it as per the RFC
+ if ( "@msgid" =~ /<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@$RT::Organization>/) {
+
+ # Make all references which are internal be to version which we
+ # have sent out
+ for (@references, @in_reply_to) {
+ s/<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@$RT::Organization>$/
+ "<$1." . $self->TicketObj->id .
+ "-" . $self->ScripObj->id .
+ "-" . $self->ScripActionObj->{_Message_ID} .
+ "@" . $RT::Organization . ">"/eg
+ }
- # 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.
+ # In reply to whatever the internal message was in reply to
+ $self->SetHeader( 'In-Reply-To', join( " ", ( @in_reply_to )));
+
+ # Default the references to whatever we're in reply to
+ @references = @in_reply_to unless @references;
+
+ # References are unchanged from internal
+ } else {
+ # In reply to that message
+ $self->SetHeader( 'In-Reply-To', join( " ", ( @msgid )));
- if ( !@references && scalar(@in_reply_to) ) {
- @references = @in_reply_to;
+ # Default the references to whatever we're in reply to
+ @references = @in_reply_to unless @references;
+
+ # Push that message onto the end of the references
+ push @references, @msgid;
}
-
+
+ # Push pseudo-ref to the front
my $pseudo_ref = $self->PseudoReference;
- @references = ($pseudo_ref, grep { $_ ne $pseudo_ref } @references , @msgid);
+ @references = ($pseudo_ref, grep { $_ ne $pseudo_ref } @references);
- # If there are more than 10 references headers, remove all but the first four and the last six
- # (Gotta keep this from growing forever)
+ # If there are more than 10 references headers, remove all but the
+ # first four and the last six (Gotta keep this from growing
+ # forever)
splice(@references, 4, -6) if ($#references >= 10);
-
-
+ # Add on the references
$self->SetHeader( 'References', join( " ", @references) );
$self->TemplateObj->MIMEObj->head->fold_length( 'References', 80 );
@@ -798,7 +802,7 @@
=head2 PseudoReference
-Returns a fake Message-Id: header for the ticket to allow a base level of threading
+Returns a fake Message-ID: header for the ticket to allow a base level of threading
=cut
Modified: rt/branches/3.4-RELEASE/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Attachment_Overlay.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Attachment_Overlay.pm Tue Jul 12 12:22:01 2005
@@ -157,8 +157,8 @@
defined($Subject) or $Subject = '';
chomp($Subject);
- #Get the Message-id
- my $MessageId = $Attachment->head->get( 'Message-Id', 0 );
+ #Get the Message-ID
+ my $MessageId = $Attachment->head->get( 'Message-ID', 0 );
defined($MessageId) or $MessageId = '';
chomp ($MessageId);
$MessageId =~ s/^<(.*)>$/$1/go;
Modified: rt/branches/3.4-RELEASE/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Interface/Email.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Interface/Email.pm Tue Jul 12 12:22:01 2005
@@ -530,7 +530,7 @@
my $ErrorsTo = ParseErrorsToAddressFromHead($head);
- my $MessageId = $head->get('Message-Id')
+ my $MessageId = $head->get('Message-ID')
|| "<no-message-id-" . time . rand(2000) . "\@.$RT::Organization>";
#Pull apart the subject line
Modified: rt/branches/3.4-RELEASE/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Interface/Web.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Interface/Web.pm Tue Jul 12 12:22:01 2005
@@ -460,12 +460,15 @@
Body => $args{ARGSRef}->{'UpdateContent'},
);
- $Message->head->add( 'Message-Id' => "<rt-"
+ $Message->head->add( 'Message-ID' =>
+ "<rt-"
. $RT::VERSION . "-"
- . $args{TicketObj}->id . "-"
. $$ . "-"
- . time() . "-"
- . rand(2000) . '@'
+ . CORE::time() . "-"
+ . int(rand(2000)) . "."
+ . $args{'TicketObj'}->id . "-"
+ . "0" . "-" # Scrip
+ . "0" . "@" # Email sent
. $RT::Organization
. ">" );
my $old_txn = RT::Transaction->new( $session{'CurrentUser'} );
@@ -477,11 +480,13 @@
}
if ( $old_txn->Message && $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('References') . " "
- . $old_txn->Message->First->GetHeader('Message-Id') );
+ my @in_reply_to = split(/\s+/m, $old_txn->Message->First->GetHeader('In-Reply-To') || '');
+ my @references = split(/\s+/m, $old_txn->Message->First->GetHeader('References') || '' );
+ my @msgid = split(/\s+/m,$old_txn->Message->First->GetHeader('Message-ID') || '');
+ my @rtmsgid = split(/\s+/m,$old_txn->Message->First->GetHeader('RT-Message-ID') || '');
+
+ $Message->head->replace( 'In-Reply-To', join (' ', @rtmsgid ? @rtmsgid : @msgid));
+ $Message->head->replace( 'References', join(' ', @references, @msgid, @rtmsgid));
}
if ( $args{ARGSRef}->{'UpdateAttachments'} ) {
Modified: rt/branches/3.4-RELEASE/lib/RT/ScripAction_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/ScripAction_Overlay.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/ScripAction_Overlay.pm Tue Jul 12 12:22:01 2005
@@ -175,13 +175,13 @@
eval "require $type" || die "Require of $type failed.\n$@\n";
- $self->{'Action'} = $type->new ( ScripActionObj => $self,
- TicketObj => $args{'TicketObj'},
- ScripObj => $args{'ScripObj'},
- TransactionObj => $args{'TransactionObj'},
- TemplateObj => $self->TemplateObj,
- Argument => $self->Argument,
- CurrentUser => $self->CurrentUser
+ $self->{'Action'} = $type->new ( Argument => $self->Argument,
+ CurrentUser => $self->CurrentUser,
+ ScripActionObj => $self,
+ ScripObj => $args{'ScripObj'},
+ TemplateObj => $self->TemplateObj,
+ TicketObj => $args{'TicketObj'},
+ TransactionObj => $args{'TransactionObj'},
);
}
# }}}
@@ -229,6 +229,7 @@
sub Prepare {
my $self = shift;
+ $self->{_Message_ID} = 0;
return ($self->Action->Prepare());
}
Modified: rt/branches/3.4-RELEASE/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Ticket_Overlay.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Ticket_Overlay.pm Tue Jul 12 12:22:01 2005
@@ -2374,6 +2374,24 @@
) )
if defined $args{'BccMessageTo'};
+ # If this is from an external source, we need to come up with its
+ # internal Message-ID now, so all emails sent because of this
+ # message have a common Message-ID
+ unless ($args{'MIMEObj'}->head->get('Message-ID')
+ =~ /<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@$RT::Organization>/) {
+ $args{'MIMEObj'}->head->set( 'RT-Message-ID',
+ "<rt-"
+ . $RT::VERSION . "-"
+ . $$ . "-"
+ . CORE::time() . "-"
+ . int(rand(2000)) . '.'
+ . $self->id . "-"
+ . "0" . "-" # Scrip
+ . "0" . "@" # Email sent
+ . $RT::Organization
+ . ">" );
+ }
+
#Record the correspondence (write the transaction)
my ( $Trans, $msg, $TransObj ) = $self->_NewTransaction(
Type => $args{'NoteType'},
More information about the Rt-commit
mailing list