diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 86372116d..f990ce1fc 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -5330,43 +5330,38 @@ bool ContactsManager::get_user_read_dates_private(UserId user_id) { return false; } -string ContactsManager::get_dialog_about(DialogId dialog_id) { - switch (dialog_id.get_type()) { - case DialogType::User: { - auto user_full = get_user_full_force(dialog_id.get_user_id(), "get_dialog_about"); - if (user_full != nullptr) { - return user_full->about; - } - break; - } - case DialogType::Chat: { - auto chat_full = get_chat_full_force(dialog_id.get_chat_id(), "get_dialog_about"); - if (chat_full != nullptr) { - return chat_full->description; - } - break; - } - case DialogType::Channel: { - auto channel_full = get_channel_full_force(dialog_id.get_channel_id(), false, "get_dialog_about"); - if (channel_full != nullptr) { - return channel_full->description; - } - break; - } - case DialogType::SecretChat: { - auto user_full = get_user_full_force(get_secret_chat_user_id(dialog_id.get_secret_chat_id()), "get_dialog_about"); - if (user_full != nullptr) { - return user_full->about; - } - break; - } - case DialogType::None: - default: - UNREACHABLE(); +string ContactsManager::get_user_about(UserId user_id) { + auto user_full = get_user_full_force(user_id, "get_user_about"); + if (user_full != nullptr) { + return user_full->about; } return string(); } +string ContactsManager::get_chat_about(ChatId chat_id) { + auto chat_full = get_chat_full_force(chat_id, "get_chat_about"); + if (chat_full != nullptr) { + return chat_full->description; + } + return string(); +} + +string ContactsManager::get_channel_about(ChannelId channel_id) { + auto channel_full = get_channel_full_force(channel_id, false, "get_channel_about"); + if (channel_full != nullptr) { + return channel_full->description; + } + return string(); +} + +string ContactsManager::get_secret_chat_about(SecretChatId secret_chat_id) { + auto c = get_secret_chat(secret_chat_id); + if (c == nullptr) { + return string(); + } + 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: diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index b1021d33d..2f192112d 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -155,6 +155,11 @@ class ContactsManager final : public Actor { td_api::object_ptr get_channel_emoji_status_object(ChannelId channel_id) const; td_api::object_ptr get_secret_chat_emoji_status_object(SecretChatId secret_chat_id) const; + string get_user_about(UserId user_id); + string get_chat_about(ChatId chat_id); + string get_channel_about(ChannelId channel_id); + string get_secret_chat_about(SecretChatId secret_chat_id); + bool get_chat_has_protected_content(ChatId chat_id) const; bool get_channel_has_protected_content(ChannelId channel_id) const; @@ -167,8 +172,6 @@ class ContactsManager final : public Actor { bool get_user_read_dates_private(UserId user_id); - string get_dialog_about(DialogId dialog_id); - string get_dialog_search_text(DialogId dialog_id) const; void for_each_secret_chat_with_user(UserId user_id, const std::function &f); diff --git a/td/telegram/DialogInviteLinkManager.cpp b/td/telegram/DialogInviteLinkManager.cpp index 62183dbf6..f190dfd76 100644 --- a/td/telegram/DialogInviteLinkManager.cpp +++ b/td/telegram/DialogInviteLinkManager.cpp @@ -840,7 +840,7 @@ td_api::object_ptr DialogInviteLinkManager::get_chat default: UNREACHABLE(); } - description = td_->contacts_manager_->get_dialog_about(dialog_id); + description = td_->dialog_manager_->get_dialog_about(dialog_id); } else { is_chat = invite_link_info->is_chat; is_megagroup = invite_link_info->is_megagroup; diff --git a/td/telegram/DialogManager.cpp b/td/telegram/DialogManager.cpp index e41a322e6..8648cd8f1 100644 --- a/td/telegram/DialogManager.cpp +++ b/td/telegram/DialogManager.cpp @@ -1090,6 +1090,23 @@ td_api::object_ptr DialogManager::get_dialog_emoji_status_o } } +string DialogManager::get_dialog_about(DialogId dialog_id) { + switch (dialog_id.get_type()) { + case DialogType::User: + return td_->contacts_manager_->get_user_about(dialog_id.get_user_id()); + case DialogType::Chat: + return td_->contacts_manager_->get_chat_about(dialog_id.get_chat_id()); + case DialogType::Channel: + return td_->contacts_manager_->get_channel_about(dialog_id.get_channel_id()); + case DialogType::SecretChat: + return td_->contacts_manager_->get_secret_chat_about(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 a3ef4559d..8d4605902 100644 --- a/td/telegram/DialogManager.h +++ b/td/telegram/DialogManager.h @@ -132,6 +132,8 @@ class DialogManager final : public Actor { td_api::object_ptr get_dialog_emoji_status_object(DialogId dialog_id) const; + string get_dialog_about(DialogId dialog_id); + bool get_dialog_has_protected_content(DialogId dialog_id) const; bool is_dialog_action_unneeded(DialogId dialog_id) const; diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index eebaae812..e503379e4 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -2692,7 +2692,7 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_di GroupCallParticipant participant; participant.is_self = true; participant.dialog_id = as_dialog_id; - participant.about = td_->contacts_manager_->get_dialog_about(participant.dialog_id); + participant.about = td_->dialog_manager_->get_dialog_about(participant.dialog_id); participant.audio_source = audio_source; participant.joined_date = G()->unix_time(); // if can_self_unmute has never been inited from self-participant,