[Rt-commit] rt branch, 4.2/digests-of-html-mail, created. rt-4.1.8-303-g49e1acc

Alex Vandiver alexmv at bestpractical.com
Tue May 14 23:37:59 EDT 2013


The branch, 4.2/digests-of-html-mail has been created
        at  49e1acc5942c7822b7005a45aa6153f8160c09b6 (commit)

- Log -----------------------------------------------------------------
commit 49e1acc5942c7822b7005a45aa6153f8160c09b6
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, nor 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
diff --git a/t/mail/digest-attributes.t b/t/mail/digest-attributes.t
index 22e457c..c8fec84 100644
--- a/t/mail/digest-attributes.t
+++ b/t/mail/digest-attributes.t
@@ -157,6 +157,7 @@ sub email_digest_like {
     open my $digester, "-|", "$perl $RT::SbinPath/rt-email-digest $arg";
     my @results = <$digester>;
     my $content = join '', @results;
+    diag $content;
     if ( ref $pattern && ref $pattern eq 'Regexp' ) {
         like($content, $pattern);
     }

-----------------------------------------------------------------------


More information about the Rt-commit mailing list