Ejemplo n.º 1
0
        private byte[] createSentTranscriptMessage(byte[] content, May <SignalServiceAddress> recipient, ulong timestamp)
        {
            {
                try
                {
                    Content.Builder                container   = Content.CreateBuilder();
                    SyncMessage.Builder            syncMessage = SyncMessage.CreateBuilder();
                    SyncMessage.Types.Sent.Builder sentMessage = SyncMessage.Types.Sent.CreateBuilder();

                    sentMessage.SetTimestamp(timestamp);
                    sentMessage.SetMessage(DataMessage.ParseFrom(content));

                    if (recipient.HasValue)
                    {
                        sentMessage.SetDestination(recipient.ForceGetValue().getNumber());
                    }

                    return(container.SetSyncMessage(syncMessage.SetSent(sentMessage)).Build().ToByteArray());;
                }
                catch (InvalidProtocolBufferException e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
Ejemplo n.º 2
0
        private byte[] createMultiDeviceSentTranscriptContent(byte[] content, May <SignalServiceAddress> recipient, ulong timestamp)
        {
            try
            {
                Content.Builder                container   = Content.CreateBuilder();
                SyncMessage.Builder            syncMessage = SyncMessage.CreateBuilder();
                SyncMessage.Types.Sent.Builder sentMessage = SyncMessage.Types.Sent.CreateBuilder();
                DataMessage dataMessage = DataMessage.ParseFrom(content);

                sentMessage.SetTimestamp(timestamp);
                sentMessage.SetMessage(dataMessage);

                if (recipient.HasValue)
                {
                    sentMessage.SetDestination(recipient.ForceGetValue().getNumber());
                }

                if (dataMessage.ExpireTimer > 0)
                {
                    sentMessage.SetExpirationStartTimestamp((ulong)Util.CurrentTimeMillis());
                }

                return(container.SetSyncMessage(syncMessage.SetSent(sentMessage)).Build().ToByteArray());
            }
            catch (InvalidProtocolBufferException e)
            {
                throw new Exception(e.Message);
            }
        }
Ejemplo n.º 3
0
        private async Task <byte[]> createMultiDeviceGroupsContent(SignalServiceAttachmentStream groups)
        {
            Content.Builder     container = Content.CreateBuilder();
            SyncMessage.Builder builder   = SyncMessage.CreateBuilder();
            builder.SetGroups(SyncMessage.Types.Groups.CreateBuilder()
                              .SetBlob(await createAttachmentPointer(groups)));

            return(container.SetSyncMessage(builder).Build().ToByteArray());
        }
        private async Task <byte[]> createMultiDeviceContactsContent(TextSecureAttachmentStream contacts)
        {
            Content.Builder     container = Content.CreateBuilder();
            SyncMessage.Builder builder   = SyncMessage.CreateBuilder();
            builder.SetContacts(SyncMessage.Types.Contacts.CreateBuilder()
                                .SetBlob(await createAttachmentPointer(contacts)));

            return(container.SetSyncMessage(builder).Build().ToByteArray());
        }
Ejemplo n.º 5
0
        private byte[] createMultiDeviceBlockedContent(BlockedListMessage blocked)
        {
            Content.Builder     container   = Content.CreateBuilder();
            SyncMessage.Builder syncMessage = SyncMessage.CreateBuilder();
            SyncMessage.Types.Blocked.Builder blockedMessage = SyncMessage.Types.Blocked.CreateBuilder();

            blockedMessage.AddRangeNumbers(blocked.getNumbers());

            return(container.SetSyncMessage(syncMessage.SetBlocked(blockedMessage)).Build().ToByteArray());
        }
Ejemplo n.º 6
0
        private byte[] createMultiDeviceReadContent(List <ReadMessage> readMessages)
        {
            Content.Builder     container = Content.CreateBuilder();
            SyncMessage.Builder builder   = SyncMessage.CreateBuilder();

            foreach (ReadMessage readMessage in readMessages)
            {
                builder.AddRead(SyncMessage.Types.Read.CreateBuilder()
                                .SetTimestamp((ulong)readMessage.getTimestamp())
                                .SetSender(readMessage.getSender()));
            }

            return(container.SetSyncMessage(builder).Build().ToByteArray());
        }