From 11a832c5756b98e2d2d2c8ee0f49709feda5cf1a Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Wed, 6 Nov 2024 04:20:07 -0700 Subject: [PATCH] connector/matrix: fix sending media Signed-off-by: Sumner Evans --- go.mod | 2 +- go.sum | 4 ++-- pkg/connector/matrix.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index bac4f6e5..7669ebf6 100644 --- a/go.mod +++ b/go.mod @@ -59,4 +59,4 @@ require ( rsc.io/qr v0.2.0 // indirect ) -replace github.com/gotd/td => github.com/beeper/td v0.107.1-0.20241105085527-43c440667847 +replace github.com/gotd/td => github.com/beeper/td v0.107.1-0.20241106111429-3af6811c898b diff --git a/go.sum b/go.sum index e4b565e2..ad9feefa 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= -github.com/beeper/td v0.107.1-0.20241105085527-43c440667847 h1:bFdMWw/YK+1hsZ6X3wWynTkCS1LAeF+C70h4/EbPHRY= -github.com/beeper/td v0.107.1-0.20241105085527-43c440667847/go.mod h1:zzgUtTDJD4TVaCpKfCD0rxazQxPhSlPzx/CVBpqsx1g= +github.com/beeper/td v0.107.1-0.20241106111429-3af6811c898b h1:9CDWJeL2L3F90k76JwBhbhCElN61eEu0OhGH/Z8IIDA= +github.com/beeper/td v0.107.1-0.20241106111429-3af6811c898b/go.mod h1:zzgUtTDJD4TVaCpKfCD0rxazQxPhSlPzx/CVBpqsx1g= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= diff --git a/pkg/connector/matrix.go b/pkg/connector/matrix.go index 3916ed30..b6b14110 100644 --- a/pkg/connector/matrix.go +++ b/pkg/connector/matrix.go @@ -44,6 +44,7 @@ func getMediaFilename(content *event.MessageEventContent) string { func (t *TelegramClient) transferMediaToTelegram(ctx context.Context, content *event.MessageEventContent, sticker bool) (tg.InputMediaClass, error) { var upload tg.InputFileClass var forceDocument bool + filename := getMediaFilename(content) err := t.main.Bridge.Bot.DownloadMediaToFile(ctx, content.URL, content.File, false, func(f *os.File) (err error) { uploadFilename := f.Name() if sticker && content.Info != nil && (content.Info.MimeType != "video/webm" && content.Info.MimeType != "application/x-tgsticker") { @@ -68,7 +69,7 @@ func (t *TelegramClient) transferMediaToTelegram(ctx context.Context, content *e } uploader := uploader.NewUploader(t.client.API()) - upload, err = uploader.FromPath(ctx, uploadFilename) + upload, err = uploader.FromPath(ctx, uploadFilename, filename) return }) if err != nil { @@ -80,7 +81,7 @@ func (t *TelegramClient) transferMediaToTelegram(ctx context.Context, content *e } var attributes []tg.DocumentAttributeClass - attributes = append(attributes, &tg.DocumentAttributeFilename{FileName: getMediaFilename(content)}) + attributes = append(attributes, &tg.DocumentAttributeFilename{FileName: filename}) if content.Info != nil && content.Info.Width != 0 && content.Info.Height != 0 { attributes = append(attributes, &tg.DocumentAttributeImageSize{W: content.Info.Width, H: content.Info.Height})