Search in sources :

Example 1 with Sticker

use of org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Sticker in project libsignal-service-java by signalapp.

the class SignalServiceCipher method createSignalServiceMessage.

private SignalServiceDataMessage createSignalServiceMessage(Metadata metadata, DataMessage content) throws ProtocolInvalidMessageException, UnsupportedDataMessageException {
    SignalServiceGroup groupInfo = createGroupInfo(content);
    List<SignalServiceAttachment> attachments = new LinkedList<>();
    boolean endSession = ((content.getFlags() & DataMessage.Flags.END_SESSION_VALUE) != 0);
    boolean expirationUpdate = ((content.getFlags() & DataMessage.Flags.EXPIRATION_TIMER_UPDATE_VALUE) != 0);
    boolean profileKeyUpdate = ((content.getFlags() & DataMessage.Flags.PROFILE_KEY_UPDATE_VALUE) != 0);
    SignalServiceDataMessage.Quote quote = createQuote(content);
    List<SharedContact> sharedContacts = createSharedContacts(content);
    List<Preview> previews = createPreviews(content);
    Sticker sticker = createSticker(content);
    if (content.getRequiredProtocolVersion() > DataMessage.ProtocolVersion.CURRENT.getNumber()) {
        throw new UnsupportedDataMessageException(DataMessage.ProtocolVersion.CURRENT.getNumber(), content.getRequiredProtocolVersion(), metadata.getSender().getIdentifier(), metadata.getSenderDevice(), Optional.fromNullable(groupInfo));
    }
    for (AttachmentPointer pointer : content.getAttachmentsList()) {
        attachments.add(createAttachmentPointer(pointer));
    }
    if (content.hasTimestamp() && content.getTimestamp() != metadata.getTimestamp()) {
        throw new ProtocolInvalidMessageException(new InvalidMessageException("Timestamps don't match: " + content.getTimestamp() + " vs " + metadata.getTimestamp()), metadata.getSender().getIdentifier(), metadata.getSenderDevice());
    }
    return new SignalServiceDataMessage(metadata.getTimestamp(), groupInfo, attachments, content.getBody(), endSession, content.getExpireTimer(), expirationUpdate, content.hasProfileKey() ? content.getProfileKey().toByteArray() : null, profileKeyUpdate, quote, sharedContacts, previews, sticker, content.getIsViewOnce());
}
Also used : ProtocolInvalidMessageException(org.signal.libsignal.metadata.ProtocolInvalidMessageException) InvalidMessageException(org.whispersystems.libsignal.InvalidMessageException) ProtocolInvalidMessageException(org.signal.libsignal.metadata.ProtocolInvalidMessageException) Preview(org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Preview) LinkedList(java.util.LinkedList) Sticker(org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Sticker) SignalServiceAttachment(org.whispersystems.signalservice.api.messages.SignalServiceAttachment) SignalServiceDataMessage(org.whispersystems.signalservice.api.messages.SignalServiceDataMessage) UnsupportedDataMessageException(org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException) SignalServiceGroup(org.whispersystems.signalservice.api.messages.SignalServiceGroup) SharedContact(org.whispersystems.signalservice.api.messages.shared.SharedContact) SignalServiceAttachmentPointer(org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer) AttachmentPointer(org.whispersystems.signalservice.internal.push.SignalServiceProtos.AttachmentPointer)

Aggregations

LinkedList (java.util.LinkedList)1 ProtocolInvalidMessageException (org.signal.libsignal.metadata.ProtocolInvalidMessageException)1 InvalidMessageException (org.whispersystems.libsignal.InvalidMessageException)1 SignalServiceAttachment (org.whispersystems.signalservice.api.messages.SignalServiceAttachment)1 SignalServiceAttachmentPointer (org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer)1 SignalServiceDataMessage (org.whispersystems.signalservice.api.messages.SignalServiceDataMessage)1 Preview (org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Preview)1 Sticker (org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Sticker)1 SignalServiceGroup (org.whispersystems.signalservice.api.messages.SignalServiceGroup)1 SharedContact (org.whispersystems.signalservice.api.messages.shared.SharedContact)1 AttachmentPointer (org.whispersystems.signalservice.internal.push.SignalServiceProtos.AttachmentPointer)1 UnsupportedDataMessageException (org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException)1