diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index 49ee6a080e..1212928596 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -485,8 +485,7 @@ class StreamAdminTest(ZulipTestCase): "privstream", subscribed=False, invite_only=True) result = self.client_delete('/json/streams/' + str(priv_stream.id)) - self.assert_json_error( - result, "Cannot administer invite-only streams this way") + self.assert_json_error(result, "Invalid stream id") def attempt_unsubscribe_of_principal(self, is_admin=False, is_subbed=True, invite_only=False, other_user_subbed=True): diff --git a/zerver/views/streams.py b/zerver/views/streams.py index de0945392b..a09a5e7df4 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -135,12 +135,8 @@ def principal_to_user_profile(agent, principal): @require_realm_admin def deactivate_stream_backend(request, user_profile, stream_id): # type: (HttpRequest, UserProfile, int) -> HttpResponse - target = get_and_validate_stream_by_id(stream_id, user_profile.realm) - - if target.invite_only and not subscribed_to_stream(user_profile, target): - return json_error(_('Cannot administer invite-only streams this way')) - - do_deactivate_stream(target) + (stream, recipient, sub) = access_stream_by_id(user_profile, stream_id) + do_deactivate_stream(stream) return json_success() @require_realm_admin