fix: Back off of failed key queries
This commit is contained in:
parent
053585852e
commit
024a27bfc2
|
@ -26,7 +26,9 @@ class KeysQueryResponse {
|
|||
Map<String, MatrixCrossSigningKey> userSigningKeys;
|
||||
|
||||
KeysQueryResponse.fromJson(Map<String, dynamic> json) {
|
||||
failures = Map<String, dynamic>.from(json['failures']);
|
||||
failures = json['failures'] != null
|
||||
? Map<String, dynamic>.from(json['failures'])
|
||||
: null;
|
||||
deviceKeys = json['device_keys'] != null
|
||||
? (json['device_keys'] as Map).map(
|
||||
(k, v) => MapEntry(
|
||||
|
|
|
@ -1122,8 +1122,8 @@ class Client extends MatrixApi {
|
|||
var prevState = room.getState(stateEvent.type, stateEvent.stateKey);
|
||||
if (prevState != null && prevState.sortOrder > stateEvent.sortOrder) {
|
||||
Logs.warning('''
|
||||
A new ${eventUpdate.type} event of the type ${stateEvent.type} has arrived with a previews
|
||||
sort order ${stateEvent.sortOrder} than the current ${stateEvent.type} event with a
|
||||
A new ${eventUpdate.type} event of the type ${stateEvent.type} has arrived with a previews
|
||||
sort order ${stateEvent.sortOrder} than the current ${stateEvent.type} event with a
|
||||
sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||
return;
|
||||
}
|
||||
|
@ -1213,6 +1213,7 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
|||
return userIds;
|
||||
}
|
||||
|
||||
final Map<String, DateTime> _keyQueryFailures = {};
|
||||
Future<void> _updateUserDeviceKeys() async {
|
||||
try {
|
||||
if (!isLogged()) return;
|
||||
|
@ -1231,7 +1232,11 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
|||
_userDeviceKeys[userId] = DeviceKeysList(userId, this);
|
||||
}
|
||||
var deviceKeysList = userDeviceKeys[userId];
|
||||
if (deviceKeysList.outdated) {
|
||||
if (deviceKeysList.outdated &&
|
||||
(!_keyQueryFailures.containsKey(userId.domain) ||
|
||||
DateTime.now()
|
||||
.subtract(Duration(minutes: 5))
|
||||
.isAfter(_keyQueryFailures[userId.domain]))) {
|
||||
outdatedLists[userId] = [];
|
||||
}
|
||||
}
|
||||
|
@ -1373,6 +1378,13 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now process all the failures
|
||||
if (response.failures != null) {
|
||||
for (final failureDomain in response.failures.keys) {
|
||||
_keyQueryFailures[failureDomain] = DateTime.now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dbActions.isNotEmpty) {
|
||||
|
|
Loading…
Reference in a new issue