Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Raise same error for all values of invite_to_stream_policy.
sahil83939c9845cb03d
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.pyindex d23ee21d4fa..a018bc4ec88 100644--- a/zerver/tests/test_subs.py+++ b/zerver/tests/test_subs.py@@ -1838,9 +1838,7 @@ class StreamAdminTest(ZulipTestCase):{"principals": orjson.dumps([cordelia_user_id]).decode()},allow_fail=True,)- self.assert_json_error(- result, "Your account is too new to modify other users' subscriptions."- )+ self.assert_json_error(result, "Insufficient permission")# Anyone can invite users..do_set_realm_property(hamlet_user.realm, "waiting_period_threshold", 0, acting_user=None)@@ -3344,7 +3342,7 @@ class SubscriptionAPITest(ZulipTestCase):{"principals": orjson.dumps([invitee_user_id]).decode()},allow_fail=True,)- self.assert_json_error(result, "Only administrators can modify other users' subscriptions.")+ self.assert_json_error(result, "Insufficient permission")do_change_user_role(self.test_user, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)self.common_subscribe_to_streams(@@ -3364,9 +3362,7 @@ class SubscriptionAPITest(ZulipTestCase):{"principals": orjson.dumps([invitee_user_id]).decode()},allow_fail=True,)- self.assert_json_error(- result, "Only administrators and moderators can modify other users' subscriptions."- )+ self.assert_json_error(result, "Insufficient permission")do_change_user_role(self.test_user, UserProfile.ROLE_MODERATOR, acting_user=None)self.common_subscribe_to_streams(@@ -3407,9 +3403,7 @@ class SubscriptionAPITest(ZulipTestCase):{"principals": orjson.dumps([invitee_user_id]).decode()},allow_fail=True,)- self.assert_json_error(- result, "Your account is too new to modify other users' subscriptions."- )+ self.assert_json_error(result, "Insufficient permission")do_set_realm_property(realm, "waiting_period_threshold", 0, acting_user=None)self.common_subscribe_to_streams(diff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex 37d06fdd17d..b6d3aad090e 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -512,19 +512,9 @@ def add_subscriptions_backend(_("You can only invite other Zephyr mirroring users to private streams."))if not user_profile.can_subscribe_other_users():- if user_profile.realm.invite_to_stream_policy == Realm.POLICY_ADMINS_ONLY:- return json_error(_("Only administrators can modify other users' subscriptions."))- if user_profile.realm.invite_to_stream_policy == Realm.POLICY_MODERATORS_ONLY:- return json_error(- _("Only administrators and moderators can modify other users' subscriptions.")- )- # Realm.POLICY_MEMBERS_ONLY only fails if the- # user is a guest, which happens in the decorator above.- if user_profile.realm.invite_to_stream_policy == Realm.POLICY_FULL_MEMBERS_ONLY:- return json_error(- _("Your account is too new to modify other users' subscriptions.")- )- raise AssertionError("Unexpected policy validation failure")+ # Guest users case will not be handled here as it will+ # be handled by the decorator above.+ raise JsonableError(_("Insufficient permission"))subscribers = {principal_to_user_profile(user_profile, principal) for principal in principals}