Remove unnecessary get_input_entity calls

This commit is contained in:
Tulir Asokan
2018-02-15 13:14:30 +02:00
parent bed1503383
commit 6615a68cee
3 changed files with 3 additions and 11 deletions
+3 -5
View File
@@ -441,14 +441,13 @@ class Portal:
del self.by_tgid[self.tgid_full]
del self.by_mxid[self.mxid]
elif source and source.tgid != user.tgid:
target = await user.get_input_entity(source)
if self.peer_type == "chat":
await source.client(DeleteChatUserRequest(chat_id=self.tgid, user_id=target))
await source.client(DeleteChatUserRequest(chat_id=self.tgid, user_id=user.tgid))
else:
channel = await self.get_input_entity(source)
rights = ChannelBannedRights(datetime.fromtimestamp(0), True)
await source.client(EditBannedRequest(channel=channel,
user_id=target,
user_id=user.tgid,
banned_rights=rights))
elif self.peer_type == "chat":
await user.client(DeleteChatUserRequest(chat_id=self.tgid, user_id=InputUserSelf()))
@@ -664,8 +663,7 @@ class Portal:
await source.client(
AddChatUserRequest(chat_id=self.tgid, user_id=puppet.tgid, fwd_limit=0))
elif self.peer_type == "channel":
target = await puppet.get_input_entity(source)
await source.client(InviteToChannelRequest(channel=self.peer, users=[target]))
await source.client(InviteToChannelRequest(channel=self.peer, users=[puppet.tgid]))
else:
raise ValueError("Invalid peer type for Telegram user invite")
-3
View File
@@ -51,9 +51,6 @@ class Puppet:
def tgid(self):
return self.id
def get_input_entity(self, user):
return user.client.get_input_entity(PeerUser(user_id=self.tgid))
def to_db(self):
return self.db.merge(
DBPuppet(id=self.id, username=self.username, displayname=self.displayname,
-3
View File
@@ -99,9 +99,6 @@ class User:
else:
self.portals = {}
def get_input_entity(self, user):
return user.client.get_input_entity(InputUser(user_id=self.tgid, access_hash=0))
# region Database conversion
def to_db(self):