feat(permalinks): point Share links/QR at to.healthchat.ch

Add a config-driven matrix_to_url option so Share dialog links and QR
codes resolve against a matrix.to-compatible resolver instead of the
hardcoded public matrix.to. MatrixToPermalinkConstructor now reads the
base URL lazily from config (default https://matrix.to), keeping the
matrix.to URL format. HealthChat configs point it at the in-house fork
https://to.healthchat.ch and drop the conflicting permalink_prefix
(which routes to the Element-format constructor a matrix.to fork can't
parse).
This commit is contained in:
2026-06-30 17:30:56 +02:00
parent 62e7334a1b
commit c2b11111dd
7 changed files with 72 additions and 15 deletions
@@ -8,6 +8,7 @@ Please see LICENSE files in the repository root for full details.
import MatrixToPermalinkConstructor from "../../../../src/utils/permalinks/MatrixToPermalinkConstructor";
import { PermalinkParts } from "../../../../src/utils/permalinks/PermalinkConstructor";
import SdkConfig from "../../../../src/SdkConfig";
describe("MatrixToPermalinkConstructor", () => {
const peramlinkConstructor = new MatrixToPermalinkConstructor();
@@ -49,4 +50,32 @@ describe("MatrixToPermalinkConstructor", () => {
).toEqual("https://matrix.to/#/!myroom:example.com/$event4?via=one.example.com&via=two.example.com");
});
});
describe("with a custom matrix_to_url config", () => {
beforeEach(() => {
SdkConfig.add({ matrix_to_url: "https://to.healthchat.ch" });
});
afterEach(() => {
SdkConfig.reset();
});
it("generates links against the configured host", () => {
const constructor = new MatrixToPermalinkConstructor();
expect(constructor.forUser("@user:example.com")).toEqual("https://to.healthchat.ch/#/@user:example.com");
expect(constructor.forRoom("!myroom:example.com", [])).toEqual(
"https://to.healthchat.ch/#/!myroom:example.com",
);
});
it("parses links from the configured host and rejects matrix.to links", () => {
const constructor = new MatrixToPermalinkConstructor();
expect(constructor.parsePermalink("https://to.healthchat.ch/#/@user:example.com")).toEqual(
new PermalinkParts(null, null, "@user:example.com", null),
);
expect(() => constructor.parsePermalink("https://matrix.to/#/@user:example.com")).toThrow(
new Error("Does not appear to be a permalink"),
);
});
});
});