]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/Manager.java
Send correct expiry value in group and contact syncs
[signal-cli] / src / main / java / org / asamk / signal / Manager.java
index 46c2e64ca7b572057d5be3f0c208202ef3e36af7..505ee12deaae74c6aa4cbe4a1dae263aadf6654f 100644 (file)
@@ -818,6 +818,16 @@ class Manager implements Signal {
         save();
     }
 
+    @Override
+    public List<byte[]> getGroupIds() {
+        List<GroupInfo> groups = getGroups();
+        List<byte[]> ids = new ArrayList<byte[]>(groups.size());
+        for (GroupInfo group : groups) {
+          ids.add(group.groupId);
+        }
+        return ids;
+    }
+
     @Override
     public String getGroupName(byte[] groupId) {
         GroupInfo group = getGroup(groupId);
@@ -1479,9 +1489,10 @@ class Manager implements Signal {
             try (OutputStream fos = new FileOutputStream(groupsFile)) {
                 DeviceGroupsOutputStream out = new DeviceGroupsOutputStream(fos);
                 for (GroupInfo record : groupStore.getGroups()) {
+                    ThreadInfo info = threadStore.getThread(Base64.encodeBytes(record.groupId));
                     out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name),
                             new ArrayList<>(record.members), createGroupAvatarAttachment(record.groupId),
-                            record.active, Optional.<Integer>absent()));
+                            record.active, Optional.fromNullable(info != null ? info.messageExpirationTime : null)));
                 }
             }
 
@@ -1513,6 +1524,7 @@ class Manager implements Signal {
                 DeviceContactsOutputStream out = new DeviceContactsOutputStream(fos);
                 for (ContactInfo record : contactStore.getContacts()) {
                     VerifiedMessage verifiedMessage = null;
+                    ThreadInfo info = threadStore.getThread(record.number);
                     if (getIdentities().containsKey(record.number)) {
                         JsonIdentityKeyStore.Identity currentIdentity = null;
                         for (JsonIdentityKeyStore.Identity id : getIdentities().get(record.number)) {
@@ -1528,7 +1540,7 @@ class Manager implements Signal {
                     // TODO include profile key
                     out.write(new DeviceContact(record.number, Optional.fromNullable(record.name),
                             createContactAvatarAttachment(record.number), Optional.fromNullable(record.color),
-                            Optional.fromNullable(verifiedMessage), Optional.<byte[]>absent(), false, Optional.<Integer>absent()));
+                            Optional.fromNullable(verifiedMessage), Optional.<byte[]>absent(), false, Optional.fromNullable(info != null ? info.messageExpirationTime : null)));
                 }
             }