Synchronize with paired devices when a contact changes.

// FREEBIE
This commit is contained in:
Moxie Marlinspike
2015-10-23 12:51:28 -07:00
parent 05eba8c2f0
commit 11a93fabe5
6 changed files with 46 additions and 21 deletions

View File

@@ -101,17 +101,19 @@ public class MultiDeviceContactUpdateJob extends MasterSecretJob implements Inje
private void sendUpdate(TextSecureMessageSender messageSender, File contactsFile)
throws IOException, UntrustedIdentityException, NetworkException
{
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
TextSecureAttachmentStream attachmentStream = TextSecureAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
if (contactsFile.length() > 0) {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
TextSecureAttachmentStream attachmentStream = TextSecureAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
try {
messageSender.sendMessage(TextSecureSyncMessage.forContacts(attachmentStream));
} catch (IOException ioe) {
throw new NetworkException(ioe);
try {
messageSender.sendMessage(TextSecureSyncMessage.forContacts(attachmentStream));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}