OutboundGroupSession.fromJson constructor

OutboundGroupSession.fromJson(
  1. Map<String, dynamic> dbEntry,
  2. String key
)

Implementation

OutboundGroupSession.fromJson(Map<String, dynamic> dbEntry, this.key) {
  try {
    for (final entry in json.decode(dbEntry['device_ids']).entries) {
      devices[entry.key] = Map<String, bool>.from(entry.value);
    }
  } catch (e) {
    // devices is bad (old data), so just not use this session
    Logs().i(
      '[OutboundGroupSession] Session in database is old, not using it. $e',
    );
    return;
  }

  creationTime =
      DateTime.fromMillisecondsSinceEpoch(dbEntry['creation_time']);

  try {
    outboundGroupSession = vod.GroupSession.fromPickleEncrypted(
      pickleKey: key.toPickleKey(),
      pickle: dbEntry['pickle'],
    );
  } catch (e, s) {
    try {
      outboundGroupSession = vod.GroupSession.fromOlmPickleEncrypted(
        pickleKey: utf8.encode(key),
        pickle: dbEntry['pickle'],
      );
    } catch (_) {
      Logs().e('[Vodozemac] Unable to unpickle outboundGroupSession', e, s);
    }
  }
}