Skip to content
Merged
12 changes: 6 additions & 6 deletions app/backend/src/couchers/email/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ def _body_builder(
self,
loc_context: LocalizationContext,
*,
standard_greeting: bool = True,
standard_closing: bool = True,
default_greeting: bool = True,
default_closing: bool = True,
security_warning: bool = False,
) -> EmailBlocksBuilder:
builder = EmailBlocksBuilder(locales=loc_context.locale_list, string_key_base=self.string_key_base)
if standard_greeting:
if default_greeting:
builder.para("generic.greeting_line", {"name": self.user_name})
if standard_closing:
builder.para("generic.closing_line", epilogue=True)
if security_warning:
builder.para("generic.security_warning_contact_support", epilogue=True)
if default_closing:
builder.para("generic.closing_lines.default", epilogue=True)
return builder

@classmethod
Expand Down Expand Up @@ -126,7 +126,7 @@ def dummy_bob() -> UserInfo:
return UserInfo(
name="Bob",
age=30,
city="Berlin",
city="Berlin, Germany",
avatar_url="https://couchers.org/logo512.png",
profile_url="https://couchers.org/user/bob",
)
Expand Down
221 changes: 125 additions & 96 deletions app/backend/src/couchers/email/emails.py

Large diffs are not rendered by default.

285 changes: 140 additions & 145 deletions app/backend/src/couchers/email/locales/en.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions app/backend/src/couchers/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def icon_url() -> str:
return f"{config.BASE_URL}/logo512.png"


def dashboard_link() -> str:
return f"{config.BASE_URL}/dashboard"


def profile_link() -> str:
return f"{config.BASE_URL}/profile"

Expand Down Expand Up @@ -118,6 +122,10 @@ def donation_success_url() -> str:
return f"{config.BASE_URL}/donate?success=true"


def strong_verification_url() -> str:
return f"{config.BASE_URL}/strong-verification"


def complete_strong_verification_url(*, verification_attempt_token: str) -> str:
return f"{config.BASE_URL}/complete-strong-verification?verification_attempt_token={verification_attempt_token}"

Expand Down
16 changes: 7 additions & 9 deletions app/backend/src/tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,8 @@ def test_ChangeEmailV2_sends_proper_emails(db, fast_passwords, push_collector: P
with session_scope() as session:
jobs = session.execute(select(BackgroundJob).where(BackgroundJob.job_type == "send_email")).scalars().all()
assert len(jobs) == 2
uq_str1 = b"An email change to the email"
uq_str2 = (
b"You requested that your email be changed to this email address on Couchers.org. Your old email address is"
)
uq_str1 = b"Email address change initiated"
uq_str2 = b"You requested that your email be changed from"
assert (uq_str1 in jobs[0].payload and uq_str2 in jobs[1].payload) or (
uq_str2 in jobs[0].payload and uq_str1 in jobs[1].payload
)
Expand Down Expand Up @@ -651,7 +649,7 @@ def test_DeleteAccount_start(db, email_collector: EmailCollector):
with account_session(token) as account:
account.DeleteAccount(account_pb2.DeleteAccountReq(confirm=True, reason=None))
email = email_collector.pop_for_recipient(user.email, last=True)
assert email.subject == "[TEST] Confirm your Couchers.org account deletion"
assert email.subject == "[TEST] Confirm your account deletion"

with session_scope() as session:
deletion_token: AccountDeletionToken = session.execute(
Expand Down Expand Up @@ -690,10 +688,10 @@ def test_full_delete_account_with_recovery(db, email_collector: EmailCollector,
account.DeleteAccount(account_pb2.DeleteAccountReq(confirm=True))

email = email_collector.pop_for_recipient(user.email, last=True)
assert email.subject == "[TEST] Confirm your Couchers.org account deletion"
assert email.subject == "[TEST] Confirm your account deletion"
assert email.recipient == user.email
assert "account deletion" in email.subject.lower()
unique_string = "You requested that we delete your account from Couchers.org."
unique_string = "You requested that we delete your Couchers.org account."
assert unique_string in email.plain
assert unique_string in email.html
assert "support@couchers.org" in email.plain
Expand Down Expand Up @@ -729,7 +727,7 @@ def test_full_delete_account_with_recovery(db, email_collector: EmailCollector,
email = email_collector.pop_for_recipient(user.email, last=True)
assert email.recipient == user.email
assert "account has been deleted" in email.subject.lower()
unique_string = "You have successfully deleted your account from Couchers.org."
unique_string = "You have successfully deleted your Couchers.org account."
assert unique_string in email.plain
assert unique_string in email.html
assert "7 days" in email.plain
Expand Down Expand Up @@ -766,7 +764,7 @@ def test_full_delete_account_with_recovery(db, email_collector: EmailCollector,
email = email_collector.pop_for_recipient(user.email, last=True)
assert email.recipient == user.email
assert "account has been recovered" in email.subject.lower()
unique_string = "Your account on Couchers.org has been successfully recovered!"
unique_string = "Your Couchers.org account has been successfully recovered."
assert unique_string in email.plain
assert unique_string in email.html
assert "support@couchers.org" in email.plain
Expand Down
4 changes: 2 additions & 2 deletions app/backend/src/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ def test_friend_request_flow(db, email_collector: EmailCollector, push_collector

email = email_collector.pop_for_recipient(user2.email, last=True)
assert email.recipient == user2.email
assert email.subject == f"[TEST] {user1.name} wants to be your friend on Couchers.org!"
assert email.subject == f"[TEST] {user1.name} wants to be your friend"
assert user2.name in email.plain
assert user2.name in email.html
assert user1.name in email.plain
Expand Down Expand Up @@ -966,7 +966,7 @@ def test_friend_request_flow(db, email_collector: EmailCollector, push_collector

email = email_collector.pop_for_recipient(user1.email, last=True)
assert email.recipient == user1.email
assert email.subject == f"[TEST] {user2.name} accepted your friend request!"
assert email.subject == f"[TEST] {user2.name} accepted your friend request"
assert user1.name in email.plain
assert user1.name in email.html
assert user2.name in email.plain
Expand Down
14 changes: 7 additions & 7 deletions app/backend/src/tests/test_bg_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,27 +1015,27 @@ def test_send_reference_reminders(db):
expected_emails = [
(
"user11@couchers.org.invalid",
"[TEST] You have 14 days to write a reference for User 12!",
"[TEST] You have 14 days to write a reference for User 12",
("from when you hosted them", "/leave-reference/hosted/"),
),
(
"user4@couchers.org.invalid",
"[TEST] You have 3 days to write a reference for User 3!",
"[TEST] You have 3 days to write a reference for User 3",
("from when you surfed with them", "/leave-reference/surfed/"),
),
(
"user5@couchers.org.invalid",
"[TEST] You have 7 days to write a reference for User 6!",
"[TEST] You have 7 days to write a reference for User 6",
("from when you hosted them", "/leave-reference/hosted/"),
),
(
"user7@couchers.org.invalid",
"[TEST] You have 14 days to write a reference for User 8!",
"[TEST] You have 14 days to write a reference for User 8",
("from when you surfed with them", "/leave-reference/surfed/"),
),
(
"user8@couchers.org.invalid",
"[TEST] You have 14 days to write a reference for User 7!",
"[TEST] You have 14 days to write a reference for User 7",
("from when you hosted them", "/leave-reference/hosted/"),
),
]
Expand Down Expand Up @@ -1198,8 +1198,8 @@ def test_send_host_request_reminders(db, moderator):
expected_emails = [
(
"user2@couchers.org.invalid",
"[TEST] You have a pending host request from User 1!",
("Please respond to the request!", "User 1"),
"[TEST] You have a pending host request from User 1",
("User 1", "is waiting for your response"),
)
]

Expand Down
10 changes: 4 additions & 6 deletions app/backend/src/tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def test_email_changed_confirmation_sent_to_new_email(db, email_collector: Email
assert user.name in email.html
assert user.email in email.plain
assert user.email in email.html
assert "Your old email address is" in email.plain
assert "Your old email address is" in email.html
assert "You requested that your email be changed from " in email.plain
assert "You requested that your email be changed from " in email.html
assert f"http://localhost:3000/confirm-email?token={confirmation_token}" in email.plain
assert f"http://localhost:3000/confirm-email?token={confirmation_token}" in email.html
assert "support@couchers.org" in email.plain
Expand Down Expand Up @@ -401,7 +401,7 @@ def test_send_donation_email(db, monkeypatch):

Thank you so much for your donation of $20 to Couchers.org.

Your contribution will go towards building and sustaining the Couchers.org platform and community, and is vital for our goal of a completely free and non-profit generation of couch surfing.
Your contribution will go towards building and sustaining the Couchers.org community, and is vital for our goal of a free and non-profit couch surfing platform.

You can download an invoice and receipt for the donation here:

Expand All @@ -411,8 +411,6 @@ def test_send_donation_email(db, monkeypatch):

If you have any questions about your donation, please email us at donations@couchers.org.

Your generosity will help deliver the platform for everyone.

Thank you!

Aapeli and Itsi,
Expand All @@ -424,7 +422,7 @@ def test_send_donation_email(db, monkeypatch):
"""
)

assert "Thank you so much for your donation of $20 to Couchers.org." in email.html
assert "Thank you so much for your donation of <b>$20</b> to Couchers.org." in email.html
assert email.sender_name == "Couchers.org"
assert email.sender_email == "notify@couchers.org.invalid"
assert email.recipient == "testing@couchers.org.invalid"
Expand Down
2 changes: 1 addition & 1 deletion app/backend/src/tests/test_jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def test_modnotes(db, email_collector: EmailCollector, push_collector: PushColle
)

email = email_collector.pop_for_recipient(user.email, last=True)
assert email.subject == "[TEST] You have received a mod note"
assert email.subject == "[TEST] You have received a moderator note"
Comment thread
tristanlabelle marked this conversation as resolved.

push = push_collector.pop_for_user(user.id, last=True)
assert push.content.title == "New moderator note"
Comment thread
tristanlabelle marked this conversation as resolved.
Expand Down
Loading