loadInboundGroupSession method

Future<SessionKey?> loadInboundGroupSession(
  1. String roomId,
  2. String sessionId
)

Loads an inbound group session

Implementation

Future<SessionKey?> loadInboundGroupSession(
    String roomId, String sessionId) async {
  final sess = _inboundGroupSessions[roomId]?[sessionId];
  if (sess != null) {
    if (sess.sessionId != sessionId && sess.sessionId.isNotEmpty) {
      return null; // session_id does not match....better not do anything
    }
    return sess; // nothing to do
  }
  final session =
      await client.database?.getInboundGroupSession(roomId, sessionId);
  if (session == null) return null;
  final userID = client.userID;
  if (userID == null) return null;
  final dbSess = SessionKey.fromDb(session, userID);
  final roomInboundGroupSessions =
      _inboundGroupSessions[roomId] ??= <String, SessionKey>{};
  if (!dbSess.isValid ||
      dbSess.sessionId.isEmpty ||
      dbSess.sessionId != sessionId) {
    return null;
  }
  roomInboundGroupSessions[sessionId] = dbSess;
  return sess;
}