Skip to content

Commit b8d433c

Browse files
Matrix: respect MSC3916, send bearer token when downloading images (42wim#2184 42wim#2205)
1 parent c4157a4 commit b8d433c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

bridge/matrix/matrix.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ func (b *Bmatrix) handleDownloadFile(rmsg *config.Message, content map[string]in
569569
if url, ok = content["url"].(string); !ok {
570570
return fmt.Errorf("url isn't a %T", url)
571571
}
572-
url = strings.Replace(url, "mxc://", b.GetString("Server")+"/_matrix/media/v1/download/", -1)
572+
// https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/3916-authentication-for-media.md
573+
url = strings.Replace(url, "mxc://", b.GetString("Server")+"/_matrix/client/v1/media/download/", -1)
573574

574575
if info, ok = content["info"].(map[string]interface{}); !ok {
575576
return fmt.Errorf("info isn't a %T", info)
@@ -606,7 +607,7 @@ func (b *Bmatrix) handleDownloadFile(rmsg *config.Message, content map[string]in
606607
return err
607608
}
608609
// actually download the file
609-
data, err := helper.DownloadFile(url)
610+
data, err := helper.DownloadFileAuth(url, "Bearer "+b.mc.AccessToken)
610611
if err != nil {
611612
return fmt.Errorf("download %s failed %#v", url, err)
612613
}

0 commit comments

Comments
 (0)