mirror of https://github.com/zulip/zulip.git
confirmation: Allow using used confirmation objects if required.
This commit is contained in:
parent
1f1beb1452
commit
1253686287
|
@ -81,7 +81,11 @@ ConfirmationObjT: TypeAlias = NoZilencerConfirmationObjT | ZilencerConfirmationO
|
|||
|
||||
|
||||
def get_object_from_key(
|
||||
confirmation_key: str, confirmation_types: list[int], *, mark_object_used: bool
|
||||
confirmation_key: str,
|
||||
confirmation_types: list[int],
|
||||
*,
|
||||
mark_object_used: bool,
|
||||
allow_used: bool = False,
|
||||
) -> ConfirmationObjT:
|
||||
"""Access a confirmation object from one of the provided confirmation
|
||||
types with the provided key.
|
||||
|
@ -109,6 +113,9 @@ def get_object_from_key(
|
|||
assert obj is not None
|
||||
|
||||
used_value = confirmation_settings.STATUS_USED
|
||||
if allow_used and obj.status == used_value:
|
||||
return obj
|
||||
|
||||
revoked_value = confirmation_settings.STATUS_REVOKED
|
||||
if hasattr(obj, "status") and obj.status in [used_value, revoked_value]:
|
||||
# Confirmations where the object has the status attribute are one-time use
|
||||
|
|
Loading…
Reference in New Issue