Bug 1741170 - Assume domain hosts a Matrix server if no well-known is found. r=clokep
Differential Revision: https://phabricator.services.mozilla.com/D134151 --HG-- extra : amend_source : 832f75a60e08978c5dc69b1464f31882831b206d
This commit is contained in:
Родитель
2d37ff5988
Коммит
a14a8cd896
|
@ -1539,7 +1539,7 @@ MatrixAccount.prototype = {
|
|||
* @throws {Error} When the autodiscovery failed.
|
||||
*/
|
||||
async getServer() {
|
||||
let domain = "https://matrix.org";
|
||||
let domain = "matrix.org";
|
||||
if (this.nameIsMXID) {
|
||||
domain = this.protocol.splitUsername(this.name)[1];
|
||||
} else if (this.prefs.prefHasUserValue("server")) {
|
||||
|
@ -1550,14 +1550,24 @@ MatrixAccount.prototype = {
|
|||
this.prefs.getIntPref("port", 443)
|
||||
);
|
||||
}
|
||||
const discoveredInfo = await MatrixSDK.AutoDiscovery.findClientConfig(
|
||||
domain
|
||||
);
|
||||
const homeserverResult = discoveredInfo[HOMESERVER_WELL_KNOWN];
|
||||
let discoveredInfo = await MatrixSDK.AutoDiscovery.findClientConfig(domain);
|
||||
let homeserverResult = discoveredInfo[HOMESERVER_WELL_KNOWN];
|
||||
|
||||
// If the well-known lookup fails, pretend the domain has a well-known for
|
||||
// itself.
|
||||
if (homeserverResult.state !== MatrixSDK.AutoDiscovery.SUCCESS) {
|
||||
discoveredInfo = await MatrixSDK.AutoDiscovery.fromDiscoveryConfig({
|
||||
[HOMESERVER_WELL_KNOWN]: {
|
||||
base_url: `https://${domain}`,
|
||||
},
|
||||
});
|
||||
homeserverResult = discoveredInfo[HOMESERVER_WELL_KNOWN];
|
||||
}
|
||||
if (homeserverResult.state === MatrixSDK.AutoDiscovery.PROMPT) {
|
||||
throw new Error(_("connection.error.serverNotFound"));
|
||||
}
|
||||
if (homeserverResult.state !== MatrixSDK.AutoDiscovery.SUCCESS) {
|
||||
//TODO these are English strings generated by the SDK.
|
||||
throw new Error(homeserverResult.error);
|
||||
}
|
||||
return homeserverResult.base_url;
|
||||
|
|
Загрузка…
Ссылка в новой задаче