[Rt-commit] rt branch, 4.4/email-addtickets-multipart, created. rt-4.4.1-300-gba7b76e

Jim Brandt jbrandt at bestpractical.com
Mon Jan 30 16:26:09 EST 2017


The branch, 4.4/email-addtickets-multipart has been created
        at  ba7b76e9472542be4064bc0c0ab6867fe5443d37 (commit)

- Log -----------------------------------------------------------------
commit 939f96611a9ed1956dceecb6a5458149ec50301e
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Jan 30 16:18:01 2017 -0500

    Add tests to confirm content type when using AddTickets in SendEmail

diff --git a/t/mail/add-tickets.t b/t/mail/add-tickets.t
new file mode 100644
index 0000000..2559983
--- /dev/null
+++ b/t/mail/add-tickets.t
@@ -0,0 +1,59 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my $user = RT::Test->load_or_create_user(
+    Name            => 'user1',
+    EmailAddress    => 'user1 at example.com',
+);
+
+ok(
+    RT::Test->set_rights(
+        { Principal => 'Everyone',  Right => [qw/CreateTicket ReplyToTicket CommentOnTicket/] },
+        { Principal => 'Requestor', Right => [qw/ShowTicket/] },
+    ),
+    'set rights'
+);
+
+my $ticket_a = RT::Test->create_ticket(
+        Queue       => 'General',
+        Subject     => 'ticket A',
+        Requestor   => 'user1 at example.com',
+        Content     => "First ticket",
+    );
+
+my $ticket_b = RT::Test->create_ticket(
+        Queue       => 'General',
+        Subject     => 'ticket b',
+        Requestor   => 'user1 at example.com',
+        Content     => "Second ticket",
+    );
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login( 'root', 'password' ), 'logged in as root';
+
+RT::Test->clean_caught_mails;
+
+# AttachTickets is mostly used in RTIR
+diag "Submit a comment with attached tickets"; 
+
+$m->get_ok('/Ticket/Display.html?id=' . $ticket_b->Id);
+$m->follow_link_ok({text => "Comment"}, "Followed link to comment");
+$m->form_name('TicketUpdate');
+$m->field('UpdateCc', 'user1 at example.com');
+$m->field('UpdateContent', 'some content');
+$m->field('AttachTickets', $ticket_a->Id);
+$m->click('SubmitTicket');
+is( $m->status, 200, "request successful" );
+
+my @mail = RT::Test->fetch_caught_mails;
+ok @mail, "got some outgoing emails";
+
+# Match the first occurance of Content-Type in the email. This should be the
+# outermost part
+$mail[0] =~ /^.*?Content\-Type\: (.*?)\;/sm;
+is( $1, 'multipart/mixed', 'Outer message is multipart mixed');
+
+undef $m;
+done_testing;

commit ba7b76e9472542be4064bc0c0ab6867fe5443d37
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Jan 30 16:20:13 2017 -0500

    Update AddTicket to force multipart/mixed email
    
    For html email, RT makes a plain text version, changing the
    top level email Content-Type to multipart/alternative to indicate
    there are several versions of the same email available. When adding
    additional attachments, like another ticket, force the top level
    email Content-Type to multipart/mixed to indicate there are additional
    attachments, not just alternate versions of the same email.
    
    This issue was observed when using the attach tickets feature in
    RTIR.

diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index 1fa479b..88ad3bd 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -542,7 +542,8 @@ sub AddTicket {
     }
     if ( $ticket_mime->parts ) {
         my $email_mime = $self->TemplateObj->MIMEObj;
-        $email_mime->make_multipart;
+        $email_mime->make_multipart( 'mixed', Force => 1 )
+            unless $email_mime->effective_type eq 'multipart/mixed';
         $email_mime->add_part($ticket_mime);
     }
     return;

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


More information about the rt-commit mailing list