Skip to content

Commit

Permalink
Use the new authenticated endpoints in MediaProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
tadzik committed Sep 5, 2024
1 parent 344d0dc commit 22aca95
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/media-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ export class MediaProxy {
}
// Cache from this point onwards.
// Extract the media from the event.
const url = this.matrixClient.mxcToHttp('mxc://' + metadata.mxc);
const mxcMatch = metadata.mxc.match(new RegExp('^([^/]+)/(.+)$'));
if (!mxcMatch) {
throw new ApiError('Invalid MXC URI', ErrCode.BadValue);
}
const [, serverName, mediaId ] = mxcMatch;
const url = `${this.matrixClient.homeserverUrl}/_matrix/client/v1/media/download/${serverName}/${mediaId}`;
get(url, {
headers: {
'Authorization': `Bearer ${this.matrixClient.accessToken}`,
Expand Down

0 comments on commit 22aca95

Please sign in to comment.