Commit 99d1623c authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 652165: Flagmails have a wrong Date: value

r=wicked a=LpSolit
parent 2c01ae87
...@@ -224,6 +224,11 @@ sub Send { ...@@ -224,6 +224,11 @@ sub Send {
my @sent; my @sent;
my @excluded; my @excluded;
# The email client will display the Date: header in the desired timezone,
# so we can always use UTC here.
my $date = $params->{dep_only} ? $end : $bug->delta_ts;
$date = format_time($date, '%a, %d %b %Y %T %z', 'UTC');
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 $sent_mail = 0;
...@@ -268,7 +273,7 @@ sub Send { ...@@ -268,7 +273,7 @@ sub Send {
{ to => $user, { to => $user,
bug => $bug, bug => $bug,
comments => $comments, comments => $comments,
delta_ts => $params->{dep_only} ? $end : undef, date => $date,
changer => $changer, changer => $changer,
watchers => exists $watching{$user_id} ? watchers => exists $watching{$user_id} ?
$watching{$user_id} : undef, $watching{$user_id} : undef,
...@@ -304,7 +309,7 @@ sub sendMail { ...@@ -304,7 +309,7 @@ sub sendMail {
my $user = $params->{to}; my $user = $params->{to};
my $bug = $params->{bug}; my $bug = $params->{bug};
my @send_comments = @{ $params->{comments} }; my @send_comments = @{ $params->{comments} };
my $delta_ts = $params->{delta_ts}; my $date = $params->{date};
my $changer = $params->{changer}; my $changer = $params->{changer};
my $watchingRef = $params->{watchers}; my $watchingRef = $params->{watchers};
my @diffs = @{ $params->{diffs} }; my @diffs = @{ $params->{diffs} };
...@@ -348,7 +353,7 @@ sub sendMail { ...@@ -348,7 +353,7 @@ sub sendMail {
push @watchingrel, map { user_id_to_login($_) } @$watchingRef; push @watchingrel, map { user_id_to_login($_) } @$watchingRef;
my $vars = { my $vars = {
delta_ts => $delta_ts, date => $date,
to_user => $user, to_user => $user,
bug => $bug, bug => $bug,
reasons => \@reasons, reasons => \@reasons,
......
...@@ -480,19 +480,19 @@ sub update_flags { ...@@ -480,19 +480,19 @@ sub update_flags {
# This is a new flag. # This is a new flag.
my $flag = $class->create($new_flag, $timestamp); my $flag = $class->create($new_flag, $timestamp);
$new_flag->{id} = $flag->id; $new_flag->{id} = $flag->id;
$class->notify($new_flag, undef, $self); $class->notify($new_flag, undef, $self, $timestamp);
} }
else { else {
my $changes = $new_flag->update($timestamp); my $changes = $new_flag->update($timestamp);
if (scalar(keys %$changes)) { if (scalar(keys %$changes)) {
$class->notify($new_flag, $old_flags{$new_flag->id}, $self); $class->notify($new_flag, $old_flags{$new_flag->id}, $self, $timestamp);
} }
delete $old_flags{$new_flag->id}; delete $old_flags{$new_flag->id};
} }
} }
# These flags have been deleted. # These flags have been deleted.
foreach my $old_flag (values %old_flags) { foreach my $old_flag (values %old_flags) {
$class->notify(undef, $old_flag, $self); $class->notify(undef, $old_flag, $self, $timestamp);
$old_flag->remove_from_db(); $old_flag->remove_from_db();
} }
...@@ -893,7 +893,7 @@ sub extract_flags_from_cgi { ...@@ -893,7 +893,7 @@ sub extract_flags_from_cgi {
=over =over
=item C<notify($flag, $bug, $attachment)> =item C<notify($flag, $old_flag, $object, $timestamp)>
Sends an email notification about a flag being created, fulfilled Sends an email notification about a flag being created, fulfilled
or deleted. or deleted.
...@@ -903,7 +903,7 @@ or deleted. ...@@ -903,7 +903,7 @@ or deleted.
=cut =cut
sub notify { sub notify {
my ($class, $flag, $old_flag, $obj) = @_; my ($class, $flag, $old_flag, $obj, $timestamp) = @_;
my ($bug, $attachment); my ($bug, $attachment);
if (blessed($obj) && $obj->isa('Bugzilla::Attachment')) { if (blessed($obj) && $obj->isa('Bugzilla::Attachment')) {
...@@ -939,6 +939,11 @@ sub notify { ...@@ -939,6 +939,11 @@ sub notify {
# Is there someone to notify? # Is there someone to notify?
return unless ($addressee || $cc_list); return unless ($addressee || $cc_list);
# The email client will display the Date: header in the desired timezone,
# so we can always use UTC here.
$timestamp ||= Bugzilla->dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
$timestamp = format_time($timestamp, '%a, %d %b %Y %T %z', 'UTC');
# If the target bug is restricted to one or more groups, then we need # If the target bug is restricted to one or more groups, then we need
# to make sure we don't send email about it to unauthorized users # to make sure we don't send email about it to unauthorized users
# on the request type's CC: list, so we have to trawl the list for users # on the request type's CC: list, so we have to trawl the list for users
...@@ -964,10 +969,8 @@ sub notify { ...@@ -964,10 +969,8 @@ sub notify {
# If there are users in the CC list who don't have an account, # If there are users in the CC list who don't have an account,
# use the default language for email notifications. # use the default language for email notifications.
my $default_lang; my $default_lang;
my $default_timezone;
if (grep { !$_ } values %recipients) { if (grep { !$_ } values %recipients) {
$default_lang = Bugzilla::User->new()->settings->{'lang'}->{'value'}; $default_lang = Bugzilla::User->new()->settings->{'lang'}->{'value'};
$default_timezone = Bugzilla::User->new()->settings->{'timezone'}->{'value'};
} }
foreach my $to (keys %recipients) { foreach my $to (keys %recipients) {
...@@ -975,13 +978,10 @@ sub notify { ...@@ -975,13 +978,10 @@ sub notify {
# threaded similar to normal bug change emails. # threaded similar to normal bug change emails.
my $thread_user_id = $recipients{$to} ? $recipients{$to}->id : 0; my $thread_user_id = $recipients{$to} ? $recipients{$to}->id : 0;
my $timezone = $recipients{$to} ?
$recipients{$to}->settings->{'timezone'}->{'value'} : $default_timezone;
my $vars = { 'flag' => $flag, my $vars = { 'flag' => $flag,
'old_flag' => $old_flag, 'old_flag' => $old_flag,
'to' => $to, 'to' => $to,
'timezone' => $timezone, 'date' => $timestamp,
'bug' => $bug, 'bug' => $bug,
'attachment' => $attachment, 'attachment' => $attachment,
'threadingmarker' => build_thread_marker($bug->id, $thread_user_id) }; 'threadingmarker' => build_thread_marker($bug->id, $thread_user_id) };
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
From: [% Param('mailfrom') %] From: [% Param('mailfrom') %]
To: [% to_user.email %] To: [% to_user.email %]
Subject: [[% terms.Bug %] [%+ bug.id %]] [% 'New: ' IF isnew %][%+ bug.short_desc %] Subject: [[% terms.Bug %] [%+ bug.id %]] [% 'New: ' IF isnew %][%+ bug.short_desc %]
Date: [% delta_ts || bug.delta_ts FILTER time("%a, %d %b %Y %T %z", to_user.timezone) %] Date: [% date %]
X-Bugzilla-Reason: [% reasonsheader %] X-Bugzilla-Reason: [% reasonsheader %]
X-Bugzilla-Type: [% isnew ? 'new' : 'changed' %] X-Bugzilla-Type: [% isnew ? 'new' : 'changed' %]
X-Bugzilla-Watch-Reason: [% reasonswatchheader %] X-Bugzilla-Watch-Reason: [% reasonswatchheader %]
......
...@@ -51,7 +51,7 @@ To: [% to %] ...@@ -51,7 +51,7 @@ To: [% to %]
Subject: [% flagtype_name %] [%+ subject_status %]: [[% terms.Bug %] [%+ bug.bug_id %]] [% bug.short_desc %] Subject: [% flagtype_name %] [%+ subject_status %]: [[% terms.Bug %] [%+ bug.bug_id %]] [% bug.short_desc %]
[%- IF attachment %] : [%- IF attachment %] :
[Attachment [% attachment.id %]] [% attachment.description %][% END %] [Attachment [% attachment.id %]] [% attachment.description %][% END %]
Date: [% bug.delta_ts FILTER time("%a, %d %b %Y %T %z", timezone) %] Date: [% date %]
X-Bugzilla-Type: request X-Bugzilla-Type: request
[%+ threadingmarker %] [%+ threadingmarker %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment