Add config param to disable client wellknown fetch (#34084)

* Add enable_client_well_known_lookups config option

Signed-off-by: David Langley <langley.dave@gmail.com>

* Gate client .well-known poll on enable_client_well_known_lookups

Signed-off-by: David Langley <langley.dave@gmail.com>

* Gate MatrixRTC foci well-known fallback on enable_client_well_known_lookups

Signed-off-by: David Langley <langley.dave@gmail.com>

---------

Signed-off-by: David Langley <langley.dave@gmail.com>
Co-authored-by: David Langley <langley.dave@gmail.com>
This commit is contained in:
David Langley
2026-07-13 16:27:36 +01:00
committed by GitHub
parent c4606c19f8
commit 6aeb5f552b
7 changed files with 71 additions and 5 deletions
+26
View File
@@ -15,6 +15,7 @@ import fetchMock from "@fetch-mock/vitest";
import { advanceDateAndTime, stubClient, createTestClient } from "test-utils";
import { type IMatrixClientPeg, MatrixClientPeg as peg } from "./MatrixClientPeg";
import SdkConfig from "./SdkConfig";
vi.useFakeTimers();
@@ -116,5 +117,30 @@ describe("MatrixClientPeg", () => {
await testPeg.start();
expect(mockInitRustCrypto).toHaveBeenCalledTimes(1);
});
it("should poll the client well-known by default", async () => {
vi.spyOn(testPeg.safeGet(), "initRustCrypto").mockResolvedValue(undefined);
const startClient = vi.spyOn(testPeg.safeGet(), "startClient").mockResolvedValue(undefined);
await testPeg.start();
const opts = startClient.mock.calls[0][0];
expect(opts?.clientWellKnownPollPeriod).toBe(2 * 60 * 60);
});
it("should not poll the client well-known when enable_client_well_known_lookups is false", async () => {
const sdkConfigGet = SdkConfig.get;
vi.spyOn(SdkConfig, "get").mockImplementation((key?: any, altCaseName?: string): any => {
if (key === "enable_client_well_known_lookups") return false;
return sdkConfigGet(key, altCaseName);
});
vi.spyOn(testPeg.safeGet(), "initRustCrypto").mockResolvedValue(undefined);
const startClient = vi.spyOn(testPeg.safeGet(), "startClient").mockResolvedValue(undefined);
await testPeg.start();
const opts = startClient.mock.calls[0][0];
expect(opts?.clientWellKnownPollPeriod).toBeUndefined();
});
});
});