private void handleEndSessionMessage(SignalServiceEnvelope envelope, SignalServiceDataMessage message, May <long> smsMessageId) { var smsDatabase = DatabaseFactory.getTextMessageDatabase();//getEncryptingSmsDatabase(context); var incomingTextMessage = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(), message.getTimestamp(), "", May <SignalServiceGroup> .NoValue); long threadId; if (!smsMessageId.HasValue) { IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage); Pair <long, long> messageAndThreadId = smsDatabase.InsertMessageInbox(incomingEndSessionMessage); threadId = messageAndThreadId.second(); } else { var messageId = smsMessageId.ForceGetValue(); smsDatabase.MarkAsEndSession(messageId); threadId = smsDatabase.GetThreadIdForMessage(messageId); } SessionStore sessionStore = new TextSecureAxolotlStore(); sessionStore.DeleteAllSessions(envelope.getSource()); //SecurityEvent.broadcastSecurityUpdateEvent(context, threadId); //MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), threadId); }
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); }
/// <summary> /// Send a message to a group. /// </summary> /// <param name="recipients">The group members.</param> /// <param name="message">The group message.</param> public async Task sendMessage(List <SignalServiceAddress> recipients, SignalServiceDataMessage message) { byte[] content = await createMessageContent(message); long timestamp = message.getTimestamp(); SendMessageResponse response = await sendMessage(recipients, timestamp, content, true); try { if (response != null && response.getNeedsSync()) { byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, May <SignalServiceAddress> .NoValue, (ulong)timestamp); await sendMessage(localAddress, timestamp, syncMessage, false, false); } } catch (UntrustedIdentityException e) { throw new EncapsulatedExceptions(e); } }
/// <summary> /// Send a message to a single recipient. /// </summary> /// <param name="recipient">The message's destination.</param> /// <param name="message">The message.</param> public async Task sendMessage(SignalServiceAddress recipient, SignalServiceDataMessage message) { byte[] content = await createMessageContent(message); long timestamp = message.getTimestamp(); bool silent = message.getGroupInfo().HasValue&& message.getGroupInfo().ForceGetValue().getType() == SignalServiceGroup.Type.REQUEST_INFO; SendMessageResponse response = await sendMessage(recipient, timestamp, content, true, silent); if (response != null && response.getNeedsSync()) { byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, new May <SignalServiceAddress>(recipient), (ulong)timestamp); await sendMessage(localAddress, timestamp, syncMessage, false, false); } if (message.isEndSession()) { store.DeleteAllSessions(recipient.getNumber()); if (eventListener.HasValue) { eventListener.ForceGetValue().onSecurityEvent(recipient); } } }