use of org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptMessage in project libsignal-service-java by signalapp.
the class SignalServiceCipher method createSynchronizeMessage.
private SignalServiceSyncMessage createSynchronizeMessage(SignalServiceEnvelope 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();
}
Aggregations