summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/SecureMail/Extension.pm52
-rwxr-xr-xwhine.pl3
2 files changed, 30 insertions, 25 deletions
diff --git a/extensions/SecureMail/Extension.pm b/extensions/SecureMail/Extension.pm
index f139c47b8..2652197b4 100644
--- a/extensions/SecureMail/Extension.pm
+++ b/extensions/SecureMail/Extension.pm
@@ -225,8 +225,9 @@ sub mailer_before_send {
$email->header('X-Bugzilla-Type') eq 'request';
my $is_passwordmail = !$is_bugmail && ($body =~ /cfmpw.*cxlpw/s);
my $is_test_email = $email->header('X-Bugzilla-Type') =~ /securemail-test/ ? 1 : 0;
+ my $is_whine_email = $email->header('X-Bugzilla-Type') eq 'whine' ? 1 : 0;
- if ($is_bugmail || $is_passwordmail || $is_test_email) {
+ if ($is_bugmail || $is_passwordmail || $is_test_email || $is_whine_email) {
# Convert the email's To address into a User object
my $login = $email->header('To');
my $emailsuffix = Bugzilla->params->{'emailsuffix'};
@@ -284,6 +285,12 @@ sub mailer_before_send {
$make_secure = SECURE_NONE;
}
}
+ elsif ($is_whine_email) {
+ # When a whine email has one or more secure bugs in the body, then
+ # encrypt the entire email body. Subject can be left alone as it
+ # comes from the whine settings.
+ $make_secure = _should_secure_whine($email) ? SECURE_BODY : SECURE_NONE;
+ }
# If finding the user fails for some reason, but we determine we
# should be encrypting, we want to make the mail safe. An empty key
@@ -332,6 +339,28 @@ sub _should_secure_bug {
|| grep($_->secure_mail, @{ $bug->groups_in });
}
+sub _should_secure_whine {
+ my ($email) = @_;
+ my $should_secure = 0;
+ $email->walk_parts(sub {
+ my $part = shift;
+ my $content_type = $part->content_type;
+ return if !$content_type || $content_type !~ /^text\/plain/;
+ my $body = $part->body;
+ my @bugids = $body =~ /Bug (\d+):/g;
+ foreach my $id (@bugids) {
+ $id = trim($id);
+ next if !$id;
+ my $bug = new Bugzilla::Bug($id);
+ if ($bug && _should_secure_bug($bug)) {
+ $should_secure = 1;
+ last;
+ }
+ }
+ });
+ return $should_secure ? 1 : 0;
+}
+
sub _make_secure {
my ($email, $key, $sanitise_subject, $add_new) = @_;
@@ -560,25 +589,4 @@ sub _filter_bug_links {
});
}
-sub whine_before_send {
- my ($self, $args) = @_;
- my $params = $args->{params};
-
- return if !exists $params->{queries};
-
- foreach my $query (@{ $params->{queries} }) {
- foreach my $bug (@{ $query->{bugs} }) {
- my $bug_obj = new Bugzilla::Bug($bug->{bug_id});
- next if !_should_secure_bug($bug_obj);
- $bug->{priority} = '--';
- $bug->{bug_severity} = '--';
- $bug->{rep_platform} = '--';
- $bug->{assigned_to} = '--';
- $bug->{bug_status} = '--';
- $bug->{resolution} = '--';
- $bug->{'short_desc'} = "(Secure bug)";
- }
- }
-}
-
__PACKAGE__->NAME;
diff --git a/whine.pl b/whine.pl
index 7e02a64e7..ad6067228 100755
--- a/whine.pl
+++ b/whine.pl
@@ -35,7 +35,6 @@ use Bugzilla::User;
use Bugzilla::Mailer;
use Bugzilla::Util;
use Bugzilla::Group;
-use Bugzilla::Hook;
# create some handles that we'll need
my $template = Bugzilla->template;
@@ -368,8 +367,6 @@ sub mail {
# Don't send mail to someone whose bugmail notification is disabled.
return if $addressee->email_disabled;
- Bugzilla::Hook::process('whine_before_send', { params => $args });
-
my $template = Bugzilla->template_inner($addressee->setting('lang'));
my $msg = ''; # it's a temporary variable to hold the template output
$args->{'alternatives'} ||= [];