Skip to content

Commit

Permalink
Merge pull request #2008 from famedly/krille/make-clear-sdk-is-compat…
Browse files Browse the repository at this point in the history
…ible-with-v1-spec

refactor: Add missing versions to supportedVersions and use warning instead of blocking
  • Loading branch information
krille-chan authored Feb 11, 2025
2 parents 2f1e423 + bf37bf8 commit beef67b
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() ?? [];
Expand Down Expand Up @@ -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,
];
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit beef67b

Please sign in to comment.