private async Task <byte[]> createMessageContent(TextSecureDataMessage message)// throws IOException
        {
            DataMessage.Builder builder = DataMessage.CreateBuilder();

            /*List<AttachmentPointer> pointers = createAttachmentPointers(message.getAttachments());
             *
             * if (!pointers.Any()) // TODO:check
             * {
             *  builder.AddRangeAttachments(pointers);
             * }*/

            if (message.getBody().HasValue)
            {
                builder.SetBody(message.getBody().ForceGetValue());
            }

            if (message.getGroupInfo().HasValue)
            {
                builder.SetGroup(await createGroupContent(message.getGroupInfo().ForceGetValue()));
            }

            if (message.isEndSession())
            {
                builder.SetFlags((uint)DataMessage.Types.Flags.END_SESSION);
            }

            return(builder.Build().ToByteArray());
        }
Esempio n. 2
0
        private async Task <byte[]> createMessageContent(SignalServiceDataMessage message)// throws IOException
        {
            DataMessage.Builder       builder  = DataMessage.CreateBuilder();
            IList <AttachmentPointer> pointers = await createAttachmentPointers(message.getAttachments());

            if (pointers.Count != 0)
            {
                builder.AddRangeAttachments(pointers);
            }

            if (message.getBody().HasValue)
            {
                builder.SetBody(message.getBody().ForceGetValue());
            }

            if (message.getGroupInfo().HasValue)
            {
                builder.SetGroup(await createGroupContent(message.getGroupInfo().ForceGetValue()));
            }

            if (message.isEndSession())
            {
                builder.SetFlags((uint)DataMessage.Types.Flags.END_SESSION);
            }

            if (message.isExpirationUpdate())
            {
                builder.SetFlags((uint)DataMessage.Types.Flags.EXPIRATION_TIMER_UPDATE);
            }

            if (message.getExpiresInSeconds() > 0)
            {
                builder.SetExpireTimer((uint)message.getExpiresInSeconds());
            }

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