diff --git a/changelog.d/506.bugfix b/changelog.d/506.bugfix new file mode 100644 index 00000000..763a7b86 --- /dev/null +++ b/changelog.d/506.bugfix @@ -0,0 +1 @@ +Use the new authenticated endpoints in MediaProxy. diff --git a/src/components/media-proxy.ts b/src/components/media-proxy.ts index 3a991364..13976445 100644 --- a/src/components/media-proxy.ts +++ b/src/components/media-proxy.ts @@ -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}`,