[Rt-commit] rt branch 5.0/email-dashboard-recipient-arg created. rt-5.0.2-25-g892cb38dae
BPS Git Server
git at git.bestpractical.com
Thu Oct 14 18:18:54 UTC 2021
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/email-dashboard-recipient-arg has been created
at 892cb38dae35863f2b4698f9c9220e7597691aef (commit)
- Log -----------------------------------------------------------------
commit 892cb38dae35863f2b4698f9c9220e7597691aef
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Oct 15 02:03:02 2021 +0800
Add --recipient to send dashboard emails to a single recipient only
This is useful when debugging dashboard emails for a specific user.
diff --git a/lib/RT/Dashboard/Mailer.pm b/lib/RT/Dashboard/Mailer.pm
index e95516ab2d..97d6087b10 100644
--- a/lib/RT/Dashboard/Mailer.pm
+++ b/lib/RT/Dashboard/Mailer.pm
@@ -70,6 +70,7 @@ sub MailDashboards {
DryRun => 0,
Time => time,
User => undef,
+ Recipient => undef,
@_,
);
@@ -88,6 +89,12 @@ sub MailDashboards {
$Users->Limit( FIELD => 'id', VALUE => $user->Id || 0 );
}
+ my $recipient;
+ if ( $args{Recipient} ) {
+ $recipient = RT::User->new( RT->SystemUser );
+ $recipient->Load( $args{Recipient} );
+ }
+
while (defined(my $user = $Users->Next)) {
my ($hour, $dow, $dom) = HourDowDomIn($args{Time}, $user->Timezone || RT->Config->Get('Timezone'));
$hour .= ':00';
@@ -121,8 +128,10 @@ sub MailDashboards {
$user->Load($user_id);
next unless $user->id and !$user->Disabled;
- push @emails, $user->EmailAddress;
- $recipient_language{$user->EmailAddress} = $user->Lang;
+ if ( !$recipient || ( $recipient->Id // 0 ) == $user->Id ) {
+ push @emails, $user->EmailAddress;
+ $recipient_language{ $user->EmailAddress } = $user->Lang;
+ }
}
# add emails for every group's members
@@ -133,8 +142,10 @@ sub MailDashboards {
my $users = $group->UserMembersObj;
while (my $user = $users->Next) {
- push @emails, $user->EmailAddress;
- $recipient_language{$user->EmailAddress} = $user->Lang;
+ if ( !$recipient || ( $recipient->Id // 0 ) == $user->Id ) {
+ push @emails, $user->EmailAddress;
+ $recipient_language{ $user->EmailAddress } = $user->Lang;
+ }
}
}
diff --git a/sbin/rt-email-dashboards.in b/sbin/rt-email-dashboards.in
index b706d6007d..eee2c5a496 100644
--- a/sbin/rt-email-dashboards.in
+++ b/sbin/rt-email-dashboards.in
@@ -70,7 +70,7 @@ BEGIN { # BEGIN RT CMD BOILERPLATE
my %opts;
use Getopt::Long;
GetOptions( \%opts,
- "help|h", "dryrun", "time=i", "epoch=i", "all", "log=s", "user=s"
+ "help|h", "dryrun", "time=i", "epoch=i", "all", "log=s", "user=s", "recipient=s"
);
if ($opts{'help'}) {
@@ -104,6 +104,7 @@ RT::Dashboard::Mailer->MailDashboards(
DryRun => $opts{dryrun},
Time => ($opts{time} || $opts{epoch} || time), # epoch is the old-style
User => $opts{user},
+ Recipient => $opts{recipient},
Opts => \%opts,
);
@@ -170,6 +171,10 @@ used with --dryrun for testing and debugging)
Only check the specified user's subscriptions
+=item --recipient User NAME or ID
+
+Only send emails to the specified user.
+
=item --log LEVEL
Adjust LogToSTDERR config option
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list