mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
invites: Use expiration time in minutes instead of days.
This commit changes the invite API to accept invitation expiration time in minutes since we are going to add a custom option in further commits which would allow a user to set expiration time in minutes, hours and weeks as well.
This commit is contained in:
@@ -86,10 +86,10 @@ def create_confirmation_link(
|
||||
obj: Union[Realm, HasRealmObject, OptionalHasRealmObject],
|
||||
confirmation_type: int,
|
||||
*,
|
||||
validity_in_days: Union[Optional[int], UnspecifiedValue] = UnspecifiedValue(),
|
||||
validity_in_minutes: Union[Optional[int], UnspecifiedValue] = UnspecifiedValue(),
|
||||
url_args: Mapping[str, str] = {},
|
||||
) -> str:
|
||||
# validity_in_days is an override for the default values which are
|
||||
# validity_in_minutes is an override for the default values which are
|
||||
# determined by the confirmation_type - its main purpose is for use
|
||||
# in tests which may want to have control over the exact expiration time.
|
||||
key = generate_key()
|
||||
@@ -101,12 +101,12 @@ def create_confirmation_link(
|
||||
|
||||
current_time = timezone_now()
|
||||
expiry_date = None
|
||||
if not isinstance(validity_in_days, UnspecifiedValue):
|
||||
if validity_in_days is None:
|
||||
if not isinstance(validity_in_minutes, UnspecifiedValue):
|
||||
if validity_in_minutes is None:
|
||||
expiry_date = None
|
||||
else:
|
||||
assert validity_in_days is not None
|
||||
expiry_date = current_time + datetime.timedelta(days=validity_in_days)
|
||||
assert validity_in_minutes is not None
|
||||
expiry_date = current_time + datetime.timedelta(minutes=validity_in_minutes)
|
||||
else:
|
||||
expiry_date = current_time + datetime.timedelta(
|
||||
days=_properties[confirmation_type].validity_in_days
|
||||
|
Reference in New Issue
Block a user