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.

streams: Change access_stream_for_delete_or_update to also return sub.

sahil8394e8f5b5b313b
diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py
index 0ea68491ec3..d4ad60caabd 100644
--- a/zerver/lib/streams.py
+++ b/zerver/lib/streams.py
@@ -250,7 +250,8 @@ def check_stream_access_for_delete_or_update(user_profile: UserProfile, stream:
raise StreamAdministratorRequired()
-def access_stream_for_delete_or_update(user_profile: UserProfile, stream_id: int) -> Stream:
+def access_stream_for_delete_or_update(user_profile: UserProfile,
+ stream_id: int) -> Tuple[Stream, Optional[Subscription]]:
try:
stream = Stream.objects.get(id=stream_id)
except Stream.DoesNotExist:
@@ -264,7 +265,7 @@ def access_stream_for_delete_or_update(user_profile: UserProfile, stream_id: int
sub = None
check_stream_access_for_delete_or_update(user_profile, stream, sub)
- return stream
+ return (stream, sub)
# Only set allow_realm_admin flag to True when you want to allow realm admin to
# access unsubscribed private stream content.
diff --git a/zerver/views/streams.py b/zerver/views/streams.py
index 7022cf42fcf..d39ff07f5c0 100644
--- a/zerver/views/streams.py
+++ b/zerver/views/streams.py
@@ -143,7 +143,7 @@ def check_if_removing_someone_else(user_profile: UserProfile,
def deactivate_stream_backend(request: HttpRequest,
user_profile: UserProfile,
stream_id: int) -> HttpResponse:
- stream = access_stream_for_delete_or_update(user_profile, stream_id)
+ (stream, sub) = access_stream_for_delete_or_update(user_profile, stream_id)
do_deactivate_stream(stream, acting_user=user_profile)
return json_success()
@@ -241,7 +241,7 @@ def update_stream_backend(
) -> HttpResponse:
# We allow realm administrators to to update the stream name and
# description even for private streams.
- stream = access_stream_for_delete_or_update(user_profile, stream_id)
+ (stream, sub) = access_stream_for_delete_or_update(user_profile, stream_id)
if message_retention_days is not None:
if not user_profile.is_realm_owner: