diff --git a/lib/src/omemo/sessionmanager.dart b/lib/src/omemo/sessionmanager.dart index 0173491..acebb32 100644 --- a/lib/src/omemo/sessionmanager.dart +++ b/lib/src/omemo/sessionmanager.dart @@ -35,23 +35,6 @@ class OmemoSessionManager { _eventStreamController = StreamController.broadcast(), _log = Logger('OmemoSessionManager'); - /// Deserialise the OmemoSessionManager from JSON data [data]. - factory OmemoSessionManager.fromJson(Map data, TrustManager trustManager) { - final ratchetMap = {}; - for (final rawRatchet in data['sessions']! as List>) { - final key = RatchetMapKey(rawRatchet['jid']! as String, rawRatchet['deviceId']! as int); - final ratchet = OmemoDoubleRatchet.fromJson(rawRatchet['ratchet']! as Map); - ratchetMap[key] = ratchet; - } - - return OmemoSessionManager( - Device.fromJson(data['device']! as Map), - data['devices']! as Map>, - ratchetMap, - trustManager, - ); - } - /// Deserialise the OmemoSessionManager from JSON data [data] that does not contain /// the ratchet sessions. factory OmemoSessionManager.fromJsonWithoutSessions(Map data, Map ratchetMap, TrustManager trustManager) { @@ -566,42 +549,6 @@ class OmemoSessionManager { @visibleForTesting Map getRatchetMap() => _ratchetMap; - /// Serialise the entire session manager into a JSON object. - Future> toJson() async { - /* - { - 'devices': { - 'alice@...': [1, 2, ...], - 'bob@...': [1], - ... - }, - 'device': { ... }, - 'sessions': [ - { - 'jid': 'alice@...', - 'deviceId': 1, - 'ratchet': { ... }, - }, - ... - ], - } - */ - - final sessions = List>.empty(growable: true); - for (final entry in _ratchetMap.entries) { - sessions.add({ - 'jid': entry.key.jid, - 'deviceId': entry.key.deviceId, - 'ratchet': await entry.value.toJson(), - }); - } - return { - 'devices': _deviceMap, - 'device': await (await getDevice()).toJson(), - 'sessions': sessions, - }; - } - /// Serialise the entire session manager into a JSON object. Future> toJsonWithoutSessions() async { /* diff --git a/test/serialisation_test.dart b/test/serialisation_test.dart index 815f36f..8244ac7 100644 --- a/test/serialisation_test.dart +++ b/test/serialisation_test.dart @@ -85,9 +85,11 @@ void main() { ); // Serialise and deserialise - final serialised = await oldSession.toJson(); - final newSession = OmemoSessionManager.fromJson( + final serialised = await oldSession.toJsonWithoutSessions(); + final newSession = OmemoSessionManager.fromJsonWithoutSessions( serialised, + // NOTE: At this point, we don't care about this attribute + {}, AlwaysTrustingTrustManager(), ); @@ -95,15 +97,6 @@ void main() { final newDevice = await newSession.getDevice(); expect(await oldDevice.equals(newDevice), true); expect(await oldSession.getDeviceMap(), await newSession.getDeviceMap()); - - expect(oldSession.getRatchetMap().length, newSession.getRatchetMap().length); - for (final session in oldSession.getRatchetMap().entries) { - expect(newSession.getRatchetMap().containsKey(session.key), true); - - final oldRatchet = oldSession.getRatchetMap()[session.key]!; - final newRatchet = newSession.getRatchetMap()[session.key]!; - expect(await oldRatchet.equals(newRatchet), true); - } }); test('Test serialising and deserialising the BlindTrustBeforeVerificationTrustManager', () async {