From: Frédéric Buclin Date: Sat, 23 Apr 2011 17:21:04 +0000 (+0200) Subject: Bug 652165: Flagmails have a wrong Date: value X-Git-Tag: bugzilla-4.0.1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf1b9d1e135d85ba1197cd3cfff8790ca92fb39f;p=thirdparty%2Fbugzilla.git Bug 652165: Flagmails have a wrong Date: value r=wicked a=LpSolit --- diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index d12836273e..e585fb7afa 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -377,6 +377,10 @@ sub Send { my @sent; my @excluded; + # The email client will display the Date: header in the desired timezone, + # so we can always use UTC here. + my $date = format_time($bug->delta_ts, '%a, %d %b %Y %T %z', 'UTC'); + foreach my $user_id (keys %recipients) { my %rels_which_want; my $sent_mail = 0; @@ -428,6 +432,7 @@ sub Send { bug => $bug, comments => $comments, is_new => !$start, + date => $date, changer => $changer, watchers => exists $watching{$user_id} ? $watching{$user_id} : undef, @@ -461,6 +466,7 @@ sub sendMail { my $bug = $params->{bug}; my @send_comments = @{ $params->{comments} }; my $isnew = $params->{is_new}; + my $date = $params->{date}; my $changer = $params->{changer}; my $watchingRef = $params->{watchers}; my @diffparts = @{ $params->{diff_parts} }; @@ -561,6 +567,7 @@ sub sendMail { my $vars = { isnew => $isnew, + date => $date, to_user => $user, bug => $bug, changedfields => \@changed_fields, diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index 13dfe6ad9c..d6dbe1629e 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -478,19 +478,19 @@ sub update_flags { # This is a new flag. my $flag = $class->create($new_flag, $timestamp); $new_flag->{id} = $flag->id; - $class->notify($new_flag, undef, $self); + $class->notify($new_flag, undef, $self, $timestamp); } else { my $changes = $new_flag->update($timestamp); 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}; } } # These flags have been deleted. 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(); } @@ -893,7 +893,7 @@ sub extract_flags_from_cgi { =over -=item C +=item C Sends an email notification about a flag being created, fulfilled or deleted. @@ -903,7 +903,7 @@ or deleted. =cut sub notify { - my ($class, $flag, $old_flag, $obj) = @_; + my ($class, $flag, $old_flag, $obj, $timestamp) = @_; my ($bug, $attachment); if (blessed($obj) && $obj->isa('Bugzilla::Attachment')) { @@ -939,6 +939,11 @@ sub notify { # Is there someone to notify? 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 # 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 @@ -964,10 +969,8 @@ sub notify { # If there are users in the CC list who don't have an account, # use the default language for email notifications. my $default_lang; - my $default_timezone; if (grep { !$_ } values %recipients) { $default_lang = Bugzilla::User->new()->settings->{'lang'}->{'value'}; - $default_timezone = Bugzilla::User->new()->settings->{'timezone'}->{'value'}; } foreach my $to (keys %recipients) { @@ -975,13 +978,10 @@ sub notify { # threaded similar to normal bug change emails. 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, 'old_flag' => $old_flag, 'to' => $to, - 'timezone' => $timezone, + 'date' => $timestamp, 'bug' => $bug, 'attachment' => $attachment, 'threadingmarker' => build_thread_marker($bug->id, $thread_user_id) }; diff --git a/template/en/default/email/newchangedmail.txt.tmpl b/template/en/default/email/newchangedmail.txt.tmpl index 44af3055d1..05e453adae 100644 --- a/template/en/default/email/newchangedmail.txt.tmpl +++ b/template/en/default/email/newchangedmail.txt.tmpl @@ -24,7 +24,7 @@ From: [% Param('mailfrom') %] To: [% to_user.email %] Subject: [[% terms.Bug %] [%+ bug.id %]] [% 'New: ' IF isnew %][%+ bug.short_desc %] -Date: [% bug.delta_ts FILTER time("%a, %d %b %Y %T %z", to_user.timezone) %] +Date: [% date %] X-Bugzilla-Reason: [% reasonsheader %] X-Bugzilla-Type: [% isnew ? 'new' : 'changed' %] X-Bugzilla-Watch-Reason: [% reasonswatchheader %] diff --git a/template/en/default/request/email.txt.tmpl b/template/en/default/request/email.txt.tmpl index 03c5e57c08..182ac09e0a 100644 --- a/template/en/default/request/email.txt.tmpl +++ b/template/en/default/request/email.txt.tmpl @@ -51,7 +51,7 @@ To: [% to %] Subject: [% flagtype_name %] [%+ subject_status %]: [[% terms.Bug %] [%+ bug.bug_id %]] [% bug.short_desc %] [%- IF attachment %] : [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 [%+ threadingmarker %]