From 497bfb152ea05853b354f4b613a829cca521d682 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Wed, 7 Aug 2024 16:25:17 -0600 Subject: [PATCH] media: bridge GIFs as documents rather than images This allows them to be animated. Closes PLAT-25990 Signed-off-by: Sumner Evans --- pkg/connector/matrix.go | 4 ++-- pkg/connector/matrixfmt/convert.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/connector/matrix.go b/pkg/connector/matrix.go index 18a9e9bd..52dd1405 100644 --- a/pkg/connector/matrix.go +++ b/pkg/connector/matrix.go @@ -49,7 +49,7 @@ func (t *TelegramClient) transferMediaToTelegram(ctx context.Context, content *e return nil, fmt.Errorf("failed to upload media to Telegram: %w", err) } - if content.MsgType == event.MsgImage { + if content.MsgType == event.MsgImage && (content.Info.MimeType == "image/jpeg" || content.Info.MimeType == "image/png") { return &tg.InputMediaUploadedPhoto{File: upload}, nil } @@ -100,7 +100,7 @@ func (t *TelegramClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2. var updates tg.UpdatesClass switch msg.Content.MsgType { - case event.MsgText, event.MsgNotice: + case event.MsgText, event.MsgNotice, event.MsgEmote: updates, err = t.client.API().MessagesSendMessage(ctx, &tg.MessagesSendMessageRequest{ Peer: peer, NoWebpage: noWebpage, diff --git a/pkg/connector/matrixfmt/convert.go b/pkg/connector/matrixfmt/convert.go index 5465222e..e3d82f48 100644 --- a/pkg/connector/matrixfmt/convert.go +++ b/pkg/connector/matrixfmt/convert.go @@ -82,7 +82,7 @@ func toTelegramEntity(br telegramfmt.BodyRange) tg.MessageEntityClass { } func Parse(ctx context.Context, parser *HTMLParser, content *event.MessageEventContent) (string, []tg.MessageEntityClass) { - if content.MsgType.IsMedia() && content.FileName == "" { + if content.MsgType.IsMedia() && (content.FileName == "" || content.FileName == content.Body) { // The body is the filename. return "", nil }