]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1398889 - Add param 'silent_users' that never trigger sending bugmail
authorDylan William Hardison <dylan@hardison.net>
Wed, 13 Sep 2017 13:03:50 +0000 (09:03 -0400)
committerGitHub <noreply@github.com>
Wed, 13 Sep 2017 13:03:50 +0000 (09:03 -0400)
* Add param silent_users
* Add method is_silent_user to User class, which returns true if the login name matches an entry in silent_users.
* Change user_wants_mail() to return false if the changer is a silent user.
* Change is_global_watcher() in User class code to use any instead of grep
* Change regex used to parse param 'globalwatchers' to use consistent regex in BugMail.pm and User.pm

Bugzilla/BugMail.pm
Bugzilla/Config/MTA.pm
Bugzilla/User.pm
template/en/default/admin/params/mta.html.tmpl

index e40e9c97a090a0c0a8b2b2eea7cbc41b8bd78bbd..defe7c84f860e0462deef171bb9e356af34d4967 100644 (file)
@@ -214,7 +214,7 @@ sub Send {
     }
 
     # Global watcher
-    my @watchers = split(/[,\s]+/, Bugzilla->params->{'globalwatchers'});
+    my @watchers = split(/\s*,\s*/ms, Bugzilla->params->{'globalwatchers'});
     foreach (@watchers) {
         my $watcher_id = login_to_id($_);
         next unless $watcher_id;
index a12b425e2df6b9e2e0c2e2f6eb60f5bc2f780949..c23c324d98a1476c259b9c8db2a5ca00b26576fe 100644 (file)
@@ -106,6 +106,11 @@ sub get_param_list {
             type    => 't',
             default => '',
         },
+        {
+            name    => 'silent_users',
+            type    => 't',
+            default => '',
+        },
     );
     return @param_list;
 }
index fafd3551d371896d968be7433335c0abe53afbf6..84fc1fb211490d008f83878e3a89bab494ead53d 100644 (file)
@@ -2246,6 +2246,9 @@ sub wants_bug_mail {
     my $self = shift;
     my ($bug, $relationship, $fieldDiffs, $comments, $dep_mail, $changer) = @_;
 
+    # is_silent_user is true if the username is mentioned in the param `silent_users`
+    return 0 if $changer && $changer->is_silent_user;
+
     # Make a list of the events which have happened during this bug change,
     # from the point of view of this user.
     my %events;
@@ -2407,13 +2410,24 @@ sub is_insider {
 sub is_global_watcher {
     my $self = shift;
 
-    if (!defined $self->{'is_global_watcher'}) {
-        my @watchers = split(/[,;]+/, Bugzilla->params->{'globalwatchers'});
-        $self->{'is_global_watcher'} = scalar(grep { $_ eq $self->login } @watchers) ? 1 : 0;
+    if (!exists $self->{'is_global_watcher'}) {
+        my @watchers = split(/\s*,\s*/, Bugzilla->params->{'globalwatchers'});
+        $self->{'is_global_watcher'} = (any { $_ eq $self->login } @watchers) ? 1 : 0;
     }
     return  $self->{'is_global_watcher'};
 }
 
+sub is_silent_user {
+    my $self = shift;
+
+    if (!exists $self->{'is_silent_user'}) {
+        my @users = split(/\s*,\s*/, Bugzilla->params->{'silent_users'});
+        $self->{'is_silent_user'} = (any { $self->login eq $_ } @users) ? 1 : 0;
+    }
+
+    return  $self->{'is_silent_user'};
+}
+
 sub is_timetracker {
     my $self = shift;
 
index 05c44853e2ab14ac9061f1699e4db78b2cb3e3c4..88d8ef981cb1d093073d19818dcf85cf56b1f29a 100644 (file)
@@ -73,6 +73,8 @@
                "Set to 0 to disable whining.",
 
   globalwatchers => "A comma-separated list of users who should receive a " _
-                    "copy of every notification mail the system sends." }
+                    "copy of every notification mail the system sends.",
+
+  silent_users => "A comma-separated list of users who never trigger sending email." }
 
 %]