diff --git a/mautrix_telegram/portal/metadata.py b/mautrix_telegram/portal/metadata.py index a7b6ee45..d45ba2f0 100644 --- a/mautrix_telegram/portal/metadata.py +++ b/mautrix_telegram/portal/metadata.py @@ -747,15 +747,13 @@ class PortalMetadata(BasePortal, ABC): if isinstance(photo, (ChatPhoto, UserProfilePhoto)): loc = InputPeerPhotoFileLocation( peer=await self.get_input_entity(user), - local_id=photo.photo_big.local_id, - volume_id=photo.photo_big.volume_id, + photo_id=photo.photo_id, big=True ) - photo_id = (f"{loc.volume_id}-{loc.local_id}" if isinstance(photo, ChatPhoto) - else photo.photo_id) + photo_id = str(photo.photo_id) elif isinstance(photo, Photo): - loc, largest = self._get_largest_photo_size(photo) - photo_id = f"{largest.location.volume_id}-{largest.location.local_id}" + loc, _ = self._get_largest_photo_size(photo) + photo_id = str(loc.id) elif isinstance(photo, (UserProfilePhotoEmpty, ChatPhotoEmpty, PhotoEmpty, type(None))): photo_id = "" loc = None diff --git a/mautrix_telegram/puppet.py b/mautrix_telegram/puppet.py index d214faa0..9ebe92ef 100644 --- a/mautrix_telegram/puppet.py +++ b/mautrix_telegram/puppet.py @@ -344,8 +344,7 @@ class Puppet(BasePuppet): loc = InputPeerPhotoFileLocation( peer=await self.get_input_entity(source), - local_id=photo.photo_big.local_id, - volume_id=photo.photo_big.volume_id, + photo_id=photo.photo_id, big=True ) file = await util.transfer_file_to_matrix(source.client, self.default_mxid_intent, loc) diff --git a/mautrix_telegram/util/file_transfer.py b/mautrix_telegram/util/file_transfer.py index 572ea559..2ba76271 100644 --- a/mautrix_telegram/util/file_transfer.py +++ b/mautrix_telegram/util/file_transfer.py @@ -102,8 +102,10 @@ def _location_to_id(location: TypeLocation) -> str: return f"{location.id}-{location.access_hash}" elif isinstance(location, (InputDocumentFileLocation, InputPhotoFileLocation)): return f"{location.id}-{location.access_hash}-{location.thumb_size}" - elif isinstance(location, (InputFileLocation, InputPeerPhotoFileLocation)): + elif isinstance(location, InputFileLocation): return f"{location.volume_id}-{location.local_id}" + elif isinstance(location, InputPeerPhotoFileLocation): + return str(location.photo_id) async def transfer_thumbnail_to_matrix(client: MautrixTelegramClient, intent: IntentAPI, diff --git a/requirements.txt b/requirements.txt index 446589d8..3e5d9e46 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,5 @@ commonmark>=0.8,<0.10 aiohttp>=3,<4 yarl>=1,<2 mautrix>=0.9.7,<0.10 -telethon>=1.20,<1.22 +telethon>=1.22,<1.23 telethon-session-sqlalchemy>=0.2.14,<0.3