Bug 874944: Do not display the Excluded list when sending bugmails
r=dkl a=LpSolit git-svn-id: svn://10.0.0.236/trunk@264860 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
d4e5454f9c
commit
f01ff05e40
@ -1 +1 @@
|
|||||||
8629
|
8630
|
||||||
@ -106,6 +106,9 @@ sub Send {
|
|||||||
# Skip empty comments.
|
# Skip empty comments.
|
||||||
@$comments = grep { $_->type || $_->body =~ /\S/ } @$comments;
|
@$comments = grep { $_->type || $_->body =~ /\S/ } @$comments;
|
||||||
|
|
||||||
|
# If no changes have been made, there is no need to process further.
|
||||||
|
return {'sent' => []} unless scalar(@diffs) || scalar(@$comments);
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Start of email filtering code
|
# Start of email filtering code
|
||||||
###########################################################################
|
###########################################################################
|
||||||
@ -197,7 +200,6 @@ sub Send {
|
|||||||
# the bug in question. However, we are not necessarily going to mail them
|
# the bug in question. However, we are not necessarily going to mail them
|
||||||
# all - there are preferences, permissions checks and all sorts to do yet.
|
# all - there are preferences, permissions checks and all sorts to do yet.
|
||||||
my @sent;
|
my @sent;
|
||||||
my @excluded;
|
|
||||||
|
|
||||||
# The email client will display the Date: header in the desired timezone,
|
# The email client will display the Date: header in the desired timezone,
|
||||||
# so we can always use UTC here.
|
# so we can always use UTC here.
|
||||||
@ -206,18 +208,13 @@ sub Send {
|
|||||||
|
|
||||||
foreach my $user_id (keys %recipients) {
|
foreach my $user_id (keys %recipients) {
|
||||||
my %rels_which_want;
|
my %rels_which_want;
|
||||||
my $sent_mail = 0;
|
my $user = $user_cache{$user_id} ||= new Bugzilla::User($user_id);
|
||||||
$user_cache{$user_id} ||= new Bugzilla::User($user_id);
|
|
||||||
my $user = $user_cache{$user_id};
|
|
||||||
# Deleted users must be excluded.
|
# Deleted users must be excluded.
|
||||||
next unless $user;
|
next unless $user;
|
||||||
|
|
||||||
# If email notifications are disabled for this account, or the bug
|
# If email notifications are disabled for this account, or the bug
|
||||||
# is ignored, there is no need to do additional checks.
|
# is ignored, there is no need to do additional checks.
|
||||||
if ($user->email_disabled || $user->is_bug_ignored($id)) {
|
next if ($user->email_disabled || $user->is_bug_ignored($id));
|
||||||
push(@excluded, $user->login);
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($user->can_see_bug($id)) {
|
if ($user->can_see_bug($id)) {
|
||||||
# Go through each role the user has and see if they want mail in
|
# Go through each role the user has and see if they want mail in
|
||||||
@ -250,7 +247,7 @@ sub Send {
|
|||||||
|
|
||||||
# Email the user if the dep check passed.
|
# Email the user if the dep check passed.
|
||||||
if ($dep_ok) {
|
if ($dep_ok) {
|
||||||
$sent_mail = sendMail(
|
my $sent_mail = sendMail(
|
||||||
{ to => $user,
|
{ to => $user,
|
||||||
bug => $bug,
|
bug => $bug,
|
||||||
comments => $comments,
|
comments => $comments,
|
||||||
@ -261,15 +258,9 @@ sub Send {
|
|||||||
diffs => \@diffs,
|
diffs => \@diffs,
|
||||||
rels_which_want => \%rels_which_want,
|
rels_which_want => \%rels_which_want,
|
||||||
});
|
});
|
||||||
|
push(@sent, $user->login) if $sent_mail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sent_mail) {
|
|
||||||
push(@sent, $user->login);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
push(@excluded, $user->login);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# When sending bugmail about a blocker being reopened or resolved,
|
# When sending bugmail about a blocker being reopened or resolved,
|
||||||
@ -281,7 +272,7 @@ sub Send {
|
|||||||
$bug->{lastdiffed} = $end;
|
$bug->{lastdiffed} = $end;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {'sent' => \@sent, 'excluded' => \@excluded};
|
return {'sent' => \@sent};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub sendMail {
|
sub sendMail {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -wT
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
@ -6,6 +6,8 @@
|
|||||||
# This Source Code Form is "Incompatible With Secondary Licenses", as
|
# This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
# defined by the Mozilla Public License, v. 2.0.
|
# defined by the Mozilla Public License, v. 2.0.
|
||||||
|
|
||||||
|
use 5.10.1;
|
||||||
|
use strict;
|
||||||
use lib qw(. lib);
|
use lib qw(. lib);
|
||||||
|
|
||||||
use Bugzilla;
|
use Bugzilla;
|
||||||
@ -16,7 +18,7 @@ use Bugzilla::User;
|
|||||||
my $dbh = Bugzilla->dbh;
|
my $dbh = Bugzilla->dbh;
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
print STDERR "Usage: $0 bug_id user_email\n";
|
say STDERR "Usage: $0 bug_id user_email";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +32,7 @@ my $changer = $ARGV[1];
|
|||||||
|
|
||||||
# Validate the bug number.
|
# Validate the bug number.
|
||||||
if (!($bugnum =~ /^(\d+)$/)) {
|
if (!($bugnum =~ /^(\d+)$/)) {
|
||||||
print STDERR "Bug number \"$bugnum\" not numeric.\n";
|
say STDERR "Bug number \"$bugnum\" not numeric.";
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,19 +42,19 @@ my ($id) = $dbh->selectrow_array("SELECT bug_id FROM bugs WHERE bug_id = ?",
|
|||||||
undef, $bugnum);
|
undef, $bugnum);
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
print STDERR "Bug number $bugnum does not exist.\n";
|
say STDERR "Bug number $bugnum does not exist.";
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
# Validate the changer address.
|
# Validate the changer address.
|
||||||
my $match = Bugzilla->params->{'emailregexp'};
|
my $match = Bugzilla->params->{'emailregexp'};
|
||||||
if ($changer !~ /$match/) {
|
if ($changer !~ /$match/) {
|
||||||
print STDERR "Changer \"$changer\" doesn't match email regular expression.\n";
|
say STDERR "Changer \"$changer\" doesn't match email regular expression.";
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
my $changer_user = new Bugzilla::User({ name => $changer });
|
my $changer_user = new Bugzilla::User({ name => $changer });
|
||||||
unless ($changer_user) {
|
unless ($changer_user) {
|
||||||
print STDERR "\"$changer\" is not a valid user.\n";
|
say STDERR "\"$changer\" is not a valid user.";
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,26 +63,15 @@ my $outputref = Bugzilla::BugMail::Send($bugnum, {'changer' => $changer_user });
|
|||||||
|
|
||||||
# Report the results.
|
# Report the results.
|
||||||
my $sent = scalar(@{$outputref->{sent}});
|
my $sent = scalar(@{$outputref->{sent}});
|
||||||
my $excluded = scalar(@{$outputref->{excluded}});
|
|
||||||
|
|
||||||
if ($sent) {
|
if ($sent) {
|
||||||
print "email sent to $sent recipients:\n";
|
say "email sent to $sent recipients:";
|
||||||
} else {
|
} else {
|
||||||
print "No email sent.\n";
|
say "No email sent.";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $sent (@{$outputref->{sent}}) {
|
foreach my $sent (@{$outputref->{sent}}) {
|
||||||
print " $sent\n";
|
say " $sent";
|
||||||
}
|
|
||||||
|
|
||||||
if ($excluded) {
|
|
||||||
print "$excluded recipients excluded:\n";
|
|
||||||
} else {
|
|
||||||
print "No recipients excluded.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $excluded (@{$outputref->{excluded}}) {
|
|
||||||
print " $excluded\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This document is copyright (C) 2004 Perforce Software, Inc. All rights
|
# This document is copyright (C) 2004 Perforce Software, Inc. All rights
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
# This Source Code Form is "Incompatible With Secondary Licenses", as
|
# This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
# defined by the Mozilla Public License, v. 2.0.
|
# defined by the Mozilla Public License, v. 2.0.
|
||||||
|
|
||||||
|
use 5.10.1;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use lib qw(. lib);
|
use lib qw(. lib);
|
||||||
|
|
||||||
use Bugzilla;
|
use Bugzilla;
|
||||||
@ -25,28 +25,21 @@ my $list = $dbh->selectcol_arrayref(
|
|||||||
' ORDER BY bug_id');
|
' ORDER BY bug_id');
|
||||||
|
|
||||||
if (scalar(@$list) > 0) {
|
if (scalar(@$list) > 0) {
|
||||||
print "OK, now attempting to send unsent mail\n";
|
say "OK, now attempting to send unsent mail";
|
||||||
print scalar(@$list) . " bugs found with possibly unsent mail.\n\n";
|
say scalar(@$list) . " bugs found with possibly unsent mail.\n";
|
||||||
foreach my $bugid (@$list) {
|
foreach my $bugid (@$list) {
|
||||||
my $start_time = time;
|
my $start_time = time;
|
||||||
print "Sending mail for bug $bugid...\n";
|
say "Sending mail for bug $bugid...";
|
||||||
my $outputref = Bugzilla::BugMail::Send($bugid);
|
my $outputref = Bugzilla::BugMail::Send($bugid);
|
||||||
if ($ARGV[0] && $ARGV[0] eq "--report") {
|
if ($ARGV[0] && $ARGV[0] eq "--report") {
|
||||||
print "Mail sent to:\n";
|
say "Mail sent to:";
|
||||||
foreach (sort @{$outputref->{sent}}) {
|
say $_ foreach (sort @{$outputref->{sent}});
|
||||||
print $_ . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "Excluded:\n";
|
|
||||||
foreach (sort @{$outputref->{excluded}}) {
|
|
||||||
print $_ . "\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my ($sent, $excluded) = (scalar(@{$outputref->{sent}}),scalar(@{$outputref->{excluded}}));
|
my $sent = scalar @{$outputref->{sent}};
|
||||||
print "$sent mails sent, $excluded people excluded.\n";
|
say "$sent mails sent.";
|
||||||
print "Took " . (time - $start_time) . " seconds.\n\n";
|
say "Took " . (time - $start_time) . " seconds.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "Unsent mail has been sent.\n";
|
say "Unsent mail has been sent.";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,27 +12,11 @@
|
|||||||
#%]
|
#%]
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
[% PROCESS emails
|
<dt>Email sent to:</dt>
|
||||||
description = "Email sent to"
|
|
||||||
names = sent_bugmail.sent
|
|
||||||
%]
|
|
||||||
|
|
||||||
[% PROCESS emails
|
|
||||||
description = "Excluding"
|
|
||||||
names = sent_bugmail.excluded
|
|
||||||
%]
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
[%############################################################################%]
|
|
||||||
[%# Block for a set of email addresses #%]
|
|
||||||
[%############################################################################%]
|
|
||||||
|
|
||||||
[% BLOCK emails %]
|
|
||||||
<dt>[% description FILTER html %]:</dt>
|
|
||||||
<dd>
|
<dd>
|
||||||
[% IF user.can_see_bug(mailing_bugid) %]
|
[% IF user.can_see_bug(mailing_bugid) %]
|
||||||
[% IF names.size > 0 %]
|
[% IF sent_bugmail.sent.size %]
|
||||||
[%+ FOREACH name = names %]
|
[% FOREACH name = sent_bugmail.sent %]
|
||||||
<code>[% name FILTER html %]</code>[% ", " UNLESS loop.last() %]
|
<code>[% name FILTER html %]</code>[% ", " UNLESS loop.last() %]
|
||||||
[% END %]
|
[% END %]
|
||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
@ -42,4 +26,4 @@
|
|||||||
(list of e-mails not available)
|
(list of e-mails not available)
|
||||||
[% END %]
|
[% END %]
|
||||||
</dd>
|
</dd>
|
||||||
[% END %]
|
</dl>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user