Merge pull request #2008 from famedly/krille/make-clear-sdk-is-compatible-with-v1-spec

refactor: Add missing versions to supportedVersions and use warning instead of blocking
This commit is contained in:
Krille-chan 2025-02-11 09:49:02 +01:00 committed by GitHub
commit beef67bd02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 14 deletions

View File

@ -548,10 +548,10 @@ class Client extends MatrixApi {
final versions = await getVersions();
if (!versions.versions
.any((version) => supportedVersions.contains(version))) {
throw BadServerVersionsException(
versions.versions.toSet(),
supportedVersions,
Logs().w(
'Server supports the versions: ${versions.toString()} but this application is only compatible with ${supportedVersions.toString()}.',
);
assert(false);
}
final loginTypes = await getLoginFlows() ?? [];
@ -1640,7 +1640,22 @@ class Client extends MatrixApi {
return pushrules != null ? TryGetPushRule.tryFromJson(pushrules) : null;
}
static const Set<String> supportedVersions = {'v1.1', 'v1.2'};
static const Set<String> supportedVersions = {
'v1.1',
'v1.2',
'v1.3',
'v1.4',
'v1.5',
'v1.6',
'v1.7',
'v1.8',
'v1.9',
'v1.10',
'v1.11',
'v1.12',
'v1.13',
};
static const List<String> supportedDirectEncryptionAlgorithms = [
AlgorithmTypes.olmV1Curve25519AesSha2,
];
@ -3988,16 +4003,6 @@ enum SyncStatus {
error,
}
class BadServerVersionsException implements Exception {
final Set<String> serverVersions, supportedVersions;
BadServerVersionsException(this.serverVersions, this.supportedVersions);
@override
String toString() =>
'Server supports the versions: ${serverVersions.toString()} but this application is only compatible with ${supportedVersions.toString()}.';
}
class BadServerLoginTypesException implements Exception {
final Set<String> serverLoginTypes, supportedLoginTypes;