Skip to content

Commit 54dd177

Browse files
Backend/emails: Review copy before localizing (#9150)
1 parent dfbedb1 commit 54dd177

9 files changed

Lines changed: 300 additions & 272 deletions

File tree

app/backend/src/couchers/email/blocks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ def _body_builder(
4747
self,
4848
loc_context: LocalizationContext,
4949
*,
50-
standard_greeting: bool = True,
51-
standard_closing: bool = True,
50+
default_greeting: bool = True,
51+
default_closing: bool = True,
5252
security_warning: bool = False,
5353
) -> EmailBlocksBuilder:
5454
builder = EmailBlocksBuilder(locales=loc_context.locale_list, string_key_base=self.string_key_base)
55-
if standard_greeting:
55+
if default_greeting:
5656
builder.para("generic.greeting_line", {"name": self.user_name})
57-
if standard_closing:
58-
builder.para("generic.closing_line", epilogue=True)
5957
if security_warning:
6058
builder.para("generic.security_warning_contact_support", epilogue=True)
59+
if default_closing:
60+
builder.para("generic.closing_lines.default", epilogue=True)
6161
return builder
6262

6363
@classmethod
@@ -126,7 +126,7 @@ def dummy_bob() -> UserInfo:
126126
return UserInfo(
127127
name="Bob",
128128
age=30,
129-
city="Berlin",
129+
city="Berlin, Germany",
130130
avatar_url="https://couchers.org/logo512.png",
131131
profile_url="https://couchers.org/user/bob",
132132
)

app/backend/src/couchers/email/emails.py

Lines changed: 125 additions & 96 deletions
Large diffs are not rendered by default.

app/backend/src/couchers/email/locales/en.json

Lines changed: 140 additions & 145 deletions
Large diffs are not rendered by default.

app/backend/src/couchers/urls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def icon_url() -> str:
1515
return f"{config.BASE_URL}/logo512.png"
1616

1717

18+
def dashboard_link() -> str:
19+
return f"{config.BASE_URL}/dashboard"
20+
21+
1822
def profile_link() -> str:
1923
return f"{config.BASE_URL}/profile"
2024

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

120124

125+
def strong_verification_url() -> str:
126+
return f"{config.BASE_URL}/strong-verification"
127+
128+
121129
def complete_strong_verification_url(*, verification_attempt_token: str) -> str:
122130
return f"{config.BASE_URL}/complete-strong-verification?verification_attempt_token={verification_attempt_token}"
123131

app/backend/src/tests/test_account.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,8 @@ def test_ChangeEmailV2_sends_proper_emails(db, fast_passwords, push_collector: P
593593
with session_scope() as session:
594594
jobs = session.execute(select(BackgroundJob).where(BackgroundJob.job_type == "send_email")).scalars().all()
595595
assert len(jobs) == 2
596-
uq_str1 = b"An email change to the email"
597-
uq_str2 = (
598-
b"You requested that your email be changed to this email address on Couchers.org. Your old email address is"
599-
)
596+
uq_str1 = b"Email address change initiated"
597+
uq_str2 = b"You requested that your email be changed from"
600598
assert (uq_str1 in jobs[0].payload and uq_str2 in jobs[1].payload) or (
601599
uq_str2 in jobs[0].payload and uq_str1 in jobs[1].payload
602600
)
@@ -651,7 +649,7 @@ def test_DeleteAccount_start(db, email_collector: EmailCollector):
651649
with account_session(token) as account:
652650
account.DeleteAccount(account_pb2.DeleteAccountReq(confirm=True, reason=None))
653651
email = email_collector.pop_for_recipient(user.email, last=True)
654-
assert email.subject == "[TEST] Confirm your Couchers.org account deletion"
652+
assert email.subject == "[TEST] Confirm your account deletion"
655653

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

692690
email = email_collector.pop_for_recipient(user.email, last=True)
693-
assert email.subject == "[TEST] Confirm your Couchers.org account deletion"
691+
assert email.subject == "[TEST] Confirm your account deletion"
694692
assert email.recipient == user.email
695693
assert "account deletion" in email.subject.lower()
696-
unique_string = "You requested that we delete your account from Couchers.org."
694+
unique_string = "You requested that we delete your Couchers.org account."
697695
assert unique_string in email.plain
698696
assert unique_string in email.html
699697
assert "support@couchers.org" in email.plain
@@ -729,7 +727,7 @@ def test_full_delete_account_with_recovery(db, email_collector: EmailCollector,
729727
email = email_collector.pop_for_recipient(user.email, last=True)
730728
assert email.recipient == user.email
731729
assert "account has been deleted" in email.subject.lower()
732-
unique_string = "You have successfully deleted your account from Couchers.org."
730+
unique_string = "You have successfully deleted your Couchers.org account."
733731
assert unique_string in email.plain
734732
assert unique_string in email.html
735733
assert "7 days" in email.plain
@@ -766,7 +764,7 @@ def test_full_delete_account_with_recovery(db, email_collector: EmailCollector,
766764
email = email_collector.pop_for_recipient(user.email, last=True)
767765
assert email.recipient == user.email
768766
assert "account has been recovered" in email.subject.lower()
769-
unique_string = "Your account on Couchers.org has been successfully recovered!"
767+
unique_string = "Your Couchers.org account has been successfully recovered."
770768
assert unique_string in email.plain
771769
assert unique_string in email.html
772770
assert "support@couchers.org" in email.plain

app/backend/src/tests/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ def test_friend_request_flow(db, email_collector: EmailCollector, push_collector
923923

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

967967
email = email_collector.pop_for_recipient(user1.email, last=True)
968968
assert email.recipient == user1.email
969-
assert email.subject == f"[TEST] {user2.name} accepted your friend request!"
969+
assert email.subject == f"[TEST] {user2.name} accepted your friend request"
970970
assert user1.name in email.plain
971971
assert user1.name in email.html
972972
assert user2.name in email.plain

app/backend/src/tests/test_bg_jobs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,27 +1015,27 @@ def test_send_reference_reminders(db):
10151015
expected_emails = [
10161016
(
10171017
"user11@couchers.org.invalid",
1018-
"[TEST] You have 14 days to write a reference for User 12!",
1018+
"[TEST] You have 14 days to write a reference for User 12",
10191019
("from when you hosted them", "/leave-reference/hosted/"),
10201020
),
10211021
(
10221022
"user4@couchers.org.invalid",
1023-
"[TEST] You have 3 days to write a reference for User 3!",
1023+
"[TEST] You have 3 days to write a reference for User 3",
10241024
("from when you surfed with them", "/leave-reference/surfed/"),
10251025
),
10261026
(
10271027
"user5@couchers.org.invalid",
1028-
"[TEST] You have 7 days to write a reference for User 6!",
1028+
"[TEST] You have 7 days to write a reference for User 6",
10291029
("from when you hosted them", "/leave-reference/hosted/"),
10301030
),
10311031
(
10321032
"user7@couchers.org.invalid",
1033-
"[TEST] You have 14 days to write a reference for User 8!",
1033+
"[TEST] You have 14 days to write a reference for User 8",
10341034
("from when you surfed with them", "/leave-reference/surfed/"),
10351035
),
10361036
(
10371037
"user8@couchers.org.invalid",
1038-
"[TEST] You have 14 days to write a reference for User 7!",
1038+
"[TEST] You have 14 days to write a reference for User 7",
10391039
("from when you hosted them", "/leave-reference/hosted/"),
10401040
),
10411041
]
@@ -1198,8 +1198,8 @@ def test_send_host_request_reminders(db, moderator):
11981198
expected_emails = [
11991199
(
12001200
"user2@couchers.org.invalid",
1201-
"[TEST] You have a pending host request from User 1!",
1202-
("Please respond to the request!", "User 1"),
1201+
"[TEST] You have a pending host request from User 1",
1202+
("User 1", "is waiting for your response"),
12031203
)
12041204
]
12051205

app/backend/src/tests/test_email.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ def test_email_changed_confirmation_sent_to_new_email(db, email_collector: Email
238238
assert user.name in email.html
239239
assert user.email in email.plain
240240
assert user.email in email.html
241-
assert "Your old email address is" in email.plain
242-
assert "Your old email address is" in email.html
241+
assert "You requested that your email be changed from " in email.plain
242+
assert "You requested that your email be changed from " in email.html
243243
assert f"http://localhost:3000/confirm-email?token={confirmation_token}" in email.plain
244244
assert f"http://localhost:3000/confirm-email?token={confirmation_token}" in email.html
245245
assert "support@couchers.org" in email.plain
@@ -401,7 +401,7 @@ def test_send_donation_email(db, monkeypatch):
401401
402402
Thank you so much for your donation of $20 to Couchers.org.
403403
404-
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.
404+
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.
405405
406406
You can download an invoice and receipt for the donation here:
407407
@@ -411,8 +411,6 @@ def test_send_donation_email(db, monkeypatch):
411411
412412
If you have any questions about your donation, please email us at donations@couchers.org.
413413
414-
Your generosity will help deliver the platform for everyone.
415-
416414
Thank you!
417415
418416
Aapeli and Itsi,
@@ -424,7 +422,7 @@ def test_send_donation_email(db, monkeypatch):
424422
"""
425423
)
426424

427-
assert "Thank you so much for your donation of $20 to Couchers.org." in email.html
425+
assert "Thank you so much for your donation of <b>$20</b> to Couchers.org." in email.html
428426
assert email.sender_name == "Couchers.org"
429427
assert email.sender_email == "notify@couchers.org.invalid"
430428
assert email.recipient == "testing@couchers.org.invalid"

app/backend/src/tests/test_jail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def test_modnotes(db, email_collector: EmailCollector, push_collector: PushColle
286286
)
287287

288288
email = email_collector.pop_for_recipient(user.email, last=True)
289-
assert email.subject == "[TEST] You have received a mod note"
289+
assert email.subject == "[TEST] You have received a moderator note"
290290

291291
push = push_collector.pop_for_user(user.id, last=True)
292292
assert push.content.title == "New moderator note"

0 commit comments

Comments
 (0)