mirror of https://github.com/vector-im/riot-web
Use fetch instead of browser-request
parent
31fd36efba
commit
2539da0dfa
|
@ -68,23 +68,18 @@ async function checkIdentityServerUrl(u) {
|
||||||
|
|
||||||
// XXX: duplicated logic from js-sdk but it's quite tied up in the validation logic in the
|
// XXX: duplicated logic from js-sdk but it's quite tied up in the validation logic in the
|
||||||
// js-sdk so probably as easy to duplicate it than to separate it out so we can reuse it
|
// js-sdk so probably as easy to duplicate it than to separate it out so we can reuse it
|
||||||
return new Promise((resolve) => {
|
try {
|
||||||
request(
|
const response = await fetch(u + '/_matrix/identity/api/v1');
|
||||||
// also XXX: we don't really know whether to hit /v1 or /v2 for this: we
|
if (response.ok) {
|
||||||
// probably want a /versions endpoint like the C/S API.
|
return null;
|
||||||
// https://github.com/matrix-org/matrix-doc/issues/1665
|
|
||||||
{ method: "GET", url: u + '/_matrix/identity/api/v1' },
|
|
||||||
(err, response, body) => {
|
|
||||||
if (err) {
|
|
||||||
resolve(_t("Could not connect to Identity Server"));
|
|
||||||
} else if (response.status < 200 || response.status >= 300) {
|
} else if (response.status < 200 || response.status >= 300) {
|
||||||
resolve(_t("Not a valid Identity Server (status code %(code)s)", {code: response.status}));
|
return _t("Not a valid Identity Server (status code %(code)s)", {code: response.status});
|
||||||
} else {
|
} else {
|
||||||
resolve(null);
|
return _t("Could not connect to Identity Server");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return _t("Could not connect to Identity Server");
|
||||||
}
|
}
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetIdServer extends React.Component {
|
export default class SetIdServer extends React.Component {
|
||||||
|
|
Loading…
Reference in New Issue