[Rt-commit] rt 01/01: Add --user so rt-email-dashboards can check subscriptions for a single user only

sunnavy sunnavy at bestpractical.com
Wed Jul 7 16:29:06 EDT 2021


This is an automated email from the git hooks/post-receive script.

sunnavy pushed a commit to branch 4.4/email-dashboard-user-arg
in repository rt.

commit 5effb2cbb62a38e7c1f8d6f9d9689d80d5a9a0bc
Author: sunnavy <sunnavy at bestpractical.com>
AuthorDate: Thu Jul 8 03:58:08 2021 +0800

    Add --user so rt-email-dashboards can check subscriptions for a single user only
    
    This is mainly for testing.
---
 lib/RT/Dashboard/Mailer.pm  | 6 ++++++
 sbin/rt-email-dashboards.in | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/RT/Dashboard/Mailer.pm b/lib/RT/Dashboard/Mailer.pm
index 53d4adf9b3..3770b1fe13 100644
--- a/lib/RT/Dashboard/Mailer.pm
+++ b/lib/RT/Dashboard/Mailer.pm
@@ -69,6 +69,7 @@ sub MailDashboards {
         All    => 0,
         DryRun => 0,
         Time   => time,
+        User   => undef,
         @_,
     );
 
@@ -81,6 +82,11 @@ sub MailDashboards {
     my $Users = RT::Users->new(RT->SystemUser);
     $Users->LimitToPrivileged;
     $Users->LimitToEnabled;
+    if ( $args{User} ) {
+        my $user = RT::User->new( RT->SystemUser );
+        $user->Load( $args{User} );
+        $Users->Limit( FIELD => 'id', VALUE => $user->Id || 0 );
+    }
 
     while (defined(my $user = $Users->Next)) {
         my ($hour, $dow, $dom) = HourDowDomIn($args{Time}, $user->Timezone || RT->Config->Get('Timezone'));
diff --git a/sbin/rt-email-dashboards.in b/sbin/rt-email-dashboards.in
index fb3eea7239..01c487225b 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"
+    "help|h", "dryrun", "time=i", "epoch=i", "all", "log=s", "user=s"
 );
 
 if ($opts{'help'}) {
@@ -97,6 +97,7 @@ RT::Dashboard::Mailer->MailDashboards(
     All    => $opts{all},
     DryRun => $opts{dryrun},
     Time   => ($opts{time} || $opts{epoch} || time), # epoch is the old-style
+    User   => $opts{user},
     Opts   => \%opts,
 );
 
@@ -159,6 +160,10 @@ Back-compat for --time SECONDS.
 Ignore subscription frequency when considering each dashboard (should only be
 used with --dryrun for testing and debugging)
 
+=item --user USER NAME or ID
+
+Only check the specified user's subscriptions.
+
 =item --log LEVEL
 
 Adjust LogToSTDERR config option

-- 
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.


More information about the rt-commit mailing list