Class Store

All Implemented Interfaces:
it.auties.protobuf.model.ProtobufMessage, it.auties.protobuf.model.ProtobufObject

public final class Store extends Controller<Store> implements it.auties.protobuf.model.ProtobufMessage
This controller holds the user-related data regarding a WhatsappWeb session
  • Field Details

    • proxy

      URI proxy
      The version used by this session
    • version

      The version used by this session
    • online

      boolean online
      Whether this account is online for other users
    • locale

      The locale of the user linked to this account
    • name

      String name
      The name of the user linked to this account. This field will be null while the user hasn't logged in yet. Assumed to be non-null otherwise.
    • verifiedName

      String verifiedName
      The name of the user linked to this account. This field will be null while the user hasn't logged in yet. Assumed to be non-null otherwise.
    • businessAddress

      String businessAddress
      The address of this account, if it's a business account
    • businessLongitude

      Double businessLongitude
      The longitude of this account's location, if it's a business account
    • businessLatitude

      Double businessLatitude
      The latitude of this account's location, if it's a business account
    • businessDescription

      String businessDescription
      The description of this account, if it's a business account
    • businessWebsite

      String businessWebsite
      The website of this account, if it's a business account
    • businessEmail

      String businessEmail
      The email of this account, if it's a business account
    • businessCategory

      BusinessCategory businessCategory
      The category of this account, if it's a business account
    • deviceHash

      String deviceHash
      The hash of the companion associated with this session
    • linkedDevicesKeys

      LinkedHashMap<Jid,Integer> linkedDevicesKeys
      A map of all the devices that the companion has associated using WhatsappWeb The key here is the index of the device's key The value is the device's companion jid
    • profilePicture

      URI profilePicture
      The profile picture of the user linked to this account. This field will be null while the user hasn't logged in yet. This field can also be null if no image was set.
    • about

      String about
      The status of the user linked to this account. This field will be null while the user hasn't logged in yet. Assumed to be non-null otherwise.
    • jid

      Jid jid
      The user linked to this account. This field will be null while the user hasn't logged in yet.
    • lid

      Jid lid
      The lid user linked to this account. This field will be null while the user hasn't logged in yet.
    • properties

      final ConcurrentHashMap<String,String> properties
      The non-null map of properties received by whatsapp
    • chats

      final ConcurrentHashMap<Jid,Chat> chats
      The non-null map of chats
    • contacts

      final ConcurrentHashMap<Jid,Contact> contacts
      The non-null map of contacts
    • status

      The non-null list of status messages
    • newsletters

      final ConcurrentHashMap<Jid,Newsletter> newsletters
      The non-null map of newsletters
    • privacySettings

      The non-null map of privacy settings
    • calls

      The non-null map of calls
    • unarchiveChats

      boolean unarchiveChats
      Whether chats should be unarchived if a new message arrives
    • twentyFourHourFormat

      boolean twentyFourHourFormat
      Whether the twenty-hours format is being used by the client
    • requests

      final ConcurrentHashMap<String,it.auties.whatsapp.socket.SocketRequest> requests
      The non-null list of requests that were sent to Whatsapp. They might or might not be waiting for a newsletters
    • replyHandlers

      The non-null list of replies waiting to be fulfilled
    • listeners

      The non-null list of listeners
    • tag

      final String tag
      The request tag, used to create messages
    • initializationTimeStamp

      final long initializationTimeStamp
      The timestampSeconds in seconds for the initialization of this object
    • mediaConnection

      MediaConnection mediaConnection
      The media connection associated with this store
    • mediaConnectionLatch

      final CountDownLatch mediaConnectionLatch
      The media connection latch associated with this store
    • newChatsEphemeralTimer

      ChatEphemeralTimer newChatsEphemeralTimer
      The request tag, used to create messages
    • textPreviewSetting

      TextPreviewSetting textPreviewSetting
      The setting to use when generating previews for text messages that contain links
    • historyLength

      WebHistoryLength historyLength
      Describes how much chat history Whatsapp should send
    • autodetectListeners

      boolean autodetectListeners
      Whether listeners should be automatically scanned and registered or not
    • cacheDetectedListeners

      boolean cacheDetectedListeners
      Whether the listeners that were automatically scanned should be cached
    • automaticPresenceUpdates

      boolean automaticPresenceUpdates
      Whether updates about the presence of the session should be sent automatically to Whatsapp For example, when the bot is started, the status of the companion is changed to available if this option is enabled If this option is enabled, the companion will not receive notifications because the bot will instantly read them
    • releaseChannel

      UserAgent.ReleaseChannel releaseChannel
      The release channel to use when connecting to Whatsapp This should allow the use of beta features
    • device

      Metadata about the device that is being simulated for Whatsapp
    • checkPatchMacs

      boolean checkPatchMacs
      Whether the mac of every app state request should be checked
  • Constructor Details

  • Method Details

    • newStore

      public static Store newStore(UUID uuid, Long phoneNumber, Collection<String> alias, ClientType clientType)
    • findContactByJid

      public Optional<Contact> findContactByJid(JidProvider jid)
      Queries the first contact whose jid is equal to jid
      Parameters:
      jid - the jid to search
      Returns:
      a non-null optional
    • findContactByName

      public Optional<Contact> findContactByName(String name)
      Queries the first contact whose name is equal to name
      Parameters:
      name - the name to search
      Returns:
      a non-null optional
    • findContactsStream

      private Stream<Contact> findContactsStream(String name)
    • contacts

      public Collection<Contact> contacts()
      Returns all the contacts
      Returns:
      an immutable collection
    • findContactsByName

      public Set<Contact> findContactsByName(String name)
      Queries every contact whose name is equal to name
      Parameters:
      name - the name to search
      Returns:
      a non-null immutable set
    • findMessageByKey

      public Optional<ChatMessageInfo> findMessageByKey(ChatMessageKey key)
      Queries the first message whose id matches the one provided in the specified chat
      Parameters:
      key - the key to search
      Returns:
      a non-null optional
    • findMessageById

      public Optional<? extends MessageStatusInfo<?>> findMessageById(JidProvider provider, String id)
      Queries the first message whose id matches the one provided in the specified chat or newsletter
      Parameters:
      provider - the chat to search in
      id - the jid to search
      Returns:
      a non-null optional
    • findMessageById

      public Optional<NewsletterMessageInfo> findMessageById(Newsletter newsletter, String id)
      Queries the first message whose id matches the one provided in the specified newsletter
      Parameters:
      newsletter - newsletter chat to search in
      id - the jid to search
      Returns:
      a non-null optional
    • findMessageById

      public Optional<ChatMessageInfo> findMessageById(Chat chat, String id)
      Queries the first message whose id matches the one provided in the specified chat
      Parameters:
      chat - the chat to search in
      id - the jid to search
      Returns:
      a non-null optional
    • findChatByJid

      public Optional<Chat> findChatByJid(JidProvider jid)
      Queries the first chat whose jid is equal to jid
      Parameters:
      jid - the jid to search
      Returns:
      a non-null optional
    • findNewsletterByJid

      public Optional<Newsletter> findNewsletterByJid(JidProvider jid)
      Queries the first newsletter whose jid is equal to jid
      Parameters:
      jid - the jid to search
      Returns:
      a non-null optional
    • findChatByName

      public Optional<Chat> findChatByName(String name)
      Queries the first chat whose name is equal to name
      Parameters:
      name - the name to search
      Returns:
      a non-null optional
    • findNewsletterByName

      public Optional<Newsletter> findNewsletterByName(String name)
      Queries the first newsletter whose name is equal to name
      Parameters:
      name - the name to search
      Returns:
      a non-null optional
    • findChatsByNameStream

      private Stream<Chat> findChatsByNameStream(String name)
    • findNewslettersByNameStream

      private Stream<Newsletter> findNewslettersByNameStream(String name)
    • findChatBy

      public Optional<Chat> findChatBy(Function<Chat,Boolean> function)
      Queries the first chat that matches the provided function
      Parameters:
      function - the non-null filter
      Returns:
      a non-null optional
    • findNewsletterBy

      public Optional<Newsletter> findNewsletterBy(Function<Newsletter,Boolean> function)
      Queries the first newsletter that matches the provided function
      Parameters:
      function - the non-null filter
      Returns:
      a non-null optional
    • findChatsByName

      public Set<Chat> findChatsByName(String name)
      Queries every chat whose name is equal to name
      Parameters:
      name - the name to search
      Returns:
      a non-null immutable set
    • findNewslettersByName

      public Set<Newsletter> findNewslettersByName(String name)
      Queries every newsletter whose name is equal to name
      Parameters:
      name - the name to search
      Returns:
      a non-null immutable set
    • findChatsBy

      public Set<Chat> findChatsBy(Function<Chat,Boolean> function)
      Queries the first chat that matches the provided function
      Parameters:
      function - the non-null filter
      Returns:
      a non-null optional
    • status

      public Collection<ChatMessageInfo> status()
      Returns all the status
      Returns:
      an immutable collection
    • newsletters

      public Collection<Newsletter> newsletters()
      Returns all the newsletters
      Returns:
      an immutable collection
    • findStatusBySender

      public Collection<ChatMessageInfo> findStatusBySender(JidProvider jid)
      Queries all the status of a contact
      Parameters:
      jid - the sender of the status
      Returns:
      a non-null immutable list
    • resolvePendingRequest

      public boolean resolvePendingRequest(Node response, boolean exceptionally)
      Queries the first request whose id equals the one stored by the newsletters and, if any is found, it completes it
      Parameters:
      response - the newsletters to complete the request with
      exceptionally - whether the newsletters is erroneous
      Returns:
      a boolean
    • findPendingRequest

      public Optional<it.auties.whatsapp.socket.SocketRequest> findPendingRequest(String id)
      Queries the first request whose id is equal to id
      Parameters:
      id - the id to search, can be null
      Returns:
      a non-null optional
    • deleteAndComplete

      private it.auties.whatsapp.socket.SocketRequest deleteAndComplete(it.auties.whatsapp.socket.SocketRequest request, Node response, boolean exceptionally)
    • resolveAllPendingRequests

      public void resolveAllPendingRequests()
      Clears all the data that this object holds and closes the pending requests
    • pendingRequests

      public Collection<it.auties.whatsapp.socket.SocketRequest> pendingRequests()
      Returns an immutable collection of pending requests
      Returns:
      a non-null collection
    • resolvePendingReply

      public boolean resolvePendingReply(ChatMessageInfo response)
      Queries the first reply waiting and completes it with the input message
      Parameters:
      response - the newsletters to complete the reply with
      Returns:
      a boolean
    • addNewChat

      public Chat addNewChat(Jid chatJid)
      Adds a chat in memory
      Parameters:
      chatJid - the chat to add
      Returns:
      the input chat
    • addChat

      public Optional<Chat> addChat(Chat chat)
      Adds a chat in memory
      Parameters:
      chat - the chat to add
      Returns:
      the old chat, if present
    • joinMessages

      private void joinMessages(Chat chat, Chat oldChat)
    • addChatDirect

      public Optional<Chat> addChatDirect(Chat chat)
      Adds a chat in memory without executing any check
      Parameters:
      chat - the chat to add
      Returns:
      the old chat, if present
    • addContact

      public Contact addContact(Jid jid)
      Adds a contact in memory
      Parameters:
      jid - the contact to add
      Returns:
      the input contact
    • addContact

      public Contact addContact(Contact contact)
      Adds a contact in memory
      Parameters:
      contact - the contact to add
      Returns:
      the input contact
    • addNewsletter

      public Optional<Newsletter> addNewsletter(Newsletter newsletter)
      Adds a newsletter in memory
      Parameters:
      newsletter - the newsletter to add
      Returns:
      the old newsletter, if present
    • removeChat

      public Optional<Chat> removeChat(JidProvider chatJid)
      Removes a chat from memory
      Parameters:
      chatJid - the chat to remove
      Returns:
      the chat that was deleted wrapped by an optional
    • removeNewsletter

      public Optional<Newsletter> removeNewsletter(JidProvider newsletterJid)
      Removes a newsletter from memory
      Parameters:
      newsletterJid - the newsletter to remove
      Returns:
      the newsletter that was deleted wrapped by an optional
    • removeContact

      public Optional<Contact> removeContact(JidProvider contactJid)
      Removes a contact from memory
      Parameters:
      contactJid - the contact to remove
      Returns:
      the contact that was deleted wrapped by an optional
    • pinnedChats

      public List<Chat> pinnedChats()
      Returns the chats pinned to the top sorted new to old
      Returns:
      a non-null list of chats
    • starredMessages

      public List<ChatMessageInfo> starredMessages()
      Returns all the starred messages
      Returns:
      a non-null list of messages
    • chats

      public List<Chat> chats()
      Returns all the chats sorted from newest to oldest
      Returns:
      an immutable collection
    • properties

      public Map<String,String> properties()
      Returns the non-null map of properties received by whatsapp
      Returns:
      an unmodifiable map
    • addProperties

      public void addProperties(Map<String,String> properties)
    • mediaConnection

      public MediaConnection mediaConnection()
      The media connection associated with this store
      Returns:
      the media connection
    • mediaConnection

      public MediaConnection mediaConnection(Duration timeout)
      The media connection associated with this store
      Parameters:
      timeout - the non-null timeout for the connection to be filled
      Returns:
      the media connection
    • setMediaConnection

      public Store setMediaConnection(MediaConnection mediaConnection)
      Writes a media connection
      Parameters:
      mediaConnection - a media connection
      Returns:
      the same instance
    • blockedContacts

      public Collection<Contact> blockedContacts()
      Returns all the blocked contacts
      Returns:
      an immutable collection
    • addStatus

      public Store addStatus(ChatMessageInfo info)
      Adds a status to this store
      Parameters:
      info - the non-null status to add
      Returns:
      the same instance
    • addRequest

      public CompletableFuture<Node> addRequest(it.auties.whatsapp.socket.SocketRequest request)
      Adds a request to this store
      Parameters:
      request - the non-null request to add
      Returns:
      the non-null completable newsletters of the request
    • addPendingReply

      public CompletableFuture<ChatMessageInfo> addPendingReply(String messageId)
      Adds a replay handler to this store
      Parameters:
      messageId - the non-null message id to listen for
      Returns:
      the non-null completable newsletters of the reply handler
    • profilePicture

      public Optional<URI> profilePicture()
      Returns the profile picture of this user if present
      Returns:
      an optional uri
    • privacySettings

      public Collection<PrivacySettingEntry> privacySettings()
      Queries all the privacy settings
      Returns:
      a non-null list
    • findPrivacySetting

      public PrivacySettingEntry findPrivacySetting(PrivacySettingType type)
      Queries the privacy setting entry for the type
      Parameters:
      type - a non-null type
      Returns:
      a non-null entry
    • addPrivacySetting

      public PrivacySettingEntry addPrivacySetting(PrivacySettingType type, PrivacySettingEntry entry)
      Sets the privacy setting entry for a type
      Parameters:
      type - a non-null type
      entry - the non-null entry
      Returns:
      the old privacy setting entry
    • linkedDevicesKeys

      public Map<Jid,Integer> linkedDevicesKeys()
      Returns an unmodifiable map that contains every companion associated using Whatsapp web mapped to its key index
      Returns:
      an unmodifiable map
    • linkedDevices

      public Collection<Jid> linkedDevices()
      Returns an unmodifiable list that contains the devices associated using Whatsapp web to this session's companion
      Returns:
      an unmodifiable list
    • addLinkedDevice

      public Optional<Integer> addLinkedDevice(Jid companion, int keyId)
      Registers a new companion Only use this method in the mobile api
      Parameters:
      companion - a non-null companion
      keyId - the id of its key
      Returns:
      the nullable old key
    • removeLinkedCompanion

      public Optional<Integer> removeLinkedCompanion(Jid companion)
      Removes a companion Only use this method in the mobile api
      Parameters:
      companion - a non-null companion
      Returns:
      the nullable old key
    • removeLinkedCompanions

      public void removeLinkedCompanions()
      Removes all linked companion
    • listeners

      public Collection<Listener> listeners()
      Returns an immutable collection of listeners
      Returns:
      a non-null collection
    • addListener

      public Store addListener(Listener listener)
      Registers a listener
      Parameters:
      listener - the listener to register
      Returns:
      the same instance
    • addListeners

      public Store addListeners(Collection<Listener> listeners)
      Registers a collection of listeners
      Parameters:
      listeners - the listeners to register
      Returns:
      the same instance
    • removeListener

      public Store removeListener(Listener listener)
      Removes a listener
      Parameters:
      listener - the listener to remove
      Returns:
      the same instance
    • removeListener

      public Store removeListener()
      Removes all listeners
      Returns:
      the same instance
    • setProxy

      public Store setProxy(URI proxy)
      Sets the proxy used by this session
      Returns:
      the same instance
    • proxy

      public Optional<URI> proxy()
      Returns the proxy used by this session
      Returns:
      a non-null optional
    • businessAddress

      public Optional<String> businessAddress()
      The address of this account, if it's a business account
      Returns:
      an optional
    • businessLongitude

      public Optional<Double> businessLongitude()
      The longitude of this account's location, if it's a business account
      Returns:
      an optional
    • businessLatitude

      public Optional<Double> businessLatitude()
      The latitude of this account's location, if it's a business account
      Returns:
      an optional
    • businessDescription

      public Optional<String> businessDescription()
      The description of this account, if it's a business account
      Returns:
      an optional
    • businessWebsite

      public Optional<String> businessWebsite()
      The website of this account, if it's a business account
      Returns:
      an optional
    • businessEmail

      public Optional<String> businessEmail()
      The email of this account, if it's a business account
      Returns:
      an optional
    • businessCategory

      public Optional<BusinessCategory> businessCategory()
      The category of this account, if it's a business account
      Returns:
      an optional
    • dispose

      public void dispose()
      Description copied from class: Controller
      Disposes this object
      Specified by:
      dispose in class Controller<Store>
    • serialize

      public void serialize(boolean async)
      Description copied from class: Controller
      Serializes this object
      Specified by:
      serialize in class Controller<Store>
      Parameters:
      async - whether the operation should be executed asynchronously
    • addCall

      public Optional<Call> addCall(Call call)
      Adds a call to the store
      Parameters:
      call - a non-null call
      Returns:
      the old value associated with Call.id()
    • findCallById

      public Optional<Call> findCallById(String callId)
      Finds a call by id
      Parameters:
      callId - the id of the call, can be null
      Returns:
      an optional
    • tag

      public String tag()
    • version

      public Version version()
    • online

      public boolean online()
    • locale

      public Optional<CountryLocale> locale()
    • name

      public String name()
    • deviceHash

      public Optional<String> deviceHash()
    • about

      public Optional<String> about()
    • jid

      public Optional<Jid> jid()
    • lid

      public Optional<Jid> lid()
    • unarchiveChats

      public boolean unarchiveChats()
    • twentyFourHourFormat

      public boolean twentyFourHourFormat()
    • initializationTimeStamp

      public long initializationTimeStamp()
    • newChatsEphemeralTimer

      public ChatEphemeralTimer newChatsEphemeralTimer()
    • textPreviewSetting

      public TextPreviewSetting textPreviewSetting()
    • historyLength

      public WebHistoryLength historyLength()
    • autodetectListeners

      public boolean autodetectListeners()
    • cacheDetectedListeners

      public boolean cacheDetectedListeners()
    • automaticPresenceUpdates

      public boolean automaticPresenceUpdates()
    • releaseChannel

      public UserAgent.ReleaseChannel releaseChannel()
    • device

      public CompanionDevice device()
    • checkPatchMacs

      public boolean checkPatchMacs()
    • calls

      public Map<String,Call> calls()
    • setOnline

      public Store setOnline(boolean online)
    • setLocale

      public Store setLocale(CountryLocale locale)
    • setName

      public Store setName(String name)
    • setBusinessAddress

      public Store setBusinessAddress(String businessAddress)
    • setBusinessLongitude

      public Store setBusinessLongitude(Double businessLongitude)
    • setBusinessLatitude

      public Store setBusinessLatitude(Double businessLatitude)
    • setBusinessDescription

      public Store setBusinessDescription(String businessDescription)
    • setBusinessWebsite

      public Store setBusinessWebsite(String businessWebsite)
    • setBusinessEmail

      public Store setBusinessEmail(String businessEmail)
    • setBusinessCategory

      public Store setBusinessCategory(BusinessCategory businessCategory)
    • setDeviceHash

      public Store setDeviceHash(String deviceHash)
    • setLinkedDevicesKeys

      public Store setLinkedDevicesKeys(LinkedHashMap<Jid,Integer> linkedDevicesKeys)
    • setProfilePicture

      public Store setProfilePicture(URI profilePicture)
    • setAbout

      public Store setAbout(String about)
    • setJid

      public Store setJid(Jid jid)
    • setLid

      public Store setLid(Jid lid)
    • setUnarchiveChats

      public Store setUnarchiveChats(boolean unarchiveChats)
    • setTwentyFourHourFormat

      public Store setTwentyFourHourFormat(boolean twentyFourHourFormat)
    • setNewChatsEphemeralTimer

      public Store setNewChatsEphemeralTimer(ChatEphemeralTimer newChatsEphemeralTimer)
    • setTextPreviewSetting

      public Store setTextPreviewSetting(TextPreviewSetting textPreviewSetting)
    • setHistoryLength

      public Store setHistoryLength(WebHistoryLength historyLength)
    • setAutodetectListeners

      public Store setAutodetectListeners(boolean autodetectListeners)
    • setCacheDetectedListeners

      public void setCacheDetectedListeners(boolean cacheDetectedListeners)
    • setAutomaticPresenceUpdates

      public Store setAutomaticPresenceUpdates(boolean automaticPresenceUpdates)
    • setReleaseChannel

      public Store setReleaseChannel(UserAgent.ReleaseChannel releaseChannel)
    • setDevice

      public Store setDevice(CompanionDevice device)
    • setCheckPatchMacs

      public Store setCheckPatchMacs(boolean checkPatchMacs)
    • setVersion

      public Store setVersion(Version version)
    • verifiedName

      public Optional<String> verifiedName()
    • setVerifiedName

      public Store setVerifiedName(String verifiedName)