Remove client-side checks when editing permissions

The server should instead fail with proper RPC errors,
as the rules could change any time (and the local checks
get out of date).
This commit is contained in:
Lonami Exo 2023-07-21 22:53:38 +02:00
parent 816b0bdf9f
commit a0cda0c37c

View File

@ -926,9 +926,6 @@ class ChatMethods:
""" """
entity = await self.get_input_entity(entity) entity = await self.get_input_entity(entity)
user = await self.get_input_entity(user) user = await self.get_input_entity(user)
ty = helpers._entity_type(user)
if ty != helpers._EntityType.USER:
raise ValueError('You must pass a user entity')
perm_names = ( perm_names = (
'change_info', 'post_messages', 'edit_messages', 'delete_messages', 'change_info', 'post_messages', 'edit_messages', 'delete_messages',
@ -1115,12 +1112,6 @@ class ChatMethods:
)) ))
user = await self.get_input_entity(user) user = await self.get_input_entity(user)
ty = helpers._entity_type(user)
if ty not in (helpers._EntityType.USER, helpers._EntityType.CHANNEL):
raise ValueError('You must pass a user or channel entity')
if isinstance(user, types.InputPeerSelf):
raise ValueError('You cannot restrict yourself')
return await self(functions.channels.EditBannedRequest( return await self(functions.channels.EditBannedRequest(
channel=entity, channel=entity,
@ -1167,8 +1158,6 @@ class ChatMethods:
""" """
entity = await self.get_input_entity(entity) entity = await self.get_input_entity(entity)
user = await self.get_input_entity(user) user = await self.get_input_entity(user)
if helpers._entity_type(user) != helpers._EntityType.USER:
raise ValueError('You must pass a user entity')
ty = helpers._entity_type(entity) ty = helpers._entity_type(entity)
if ty == helpers._EntityType.CHAT: if ty == helpers._EntityType.CHAT:
@ -1245,8 +1234,6 @@ class ChatMethods:
entity = await self.get_input_entity(entity) entity = await self.get_input_entity(entity)
user = await self.get_input_entity(user) user = await self.get_input_entity(user)
if helpers._entity_type(user) != helpers._EntityType.USER:
raise ValueError('You must pass a user entity')
if helpers._entity_type(entity) == helpers._EntityType.CHANNEL: if helpers._entity_type(entity) == helpers._EntityType.CHANNEL:
participant = await self(functions.channels.GetParticipantRequest( participant = await self(functions.channels.GetParticipantRequest(
entity, entity,