]> nmode's Git Repositories - signal-cli/commitdiff
Add missing isActive check
authorAsamK <asamk@gmx.de>
Fri, 3 Sep 2021 19:30:45 +0000 (21:30 +0200)
committerAsamK <asamk@gmx.de>
Fri, 3 Sep 2021 19:30:45 +0000 (21:30 +0200)
lib/src/main/java/org/asamk/signal/manager/storage/sessions/SessionStore.java

index 5738408d6826f9861e14dbb7df9b7d2d13128ed4..1b94642abdd47d006403033f7cb35f27c1c85ad9 100644 (file)
@@ -109,11 +109,7 @@ public class SessionStore implements SignalServiceSessionStore {
 
         synchronized (cachedSessions) {
             final var session = loadSessionLocked(key);
 
         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())
             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());
         }
                     .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;
     private static final class Key {
 
         private final RecipientId recipientId;