Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

get_object_from_key: Make mark_object_used an obligatory kwarg.

Mateusz Manderaf787ddc7d222
diff --git a/confirmation/models.py b/confirmation/models.py
index ed22f978091..add4fcec32f 100644
--- a/confirmation/models.py
+++ b/confirmation/models.py
@@ -50,7 +50,7 @@ ConfirmationObjT = Union[MultiuseInvite, PreregistrationUser, EmailChangeStatus,
def get_object_from_key(
- confirmation_key: str, confirmation_types: List[int], mark_object_used: bool = True
+ confirmation_key: str, confirmation_types: List[int], *, mark_object_used: bool
) -> ConfirmationObjT:
"""Access a confirmation object from one of the provided confirmation
types with the provided key.
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
index 67fe4d4ff55..20454f19230 100644
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -2123,7 +2123,7 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
# Mainly a test of get_object_from_key, rather than of the invitation pathway
with self.assertRaises(ConfirmationKeyException) as cm:
- get_object_from_key(registration_key, [Confirmation.INVITATION])
+ get_object_from_key(registration_key, [Confirmation.INVITATION], mark_object_used=True)
self.assertEqual(cm.exception.error_type, ConfirmationKeyException.DOES_NOT_EXIST)
# Verify that using the wrong type doesn't work in the main confirm code path
diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py
index d526d541f14..e12e9af1a2d 100644
--- a/zerver/views/user_settings.py
+++ b/zerver/views/user_settings.py
@@ -62,7 +62,9 @@ AVATAR_CHANGES_DISABLED_ERROR = gettext_lazy("Avatar changes are disabled in thi
def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpResponse:
try:
- email_change_object = get_object_from_key(confirmation_key, [Confirmation.EMAIL_CHANGE])
+ email_change_object = get_object_from_key(
+ confirmation_key, [Confirmation.EMAIL_CHANGE], mark_object_used=True
+ )
except ConfirmationKeyException as exception:
return render_confirmation_key_error(request, exception)