org.whispersystems.signalservice.internal.push.SignalServiceProtos.SyncMessage Java Examples
The following examples show how to use
org.whispersystems.signalservice.internal.push.SignalServiceProtos.SyncMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceVerifiedContent(VerifiedMessage verifiedMessage, byte[] nullMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); Verified.Builder verifiedMessageBuilder = Verified.newBuilder(); verifiedMessageBuilder.setNullMessage(ByteString.copyFrom(nullMessage)); verifiedMessageBuilder.setIdentityKey(ByteString.copyFrom(verifiedMessage.getIdentityKey().serialize())); if (verifiedMessage.getDestination().getUuid().isPresent()) { verifiedMessageBuilder.setDestinationUuid(verifiedMessage.getDestination().getUuid().get().toString()); } if (verifiedMessage.getDestination().getNumber().isPresent()) { verifiedMessageBuilder.setDestinationE164(verifiedMessage.getDestination().getNumber().get()); } switch(verifiedMessage.getVerified()) { case DEFAULT: verifiedMessageBuilder.setState(Verified.State.DEFAULT); break; case VERIFIED: verifiedMessageBuilder.setState(Verified.State.VERIFIED); break; case UNVERIFIED: verifiedMessageBuilder.setState(Verified.State.UNVERIFIED); break; default: throw new AssertionError("Unknown: " + verifiedMessage.getVerified()); } syncMessage.setVerified(verifiedMessageBuilder); return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #2
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceReadContent(List<ReadMessage> readMessages) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); for (ReadMessage readMessage : readMessages) { SyncMessage.Read.Builder readBuilder = SyncMessage.Read.newBuilder().setTimestamp(readMessage.getTimestamp()); if (readMessage.getSender().getUuid().isPresent()) { readBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString()); } if (readMessage.getSender().getNumber().isPresent()) { readBuilder.setSenderE164(readMessage.getSender().getNumber().get()); } builder.addRead(readBuilder.build()); } return container.setSyncMessage(builder).build().toByteArray(); }
Example #3
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceViewOnceOpenContent(ViewOnceOpenMessage readMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); SyncMessage.ViewOnceOpen.Builder viewOnceBuilder = SyncMessage.ViewOnceOpen.newBuilder().setTimestamp(readMessage.getTimestamp()); if (readMessage.getSender().getUuid().isPresent()) { viewOnceBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString()); } if (readMessage.getSender().getNumber().isPresent()) { viewOnceBuilder.setSenderE164(readMessage.getSender().getNumber().get()); } builder.setViewOnceOpen(viewOnceBuilder.build()); return container.setSyncMessage(builder).build().toByteArray(); }
Example #4
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceBlockedContent(BlockedListMessage blocked) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Blocked.Builder blockedMessage = SyncMessage.Blocked.newBuilder(); for (SignalServiceAddress address : blocked.getAddresses()) { if (address.getUuid().isPresent()) { blockedMessage.addUuids(address.getUuid().get().toString()); } if (address.getNumber().isPresent()) { blockedMessage.addNumbers(address.getNumber().get()); } } for (byte[] groupId : blocked.getGroupIds()) { blockedMessage.addGroupIds(ByteString.copyFrom(groupId)); } return container.setSyncMessage(syncMessage.setBlocked(blockedMessage)).build().toByteArray(); }
Example #5
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceConfigurationContent(ConfigurationMessage configuration) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Configuration.Builder configurationMessage = SyncMessage.Configuration.newBuilder(); if (configuration.getReadReceipts().isPresent()) { configurationMessage.setReadReceipts(configuration.getReadReceipts().get()); } if (configuration.getUnidentifiedDeliveryIndicators().isPresent()) { configurationMessage.setUnidentifiedDeliveryIndicators(configuration.getUnidentifiedDeliveryIndicators().get()); } if (configuration.getTypingIndicators().isPresent()) { configurationMessage.setTypingIndicators(configuration.getTypingIndicators().get()); } if (configuration.getLinkPreviews().isPresent()) { configurationMessage.setLinkPreviews(configuration.getLinkPreviews().get()); } configurationMessage.setProvisioningVersion(ProvisioningProtos.ProvisioningVersion.CURRENT_VALUE); return container.setSyncMessage(syncMessage.setConfiguration(configurationMessage)).build().toByteArray(); }
Example #6
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceFetchTypeContent(SignalServiceSyncMessage.FetchType fetchType) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.FetchLatest.Builder fetchMessage = SyncMessage.FetchLatest.newBuilder(); switch (fetchType) { case LOCAL_PROFILE: fetchMessage.setType(SyncMessage.FetchLatest.Type.LOCAL_PROFILE); break; case STORAGE_MANIFEST: fetchMessage.setType(SyncMessage.FetchLatest.Type.STORAGE_MANIFEST); break; default: Log.w(TAG, "Unknown fetch type!"); break; } return container.setSyncMessage(syncMessage.setFetchLatest(fetchMessage)).build().toByteArray(); }
Example #7
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceFetchTypeContent(SignalServiceSyncMessage.FetchType fetchType) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.FetchLatest.Builder fetchMessage = SyncMessage.FetchLatest.newBuilder(); switch (fetchType) { case LOCAL_PROFILE: fetchMessage.setType(SyncMessage.FetchLatest.Type.LOCAL_PROFILE); break; case STORAGE_MANIFEST: fetchMessage.setType(SyncMessage.FetchLatest.Type.STORAGE_MANIFEST); break; default: Log.w(TAG, "Unknown fetch type!"); break; } return container.setSyncMessage(syncMessage.setFetchLatest(fetchMessage)).build().toByteArray(); }
Example #8
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceConfigurationContent(ConfigurationMessage configuration) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Configuration.Builder configurationMessage = SyncMessage.Configuration.newBuilder(); if (configuration.getReadReceipts().isPresent()) { configurationMessage.setReadReceipts(configuration.getReadReceipts().get()); } if (configuration.getUnidentifiedDeliveryIndicators().isPresent()) { configurationMessage.setUnidentifiedDeliveryIndicators(configuration.getUnidentifiedDeliveryIndicators().get()); } if (configuration.getTypingIndicators().isPresent()) { configurationMessage.setTypingIndicators(configuration.getTypingIndicators().get()); } if (configuration.getLinkPreviews().isPresent()) { configurationMessage.setLinkPreviews(configuration.getLinkPreviews().get()); } configurationMessage.setProvisioningVersion(ProvisioningProtos.ProvisioningVersion.CURRENT_VALUE); return container.setSyncMessage(syncMessage.setConfiguration(configurationMessage)).build().toByteArray(); }
Example #9
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceVerifiedContent(VerifiedMessage verifiedMessage, byte[] nullMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); Verified.Builder verifiedMessageBuilder = Verified.newBuilder(); verifiedMessageBuilder.setNullMessage(ByteString.copyFrom(nullMessage)); verifiedMessageBuilder.setIdentityKey(ByteString.copyFrom(verifiedMessage.getIdentityKey().serialize())); if (verifiedMessage.getDestination().getUuid().isPresent()) { verifiedMessageBuilder.setDestinationUuid(verifiedMessage.getDestination().getUuid().get().toString()); } if (verifiedMessage.getDestination().getNumber().isPresent()) { verifiedMessageBuilder.setDestinationE164(verifiedMessage.getDestination().getNumber().get()); } switch(verifiedMessage.getVerified()) { case DEFAULT: verifiedMessageBuilder.setState(Verified.State.DEFAULT); break; case VERIFIED: verifiedMessageBuilder.setState(Verified.State.VERIFIED); break; case UNVERIFIED: verifiedMessageBuilder.setState(Verified.State.UNVERIFIED); break; default: throw new AssertionError("Unknown: " + verifiedMessage.getVerified()); } syncMessage.setVerified(verifiedMessageBuilder); return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #10
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceBlockedContent(BlockedListMessage blocked) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Blocked.Builder blockedMessage = SyncMessage.Blocked.newBuilder(); for (SignalServiceAddress address : blocked.getAddresses()) { if (address.getUuid().isPresent()) { blockedMessage.addUuids(address.getUuid().get().toString()); } if (address.getNumber().isPresent()) { blockedMessage.addNumbers(address.getNumber().get()); } } for (byte[] groupId : blocked.getGroupIds()) { blockedMessage.addGroupIds(ByteString.copyFrom(groupId)); } return container.setSyncMessage(syncMessage.setBlocked(blockedMessage)).build().toByteArray(); }
Example #11
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceViewOnceOpenContent(ViewOnceOpenMessage readMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); SyncMessage.ViewOnceOpen.Builder viewOnceBuilder = SyncMessage.ViewOnceOpen.newBuilder().setTimestamp(readMessage.getTimestamp()); if (readMessage.getSender().getUuid().isPresent()) { viewOnceBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString()); } if (readMessage.getSender().getNumber().isPresent()) { viewOnceBuilder.setSenderE164(readMessage.getSender().getNumber().get()); } builder.setViewOnceOpen(viewOnceBuilder.build()); return container.setSyncMessage(builder).build().toByteArray(); }
Example #12
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceReadContent(List<ReadMessage> readMessages) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); for (ReadMessage readMessage : readMessages) { SyncMessage.Read.Builder readBuilder = SyncMessage.Read.newBuilder().setTimestamp(readMessage.getTimestamp()); if (readMessage.getSender().getUuid().isPresent()) { readBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString()); } if (readMessage.getSender().getNumber().isPresent()) { readBuilder.setSenderE164(readMessage.getSender().getNumber().get()); } builder.addRead(readBuilder.build()); } return container.setSyncMessage(builder).build().toByteArray(); }
Example #13
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private SyncMessage.Builder createSyncMessageBuilder() { SecureRandom random = new SecureRandom(); byte[] padding = Util.getRandomLengthBytes(512); random.nextBytes(padding); SyncMessage.Builder builder = SyncMessage.newBuilder(); builder.setPadding(ByteString.copyFrom(padding)); return builder; }
Example #14
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private SyncMessage.Builder createSyncMessageBuilder() { SecureRandom random = new SecureRandom(); byte[] padding = Util.getRandomLengthBytes(512); random.nextBytes(padding); SyncMessage.Builder builder = SyncMessage.newBuilder(); builder.setPadding(ByteString.copyFrom(padding)); return builder; }
Example #15
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceStickerPackOperationContent(List<StickerPackOperationMessage> stickerPackOperations) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); for (StickerPackOperationMessage stickerPackOperation : stickerPackOperations) { SyncMessage.StickerPackOperation.Builder builder = SyncMessage.StickerPackOperation.newBuilder(); if (stickerPackOperation.getPackId().isPresent()) { builder.setPackId(ByteString.copyFrom(stickerPackOperation.getPackId().get())); } if (stickerPackOperation.getPackKey().isPresent()) { builder.setPackKey(ByteString.copyFrom(stickerPackOperation.getPackKey().get())); } if (stickerPackOperation.getType().isPresent()) { switch (stickerPackOperation.getType().get()) { case INSTALL: builder.setType(SyncMessage.StickerPackOperation.Type.INSTALL); break; case REMOVE: builder.setType(SyncMessage.StickerPackOperation.Type.REMOVE); break; } } syncMessage.addStickerPackOperation(builder); } return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #16
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceGroupsContent(SignalServiceAttachmentStream groups) throws IOException { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); builder.setGroups(SyncMessage.Groups.newBuilder() .setBlob(createAttachmentPointer(groups))); return container.setSyncMessage(builder).build().toByteArray(); }
Example #17
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceContactsContent(SignalServiceAttachmentStream contacts, boolean complete) throws IOException { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); builder.setContacts(SyncMessage.Contacts.newBuilder() .setBlob(createAttachmentPointer(contacts)) .setComplete(complete)); return container.setSyncMessage(builder).build().toByteArray(); }
Example #18
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceContactsContent(SignalServiceAttachmentStream contacts, boolean complete) throws IOException { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); builder.setContacts(SyncMessage.Contacts.newBuilder() .setBlob(createAttachmentPointer(contacts)) .setComplete(complete)); return container.setSyncMessage(builder).build().toByteArray(); }
Example #19
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceSyncKeysContent(KeysMessage keysMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Keys.Builder builder = SyncMessage.Keys.newBuilder(); if (keysMessage.getStorageService().isPresent()) { builder.setStorageService(ByteString.copyFrom(keysMessage.getStorageService().get().serialize())); } else { Log.w(TAG, "Invalid keys message!"); } return container.setSyncMessage(syncMessage.setKeys(builder)).build().toByteArray(); }
Example #20
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceStickerPackOperationContent(List<StickerPackOperationMessage> stickerPackOperations) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); for (StickerPackOperationMessage stickerPackOperation : stickerPackOperations) { SyncMessage.StickerPackOperation.Builder builder = SyncMessage.StickerPackOperation.newBuilder(); if (stickerPackOperation.getPackId().isPresent()) { builder.setPackId(ByteString.copyFrom(stickerPackOperation.getPackId().get())); } if (stickerPackOperation.getPackKey().isPresent()) { builder.setPackKey(ByteString.copyFrom(stickerPackOperation.getPackKey().get())); } if (stickerPackOperation.getType().isPresent()) { switch (stickerPackOperation.getType().get()) { case INSTALL: builder.setType(SyncMessage.StickerPackOperation.Type.INSTALL); break; case REMOVE: builder.setType(SyncMessage.StickerPackOperation.Type.REMOVE); break; } } syncMessage.addStickerPackOperation(builder); } return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #21
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceGroupsContent(SignalServiceAttachmentStream groups) throws IOException { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); builder.setGroups(SyncMessage.Groups.newBuilder() .setBlob(createAttachmentPointer(groups))); return container.setSyncMessage(builder).build().toByteArray(); }
Example #22
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 4 votes |
private byte[] createMultiDeviceSentTranscriptContent(byte[] content, Optional<SignalServiceAddress> recipient, long timestamp, List<SendMessageResult> sendMessageResults, boolean isRecipientUpdate) { try { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Sent.Builder sentMessage = SyncMessage.Sent.newBuilder(); DataMessage dataMessage = Content.parseFrom(content).getDataMessage(); sentMessage.setTimestamp(timestamp); sentMessage.setMessage(dataMessage); for (SendMessageResult result : sendMessageResults) { if (result.getSuccess() != null) { SyncMessage.Sent.UnidentifiedDeliveryStatus.Builder builder = SyncMessage.Sent.UnidentifiedDeliveryStatus.newBuilder(); if (result.getAddress().getUuid().isPresent()) { builder = builder.setDestinationUuid(result.getAddress().getUuid().get().toString()); } if (result.getAddress().getNumber().isPresent()) { builder = builder.setDestinationE164(result.getAddress().getNumber().get()); } builder.setUnidentified(result.getSuccess().isUnidentified()); sentMessage.addUnidentifiedStatus(builder.build()); } } if (recipient.isPresent()) { if (recipient.get().getUuid().isPresent()) sentMessage.setDestinationUuid(recipient.get().getUuid().get().toString()); if (recipient.get().getNumber().isPresent()) sentMessage.setDestinationE164(recipient.get().getNumber().get()); } if (dataMessage.getExpireTimer() > 0) { sentMessage.setExpirationStartTimestamp(System.currentTimeMillis()); } if (dataMessage.getIsViewOnce()) { dataMessage = dataMessage.toBuilder().clearAttachments().build(); sentMessage.setMessage(dataMessage); } sentMessage.setIsRecipientUpdate(isRecipientUpdate); return container.setSyncMessage(syncMessage.setSent(sentMessage)).build().toByteArray(); } catch (InvalidProtocolBufferException e) { throw new AssertionError(e); } }
Example #23
Source File: SignalServiceCipher.java From bcm-android with GNU General Public License v3.0 | 4 votes |
private SignalServiceSyncMessage createSynchronizeMessage(SignalServiceProtos.Envelope envelope, SyncMessage content) throws InvalidMessageException { if (content.hasSent()) { SyncMessage.Sent sentContent = content.getSent(); return SignalServiceSyncMessage.forSentTranscript(new SentTranscriptMessage(sentContent.getDestination(), sentContent.getTimestamp(), createSignalServiceMessage(envelope, sentContent.getMessage()), sentContent.getExpirationStartTimestamp())); } if (content.hasRequest()) { return SignalServiceSyncMessage.forRequest(new RequestMessage(content.getRequest())); } if (content.getReadList().size() > 0) { List<ReadMessage> readMessages = new LinkedList<>(); for (SyncMessage.Read read : content.getReadList()) { readMessages.add(new ReadMessage(read.getSender(), read.getTimestamp())); } return SignalServiceSyncMessage.forRead(readMessages); } if (content.hasVerified()) { try { Verified verified = content.getVerified(); String destination = verified.getDestination(); IdentityKey identityKey = new IdentityKey(verified.getIdentityKey().toByteArray(), 0); VerifiedState verifiedState; if (verified.getState() == Verified.State.DEFAULT) { verifiedState = VerifiedState.DEFAULT; } else if (verified.getState() == Verified.State.VERIFIED) { verifiedState = VerifiedState.VERIFIED; } else if (verified.getState() == Verified.State.UNVERIFIED) { verifiedState = VerifiedState.UNVERIFIED; } else { throw new InvalidMessageException("Unknown state: " + verified.getState().getNumber()); } return SignalServiceSyncMessage.forVerified(new VerifiedMessage(destination, identityKey, verifiedState, System.currentTimeMillis())); } catch (InvalidKeyException e) { throw new InvalidMessageException(e); } } return SignalServiceSyncMessage.empty(); }
Example #24
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private byte[] createMultiDeviceMessageRequestResponseContent(MessageRequestResponseMessage message) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.MessageRequestResponse.Builder responseMessage = SyncMessage.MessageRequestResponse.newBuilder(); if (message.getGroupId().isPresent()) { responseMessage.setGroupId(ByteString.copyFrom(message.getGroupId().get())); } if (message.getPerson().isPresent()) { if (message.getPerson().get().getNumber().isPresent()) { responseMessage.setThreadE164(message.getPerson().get().getNumber().get()); } if (message.getPerson().get().getUuid().isPresent()) { responseMessage.setThreadUuid(message.getPerson().get().getUuid().get().toString()); } } switch (message.getType()) { case ACCEPT: responseMessage.setType(SyncMessage.MessageRequestResponse.Type.ACCEPT); break; case DELETE: responseMessage.setType(SyncMessage.MessageRequestResponse.Type.DELETE); break; case BLOCK: responseMessage.setType(SyncMessage.MessageRequestResponse.Type.BLOCK); break; case BLOCK_AND_DELETE: responseMessage.setType(SyncMessage.MessageRequestResponse.Type.BLOCK_AND_DELETE); break; default: Log.w(TAG, "Unknown type!"); responseMessage.setType(SyncMessage.MessageRequestResponse.Type.UNKNOWN); break; } syncMessage.setMessageRequestResponse(responseMessage); return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #25
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private byte[] createMultiDeviceSentTranscriptContent(byte[] content, Optional<SignalServiceAddress> recipient, long timestamp, List<SendMessageResult> sendMessageResults, boolean isRecipientUpdate) { try { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Sent.Builder sentMessage = SyncMessage.Sent.newBuilder(); DataMessage dataMessage = Content.parseFrom(content).getDataMessage(); sentMessage.setTimestamp(timestamp); sentMessage.setMessage(dataMessage); for (SendMessageResult result : sendMessageResults) { if (result.getSuccess() != null) { SyncMessage.Sent.UnidentifiedDeliveryStatus.Builder builder = SyncMessage.Sent.UnidentifiedDeliveryStatus.newBuilder(); if (result.getAddress().getUuid().isPresent()) { builder = builder.setDestinationUuid(result.getAddress().getUuid().get().toString()); } if (result.getAddress().getNumber().isPresent()) { builder = builder.setDestinationE164(result.getAddress().getNumber().get()); } builder.setUnidentified(result.getSuccess().isUnidentified()); sentMessage.addUnidentifiedStatus(builder.build()); } } if (recipient.isPresent()) { if (recipient.get().getUuid().isPresent()) sentMessage.setDestinationUuid(recipient.get().getUuid().get().toString()); if (recipient.get().getNumber().isPresent()) sentMessage.setDestinationE164(recipient.get().getNumber().get()); } if (dataMessage.getExpireTimer() > 0) { sentMessage.setExpirationStartTimestamp(System.currentTimeMillis()); } if (dataMessage.getIsViewOnce()) { dataMessage = dataMessage.toBuilder().clearAttachments().build(); sentMessage.setMessage(dataMessage); } sentMessage.setIsRecipientUpdate(isRecipientUpdate); return container.setSyncMessage(syncMessage.setSent(sentMessage)).build().toByteArray(); } catch (InvalidProtocolBufferException e) { throw new AssertionError(e); } }