From c3dde772743c9c8571fcf7aa1b9493d74b199def Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 7 Sep 2019 15:55:58 +0200 Subject: [PATCH] Fix ChatPhoto failing to parse in case the user is not known yet --- pyrogram/client/types/user_and_chats/chat_photo.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/types/user_and_chats/chat_photo.py b/pyrogram/client/types/user_and_chats/chat_photo.py index 95160447..b19ea771 100644 --- a/pyrogram/client/types/user_and_chats/chat_photo.py +++ b/pyrogram/client/types/user_and_chats/chat_photo.py @@ -20,6 +20,7 @@ from struct import pack import pyrogram from pyrogram.api import types +from pyrogram.errors import PeerIdInvalid from ..object import Object from ...ext.utils import encode @@ -58,7 +59,10 @@ class ChatPhoto(Object): loc_small = chat_photo.photo_small loc_big = chat_photo.photo_big - peer = client.resolve_peer(peer_id) + try: + peer = client.resolve_peer(peer_id) + except PeerIdInvalid: + return None if isinstance(peer, types.InputPeerUser): peer_id = peer.user_id