mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
Avoid creating new otk if there are pending to_devices to process
This commit is contained in:
parent
5eda8a84d0
commit
270c70d301
1 changed files with 11 additions and 1 deletions
|
@ -428,7 +428,17 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
val currentCount = syncResponse.deviceOneTimeKeysCount.signedCurve25519 ?: 0
|
||||
oneTimeKeysUploader.updateOneTimeKeyCount(currentCount)
|
||||
}
|
||||
if (isStarted()) {
|
||||
// There is a limit of to_device events returned per sync.
|
||||
// If we are in a case of such limited to_device sync we can't try to generate/upload
|
||||
// new otk now, because there might be some pending olm pre-key to_device messages that would fail if we rotate
|
||||
// the old otk too early. In this case we want to wait for the pending to_device before doing anything
|
||||
// As per spec:
|
||||
// If there is a large queue of send-to-device messages, the server should limit the number sent in each /sync response.
|
||||
// 100 messages is recommended as a reasonable limit.
|
||||
// The limit is not part of the spec, so it's probably safer to handle that when there are no more to_device ( so we are sure
|
||||
// that there are no pending to_device
|
||||
val toDevices = syncResponse.toDevice?.events.orEmpty()
|
||||
if (isStarted() && toDevices.isEmpty()) {
|
||||
// Make sure we process to-device messages before generating new one-time-keys #2782
|
||||
deviceListManager.refreshOutdatedDeviceLists()
|
||||
oneTimeKeysUploader.maybeUploadOneTimeKeys()
|
||||
|
|
Loading…
Reference in a new issue