Add missing isActive check

This commit is contained in:
AsamK 2021-09-03 21:30:45 +02:00
parent b903102407
commit 43bcc95713

View file

@ -109,11 +109,7 @@ public class SessionStore implements SignalServiceSessionStore {
synchronized (cachedSessions) {
final var session = loadSessionLocked(key);
if (session == null) {
return false;
}
return session.hasSenderChain() && session.getSessionVersion() == CiphertextMessage.CURRENT_VERSION;
return isActive(session);
}
}
@ -158,6 +154,7 @@ public class SessionStore implements SignalServiceSessionStore {
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());
}
@ -321,6 +318,12 @@ public class SessionStore implements SignalServiceSessionStore {
}
}
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;