From 0988de12671662163ca906e67b90295caae2ffd0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 10 Apr 2026 20:18:03 +0300 Subject: [PATCH] tomatrix: consistently add extensions for all files --- pkg/connector/tomatrix.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/connector/tomatrix.go b/pkg/connector/tomatrix.go index 8452f955..65c67b25 100644 --- a/pkg/connector/tomatrix.go +++ b/pkg/connector/tomatrix.go @@ -632,7 +632,7 @@ func (tc *TelegramClient) convertMediaRequiringUpload( if content.Body != "" { content.FileName = content.Body } else { - content.Body = "file" + exmime.ExtensionFromMimetype(content.Info.MimeType) + content.Body = "document" } } @@ -731,8 +731,13 @@ func (tc *TelegramClient) convertMediaRequiringUpload( return } } - if _, isPhoto := msgMedia.(*tg.MessageMediaPhoto); isPhoto { - content.Body = content.Body + exmime.ExtensionFromMimetype(content.Info.MimeType) + if eventType != event.EventSticker && content.MsgType.IsMedia() { + if (content.FileName == "" || content.FileName == content.Body) && !strings.ContainsRune(content.Body, '.') { + content.Body = content.Body + exmime.ExtensionFromMimetype(content.Info.MimeType) + content.FileName = content.Body + } else if content.FileName != content.Body && content.FileName != "" && !strings.ContainsRune(content.FileName, '.') { + content.FileName = content.FileName + exmime.ExtensionFromMimetype(content.Info.MimeType) + } } // Handle spoilers