java.lang.Object
it.auties.whatsapp.model.chat.Chat
- All Implemented Interfaces:
it.auties.protobuf.model.ProtobufMessage,it.auties.protobuf.model.ProtobufObject,JidProvider
public final class Chat
extends Object
implements it.auties.protobuf.model.ProtobufMessage, JidProvider
A model class that represents a Chat. A chat can be of two types: a conversation with a contact
or a group. This class is only a model, this means that changing its values will have no real
effect on WhatsappWeb's servers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe constants of this enumerated type describe the various types of transfers that can regard a chat history sync -
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean(package private) boolean(package private) String(package private) ChatDisappear(package private) String(package private) boolean(package private) Chat.EndOfHistoryTransferType(package private) ChatEphemeralTimer(package private) long(package private) long(package private) Jid(package private) final ConcurrentLinkedHashedDequeue<HistorySyncMessage> (package private) byte[](package private) final Jid(package private) Jid(package private) boolean(package private) MediaVisibility(package private) ChatMute(package private) String(package private) final Jid(package private) boolean(package private) final Jid(package private) boolean(package private) final Jid(package private) final List<GroupParticipant> (package private) final Set<GroupPastParticipant> (package private) Jid(package private) int(package private) boolean(package private) final ConcurrentHashMap<Jid, ContactStatus> (package private) boolean(package private) boolean(package private) boolean(package private) boolean(package private) boolean(package private) long(package private) byte[](package private) long(package private) long(package private) intprivate boolean(package private) ChatWallpaper -
Constructor Summary
ConstructorsConstructorDescriptionChat(Jid jid, ConcurrentLinkedHashedDequeue<HistorySyncMessage> historySyncMessages, Jid newJid, Jid oldJid, int unreadMessagesCount, boolean readOnly, boolean endOfHistoryTransfer, ChatEphemeralTimer ephemeralMessageDuration, long ephemeralMessagesToggleTimeSeconds, Chat.EndOfHistoryTransferType endOfHistoryTransferType, long timestampSeconds, String name, boolean notSpam, boolean archived, ChatDisappear disappearInitiator, boolean markedAsUnread, List<GroupParticipant> participants, byte[] token, long tokenTimestampSeconds, byte[] identityKey, int pinnedTimestampSeconds, ChatMute mute, ChatWallpaper wallpaper, MediaVisibility mediaVisibility, long tokenSenderTimestampSeconds, boolean suspended, boolean terminated, long foundationTimestampSeconds, Jid founder, String description, boolean support, boolean parentGroup, boolean defaultSubGroup, Jid parentGroupJid, String displayName, Jid phoneJid, boolean shareOwnPhoneNumber, boolean pnhDuplicateLidThread, Jid lidJid, ConcurrentHashMap<Jid, ContactStatus> presences, Set<Jid> participantsPreKeys, Set<GroupPastParticipant> pastParticipants) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessages(Collection<HistorySyncMessage> newMessages) Adds a new unspecified amount of messages to this chat and sorts them accordinglybooleanaddNewMessage(ChatMessageInfo info) Adds a message to the chat in the most recent slot availablebooleanAdds a message to the chat in the oldest slot availablevoidaddOldMessages(Collection<HistorySyncMessage> oldMessages) Adds a new unspecified amount of messages to this chat and sorts them accordinglybooleanaddParticipant(GroupParticipant participant) Adds a participant to this chatbooleanaddParticipant(Jid jid, GroupRole role) Adds a participant to this chatvoidaddParticipants(Collection<GroupParticipant> participants) Adds a collection of participants to this chatvoidaddParticipantsPreKeys(Collection<Jid> jids) booleanaddPastParticipant(GroupPastParticipant participant) Adds a past participantbooleanaddPastParticipants(List<GroupPastParticipant> pastParticipants) Adds a collection of past participantsbooleanarchived()voidbooleanbooleanReturns an optional value containing the seconds in seconds sinceInstant.EPOCHwhen ephemeral messages were turned onlongbooleanChecks if this chat is equal to another chatprivate Optional<ChatMessageInfo> findMessageBy(Function<ChatMessageInfo, Boolean> filter, boolean newest) findParticipant(Jid jid) Finds a participant by jid This method only works ifWhatsapp.queryGroupMetadata(JidProvider)has been called before on this chat.findPastParticipant(Jid jid) Finds a past participant by jidReturns the timestampSeconds for the creation of this chat if it's a grouplongfounder()inthashCode()Returns the hash code for this chatbooleanhasName()booleanReturns a boolean to represent whether this chat has unread messagesbooleanOptional<byte[]> booleanReturns a boolean to represent whether ephemeral messages are enabled for this chatbooleanisGroup()Returns a boolean to represent whether this chat is a group or notprivate booleanbooleanisPinned()Returns a boolean to represent whether this chat is pinned or notprivate booleanprivate booleanjid()lidJid()booleanmessages()Returns an immutable list of messages wrapped in history syncs This is useful for the protomute()name()Returns the name of this chatReturns an optional value containing the latest message in chronological terms for this chatReturns an optional value containing the latest message in chronological terms for this chat sent from youReturns an optional value containing the latest message in chronological terms for this chat with type serverReturns an optional value containing the latest message in chronological terms for this chat with type that isn't servernewJid()booleannotSpam()Returns an optional value containing the first message in chronological terms for this chatReturns an optional value containing the first message in chronological terms for this chat sent from youReturns an optional value containing the first message in chronological terms for this chat with type serverReturns an optional value containing the first message in chronological terms for this chat with type that isn't serveroldJid()booleanphoneJid()Returns an optional value containing the seconds this chat was pinnedintbooleanbooleanreadOnly()private voidbooleanremoveMessage(ChatMessageInfo info) Remove a message from the chatbooleanremoveMessage(Predicate<? super ChatMessageInfo> predicate) Remove a message from the chatvoidRemoves all messages from the chatbooleanremoveParticipant(Jid jid) Removes a participant from this chatbooleanremovePastParticipant(Jid jid) Removes a past participantsetArchived(boolean archived) setDefaultSubGroup(boolean defaultSubGroup) setDescription(String description) setDisappearInitiator(ChatDisappear disappearInitiator) setDisplayName(String displayName) setEndOfHistoryTransfer(boolean endOfHistoryTransfer) setEndOfHistoryTransferType(Chat.EndOfHistoryTransferType endOfHistoryTransferType) setEphemeralMessageDuration(ChatEphemeralTimer ephemeralMessageDuration) setEphemeralMessagesToggleTimeSeconds(long ephemeralMessagesToggleTimeSeconds) setFoundationTimestampSeconds(long foundationTimestampSeconds) setFounder(Jid founder) setIdentityKey(byte[] identityKey) setMarkedAsUnread(boolean markedAsUnread) setMediaVisibility(MediaVisibility mediaVisibility) setNotSpam(boolean notSpam) setParentGroup(boolean parentGroup) setPhoneJid(Jid phoneJid) setPinnedTimestampSeconds(int pinnedTimestampSeconds) setPnhDuplicateLidThread(boolean pnhDuplicateLidThread) setReadOnly(boolean readOnly) setShareOwnPhoneNumber(boolean shareOwnPhoneNumber) setSupport(boolean support) setSuspended(boolean suspended) setTerminated(boolean terminated) setTimestampSeconds(long timestampSeconds) setToken(byte[] token) setTokenSenderTimestampSeconds(long tokenSenderTimestampSeconds) setTokenTimestampSeconds(long tokenTimestampSeconds) setUnreadMessagesCount(int unreadMessagesCount) setWallpaper(ChatWallpaper wallpaper) booleanReturns all the starred messages in this chatbooleansupport()booleanbooleanReturns the timestampSeconds for the creation of this chat in seconds sinceInstant.EPOCHlongtoJid()Returns this object as a jidOptional<byte[]> token()Returns the timestampSeconds for the token sender creation of this chatlongReturns the timestampSeconds for the creation of this chat's tokenlongReturns all the unread messages in this chatintprivate void
-
Field Details
-
jid
-
historySyncMessages
-
newJid
-
oldJid
-
unreadMessagesCount
int unreadMessagesCount -
readOnly
boolean readOnly -
endOfHistoryTransfer
boolean endOfHistoryTransfer -
ephemeralMessageDuration
ChatEphemeralTimer ephemeralMessageDuration -
ephemeralMessagesToggleTimeSeconds
long ephemeralMessagesToggleTimeSeconds -
endOfHistoryTransferType
Chat.EndOfHistoryTransferType endOfHistoryTransferType -
timestampSeconds
long timestampSeconds -
name
String name -
notSpam
boolean notSpam -
archived
boolean archived -
disappearInitiator
ChatDisappear disappearInitiator -
markedAsUnread
boolean markedAsUnread -
participants
-
token
byte[] token -
tokenTimestampSeconds
long tokenTimestampSeconds -
identityKey
byte[] identityKey -
pinnedTimestampSeconds
int pinnedTimestampSeconds -
mute
ChatMute mute -
wallpaper
ChatWallpaper wallpaper -
mediaVisibility
MediaVisibility mediaVisibility -
tokenSenderTimestampSeconds
long tokenSenderTimestampSeconds -
suspended
boolean suspended -
terminated
boolean terminated -
foundationTimestampSeconds
long foundationTimestampSeconds -
founder
Jid founder -
description
String description -
support
boolean support -
parentGroup
boolean parentGroup -
defaultSubGroup
boolean defaultSubGroup -
parentGroupJid
-
displayName
String displayName -
phoneJid
Jid phoneJid -
pnhDuplicateLidThread
boolean pnhDuplicateLidThread -
lidJid
Jid lidJid -
presences
-
participantsPreKeys
-
pastParticipants
-
update
private boolean update
-
-
Constructor Details
-
Chat
public Chat(Jid jid, ConcurrentLinkedHashedDequeue<HistorySyncMessage> historySyncMessages, Jid newJid, Jid oldJid, int unreadMessagesCount, boolean readOnly, boolean endOfHistoryTransfer, ChatEphemeralTimer ephemeralMessageDuration, long ephemeralMessagesToggleTimeSeconds, Chat.EndOfHistoryTransferType endOfHistoryTransferType, long timestampSeconds, String name, boolean notSpam, boolean archived, ChatDisappear disappearInitiator, boolean markedAsUnread, List<GroupParticipant> participants, byte[] token, long tokenTimestampSeconds, byte[] identityKey, int pinnedTimestampSeconds, ChatMute mute, ChatWallpaper wallpaper, MediaVisibility mediaVisibility, long tokenSenderTimestampSeconds, boolean suspended, boolean terminated, long foundationTimestampSeconds, Jid founder, String description, boolean support, boolean parentGroup, boolean defaultSubGroup, Jid parentGroupJid, String displayName, Jid phoneJid, boolean shareOwnPhoneNumber, boolean pnhDuplicateLidThread, Jid lidJid, ConcurrentHashMap<Jid, ContactStatus> presences, Set<Jid> participantsPreKeys, Set<GroupPastParticipant> pastParticipants)
-
-
Method Details
-
name
Returns the name of this chat- Returns:
- a non-null string
-
isGroup
public boolean isGroup()Returns a boolean to represent whether this chat is a group or not- Returns:
- true if this chat is a group
-
isPinned
public boolean isPinned()Returns a boolean to represent whether this chat is pinned or not- Returns:
- true if this chat is pinned
-
isEphemeral
public boolean isEphemeral()Returns a boolean to represent whether ephemeral messages are enabled for this chat- Returns:
- true if ephemeral messages are enabled for this chat
-
unreadMessages
Returns all the unread messages in this chat- Returns:
- a non-null collection
-
hasUnreadMessages
public boolean hasUnreadMessages()Returns a boolean to represent whether this chat has unread messages- Returns:
- true if this chat has unread messages
-
pinnedTimestamp
Returns an optional value containing the seconds this chat was pinned- Returns:
- an optional
-
timestamp
Returns the timestampSeconds for the creation of this chat in seconds sinceInstant.EPOCH- Returns:
- an optional
-
ephemeralMessagesToggleTime
Returns an optional value containing the seconds in seconds sinceInstant.EPOCHwhen ephemeral messages were turned on- Returns:
- an optional
-
newestMessage
Returns an optional value containing the latest message in chronological terms for this chat- Returns:
- an optional
-
oldestMessage
Returns an optional value containing the first message in chronological terms for this chat- Returns:
- an optional
-
newestStandardMessage
Returns an optional value containing the latest message in chronological terms for this chat with type that isn't server- Returns:
- an optional
-
oldestStandardMessage
Returns an optional value containing the first message in chronological terms for this chat with type that isn't server- Returns:
- an optional
-
isStandardMessage
-
newestMessageFromMe
Returns an optional value containing the latest message in chronological terms for this chat sent from you- Returns:
- an optional
-
oldestMessageFromMe
Returns an optional value containing the first message in chronological terms for this chat sent from you- Returns:
- an optional
-
isMessageFromMe
-
newestServerMessage
Returns an optional value containing the latest message in chronological terms for this chat with type server- Returns:
- an optional
-
oldestServerMessage
Returns an optional value containing the first message in chronological terms for this chat with type server- Returns:
- an optional
-
isServerMessage
-
findMessageBy
private Optional<ChatMessageInfo> findMessageBy(Function<ChatMessageInfo, Boolean> filter, boolean newest) -
starredMessages
Returns all the starred messages in this chat- Returns:
- a non-null list of messages
-
tokenTimestamp
Returns the timestampSeconds for the creation of this chat's token- Returns:
- an optional
-
tokenSenderTimestamp
Returns the timestampSeconds for the token sender creation of this chat- Returns:
- an optional
-
foundationTimestamp
Returns the timestampSeconds for the creation of this chat if it's a group- Returns:
- an optional
-
addMessages
Adds a new unspecified amount of messages to this chat and sorts them accordingly- Parameters:
newMessages- the non-null messages to add
-
addOldMessages
Adds a new unspecified amount of messages to this chat and sorts them accordingly- Parameters:
oldMessages- the non-null messages to add
-
addNewMessage
Adds a message to the chat in the most recent slot available- Parameters:
info- the message to add to the chat- Returns:
- whether the message was added
-
addOldMessage
Adds a message to the chat in the oldest slot available- Parameters:
info- the message to add to the chat- Returns:
- whether the message was added
-
removeMessage
Remove a message from the chat- Parameters:
info- the message to remove- Returns:
- whether the message was removed
-
removeMessage
Remove a message from the chat- Parameters:
predicate- the predicate that determines if a message should be removed- Returns:
- whether the message was removed
-
refreshChatTimestamp
private void refreshChatTimestamp() -
updateChatTimestamp
-
removeMessages
public void removeMessages()Removes all messages from the chat -
messages
Returns an immutable list of messages wrapped in history syncs This is useful for the proto- Returns:
- a non-null collection
-
addParticipants
Adds a collection of participants to this chat- Parameters:
participants- the participants to add
-
addParticipant
Adds a participant to this chat- Parameters:
jid- the non-null jid of the participantrole- the role of the participant- Returns:
- whether the participant was added
-
addParticipant
Adds a participant to this chat- Parameters:
participant- the non-null participant- Returns:
- whether the participant was added
-
removeParticipant
Removes a participant from this chat- Parameters:
jid- the non-null jid of the participant- Returns:
- whether the participant was removed
-
findParticipant
Finds a participant by jid This method only works ifWhatsapp.queryGroupMetadata(JidProvider)has been called before on this chat. By default, all groups that have been used in the last two weeks wil be synced automatically- Parameters:
jid- the non-null jid of the participant- Returns:
- the participant, if present
-
addPastParticipant
Adds a past participant- Parameters:
participant- the non-null jid of the past participant- Returns:
- whether the participant was added
-
addPastParticipants
Adds a collection of past participants- Parameters:
pastParticipants- the non-null list of past participants- Returns:
- whether the participant were added
-
removePastParticipant
Removes a past participant- Parameters:
jid- the non-null jid of the past participant- Returns:
- whether the participant was removed
-
findPastParticipant
Finds a past participant by jid- Parameters:
jid- the non-null jid of the past participant- Returns:
- the past participant, if present
-
participantsPreKeys
-
addParticipantsPreKeys
-
clearParticipantsPreKeys
public void clearParticipantsPreKeys() -
equals
Checks if this chat is equal to another chat -
toJid
Returns this object as a jid- Specified by:
toJidin interfaceJidProvider- Returns:
- a non-null jid
-
hashCode
public int hashCode()Returns the hash code for this chat -
jid
-
historySyncMessages
-
newJid
-
oldJid
-
unreadMessagesCount
public int unreadMessagesCount() -
readOnly
public boolean readOnly() -
endOfHistoryTransfer
public boolean endOfHistoryTransfer() -
ephemeralMessageDuration
-
ephemeralMessagesToggleTimeSeconds
public long ephemeralMessagesToggleTimeSeconds() -
endOfHistoryTransferType
-
timestampSeconds
public long timestampSeconds() -
notSpam
public boolean notSpam() -
archived
public boolean archived() -
disappearInitiator
-
markedAsUnread
public boolean markedAsUnread() -
participants
-
token
-
tokenTimestampSeconds
public long tokenTimestampSeconds() -
identityKey
-
pinnedTimestampSeconds
public int pinnedTimestampSeconds() -
mute
-
wallpaper
-
mediaVisibility
-
tokenSenderTimestampSeconds
public long tokenSenderTimestampSeconds() -
suspended
public boolean suspended() -
terminated
public boolean terminated() -
foundationTimestampSeconds
public long foundationTimestampSeconds() -
founder
-
description
-
support
public boolean support() -
parentGroup
public boolean parentGroup() -
defaultSubGroup
public boolean defaultSubGroup() -
parentGroupJid
-
displayName
-
phoneJid
-
pnhDuplicateLidThread
public boolean pnhDuplicateLidThread() -
lidJid
-
presences
-
pastParticipants
-
hasName
public boolean hasName() -
setUnreadMessagesCount
-
setReadOnly
-
setEndOfHistoryTransfer
-
setEphemeralMessageDuration
-
setEphemeralMessagesToggleTimeSeconds
-
setEndOfHistoryTransferType
-
setTimestampSeconds
-
setName
-
setNotSpam
-
setArchived
-
setDisappearInitiator
-
setMarkedAsUnread
-
setToken
-
setTokenTimestampSeconds
-
setIdentityKey
-
setPinnedTimestampSeconds
-
setMute
-
setWallpaper
-
setMediaVisibility
-
setTokenSenderTimestampSeconds
-
setSuspended
-
setTerminated
-
setFoundationTimestampSeconds
-
setFounder
-
setDescription
-
setSupport
-
setParentGroup
-
setDefaultSubGroup
-
setDisplayName
-
setPhoneJid
-
setPnhDuplicateLidThread
-
setLidJid
-
hasUpdate
public boolean hasUpdate()
-