summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-12-06 18:28:00 +0100
committerByron Jones <bjones@mozilla.com>2013-12-06 18:28:00 +0100
commitce665b1f88150f437c7bb893bf3ebeabc3f04f07 (patch)
treef28bd6e20fc74672c4a10d6eec2eac2aec719065 /extensions
parent07f5353454ce64657544640eca84dd06769dd8a3 (diff)
downloadbugzilla-ce665b1f88150f437c7bb893bf3ebeabc3f04f07.tar.gz
bugzilla-ce665b1f88150f437c7bb893bf3ebeabc3f04f07.tar.xz
Bug 869989: Add X-Bugzilla-Mentors field to bugmail headers and an indication to mentors in bugmail body
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BMO/Extension.pm15
-rw-r--r--extensions/BMO/template/en/default/email/bugmail.html.tmpl31
-rw-r--r--extensions/BMO/template/en/default/email/bugmail.txt.tmpl9
-rw-r--r--extensions/Review/Extension.pm7
4 files changed, 46 insertions, 16 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index 2235ebfea..4fd385861 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -860,6 +860,11 @@ sub mailer_before_send {
_log_sent_email($email);
+ # $bug->mentors is added by the Review extension
+ if (Bugzilla::Bug->can('mentors')) {
+ _add_mentors_header($email);
+ }
+
# see bug 844724
if ($email->header('to') && $email->header('to') eq 'sync-1@bugzilla.tld') {
$email->header_set('to', 'mei.kong@tcl.com');
@@ -945,6 +950,16 @@ sub _log_sent_email {
_syslog("[bugmail] $recipient ($message_type) $bug_id $subject");
}
+# Add X-Bugzilla-Mentors field to bugmail
+sub _add_mentors_header {
+ my $email = shift;
+ return unless my $bug_id = $email->header('X-Bugzilla-ID');
+ return unless my $bug = Bugzilla::Bug->new({ id => $bug_id, cache => 1 });
+ return unless my $mentors = $bug->mentors;
+ return unless @$mentors;
+ $email->header_set('X-Bugzilla-Mentors', join(', ', map { $_->login } @$mentors));
+}
+
sub _syslog {
my $message = shift;
openlog('apache', 'cons,pid', 'local4');
diff --git a/extensions/BMO/template/en/default/email/bugmail.html.tmpl b/extensions/BMO/template/en/default/email/bugmail.html.tmpl
index 094b0c579..a6d2b340c 100644
--- a/extensions/BMO/template/en/default/email/bugmail.html.tmpl
+++ b/extensions/BMO/template/en/default/email/bugmail.html.tmpl
@@ -73,21 +73,26 @@
<div id="bug_details" style="font-size: 90%; color: #666666">
<hr style="border: 1px dashed #969696">
- Product/Component: [% bug.product FILTER html %] :: [% bug.component FILTER html %]
+ Product/Component: [% bug.product FILTER html %] :: [% bug.component FILTER html %]<br>
+ [% "You are mentoring this " _ terms.bug IF bug.is_mentor(to_user) %]
</div>
-[% IF tracking_flags.size %]
- <div id="tracking" style="font-size: 90%; color: #666666">
- <hr style="border: 1px dashed #969696">
- <b>Tracking Flags:</b>
- <ul>
- [% FOREACH flag = tracking_flags %]
- [% NEXT IF bug.${flag.name} == "---" %]
- <li>[% flag.description FILTER html %]:[% bug.${flag.name} FILTER html %]</li>
- [% END %]
- </ul>
- </div>
-[% END %]
+ [% seen_header = 0 %]
+ [% FOREACH flag = tracking_flags %]
+ [% NEXT IF bug.${flag.name} == "---" %]
+ [% IF !seen_header %]
+ [% seen_header = 1 %]
+ <div id="tracking" style="font-size: 90%; color: #666666">
+ <hr style="border: 1px dashed #969696">
+ <b>Tracking Flags:</b>
+ <ul>
+ [% END %]
+ <li>[% flag.description FILTER html %]:[% bug.${flag.name} FILTER html %]</li>
+ [% END %]
+ [% IF seen_header %]
+ </ul>
+ </div>
+ [% END %]
<div id="reason" style="font-size: 90%; color: #666666">
<hr style="border: 1px dashed #969696">
diff --git a/extensions/BMO/template/en/default/email/bugmail.txt.tmpl b/extensions/BMO/template/en/default/email/bugmail.txt.tmpl
index ed74ad880..b0e8636a4 100644
--- a/extensions/BMO/template/en/default/email/bugmail.txt.tmpl
+++ b/extensions/BMO/template/en/default/email/bugmail.txt.tmpl
@@ -38,14 +38,17 @@ Configure [% terms.bug %]mail: [% urlbase %]userprefs.cgi?tab=email
-------------------------------
Product/Component: [%+ bug.product +%] :: [%+ bug.component %]
+[%+ "You are mentoring this " _ terms.bug IF bug.is_mentor(to_user) %]
-[% IF tracking_flags.size %]
-------- Tracking Flags: -------
+[% seen_header = 0 %]
[% FOREACH flag = tracking_flags %]
[% NEXT IF bug.${flag.name} == "---" %]
+ [% IF !seen_header %]
+ [% seen_header = 1 %]
+------- Tracking Flags: -------
+ [% END %]
[%+ flag.description %]:[% bug.${flag.name} %]
[% END %]
-[% END %]
------- You are receiving this mail because: -------
[% SET reason_lines = [] %]
diff --git a/extensions/Review/Extension.pm b/extensions/Review/Extension.pm
index 0aa21ad5b..f15bdc9ef 100644
--- a/extensions/Review/Extension.pm
+++ b/extensions/Review/Extension.pm
@@ -33,6 +33,7 @@ BEGIN {
*Bugzilla::Component::reviewers = \&_component_reviewers;
*Bugzilla::Component::reviewers_objs = \&_component_reviewers_objs;
*Bugzilla::Bug::mentors = \&_bug_mentors;
+ *Bugzilla::Bug::is_mentor = \&_bug_is_mentor;
*Bugzilla::User::review_count = \&_user_review_count;
}
@@ -103,6 +104,12 @@ sub _bug_mentors {
return $self->{mentors};
}
+sub _bug_is_mentor {
+ my ($self, $user) = @_;
+ my $user_id = ($user || Bugzilla->user)->id;
+ return (grep { $_->id == $user_id} @{ $self->mentors }) ? 1 : 0;
+}
+
sub _user_review_count {
my ($self) = @_;
if (!exists $self->{review_count}) {