diff --git a/td/telegram/DialogFilterManager.cpp b/td/telegram/DialogFilterManager.cpp index 3f598fc4b..911a0a2b8 100644 --- a/td/telegram/DialogFilterManager.cpp +++ b/td/telegram/DialogFilterManager.cpp @@ -399,7 +399,7 @@ class GetChatlistUpdatesQuery final : public Td::ResultHandler { LOG(INFO) << "Receive result for GetChatlistUpdatesQuery: " << to_string(ptr); td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetChatlistUpdatesQuery"); td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetChatlistUpdatesQuery"); - auto missing_dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(ptr->missing_peers_), true); + auto missing_dialog_ids = td_->dialog_manager_->get_peers_dialog_ids(std::move(ptr->missing_peers_), true); promise_.set_value(td_->dialog_manager_->get_chats_object(-1, missing_dialog_ids, "GetChatlistUpdatesQuery")); } @@ -1709,7 +1709,7 @@ void DialogFilterManager::on_get_leave_dialog_filter_suggestions( return promise.set_value(td_api::make_object()); } - auto dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(peers)); + auto dialog_ids = td_->dialog_manager_->get_peers_dialog_ids(std::move(peers)); td::remove_if(dialog_ids, [&](DialogId dialog_id) { return !dialog_filter->is_dialog_included(dialog_id); }); promise.set_value(td_->dialog_manager_->get_chats_object(-1, dialog_ids, "on_get_leave_dialog_filter_suggestions")); } @@ -2022,8 +2022,8 @@ void DialogFilterManager::on_get_chatlist_invite( td_->contacts_manager_->on_get_users(std::move(users), "on_get_chatlist_invite"); td_->contacts_manager_->on_get_chats(std::move(chats), "on_get_chatlist_invite"); - auto missing_dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(missing_peers), true); - auto already_dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(already_peers)); + auto missing_dialog_ids = td_->dialog_manager_->get_peers_dialog_ids(std::move(missing_peers), true); + auto already_dialog_ids = td_->dialog_manager_->get_peers_dialog_ids(std::move(already_peers)); promise.set_value(td_api::make_object( std::move(info), td_->dialog_manager_->get_chat_ids_object(missing_dialog_ids, "chatFolderInviteLinkInfo 1"), td_->dialog_manager_->get_chat_ids_object(already_dialog_ids, "chatFolderInviteLinkInfo 1"))); diff --git a/td/telegram/DialogManager.cpp b/td/telegram/DialogManager.cpp index 4e11aca20..221f19b3c 100644 --- a/td/telegram/DialogManager.cpp +++ b/td/telegram/DialogManager.cpp @@ -181,6 +181,20 @@ void DialogManager::force_create_dialog(DialogId dialog_id, const char *source, td_->messages_manager_->force_create_dialog(dialog_id, source, expect_no_access, force_update_dialog_pos); } +vector DialogManager::get_peers_dialog_ids(vector> &&peers, + bool expect_no_access) { + vector result; + result.reserve(peers.size()); + for (auto &peer : peers) { + DialogId dialog_id(peer); + if (dialog_id.is_valid()) { + force_create_dialog(dialog_id, "get_peers_dialog_ids", expect_no_access); + result.push_back(dialog_id); + } + } + return result; +} + bool DialogManager::have_dialog_info(DialogId dialog_id) const { switch (dialog_id.get_type()) { case DialogType::User: { diff --git a/td/telegram/DialogManager.h b/td/telegram/DialogManager.h index 57e95e0b4..541582aa5 100644 --- a/td/telegram/DialogManager.h +++ b/td/telegram/DialogManager.h @@ -59,6 +59,9 @@ class DialogManager final : public Actor { void force_create_dialog(DialogId dialog_id, const char *source, bool expect_no_access = false, bool force_update_dialog_pos = false); + vector get_peers_dialog_ids(vector> &&peers, + bool expect_no_access = false); + bool have_dialog_info(DialogId dialog_id) const; bool have_dialog_info_force(DialogId dialog_id, const char *source) const; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index fc19326b9..963699547 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -9964,20 +9964,6 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_ promise.set_value(Unit()); } -vector MessagesManager::get_peers_dialog_ids(vector> &&peers, - bool expect_no_access) { - vector result; - result.reserve(peers.size()); - for (auto &peer : peers) { - DialogId dialog_id(peer); - if (dialog_id.is_valid()) { - force_create_dialog(dialog_id, "get_peers_dialog_ids", expect_no_access); - result.push_back(dialog_id); - } - } - return result; -} - void MessagesManager::on_get_public_dialogs_search_result(const string &query, vector> &&my_peers, vector> &&peers) { @@ -9987,8 +9973,8 @@ void MessagesManager::on_get_public_dialogs_search_result(const string &query, auto promises = std::move(it->second); search_public_dialogs_queries_.erase(it); - found_public_dialogs_[query] = get_peers_dialog_ids(std::move(peers)); - found_on_server_dialogs_[query] = get_peers_dialog_ids(std::move(my_peers)); + found_public_dialogs_[query] = td_->dialog_manager_->get_peers_dialog_ids(std::move(peers)); + found_on_server_dialogs_[query] = td_->dialog_manager_->get_peers_dialog_ids(std::move(my_peers)); set_promises(promises); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 15cb453f5..9d25c64aa 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -151,9 +151,6 @@ class MessagesManager final : public Actor { static int32 get_message_date(const tl_object_ptr &message_ptr); - vector get_peers_dialog_ids(vector> &&peers, - bool expect_no_access = false); - void on_get_empty_messages(DialogId dialog_id, const vector &empty_message_ids); void get_channel_difference_if_needed(DialogId dialog_id, MessagesInfo &&messages_info,