diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 880d3c49..fcb17289 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1221,6 +1221,7 @@ class Client(Methods, BaseClient): access_hash=data.access_hash, thumb_size=data.thumb_size, peer_id=data.peer_id, + peer_type=data.peer_type, peer_access_hash=data.peer_access_hash, volume_id=data.volume_id, local_id=data.local_id, @@ -1866,6 +1867,7 @@ class Client(Methods, BaseClient): access_hash: int, thumb_size: str, peer_id: int, + peer_type: str, peer_access_hash: int, volume_id: int, local_id: int, @@ -1913,11 +1915,23 @@ class Client(Methods, BaseClient): file_ref = utils.decode_file_ref(file_ref) if media_type == 1: - location = types.InputPeerPhotoFileLocation( - peer=types.InputPeerUser( + if peer_type == "user": + peer = types.InputPeerUser( user_id=peer_id, access_hash=peer_access_hash - ), + ) + elif peer_type == "chat": + peer = types.InputPeerChat( + chat_id=peer_id + ) + else: + peer = types.InputPeerChannel( + channel_id=peer_id, + access_hash=peer_access_hash + ) + + location = types.InputPeerPhotoFileLocation( + peer=peer, volume_id=volume_id, local_id=local_id, big=is_big or None diff --git a/pyrogram/client/ext/file_data.py b/pyrogram/client/ext/file_data.py index ae023d18..94c90329 100644 --- a/pyrogram/client/ext/file_data.py +++ b/pyrogram/client/ext/file_data.py @@ -20,9 +20,9 @@ class FileData: def __init__( self, *, media_type: int = None, dc_id: int = None, document_id: int = None, access_hash: int = None, - thumb_size: str = None, peer_id: int = None, peer_access_hash: int = None, volume_id: int = None, - local_id: int = None, is_big: bool = None, file_size: int = None, mime_type: str = None, file_name: str = None, - date: int = None, file_ref: str = None + thumb_size: str = None, peer_id: int = None, peer_type: str = None, peer_access_hash: int = None, + volume_id: int = None, local_id: int = None, is_big: bool = None, file_size: int = None, mime_type: str = None, + file_name: str = None, date: int = None, file_ref: str = None ): self.media_type = media_type self.dc_id = dc_id @@ -30,6 +30,7 @@ class FileData: self.access_hash = access_hash self.thumb_size = thumb_size self.peer_id = peer_id + self.peer_type = peer_type self.peer_access_hash = peer_access_hash self.volume_id = volume_id self.local_id = local_id diff --git a/pyrogram/client/methods/messages/download_media.py b/pyrogram/client/methods/messages/download_media.py index 053e0155..c0e48823 100644 --- a/pyrogram/client/methods/messages/download_media.py +++ b/pyrogram/client/methods/messages/download_media.py @@ -146,13 +146,23 @@ class DownloadMedia(BaseClient): if media_type == 1: unpacked = struct.unpack("