From 0a75480444788d2659d8f4fc6e4eb8ebe0524ab2 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sun, 29 Jan 2017 18:42:41 -0800 Subject: [PATCH] do_make_stream_public: Accept a stream object, not a name. --- zerver/lib/actions.py | 13 ++----------- zerver/views/streams.py | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 642cc5693d..e92a8d3026 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -2052,17 +2052,8 @@ def do_change_bot_type(user_profile, value): user_profile.bot_type = value user_profile.save(update_fields=["bot_type"]) -def do_make_stream_public(user_profile, realm, stream_name): - # type: (UserProfile, Realm, Text) -> None - stream_name = stream_name.strip() - stream = get_stream(stream_name, realm) - - if not stream: - raise JsonableError(_('Unknown stream "%s"') % (stream_name,)) - - if not subscribed_to_stream(user_profile, stream): - raise JsonableError(_('You are not invited to this stream.')) - +def do_make_stream_public(realm, stream): + # type: (Realm, Stream) -> None stream.invite_only = False stream.save(update_fields=['invite_only']) diff --git a/zerver/views/streams.py b/zerver/views/streams.py index 479e50a236..6f787f9dca 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -100,7 +100,7 @@ def update_stream_backend(request, user_profile, stream_id, if is_private: do_make_stream_private(user_profile.realm, stream.name) else: - do_make_stream_public(user_profile, user_profile.realm, stream.name) + do_make_stream_public(user_profile.realm, stream) return json_success() def list_subscriptions_backend(request, user_profile):