default stream: Allows admins to remove any default stream.

This fixes a bug where administrators couldn't remove private
unsubscribed streams from the "default streams" list, because
access_stream_by_name didn't give them access to the stream object.
This commit is contained in:
Yashashvi Dave
2018-08-07 17:43:58 +05:30
committed by Tim Abbott
parent c41c82aae0
commit 6e136be975
3 changed files with 24 additions and 3 deletions

View File

@@ -102,14 +102,16 @@ def check_stream_name_available(realm: Realm, name: str) -> None:
pass
def access_stream_by_name(user_profile: UserProfile,
stream_name: str) -> Tuple[Stream, Recipient, Optional[Subscription]]:
stream_name: str,
allow_realm_admin: bool=False) -> Tuple[Stream, Recipient, Optional[Subscription]]:
error = _("Invalid stream name '%s'" % (stream_name,))
try:
stream = get_realm_stream(stream_name, user_profile.realm_id)
except Stream.DoesNotExist:
raise JsonableError(error)
(recipient, sub) = access_stream_common(user_profile, stream, error)
(recipient, sub) = access_stream_common(user_profile, stream, error,
allow_realm_admin=allow_realm_admin)
return (stream, recipient, sub)
def access_stream_for_unmute_topic(user_profile: UserProfile, stream_name: str, error: str) -> Stream: