Merge pull request #5477 from matrix-org/t3chguy/fix/15913
Handle manual hs urls better for the server picker
This commit is contained in:
commit
91ae8df423
3 changed files with 19 additions and 6 deletions
|
@ -49,9 +49,19 @@ export default class ServerPickerDialog extends React.PureComponent<IProps, ISta
|
||||||
const config = SdkConfig.get();
|
const config = SdkConfig.get();
|
||||||
this.defaultServer = config["validated_server_config"] as ValidatedServerConfig;
|
this.defaultServer = config["validated_server_config"] as ValidatedServerConfig;
|
||||||
const { serverConfig } = this.props;
|
const { serverConfig } = this.props;
|
||||||
|
|
||||||
|
let otherHomeserver = "";
|
||||||
|
if (!serverConfig.isDefault) {
|
||||||
|
if (serverConfig.isNameResolvable && serverConfig.hsName) {
|
||||||
|
otherHomeserver = serverConfig.hsName;
|
||||||
|
} else {
|
||||||
|
otherHomeserver = serverConfig.hsUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
defaultChosen: serverConfig.isDefault,
|
defaultChosen: serverConfig.isDefault,
|
||||||
otherHomeserver: serverConfig.isDefault ? "" : (serverConfig.hsName || serverConfig.hsUrl),
|
otherHomeserver,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ const ServerPicker = ({ title, dialogTitle, serverConfig, onServerConfigChange }
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
}
|
}
|
||||||
|
|
||||||
let serverName = serverConfig.hsName;
|
let serverName = serverConfig.isNameResolvable ? serverConfig.hsName : serverConfig.hsUrl;
|
||||||
if (serverConfig.hsNameIsDifferent) {
|
if (serverConfig.hsNameIsDifferent) {
|
||||||
serverName = <TextWithTooltip class="mx_Login_underlinedServerName" tooltip={serverConfig.hsUrl}>
|
serverName = <TextWithTooltip class="mx_Login_underlinedServerName" tooltip={serverConfig.hsUrl}>
|
||||||
{serverConfig.hsName}
|
{serverConfig.hsName}
|
||||||
|
|
|
@ -34,6 +34,8 @@ export class ValidatedServerConfig {
|
||||||
isUrl: string;
|
isUrl: string;
|
||||||
|
|
||||||
isDefault: boolean;
|
isDefault: boolean;
|
||||||
|
// when the server config is based on static URLs the hsName is not resolvable and things may wish to use hsUrl
|
||||||
|
isNameResolvable: boolean;
|
||||||
|
|
||||||
warning: string;
|
warning: string;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +163,7 @@ export default class AutoDiscoveryUtils {
|
||||||
const url = new URL(homeserverUrl);
|
const url = new URL(homeserverUrl);
|
||||||
const serverName = url.hostname;
|
const serverName = url.hostname;
|
||||||
|
|
||||||
return AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, result, syntaxOnly);
|
return AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, result, syntaxOnly, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,12 +181,12 @@ export default class AutoDiscoveryUtils {
|
||||||
* input.
|
* input.
|
||||||
* @param {string} serverName The domain name the AutoDiscovery result is for.
|
* @param {string} serverName The domain name the AutoDiscovery result is for.
|
||||||
* @param {*} discoveryResult The AutoDiscovery result.
|
* @param {*} discoveryResult The AutoDiscovery result.
|
||||||
* @param {boolean} syntaxOnly If true, errors relating to liveliness of the servers will
|
* @param {boolean} syntaxOnly If true, errors relating to liveliness of the servers will not be raised.
|
||||||
* not be raised.
|
* @param {boolean} isSynthetic If true, then the discoveryResult was synthesised locally.
|
||||||
* @returns {Promise<ValidatedServerConfig>} Resolves to the validated configuration.
|
* @returns {Promise<ValidatedServerConfig>} Resolves to the validated configuration.
|
||||||
*/
|
*/
|
||||||
static buildValidatedConfigFromDiscovery(
|
static buildValidatedConfigFromDiscovery(
|
||||||
serverName: string, discoveryResult, syntaxOnly=false): ValidatedServerConfig {
|
serverName: string, discoveryResult, syntaxOnly=false, isSynthetic=false): ValidatedServerConfig {
|
||||||
if (!discoveryResult || !discoveryResult["m.homeserver"]) {
|
if (!discoveryResult || !discoveryResult["m.homeserver"]) {
|
||||||
// This shouldn't happen without major misconfiguration, so we'll log a bit of information
|
// This shouldn't happen without major misconfiguration, so we'll log a bit of information
|
||||||
// in the log so we can find this bit of codee but otherwise tell teh user "it broke".
|
// in the log so we can find this bit of codee but otherwise tell teh user "it broke".
|
||||||
|
@ -252,6 +254,7 @@ export default class AutoDiscoveryUtils {
|
||||||
isUrl: preferredIdentityUrl,
|
isUrl: preferredIdentityUrl,
|
||||||
isDefault: false,
|
isDefault: false,
|
||||||
warning: hsResult.error,
|
warning: hsResult.error,
|
||||||
|
isNameResolvable: !isSynthetic,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue