Record Class MessageContainer

java.lang.Object
java.lang.Record
it.auties.whatsapp.model.message.model.MessageContainer
All Implemented Interfaces:
it.auties.protobuf.model.ProtobufMessage, it.auties.protobuf.model.ProtobufObject

public record MessageContainer(Optional<String> textWithNoContextMessage, Optional<SenderKeyDistributionMessage> senderKeyDistributionMessage, Optional<ImageMessage> imageMessage, Optional<ContactMessage> contactMessage, Optional<LocationMessage> locationMessage, Optional<TextMessage> textMessage, Optional<DocumentMessage> documentMessage, Optional<AudioMessage> audioMessage, Optional<VideoOrGifMessage> videoMessage, Optional<CallMessage> callMessage, Optional<ProtocolMessage> protocolMessage, Optional<ContactsMessage> contactsArrayMessage, Optional<HighlyStructuredMessage> highlyStructuredMessage, Optional<SendPaymentMessage> sendPaymentMessage, Optional<LiveLocationMessage> liveLocationMessage, Optional<RequestPaymentMessage> requestPaymentMessage, Optional<DeclinePaymentRequestMessage> declinePaymentRequestMessage, Optional<CancelPaymentRequestMessage> cancelPaymentRequestMessage, Optional<TemplateMessage> templateMessage, Optional<StickerMessage> stickerMessage, Optional<GroupInviteMessage> groupInviteMessage, Optional<TemplateReplyMessage> templateReplyMessage, Optional<ProductMessage> productMessage, Optional<DeviceSentMessage> deviceSentMessage, Optional<DeviceSyncMessage> deviceSyncMessage, Optional<ListMessage> listMessage, Optional<FutureMessageContainer> viewOnceMessage, Optional<PaymentOrderMessage> orderMessage, Optional<ListResponseMessage> listResponseMessage, Optional<FutureMessageContainer> ephemeralMessage, Optional<PaymentInvoiceMessage> invoiceMessage, Optional<ButtonsMessage> buttonsMessage, Optional<ButtonsResponseMessage> buttonsResponseMessage, Optional<PaymentInviteMessage> paymentInviteMessage, Optional<InteractiveMessage> interactiveMessage, Optional<ReactionMessage> reactionMessage, Optional<StickerSyncRMRMessage> stickerSyncMessage, Optional<InteractiveResponseMessage> interactiveResponseMessage, Optional<PollCreationMessage> pollCreationMessage, Optional<PollUpdateMessage> pollUpdateMessage, Optional<KeepInChatMessage> keepInChatMessage, Optional<FutureMessageContainer> documentWithCaptionMessage, Optional<RequestPhoneNumberMessage> requestPhoneNumberMessage, Optional<FutureMessageContainer> viewOnceV2Message, Optional<EncryptedReactionMessage> encryptedReactionMessage, Optional<FutureMessageContainer> editedMessage, Optional<FutureMessageContainer> viewOnceV2ExtensionMessage, Optional<NewsletterAdminInviteMessage> newsletterAdminInviteMessage, Optional<DeviceContextInfo> deviceInfo) extends Record implements it.auties.protobuf.model.ProtobufMessage
A container for all types of messages known currently to WhatsappWeb.

Only one of these properties should be populated, however it's not certain as Whatsapp's Protobuf doesn't use a one of instruction as it would be logical to in said case. This may imply that in some particular and rare cases more than one property can be populated.

There are several categories of messages:

  • Server messages
  • Button messages
  • Product messages
  • Payment messages
  • Standard messages
  • Field Details

    • textWithNoContextMessage

      private final Optional<String> textWithNoContextMessage
      The field for the textWithNoContextMessage record component.
    • senderKeyDistributionMessage

      private final Optional<SenderKeyDistributionMessage> senderKeyDistributionMessage
      The field for the senderKeyDistributionMessage record component.
    • imageMessage

      private final Optional<ImageMessage> imageMessage
      The field for the imageMessage record component.
    • contactMessage

      private final Optional<ContactMessage> contactMessage
      The field for the contactMessage record component.
    • locationMessage

      private final Optional<LocationMessage> locationMessage
      The field for the locationMessage record component.
    • textMessage

      private final Optional<TextMessage> textMessage
      The field for the textMessage record component.
    • documentMessage

      private final Optional<DocumentMessage> documentMessage
      The field for the documentMessage record component.
    • audioMessage

      private final Optional<AudioMessage> audioMessage
      The field for the audioMessage record component.
    • videoMessage

      private final Optional<VideoOrGifMessage> videoMessage
      The field for the videoMessage record component.
    • callMessage

      private final Optional<CallMessage> callMessage
      The field for the callMessage record component.
    • protocolMessage

      private final Optional<ProtocolMessage> protocolMessage
      The field for the protocolMessage record component.
    • contactsArrayMessage

      private final Optional<ContactsMessage> contactsArrayMessage
      The field for the contactsArrayMessage record component.
    • highlyStructuredMessage

      private final Optional<HighlyStructuredMessage> highlyStructuredMessage
      The field for the highlyStructuredMessage record component.
    • sendPaymentMessage

      private final Optional<SendPaymentMessage> sendPaymentMessage
      The field for the sendPaymentMessage record component.
    • liveLocationMessage

      private final Optional<LiveLocationMessage> liveLocationMessage
      The field for the liveLocationMessage record component.
    • requestPaymentMessage

      private final Optional<RequestPaymentMessage> requestPaymentMessage
      The field for the requestPaymentMessage record component.
    • declinePaymentRequestMessage

      private final Optional<DeclinePaymentRequestMessage> declinePaymentRequestMessage
      The field for the declinePaymentRequestMessage record component.
    • cancelPaymentRequestMessage

      private final Optional<CancelPaymentRequestMessage> cancelPaymentRequestMessage
      The field for the cancelPaymentRequestMessage record component.
    • templateMessage

      private final Optional<TemplateMessage> templateMessage
      The field for the templateMessage record component.
    • stickerMessage

      private final Optional<StickerMessage> stickerMessage
      The field for the stickerMessage record component.
    • groupInviteMessage

      private final Optional<GroupInviteMessage> groupInviteMessage
      The field for the groupInviteMessage record component.
    • templateReplyMessage

      private final Optional<TemplateReplyMessage> templateReplyMessage
      The field for the templateReplyMessage record component.
    • productMessage

      private final Optional<ProductMessage> productMessage
      The field for the productMessage record component.
    • deviceSentMessage

      private final Optional<DeviceSentMessage> deviceSentMessage
      The field for the deviceSentMessage record component.
    • deviceSyncMessage

      private final Optional<DeviceSyncMessage> deviceSyncMessage
      The field for the deviceSyncMessage record component.
    • listMessage

      private final Optional<ListMessage> listMessage
      The field for the listMessage record component.
    • viewOnceMessage

      private final Optional<FutureMessageContainer> viewOnceMessage
      The field for the viewOnceMessage record component.
    • orderMessage

      private final Optional<PaymentOrderMessage> orderMessage
      The field for the orderMessage record component.
    • listResponseMessage

      private final Optional<ListResponseMessage> listResponseMessage
      The field for the listResponseMessage record component.
    • ephemeralMessage

      private final Optional<FutureMessageContainer> ephemeralMessage
      The field for the ephemeralMessage record component.
    • invoiceMessage

      private final Optional<PaymentInvoiceMessage> invoiceMessage
      The field for the invoiceMessage record component.
    • buttonsMessage

      private final Optional<ButtonsMessage> buttonsMessage
      The field for the buttonsMessage record component.
    • buttonsResponseMessage

      private final Optional<ButtonsResponseMessage> buttonsResponseMessage
      The field for the buttonsResponseMessage record component.
    • paymentInviteMessage

      private final Optional<PaymentInviteMessage> paymentInviteMessage
      The field for the paymentInviteMessage record component.
    • interactiveMessage

      private final Optional<InteractiveMessage> interactiveMessage
      The field for the interactiveMessage record component.
    • reactionMessage

      private final Optional<ReactionMessage> reactionMessage
      The field for the reactionMessage record component.
    • stickerSyncMessage

      private final Optional<StickerSyncRMRMessage> stickerSyncMessage
      The field for the stickerSyncMessage record component.
    • interactiveResponseMessage

      private final Optional<InteractiveResponseMessage> interactiveResponseMessage
      The field for the interactiveResponseMessage record component.
    • pollCreationMessage

      private final Optional<PollCreationMessage> pollCreationMessage
      The field for the pollCreationMessage record component.
    • pollUpdateMessage

      private final Optional<PollUpdateMessage> pollUpdateMessage
      The field for the pollUpdateMessage record component.
    • keepInChatMessage

      private final Optional<KeepInChatMessage> keepInChatMessage
      The field for the keepInChatMessage record component.
    • documentWithCaptionMessage

      private final Optional<FutureMessageContainer> documentWithCaptionMessage
      The field for the documentWithCaptionMessage record component.
    • requestPhoneNumberMessage

      private final Optional<RequestPhoneNumberMessage> requestPhoneNumberMessage
      The field for the requestPhoneNumberMessage record component.
    • viewOnceV2Message

      private final Optional<FutureMessageContainer> viewOnceV2Message
      The field for the viewOnceV2Message record component.
    • encryptedReactionMessage

      private final Optional<EncryptedReactionMessage> encryptedReactionMessage
      The field for the encryptedReactionMessage record component.
    • editedMessage

      private final Optional<FutureMessageContainer> editedMessage
      The field for the editedMessage record component.
    • viewOnceV2ExtensionMessage

      private final Optional<FutureMessageContainer> viewOnceV2ExtensionMessage
      The field for the viewOnceV2ExtensionMessage record component.
    • newsletterAdminInviteMessage

      private final Optional<NewsletterAdminInviteMessage> newsletterAdminInviteMessage
      The field for the newsletterAdminInviteMessage record component.
    • deviceInfo

      private final Optional<DeviceContextInfo> deviceInfo
      The field for the deviceInfo record component.
    • EMPTY_MESSAGE

      private static final EmptyMessage EMPTY_MESSAGE
      An empty message
  • Constructor Details

  • Method Details

    • empty

      public static MessageContainer empty()
      Returns an empty message container
      Returns:
      a non-null container
    • of

      public static <T extends Message> MessageContainer of(T message)
      Constructs a new MessageContainer from a message of any type
      Type Parameters:
      T - the type of the message
      Parameters:
      message - the message that the new container should wrap
      Returns:
      a non-null container
    • ofBuilder

      public static <T extends Message> MessageContainerBuilder ofBuilder(T message)
      Constructs a new MessageContainerBuilder from a message of any type
      Type Parameters:
      T - the type of the message
      Parameters:
      message - the message that the new container should wrap
      Returns:
      a non-null builder
    • of

      public static MessageContainer of(String message)
      Constructs a new MessageContainer from a text message
      Parameters:
      message - the text message with no context
    • ofViewOnce

      public static <T extends Message> MessageContainer ofViewOnce(T message)
      Constructs a new MessageContainer from a message of any type that can only be seen once
      Type Parameters:
      T - the type of the message
      Parameters:
      message - the message that the new container should wrap
    • ofViewOnceV2

      public static <T extends Message> MessageContainer ofViewOnceV2(T message)
      Constructs a new MessageContainer from a message of any type that can only be seen once(version v2)
      Type Parameters:
      T - the type of the message
      Parameters:
      message - the message that the new container should wrap
    • ofEphemeral

      public static <T extends Message> MessageContainer ofEphemeral(T message)
      Constructs a new MessageContainer from a message of any type marking it as ephemeral
      Type Parameters:
      T - the type of the message
      Parameters:
      message - the message that the new container should wrap
    • ofEditedMessage

      public static <T extends Message> MessageContainer ofEditedMessage(T message)
      Constructs a new MessageContainer from an edited message
      Type Parameters:
      T - the type of the message
      Parameters:
      message - the message that the new container should wrap
    • ofDocumentWithCaption

      public static <T extends Message> MessageContainer ofDocumentWithCaption(T message)
      Constructs a new MessageContainer from a document with caption message
      Type Parameters:
      T - the type of the message
      Parameters:
      message - the message that the new container should wrap
    • content

      public Message content()
      Returns the first populated message inside this container. If no message is found, EmptyMessage is returned
      Returns:
      a non-null message
    • contentWithContext

      public Optional<ContextualMessage<?>> contentWithContext()
      Returns the first populated contextual message inside this container
      Returns:
      a non-null Optional ContextualMessage
    • hasType

      public boolean hasType(MessageType type)
      Checks whether the message that this container wraps matches the provided type
      Parameters:
      type - the non-null type to check against
      Returns:
      a boolean
    • hasCategory

      public boolean hasCategory(MessageCategory category)
      Checks whether the message that this container wraps matches the provided category
      Parameters:
      category - the non-null category to check against
      Returns:
      a boolean
    • type

      public MessageType type()
      Returns the type of the message
      Returns:
      a non-null type
    • deepType

      public MessageType deepType()
      Returns the deep type of the message unwrapping ephemeral and view once messages
      Returns:
      a non-null type
    • category

      public MessageCategory category()
      Returns the category of the message
      Returns:
      a non-null category
    • toEphemeral

      public MessageContainer toEphemeral()
      Converts this message to an ephemeral message
      Returns:
      a non-null message container
    • toViewOnce

      public MessageContainer toViewOnce()
      Converts this message to a view once message
      Returns:
      a non-null message container
    • unbox

      public MessageContainer unbox()
      Returns an unboxed message where are all future-proof messages(i.e. ephemeral and view once) have been unboxed
      Returns:
      a non-null message container
    • withDeviceInfo

      public MessageContainer withDeviceInfo(DeviceContextInfo deviceInfo)
      Returns a copy of this container with a different device info
      Returns:
      a non-null message container
    • isEmpty

      public boolean isEmpty()
      Returns whether this container is empty
      Returns:
      a boolean
    • toString

      public String toString()
      Converts this container into a String
      Specified by:
      toString in class Record
      Returns:
      a non-null String
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • textWithNoContextMessage

      public Optional<String> textWithNoContextMessage()
      Returns the value of the textWithNoContextMessage record component.
      Returns:
      the value of the textWithNoContextMessage record component
    • senderKeyDistributionMessage

      public Optional<SenderKeyDistributionMessage> senderKeyDistributionMessage()
      Returns the value of the senderKeyDistributionMessage record component.
      Returns:
      the value of the senderKeyDistributionMessage record component
    • imageMessage

      public Optional<ImageMessage> imageMessage()
      Returns the value of the imageMessage record component.
      Returns:
      the value of the imageMessage record component
    • contactMessage

      public Optional<ContactMessage> contactMessage()
      Returns the value of the contactMessage record component.
      Returns:
      the value of the contactMessage record component
    • locationMessage

      public Optional<LocationMessage> locationMessage()
      Returns the value of the locationMessage record component.
      Returns:
      the value of the locationMessage record component
    • textMessage

      public Optional<TextMessage> textMessage()
      Returns the value of the textMessage record component.
      Returns:
      the value of the textMessage record component
    • documentMessage

      public Optional<DocumentMessage> documentMessage()
      Returns the value of the documentMessage record component.
      Returns:
      the value of the documentMessage record component
    • audioMessage

      public Optional<AudioMessage> audioMessage()
      Returns the value of the audioMessage record component.
      Returns:
      the value of the audioMessage record component
    • videoMessage

      public Optional<VideoOrGifMessage> videoMessage()
      Returns the value of the videoMessage record component.
      Returns:
      the value of the videoMessage record component
    • callMessage

      public Optional<CallMessage> callMessage()
      Returns the value of the callMessage record component.
      Returns:
      the value of the callMessage record component
    • protocolMessage

      public Optional<ProtocolMessage> protocolMessage()
      Returns the value of the protocolMessage record component.
      Returns:
      the value of the protocolMessage record component
    • contactsArrayMessage

      public Optional<ContactsMessage> contactsArrayMessage()
      Returns the value of the contactsArrayMessage record component.
      Returns:
      the value of the contactsArrayMessage record component
    • highlyStructuredMessage

      public Optional<HighlyStructuredMessage> highlyStructuredMessage()
      Returns the value of the highlyStructuredMessage record component.
      Returns:
      the value of the highlyStructuredMessage record component
    • sendPaymentMessage

      public Optional<SendPaymentMessage> sendPaymentMessage()
      Returns the value of the sendPaymentMessage record component.
      Returns:
      the value of the sendPaymentMessage record component
    • liveLocationMessage

      public Optional<LiveLocationMessage> liveLocationMessage()
      Returns the value of the liveLocationMessage record component.
      Returns:
      the value of the liveLocationMessage record component
    • requestPaymentMessage

      public Optional<RequestPaymentMessage> requestPaymentMessage()
      Returns the value of the requestPaymentMessage record component.
      Returns:
      the value of the requestPaymentMessage record component
    • declinePaymentRequestMessage

      public Optional<DeclinePaymentRequestMessage> declinePaymentRequestMessage()
      Returns the value of the declinePaymentRequestMessage record component.
      Returns:
      the value of the declinePaymentRequestMessage record component
    • cancelPaymentRequestMessage

      public Optional<CancelPaymentRequestMessage> cancelPaymentRequestMessage()
      Returns the value of the cancelPaymentRequestMessage record component.
      Returns:
      the value of the cancelPaymentRequestMessage record component
    • templateMessage

      public Optional<TemplateMessage> templateMessage()
      Returns the value of the templateMessage record component.
      Returns:
      the value of the templateMessage record component
    • stickerMessage

      public Optional<StickerMessage> stickerMessage()
      Returns the value of the stickerMessage record component.
      Returns:
      the value of the stickerMessage record component
    • groupInviteMessage

      public Optional<GroupInviteMessage> groupInviteMessage()
      Returns the value of the groupInviteMessage record component.
      Returns:
      the value of the groupInviteMessage record component
    • templateReplyMessage

      public Optional<TemplateReplyMessage> templateReplyMessage()
      Returns the value of the templateReplyMessage record component.
      Returns:
      the value of the templateReplyMessage record component
    • productMessage

      public Optional<ProductMessage> productMessage()
      Returns the value of the productMessage record component.
      Returns:
      the value of the productMessage record component
    • deviceSentMessage

      public Optional<DeviceSentMessage> deviceSentMessage()
      Returns the value of the deviceSentMessage record component.
      Returns:
      the value of the deviceSentMessage record component
    • deviceSyncMessage

      public Optional<DeviceSyncMessage> deviceSyncMessage()
      Returns the value of the deviceSyncMessage record component.
      Returns:
      the value of the deviceSyncMessage record component
    • listMessage

      public Optional<ListMessage> listMessage()
      Returns the value of the listMessage record component.
      Returns:
      the value of the listMessage record component
    • viewOnceMessage

      public Optional<FutureMessageContainer> viewOnceMessage()
      Returns the value of the viewOnceMessage record component.
      Returns:
      the value of the viewOnceMessage record component
    • orderMessage

      public Optional<PaymentOrderMessage> orderMessage()
      Returns the value of the orderMessage record component.
      Returns:
      the value of the orderMessage record component
    • listResponseMessage

      public Optional<ListResponseMessage> listResponseMessage()
      Returns the value of the listResponseMessage record component.
      Returns:
      the value of the listResponseMessage record component
    • ephemeralMessage

      public Optional<FutureMessageContainer> ephemeralMessage()
      Returns the value of the ephemeralMessage record component.
      Returns:
      the value of the ephemeralMessage record component
    • invoiceMessage

      public Optional<PaymentInvoiceMessage> invoiceMessage()
      Returns the value of the invoiceMessage record component.
      Returns:
      the value of the invoiceMessage record component
    • buttonsMessage

      public Optional<ButtonsMessage> buttonsMessage()
      Returns the value of the buttonsMessage record component.
      Returns:
      the value of the buttonsMessage record component
    • buttonsResponseMessage

      public Optional<ButtonsResponseMessage> buttonsResponseMessage()
      Returns the value of the buttonsResponseMessage record component.
      Returns:
      the value of the buttonsResponseMessage record component
    • paymentInviteMessage

      public Optional<PaymentInviteMessage> paymentInviteMessage()
      Returns the value of the paymentInviteMessage record component.
      Returns:
      the value of the paymentInviteMessage record component
    • interactiveMessage

      public Optional<InteractiveMessage> interactiveMessage()
      Returns the value of the interactiveMessage record component.
      Returns:
      the value of the interactiveMessage record component
    • reactionMessage

      public Optional<ReactionMessage> reactionMessage()
      Returns the value of the reactionMessage record component.
      Returns:
      the value of the reactionMessage record component
    • stickerSyncMessage

      public Optional<StickerSyncRMRMessage> stickerSyncMessage()
      Returns the value of the stickerSyncMessage record component.
      Returns:
      the value of the stickerSyncMessage record component
    • interactiveResponseMessage

      public Optional<InteractiveResponseMessage> interactiveResponseMessage()
      Returns the value of the interactiveResponseMessage record component.
      Returns:
      the value of the interactiveResponseMessage record component
    • pollCreationMessage

      public Optional<PollCreationMessage> pollCreationMessage()
      Returns the value of the pollCreationMessage record component.
      Returns:
      the value of the pollCreationMessage record component
    • pollUpdateMessage

      public Optional<PollUpdateMessage> pollUpdateMessage()
      Returns the value of the pollUpdateMessage record component.
      Returns:
      the value of the pollUpdateMessage record component
    • keepInChatMessage

      public Optional<KeepInChatMessage> keepInChatMessage()
      Returns the value of the keepInChatMessage record component.
      Returns:
      the value of the keepInChatMessage record component
    • documentWithCaptionMessage

      public Optional<FutureMessageContainer> documentWithCaptionMessage()
      Returns the value of the documentWithCaptionMessage record component.
      Returns:
      the value of the documentWithCaptionMessage record component
    • requestPhoneNumberMessage

      public Optional<RequestPhoneNumberMessage> requestPhoneNumberMessage()
      Returns the value of the requestPhoneNumberMessage record component.
      Returns:
      the value of the requestPhoneNumberMessage record component
    • viewOnceV2Message

      public Optional<FutureMessageContainer> viewOnceV2Message()
      Returns the value of the viewOnceV2Message record component.
      Returns:
      the value of the viewOnceV2Message record component
    • encryptedReactionMessage

      public Optional<EncryptedReactionMessage> encryptedReactionMessage()
      Returns the value of the encryptedReactionMessage record component.
      Returns:
      the value of the encryptedReactionMessage record component
    • editedMessage

      public Optional<FutureMessageContainer> editedMessage()
      Returns the value of the editedMessage record component.
      Returns:
      the value of the editedMessage record component
    • viewOnceV2ExtensionMessage

      public Optional<FutureMessageContainer> viewOnceV2ExtensionMessage()
      Returns the value of the viewOnceV2ExtensionMessage record component.
      Returns:
      the value of the viewOnceV2ExtensionMessage record component
    • newsletterAdminInviteMessage

      public Optional<NewsletterAdminInviteMessage> newsletterAdminInviteMessage()
      Returns the value of the newsletterAdminInviteMessage record component.
      Returns:
      the value of the newsletterAdminInviteMessage record component
    • deviceInfo

      public Optional<DeviceContextInfo> deviceInfo()
      Returns the value of the deviceInfo record component.
      Returns:
      the value of the deviceInfo record component