java.lang.Object
it.auties.whatsapp.util.DefaultControllerSerializer
- All Implemented Interfaces:
ControllerSerializer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<UUID, CompletableFuture<Void>> private final Pathprivate LinkedList<PhoneNumber> private LinkedList<UUID> private static final Stringprivate static final Pathprivate static final Stringprivate static final Stringprivate static final Map<Path, DefaultControllerSerializer> private static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattributeStore(Store store) Attributes the store asynchronously.private voidattributeStoreContextInfo(Store store, ContextInfo contextInfo) private voidattributeStoreContextualMessage(Store store, HistorySyncMessage message) private voidprivate PathvoiddeleteSession(Controller<?> controller) Deletes a sessionprivate voiddeserializeChat(Store store, Path chatFile) deserializeKeys(ClientType type, long phoneNumber) Serializes the keysdeserializeKeys(ClientType type, String alias) Serializes the keysdeserializeKeys(ClientType type, UUID id) Serializes the keysdeserializeKeysFromId(ClientType type, String id) private voiddeserializeNewsletter(Store store, Path newsletterFile) deserializeStore(ClientType type, long phoneNumber) Serializes the storedeserializeStore(ClientType type, String alias) Serializes the storedeserializeStore(ClientType type, UUID id) Serializes the storedeserializeStoreFromId(ClientType type, String id) deserializeStoreKeysPair(UUID uuid, Long phoneNumber, String alias, ClientType clientType) Deserializes a store-keys pair from a list of possible identifiersprivate PathgetHome(ClientType type) private FileTimegetLastModifiedTime(Path path) private PathgetSessionDirectory(ClientType clientType, String path) private PathgetSessionFile(ClientType clientType, String uuid, String fileName) private PathgetSessionFile(Store store, String fileName) private CompletableFuture<Void> handleStoreFile(Store store, Path entry) voidlinkMetadata(Controller<?> controller) Creates a link between the session and its metadata, usually phone number and aliasprivate voidlinkToUuid(ClientType type, UUID uuid, String string) listIds(ClientType type) Returns all the known IDslistPhoneNumbers(ClientType type) Returns all the known IDsnewStoreKeysPair(UUID uuid, Long phoneNumber, Collection<String> alias, ClientType clientType) Creates a fresh pair of store and keysstatic ControllerSerializerof()static ControllerSerializerprivate VoidparsePathAsId(Path file) private Optional<PhoneNumber> parsePathAsPhoneNumber(Path file) private ChatrescueChat(Path entry) private NewsletterrescueNewsletter(Path entry) private CompletableFuture<Void> serializeChatAsync(Store store, Chat chat) private CompletableFuture<?>[]serializeChatsAsync(Store store) serializeKeys(Keys keys, boolean async) Serializes the keysprivate CompletableFuture<Void> serializeNewsletterAsync(Store store, Newsletter newsletter) private CompletableFuture<?>[]serializeNewslettersAsync(Store store) serializeStore(Store store, boolean async) Serializes the storeprivate void
-
Field Details
-
DEFAULT_SERIALIZER_PATH
-
CHAT_PREFIX
- See Also:
-
NEWSLETTER_PREFIX
- See Also:
-
STORE_NAME
- See Also:
-
KEYS_NAME
- See Also:
-
serializers
-
baseDirectory
-
attributeStoreSerializers
-
cachedUuids
-
cachedPhoneNumbers
-
-
Constructor Details
-
DefaultControllerSerializer
-
-
Method Details
-
of
-
of
-
newStoreKeysPair
public StoreKeysPair newStoreKeysPair(UUID uuid, Long phoneNumber, Collection<String> alias, ClientType clientType) Description copied from interface:ControllerSerializerCreates a fresh pair of store and keys- Specified by:
newStoreKeysPairin interfaceControllerSerializer- Parameters:
uuid- the non-null uuidphoneNumber- the nullable phone numberalias- the nullable aliasclientType- the non-null client type- Returns:
- a non-null store-keys pair
-
deserializeStoreKeysPair
public Optional<StoreKeysPair> deserializeStoreKeysPair(UUID uuid, Long phoneNumber, String alias, ClientType clientType) Description copied from interface:ControllerSerializerDeserializes a store-keys pair from a list of possible identifiers- Specified by:
deserializeStoreKeysPairin interfaceControllerSerializer- Parameters:
uuid- the nullable identifying unique idphoneNumber- the nullable identifying phone numberalias- the nullable identifying aliasclientType- the non-null client type- Returns:
- an optional store-keys pair
-
listIds
Description copied from interface:ControllerSerializerReturns all the known IDs- Specified by:
listIdsin interfaceControllerSerializer- Parameters:
type- the non-null type of client- Returns:
- a non-null linked list
-
listPhoneNumbers
Description copied from interface:ControllerSerializerReturns all the known IDs- Specified by:
listPhoneNumbersin interfaceControllerSerializer- Parameters:
type- the non-null type of client- Returns:
- a non-null linked list
-
getLastModifiedTime
-
parsePathAsId
-
parsePathAsPhoneNumber
-
serializeKeys
Description copied from interface:ControllerSerializerSerializes the keys- Specified by:
serializeKeysin interfaceControllerSerializer- Parameters:
keys- the non-null keys to serializeasync- whether the operation should be executed asynchronously
-
serializeStore
Description copied from interface:ControllerSerializerSerializes the store- Specified by:
serializeStorein interfaceControllerSerializer- Parameters:
store- the non-null store to serializeasync- whether the operation should be executed asynchronously
-
serializeChatsAsync
-
serializeChatAsync
-
onError
-
serializeNewslettersAsync
-
serializeNewsletterAsync
-
writeFile
-
deserializeKeys
Description copied from interface:ControllerSerializerSerializes the keys- Specified by:
deserializeKeysin interfaceControllerSerializer- Parameters:
type- the non-null type of clientid- the id of the keys- Returns:
- a non-null keys
-
deserializeKeys
Description copied from interface:ControllerSerializerSerializes the keys- Specified by:
deserializeKeysin interfaceControllerSerializer- Parameters:
type- the non-null type of clientalias- the alias number of the keys- Returns:
- a non-null keys
-
deserializeKeys
Description copied from interface:ControllerSerializerSerializes the keys- Specified by:
deserializeKeysin interfaceControllerSerializer- Parameters:
type- the non-null type of clientphoneNumber- the phone number of the keys- Returns:
- a non-null keys
-
deserializeKeysFromId
-
deserializeStore
Description copied from interface:ControllerSerializerSerializes the store- Specified by:
deserializeStorein interfaceControllerSerializer- Parameters:
type- the non-null type of clientid- the id of the store- Returns:
- a non-null store
-
deserializeStore
Description copied from interface:ControllerSerializerSerializes the store- Specified by:
deserializeStorein interfaceControllerSerializer- Parameters:
type- the non-null type of clientalias- the alias of the store- Returns:
- a non-null store
-
deserializeStore
Description copied from interface:ControllerSerializerSerializes the store- Specified by:
deserializeStorein interfaceControllerSerializer- Parameters:
type- the non-null type of clientphoneNumber- the phone number of the store- Returns:
- a non-null store
-
deserializeStoreFromId
-
attributeStore
Description copied from interface:ControllerSerializerAttributes the store asynchronously. This method is optionally used to load asynchronously heavy data such as chats while the socket is connecting. If implemented, cache the returning newsletters because the method may be called multiple times.- Specified by:
attributeStorein interfaceControllerSerializer- Parameters:
store- the non-null store to attribute- Returns:
- a completable newsletters
-
attributeStoreContextualMessages
-
attributeStoreContextualMessage
-
attributeStoreContextInfo
-
handleStoreFile
-
deleteSession
Description copied from interface:ControllerSerializerDeletes a session- Specified by:
deleteSessionin interfaceControllerSerializer- Parameters:
controller- the non-null controller
-
delete
- Throws:
IOException
-
linkMetadata
Description copied from interface:ControllerSerializerCreates a link between the session and its metadata, usually phone number and alias- Specified by:
linkMetadatain interfaceControllerSerializer- Parameters:
controller- a non-null controller
-
linkToUuid
-
deserializeChat
-
rescueChat
-
deserializeNewsletter
-
rescueNewsletter
-
getHome
-
getSessionDirectory
-
getSessionFile
-
getSessionFile
-