org.whispersystems.signalservice.api.messages.multidevice.ReadMessage Java Examples

The following examples show how to use org.whispersystems.signalservice.api.messages.multidevice.ReadMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignalServiceMessageSender.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private byte[] createMultiDeviceReadContent(List<ReadMessage> readMessages) {
  Content.Builder     container = Content.newBuilder();
  SyncMessage.Builder builder   = createSyncMessageBuilder();

  for (ReadMessage readMessage : readMessages) {
    SyncMessage.Read.Builder readBuilder = SyncMessage.Read.newBuilder().setTimestamp(readMessage.getTimestamp());

    if (readMessage.getSender().getUuid().isPresent()) {
      readBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString());
    }

    if (readMessage.getSender().getNumber().isPresent()) {
      readBuilder.setSenderE164(readMessage.getSender().getNumber().get());
    }

    builder.addRead(readBuilder.build());
  }

  return container.setSyncMessage(builder).build().toByteArray();
}
 
Example #2
Source File: MultiDeviceReadUpdateJob.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onRun() throws IOException, UntrustedIdentityException {
  if (!TextSecurePreferences.isMultiDevice(context)) {
    Log.i(TAG, "Not multi device...");
    return;
  }

  List<ReadMessage> readMessages = new LinkedList<>();

  for (SerializableSyncMessageId messageId : messageIds) {
    Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId));
    readMessages.add(new ReadMessage(RecipientUtil.toSignalServiceAddress(context, recipient), messageId.timestamp));
  }

  SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
  messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages), UnidentifiedAccessUtil.getAccessForSync(context));
}
 
Example #3
Source File: SignalServiceMessageSender.java    From libsignal-service-java with GNU General Public License v3.0 6 votes vote down vote up
private byte[] createMultiDeviceReadContent(List<ReadMessage> readMessages) {
  Content.Builder     container = Content.newBuilder();
  SyncMessage.Builder builder   = createSyncMessageBuilder();

  for (ReadMessage readMessage : readMessages) {
    SyncMessage.Read.Builder readBuilder = SyncMessage.Read.newBuilder().setTimestamp(readMessage.getTimestamp());

    if (readMessage.getSender().getUuid().isPresent()) {
      readBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString());
    }

    if (readMessage.getSender().getNumber().isPresent()) {
      readBuilder.setSenderE164(readMessage.getSender().getNumber().get());
    }

    builder.addRead(readBuilder.build());
  }

  return container.setSyncMessage(builder).build().toByteArray();
}
 
Example #4
Source File: PushDecryptJob.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private void handleSynchronizeReadMessage(@NonNull List<ReadMessage> readMessages,
                                          long envelopeTimestamp) {
    ALog.i(TAG, "handleSynchronizeReadMessage");

    for (ReadMessage readMessage : readMessages) {
        List<kotlin.Pair<Long, Long>> expiring = repository.getChatRepo().setTimestampRead(readMessage.getSender(), readMessage.getTimestamp(), envelopeTimestamp);

        IExpiringScheduler manager = ExpirationManager.INSTANCE.get(accountContext);
        for (Pair<Long, Long> expiringMessage : expiring) {
            manager.scheduleDeletion(expiringMessage.getFirst(), false, envelopeTimestamp, expiringMessage.getSecond());
        }

    }
}
 
Example #5
Source File: SignalServiceCipher.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
private SignalServiceSyncMessage createSynchronizeMessage(SignalServiceProtos.Envelope envelope, SyncMessage content) throws InvalidMessageException {
  if (content.hasSent()) {
    SyncMessage.Sent sentContent = content.getSent();
    return SignalServiceSyncMessage.forSentTranscript(new SentTranscriptMessage(sentContent.getDestination(),
                                                                                sentContent.getTimestamp(),
                                                                                createSignalServiceMessage(envelope, sentContent.getMessage()),
                                                                                sentContent.getExpirationStartTimestamp()));
  }

  if (content.hasRequest()) {
    return SignalServiceSyncMessage.forRequest(new RequestMessage(content.getRequest()));
  }

  if (content.getReadList().size() > 0) {
    List<ReadMessage> readMessages = new LinkedList<>();

    for (SyncMessage.Read read : content.getReadList()) {
      readMessages.add(new ReadMessage(read.getSender(), read.getTimestamp()));
    }

    return SignalServiceSyncMessage.forRead(readMessages);
  }

  if (content.hasVerified()) {
    try {
      Verified    verified    = content.getVerified();
      String      destination = verified.getDestination();
      IdentityKey identityKey = new IdentityKey(verified.getIdentityKey().toByteArray(), 0);

      VerifiedState verifiedState;

      if (verified.getState() == Verified.State.DEFAULT) {
        verifiedState = VerifiedState.DEFAULT;
      } else if (verified.getState() == Verified.State.VERIFIED) {
        verifiedState = VerifiedState.VERIFIED;
      } else if (verified.getState() == Verified.State.UNVERIFIED) {
        verifiedState = VerifiedState.UNVERIFIED;
      } else {
        throw new InvalidMessageException("Unknown state: " + verified.getState().getNumber());
      }

      return SignalServiceSyncMessage.forVerified(new VerifiedMessage(destination, identityKey, verifiedState, System.currentTimeMillis()));
    } catch (InvalidKeyException e) {
      throw new InvalidMessageException(e);
    }
  }

  return SignalServiceSyncMessage.empty();
}
 
Example #6
Source File: SignalBot.java    From signal-bot with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void onReadUpdate(List<ReadMessage> readList) {}