From a0cda0c37c229b5b2058839e689ae06f98c4e157 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 21 Jul 2023 22:53:38 +0200 Subject: [PATCH] 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). --- telethon/client/chats.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/telethon/client/chats.py b/telethon/client/chats.py index d3843833..64f60d5d 100644 --- a/telethon/client/chats.py +++ b/telethon/client/chats.py @@ -926,9 +926,6 @@ class ChatMethods: """ entity = await self.get_input_entity(entity) 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 = ( 'change_info', 'post_messages', 'edit_messages', 'delete_messages', @@ -1115,12 +1112,6 @@ class ChatMethods: )) 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( channel=entity, @@ -1167,8 +1158,6 @@ class ChatMethods: """ entity = await self.get_input_entity(entity) 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) if ty == helpers._EntityType.CHAT: @@ -1245,8 +1234,6 @@ class ChatMethods: entity = await self.get_input_entity(entity) 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: participant = await self(functions.channels.GetParticipantRequest( entity,