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

[#7693] Update InfoRequest#recipient_name_and_email #8201

Merged
merged 1 commit into from Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions app/models/info_request.rb
Expand Up @@ -1265,13 +1265,17 @@ def recipient_email_valid_for_followup?
end

def recipient_name_and_email
MailHandler.address_from_name_and_email(
# TRANSLATORS: Please don't use double quotes (") in this translation
# or it will break the site's ability to send emails to authorities!
_("{{law_used_short}} requests at {{public_body}}",
law_used_short: legislation,
public_body: public_body.short_or_long_name),
recipient_email)
# TRANSLATORS: Please don't use double quotes (") in this translation
# or it will break the site's ability to send emails to authorities!
recipient_name = _("{{law_used_short}} requests at {{public_body}}",
law_used_short: legislation,
public_body: public_body.short_or_long_name)

if MySociety::Validate.is_valid_email(recipient_email)
MailHandler.address_from_name_and_email(recipient_name, recipient_email)
else
recipient_name
end
end

def public_response_events
Expand Down
1 change: 1 addition & 0 deletions doc/CHANGES.md
Expand Up @@ -2,6 +2,7 @@

## Highlighted Features

* Fix admin error when authority are missing an email address (Graeme Porteous)
* Allow categories to have notes associated with them (Graeme Porteous)
* Add styling option and rich text editor to the notes admin (Graeme Porteous)
* Strengthen 2FA warning. Users *must* remember to keep this code safe (Gareth
Expand Down
6 changes: 6 additions & 0 deletions spec/models/info_request_spec.rb
Expand Up @@ -2393,6 +2393,12 @@
expect(@info_request.recipient_name_and_email).to eq("FOI requests at TGQ <geraldine-requests@localhost>")
end

it "has a invalid email" do
allow(MySociety::Validate).to receive(:is_valid_email).and_return(false)
expect(@info_request.recipient_name_and_email).
to eq("FOI requests at TGQ")
end

it "copes with indexing after item is deleted" do
load_raw_emails_data
IncomingMessage.find_each(&:parse_raw_email!)
Expand Down