Skip to content

Commit ffa8971

Browse files
richvdht3chguy
andauthored
Device dehydration: remove .well-known check (#29404)
* Device dehydrateion: remove .well-known check Per #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>
1 parent 072ee0c commit ffa8971

2 files changed

Lines changed: 5 additions & 39 deletions

File tree

playwright/e2e/crypto/dehydration.spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ test.use({
2222
msc3814_enabled: true,
2323
},
2424
},
25-
config: async ({ config, context }, use) => {
26-
const wellKnown = {
27-
...config.default_server_config,
28-
"org.matrix.msc3814": true,
29-
};
30-
31-
await context.route("https://localhost/.well-known/matrix/client", async (route) => {
32-
await route.fulfill({ json: wellKnown });
33-
});
34-
35-
await use(config);
36-
},
3725
});
3826

3927
test.describe("Dehydration", () => {

src/utils/device/dehydration.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,12 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import { logger } from "matrix-js-sdk/src/logger";
10-
import { type CryptoApi, type StartDehydrationOpts } from "matrix-js-sdk/src/crypto-api";
10+
import { type StartDehydrationOpts } from "matrix-js-sdk/src/crypto-api";
1111

1212
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
1313

1414
/**
15-
* Check if device dehydration is enabled.
16-
*
17-
* Note that this doesn't necessarily mean that device dehydration has been initialised
18-
* (yet) on this client; rather, it means that the server supports it, the crypto backend
19-
* supports it, and the application configuration suggests that it *should* be
20-
* initialised on this device.
21-
*
22-
* Dehydration can currently only be enabled by setting a flag in the .well-known file.
23-
*/
24-
async function deviceDehydrationEnabled(client: MatrixClient, crypto: CryptoApi | undefined): Promise<boolean> {
25-
if (!crypto) {
26-
return false;
27-
}
28-
if (!(await crypto.isDehydrationSupported())) {
29-
return false;
30-
}
31-
const wellknown = await client.waitForClientWellKnown();
32-
return !!wellknown?.["org.matrix.msc3814"];
33-
}
34-
35-
/**
36-
* If dehydration is enabled (i.e., it is supported by the server and enabled in
37-
* the configuration), rehydrate a device (if available) and create
15+
* If dehydration is supported by the server, rehydrate a device (if available) and create
3816
* a new dehydrated device.
3917
*
4018
* @param client - MatrixClient to use for the operation
@@ -45,8 +23,8 @@ export async function initialiseDehydrationIfEnabled(
4523
opts: StartDehydrationOpts = {},
4624
): Promise<void> {
4725
const crypto = client.getCrypto();
48-
if (await deviceDehydrationEnabled(client, crypto)) {
49-
logger.log("Device dehydration enabled");
50-
await crypto!.startDehydration(opts);
26+
if (crypto && (await crypto.isDehydrationSupported())) {
27+
logger.debug("Starting device dehydration");
28+
await crypto.startDehydration(opts);
5129
}
5230
}

0 commit comments

Comments
 (0)