Move get_peers_dialog_ids to DialogManager.
This commit is contained in:
parent
b97fa08e62
commit
d24a0eda1d
@ -399,7 +399,7 @@ class GetChatlistUpdatesQuery final : public Td::ResultHandler {
|
|||||||
LOG(INFO) << "Receive result for GetChatlistUpdatesQuery: " << to_string(ptr);
|
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_users(std::move(ptr->users_), "GetChatlistUpdatesQuery");
|
||||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "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"));
|
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<td_api::chats>());
|
return promise.set_value(td_api::make_object<td_api::chats>());
|
||||||
}
|
}
|
||||||
|
|
||||||
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); });
|
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"));
|
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_users(std::move(users), "on_get_chatlist_invite");
|
||||||
td_->contacts_manager_->on_get_chats(std::move(chats), "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 missing_dialog_ids = td_->dialog_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 already_dialog_ids = td_->dialog_manager_->get_peers_dialog_ids(std::move(already_peers));
|
||||||
promise.set_value(td_api::make_object<td_api::chatFolderInviteLinkInfo>(
|
promise.set_value(td_api::make_object<td_api::chatFolderInviteLinkInfo>(
|
||||||
std::move(info), td_->dialog_manager_->get_chat_ids_object(missing_dialog_ids, "chatFolderInviteLinkInfo 1"),
|
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")));
|
td_->dialog_manager_->get_chat_ids_object(already_dialog_ids, "chatFolderInviteLinkInfo 1")));
|
||||||
|
@ -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);
|
td_->messages_manager_->force_create_dialog(dialog_id, source, expect_no_access, force_update_dialog_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<DialogId> DialogManager::get_peers_dialog_ids(vector<telegram_api::object_ptr<telegram_api::Peer>> &&peers,
|
||||||
|
bool expect_no_access) {
|
||||||
|
vector<DialogId> 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 {
|
bool DialogManager::have_dialog_info(DialogId dialog_id) const {
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User: {
|
case DialogType::User: {
|
||||||
|
@ -59,6 +59,9 @@ class DialogManager final : public Actor {
|
|||||||
void force_create_dialog(DialogId dialog_id, const char *source, bool expect_no_access = false,
|
void force_create_dialog(DialogId dialog_id, const char *source, bool expect_no_access = false,
|
||||||
bool force_update_dialog_pos = false);
|
bool force_update_dialog_pos = false);
|
||||||
|
|
||||||
|
vector<DialogId> get_peers_dialog_ids(vector<telegram_api::object_ptr<telegram_api::Peer>> &&peers,
|
||||||
|
bool expect_no_access = false);
|
||||||
|
|
||||||
bool have_dialog_info(DialogId dialog_id) const;
|
bool have_dialog_info(DialogId dialog_id) const;
|
||||||
|
|
||||||
bool have_dialog_info_force(DialogId dialog_id, const char *source) const;
|
bool have_dialog_info_force(DialogId dialog_id, const char *source) const;
|
||||||
|
@ -9964,20 +9964,6 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<DialogId> MessagesManager::get_peers_dialog_ids(vector<tl_object_ptr<telegram_api::Peer>> &&peers,
|
|
||||||
bool expect_no_access) {
|
|
||||||
vector<DialogId> 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,
|
void MessagesManager::on_get_public_dialogs_search_result(const string &query,
|
||||||
vector<tl_object_ptr<telegram_api::Peer>> &&my_peers,
|
vector<tl_object_ptr<telegram_api::Peer>> &&my_peers,
|
||||||
vector<tl_object_ptr<telegram_api::Peer>> &&peers) {
|
vector<tl_object_ptr<telegram_api::Peer>> &&peers) {
|
||||||
@ -9987,8 +9973,8 @@ void MessagesManager::on_get_public_dialogs_search_result(const string &query,
|
|||||||
auto promises = std::move(it->second);
|
auto promises = std::move(it->second);
|
||||||
search_public_dialogs_queries_.erase(it);
|
search_public_dialogs_queries_.erase(it);
|
||||||
|
|
||||||
found_public_dialogs_[query] = get_peers_dialog_ids(std::move(peers));
|
found_public_dialogs_[query] = td_->dialog_manager_->get_peers_dialog_ids(std::move(peers));
|
||||||
found_on_server_dialogs_[query] = get_peers_dialog_ids(std::move(my_peers));
|
found_on_server_dialogs_[query] = td_->dialog_manager_->get_peers_dialog_ids(std::move(my_peers));
|
||||||
|
|
||||||
set_promises(promises);
|
set_promises(promises);
|
||||||
}
|
}
|
||||||
|
@ -151,9 +151,6 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
static int32 get_message_date(const tl_object_ptr<telegram_api::Message> &message_ptr);
|
static int32 get_message_date(const tl_object_ptr<telegram_api::Message> &message_ptr);
|
||||||
|
|
||||||
vector<DialogId> get_peers_dialog_ids(vector<tl_object_ptr<telegram_api::Peer>> &&peers,
|
|
||||||
bool expect_no_access = false);
|
|
||||||
|
|
||||||
void on_get_empty_messages(DialogId dialog_id, const vector<MessageId> &empty_message_ids);
|
void on_get_empty_messages(DialogId dialog_id, const vector<MessageId> &empty_message_ids);
|
||||||
|
|
||||||
void get_channel_difference_if_needed(DialogId dialog_id, MessagesInfo &&messages_info,
|
void get_channel_difference_if_needed(DialogId dialog_id, MessagesInfo &&messages_info,
|
||||||
|
Loading…
Reference in New Issue
Block a user