mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	streams: Raise same error for all values of invite_to_stream_policy.
We keep the error message same for all cases when a user is not allowed to subscribe others for all values of invite_to_stream_policy. We raise error with different message for guest cases because it is handled by decorators. We aim to change this behavior in future. Explaining the details in error message isn't much important as we do not show errors probably in API only, as we do not the show the options itself in the frontend.
This commit is contained in:
		@@ -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
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user