Two-step well-known check
This commit is contained in:
parent
d07c85a76b
commit
15a9a55767
|
@ -192,9 +192,28 @@ class Client {
|
||||||
) async {
|
) async {
|
||||||
final response = await http
|
final response = await http
|
||||||
.get('https://${MatrixIdOrDomain.domain}/.well-known/matrix/client');
|
.get('https://${MatrixIdOrDomain.domain}/.well-known/matrix/client');
|
||||||
final rawJson = json.decode(response.body);
|
WellKnownInformations wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
||||||
return WellKnownInformations.fromJson(rawJson);
|
if (Uri.parse(wellKnown.mHomeserver.baseUrl).host != MatrixIdOrDomain.domain) {
|
||||||
|
final response = await http
|
||||||
|
.get('https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client');
|
||||||
|
wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
||||||
}
|
}
|
||||||
|
return wellKnown;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<WellKnownInformations> getWellKnownInformationsByDomain(dynamic serverUrl) async {
|
||||||
|
Uri homeserver = (serverUrl is Uri) ? serverUrl : Uri.parse(serverUrl);
|
||||||
|
final response = await http
|
||||||
|
.get('https://${homeserver.host}/.well-known/matrix/client');
|
||||||
|
WellKnownInformations wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
||||||
|
if (Uri.parse(wellKnown.mHomeserver.baseUrl).host != homeserver.host) {
|
||||||
|
final response = await http
|
||||||
|
.get('https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client');
|
||||||
|
wellKnown = WellKnownInformations.fromJson(json.decode(response.body));
|
||||||
|
}
|
||||||
|
return wellKnown;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Checks the supported versions of the Matrix protocol and the supported
|
/// Checks the supported versions of the Matrix protocol and the supported
|
||||||
/// login types. Returns false if the server is not compatible with the
|
/// login types. Returns false if the server is not compatible with the
|
||||||
|
|
Loading…
Reference in a new issue