summaryrefslogtreecommitdiffstats
path: root/Bugzilla/User.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-09-13 15:03:50 +0200
committerGitHub <noreply@github.com>2017-09-13 15:03:50 +0200
commit5c003fcc3ee164e92295f8518ca90eec0196a30c (patch)
treed92254cd59e3f97f4b3fcf42e09715c0ccd286b4 /Bugzilla/User.pm
parent90757225b25c4eab4b4f4b9296c63746c710721d (diff)
downloadbugzilla-5c003fcc3ee164e92295f8518ca90eec0196a30c.tar.gz
bugzilla-5c003fcc3ee164e92295f8518ca90eec0196a30c.tar.xz
Bug 1398889 - Add param 'silent_users' that never trigger sending bugmail
* 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
Diffstat (limited to 'Bugzilla/User.pm')
-rw-r--r--Bugzilla/User.pm20
1 files changed, 17 insertions, 3 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index fafd3551d..84fc1fb21 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -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;