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;
|
Map<String, MatrixCrossSigningKey> userSigningKeys;
|
||||||
|
|
||||||
KeysQueryResponse.fromJson(Map<String, dynamic> json) {
|
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
|
deviceKeys = json['device_keys'] != null
|
||||||
? (json['device_keys'] as Map).map(
|
? (json['device_keys'] as Map).map(
|
||||||
(k, v) => MapEntry(
|
(k, v) => MapEntry(
|
||||||
|
|
|
@ -1213,6 +1213,7 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
return userIds;
|
return userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Map<String, DateTime> _keyQueryFailures = {};
|
||||||
Future<void> _updateUserDeviceKeys() async {
|
Future<void> _updateUserDeviceKeys() async {
|
||||||
try {
|
try {
|
||||||
if (!isLogged()) return;
|
if (!isLogged()) return;
|
||||||
|
@ -1231,7 +1232,11 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
_userDeviceKeys[userId] = DeviceKeysList(userId, this);
|
_userDeviceKeys[userId] = DeviceKeysList(userId, this);
|
||||||
}
|
}
|
||||||
var deviceKeysList = userDeviceKeys[userId];
|
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] = [];
|
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) {
|
if (dbActions.isNotEmpty) {
|
||||||
|
|
Loading…
Reference in a new issue