Device dehydration: remove .well-known check (#29404)

* Device dehydrateion: remove .well-known check

Per https://github.com/element-hq/element-web/issues/29387, this is redundant

* Update src/utils/device/dehydration.ts

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Richard van der Hoff
2025-03-04 10:41:16 +00:00
committed by GitHub
parent 072ee0cf36
commit ffa8971195
2 changed files with 5 additions and 39 deletions

View File

@@ -22,18 +22,6 @@ test.use({
msc3814_enabled: true, msc3814_enabled: true,
}, },
}, },
config: async ({ config, context }, use) => {
const wellKnown = {
...config.default_server_config,
"org.matrix.msc3814": true,
};
await context.route("https://localhost/.well-known/matrix/client", async (route) => {
await route.fulfill({ json: wellKnown });
});
await use(config);
},
}); });
test.describe("Dehydration", () => { test.describe("Dehydration", () => {

View File

@@ -7,34 +7,12 @@ Please see LICENSE files in the repository root for full details.
*/ */
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { type CryptoApi, type StartDehydrationOpts } from "matrix-js-sdk/src/crypto-api"; import { type StartDehydrationOpts } from "matrix-js-sdk/src/crypto-api";
import type { MatrixClient } from "matrix-js-sdk/src/matrix"; import type { MatrixClient } from "matrix-js-sdk/src/matrix";
/** /**
* Check if device dehydration is enabled. * If dehydration is supported by the server, rehydrate a device (if available) and create
*
* Note that this doesn't necessarily mean that device dehydration has been initialised
* (yet) on this client; rather, it means that the server supports it, the crypto backend
* supports it, and the application configuration suggests that it *should* be
* initialised on this device.
*
* Dehydration can currently only be enabled by setting a flag in the .well-known file.
*/
async function deviceDehydrationEnabled(client: MatrixClient, crypto: CryptoApi | undefined): Promise<boolean> {
if (!crypto) {
return false;
}
if (!(await crypto.isDehydrationSupported())) {
return false;
}
const wellknown = await client.waitForClientWellKnown();
return !!wellknown?.["org.matrix.msc3814"];
}
/**
* If dehydration is enabled (i.e., it is supported by the server and enabled in
* the configuration), rehydrate a device (if available) and create
* a new dehydrated device. * a new dehydrated device.
* *
* @param client - MatrixClient to use for the operation * @param client - MatrixClient to use for the operation
@@ -45,8 +23,8 @@ export async function initialiseDehydrationIfEnabled(
opts: StartDehydrationOpts = {}, opts: StartDehydrationOpts = {},
): Promise<void> { ): Promise<void> {
const crypto = client.getCrypto(); const crypto = client.getCrypto();
if (await deviceDehydrationEnabled(client, crypto)) { if (crypto && (await crypto.isDehydrationSupported())) {
logger.log("Device dehydration enabled"); logger.debug("Starting device dehydration");
await crypto!.startDehydration(opts); await crypto.startDehydration(opts);
} }
} }