DeviceKeysList.fromDbJson constructor

DeviceKeysList.fromDbJson(
  1. Map<String, dynamic> dbEntry,
  2. List<Map<String, dynamic>> childEntries,
  3. List<Map<String, dynamic>> crossSigningEntries,
  4. Client client,
)

Implementation

DeviceKeysList.fromDbJson(
    Map<String, dynamic> dbEntry,
    List<Map<String, dynamic>> childEntries,
    List<Map<String, dynamic>> crossSigningEntries,
    this.client)
    : userId = dbEntry['user_id'] ?? '' {
  outdated = dbEntry['outdated'];
  deviceKeys = {};
  for (final childEntry in childEntries) {
    final entry = DeviceKeys.fromDb(childEntry, client);
    if (entry.isValid) {
      deviceKeys[childEntry['device_id']] = entry;
    } else {
      outdated = true;
    }
  }
  for (final crossSigningEntry in crossSigningEntries) {
    final entry = CrossSigningKey.fromDbJson(crossSigningEntry, client);
    if (entry.isValid) {
      crossSigningKeys[crossSigningEntry['public_key']] = entry;
    } else {
      outdated = true;
    }
  }
}