diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index dde12ea32..5729c169d 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -5361,23 +5361,6 @@ string ContactsManager::get_secret_chat_about(SecretChatId secret_chat_id) { return get_user_about(c->user_id); } -string ContactsManager::get_dialog_search_text(DialogId dialog_id) const { - switch (dialog_id.get_type()) { - case DialogType::User: - return get_user_search_text(dialog_id.get_user_id()); - case DialogType::Chat: - return get_chat_title(dialog_id.get_chat_id()); - case DialogType::Channel: - return get_channel_search_text(dialog_id.get_channel_id()); - case DialogType::SecretChat: - return get_user_search_text(get_secret_chat_user_id(dialog_id.get_secret_chat_id())); - case DialogType::None: - default: - UNREACHABLE(); - } - return string(); -} - string ContactsManager::get_user_search_text(UserId user_id) const { auto u = get_user(user_id); if (u == nullptr) { @@ -5396,11 +5379,6 @@ string ContactsManager::get_channel_search_text(ChannelId channel_id) const { if (c == nullptr) { return get_channel_title(channel_id); } - return get_channel_search_text(c); -} - -string ContactsManager::get_channel_search_text(const Channel *c) { - CHECK(c != nullptr); return PSTRING() << c->title << ' ' << implode(c->usernames.get_active_usernames()); } @@ -17063,7 +17041,7 @@ std::pair> ContactsManager::search_among_dialogs(const v if (query.empty()) { hints.add(dialog_id.get(), Slice(" ")); } else { - hints.add(dialog_id.get(), get_dialog_search_text(dialog_id)); + hints.add(dialog_id.get(), td_->dialog_manager_->get_dialog_search_text(dialog_id)); } } hints.set_rating(dialog_id.get(), rating); diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index a071284fe..6fe131512 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -172,7 +172,9 @@ class ContactsManager final : public Actor { bool get_user_read_dates_private(UserId user_id); - string get_dialog_search_text(DialogId dialog_id) const; + string get_user_search_text(UserId user_id) const; + + string get_channel_search_text(ChannelId channel_id) const; void for_each_secret_chat_with_user(UserId user_id, const std::function &f); @@ -1400,7 +1402,6 @@ class ContactsManager final : public Actor { SecretChat *add_secret_chat(SecretChatId secret_chat_id); - string get_user_search_text(UserId user_id) const; static string get_user_search_text(const User *u); static DialogParticipantStatus get_chat_status(const Chat *c); @@ -1415,9 +1416,6 @@ class ContactsManager final : public Actor { static bool get_channel_join_to_send(const Channel *c); static bool get_channel_join_request(const Channel *c); - string get_channel_search_text(ChannelId channel_id) const; - static string get_channel_search_text(const Channel *c); - void set_my_id(UserId my_id); void on_set_emoji_status(EmojiStatus emoji_status, Promise &&promise); diff --git a/td/telegram/DialogManager.cpp b/td/telegram/DialogManager.cpp index 2dcf632e8..18bc6f992 100644 --- a/td/telegram/DialogManager.cpp +++ b/td/telegram/DialogManager.cpp @@ -1107,6 +1107,24 @@ string DialogManager::get_dialog_about(DialogId dialog_id) { } } +string DialogManager::get_dialog_search_text(DialogId dialog_id) const { + switch (dialog_id.get_type()) { + case DialogType::User: + return td_->contacts_manager_->get_user_search_text(dialog_id.get_user_id()); + case DialogType::Chat: + return td_->contacts_manager_->get_chat_title(dialog_id.get_chat_id()); + case DialogType::Channel: + return td_->contacts_manager_->get_channel_search_text(dialog_id.get_channel_id()); + case DialogType::SecretChat: + return td_->contacts_manager_->get_user_search_text( + td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id())); + case DialogType::None: + default: + UNREACHABLE(); + } + return string(); +} + bool DialogManager::get_dialog_has_protected_content(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 041016aa8..31159c973 100644 --- a/td/telegram/DialogManager.h +++ b/td/telegram/DialogManager.h @@ -135,6 +135,8 @@ class DialogManager final : public Actor { string get_dialog_about(DialogId dialog_id); + string get_dialog_search_text(DialogId dialog_id) const; + bool get_dialog_has_protected_content(DialogId dialog_id) const; bool is_dialog_action_unneeded(DialogId dialog_id) const; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index a26fb67fa..6a6d2cc00 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -15992,7 +15992,7 @@ std::pair> MessagesManager::search_recently_found_dialog Hints hints; int rating = 1; for (auto dialog_id : result.second) { - hints.add(dialog_id.get(), td_->contacts_manager_->get_dialog_search_text(dialog_id)); + hints.add(dialog_id.get(), td_->dialog_manager_->get_dialog_search_text(dialog_id)); hints.set_rating(dialog_id.get(), ++rating); } @@ -34705,7 +34705,7 @@ bool MessagesManager::add_pending_dialog_data(Dialog *d, unique_ptr &&l void MessagesManager::update_dialogs_hints(const Dialog *d) { if (!td_->auth_manager_->is_bot() && d->order != DEFAULT_ORDER) { - dialogs_hints_.add(-d->dialog_id.get(), td_->contacts_manager_->get_dialog_search_text(d->dialog_id)); + dialogs_hints_.add(-d->dialog_id.get(), td_->dialog_manager_->get_dialog_search_text(d->dialog_id)); } }