-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update registrations from email for unmnemonic
- Loading branch information
Showing
3 changed files
with
63 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ defmodule AdventureRegistrations.Mailer do | |
def send_welcome_email(email) do | ||
new() | ||
|> to(email) | ||
|> from(@from) | ||
|> from(adventure_from()) | ||
|> subject("[#{phrase("email_title")}] Welcome!") | ||
|> html_body(welcome_html()) | ||
|> text_body(welcome_text()) | ||
|
@@ -20,8 +20,8 @@ defmodule AdventureRegistrations.Mailer do | |
|
||
def send_question(attributes) do | ||
new() | ||
|> to("[email protected]") | ||
|> from(@from) | ||
|> to(adventure_from()) | ||
|> from(adventure_from()) | ||
|> subject( | ||
"Question from #{attributes["name"]} <#{attributes["email"]}>: #{attributes["subject"]}" | ||
) | ||
|
@@ -31,26 +31,26 @@ defmodule AdventureRegistrations.Mailer do | |
|
||
def send_user_changes(user, changes) do | ||
new() | ||
|> to(@from) | ||
|> from(@from) | ||
|> to(adventure_from()) | ||
|> from(adventure_from()) | ||
|> subject("#{user.email} details changed: #{Enum.join(Map.keys(changes), ", ")}") | ||
|> text_body(inspect(changes)) | ||
|> deliver | ||
end | ||
|
||
def send_user_deletion(user) do | ||
new() | ||
|> to(@from) | ||
|> from(@from) | ||
|> to(adventure_from()) | ||
|> from(adventure_from()) | ||
|> subject("#{user.email} deleted their account") | ||
|> text_body(inspect(user)) | ||
|> deliver | ||
end | ||
|
||
def send_registration(user) do | ||
new() | ||
|> to(@from) | ||
|> from(@from) | ||
|> to(adventure_from()) | ||
|> from(adventure_from()) | ||
|> subject("#{user.email} registered") | ||
|> text_body("Yes") | ||
|> deliver | ||
|
@@ -75,7 +75,7 @@ defmodule AdventureRegistrations.Mailer do | |
|
||
new() | ||
|> to(user.email) | ||
|> from(@from) | ||
|> from(adventure_from()) | ||
|> subject("[#{phrase("email_title")}] #{subject}") | ||
|> text_body(backlog_text(messages)) | ||
|> html_body(backlog_html(messages)) | ||
|
@@ -87,7 +87,7 @@ defmodule AdventureRegistrations.Mailer do | |
def send_password_reset(user) do | ||
new() | ||
|> to(user.email) | ||
|> from(@from) | ||
|> from(adventure_from()) | ||
|> subject("[#{phrase("email_title")}] Password reset") | ||
|> html_body( | ||
"Here is a <a href='#{Router.Helpers.reset_url(Endpoint, :edit, user.recovery_hash)}'>password reset link</a>" | ||
|
@@ -149,6 +149,14 @@ defmodule AdventureRegistrations.Mailer do | |
end | ||
end | ||
|
||
defp adventure_from() do | ||
if AdventureRegistrationsWeb.SharedHelpers.is_unmnemonic_devices() do | ||
"[email protected]" | ||
else | ||
@from | ||
end | ||
end | ||
|
||
def message_from_string(message) do | ||
case message.from_address do | ||
"" -> nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,8 @@ defmodule AdventureRegistrations.UnmnemonicDevices.Integration.Questions do | |
assert Nav.info_text() == "Your question has been submitted." | ||
|
||
[sent_email] = AdventureRegistrations.SwooshHelper.sent_email() | ||
assert sent_email.to == [{"", "b@events.chromatin.ca"}] | ||
assert sent_email.from == {"", "b@events.chromatin.ca"} | ||
assert sent_email.to == [{"", "knut@chromatin.ca"}] | ||
assert sent_email.from == {"", "knut@chromatin.ca"} | ||
|
||
assert sent_email.subject == | ||
"Question from Lucy Parsons <[email protected]>: A Word to Tramps" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
defmodule AdventureRegistrations.Integration.Registrations do | ||
defmodule AdventureRegistrations.Integration.ClandestineRendezvous.Registrations do | ||
use AdventureRegistrationsWeb.ConnCase | ||
use AdventureRegistrations.SwooshHelper | ||
use AdventureRegistrations.ResetRegistrationClosed | ||
|
@@ -240,3 +240,44 @@ defmodule AdventureRegistrations.Integration.Registrations do | |
"You may change your details but it’s too late to guarantee the changes can be integrated" | ||
end | ||
end | ||
|
||
defmodule AdventureRegistrations.Integration.UnmnemonicDevices.Registrations do | ||
use AdventureRegistrationsWeb.ConnCase | ||
use AdventureRegistrations.SwooshHelper | ||
use AdventureRegistrations.ResetRegistrationClosed | ||
use AdventureRegistrations.UnmnemonicDevices | ||
|
||
alias AdventureRegistrations.Pages.Register | ||
alias AdventureRegistrations.Pages.Nav | ||
|
||
# Import Hound helpers | ||
use Hound.Helpers | ||
|
||
# Start a Hound session | ||
hound_session() | ||
|
||
def set_window_to_show_account do | ||
set_window_size(current_window_handle(), 720, 450) | ||
end | ||
|
||
test "registering sends email from and to a different address" do | ||
set_window_to_show_account() | ||
|
||
navigate_to("/") | ||
Nav.register_link().click | ||
|
||
Register.fill_email("[email protected]") | ||
Register.fill_password("nestofspiders") | ||
Register.submit() | ||
|
||
[welcome_email, admin_email] = AdventureRegistrations.SwooshHelper.sent_email() | ||
|
||
assert admin_email.to == [{"", "[email protected]"}] | ||
assert admin_email.from == {"", "[email protected]"} | ||
assert admin_email.subject == "[email protected] registered" | ||
|
||
assert welcome_email.to == [{"", "[email protected]"}] | ||
assert welcome_email.from == {"", "[email protected]"} | ||
assert welcome_email.subject == "[unmnemonic] Welcome!" | ||
end | ||
end |