From 8e2d1615ada2874a8592e535b525adfbf565274c Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Thu, 30 Jun 2022 16:01:29 +1000 Subject: [PATCH] Update resendoauthverifications command with corrections --- .../commands/resendoauthverification.py | 16 ++++++++++------ .../commands/resendoauthverification_test.py | 8 ++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/api/catalog/management/commands/resendoauthverification.py b/api/catalog/management/commands/resendoauthverification.py index 23dfc6beb..e0b477082 100644 --- a/api/catalog/management/commands/resendoauthverification.py +++ b/api/catalog/management/commands/resendoauthverification.py @@ -32,7 +32,10 @@ def get_input(text): {link} -If you believe you received this message in error, please disregard it. +We previously sent this message with an incorrectly formatted link. +Apologies for the repeated contacts. If you believe you received this +message in error or have already successfully verified your OAuth +application, please disregard it. """ @@ -47,14 +50,15 @@ class Result: class Command(BaseCommand): help = "Resends verification emails for unverified Oauth applications." """ - This command is meant to be used a single time in production to remediate - failed email sending. + This command sends a corrected oauth verification email to users who have + not yet verified their Openverse oauth applications. A previous version sent + an email with an incorrectly formatted link. It stores a cache of successfully sent emails in Redis, so running it multiple times (in case of failure) should not be an issue. """ - processed_key = "resendoauthverification:processed" + processed_key = "resendoauthverification-corrections:processed" def add_arguments(self, parser): parser.add_argument( @@ -123,11 +127,11 @@ def _handle_email(self, email, dry): # We don't have access to `request.build_absolute_uri` so we # have to build it ourselves for the production endpoint link = ( - f"https://api.openverse.engineering/{reverse('verify-email', [token])}" + f"https://api.openverse.engineering{reverse('verify-email', [token])}" ) verification_msg = verification_msg_template.format(link=link) send_mail( - subject="Verify your API credentials", + subject="Verify your API credentials (corrected)", message=verification_msg, from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=[verification.email], diff --git a/api/test/unit/management/commands/resendoauthverification_test.py b/api/test/unit/management/commands/resendoauthverification_test.py index 8447dc05d..94ace128c 100644 --- a/api/test/unit/management/commands/resendoauthverification_test.py +++ b/api/test/unit/management/commands/resendoauthverification_test.py @@ -266,7 +266,9 @@ def test_should_not_count_email_as_sent_if_failed_and_rollback( ) assert ( - redis.sismember("resendoauthverification:processed", keep.registration.email) + redis.sismember( + "resendoauthverification-corrections:processed", keep.registration.email + ) is False ) @@ -300,7 +302,9 @@ def test_should_not_delete_or_send_if_dry_run(cleanable_email, captured_emails, ) assert ( - redis.sismember("resendoauthverification:processed", keep.registration.email) + redis.sismember( + "resendoauthverification-corrections:processed", keep.registration.email + ) is False )