]> nmode's Git Repositories - signal-cli/commitdiff
Implement blocking for v2 groups
authorAsamK <asamk@gmx.de>
Mon, 21 Dec 2020 14:24:52 +0000 (15:24 +0100)
committerAsamK <asamk@gmx.de>
Mon, 21 Dec 2020 14:24:52 +0000 (15:24 +0100)
src/main/java/org/asamk/signal/manager/Manager.java

index 24bc0ebd8a04be61b2eb1c60e8f15815cbcc45e0..6db40566236400133f9f65a18c10e66883a86960 100644 (file)
@@ -1928,10 +1928,23 @@ public class Manager implements Closeable {
 
         if (content != null && content.getDataMessage().isPresent()) {
             SignalServiceDataMessage message = content.getDataMessage().get();
-            if (message.getGroupContext().isPresent() && message.getGroupContext().get().getGroupV1().isPresent()) {
-                SignalServiceGroup groupInfo = message.getGroupContext().get().getGroupV1().get();
-                GroupInfo group = getGroup(groupInfo.getGroupId());
-                return groupInfo.getType() == SignalServiceGroup.Type.DELIVER && group != null && group.isBlocked();
+            if (message.getGroupContext().isPresent()) {
+                GroupInfo group = null;
+                if (message.getGroupContext().get().getGroupV1().isPresent()) {
+                    SignalServiceGroup groupInfo = message.getGroupContext().get().getGroupV1().get();
+                    if (groupInfo.getType() == SignalServiceGroup.Type.DELIVER) {
+                        group = getGroup(groupInfo.getGroupId());
+                    }
+                }
+                if (message.getGroupContext().get().getGroupV2().isPresent()) {
+                    SignalServiceGroupV2 groupContext = message.getGroupContext().get().getGroupV2().get();
+                    final GroupMasterKey groupMasterKey = groupContext.getMasterKey();
+                    byte[] groupId = GroupUtils.getGroupId(groupMasterKey);
+                    group = account.getGroupStore().getGroupByV2Id(groupId);
+                }
+                if (group != null && group.isBlocked()) {
+                    return true;
+                }
             }
         }
         return false;