Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert email subject in the receivers language #8469

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions app/mailers/alaveteli_pro/embargo_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,31 @@
def expiring_alert(user, info_requests)
@user = user
@info_requests = info_requests
subject = n_(
"{{count}} request will be made public on {{site_name}} this week",
"{{count}} requests will be made public on {{site_name}} this week",
info_requests.count,
site_name: site_name.html_safe,
count: info_requests.count
mail_user(
@user,
subject: -> { n_(

Check warning on line 73 in app/mailers/alaveteli_pro/embargo_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Block body expression is on the same line as the block start. Raw Output: app/mailers/alaveteli_pro/embargo_mailer.rb:73:23: C: Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.
"{{count}} request will be made public on {{site_name}} this week",
"{{count}} requests will be made public on {{site_name}} this week",
info_requests.count,
site_name: site_name.html_safe,
count: info_requests.count
) }

Check warning on line 79 in app/mailers/alaveteli_pro/embargo_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Expression at 79, 11 should be on its own line. Raw Output: app/mailers/alaveteli_pro/embargo_mailer.rb:79:11: C: Layout/BlockEndNewline: Expression at 79, 11 should be on its own line.
)
mail_user(@user, subject: subject)
end

def expired_alert(user, info_requests)
@user = user
@info_requests = info_requests
subject = n_(
"{{count}} request has been made public on {{site_name}}",
"{{count}} requests have been made public on {{site_name}}",
info_requests.count,
site_name: site_name.html_safe,
count: info_requests.count
mail_user(
@user,
subject: -> { n_(

Check warning on line 88 in app/mailers/alaveteli_pro/embargo_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Block body expression is on the same line as the block start. Raw Output: app/mailers/alaveteli_pro/embargo_mailer.rb:88:23: C: Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.
"{{count}} request has been made public on {{site_name}}",
"{{count}} requests have been made public on {{site_name}}",
info_requests.count,
site_name: site_name.html_safe,
count: info_requests.count
) }

Check warning on line 94 in app/mailers/alaveteli_pro/embargo_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Expression at 94, 11 should be on its own line. Raw Output: app/mailers/alaveteli_pro/embargo_mailer.rb:94:11: C: Layout/BlockEndNewline: Expression at 94, 11 should be on its own line.
)
mail_user(@user, subject: subject)
end
end
end
11 changes: 7 additions & 4 deletions app/mailers/alaveteli_pro/subscription_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
def payment_failed(user)
auto_generated_headers(user)

subject = _('Action Required: Payment failed on {{pro_site_name}}',
pro_site_name: pro_site_name)

@user_name = user.name
@pro_site_name = pro_site_name.html_safe
@subscriptions_url = subscriptions_url
mail_user(user, subject: subject)
mail_user(
user,
subject: -> { _(

Check warning on line 11 in app/mailers/alaveteli_pro/subscription_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Block body expression is on the same line as the block start. Raw Output: app/mailers/alaveteli_pro/subscription_mailer.rb:11:21: C: Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.
'Action Required: Payment failed on {{pro_site_name}}',
pro_site_name: pro_site_name
) }

Check warning on line 14 in app/mailers/alaveteli_pro/subscription_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Expression at 14, 9 should be on its own line. Raw Output: app/mailers/alaveteli_pro/subscription_mailer.rb:14:9: C: Layout/BlockEndNewline: Expression at 14, 9 should be on its own line.
)
end

private
Expand Down
5 changes: 3 additions & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ class ApplicationMailer < ActionMailer::Base
# about the errors, and have to do error checking on return codes.
self.raise_delivery_errors = true

# The subject: arg must be a proc, it is localized with the user's locale.
def mail_user(user, subject:, **opts)
if user.is_a?(User)
locale = user.locale
opts[:to] = user.name_and_email
else
opts[:to] = user
Expand All @@ -36,7 +38,6 @@ def mail_user(user, subject:, **opts)
opts[:from] = MailHandler.address_from_name_and_email(
opts[:from].name, blackhole_email
)

else
set_reply_to_headers
opts[:from] ||= blackhole_email
Expand All @@ -45,7 +46,7 @@ def mail_user(user, subject:, **opts)
set_auto_generated_headers

default_opts = {
subject: subject
subject: AlaveteliLocalization.with_locale(locale) { subject.call }
}
default_opts.merge!(opts)
mail(default_opts)
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/contact_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def user_message(from_user, recipient_user, from_user_url, subject, message)
mail_user(
recipient_user,
from: from_user,
subject: subject
subject: -> { subject }
)
end

Expand All @@ -53,7 +53,7 @@ def from_admin_message(recipient_name, recipient_email, subject, message)
to_address,
from: from_address,
bcc: AlaveteliConfiguration.contact_email,
subject: subject
subject: -> { subject }
)
end
end
6 changes: 4 additions & 2 deletions app/mailers/info_request_batch_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

mail_user(
user,
subject: _("Your batch request \"{{title}}\" has been sent",
title: info_request_batch.title.html_safe)
subject: -> { _(

Check warning on line 15 in app/mailers/info_request_batch_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Block body expression is on the same line as the block start. Raw Output: app/mailers/info_request_batch_mailer.rb:15:21: C: Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.
"Your batch request \"{{title}}\" has been sent",
title: info_request_batch.title.html_safe
) }

Check warning on line 18 in app/mailers/info_request_batch_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Expression at 18, 9 should be on its own line. Raw Output: app/mailers/info_request_batch_mailer.rb:18:9: C: Layout/BlockEndNewline: Expression at 18, 9 should be on its own line.
)
end
end
59 changes: 29 additions & 30 deletions app/mailers/notification_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@

mail_user(
user,
subject: _("Your daily request summary from {{pro_site_name}}",
pro_site_name: pro_site_name)
subject: -> {
_("Your daily request summary from {{pro_site_name}}",
pro_site_name: pro_site_name)
}
)
end

Expand All @@ -99,45 +101,42 @@
@info_request = notification.info_request_event.info_request
@incoming_message = notification.info_request_event.incoming_message

subject = _("New response to your FOI request - {{request_title}}",
request_title: @info_request.title.html_safe)
mail_user(
@info_request.user,
subject: subject,
subject: -> {
_("New response to your FOI request - {{request_title}}",
request_title: @info_request.title.html_safe)
},
template_name: 'response_notification'
)
end

def embargo_expiring_notification(notification)
@info_request = notification.info_request_event.info_request

subject = _(
"Your FOI request - {{request_title}} will be made public on " \
"{{site_name}} this week",
request_title: @info_request.title.html_safe,
site_name: site_name.html_safe
)

mail_user(
@info_request.user,
subject: subject,
subject: -> { _(

Check warning on line 119 in app/mailers/notification_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Block body expression is on the same line as the block start. Raw Output: app/mailers/notification_mailer.rb:119:21: C: Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.
"Your FOI request - {{request_title}} will be made public on " \
"{{site_name}} this week",
request_title: @info_request.title.html_safe,
site_name: site_name.html_safe
) },

Check warning on line 124 in app/mailers/notification_mailer.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Expression at 124, 9 should be on its own line. Raw Output: app/mailers/notification_mailer.rb:124:9: C: Layout/BlockEndNewline: Expression at 124, 9 should be on its own line.
template_name: 'embargo_expiring_notification'
)
end

def expire_embargo_notification(notification)
@info_request = notification.info_request_event.info_request

subject = _(
"Your FOI request - {{request_title}} has been made public on " \
"{{site_name}}",
request_title: @info_request.title.html_safe,
site_name: site_name.html_safe
)

mail_user(
@info_request.user,
subject: subject,
subject: -> { _(
"Your FOI request - {{request_title}} has been made public on " \
"{{site_name}}",
request_title: @info_request.title.html_safe,
site_name: site_name.html_safe
) },
template_name: 'expire_embargo_notification'
)
end
Expand All @@ -146,12 +145,12 @@
@info_request = notification.info_request_event.info_request
@url = signin_url(r: respond_to_last_path(@info_request))

subject = _("Delayed response to your FOI request - {{request_title}}",
request_title: @info_request.title.html_safe)

mail_user(
@info_request.user,
subject: subject,
subject: -> { _(
"Delayed response to your FOI request - {{request_title}}",
request_title: @info_request.title.html_safe
) },
template_name: 'overdue_notification'
)
end
Expand All @@ -160,13 +159,13 @@
@info_request = notification.info_request_event.info_request
@url = signin_url(r: respond_to_last_path(@info_request))

subject = _("You're long overdue a response to your FOI request " \
"- {{request_title}}",
request_title: @info_request.title.html_safe)

mail_user(
@info_request.user,
subject: subject,
subject: -> { _(
"You're long overdue a response to your FOI request " \
"- {{request_title}}",
request_title: @info_request.title.html_safe
) },
template_name: 'very_overdue_notification'
)
end
Expand Down
46 changes: 30 additions & 16 deletions app/mailers/request_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ def new_response(info_request, incoming_message)

mail_user(
info_request.user,
subject: _("New response to your FOI request - {{request_title}}",
request_title: info_request.title.html_safe),
subject: -> {
_("New response to your FOI request - {{request_title}}",
request_title: info_request.title.html_safe)
},
charset: "UTF-8"
)
end
Expand All @@ -103,8 +105,10 @@ def overdue_alert(info_request, user)

mail_user(
user,
subject: _("Delayed response to your FOI request - {{request_title}}",
request_title: info_request.title.html_safe)
subject: -> { _(
"Delayed response to your FOI request - {{request_title}}",
request_title: info_request.title.html_safe
) }
)
end

Expand All @@ -115,9 +119,11 @@ def very_overdue_alert(info_request, user)

mail_user(
user,
subject: _("You're long overdue a response to your FOI request - " \
"{{request_title}}",
request_title: info_request.title.html_safe)
subject: -> { _(
"You're long overdue a response to your FOI request - " \
"{{request_title}}",
request_title: info_request.title.html_safe
) }
)
end

Expand All @@ -133,8 +139,10 @@ def new_response_reminder_alert(info_request, incoming_message)

mail_user(
info_request.user,
subject: _("Please update the status of your request - {{request_title}}",
request_title: info_request.title.html_safe)
subject: -> { _(
"Please update the status of your request - {{request_title}}",
request_title: info_request.title.html_safe
) }
)
end

Expand All @@ -145,7 +153,7 @@ def old_unclassified_updated(info_request)

mail_user(
info_request.user,
subject: _("Someone has updated the status of your request")
subject: -> { _("Someone has updated the status of your request") }
)
end

Expand All @@ -162,8 +170,10 @@ def not_clarified_alert(info_request, incoming_message)

mail_user(
info_request.user,
subject: _("Clarify your FOI request - {{request_title}}",
request_title: info_request.title.html_safe)
subject: -> { _(
"Clarify your FOI request - {{request_title}}",
request_title: info_request.title.html_safe
) }
)
end

Expand All @@ -175,8 +185,10 @@ def comment_on_alert(info_request, comment)

mail_user(
info_request.user,
subject: _("Somebody added a note to your FOI request - {{request_title}}",
request_title: info_request.title.html_safe)
subject: -> { _(
"Somebody added a note to your FOI request - {{request_title}}",
request_title: info_request.title.html_safe
) }
)
end

Expand All @@ -189,8 +201,10 @@ def comment_on_alert_plural(info_request, count, earliest_unalerted_comment)

mail_user(
info_request.user,
subject: _("Some notes have been added to your FOI request - {{request_title}}",
request_title: info_request.title.html_safe)
subject: -> { _(
"Some notes have been added to your FOI request - {{request_title}}",
request_title: info_request.title.html_safe
) }
)
end

Expand Down
4 changes: 3 additions & 1 deletion app/mailers/survey_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def survey_alert(info_request)

mail_user(
@user,
subject: _('A survey about your recent Freedom of Information request')
subject: -> { _(
'A survey about your recent Freedom of Information request'
) }
)
end

Expand Down
6 changes: 4 additions & 2 deletions app/mailers/track_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def event_digest(user, email_about_things)

mail_user(
user,
subject: _("Your {{site_name}} email alert",
site_name: site_name.html_safe)
subject: -> { _(
"Your {{site_name}} email alert",
site_name: site_name.html_safe
) }
)
end

Expand Down
Loading
Loading