Move get_dialog_about to DialogManager.

This commit is contained in:
levlam 2024-02-19 01:10:57 +03:00
parent 5828e46046
commit 32040c22cb
6 changed files with 54 additions and 37 deletions

View File

@ -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:

View File

@ -155,6 +155,11 @@ class ContactsManager final : public Actor {
td_api::object_ptr<td_api::emojiStatus> get_channel_emoji_status_object(ChannelId channel_id) const;
td_api::object_ptr<td_api::emojiStatus> 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<void(SecretChatId)> &f);

View File

@ -840,7 +840,7 @@ td_api::object_ptr<td_api::chatInviteLinkInfo> 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;

View File

@ -1090,6 +1090,23 @@ td_api::object_ptr<td_api::emojiStatus> 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:

View File

@ -132,6 +132,8 @@ class DialogManager final : public Actor {
td_api::object_ptr<td_api::emojiStatus> 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;

View File

@ -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,