[Rt-commit] rt branch, 4.2/digests-of-html-mail, created. rt-4.1.8-303-g65cf310
Thomas Sibley
trs at bestpractical.com
Thu May 16 18:52:39 EDT 2013
The branch, 4.2/digests-of-html-mail has been created
at 65cf3109b0ff4d514af7741d79028556a8005e29 (commit)
- Log -----------------------------------------------------------------
commit 65cf3109b0ff4d514af7741d79028556a8005e29
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue May 14 23:34:11 2013 -0400
Headers and content may be on different attachments when building digests
The recent HTML templates branch causes $attachment->ContentObj for
default templates to no longer contain the top-level RFC822 headers such
as From, To, and Subject, which breaks assumptions in rt-email-digest.
Store the entire transaction, not just the ContentObj attachment, in the
hash. This allows us to satisfy both the locations which inspect the
headers (making use of the ->Attachments->First), as well as where the
content is extracted (using ->ContentObj->Content).
diff --git a/sbin/rt-email-digest.in b/sbin/rt-email-digest.in
index 2f01c95..554d32c 100644
--- a/sbin/rt-email-digest.in
+++ b/sbin/rt-email-digest.in
@@ -256,7 +256,7 @@ sub find_transactions {
my $queue = $txn->TicketObj->QueueObj->Name;
# Xxx todo - may clobber if two queues have the same name
foreach my $user ( $txn->DeferredRecipients($frequency) ) {
- $all_digest->{$user}->{$queue}->{$ticket}->{ $txn->id } = $txn->ContentObj;
+ $all_digest->{$user}->{$queue}->{$ticket}->{ $txn->id } = $txn;
$sent_transactions->{$user}->{ $txn->id } = $txn;
}
}
@@ -300,12 +300,14 @@ sub build_digest_for_user {
# Spit out the messages for the transactions on this ticket.
$contents_body .= "\n== $ticket_title\n";
foreach my $txn ( sort keys %$tkt_txns ) {
- my $msg = $tkt_txns->{$txn};
-
- # $msg contains an RT::Attachment with our outgoing
- # message. Print a few headers for clarity's sake.
- $contents_body .= "From: " . $msg->GetHeader('From') . "\n";
- my $date = $msg->GetHeader('Date ');
+ my $top = $tkt_txns->{$txn}->Attachments->First;
+
+ # $top contains the top-most RT::Attachment with our
+ # outgoing message. It may not be the MIME part with
+ # the content. Print a few headers from it for
+ # clarity's sake.
+ $contents_body .= "From: " . $top->GetHeader('From') . "\n";
+ my $date = $top->GetHeader('Date ');
unless ($date) {
my $txn_obj = RT::Transaction->new( RT->SystemUser );
$txn_obj->Load($txn);
@@ -318,7 +320,7 @@ sub build_digest_for_user {
@{ [ localtime( $date_obj->Unix ) ] } );
}
$contents_body .= "Date: $date\n\n";
- $contents_body .= $msg->Content . "\n";
+ $contents_body .= $tkt_txns->{$txn}->ContentObj->Content . "\n";
$contents_body .= "-------\n";
} # foreach transaction
} # foreach ticket
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list