Skip to content

Commit

Permalink
Add extension to unnamed file names. Fixes mautrix#646
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 20, 2021
1 parent d778c63 commit 3083727
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mautrix_telegram/portal/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,12 @@ async def handle_telegram_document(self, source: 'AbstractUser', intent: IntentA
info["fi.mau.autoplay"] = True
info["fi.mau.hide_controls"] = True
info["fi.mau.no_audio"] = True
if not name:
ext = sane_mimetypes.guess_extension(file.mime_type)
name = "unnamed_file" + ext

content = MediaMessageEventContent(
body=name or "unnamed file", info=info, relates_to=relates_to,
body=name, info=info, relates_to=relates_to,
external_url=self._get_external_url(evt),
msgtype={
"video/": MessageType.VIDEO,
Expand Down

0 comments on commit 3083727

Please sign in to comment.