[Rt-commit] rt branch, 4.0/digests-no-mail-on-success, created. rt-4.0.12-12-g22314ef

Alex Vandiver alexmv at bestpractical.com
Tue May 14 02:20:35 EDT 2013


The branch, 4.0/digests-no-mail-on-success has been created
        at  22314efd0e70949bd26e6248d3bc18165f87194b (commit)

- Log -----------------------------------------------------------------
commit 22314efd0e70949bd26e6248d3bc18165f87194b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon May 13 15:31:13 2013 -0400

    Don't output to STDOUT for successfully sent digests, by default
    
    Most commonly, digests are sent from cron jobs, where any output to
    STDOUT is sent to the administrator.  Printing on every successfully
    sent digest will thus lead to the administrator getting sent daily mail
    which is essentially content-less.  This might lead them to redirect the
    output to /dev/null, which would cause them to be ignorant when sending
    messages _failed_.
    
    Restrict output to STDOUT to only when messages failed to send, by
    default.  The new --verbose option can be used to restore the old
    behavior of printing for every message sent.

diff --git a/sbin/rt-email-digest.in b/sbin/rt-email-digest.in
index 68f0b4c..d8649f7 100644
--- a/sbin/rt-email-digest.in
+++ b/sbin/rt-email-digest.in
@@ -95,6 +95,7 @@ sub usage {
     print "\t-p, --print\t"
         . loc("Print the resulting digest messages to STDOUT; don't mail them. Do not mark them as sent")
         . "\n";
+    print "\t-v, --verbose\t" . loc("Give output even on messages successfully sent") . "\n";
     print "\t-h, --help\t" . loc("Print this message") . "\n";
 
     if ( $error eq 'help' ) {
@@ -105,10 +106,11 @@ sub usage {
     }
 }
 
-my ( $frequency, $print, $help ) = ( '', '', '' );
+my ( $frequency, $print, $verbose, $help ) = ( '', '', '', '' );
 GetOptions(
     'mode=s' => \$frequency,
     'print'  => \$print,
+    'verbose' => \$verbose,
     'help'   => \$help,
 );
 
@@ -134,7 +136,7 @@ sub run {
         my ( $contents_list, $contents_body ) = build_digest_for_user( $user, $all_digest->{$user} );
         # Now we have a content head and a content body.  We can send a message.
         if ( send_digest( $user, $contents_list, $contents_body ) ) {
-            print "Sent message to $user\n";
+            print "Sent message to $user\n" if $verbose;
             mark_transactions_sent( $frequency, $user, values %{$sent_transactions->{$user}} ) unless ($print);
         } else {
             print "Failed to send message to $user\n";
diff --git a/t/mail/digest-attributes.t b/t/mail/digest-attributes.t
index badd59b..54c1c80 100644
--- a/t/mail/digest-attributes.t
+++ b/t/mail/digest-attributes.t
@@ -136,14 +136,14 @@ is( $c_susp, 1, "correct number of suspended messages" );
 # the first time get the content
 email_digest_like( '--mode daily --print', qr/in the last day/ );
 # The second time run it for real so we make sure that we get RT to mark the txn as sent
-email_digest_like( '--mode daily', qr/maildaily\@/ );
+email_digest_like( '--mode daily --verbose', qr/maildaily\@/ );
 # now we should have nothing to do, so no content.
 email_digest_like( '--mode daily --print', '' );
 
 # the first time get the content
 email_digest_like( '--mode weekly --print', qr/in the last seven days/ );
 # The second time run it for real so we make sure that we get RT to mark the txn as sent
-email_digest_like( '--mode weekly', qr/mailweekly\@/ );
+email_digest_like( '--mode weekly --verbose', qr/mailweekly\@/ );
 # now we should have nothing to do, so no content.
 email_digest_like( '--mode weekly --print', '' );
 

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


More information about the Rt-commit mailing list