[Rt-commit] rt branch, 4.2/refactor-send-mail-code, created. rt-4.1.8-263-g5df0070

Ruslan Zakirov ruz at bestpractical.com
Thu May 9 17:02:26 EDT 2013


The branch, 4.2/refactor-send-mail-code has been created
        at  5df007048ad655dd5c1dd5f67dde5668c6808169 (commit)

- Log -----------------------------------------------------------------
commit d20ab27469fdc0dab0be1ae1da287de1b501efc9
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu May 9 19:54:26 2013 +0400

    encryption/signing should be last thing

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 6e4a342..b461cc1 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -396,6 +396,13 @@ sub SendEmail {
         $TicketObj = $TransactionObj->Object;
     }
 
+    unless ( $args{'Entity'}->head->get('Date') ) {
+        require RT::Date;
+        my $date = RT::Date->new( RT->SystemUser );
+        $date->SetToNow;
+        $args{'Entity'}->head->set( 'Date', $date->RFC2822( Timezone => 'server' ) );
+    }
+
     if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
         %args = WillSignEncrypt(
             %args,
@@ -406,13 +413,6 @@ sub SendEmail {
         return $res unless $res > 0;
     }
 
-    unless ( $args{'Entity'}->head->get('Date') ) {
-        require RT::Date;
-        my $date = RT::Date->new( RT->SystemUser );
-        $date->SetToNow;
-        $args{'Entity'}->head->set( 'Date', $date->RFC2822( Timezone => 'server' ) );
-    }
-
     my $mail_command = RT->Config->Get('MailCommand');
 
     # if it is a sub routine, we just return it;

commit 5df007048ad655dd5c1dd5f67dde5668c6808169
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri May 10 00:58:50 2013 +0400

    move setting some headers to ::Interface::Email
    
    We were setting MIME-Version and Content-Transfer-Encoding
    in Action::SendEmail. This code has some history and we should
    keep it. These days we have more API to send emails besides
    SendEmail scrip action, so it's good to move this code into
    place which handles all emails.
    
    See http://issues.bestpractical.com/Ticket/Display.html?id=16818

diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index 65f99fd..579f930 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -179,12 +179,6 @@ sub Prepare {
             && !$MIMEObj->head->get('To')
             && ( $MIMEObj->head->get('Cc') or $MIMEObj->head->get('Bcc') );
 
-    # We should never have to set the MIME-Version header
-    $self->SetHeader( 'MIME-Version', '1.0' );
-
-    # fsck.com #5959: Since RT sends 8bit mail, we should say so.
-    $self->SetHeader( 'Content-Transfer-Encoding', '8bit' );
-
     # For security reasons, we only send out textual mails.
     foreach my $part ( grep !$_->is_multipart, $MIMEObj->parts_DFS ) {
         my $type = $part->mime_type || 'text/plain';
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index b461cc1..aa34068 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -396,11 +396,20 @@ sub SendEmail {
         $TicketObj = $TransactionObj->Object;
     }
 
-    unless ( $args{'Entity'}->head->get('Date') ) {
+    my $head = $args{'Entity'}->head;
+    unless ( $head->get('Date') ) {
         require RT::Date;
         my $date = RT::Date->new( RT->SystemUser );
         $date->SetToNow;
-        $args{'Entity'}->head->set( 'Date', $date->RFC2822( Timezone => 'server' ) );
+        $head->set( 'Date', $date->RFC2822( Timezone => 'server' ) );
+    }
+    unless ( $head->get('MIME-Version') ) {
+        # We should never have to set the MIME-Version header
+        $head->set( 'MIME-Version', '1.0' );
+    }
+    unless ( $head->get('Content-Transfer-Encoding') ) {
+        # fsck.com #5959: Since RT sends 8bit mail, we should say so.
+        $head->set( 'Content-Transfer-Encoding', '8bit' );
     }
 
     if ( RT->Config->Get('GnuPG')->{'Enable'} ) {

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


More information about the Rt-commit mailing list