]> nmode's Git Repositories - signal-cli/commitdiff
Fix behavior when reading a v1 group from storage that has already been migrated...
authorAsamK <asamk@gmx.de>
Thu, 10 Feb 2022 14:40:04 +0000 (15:40 +0100)
committerAsamK <asamk@gmx.de>
Thu, 10 Feb 2022 14:42:43 +0000 (15:42 +0100)
Fixes #888

lib/src/main/java/org/asamk/signal/manager/helper/StorageHelper.java

index 960ed1d5973c9e24ccc5f9d4c462c47885a4329a..dfed3d43a005aa3188ef02511a82aa5953434c75 100644 (file)
@@ -129,18 +129,18 @@ public class StorageHelper {
         final var groupV1Record = record.getGroupV1().get();
         final var groupIdV1 = GroupId.v1(groupV1Record.getGroupId());
 
         final var groupV1Record = record.getGroupV1().get();
         final var groupIdV1 = GroupId.v1(groupV1Record.getGroupId());
 
-        final var group = account.getGroupStore().getGroup(groupIdV1);
+        var group = account.getGroupStore().getGroup(groupIdV1);
         if (group == null) {
             try {
                 context.getGroupHelper().sendGroupInfoRequest(groupIdV1, account.getSelfRecipientId());
             } catch (Throwable e) {
                 logger.warn("Failed to send group request", e);
             }
         if (group == null) {
             try {
                 context.getGroupHelper().sendGroupInfoRequest(groupIdV1, account.getSelfRecipientId());
             } catch (Throwable e) {
                 logger.warn("Failed to send group request", e);
             }
+            group = account.getGroupStore().getOrCreateGroupV1(groupIdV1);
         }
         }
-        final var groupV1 = account.getGroupStore().getOrCreateGroupV1(groupIdV1);
-        if (groupV1.isBlocked() != groupV1Record.isBlocked()) {
-            groupV1.setBlocked(groupV1Record.isBlocked());
-            account.getGroupStore().updateGroup(groupV1);
+        if (group != null && group.isBlocked() != groupV1Record.isBlocked()) {
+            group.setBlocked(groupV1Record.isBlocked());
+            account.getGroupStore().updateGroup(group);
         }
     }
 
         }
     }