Search in sources :

Example 1 with ReadMessage

use of org.whispersystems.signalservice.api.messages.multidevice.ReadMessage in project Signal-Android by WhisperSystems.

the class MultiDeviceReadUpdateJob method onRun.

@Override
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
    if (!TextSecurePreferences.isMultiDevice(context)) {
        Log.w(TAG, "Not multi device...");
        return;
    }
    List<ReadMessage> readMessages = new LinkedList<>();
    for (SerializableSyncMessageId messageId : messageIds) {
        readMessages.add(new ReadMessage(messageId.sender, messageId.timestamp));
    }
    SignalServiceMessageSender messageSender = messageSenderFactory.create();
    messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages));
}
Also used : ReadMessage(org.whispersystems.signalservice.api.messages.multidevice.ReadMessage) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) LinkedList(java.util.LinkedList)

Example 2 with ReadMessage

use of org.whispersystems.signalservice.api.messages.multidevice.ReadMessage in project Signal-Android by WhisperSystems.

the class PushDecryptJob method handleSynchronizeReadMessage.

private void handleSynchronizeReadMessage(@NonNull MasterSecretUnion masterSecret, @NonNull List<ReadMessage> readMessages, long envelopeTimestamp) {
    for (ReadMessage readMessage : readMessages) {
        List<Pair<Long, Long>> expiringText = DatabaseFactory.getSmsDatabase(context).setTimestampRead(new SyncMessageId(readMessage.getSender(), readMessage.getTimestamp()), envelopeTimestamp);
        List<Pair<Long, Long>> expiringMedia = DatabaseFactory.getMmsDatabase(context).setTimestampRead(new SyncMessageId(readMessage.getSender(), readMessage.getTimestamp()), envelopeTimestamp);
        for (Pair<Long, Long> expiringMessage : expiringText) {
            ApplicationContext.getInstance(context).getExpiringMessageManager().scheduleDeletion(expiringMessage.first, false, envelopeTimestamp, expiringMessage.second);
        }
        for (Pair<Long, Long> expiringMessage : expiringMedia) {
            ApplicationContext.getInstance(context).getExpiringMessageManager().scheduleDeletion(expiringMessage.first, true, envelopeTimestamp, expiringMessage.second);
        }
    }
    MessageNotifier.setLastDesktopActivityTimestamp(envelopeTimestamp);
    MessageNotifier.cancelDelayedNotifications();
    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull());
}
Also used : ReadMessage(org.whispersystems.signalservice.api.messages.multidevice.ReadMessage) SyncMessageId(org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId) Pair(android.util.Pair)

Aggregations

ReadMessage (org.whispersystems.signalservice.api.messages.multidevice.ReadMessage)2 Pair (android.util.Pair)1 LinkedList (java.util.LinkedList)1 SyncMessageId (org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId)1 SignalServiceMessageSender (org.whispersystems.signalservice.api.SignalServiceMessageSender)1