diff --git a/CMakeLists.txt b/CMakeLists.txt index 96a3f48f6..4afbde281 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -456,6 +456,7 @@ set(TDLIB_SOURCE td/telegram/Contact.h td/telegram/ContactsManager.h td/telegram/DelayDispatcher.h + td/telegram/Dependencies.h td/telegram/DeviceTokenManager.h td/telegram/DhCache.h td/telegram/DhConfig.h diff --git a/td/telegram/Dependencies.h b/td/telegram/Dependencies.h new file mode 100644 index 000000000..9807cae9a --- /dev/null +++ b/td/telegram/Dependencies.h @@ -0,0 +1,29 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#pragma once + +#include "td/telegram/ChannelId.h" +#include "td/telegram/ChatId.h" +#include "td/telegram/DialogId.h" +#include "td/telegram/SecretChatId.h" +#include "td/telegram/UserId.h" +#include "td/telegram/WebPageId.h" + +#include + +namespace td { + +struct Dependencies { + std::unordered_set user_ids; + std::unordered_set chat_ids; + std::unordered_set channel_ids; + std::unordered_set secret_chat_ids; + std::unordered_set dialog_ids; + std::unordered_set web_page_ids; +}; + +} // namespace td diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index f18f235ca..52e5fae0e 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -2196,4 +2196,12 @@ Status fix_formatted_text(string &text, vector &entities, bool al return Status::OK(); } +void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText &text) { + for (auto &entity : text.entities) { + if (entity.user_id.is_valid()) { + dependencies.user_ids.insert(entity.user_id); + } + } +} + } // namespace td diff --git a/td/telegram/MessageEntity.h b/td/telegram/MessageEntity.h index f0af48ccb..cea0061c0 100644 --- a/td/telegram/MessageEntity.h +++ b/td/telegram/MessageEntity.h @@ -6,6 +6,7 @@ // #pragma once +#include "td/telegram/Dependencies.h" #include "td/telegram/UserId.h" #include "td/utils/common.h" @@ -144,4 +145,6 @@ vector get_message_entities(vector &entities, bool allow_empty, bool skip_new_entities, bool skip_bot_commands, bool for_draft) TD_WARN_UNUSED_RESULT; +void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText &text); + } // namespace td diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 933a24f6f..ed727a798 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -16681,14 +16681,6 @@ bool MessagesManager::is_message_auto_read(DialogId dialog_id, bool is_outgoing) } } -void MessagesManager::add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText &text) { - for (auto &entity : text.entities) { - if (entity.user_id.is_valid()) { - dependencies.user_ids.insert(entity.user_id); - } - } -} - void MessagesManager::add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m) { dependencies.user_ids.insert(m->sender_user_id); dependencies.user_ids.insert(m->via_bot_user_id); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index c478496ae..9c74c229c 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -23,6 +23,7 @@ #include "td/telegram/ChannelId.h" #include "td/telegram/ChatId.h" #include "td/telegram/Contact.h" +#include "td/telegram/Dependencies.h" #include "td/telegram/DialogId.h" #include "td/telegram/DialogParticipant.h" #include "td/telegram/DocumentsManager.h" @@ -855,16 +856,6 @@ class dummyUpdate : public telegram_api::Update { void store(TlStorerToString &s, const char *field_name) const override; }; -class Dependencies { - public: - std::unordered_set user_ids; - std::unordered_set chat_ids; - std::unordered_set channel_ids; - std::unordered_set secret_chat_ids; - std::unordered_set dialog_ids; - std::unordered_set web_page_ids; -}; - struct CallsDbState { std::array first_calls_database_message_id_by_index; std::array message_count_by_index; @@ -2747,8 +2738,6 @@ class MessagesManager : public Actor { static void dump_debug_message_op(const Dialog *d, int priority = 0); - static void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText &text); - static void add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m); static void add_dialog_dependencies(Dependencies &dependencies, DialogId dialog_id);