media: bridge GIFs as documents rather than images

This allows them to be animated.

Closes PLAT-25990

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-08-07 16:25:17 -06:00
parent 83695b4336
commit 497bfb152e
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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,
+1 -1
View File
@@ -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
}