From cf3fa62685f06f0325ef6cd0a700c278deba029f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Wed, 19 Apr 2017 19:30:03 +0200 Subject: Do not email global watchers if the single change is about the CC list (mga#13379) --- Bugzilla/User.pm | 8 +++++++- extensions/Mageia/Extension.pm | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 77e6cebb0..1768d7c48 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -2132,10 +2132,16 @@ sub wants_mail { $relationship = REL_ANY; } + my $wants_mail; + Bugzilla::Hook::process('user_wants_mail', { events => $events, + relationship => $relationship, + wants_mail => \$wants_mail }); + return $wants_mail if defined $wants_mail; + # Skip DB query if relationship is explicit return 1 if $relationship == REL_GLOBAL_WATCHER; - my $wants_mail = grep { $self->mail_settings->{$relationship}{$_} } @$events; + $wants_mail = grep { $self->mail_settings->{$relationship}{$_} } @$events; return $wants_mail ? 1 : 0; } diff --git a/extensions/Mageia/Extension.pm b/extensions/Mageia/Extension.pm index 19d579c63..819838b95 100644 --- a/extensions/Mageia/Extension.pm +++ b/extensions/Mageia/Extension.pm @@ -13,6 +13,7 @@ use warnings; use parent qw(Bugzilla::Extension); +use Bugzilla::Constants qw(EVT_CC REL_GLOBAL_WATCHER); use Bugzilla::Bug qw(LogActivityEntry); use Bugzilla::Field qw(get_field_id); use Bugzilla::User qw(); @@ -117,4 +118,14 @@ sub mailer_before_send { } } +sub user_wants_mail { + my ($self, $args) = @_; + return unless $args->{relationship} == REL_GLOBAL_WATCHER; + + my $wants_mail = $args->{wants_mail}; + my @events = @{ $args->{events} }; + # Do not email global watchers if the single change is about the CC list. + $$wants_mail = (scalar(@events) == 1 && $events[0] == EVT_CC) ? 0 : 1; +} + __PACKAGE__->NAME; -- cgit v1.2.1