Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Update resendoauthverifications command with corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
sarayourfriend committed Jun 30, 2022
1 parent 7208531 commit 8e2d161
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 10 additions & 6 deletions api/catalog/management/commands/resendoauthverification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""


Expand All @@ -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(
Expand Down Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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
)

Expand Down

0 comments on commit 8e2d161

Please sign in to comment.