Merge branch 'krille/warn-on-unverified-devices' into 'main'

feat: Add getter for own unverified devices

See merge request famedly/company/frontend/famedlysdk!1141
This commit is contained in:
td 2022-09-27 09:25:20 +00:00
commit 3a8fedb02f
1 changed files with 14 additions and 0 deletions

View File

@ -2146,6 +2146,20 @@ class Client extends MatrixApi {
Map<String, DeviceKeysList> get userDeviceKeys => _userDeviceKeys;
Map<String, DeviceKeysList> _userDeviceKeys = {};
/// A list of all not verified and not blocked device keys. Clients should
/// display a warning if this list is not empty and suggest the user to
/// verify or block those devices.
List<DeviceKeys> get unverifiedDevices {
final userId = userID;
if (userId == null) return [];
return userDeviceKeys[userId]
?.deviceKeys
.values
.where((deviceKey) => !deviceKey.verified && !deviceKey.blocked)
.toList() ??
[];
}
/// Gets user device keys by its curve25519 key. Returns null if it isn't found
DeviceKeys? getUserDeviceKeysByCurve25519Key(String senderKey) {
for (final user in userDeviceKeys.values) {