#ifndef _ACCOUNT_DATA_H #define _ACCOUNT_DATA_H #include #include #include enum { CHAT_HISTORY_REQUEST_LIMIT = 50, CHAT_HISTORY_RETRIEVE_LIMIT = 100 }; class TdAccountData { public: using TdUserPtr = td::td_api::object_ptr; using TdChatPtr = td::td_api::object_ptr; using TdMessagePtr = td::td_api::object_ptr; void updateUser(TdUserPtr user); void addChat(TdChatPtr chat); // Updates existing chat if any void setContacts(const std::vector &userIds); void setActiveChats(std::vector &&chats); void getContactsWithNoChat(std::vector &userIds); const td::td_api::chat *getChat(int64_t chatId) const; const td::td_api::chat *getPrivateChatByUserId(int32_t userId) const; const td::td_api::user *getUser(int32_t userId) const; const td::td_api::user *getUserByPhone(const char *phoneNumber) const; const td::td_api::user *getUserByPrivateChat(const td::td_api::chat &chat); void getPrivateChats(std::vector &chats) const; void addNewContactRequest(uint64_t requestId, const char *phoneNumber, const char *alias, int32_t userId = 0); bool extractContactRequest(uint64_t requestId, std::string &phoneNumber, std::string &alias, int32_t &userId); private: using UserInfoMap = std::map; using ChatInfoMap = std::map; struct ContactRequest { uint64_t requestId; std::string phoneNumber; std::string alias; int32_t userId; }; UserInfoMap m_userInfo; ChatInfoMap m_chatInfo; // List of contacts for which private chat is not known yet. std::vector m_contactUserIdsNoChat; // m_chatInfo can contain chats that are not in m_activeChats if some other chat contains // messages forwarded from another channel std::vector m_activeChats; std::vector m_addContactRequests; }; #endif