private void handleTextMessage(/*@NonNull MasterSecretUnion masterSecret,*/ SignalServiceEnvelope envelope, SignalServiceDataMessage 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(), DatabaseFactory.getDirectoryDatabase().GetForNumber(envelope.getSource()).Name, body); }
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()); }