[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.8-85-g920c132

? sunnavy sunnavy at bestpractical.com
Mon Jun 14 23:41:43 EDT 2010


The branch, 3.8-trunk has been updated
       via  920c132891b42ec25efccf5507bc06c6020c8c8a (commit)
      from  e57b44c821fa200c64a1486d10052aeaec3d62c1 (commit)

Summary of changes:
 lib/RT/Interface/Email.pm     |   27 +++++++++++++++++++++++++++
 lib/RT/Transaction_Overlay.pm |    3 +++
 2 files changed, 30 insertions(+), 0 deletions(-)

- Log -----------------------------------------------------------------
commit 920c132891b42ec25efccf5507bc06c6020c8c8a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jun 15 11:42:18 2010 +0800

    record send email error if possible

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index eaf324e..fc1a721 100755
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -462,6 +462,9 @@ sub SendEmail {
         };
         if ( $@ ) {
             $RT::Logger->crit( "$msgid: Could not send mail with command `$path $args`: " . $@ );
+            if ( $TicketObj ) {
+                _RecordSendEmailFailure( $TicketObj );
+            }
             return 0;
         }
     }
@@ -473,6 +476,9 @@ sub SendEmail {
         ) } };
         unless ( $smtp ) {
             $RT::Logger->crit( "Could not connect to SMTP server.");
+            if ($TicketObj) {
+                _RecordSendEmailFailure( $TicketObj );
+            }
             return 0;
         }
 
@@ -501,6 +507,9 @@ sub SendEmail {
 
         unless ( $status ) {
             $RT::Logger->crit( "$msgid: Could not send mail via SMTP." );
+            if ( $TicketObj ) {
+                _RecordSendEmailFailure( $TicketObj );
+            }
             return 0;
         }
     }
@@ -518,6 +527,9 @@ sub SendEmail {
 
         unless ( $args{'Entity'}->send( @mailer_args ) ) {
             $RT::Logger->crit( "$msgid: Could not send mail." );
+            if ( $TicketObj ) {
+                _RecordSendEmailFailure( $TicketObj );
+            }
             return 0;
         }
     }
@@ -1780,6 +1792,21 @@ sub IsCorrectAction {
     return ( 1, @actions );
 }
 
+sub _RecordSendEmailFailure {
+    my $ticket = shift;
+    if ($ticket) {
+        $ticket->_RecordNote(
+            NoteType => 'SystemError',
+            Content => "Sending the previous mail has failed.  Please contact your admin, they can find more details in the logs.",
+        );
+        return 1;
+    }
+    else {
+        $RT::Logger->error( "Can't record send email failure as ticket is missing" );
+        return;
+    }
+}
+
 eval "require RT::Interface::Email_Vendor";
 die $@ if ( $@ && $@ !~ qr{^Can't locate RT/Interface/Email_Vendor.pm} );
 eval "require RT::Interface::Email_Local";
diff --git a/lib/RT/Transaction_Overlay.pm b/lib/RT/Transaction_Overlay.pm
index 4671236..d1630ea 100755
--- a/lib/RT/Transaction_Overlay.pm
+++ b/lib/RT/Transaction_Overlay.pm
@@ -658,6 +658,9 @@ sub BriefDescription {
             )
         );
     }
+    elsif ( $type =~ /SystemError/ ) {
+        return $self->loc("System error");
+    }
 
     if ( my $code = $_BriefDescriptions{$type} ) {
         return $code->($self);

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


More information about the Rt-commit mailing list