From 86b3564b547d4b95fc887dd465af2cb675169f0a Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 11 Feb 2024 08:32:57 +0100 Subject: [PATCH] Enable redirected media by default (#12142) * Enable redirected media by default See https://github.com/matrix-org/matrix-js-sdk/pull/4007 * Update the tests * Update tests * Update end-to-end tests too * Update linkifier to use Media customisation endpoint * Fix tests for new js-sdk behaviour * Fix unchanged file * Fix linkifier * Fix lint --- playwright/e2e/timeline/timeline.spec.ts | 2 +- src/customisations/Media.ts | 8 ++++---- src/linkify-matrix.ts | 10 +++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/playwright/e2e/timeline/timeline.spec.ts b/playwright/e2e/timeline/timeline.spec.ts index 19e38f79f7..67d7bb84d2 100644 --- a/playwright/e2e/timeline/timeline.spec.ts +++ b/playwright/e2e/timeline/timeline.spec.ts @@ -49,7 +49,7 @@ const expectAvatar = async (cli: Client, e: Locator, avatarUrl: string): Promise const url = await cli.evaluate( (client, { avatarUrl, size, resizeMethod }) => { // eslint-disable-next-line no-restricted-properties - return client.mxcUrlToHttp(avatarUrl, size, size, resizeMethod); + return client.mxcUrlToHttp(avatarUrl, size, size, resizeMethod, false, true); }, { avatarUrl, size, resizeMethod: AVATAR_RESIZE_METHOD }, ); diff --git a/src/customisations/Media.ts b/src/customisations/Media.ts index 415a7f4c5d..05f91325dd 100644 --- a/src/customisations/Media.ts +++ b/src/customisations/Media.ts @@ -80,7 +80,7 @@ export class Media { */ public get srcHttp(): string | null { // eslint-disable-next-line no-restricted-properties - return this.client.mxcUrlToHttp(this.srcMxc) || null; + return this.client.mxcUrlToHttp(this.srcMxc, undefined, undefined, undefined, false, true) || null; } /** @@ -90,7 +90,7 @@ export class Media { public get thumbnailHttp(): string | null { if (!this.hasThumbnail) return null; // eslint-disable-next-line no-restricted-properties - return this.client.mxcUrlToHttp(this.thumbnailMxc!); + return this.client.mxcUrlToHttp(this.thumbnailMxc!, undefined, undefined, undefined, false, true); } /** @@ -107,7 +107,7 @@ export class Media { width = Math.floor(width * window.devicePixelRatio); height = Math.floor(height * window.devicePixelRatio); // eslint-disable-next-line no-restricted-properties - return this.client.mxcUrlToHttp(this.thumbnailMxc!, width, height, mode); + return this.client.mxcUrlToHttp(this.thumbnailMxc!, width, height, mode, false, true); } /** @@ -122,7 +122,7 @@ export class Media { width = Math.floor(width * window.devicePixelRatio); height = Math.floor(height * window.devicePixelRatio); // eslint-disable-next-line no-restricted-properties - return this.client.mxcUrlToHttp(this.srcMxc, width, height, mode); + return this.client.mxcUrlToHttp(this.srcMxc, width, height, mode, false, true); } /** diff --git a/src/linkify-matrix.ts b/src/linkify-matrix.ts index f5a419f0a7..f7b7775bbe 100644 --- a/src/linkify-matrix.ts +++ b/src/linkify-matrix.ts @@ -184,7 +184,15 @@ export const options: Opts = { switch (type) { case "url": if (href.startsWith("mxc://") && MatrixClientPeg.get()) { - return getHttpUriForMxc(MatrixClientPeg.get()!.baseUrl, href); + return getHttpUriForMxc( + MatrixClientPeg.get()!.baseUrl, + href, + undefined, + undefined, + undefined, + false, + true, + ); } // fallthrough case Type.RoomAlias: