feat: Add getter for own unverified devices

This commit is contained in:
Christian Pauly 2022-09-21 10:20:47 +02:00
parent d77b8476bc
commit dd375eddfd
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) {