connector/matrix: fix sending media
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
@@ -59,4 +59,4 @@ require (
|
|||||||
rsc.io/qr v0.2.0 // indirect
|
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
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
|||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
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 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
|
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.20241106111429-3af6811c898b h1:9CDWJeL2L3F90k76JwBhbhCElN61eEu0OhGH/Z8IIDA=
|
||||||
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/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 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
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=
|
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
||||||
|
|||||||
@@ -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) {
|
func (t *TelegramClient) transferMediaToTelegram(ctx context.Context, content *event.MessageEventContent, sticker bool) (tg.InputMediaClass, error) {
|
||||||
var upload tg.InputFileClass
|
var upload tg.InputFileClass
|
||||||
var forceDocument bool
|
var forceDocument bool
|
||||||
|
filename := getMediaFilename(content)
|
||||||
err := t.main.Bridge.Bot.DownloadMediaToFile(ctx, content.URL, content.File, false, func(f *os.File) (err error) {
|
err := t.main.Bridge.Bot.DownloadMediaToFile(ctx, content.URL, content.File, false, func(f *os.File) (err error) {
|
||||||
uploadFilename := f.Name()
|
uploadFilename := f.Name()
|
||||||
if sticker && content.Info != nil && (content.Info.MimeType != "video/webm" && content.Info.MimeType != "application/x-tgsticker") {
|
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())
|
uploader := uploader.NewUploader(t.client.API())
|
||||||
upload, err = uploader.FromPath(ctx, uploadFilename)
|
upload, err = uploader.FromPath(ctx, uploadFilename, filename)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -80,7 +81,7 @@ func (t *TelegramClient) transferMediaToTelegram(ctx context.Context, content *e
|
|||||||
}
|
}
|
||||||
|
|
||||||
var attributes []tg.DocumentAttributeClass
|
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 {
|
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})
|
attributes = append(attributes, &tg.DocumentAttributeImageSize{W: content.Info.Width, H: content.Info.Height})
|
||||||
|
|||||||
Reference in New Issue
Block a user