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(createGroupContent(message.getGroupInfo().ForceGetValue())); } if (message.isEndSession()) { builder.SetFlags((uint)DataMessage.Types.Flags.END_SESSION); } return builder.Build().ToByteArray(); }
private void handleTextMessage(/*@NonNull MasterSecretUnion masterSecret,*/ TextSecureEnvelope envelope, TextSecureDataMessage message, May<long> smsMessageId) { var textMessageDatabase = DatabaseFactory.getTextMessageDatabase(); String body = message.getBody().HasValue ? message.getBody().ForceGetValue() : ""; IncomingTextMessage textMessage = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(), message.getTimestamp(), body, message.getGroupInfo()); textMessage = new IncomingEncryptedMessage(textMessage, body); var messageAndThreadId = textMessageDatabase.InsertMessageInbox(textMessage); ToastHelper.NotifyNewMessage(messageAndThreadId.second()); }