[Rt-commit] rt branch, 4.0/rfc822-attachment, updated. rt-4.0.0-220-g38ab255

Thomas Sibley trs at bestpractical.com
Thu May 12 19:09:19 EDT 2011


The branch, 4.0/rfc822-attachment has been updated
       via  38ab255dec8fec923e031d6473d2f436d7aa03b6 (commit)
      from  f889cbb350deda1e20af8be720cc5ebe5a60bfbc (commit)

Summary of changes:
 lib/RT/Transaction.pm |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

- Log -----------------------------------------------------------------
commit 38ab255dec8fec923e031d6473d2f436d7aa03b6
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu May 12 19:05:54 2011 -0400

    message/rfc822 isn't multipart, and transactions only have one top attachment
    
    If transactions somehow grow more than one top attachment, we'll need
    to switch this to create a multipart/mixed of message/rfc822 parts.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index c9d816d..b032481 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -554,20 +554,21 @@ sub ContentAsMIME {
     # transaction.  Check ACLs here before we go any further.
     return unless $self->CurrentUserCanSee;
 
-    my $entity = MIME::Entity->build(
-        Type        => 'message/rfc822',
-        Description => 'transaction ' . $self->Id,
-    );
-
     my $attachments = RT::Attachments->new( $self->CurrentUser );
     $attachments->OrderBy( FIELD => 'id', ORDER => 'ASC' );
     $attachments->Limit( FIELD => 'TransactionId', VALUE => $self->id );
     $attachments->Limit( FIELD => 'Parent',        VALUE => 0 );
+    $attachments->RowsPerPage(1);
+
+    my $top = $attachments->First;
+    return unless $top;
+
+    my $entity = MIME::Entity->build(
+        Type        => 'message/rfc822',
+        Description => 'transaction ' . $self->id,
+        Data        => $top->ContentAsMIME(Children => 1)->as_string,
+    );
 
-    while ( my $a = $attachments->Next ) {
-        $entity->make_multipart unless $entity->is_multipart;
-        $entity->add_part( $a->ContentAsMIME(Children => 1) );
-    }
     return $entity;
 }
 

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


More information about the Rt-commit mailing list