]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/Manager.java
Update dependency
[signal-cli] / src / main / java / org / asamk / signal / Manager.java
index 575bba222b243862a5102bb4f97c9ece96690fd2..a38d313f516e2fa93f52a7f5b11dea02ce855c46 100644 (file)
@@ -558,7 +558,8 @@ class Manager implements Signal {
         if (mime == null) {
             mime = "application/octet-stream";
         }
-        return new SignalServiceAttachmentStream(attachmentStream, mime, attachmentSize, Optional.of(attachmentFile.getName()), null);
+        // TODO mabybe add a parameter to set the voiceNote and preview option
+        return new SignalServiceAttachmentStream(attachmentStream, mime, attachmentSize, Optional.of(attachmentFile.getName()), false, Optional.<byte[]>absent(),null);
     }
 
     private Optional<SignalServiceAttachmentStream> createGroupAvatarAttachment(byte[] groupId) throws IOException {
@@ -836,7 +837,10 @@ class Manager implements Signal {
     }
 
     @Override
-    public void updateGroup(byte[] groupId, String name, List<String> members, String avatar) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException {
+    public byte[] updateGroup(byte[] groupId, String name, List<String> members, String avatar) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException {
+        if (groupId.length == 0) {
+            groupId = null;
+        }
         if (name.isEmpty()) {
             name = null;
         }
@@ -846,7 +850,7 @@ class Manager implements Signal {
         if (avatar.isEmpty()) {
             avatar = null;
         }
-        sendUpdateGroupMessage(groupId, name, members, avatar);
+        return sendUpdateGroupMessage(groupId, name, members, avatar);
     }
 
     private void requestSyncGroups() throws IOException {
@@ -1248,7 +1252,11 @@ class Manager implements Signal {
                     File tmpFile = null;
                     try {
                         tmpFile = Util.createTempFile();
-                        DeviceContactsInputStream s = new DeviceContactsInputStream(retrieveAttachmentAsStream(syncMessage.getContacts().get().asPointer(), tmpFile));
+                        final ContactsMessage contactsMessage = syncMessage.getContacts().get();
+                        DeviceContactsInputStream s = new DeviceContactsInputStream(retrieveAttachmentAsStream(contactsMessage.getContactsStream().asPointer(), tmpFile));
+                        if (contactsMessage.isComplete()) {
+                            contactStore.clear();
+                        }
                         DeviceContact c;
                         while ((c = s.read()) != null) {
                             ContactInfo contact = contactStore.getContact(c.getNumber());
@@ -1503,7 +1511,7 @@ class Manager implements Signal {
                             .withLength(contactsFile.length())
                             .build();
 
-                    sendSyncMessage(SignalServiceSyncMessage.forContacts(attachmentStream));
+                    sendSyncMessage(SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, true)));
                 }
             }
         } finally {