mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	streams: Use can_administer_channel_group for checking permissions.
We're not using OrganizationAdministratorRequiredError anymore and the new error message will be `Insufficient Permission`.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							4b3d1a5aac
						
					
				
				
					commit
					75d994f5b4
				
			@@ -9,9 +9,9 @@ from django.utils.translation import gettext as _
 | 
			
		||||
 | 
			
		||||
from zerver.lib.default_streams import get_default_stream_ids_for_realm
 | 
			
		||||
from zerver.lib.exceptions import (
 | 
			
		||||
    CannotAdministerChannelError,
 | 
			
		||||
    IncompatibleParametersError,
 | 
			
		||||
    JsonableError,
 | 
			
		||||
    OrganizationAdministratorRequiredError,
 | 
			
		||||
    OrganizationOwnerRequiredError,
 | 
			
		||||
)
 | 
			
		||||
from zerver.lib.markdown import markdown_convert
 | 
			
		||||
@@ -430,7 +430,10 @@ def check_stream_access_for_delete_or_update(
 | 
			
		||||
    if sub is None and stream.invite_only:
 | 
			
		||||
        raise JsonableError(error)
 | 
			
		||||
 | 
			
		||||
    raise OrganizationAdministratorRequiredError
 | 
			
		||||
    if can_administer_channel(stream, user_profile):
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    raise CannotAdministerChannelError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def access_stream_for_delete_or_update(
 | 
			
		||||
@@ -737,6 +740,16 @@ def can_remove_subscribers_from_stream(
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def can_administer_channel(channel: Stream, user_profile: UserProfile) -> bool:
 | 
			
		||||
    group_allowed_to_administer_channel = channel.can_administer_channel_group
 | 
			
		||||
    assert group_allowed_to_administer_channel is not None
 | 
			
		||||
    return user_has_permission_for_group_setting(
 | 
			
		||||
        group_allowed_to_administer_channel,
 | 
			
		||||
        user_profile,
 | 
			
		||||
        Stream.stream_permission_group_settings["can_administer_channel_group"],
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def filter_stream_authorization(
 | 
			
		||||
    user_profile: UserProfile, streams: Collection[Stream]
 | 
			
		||||
) -> tuple[list[Stream], list[Stream]]:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user