summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-10-30 07:58:13 +0100
committerByron Jones <bjones@mozilla.com>2013-10-30 07:58:13 +0100
commit1b28e5b941d480249d4dd637138a3781d6f9cd05 (patch)
treea69d86f0194417e096ceb1a460ca7d064403128c /extensions
parent7f7de14b517a953e83c97ec5a268613442826b8c (diff)
downloadbugzilla-1b28e5b941d480249d4dd637138a3781d6f9cd05.tar.gz
bugzilla-1b28e5b941d480249d4dd637138a3781d6f9cd05.tar.xz
Bug 892615: update requestnagging to suport securemail
Diffstat (limited to 'extensions')
-rwxr-xr-x[-rw-r--r--]extensions/RequestNagger/bin/send-request-nags.pl28
-rw-r--r--extensions/RequestNagger/lib/Bug.pm30
-rw-r--r--extensions/RequestNagger/template/en/default/email/request_nagging-requestee.html.tmpl3
-rw-r--r--extensions/RequestNagger/template/en/default/email/request_nagging-watching.html.tmpl3
-rw-r--r--extensions/SecureMail/Extension.pm15
5 files changed, 72 insertions, 7 deletions
diff --git a/extensions/RequestNagger/bin/send-request-nags.pl b/extensions/RequestNagger/bin/send-request-nags.pl
index c62d91f03..93265b9ee 100644..100755
--- a/extensions/RequestNagger/bin/send-request-nags.pl
+++ b/extensions/RequestNagger/bin/send-request-nags.pl
@@ -21,6 +21,7 @@ use Bugzilla::Bug;
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Extension::RequestNagger::Constants;
+use Bugzilla::Extension::RequestNagger::Bug;
use Bugzilla::Mailer;
use Bugzilla::User;
use Bugzilla::Util qw(format_time);
@@ -107,8 +108,30 @@ sub send_email {
my $vars = \%vars;
return unless $vars->{recipient} && @{ $vars->{requests} };
- # restructure the list to group by requestee then flag type
my $request_list = delete $vars->{requests};
+
+ # if securemail is installed, we need to encrypt or censor emails which
+ # contain non-public bugs
+ my $default_user = Bugzilla::User->new();
+ my $securemail = $vars->{recipient}->can('public_key');
+ my $has_key = $securemail && $vars->{recipient}->public_key;
+ # have to do this each time as objects are shared between requests
+ my $has_private_bug = 0;
+ foreach my $request (@{ $request_list }) {
+ # rebless bug objects into our subclass
+ bless($request->{bug}, 'Bugzilla::Extension::RequestNagger::Bug');
+ # and tell that object to hide the summary if required
+ if ($securemail && !$default_user->can_see_bug($request->{bug})) {
+ $has_private_bug = 1;
+ $request->{bug}->{secure_bug} = !$has_key;
+ }
+ else {
+ $request->{bug}->{secure_bug} = 0;
+ }
+ }
+ my $encrypt = $securemail && $has_private_bug && $has_key;
+
+ # restructure the list to group by requestee then flag type
my $requests = {};
my %seen_types;
foreach my $request (@{ $request_list }) {
@@ -172,6 +195,9 @@ sub send_email {
$email->content_type_set('multipart/alternative');
}
$email->parts_set(\@parts);
+ if ($encrypt) {
+ $email->header_set('X-Bugzilla-Encrypt' => '1');
+ }
# send
if ($DO_NOT_NAG) {
diff --git a/extensions/RequestNagger/lib/Bug.pm b/extensions/RequestNagger/lib/Bug.pm
new file mode 100644
index 000000000..de6d5eae5
--- /dev/null
+++ b/extensions/RequestNagger/lib/Bug.pm
@@ -0,0 +1,30 @@
+# 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
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Extension::RequestNagger::Bug;
+
+use strict;
+use parent qw(Bugzilla::Bug);
+
+sub short_desc {
+ my ($self) = @_;
+ return $self->{secure_bug} ? '(Secure bug)' : $self->SUPER::short_desc;
+}
+
+sub tooltip {
+ my ($self) = @_;
+ my $tooltip = $self->bug_status;
+ if ($self->bug_status eq 'RESOLVED') {
+ $tooltip .= '/' . $self->resolution;
+ }
+ if (!$self->{secure_bug}) {
+ $tooltip .= ' ' . $self->product . ' :: ' . $self->component;
+ }
+ return $tooltip;
+}
+
+1;
diff --git a/extensions/RequestNagger/template/en/default/email/request_nagging-requestee.html.tmpl b/extensions/RequestNagger/template/en/default/email/request_nagging-requestee.html.tmpl
index b1b0eff7e..d76e39afa 100644
--- a/extensions/RequestNagger/template/en/default/email/request_nagging-requestee.html.tmpl
+++ b/extensions/RequestNagger/template/en/default/email/request_nagging-requestee.html.tmpl
@@ -41,8 +41,7 @@
[% FOREACH request = requests.types.$type %]
<li>
<a href="[% urlbase FILTER none %]show_bug.cgi?id=[% request.bug.id FILTER none %]"
- title="[% request.bug.bug_status FILTER html %]
- [% request.bug.product FILTER html %] :: [% request.bug.component FILTER html %]">
+ title="[% request.bug.tooltip FILTER html %]">
[% request.bug.id FILTER none %] - [% request.bug.short_desc FILTER html %]
</a><br>
<b>[%+ request.flag.age FILTER html %]</b> from [% request.requester.identity FILTER html %]<br>
diff --git a/extensions/RequestNagger/template/en/default/email/request_nagging-watching.html.tmpl b/extensions/RequestNagger/template/en/default/email/request_nagging-watching.html.tmpl
index e01167c5f..86a31da37 100644
--- a/extensions/RequestNagger/template/en/default/email/request_nagging-watching.html.tmpl
+++ b/extensions/RequestNagger/template/en/default/email/request_nagging-watching.html.tmpl
@@ -69,8 +69,7 @@
[% FOREACH request = requests.$login.types.$type %]
<li>
<a href="[% urlbase FILTER none %]show_bug.cgi?id=[% request.bug.id FILTER none %]"
- title="[% request.bug.bug_status FILTER html %]
- [% request.bug.product FILTER html %] :: [% request.bug.component FILTER html %]">
+ title="[% request.bug.tooltip FILTER html %]">
[% request.bug.id FILTER none %] - [% request.bug.short_desc FILTER html %]
</a><br>
<b>[%+ request.flag.age FILTER html %]</b> from [% request.requester.identity FILTER html %]<br>
diff --git a/extensions/SecureMail/Extension.pm b/extensions/SecureMail/Extension.pm
index 8fd09510d..a4a23a2cd 100644
--- a/extensions/SecureMail/Extension.pm
+++ b/extensions/SecureMail/Extension.pm
@@ -261,8 +261,14 @@ sub mailer_before_send {
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 || $is_whine_email) {
+ my $encrypt_header = $email->header('X-Bugzilla-Encrypt') ? 1 : 0;
+
+ if ($is_bugmail
+ || $is_passwordmail
+ || $is_test_email
+ || $is_whine_email
+ || $encrypt_header
+ ) {
# Convert the email's To address into a User object
my $login = $email->header('To');
my $emailsuffix = Bugzilla->params->{'emailsuffix'};
@@ -329,6 +335,11 @@ sub mailer_before_send {
# comes from the whine settings.
$make_secure = _should_secure_whine($email) ? SECURE_BODY : SECURE_NONE;
}
+ elsif ($encrypt_header) {
+ # Templates or code may set the X-Bugzilla-Encrypt header to
+ # trigger encryption of emails. Remove that header from the email.
+ $email->header_set('X-Bugzilla-Encrypt');
+ }
# 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