Merge branch 'client-fix-losing-verified-devices' into 'master'

[Client] Fix storing verified and blocked devices

See merge request famedly/famedlysdk!194
This commit is contained in:
Christian Pauly 2020-02-17 11:53:11 +00:00
commit 75c1dc1c56

View file

@ -1391,6 +1391,8 @@ class Client {
type: HTTPType.POST, type: HTTPType.POST,
action: "/client/r0/keys/query", action: "/client/r0/keys/query",
data: {"timeout": 10000, "device_keys": outdatedLists}); data: {"timeout": 10000, "device_keys": outdatedLists});
final Map<String, DeviceKeysList> oldUserDeviceKeys =
Map<String, DeviceKeysList>.from(_userDeviceKeys);
for (final rawDeviceKeyListEntry in response["device_keys"].entries) { for (final rawDeviceKeyListEntry in response["device_keys"].entries) {
final String userId = rawDeviceKeyListEntry.key; final String userId = rawDeviceKeyListEntry.key;
_userDeviceKeys[userId].deviceKeys = {}; _userDeviceKeys[userId].deviceKeys = {};
@ -1398,7 +1400,13 @@ class Client {
final String deviceId = rawDeviceKeyEntry.key; final String deviceId = rawDeviceKeyEntry.key;
_userDeviceKeys[userId].deviceKeys[deviceId] = _userDeviceKeys[userId].deviceKeys[deviceId] =
DeviceKeys.fromJson(rawDeviceKeyEntry.value); DeviceKeys.fromJson(rawDeviceKeyEntry.value);
if (deviceId == this.deviceID && if (oldUserDeviceKeys.containsKey(userId) &&
_userDeviceKeys[userId].deviceKeys.containsKey(deviceId)) {
_userDeviceKeys[userId].deviceKeys[deviceId].verified =
_userDeviceKeys[userId].deviceKeys[deviceId].verified;
_userDeviceKeys[userId].deviceKeys[deviceId].blocked =
_userDeviceKeys[userId].deviceKeys[deviceId].blocked;
} else if (deviceId == this.deviceID &&
_userDeviceKeys[userId].deviceKeys[deviceId].ed25519Key == _userDeviceKeys[userId].deviceKeys[deviceId].ed25519Key ==
this.fingerprintKey) { this.fingerprintKey) {
_userDeviceKeys[userId].deviceKeys[deviceId].verified = true; _userDeviceKeys[userId].deviceKeys[deviceId].verified = true;