synchronized (cachedSessions) {
final var session = loadSessionLocked(key);
- if (session == null) {
- return false;
- }
-
- return session.hasSenderChain() && session.getSessionVersion() == CiphertextMessage.CURRENT_VERSION;
+ return isActive(session);
}
}
return recipientIdToNameMap.keySet()
.stream()
.flatMap(recipientId -> getKeysLocked(recipientId).stream())
+ .filter(key -> isActive(this.loadSessionLocked(key)))
.map(key -> new SignalProtocolAddress(recipientIdToNameMap.get(key.recipientId), key.getDeviceId()))
.collect(Collectors.toSet());
}
}
}
+ private static boolean isActive(SessionRecord record) {
+ return record != null
+ && record.hasSenderChain()
+ && record.getSessionVersion() == CiphertextMessage.CURRENT_VERSION;
+ }
+
private static final class Key {
private final RecipientId recipientId;