Skip to content

Commit

Permalink
Enable redirected media by default (matrix-org#12142)
Browse files Browse the repository at this point in the history
* Enable redirected media by default

See matrix-org/matrix-js-sdk#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
  • Loading branch information
turt2live authored Feb 11, 2024
1 parent d192807 commit 86b3564
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion playwright/e2e/timeline/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
);
Expand Down
8 changes: 4 additions & 4 deletions src/customisations/Media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/linkify-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 86b3564

Please sign in to comment.