From 634cec5ba936b0158afc6b0aa9c19e4a1596b6a0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 10 Apr 2026 14:43:37 +0300 Subject: [PATCH] tomatrix: avoid multipart messages --- pkg/connector/tomatrix.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/connector/tomatrix.go b/pkg/connector/tomatrix.go index 8ef70d00..63121582 100644 --- a/pkg/connector/tomatrix.go +++ b/pkg/connector/tomatrix.go @@ -199,6 +199,11 @@ func (tc *TelegramClient) convertToMatrix( if mediaPart != nil { hasher.Write(mediaHashID) cm.Parts = append(cm.Parts, mediaPart) + // Force stickers into images if there is a caption (usually there shouldn't be) + if mediaPart.Type == event.EventSticker && len(cm.Parts) == 2 { + mediaPart.Type = event.EventMessage + mediaPart.Content.MsgType = event.MsgImage + } cm.MergeCaption() contentURI = mediaPart.Content.URL @@ -252,6 +257,12 @@ func (tc *TelegramClient) convertToMatrix( log.Warn().Type("reply_to", replyTo).Msg("unhandled reply to type") } } + if len(cm.Parts) > 1 { + log.Warn().Int("part_count", len(cm.Parts)).Msg("Message has multiple parts") + for i, part := range cm.Parts[1:] { + part.ID = networkid.PartID(strconv.Itoa(i + 1)) + } + } if ttl, ok := msg.GetTTLPeriod(); ok && disappearingSetting == nil { cm.Disappear = database.DisappearingSetting{