Fix weird mime type bug in alpine/magic

This commit is contained in:
Tulir Asokan
2019-10-03 10:57:52 +03:00
parent 9694fb901a
commit d2edf12fdf
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -178,7 +178,7 @@ bridge:
args:
width: 256
height: 256
background: "ffffff"
background: "020202"
# Whether to bridge Telegram bot messages as m.notices or m.texts.
bot_messages_as_notices: true
+4 -1
View File
@@ -202,7 +202,10 @@ async def _unlocked_transfer_file_to_matrix(client: MautrixTelegramClient, inten
mime_type = magic.from_buffer(file, mime=True)
image_converted = False
if mime_type == "application/gzip" and is_sticker and tgs_convert:
# A weird bug in alpine/magic makes it return application/octet-stream for gzips...
if is_sticker and tgs_convert and (mime_type == "application/gzip" or (
mime_type == "application/octet-stream"
and magic.from_buffer(file).startswith("gzip"))):
mime_type, file, width, height, thumbnail = await convert_tgs_to(
file, tgs_convert["target"], **tgs_convert["args"])
image_converted = mime_type != "application/gzip"