X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fsbin%2Frt-email-digest.in;h=a535e3649c6d410ec9182a7dd2cb3ef040582a04;hb=c71b2dc296da6207c525a064d322f7153c284d4e;hp=5730717f2b8806771d451e4fa8747219cabb8136;hpb=fc6209f398899f0211cfcedeb81a3cd65e04a941;p=freeside.git diff --git a/rt/sbin/rt-email-digest.in b/rt/sbin/rt-email-digest.in index 5730717f2..a535e3649 100644 --- a/rt/sbin/rt-email-digest.in +++ b/rt/sbin/rt-email-digest.in @@ -3,7 +3,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -85,7 +85,7 @@ RT::Init(); sub usage { my ($error) = @_; - print loc("Usage: ") . "$0 -m (daily|weekly) [--print] [--help]\n"; + print loc("Usage:") . " $0 -m (daily|weekly) [--print] [--help]\n"; print loc( "[_1] is a utility, meant to be run from cron, that dispatches all deferred RT notifications as a per-user digest.", $0 @@ -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"; @@ -188,13 +190,13 @@ sub send_digest { } } -=item mark_transactions_sent( $frequency, $user, @txn_list ); - -Takes a frequency string (either 'daily' or 'weekly'), a user and one or more -transaction objects as its arguments. Marks the given deferred -notifications as sent. - -=cut +# =item mark_transactions_sent( $frequency, $user, @txn_list ); +# +# Takes a frequency string (either 'daily' or 'weekly'), a user and one or more +# transaction objects as its arguments. Marks the given deferred +# notifications as sent. +# +# =cut sub mark_transactions_sent { my ( $freq, $user, @txns ) = @_; @@ -335,3 +337,42 @@ sub build_digest_for_user { return ( $contents_list, $contents_body ); } + +__END__ + +=head1 NAME + +rt-email-digest - dispatch deferred notifications as a per-user digest + +=head1 SYNOPSIS + + rt-email-digest -m (daily|weekly) [--print] [--help] + +=head1 DESCRIPTION + +This script is a tool to dispatch all deferred RT notifications as a per-user +object. + +=head1 OPTIONS + +=over + +=item mode + +Specify whether this is a daily or weekly run. + +--mode is equal to -m + +=item print + +Print the resulting digest messages to STDOUT; don't mail them. Do not mark them as sent + +--print is equal to -p + +=item help + +Print this message + +--help is equal to -h + +=back