+ if (groupsFile.exists() && groupsFile.length() > 0) {
+ FileInputStream contactsFileStream = new FileInputStream(groupsFile);
+ SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
+ .withStream(contactsFileStream)
+ .withContentType("application/octet-stream")
+ .withLength(groupsFile.length())
+ .build();
+
+ sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
+ }
+ } finally {
+ groupsFile.delete();
+ }
+ }
+
+ private void sendContacts() throws IOException, EncapsulatedExceptions, UntrustedIdentityException {
+ File contactsFile = File.createTempFile("multidevice-contact-update", ".tmp");
+
+ try {
+ DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactsFile));
+ try {
+ for (ContactInfo record : contactStore.getContacts()) {
+ out.write(new DeviceContact(record.number, Optional.fromNullable(record.name),
+ Optional.<SignalServiceAttachmentStream>absent())); // TODO
+ }
+ } finally {
+ out.close();
+ }
+