tomatrix: use extra field in info for custom fields

This commit is contained in:
Tulir Asokan
2026-04-23 14:51:33 +03:00
parent 65fcf712d3
commit 6eacf38d74
2 changed files with 14 additions and 11 deletions
+5
View File
@@ -197,6 +197,11 @@ func (t *Transferer) WithVideo(attr *tg.DocumentAttributeVideo) *Transferer {
return t
}
func (t *Transferer) WithAudio(attr *tg.DocumentAttributeAudio) *Transferer {
t.fileInfo.Duration = attr.Duration * 1000
return t
}
func (t *Transferer) WithImageSize(attr *tg.DocumentAttributeImageSize) *Transferer {
t.fileInfo.Width, t.fileInfo.Height = attr.W, attr.H
t.adjustStickerSize()
+9 -11
View File
@@ -584,11 +584,10 @@ func (tc *TelegramClient) convertMediaRequiringUpload(
if a.RoundMessage {
extraInfo["fi.mau.telegram.round_message"] = a.RoundMessage
}
extraInfo["duration"] = int(a.Duration * 1000)
case *tg.DocumentAttributeAudio:
if content.MsgType != event.MsgVideo {
content.MsgType = event.MsgAudio
extraInfo["duration"] = int(a.Duration * 1000) // only set the duration is not already set by the video handling logic
transferer = transferer.WithAudio(a) // only set the duration is not already set by the video handling logic
}
content.MSC1767Audio = &event.MSC1767Audio{
Duration: a.Duration * 1000,
@@ -663,14 +662,6 @@ func (tc *TelegramClient) convertMediaRequiringUpload(
}
}
if isVideoGif {
extraInfo["fi.mau.gif"] = true
extraInfo["fi.mau.loop"] = true
extraInfo["fi.mau.autoplay"] = true
extraInfo["fi.mau.hide_controls"] = true
extraInfo["fi.mau.no_audio"] = true
}
if _, ok := document.GetThumbs(); ok && eventType != event.EventSticker {
var thumbnailURL id.ContentURIString
var thumbnailFile *event.EncryptedFileInfo
@@ -752,6 +743,13 @@ func (tc *TelegramClient) convertMediaRequiringUpload(
content.FileName = content.FileName + exmime.ExtensionFromMimetype(content.Info.MimeType)
}
}
if isVideoGif {
content.Info.MauGIF = true
extraInfo["fi.mau.loop"] = true
extraInfo["fi.mau.autoplay"] = true
extraInfo["fi.mau.hide_controls"] = true
extraInfo["fi.mau.no_audio"] = true
}
// Handle spoilers
// See: https://github.com/matrix-org/matrix-spec-proposals/pull/3725
@@ -763,7 +761,7 @@ func (tc *TelegramClient) convertMediaRequiringUpload(
extraInfo["fi.mau.telegram.spoiler"] = true
}
if len(extraInfo) > 0 {
extra["info"] = extraInfo
content.Info.Extra = extraInfo
}
converted = &bridgev2.ConvertedMessagePart{