mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
streams: Add API for changing stream-level message_retention_days.
This commit adds backend support for setting message_retention_days while creating streams and updating it for an existing stream. We only allow organization owners to set/update it for a stream. 'message_retention_days' field for a stream existed previously also, but there was no way to set it while creating streams or update it for an exisiting streams using any endpoint.
This commit is contained in:
@@ -3613,6 +3613,20 @@ def do_change_stream_description(stream: Stream, new_description: str) -> None:
|
||||
)
|
||||
send_event(stream.realm, event, can_access_stream_user_ids(stream))
|
||||
|
||||
def do_change_stream_message_retention_days(stream: Stream, message_retention_days: Optional[int]=None) -> None:
|
||||
stream.message_retention_days = message_retention_days
|
||||
stream.save(update_fields=['message_retention_days'])
|
||||
|
||||
event = dict(
|
||||
op="update",
|
||||
type="stream",
|
||||
property="message_retention_days",
|
||||
value=message_retention_days,
|
||||
stream_id=stream.id,
|
||||
name=stream.name,
|
||||
)
|
||||
send_event(stream.realm, event, can_access_stream_user_ids(stream))
|
||||
|
||||
def do_create_realm(string_id: str, name: str,
|
||||
emails_restricted_to_domains: Optional[bool]=None) -> Realm:
|
||||
if Realm.objects.filter(string_id=string_id).exists():
|
||||
|
||||
Reference in New Issue
Block a user