Update Telethon and strip empty entities when sending to Telegram

This commit is contained in:
Tulir Asokan
2022-08-02 13:46:06 +03:00
parent bea9bc4ec0
commit 473ab17fe7
4 changed files with 19 additions and 10 deletions
+6 -2
View File
@@ -125,9 +125,9 @@ def _read_video_thumbnail(
def _location_to_id(location: TypeLocation) -> str:
if isinstance(location, Document):
return f"{location.id}-{location.access_hash}"
return str(location.id)
elif isinstance(location, (InputDocumentFileLocation, InputPhotoFileLocation)):
return f"{location.id}-{location.access_hash}-{location.thumb_size}"
return f"{location.id}-{location.thumb_size}"
elif isinstance(location, InputFileLocation):
return f"{location.volume_id}-{location.local_id}"
elif isinstance(location, InputPeerPhotoFileLocation):
@@ -155,6 +155,8 @@ async def transfer_thumbnail_to_matrix(
if custom_data:
loc_id += "-mau_custom_thumbnail"
if encrypt:
loc_id += "-encrypted"
db_file = await DBTelegramFile.get(loc_id)
if db_file:
@@ -226,6 +228,8 @@ async def transfer_file_to_matrix(
location_id = _location_to_id(location)
if not location_id:
return None
if encrypt:
location_id += "-encrypted"
db_file = await DBTelegramFile.get(location_id)
if db_file: