From 544888fe33a14e0610b2916b5069656a06aeb299 Mon Sep 17 00:00:00 2001 From: Krille Date: Mon, 15 Jan 2024 13:56:54 +0100 Subject: [PATCH] refactor: Use maxnumberofotk from olm instead hardcode 100 --- lib/encryption/olm_manager.dart | 2 ++ lib/src/client.dart | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/encryption/olm_manager.dart b/lib/encryption/olm_manager.dart index 1e0e8bf1..59a64ef4 100644 --- a/lib/encryption/olm_manager.dart +++ b/lib/encryption/olm_manager.dart @@ -128,6 +128,8 @@ class OlmManager { bool _uploadKeysLock = false; CancelableOperation>? currentUpload; + int? get maxNumberOfOneTimeKeys => _olmAccount?.max_number_of_one_time_keys(); + /// Generates new one time keys, signs everything and upload it to the server. /// If `retry` is > 0, the request will be retried with new OTKs on upload failure. Future uploadKeys({ diff --git a/lib/src/client.dart b/lib/src/client.dart index d44edc1b..32d53d69 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1815,7 +1815,9 @@ class Client extends MatrixApi { /// Use this method only for testing utilities! Future handleSync(SyncUpdate sync, {Direction? direction}) async { // ensure we don't upload keys because someone forgot to set a key count - sync.deviceOneTimeKeysCount ??= {'signed_curve25519': 100}; + sync.deviceOneTimeKeysCount ??= { + 'signed_curve25519': encryption?.olmManager.maxNumberOfOneTimeKeys ?? 100, + }; await _handleSync(sync, direction: direction); }