From 333c906ac304e6df8369cf1983da1ca5692816f0 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 26 Feb 2018 15:44:08 +0100 Subject: [PATCH] Always fetch peers (when applicable) --- pyrogram/client/client.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index cf21d754..681ab8b1 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -546,7 +546,12 @@ class Client: Raises: :class:`pyrogram.Error` """ - return self.session.send(data) + r = self.session.send(data) + + self.fetch_peers(getattr(r, "users", [])) + self.fetch_peers(getattr(r, "chats", [])) + + return r def authorize(self): phone_number_invalid_raises = self.phone_number is not None @@ -772,9 +777,6 @@ class Client: def get_dialogs(self): def parse_dialogs(d): - self.fetch_peers(d.chats) - self.fetch_peers(d.users) - for m in reversed(d.messages): if isinstance(m, types.MessageEmpty): continue @@ -2513,8 +2515,6 @@ class Client: ) ) - self.fetch_peers(imported_contacts.users) - return imported_contacts def delete_contacts(self, ids: list): @@ -2559,6 +2559,5 @@ class Client: else: if isinstance(contacts, types.contacts.Contacts): log.info("Contacts count: {}".format(len(contacts.users))) - self.fetch_peers(contacts.users) return contacts