From c667fc5a4a018128c03f73e4e4661fd2b5bd9701 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 17 Jul 2023 12:10:50 +0200 Subject: [PATCH] Fix ArgumentError in mailers when a user's timezone is blank (#26025) --- app/views/notification_mailer/_status.html.haml | 2 +- app/views/user_mailer/appeal_approved.html.haml | 2 +- app/views/user_mailer/appeal_approved.text.erb | 2 +- app/views/user_mailer/appeal_rejected.html.haml | 2 +- app/views/user_mailer/appeal_rejected.text.erb | 2 +- app/views/user_mailer/suspicious_sign_in.html.haml | 2 +- app/views/user_mailer/suspicious_sign_in.text.erb | 2 +- app/views/user_mailer/warning.html.haml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/notification_mailer/_status.html.haml b/app/views/notification_mailer/_status.html.haml index d8aa38b11..4ea3d2c45 100644 --- a/app/views/notification_mailer/_status.html.haml +++ b/app/views/notification_mailer/_status.html.haml @@ -42,4 +42,4 @@ = link_to a.remote_url, a.remote_url %p.status-footer - = link_to l(status.created_at.in_time_zone(time_zone)), web_url("@#{status.account.pretty_acct}/#{status.id}") + = link_to l(status.created_at.in_time_zone(time_zone.presence)), web_url("@#{status.account.pretty_acct}/#{status.id}") diff --git a/app/views/user_mailer/appeal_approved.html.haml b/app/views/user_mailer/appeal_approved.html.haml index d62789a06..1bbd8ae75 100644 --- a/app/views/user_mailer/appeal_approved.html.haml +++ b/app/views/user_mailer/appeal_approved.html.haml @@ -36,7 +36,7 @@ %tbody %tr %td.column-cell.text-center - %p= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) + %p= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone.presence)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone.presence)) %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/user_mailer/appeal_approved.text.erb b/app/views/user_mailer/appeal_approved.text.erb index 99596605a..9a4bd81c3 100644 --- a/app/views/user_mailer/appeal_approved.text.erb +++ b/app/views/user_mailer/appeal_approved.text.erb @@ -2,6 +2,6 @@ === -<%= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) %> +<%= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone.presence)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone.presence)) %> => <%= root_url %> diff --git a/app/views/user_mailer/appeal_rejected.html.haml b/app/views/user_mailer/appeal_rejected.html.haml index ae60775b0..22e3f62df 100644 --- a/app/views/user_mailer/appeal_rejected.html.haml +++ b/app/views/user_mailer/appeal_rejected.html.haml @@ -36,7 +36,7 @@ %tbody %tr %td.column-cell.text-center - %p= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) + %p= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone.presence)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone.presence)) %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/user_mailer/appeal_rejected.text.erb b/app/views/user_mailer/appeal_rejected.text.erb index 3c9377718..3b063e19d 100644 --- a/app/views/user_mailer/appeal_rejected.text.erb +++ b/app/views/user_mailer/appeal_rejected.text.erb @@ -2,6 +2,6 @@ === -<%= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) %> +<%= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone.presence)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone.presence)) %> => <%= root_url %> diff --git a/app/views/user_mailer/suspicious_sign_in.html.haml b/app/views/user_mailer/suspicious_sign_in.html.haml index 6ebba3fa5..3dbec61ff 100644 --- a/app/views/user_mailer/suspicious_sign_in.html.haml +++ b/app/views/user_mailer/suspicious_sign_in.html.haml @@ -47,7 +47,7 @@ %strong= "#{t('sessions.browser')}:" %span{ title: @user_agent }= t 'sessions.description', browser: t("sessions.browsers.#{@detection.id}", default: @detection.id.to_s), platform: t("sessions.platforms.#{@detection.platform.id}", default: @detection.platform.id.to_s) %br/ - = l(@timestamp.in_time_zone(@resource.time_zone)) + = l(@timestamp.in_time_zone(@resource.time_zone.presence)) %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/user_mailer/suspicious_sign_in.text.erb b/app/views/user_mailer/suspicious_sign_in.text.erb index 956071e77..ed01e54fa 100644 --- a/app/views/user_mailer/suspicious_sign_in.text.erb +++ b/app/views/user_mailer/suspicious_sign_in.text.erb @@ -8,7 +8,7 @@ <%= t('sessions.ip') %>: <%= @remote_ip %> <%= t('sessions.browser') %>: <%= t('sessions.description', browser: t("sessions.browsers.#{@detection.id}", default: "#{@detection.id}"), platform: t("sessions.platforms.#{@detection.platform.id}", default: "#{@detection.platform.id}")) %> -<%= l(@timestamp.in_time_zone(@resource.time_zone)) %> +<%= l(@timestamp.in_time_zone(@resource.time_zone.presence)) %> <%= t 'user_mailer.suspicious_sign_in.further_actions_html', action: t('user_mailer.suspicious_sign_in.change_password') %> diff --git a/app/views/user_mailer/warning.html.haml b/app/views/user_mailer/warning.html.haml index 9cb73b0fe..8a878bead 100644 --- a/app/views/user_mailer/warning.html.haml +++ b/app/views/user_mailer/warning.html.haml @@ -58,7 +58,7 @@ - unless @statuses.empty? - @statuses.each_with_index do |status, i| - = render 'notification_mailer/status', status: status, i: i + 1, highlighted: true, time_zone: @resource.time_zone + = render 'notification_mailer/status', status: status, i: i + 1, highlighted: true, time_zone: @resource.time_zone.presence %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody