Rename rest of ContactsManager to ChatManager.

This commit is contained in:
levlam 2024-04-02 13:06:22 +03:00
parent 9482eb6ede
commit bd8c6be0cd
59 changed files with 1247 additions and 1295 deletions

View File

@ -318,13 +318,13 @@ set(TDLIB_SOURCE
td/telegram/CallManager.cpp
td/telegram/ChannelParticipantFilter.cpp
td/telegram/ChannelRecommendationManager.cpp
td/telegram/ChatManager.cpp
td/telegram/ChatReactions.cpp
td/telegram/ClientActor.cpp
td/telegram/CommonDialogManager.cpp
td/telegram/ConfigManager.cpp
td/telegram/ConnectionState.cpp
td/telegram/Contact.cpp
td/telegram/ContactsManager.cpp
td/telegram/CountryInfoManager.cpp
td/telegram/DelayDispatcher.cpp
td/telegram/Dependencies.cpp
@ -617,13 +617,13 @@ set(TDLIB_SOURCE
td/telegram/ChannelRecommendationManager.h
td/telegram/ChannelType.h
td/telegram/ChatId.h
td/telegram/ChatManager.h
td/telegram/ChatReactions.h
td/telegram/ClientActor.h
td/telegram/CommonDialogManager.h
td/telegram/ConfigManager.h
td/telegram/ConnectionState.h
td/telegram/Contact.h
td/telegram/ContactsManager.h
td/telegram/CountryInfoManager.h
td/telegram/CustomEmojiId.h
td/telegram/DelayDispatcher.h

View File

@ -326,8 +326,8 @@ function split_file($file, $chunks, $undo) {
'ChannelId' => 'ChannelId',
'channel_recommendation_manager[_(-](?![.]get[(][)])|ChannelRecommendationManager' => 'ChannelRecommendationManager',
'ChatId' => 'ChatId',
'chat_manager[_(-](?![.]get[(][)])|ChatManager([^ ;.]| [^*])' => 'ChatManager',
'common_dialog_manager[_(-](?![.]get[(][)])|CommonDialogManager' => 'CommonDialogManager',
'contacts_manager[_(-](?![.]get[(][)])|ContactsManager([^ ;.]| [^*])' => 'ContactsManager',
'country_info_manager[_(-](?![.]get[(][)])|CountryInfoManager' => 'CountryInfoManager',
'CustomEmojiId' => 'CustomEmojiId',
'device_token_manager[_(-](?![.]get[(][)])|DeviceTokenManager' => 'DeviceTokenManager',
@ -464,12 +464,12 @@ if (in_array('--help', $argv) || in_array('-h', $argv)) {
}
$undo = in_array('--undo', $argv) || in_array('-u', $argv);
$files = array('td/telegram/ContactsManager' => 20,
$files = array('td/telegram/ChatManager' => 10,
'td/telegram/MessagesManager' => 50,
'td/telegram/NotificationManager' => 10,
'td/telegram/StickersManager' => 10,
'td/telegram/Td' => 50,
'td/telegram/UserManager' => 20,
'td/telegram/UserManager' => 10,
'td/generate/auto/td/telegram/td_api' => 10,
'td/generate/auto/td/telegram/td_api_json' => 10,
'td/generate/auto/td/telegram/telegram_api' => 10);

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
@ -867,7 +867,7 @@ void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id,
if (!top_thread_message_id.is_valid() || !top_thread_message_id.is_server() ||
dialog_id.get_type() != DialogType::Channel ||
!td_->contacts_manager_->is_megagroup_channel(dialog_id.get_channel_id())) {
!td_->chat_manager_->is_megagroup_channel(dialog_id.get_channel_id())) {
top_thread_message_id = MessageId();
}
auto input_reply_to = td_->messages_manager_->create_message_input_reply_to(dialog_id, top_thread_message_id,

View File

@ -7,7 +7,7 @@
#include "td/telegram/AutosaveManager.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -386,7 +386,7 @@ void AutosaveManager::on_get_autosave_settings(
auto settings = r_settings.move_as_ok();
td_->user_manager_->on_get_users(std::move(settings->users_), "on_get_autosave_settings");
td_->contacts_manager_->on_get_chats(std::move(settings->chats_), "on_get_autosave_settings");
td_->chat_manager_->on_get_chats(std::move(settings->chats_), "on_get_autosave_settings");
DialogAutosaveSettings new_user_settings(settings->users_settings_.get());
DialogAutosaveSettings new_chat_settings(settings->chats_settings_.get());

View File

@ -9,7 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/BackgroundType.hpp"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
@ -779,8 +779,7 @@ Result<DialogId> BackgroundManager::get_background_dialog(DialogId dialog_id) {
return Status::Error(400, "Can't change background in the chat");
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id)
.can_change_info_and_settings_as_administrator()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_change_info_and_settings_as_administrator()) {
return Status::Error(400, "Not enough rights in the chat");
}
return dialog_id;

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/LinkManager.h"
@ -72,7 +72,7 @@ static td_api::object_ptr<td_api::chatBoost> get_chat_boost_object(
static td_api::object_ptr<td_api::chatBoostSlots> get_chat_boost_slots_object(
Td *td, telegram_api::object_ptr<telegram_api::premium_myBoosts> &&my_boosts) {
td->user_manager_->on_get_users(std::move(my_boosts->users_), "GetMyBoostsQuery");
td->contacts_manager_->on_get_chats(std::move(my_boosts->chats_), "GetMyBoostsQuery");
td->chat_manager_->on_get_chats(std::move(my_boosts->chats_), "GetMyBoostsQuery");
vector<td_api::object_ptr<td_api::chatBoostSlot>> slots;
for (auto &my_boost : my_boosts->my_boosts_) {
auto expiration_date = my_boost->expires_;
@ -179,7 +179,7 @@ class GetBoostsStatusQuery final : public Td::ResultHandler {
premium_member_count = max(0, static_cast<int32>(result->premium_audience_->part_));
auto participant_count = max(static_cast<int32>(result->premium_audience_->total_), premium_member_count);
if (dialog_id_.get_type() == DialogType::Channel) {
td_->contacts_manager_->on_update_channel_participant_count(dialog_id_.get_channel_id(), participant_count);
td_->chat_manager_->on_update_channel_participant_count(dialog_id_.get_channel_id(), participant_count);
}
if (participant_count > 0) {
premium_member_percentage = 100.0 * premium_member_count / participant_count;
@ -429,7 +429,7 @@ Result<std::pair<string, bool>> BoostManager::get_dialog_boost_link(DialogId dia
SliceBuilder sb;
sb << LinkManager::get_t_me_url() << "boost";
auto username = td_->contacts_manager_->get_channel_first_username(dialog_id.get_channel_id());
auto username = td_->chat_manager_->get_channel_first_username(dialog_id.get_channel_id());
bool is_public = !username.empty();
if (is_public) {
sb << '/' << username;

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/UserManager.h"
@ -79,7 +79,7 @@ Result<BotCommandScope> BotCommandScope::get_bot_command_scope(Td *td,
// ok
break;
case DialogType::Channel:
if (td->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
if (td->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
return Status::Error(400, "Can't change commands in channel chats");
}
break;

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/files/FileId.h"
#include "td/telegram/files/FileLocation.h"
@ -601,7 +601,7 @@ void BusinessConnectionManager::on_get_business_connection(
auto update = telegram_api::move_object_as<telegram_api::updateBotBusinessConnect>(updates->updates_[0]);
td_->user_manager_->on_get_users(std::move(updates->users_), "on_get_business_connection");
td_->contacts_manager_->on_get_chats(std::move(updates->chats_), "on_get_business_connection");
td_->chat_manager_->on_get_chats(std::move(updates->chats_), "on_get_business_connection");
auto business_connection = make_unique<BusinessConnection>(update->connection_);
if (!business_connection->is_valid() || connection_id != business_connection->connection_id_) {
@ -765,7 +765,7 @@ void BusinessConnectionManager::process_sent_business_message(
auto update = telegram_api::move_object_as<telegram_api::updateBotNewBusinessMessage>(updates->updates_[0]);
td_->user_manager_->on_get_users(std::move(updates->users_), "SendBusinessMediaQuery");
td_->contacts_manager_->on_get_chats(std::move(updates->chats_), "SendBusinessMediaQuery");
td_->chat_manager_->on_get_chats(std::move(updates->chats_), "SendBusinessMediaQuery");
promise.set_value(td_->messages_manager_->get_business_message_object(std::move(update->message_),
std::move(update->reply_to_message_)));
@ -1097,7 +1097,7 @@ void BusinessConnectionManager::process_sent_business_message_album(
}
}
td_->user_manager_->on_get_users(std::move(updates->users_), "process_sent_business_message_album");
td_->contacts_manager_->on_get_chats(std::move(updates->chats_), "process_sent_business_message_album");
td_->chat_manager_->on_get_chats(std::move(updates->chats_), "process_sent_business_message_album");
auto messages = td_api::make_object<td_api::businessMessages>();
for (auto &update_ptr : updates->updates_) {

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/Application.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -41,7 +41,7 @@ class GetChannelRecommendationsQuery final : public Td::ResultHandler {
void send(ChannelId channel_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(
G()->net_query_creator().create(telegram_api::channels_getChannelRecommendations(std::move(input_channel))));
@ -72,7 +72,7 @@ class GetChannelRecommendationsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelRecommendationsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetChannelRecommendationsQuery");
promise_.set_error(std::move(status));
}
};
@ -132,8 +132,8 @@ bool ChannelRecommendationManager::is_suitable_recommended_channel(DialogId dial
}
bool ChannelRecommendationManager::is_suitable_recommended_channel(ChannelId channel_id) const {
auto status = td_->contacts_manager_->get_channel_status(channel_id);
return !status.is_member() && td_->contacts_manager_->have_input_peer_channel(channel_id, AccessRights::Read);
auto status = td_->chat_manager_->get_channel_status(channel_id);
return !status.is_member() && td_->chat_manager_->have_input_peer_channel(channel_id, AccessRights::Read);
}
bool ChannelRecommendationManager::are_suitable_recommended_dialogs(
@ -173,8 +173,8 @@ void ChannelRecommendationManager::get_channel_recommendations(
return;
}
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->is_broadcast_channel(channel_id) ||
td_->contacts_manager_->get_input_channel(channel_id) == nullptr) {
if (!td_->chat_manager_->is_broadcast_channel(channel_id) ||
td_->chat_manager_->get_input_channel(channel_id) == nullptr) {
if (chats_promise) {
chats_promise.set_value(td_api::make_object<td_api::chats>());
}
@ -347,7 +347,7 @@ void ChannelRecommendationManager::on_get_channel_recommendations(
auto chats = r_chats.move_as_ok();
auto total_count = chats.first;
auto channel_ids = td_->contacts_manager_->get_channel_ids(std::move(chats.second), "on_get_channel_recommendations");
auto channel_ids = td_->chat_manager_->get_channel_ids(std::move(chats.second), "on_get_channel_recommendations");
vector<DialogId> dialog_ids;
if (total_count < static_cast<int32>(channel_ids.size())) {
LOG(ERROR) << "Receive total_count = " << total_count << " and " << channel_ids.size() << " similar chats for "

File diff suppressed because it is too large Load Diff

View File

@ -57,14 +57,14 @@ struct BinlogEvent;
struct MinChannel;
class Td;
class ContactsManager final : public Actor {
class ChatManager final : public Actor {
public:
ContactsManager(Td *td, ActorShared<> parent);
ContactsManager(const ContactsManager &) = delete;
ContactsManager &operator=(const ContactsManager &) = delete;
ContactsManager(ContactsManager &&) = delete;
ContactsManager &operator=(ContactsManager &&) = delete;
~ContactsManager() final;
ChatManager(Td *td, ActorShared<> parent);
ChatManager(const ChatManager &) = delete;
ChatManager &operator=(const ChatManager &) = delete;
ChatManager(ChatManager &&) = delete;
ChatManager &operator=(ChatManager &&) = delete;
~ChatManager() final;
static ChatId get_chat_id(const tl_object_ptr<telegram_api::Chat> &chat);
static ChannelId get_channel_id(const tl_object_ptr<telegram_api::Chat> &chat);
@ -875,11 +875,11 @@ class ContactsManager final : public Actor {
void get_channel_statistics_dc_id_impl(ChannelId channel_id, bool for_full_statistics, Promise<DcId> &&promise);
static void on_channel_emoji_status_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long);
static void on_channel_emoji_status_timeout_callback(void *chat_manager_ptr, int64 channel_id_long);
static void on_channel_unban_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long);
static void on_channel_unban_timeout_callback(void *chat_manager_ptr, int64 channel_id_long);
static void on_slow_mode_delay_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long);
static void on_slow_mode_delay_timeout_callback(void *chat_manager_ptr, int64 channel_id_long);
void on_channel_emoji_status_timeout(ChannelId channel_id);

View File

@ -6,7 +6,7 @@
//
#include "td/telegram/CommonDialogManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/Td.h"
@ -197,12 +197,12 @@ void CommonDialogManager::on_get_common_dialogs(UserId user_id, int64 offset_cha
}
bool is_last = chats.empty() && offset_chat_id == 0;
for (auto &chat : chats) {
auto dialog_id = ContactsManager::get_dialog_id(chat);
auto dialog_id = ChatManager::get_dialog_id(chat);
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << to_string(chat);
continue;
}
td_->contacts_manager_->on_get_chat(std::move(chat), "on_get_common_dialogs");
td_->chat_manager_->on_get_chat(std::move(chat), "on_get_common_dialogs");
if (!td::contains(result, dialog_id)) {
td_->dialog_manager_->force_create_dialog(dialog_id, "get common dialogs");

View File

@ -6,7 +6,7 @@
//
#include "td/telegram/Dependencies.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/StoryManager.h"
#include "td/telegram/Td.h"
@ -101,7 +101,7 @@ bool Dependencies::resolve_force(Td *td, const char *source, bool ignore_errors)
}
}
for (auto chat_id : chat_ids) {
if (!td->contacts_manager_->have_chat_force(chat_id, source)) {
if (!td->chat_manager_->have_chat_force(chat_id, source)) {
if (!ignore_errors) {
LOG(ERROR) << "Can't find " << chat_id << " from " << source;
}
@ -109,8 +109,8 @@ bool Dependencies::resolve_force(Td *td, const char *source, bool ignore_errors)
}
}
for (auto channel_id : channel_ids) {
if (!td->contacts_manager_->have_channel_force(channel_id, source)) {
if (td->contacts_manager_->have_min_channel(channel_id)) {
if (!td->chat_manager_->have_channel_force(channel_id, source)) {
if (td->chat_manager_->have_min_channel(channel_id)) {
LOG(INFO) << "Can't find " << channel_id << " from " << source << ", but have it as a min-channel";
continue;
}

View File

@ -6,7 +6,7 @@
//
#include "td/telegram/DialogActionBar.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/UserManager.h"
@ -97,8 +97,8 @@ void DialogActionBar::fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, Fo
}
}
if (can_invite_members_) {
if (dialog_type != DialogType::Chat && (dialog_type != DialogType::Channel ||
td->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id()))) {
if (dialog_type != DialogType::Chat &&
(dialog_type != DialogType::Channel || td->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id()))) {
LOG(ERROR) << "Receive can_invite_members in " << dialog_id;
can_invite_members_ = false;
} else if (can_report_spam_ || can_add_contact_ || can_block_user_ || can_share_phone_number_ || can_unarchive_) {

View File

@ -9,8 +9,8 @@
#include "td/telegram/AccentColorId.h"
#include "td/telegram/BackgroundInfo.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/ChatReactions.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogInviteLink.h"
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
@ -74,7 +74,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
case telegram_api::channelAdminLogEventActionParticipantInvite::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantInvite>(action_ptr);
DialogParticipant dialog_participant(std::move(action->participant_),
td->contacts_manager_->get_channel_type(channel_id));
td->chat_manager_->get_channel_type(channel_id));
if (!dialog_participant.is_valid() || dialog_participant.dialog_id_.get_type() != DialogType::User) {
LOG(ERROR) << "Wrong invite: " << dialog_participant;
return nullptr;
@ -85,7 +85,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
}
case telegram_api::channelAdminLogEventActionParticipantToggleBan::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleBan>(action_ptr);
auto channel_type = td->contacts_manager_->get_channel_type(channel_id);
auto channel_type = td->chat_manager_->get_channel_type(channel_id);
DialogParticipant old_dialog_participant(std::move(action->prev_participant_), channel_type);
DialogParticipant new_dialog_participant(std::move(action->new_participant_), channel_type);
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_) {
@ -103,7 +103,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
}
case telegram_api::channelAdminLogEventActionParticipantToggleAdmin::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleAdmin>(action_ptr);
auto channel_type = td->contacts_manager_->get_channel_type(channel_id);
auto channel_type = td->chat_manager_->get_channel_type(channel_id);
DialogParticipant old_dialog_participant(std::move(action->prev_participant_), channel_type);
DialogParticipant new_dialog_participant(std::move(action->new_participant_), channel_type);
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_) {
@ -151,7 +151,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
}
case telegram_api::channelAdminLogEventActionDefaultBannedRights::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDefaultBannedRights>(action_ptr);
auto channel_type = td->contacts_manager_->get_channel_type(channel_id);
auto channel_type = td->chat_manager_->get_channel_type(channel_id);
auto old_permissions = RestrictedRights(action->prev_banned_rights_, channel_type);
auto new_permissions = RestrictedRights(action->new_banned_rights_, channel_type);
return td_api::make_object<td_api::chatEventPermissionsChanged>(old_permissions.get_chat_permissions_object(),
@ -490,7 +490,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
vector<tl_object_ptr<telegram_api::InputUser>> input_users) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = 0;
@ -514,7 +514,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
auto events = result_ptr.move_as_ok();
LOG(INFO) << "Receive in " << channel_id_ << ' ' << to_string(events);
td_->user_manager_->on_get_users(std::move(events->users_), "on_get_event_log");
td_->contacts_manager_->on_get_chats(std::move(events->chats_), "on_get_event_log");
td_->chat_manager_->on_get_chats(std::move(events->chats_), "on_get_event_log");
auto anti_spam_user_id = UserId(G()->get_option_integer("anti_spam_bot_user_id"));
auto result = td_api::make_object<td_api::chatEvents>();
@ -556,7 +556,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdminLogQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdminLogQuery");
promise_.set_error(std::move(status));
}
};
@ -631,11 +631,11 @@ void get_dialog_event_log(Td *td, DialogId dialog_id, const string &query, int64
}
auto channel_id = dialog_id.get_channel_id();
if (!td->contacts_manager_->have_channel(channel_id)) {
if (!td->chat_manager_->have_channel(channel_id)) {
return promise.set_error(Status::Error(400, "Chat info not found"));
}
if (!td->contacts_manager_->get_channel_status(channel_id).is_administrator()) {
if (!td->chat_manager_->get_channel_status(channel_id).is_administrator()) {
return promise.set_error(Status::Error(400, "Not enough rights to get event log"));
}

View File

@ -6,7 +6,7 @@
//
#include "td/telegram/DialogFilter.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -734,16 +734,16 @@ vector<DialogId> DialogFilter::get_dialogs_for_invite_link(Td *td) {
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
// the user can manage invite links in the chat
is_good = td->contacts_manager_->get_chat_status(chat_id).can_manage_invite_links();
is_good = td->chat_manager_->get_chat_status(chat_id).can_manage_invite_links();
break;
}
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
// the user can manage invite links in the chat
// or the chat is a public chat, which can be joined without administrator approval
is_good = td->contacts_manager_->get_channel_status(channel_id).can_manage_invite_links() ||
(td->contacts_manager_->is_channel_public(channel_id) &&
!td->contacts_manager_->get_channel_join_request(channel_id));
is_good = td->chat_manager_->get_channel_status(channel_id).can_manage_invite_links() ||
(td->chat_manager_->is_channel_public(channel_id) &&
!td->chat_manager_->get_channel_join_request(channel_id));
break;
}
default:
@ -808,8 +808,7 @@ bool DialogFilter::need_dialog(const Td *td, const DialogFilterDialogInfo &dialo
case DialogType::Chat:
return include_groups_;
case DialogType::Channel:
return td->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id()) ? include_channels_
: include_groups_;
return td->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id()) ? include_channels_ : include_groups_;
case DialogType::SecretChat: {
auto user_id = td->user_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
if (td->user_manager_->is_user_bot(user_id)) {

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogFilter.h"
#include "td/telegram/DialogFilter.hpp"
#include "td/telegram/DialogFilterInviteLink.h"
@ -209,7 +209,7 @@ class GetExportedChatlistInvitesQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetExportedChatlistInvitesQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetExportedChatlistInvitesQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetExportedChatlistInvitesQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetExportedChatlistInvitesQuery");
auto result = td_api::make_object<td_api::chatFolderInviteLinks>();
for (auto &invite : ptr->invites_) {
result->invite_links_.push_back(
@ -426,7 +426,7 @@ class GetChatlistUpdatesQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetChatlistUpdatesQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetChatlistUpdatesQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetChatlistUpdatesQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetChatlistUpdatesQuery");
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"));
}
@ -519,7 +519,7 @@ class GetDialogsQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for GetDialogsQuery: " << to_string(result);
td_->user_manager_->on_get_users(std::move(result->users_), "GetDialogsQuery");
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetDialogsQuery");
td_->chat_manager_->on_get_chats(std::move(result->chats_), "GetDialogsQuery");
td_->messages_manager_->on_get_dialogs(FolderId(), std::move(result->dialogs_), -1, std::move(result->messages_),
std::move(promise_));
}
@ -2132,7 +2132,7 @@ void DialogFilterManager::on_get_chatlist_invite(
}
td_->user_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_->chat_manager_->on_get_chats(std::move(chats), "on_get_chatlist_invite");
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));

View File

@ -9,7 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogInviteLink.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -646,7 +646,7 @@ void DialogInviteLinkManager::check_dialog_invite_link(const string &invite_link
if (it != invite_link_infos_.end()) {
auto dialog_id = it->second->dialog_id;
if (!force && dialog_id.get_type() == DialogType::Chat &&
!td_->contacts_manager_->get_chat_is_active(dialog_id.get_chat_id())) {
!td_->chat_manager_->get_chat_is_active(dialog_id.get_chat_id())) {
invite_link_infos_.erase(it);
} else {
return promise.set_value(Unit());
@ -687,12 +687,12 @@ void DialogInviteLinkManager::on_get_dialog_invite_link_info(
chat = std::move(chat_invite_peek->chat_);
accessible_before_date = chat_invite_peek->expires_;
}
auto chat_id = ContactsManager::get_chat_id(chat);
auto chat_id = ChatManager::get_chat_id(chat);
if (chat_id != ChatId() && !chat_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << chat_id;
chat_id = ChatId();
}
auto channel_id = ContactsManager::get_channel_id(chat);
auto channel_id = ChatManager::get_channel_id(chat);
if (channel_id != ChannelId() && !channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id;
channel_id = ChannelId();
@ -702,7 +702,7 @@ void DialogInviteLinkManager::on_get_dialog_invite_link_info(
<< to_string(chat);
accessible_before_date = 0;
}
td_->contacts_manager_->on_get_chat(std::move(chat), "chatInviteAlready");
td_->chat_manager_->on_get_chat(std::move(chat), "chatInviteAlready");
CHECK(chat_id == ChatId() || channel_id == ChannelId());
@ -816,25 +816,25 @@ td_api::object_ptr<td_api::chatInviteLinkInfo> DialogInviteLinkManager::get_chat
auto chat_id = dialog_id.get_chat_id();
is_chat = true;
title = td_->contacts_manager_->get_chat_title(chat_id);
photo = td_->contacts_manager_->get_chat_dialog_photo(chat_id);
participant_count = td_->contacts_manager_->get_chat_participant_count(chat_id);
is_member = td_->contacts_manager_->get_chat_status(chat_id).is_member();
accent_color_id_object = td_->contacts_manager_->get_chat_accent_color_id_object(chat_id);
title = td_->chat_manager_->get_chat_title(chat_id);
photo = td_->chat_manager_->get_chat_dialog_photo(chat_id);
participant_count = td_->chat_manager_->get_chat_participant_count(chat_id);
is_member = td_->chat_manager_->get_chat_status(chat_id).is_member();
accent_color_id_object = td_->chat_manager_->get_chat_accent_color_id_object(chat_id);
break;
}
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
title = td_->contacts_manager_->get_channel_title(channel_id);
photo = td_->contacts_manager_->get_channel_dialog_photo(channel_id);
is_public = td_->contacts_manager_->is_channel_public(channel_id);
is_megagroup = td_->contacts_manager_->is_megagroup_channel(channel_id);
participant_count = td_->contacts_manager_->get_channel_participant_count(channel_id);
is_member = td_->contacts_manager_->get_channel_status(channel_id).is_member();
is_verified = td_->contacts_manager_->get_channel_is_verified(channel_id);
is_scam = td_->contacts_manager_->get_channel_is_scam(channel_id);
is_fake = td_->contacts_manager_->get_channel_is_fake(channel_id);
accent_color_id_object = td_->contacts_manager_->get_channel_accent_color_id_object(channel_id);
title = td_->chat_manager_->get_channel_title(channel_id);
photo = td_->chat_manager_->get_channel_dialog_photo(channel_id);
is_public = td_->chat_manager_->is_channel_public(channel_id);
is_megagroup = td_->chat_manager_->is_megagroup_channel(channel_id);
participant_count = td_->chat_manager_->get_channel_participant_count(channel_id);
is_member = td_->chat_manager_->get_channel_status(channel_id).is_member();
is_verified = td_->chat_manager_->get_channel_is_verified(channel_id);
is_scam = td_->chat_manager_->get_channel_is_scam(channel_id);
is_fake = td_->chat_manager_->get_channel_is_fake(channel_id);
accent_color_id_object = td_->chat_manager_->get_channel_accent_color_id_object(channel_id);
break;
}
default:
@ -932,10 +932,10 @@ Status DialogInviteLinkManager::can_manage_dialog_invite_links(DialogId dialog_i
return Status::Error(400, "Can't invite members to a private chat");
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
if (!td_->contacts_manager_->get_chat_is_active(chat_id)) {
if (!td_->chat_manager_->get_chat_is_active(chat_id)) {
return Status::Error(400, "Chat is deactivated");
}
auto status = td_->contacts_manager_->get_chat_status(chat_id);
auto status = td_->chat_manager_->get_chat_status(chat_id);
bool have_rights = creator_only ? status.is_creator() : status.can_manage_invite_links();
if (!have_rights) {
return Status::Error(400, "Not enough rights to manage chat invite link");
@ -944,7 +944,7 @@ Status DialogInviteLinkManager::can_manage_dialog_invite_links(DialogId dialog_i
}
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
auto status = td_->contacts_manager_->get_channel_status(channel_id);
auto status = td_->chat_manager_->get_channel_status(channel_id);
bool have_rights = creator_only ? status.is_creator() : status.can_manage_invite_links();
if (!have_rights) {
return Status::Error(400, "Not enough rights to manage chat invite link");
@ -964,9 +964,9 @@ void DialogInviteLinkManager::on_get_permanent_dialog_invite_link(DialogId dialo
const DialogInviteLink &invite_link) {
switch (dialog_id.get_type()) {
case DialogType::Chat:
return td_->contacts_manager_->on_update_chat_permanent_invite_link(dialog_id.get_chat_id(), invite_link);
return td_->chat_manager_->on_update_chat_permanent_invite_link(dialog_id.get_chat_id(), invite_link);
case DialogType::Channel:
return td_->contacts_manager_->on_update_channel_permanent_invite_link(dialog_id.get_channel_id(), invite_link);
return td_->chat_manager_->on_update_channel_permanent_invite_link(dialog_id.get_channel_id(), invite_link);
case DialogType::User:
case DialogType::SecretChat:
case DialogType::None:

View File

@ -11,7 +11,7 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChannelType.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/files/FileType.h"
@ -79,7 +79,7 @@ class CheckChannelUsernameQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
telegram_api::object_ptr<telegram_api::InputChannel> input_channel;
if (channel_id.is_valid()) {
input_channel = td_->contacts_manager_->get_input_channel(channel_id);
input_channel = td_->chat_manager_->get_input_channel(channel_id);
} else {
input_channel = telegram_api::make_object<telegram_api::inputChannelEmpty>();
}
@ -99,7 +99,7 @@ class CheckChannelUsernameQuery final : public Td::ResultHandler {
void on_error(Status status) final {
if (channel_id_.is_valid()) {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "CheckChannelUsernameQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "CheckChannelUsernameQuery");
}
promise_.set_error(std::move(status));
}
@ -125,7 +125,7 @@ class ResolveUsernameQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for ResolveUsernameQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "ResolveUsernameQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "ResolveUsernameQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "ResolveUsernameQuery");
promise_.set_value(DialogId(ptr->peer_));
}
@ -211,7 +211,7 @@ class EditDialogTitleQuery final : public Td::ResultHandler {
break;
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(telegram_api::channels_editTitle(std::move(input_channel), title)));
break;
@ -274,7 +274,7 @@ class EditDialogPhotoQuery final : public Td::ResultHandler {
break;
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::channels_editPhoto(std::move(input_channel), std::move(input_chat_photo))));
@ -572,9 +572,9 @@ tl_object_ptr<telegram_api::InputPeer> DialogManager::get_input_peer(DialogId di
case DialogType::User:
return td_->user_manager_->get_input_peer_user(dialog_id.get_user_id(), access_rights);
case DialogType::Chat:
return td_->contacts_manager_->get_input_peer_chat(dialog_id.get_chat_id(), access_rights);
return td_->chat_manager_->get_input_peer_chat(dialog_id.get_chat_id(), access_rights);
case DialogType::Channel:
return td_->contacts_manager_->get_input_peer_channel(dialog_id.get_channel_id(), access_rights);
return td_->chat_manager_->get_input_peer_channel(dialog_id.get_channel_id(), access_rights);
case DialogType::SecretChat:
return nullptr;
case DialogType::None:
@ -679,11 +679,11 @@ bool DialogManager::have_input_peer(DialogId dialog_id, AccessRights access_righ
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return td_->contacts_manager_->have_input_peer_chat(chat_id, access_rights);
return td_->chat_manager_->have_input_peer_chat(chat_id, access_rights);
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return td_->contacts_manager_->have_input_peer_channel(channel_id, access_rights);
return td_->chat_manager_->have_input_peer_channel(channel_id, access_rights);
}
case DialogType::SecretChat: {
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
@ -728,11 +728,11 @@ bool DialogManager::have_dialog_info(DialogId dialog_id) const {
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return td_->contacts_manager_->have_chat(chat_id);
return td_->chat_manager_->have_chat(chat_id);
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return td_->contacts_manager_->have_channel(channel_id);
return td_->chat_manager_->have_channel(channel_id);
}
case DialogType::SecretChat: {
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
@ -749,9 +749,9 @@ bool DialogManager::is_dialog_info_received_from_server(DialogId dialog_id) cons
case DialogType::User:
return td_->user_manager_->is_user_received_from_server(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->is_chat_received_from_server(dialog_id.get_chat_id());
return td_->chat_manager_->is_chat_received_from_server(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->is_channel_received_from_server(dialog_id.get_channel_id());
return td_->chat_manager_->is_channel_received_from_server(dialog_id.get_channel_id());
default:
return false;
}
@ -765,11 +765,11 @@ bool DialogManager::have_dialog_info_force(DialogId dialog_id, const char *sourc
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return td_->contacts_manager_->have_chat_force(chat_id, source);
return td_->chat_manager_->have_chat_force(chat_id, source);
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return td_->contacts_manager_->have_channel_force(channel_id, source);
return td_->chat_manager_->have_channel_force(channel_id, source);
}
case DialogType::SecretChat: {
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
@ -786,10 +786,9 @@ void DialogManager::reload_dialog_info(DialogId dialog_id, Promise<Unit> &&promi
case DialogType::User:
return td_->user_manager_->reload_user(dialog_id.get_user_id(), std::move(promise), "reload_dialog_info");
case DialogType::Chat:
return td_->contacts_manager_->reload_chat(dialog_id.get_chat_id(), std::move(promise), "reload_dialog_info");
return td_->chat_manager_->reload_chat(dialog_id.get_chat_id(), std::move(promise), "reload_dialog_info");
case DialogType::Channel:
return td_->contacts_manager_->reload_channel(dialog_id.get_channel_id(), std::move(promise),
"reload_dialog_info");
return td_->chat_manager_->reload_channel(dialog_id.get_channel_id(), std::move(promise), "reload_dialog_info");
default:
return promise.set_error(Status::Error("Invalid chat identifier to reload"));
}
@ -802,12 +801,12 @@ void DialogManager::get_dialog_info_full(DialogId dialog_id, Promise<Unit> &&pro
std::move(promise), source);
return;
case DialogType::Chat:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::load_chat_full, dialog_id.get_chat_id(), false,
send_closure_later(td_->chat_manager_actor_, &ChatManager::load_chat_full, dialog_id.get_chat_id(), false,
std::move(promise), source);
return;
case DialogType::Channel:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::load_channel_full, dialog_id.get_channel_id(),
false, std::move(promise), source);
send_closure_later(td_->chat_manager_actor_, &ChatManager::load_channel_full, dialog_id.get_channel_id(), false,
std::move(promise), source);
return;
case DialogType::SecretChat:
return promise.set_value(Unit());
@ -830,12 +829,12 @@ void DialogManager::reload_dialog_info_full(DialogId dialog_id, const char *sour
Promise<Unit>(), source);
return;
case DialogType::Chat:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_chat_full, dialog_id.get_chat_id(),
send_closure_later(td_->chat_manager_actor_, &ChatManager::reload_chat_full, dialog_id.get_chat_id(),
Promise<Unit>(), source);
return;
case DialogType::Channel:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_channel_full,
dialog_id.get_channel_id(), Promise<Unit>(), source);
send_closure_later(td_->chat_manager_actor_, &ChatManager::reload_channel_full, dialog_id.get_channel_id(),
Promise<Unit>(), source);
return;
case DialogType::SecretChat:
return;
@ -880,12 +879,12 @@ td_api::object_ptr<td_api::ChatType> DialogManager::get_chat_type_object(DialogI
td_->user_manager_->get_user_id_object(dialog_id.get_user_id(), source));
case DialogType::Chat:
return td_api::make_object<td_api::chatTypeBasicGroup>(
td_->contacts_manager_->get_basic_group_id_object(dialog_id.get_chat_id(), source));
td_->chat_manager_->get_basic_group_id_object(dialog_id.get_chat_id(), source));
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
return td_api::make_object<td_api::chatTypeSupergroup>(
td_->contacts_manager_->get_supergroup_id_object(channel_id, source),
!td_->contacts_manager_->is_megagroup_channel(channel_id));
td_->chat_manager_->get_supergroup_id_object(channel_id, source),
!td_->chat_manager_->is_megagroup_channel(channel_id));
}
case DialogType::SecretChat: {
auto secret_chat_id = dialog_id.get_secret_chat_id();
@ -927,10 +926,10 @@ void DialogManager::migrate_dialog_to_megagroup(DialogId dialog_id,
}
auto chat_id = dialog_id.get_chat_id();
if (!td_->contacts_manager_->get_chat_status(chat_id).is_creator()) {
if (!td_->chat_manager_->get_chat_status(chat_id).is_creator()) {
return promise.set_error(Status::Error(400, "Need creator rights in the chat"));
}
if (td_->contacts_manager_->get_chat_migrated_to_channel_id(chat_id).is_valid()) {
if (td_->chat_manager_->get_chat_migrated_to_channel_id(chat_id).is_valid()) {
return on_migrate_chat_to_megagroup(chat_id, std::move(promise));
}
@ -945,12 +944,12 @@ void DialogManager::migrate_dialog_to_megagroup(DialogId dialog_id,
}
void DialogManager::on_migrate_chat_to_megagroup(ChatId chat_id, Promise<td_api::object_ptr<td_api::chat>> &&promise) {
auto channel_id = td_->contacts_manager_->get_chat_migrated_to_channel_id(chat_id);
auto channel_id = td_->chat_manager_->get_chat_migrated_to_channel_id(chat_id);
if (!channel_id.is_valid()) {
LOG(ERROR) << "Can't find the supergroup to which the basic group has migrated";
return promise.set_error(Status::Error(500, "Supergroup not found"));
}
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
LOG(ERROR) << "Can't find info about the supergroup to which the basic group has migrated";
return promise.set_error(Status::Error(500, "Supergroup info is not found"));
}
@ -975,7 +974,7 @@ bool DialogManager::is_anonymous_administrator(DialogId dialog_id, string *autho
return false;
}
auto status = td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id());
auto status = td_->chat_manager_->get_channel_status(dialog_id.get_channel_id());
if (!status.is_anonymous()) {
return false;
}
@ -991,7 +990,7 @@ bool DialogManager::is_group_dialog(DialogId dialog_id) const {
case DialogType::Chat:
return true;
case DialogType::Channel:
return td_->contacts_manager_->is_megagroup_channel(dialog_id.get_channel_id());
return td_->chat_manager_->is_megagroup_channel(dialog_id.get_channel_id());
default:
return false;
}
@ -999,7 +998,7 @@ bool DialogManager::is_group_dialog(DialogId dialog_id) const {
bool DialogManager::is_forum_channel(DialogId dialog_id) const {
return dialog_id.get_type() == DialogType::Channel &&
td_->contacts_manager_->is_forum_channel(dialog_id.get_channel_id());
td_->chat_manager_->is_forum_channel(dialog_id.get_channel_id());
}
bool DialogManager::is_broadcast_channel(DialogId dialog_id) const {
@ -1007,7 +1006,7 @@ bool DialogManager::is_broadcast_channel(DialogId dialog_id) const {
return false;
}
return td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id());
return td_->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id());
}
bool DialogManager::on_get_dialog_error(DialogId dialog_id, const Status &status, const char *source) {
@ -1033,7 +1032,7 @@ bool DialogManager::on_get_dialog_error(DialogId dialog_id, const Status &status
// to be implemented if necessary
break;
case DialogType::Channel:
return td_->contacts_manager_->on_get_channel_error(dialog_id.get_channel_id(), status, source);
return td_->chat_manager_->on_get_channel_error(dialog_id.get_channel_id(), status, source);
case DialogType::None:
// to be implemented if necessary
break;
@ -1052,9 +1051,9 @@ void DialogManager::delete_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
case DialogType::User:
return td_->messages_manager_->delete_dialog_history(dialog_id, true, true, std::move(promise));
case DialogType::Chat:
return td_->contacts_manager_->delete_chat(dialog_id.get_chat_id(), std::move(promise));
return td_->chat_manager_->delete_chat(dialog_id.get_chat_id(), std::move(promise));
case DialogType::Channel:
return td_->contacts_manager_->delete_channel(dialog_id.get_channel_id(), std::move(promise));
return td_->chat_manager_->delete_channel(dialog_id.get_channel_id(), std::move(promise));
case DialogType::SecretChat:
send_closure(td_->secret_chats_manager_, &SecretChatsManager::cancel_chat, dialog_id.get_secret_chat_id(), true,
std::move(promise));
@ -1069,9 +1068,9 @@ string DialogManager::get_dialog_title(DialogId dialog_id) const {
case DialogType::User:
return td_->user_manager_->get_user_title(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_title(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_title(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_title(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_title(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_title(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1086,9 +1085,9 @@ const DialogPhoto *DialogManager::get_dialog_photo(DialogId dialog_id) const {
case DialogType::User:
return td_->user_manager_->get_user_dialog_photo(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_dialog_photo(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_dialog_photo(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_dialog_photo(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_dialog_photo(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_dialog_photo(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1103,9 +1102,9 @@ int32 DialogManager::get_dialog_accent_color_id_object(DialogId dialog_id) const
case DialogType::User:
return td_->user_manager_->get_user_accent_color_id_object(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_accent_color_id_object(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_accent_color_id_object(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_accent_color_id_object(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_accent_color_id_object(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_accent_color_id_object(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1120,9 +1119,9 @@ CustomEmojiId DialogManager::get_dialog_background_custom_emoji_id(DialogId dial
case DialogType::User:
return td_->user_manager_->get_user_background_custom_emoji_id(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_background_custom_emoji_id(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_background_custom_emoji_id(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_background_custom_emoji_id(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_background_custom_emoji_id(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_background_custom_emoji_id(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1137,9 +1136,9 @@ int32 DialogManager::get_dialog_profile_accent_color_id_object(DialogId dialog_i
case DialogType::User:
return td_->user_manager_->get_user_profile_accent_color_id_object(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_profile_accent_color_id_object(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_profile_accent_color_id_object(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_profile_accent_color_id_object(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_profile_accent_color_id_object(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_profile_accent_color_id_object(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1154,9 +1153,9 @@ CustomEmojiId DialogManager::get_dialog_profile_background_custom_emoji_id(Dialo
case DialogType::User:
return td_->user_manager_->get_user_profile_background_custom_emoji_id(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_profile_background_custom_emoji_id(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_profile_background_custom_emoji_id(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_profile_background_custom_emoji_id(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_profile_background_custom_emoji_id(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_profile_background_custom_emoji_id(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1171,9 +1170,9 @@ RestrictedRights DialogManager::get_dialog_default_permissions(DialogId dialog_i
case DialogType::User:
return td_->user_manager_->get_user_default_permissions(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_default_permissions(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_default_permissions(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_default_permissions(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_default_permissions(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1189,9 +1188,9 @@ td_api::object_ptr<td_api::emojiStatus> DialogManager::get_dialog_emoji_status_o
case DialogType::User:
return td_->user_manager_->get_user_emoji_status_object(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_emoji_status_object(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_emoji_status_object(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_emoji_status_object(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_emoji_status_object(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_emoji_status_object(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1206,9 +1205,9 @@ string DialogManager::get_dialog_about(DialogId dialog_id) {
case DialogType::User:
return td_->user_manager_->get_user_about(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_about(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_about(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_about(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_about(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_secret_chat_about(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -1223,9 +1222,9 @@ string DialogManager::get_dialog_search_text(DialogId dialog_id) const {
case DialogType::User:
return td_->user_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());
return td_->chat_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());
return td_->chat_manager_->get_channel_search_text(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->user_manager_->get_user_search_text(
td_->user_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()));
@ -1241,9 +1240,9 @@ bool DialogManager::get_dialog_has_protected_content(DialogId dialog_id) const {
case DialogType::User:
return false;
case DialogType::Chat:
return td_->contacts_manager_->get_chat_has_protected_content(dialog_id.get_chat_id());
return td_->chat_manager_->get_chat_has_protected_content(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_has_protected_content(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_has_protected_content(dialog_id.get_channel_id());
case DialogType::SecretChat:
return false;
case DialogType::None:
@ -1301,15 +1300,15 @@ void DialogManager::set_dialog_title(DialogId dialog_id, const string &title, Pr
return promise.set_error(Status::Error(400, "Can't change private chat title"));
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_permissions(chat_id);
auto status = td_->chat_manager_->get_chat_permissions(chat_id);
if (!status.can_change_info_and_settings() ||
(td_->auth_manager_->is_bot() && !td_->contacts_manager_->is_appointed_chat_administrator(chat_id))) {
(td_->auth_manager_->is_bot() && !td_->chat_manager_->is_appointed_chat_administrator(chat_id))) {
return promise.set_error(Status::Error(400, "Not enough rights to change chat title"));
}
break;
}
case DialogType::Channel: {
auto status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
auto status = td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id());
if (!status.can_change_info_and_settings()) {
return promise.set_error(Status::Error(400, "Not enough rights to change chat title"));
}
@ -1342,15 +1341,15 @@ void DialogManager::set_dialog_photo(DialogId dialog_id, const td_api::object_pt
return promise.set_error(Status::Error(400, "Can't change private chat photo"));
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_permissions(chat_id);
auto status = td_->chat_manager_->get_chat_permissions(chat_id);
if (!status.can_change_info_and_settings() ||
(td_->auth_manager_->is_bot() && !td_->contacts_manager_->is_appointed_chat_administrator(chat_id))) {
(td_->auth_manager_->is_bot() && !td_->chat_manager_->is_appointed_chat_administrator(chat_id))) {
return promise.set_error(Status::Error(400, "Not enough rights to change chat photo"));
}
break;
}
case DialogType::Channel: {
auto status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
auto status = td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id());
if (!status.can_change_info_and_settings()) {
return promise.set_error(Status::Error(400, "Not enough rights to change chat photo"));
}
@ -1552,8 +1551,8 @@ void DialogManager::set_dialog_accent_color(DialogId dialog_id, AccentColorId ac
case DialogType::Chat:
break;
case DialogType::Channel:
return td_->contacts_manager_->set_channel_accent_color(dialog_id.get_channel_id(), accent_color_id,
background_custom_emoji_id, std::move(promise));
return td_->chat_manager_->set_channel_accent_color(dialog_id.get_channel_id(), accent_color_id,
background_custom_emoji_id, std::move(promise));
case DialogType::SecretChat:
break;
case DialogType::None:
@ -1580,7 +1579,7 @@ void DialogManager::set_dialog_profile_accent_color(DialogId dialog_id, AccentCo
case DialogType::Chat:
break;
case DialogType::Channel:
return td_->contacts_manager_->set_channel_profile_accent_color(
return td_->chat_manager_->set_channel_profile_accent_color(
dialog_id.get_channel_id(), profile_accent_color_id, profile_background_custom_emoji_id, std::move(promise));
case DialogType::SecretChat:
break;
@ -1611,7 +1610,7 @@ void DialogManager::set_dialog_permissions(DialogId dialog_id,
return promise.set_error(Status::Error(400, "Can't change private chat permissions"));
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_permissions(chat_id);
auto status = td_->chat_manager_->get_chat_permissions(chat_id);
if (!status.can_restrict_members()) {
return promise.set_error(Status::Error(400, "Not enough rights to change chat permissions"));
}
@ -1621,7 +1620,7 @@ void DialogManager::set_dialog_permissions(DialogId dialog_id,
if (is_broadcast_channel(dialog_id)) {
return promise.set_error(Status::Error(400, "Can't change channel chat permissions"));
}
auto status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
auto status = td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id());
if (!status.can_restrict_members()) {
return promise.set_error(Status::Error(400, "Not enough rights to change chat permissions"));
}
@ -1661,8 +1660,7 @@ void DialogManager::set_dialog_emoji_status(DialogId dialog_id, const EmojiStatu
case DialogType::Chat:
break;
case DialogType::Channel:
return td_->contacts_manager_->set_channel_emoji_status(dialog_id.get_channel_id(), emoji_status,
std::move(promise));
return td_->chat_manager_->set_channel_emoji_status(dialog_id.get_channel_id(), emoji_status, std::move(promise));
case DialogType::SecretChat:
break;
case DialogType::None:
@ -1687,14 +1685,14 @@ void DialogManager::toggle_dialog_has_protected_content(DialogId dialog_id, bool
return promise.set_error(Status::Error(400, "Can't restrict saving content in the chat"));
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_status(chat_id);
auto status = td_->chat_manager_->get_chat_status(chat_id);
if (!status.is_creator()) {
return promise.set_error(Status::Error(400, "Only owner can restrict saving content"));
}
break;
}
case DialogType::Channel: {
auto status = td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id());
auto status = td_->chat_manager_->get_channel_status(dialog_id.get_channel_id());
if (!status.is_creator()) {
return promise.set_error(Status::Error(400, "Only owner can restrict saving content"));
}
@ -1723,10 +1721,9 @@ void DialogManager::set_dialog_description(DialogId dialog_id, const string &des
case DialogType::User:
return promise.set_error(Status::Error(400, "Can't change private chat description"));
case DialogType::Chat:
return td_->contacts_manager_->set_chat_description(dialog_id.get_chat_id(), description, std::move(promise));
return td_->chat_manager_->set_chat_description(dialog_id.get_chat_id(), description, std::move(promise));
case DialogType::Channel:
return td_->contacts_manager_->set_channel_description(dialog_id.get_channel_id(), description,
std::move(promise));
return td_->chat_manager_->set_channel_description(dialog_id.get_channel_id(), description, std::move(promise));
case DialogType::SecretChat:
return promise.set_error(Status::Error(400, "Can't change secret chat description"));
case DialogType::None:
@ -1746,7 +1743,7 @@ void DialogManager::set_dialog_location(DialogId dialog_id, const DialogLocation
case DialogType::SecretChat:
return promise.set_error(Status::Error(400, "The chat can't have location"));
case DialogType::Channel:
return td_->contacts_manager_->set_channel_location(dialog_id.get_channel_id(), location, std::move(promise));
return td_->chat_manager_->set_channel_location(dialog_id.get_channel_id(), location, std::move(promise));
case DialogType::None:
default:
UNREACHABLE();
@ -1761,7 +1758,7 @@ bool DialogManager::can_report_dialog(DialogId dialog_id) const {
case DialogType::Chat:
return false;
case DialogType::Channel:
return !td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).is_creator();
return !td_->chat_manager_->get_channel_status(dialog_id.get_channel_id()).is_creator();
case DialogType::SecretChat:
return false;
case DialogType::None:
@ -1848,15 +1845,15 @@ Status DialogManager::can_pin_messages(DialogId dialog_id) const {
break;
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_permissions(chat_id);
auto status = td_->chat_manager_->get_chat_permissions(chat_id);
if (!status.can_pin_messages() ||
(td_->auth_manager_->is_bot() && !td_->contacts_manager_->is_appointed_chat_administrator(chat_id))) {
(td_->auth_manager_->is_bot() && !td_->chat_manager_->is_appointed_chat_administrator(chat_id))) {
return Status::Error(400, "Not enough rights to manage pinned messages in the chat");
}
break;
}
case DialogType::Channel: {
auto status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
auto status = td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id());
bool can_pin = is_broadcast_channel(dialog_id) ? status.can_edit_messages() : status.can_pin_messages();
if (!can_pin) {
return Status::Error(400, "Not enough rights to manage pinned messages in the chat");
@ -1884,7 +1881,7 @@ bool DialogManager::can_use_premium_custom_emoji_in_dialog(DialogId dialog_id) c
return true;
}
if (dialog_id.get_type() == DialogType::Channel &&
td_->contacts_manager_->can_use_premium_custom_emoji_in_channel(dialog_id.get_channel_id())) {
td_->chat_manager_->can_use_premium_custom_emoji_in_channel(dialog_id.get_channel_id())) {
return true;
}
return false;
@ -1895,9 +1892,9 @@ bool DialogManager::is_dialog_removed_from_dialog_list(DialogId dialog_id) const
case DialogType::User:
break;
case DialogType::Chat:
return !td_->contacts_manager_->get_chat_is_active(dialog_id.get_chat_id());
return !td_->chat_manager_->get_chat_is_active(dialog_id.get_chat_id());
case DialogType::Channel:
return !td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).is_member();
return !td_->chat_manager_->get_channel_status(dialog_id.get_channel_id()).is_member();
case DialogType::SecretChat:
break;
case DialogType::None:
@ -1930,11 +1927,11 @@ void DialogManager::on_update_dialog_bot_commands(
}
return td_->user_manager_->on_update_user_commands(bot_user_id, std::move(bot_commands));
case DialogType::Chat:
return td_->contacts_manager_->on_update_chat_bot_commands(dialog_id.get_chat_id(),
BotCommands(bot_user_id, std::move(bot_commands)));
return td_->chat_manager_->on_update_chat_bot_commands(dialog_id.get_chat_id(),
BotCommands(bot_user_id, std::move(bot_commands)));
case DialogType::Channel:
return td_->contacts_manager_->on_update_channel_bot_commands(dialog_id.get_channel_id(),
BotCommands(bot_user_id, std::move(bot_commands)));
return td_->chat_manager_->on_update_channel_bot_commands(dialog_id.get_channel_id(),
BotCommands(bot_user_id, std::move(bot_commands)));
case DialogType::SecretChat:
default:
LOG(ERROR) << "Receive updateBotCommands in " << dialog_id;
@ -1980,10 +1977,10 @@ void DialogManager::check_dialog_username(DialogId dialog_id, const string &user
}
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_status(channel_id).is_creator()) {
if (!td_->chat_manager_->get_channel_status(channel_id).is_creator()) {
return promise.set_error(Status::Error(400, "Not enough rights to change username"));
}
if (username == td_->contacts_manager_->get_channel_editable_username(channel_id)) {
if (username == td_->chat_manager_->get_channel_editable_username(channel_id)) {
return promise.set_value(CheckDialogUsernameResult::Ok);
}
break;
@ -2123,7 +2120,7 @@ void DialogManager::on_resolved_username(const string &username, Result<DialogId
void DialogManager::resolve_dialog(const string &username, ChannelId channel_id, Promise<DialogId> promise) {
CHECK(username.empty() == channel_id.is_valid());
bool have_dialog = username.empty() ? td_->contacts_manager_->have_channel_force(channel_id, "resolve_dialog")
bool have_dialog = username.empty() ? td_->chat_manager_->have_channel_force(channel_id, "resolve_dialog")
: get_resolved_dialog_by_username(username).is_valid();
if (!have_dialog) {
auto query_promise = PromiseCreator::lambda(
@ -2134,7 +2131,7 @@ void DialogManager::resolve_dialog(const string &username, ChannelId channel_id,
send_closure(actor_id, &DialogManager::on_resolve_dialog, username, channel_id, std::move(promise));
});
if (username.empty()) {
td_->contacts_manager_->reload_channel(channel_id, std::move(query_promise), "resolve_dialog");
td_->chat_manager_->reload_channel(channel_id, std::move(query_promise), "resolve_dialog");
} else {
send_resolve_dialog_username_query(username, std::move(query_promise));
}
@ -2149,7 +2146,7 @@ void DialogManager::on_resolve_dialog(const string &username, ChannelId channel_
DialogId dialog_id;
if (username.empty()) {
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
return promise.set_error(Status::Error(500, "Chat info not found"));
}
@ -2212,8 +2209,7 @@ DialogId DialogManager::search_public_dialog(const string &username_to_search, b
if (!force && reload_voice_chat_on_search_usernames_.count(username)) {
reload_voice_chat_on_search_usernames_.erase(username);
if (dialog_id.get_type() == DialogType::Channel) {
td_->contacts_manager_->reload_channel_full(dialog_id.get_channel_id(), std::move(promise),
"search_public_dialog");
td_->chat_manager_->reload_channel_full(dialog_id.get_channel_id(), std::move(promise), "search_public_dialog");
return DialogId();
}
}
@ -2277,7 +2273,7 @@ void DialogManager::set_dialog_pending_suggestions(DialogId dialog_id, vector<st
if (!suggested_action.is_empty()) {
if (suggested_action == SuggestedAction{SuggestedAction::Type::ConvertToGigagroup, dialog_id} &&
(dialog_id.get_type() != DialogType::Channel ||
!td_->contacts_manager_->can_convert_channel_to_gigagroup(dialog_id.get_channel_id()))) {
!td_->chat_manager_->can_convert_channel_to_gigagroup(dialog_id.get_channel_id()))) {
LOG(INFO) << "Skip ConvertToGigagroup suggested action";
} else {
suggested_actions.push_back(suggested_action);

View File

@ -6,7 +6,7 @@
//
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/misc.h"
#include "td/telegram/Td.h"
@ -827,7 +827,7 @@ td_api::object_ptr<td_api::chatMembers> DialogParticipants::get_chat_members_obj
vector<tl_object_ptr<td_api::chatMember>> chat_members;
chat_members.reserve(participants_.size());
for (auto &participant : participants_) {
chat_members.push_back(td->contacts_manager_->get_chat_member_object(participant, source));
chat_members.push_back(td->chat_manager_->get_chat_member_object(participant, source));
}
return td_api::make_object<td_api::chatMembers>(total_count_, std::move(chat_members));

View File

@ -11,7 +11,7 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChannelParticipantFilter.h"
#include "td/telegram/ChannelType.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
@ -256,7 +256,7 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler {
}
void send(ChannelId channel_id, int64 hash) {
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Supergroup not found"));
}
@ -281,9 +281,9 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler {
case telegram_api::channels_channelParticipants::ID: {
auto participants = telegram_api::move_object_as<telegram_api::channels_channelParticipants>(participants_ptr);
td_->user_manager_->on_get_users(std::move(participants->users_), "GetChannelAdministratorsQuery");
td_->contacts_manager_->on_get_chats(std::move(participants->chats_), "GetChannelAdministratorsQuery");
td_->chat_manager_->on_get_chats(std::move(participants->chats_), "GetChannelAdministratorsQuery");
auto channel_type = td_->contacts_manager_->get_channel_type(channel_id_);
auto channel_type = td_->chat_manager_->get_channel_type(channel_id_);
vector<DialogAdministrator> administrators;
administrators.reserve(participants->participants_.size());
for (auto &participant : participants->participants_) {
@ -297,8 +297,8 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler {
dialog_participant.status_.get_rank(), dialog_participant.status_.is_creator());
}
td_->contacts_manager_->on_update_channel_administrator_count(channel_id_,
narrow_cast<int32>(administrators.size()));
td_->chat_manager_->on_update_channel_administrator_count(channel_id_,
narrow_cast<int32>(administrators.size()));
td_->dialog_participant_manager_->on_update_dialog_administrators(DialogId(channel_id_),
std::move(administrators), true, false);
@ -314,7 +314,7 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdministratorsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdministratorsQuery");
promise_.set_error(std::move(status));
}
};
@ -329,7 +329,7 @@ class GetChannelParticipantQuery final : public Td::ResultHandler {
}
void send(ChannelId channel_id, DialogId participant_dialog_id, tl_object_ptr<telegram_api::InputPeer> &&input_peer) {
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Supergroup not found"));
}
@ -352,9 +352,8 @@ class GetChannelParticipantQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for GetChannelParticipantQuery: " << to_string(participant);
td_->user_manager_->on_get_users(std::move(participant->users_), "GetChannelParticipantQuery");
td_->contacts_manager_->on_get_chats(std::move(participant->chats_), "GetChannelParticipantQuery");
DialogParticipant result(std::move(participant->participant_),
td_->contacts_manager_->get_channel_type(channel_id_));
td_->chat_manager_->on_get_chats(std::move(participant->chats_), "GetChannelParticipantQuery");
DialogParticipant result(std::move(participant->participant_), td_->chat_manager_->get_channel_type(channel_id_));
if (!result.is_valid()) {
LOG(ERROR) << "Receive invalid " << result;
return promise_.set_error(Status::Error(500, "Receive invalid chat member"));
@ -369,7 +368,7 @@ class GetChannelParticipantQuery final : public Td::ResultHandler {
}
if (participant_dialog_id_.get_type() != DialogType::Channel) {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantQuery");
}
promise_.set_error(std::move(status));
}
@ -386,7 +385,7 @@ class GetChannelParticipantsQuery final : public Td::ResultHandler {
}
void send(ChannelId channel_id, const ChannelParticipantFilter &filter, int32 offset, int32 limit) {
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Supergroup not found"));
}
@ -418,7 +417,7 @@ class GetChannelParticipantsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantsQuery");
promise_.set_error(std::move(status));
}
};
@ -546,7 +545,7 @@ class JoinChannelQuery final : public Td::ResultHandler {
void send(ChannelId channel_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(
G()->net_query_creator().create(telegram_api::channels_joinChannel(std::move(input_channel)), {{channel_id}}));
@ -564,7 +563,7 @@ class JoinChannelQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "JoinChannelQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "JoinChannelQuery");
promise_.set_error(std::move(status));
}
};
@ -582,7 +581,7 @@ class InviteToChannelQuery final : public Td::ResultHandler {
vector<tl_object_ptr<telegram_api::InputUser>> &&input_users) {
channel_id_ = channel_id;
user_ids_ = std::move(user_ids);
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::channels_inviteToChannel(std::move(input_channel), std::move(input_users))));
@ -596,7 +595,7 @@ class InviteToChannelQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for InviteToChannelQuery: " << to_string(ptr);
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "InviteToChannelQuery");
td_->chat_manager_->invalidate_channel_full(channel_id_, false, "InviteToChannelQuery");
td_->updates_manager_->on_get_updates(std::move(std::move(ptr->updates_)), std::move(promise_));
}
@ -606,8 +605,8 @@ class InviteToChannelQuery final : public Td::ResultHandler {
DialogId(channel_id_), std::move(user_ids_), "InviteToChannelQuery");
return promise_.set_error(Status::Error(406, "USER_PRIVACY_RESTRICTED"));
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "InviteToChannelQuery");
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "InviteToChannelQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "InviteToChannelQuery");
td_->chat_manager_->invalidate_channel_full(channel_id_, false, "InviteToChannelQuery");
promise_.set_error(std::move(status));
}
};
@ -627,7 +626,7 @@ class EditChannelAdminQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
user_id_ = user_id;
status_ = status;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(telegram_api::channels_editAdmin(
std::move(input_channel), std::move(input_user), status.get_chat_admin_rights(), status.get_rank())));
@ -641,7 +640,7 @@ class EditChannelAdminQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for EditChannelAdminQuery: " << to_string(ptr);
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "EditChannelAdminQuery");
td_->chat_manager_->invalidate_channel_full(channel_id_, false, "EditChannelAdminQuery");
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
td_->dialog_participant_manager_->on_set_channel_participant_status(channel_id_, DialogId(user_id_), status_);
}
@ -652,8 +651,8 @@ class EditChannelAdminQuery final : public Td::ResultHandler {
DialogId(channel_id_), {user_id_}, "EditChannelAdminQuery");
return promise_.set_error(Status::Error(406, "USER_PRIVACY_RESTRICTED"));
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelAdminQuery");
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "EditChannelAdminQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "EditChannelAdminQuery");
td_->chat_manager_->invalidate_channel_full(channel_id_, false, "EditChannelAdminQuery");
promise_.set_error(std::move(status));
}
};
@ -673,7 +672,7 @@ class EditChannelBannedQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
participant_dialog_id_ = participant_dialog_id;
status_ = status;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(telegram_api::channels_editBanned(
std::move(input_channel), std::move(input_peer), status.get_chat_banned_rights())));
@ -687,16 +686,16 @@ class EditChannelBannedQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for EditChannelBannedQuery: " << to_string(ptr);
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "EditChannelBannedQuery");
td_->chat_manager_->invalidate_channel_full(channel_id_, false, "EditChannelBannedQuery");
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
td_->dialog_participant_manager_->on_set_channel_participant_status(channel_id_, participant_dialog_id_, status_);
}
void on_error(Status status) final {
if (participant_dialog_id_.get_type() != DialogType::Channel) {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelBannedQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "EditChannelBannedQuery");
}
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "EditChannelBannedQuery");
td_->chat_manager_->invalidate_channel_full(channel_id_, false, "EditChannelBannedQuery");
promise_.set_error(std::move(status));
}
};
@ -711,7 +710,7 @@ class LeaveChannelQuery final : public Td::ResultHandler {
void send(ChannelId channel_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(
G()->net_query_creator().create(telegram_api::channels_leaveChannel(std::move(input_channel)), {{channel_id}}));
@ -730,9 +729,9 @@ class LeaveChannelQuery final : public Td::ResultHandler {
void on_error(Status status) final {
if (status.message() == "USER_NOT_PARTICIPANT") {
return td_->contacts_manager_->reload_channel(channel_id_, std::move(promise_), "LeaveChannelQuery");
return td_->chat_manager_->reload_channel(channel_id_, std::move(promise_), "LeaveChannelQuery");
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "LeaveChannelQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "LeaveChannelQuery");
promise_.set_error(std::move(status));
}
};
@ -781,7 +780,7 @@ class EditChannelCreatorQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputCheckPasswordSRP> input_check_password) {
channel_id_ = channel_id;
user_id_ = user_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Have no access to the chat"));
}
@ -800,7 +799,7 @@ class EditChannelCreatorQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for EditChannelCreatorQuery: " << to_string(ptr);
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "EditChannelCreatorQuery");
td_->chat_manager_->invalidate_channel_full(channel_id_, false, "EditChannelCreatorQuery");
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
@ -810,7 +809,7 @@ class EditChannelCreatorQuery final : public Td::ResultHandler {
DialogId(channel_id_), {user_id_}, "EditChannelCreatorQuery");
return promise_.set_error(Status::Error(406, "USER_PRIVACY_RESTRICTED"));
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelCreatorQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "EditChannelCreatorQuery");
promise_.set_error(std::move(status));
}
};
@ -857,8 +856,8 @@ void DialogParticipantManager::on_update_dialog_online_member_count_timeout(Dial
}
if (dialog_id.get_type() == DialogType::Channel && !td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
auto has_hidden_participants = td_->contacts_manager_->get_channel_effective_has_hidden_participants(
auto participant_count = td_->chat_manager_->get_channel_participant_count(dialog_id.get_channel_id());
auto has_hidden_participants = td_->chat_manager_->get_channel_effective_has_hidden_participants(
dialog_id.get_channel_id(), "on_update_dialog_online_member_count_timeout");
if (participant_count == 0 || participant_count >= 195 || has_hidden_participants) {
td_->create_handler<GetOnlinesQuery>()->send(dialog_id);
@ -870,7 +869,7 @@ void DialogParticipantManager::on_update_dialog_online_member_count_timeout(Dial
}
if (dialog_id.get_type() == DialogType::Chat) {
// we need actual online status state, so we need to reget chat participants
td_->contacts_manager_->repair_chat_participants(dialog_id.get_chat_id());
td_->chat_manager_->repair_chat_participants(dialog_id.get_chat_id());
return;
}
}
@ -936,14 +935,14 @@ void DialogParticipantManager::set_dialog_online_member_count(DialogId dialog_id
switch (dialog_id.get_type()) {
case DialogType::Chat: {
auto participant_count = td_->contacts_manager_->get_chat_participant_count(dialog_id.get_chat_id());
auto participant_count = td_->chat_manager_->get_chat_participant_count(dialog_id.get_chat_id());
if (online_member_count > participant_count) {
online_member_count = participant_count;
}
break;
}
case DialogType::Channel: {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
auto participant_count = td_->chat_manager_->get_channel_participant_count(dialog_id.get_channel_id());
if (participant_count != 0 && online_member_count > participant_count) {
online_member_count = participant_count;
}
@ -1009,7 +1008,7 @@ void DialogParticipantManager::update_user_online_member_count(UserId user_id) {
switch (dialog_id.get_type()) {
case DialogType::Chat:
td_->contacts_manager_->update_chat_online_member_count(dialog_id.get_chat_id(), false);
td_->chat_manager_->update_chat_online_member_count(dialog_id.get_chat_id(), false);
break;
case DialogType::Channel:
update_channel_online_member_count(dialog_id.get_channel_id(), false);
@ -1033,9 +1032,9 @@ void DialogParticipantManager::update_user_online_member_count(UserId user_id) {
}
void DialogParticipantManager::update_channel_online_member_count(ChannelId channel_id, bool is_from_server) {
if (!td_->contacts_manager_->is_megagroup_channel(channel_id) ||
td_->contacts_manager_->get_channel_effective_has_hidden_participants(channel_id,
"update_channel_online_member_count")) {
if (!td_->chat_manager_->is_megagroup_channel(channel_id) ||
td_->chat_manager_->get_channel_effective_has_hidden_participants(channel_id,
"update_channel_online_member_count")) {
return;
}
@ -1087,16 +1086,16 @@ Status DialogParticipantManager::can_manage_dialog_join_requests(DialogId dialog
return Status::Error(400, "The chat can't have join requests");
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
if (!td_->contacts_manager_->get_chat_is_active(chat_id)) {
if (!td_->chat_manager_->get_chat_is_active(chat_id)) {
return Status::Error(400, "Chat is deactivated");
}
if (!td_->contacts_manager_->get_chat_status(chat_id).can_manage_invite_links()) {
if (!td_->chat_manager_->get_chat_status(chat_id).can_manage_invite_links()) {
return Status::Error(400, "Not enough rights to manage chat join requests");
}
break;
}
case DialogType::Channel:
if (!td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).can_manage_invite_links()) {
if (!td_->chat_manager_->get_channel_status(dialog_id.get_channel_id()).can_manage_invite_links()) {
return Status::Error(400, "Not enough rights to manage chat join requests");
}
break;
@ -1319,7 +1318,7 @@ void DialogParticipantManager::reload_dialog_administrators(
Promise<td_api::object_ptr<td_api::chatAdministrators>> &&promise) {
auto dialog_type = dialog_id.get_type();
if (dialog_type == DialogType::Chat &&
!td_->contacts_manager_->get_chat_permissions(dialog_id.get_chat_id()).is_member()) {
!td_->chat_manager_->get_chat_permissions(dialog_id.get_chat_id()).is_member()) {
return promise.set_value(td_api::make_object<td_api::chatAdministrators>());
}
auto query_promise = PromiseCreator::lambda(
@ -1335,13 +1334,13 @@ void DialogParticipantManager::reload_dialog_administrators(
});
switch (dialog_type) {
case DialogType::Chat:
td_->contacts_manager_->load_chat_full(dialog_id.get_chat_id(), false, std::move(query_promise),
"reload_dialog_administrators");
td_->chat_manager_->load_chat_full(dialog_id.get_chat_id(), false, std::move(query_promise),
"reload_dialog_administrators");
break;
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
if (td_->contacts_manager_->is_broadcast_channel(channel_id) &&
!td_->contacts_manager_->get_channel_status(channel_id).is_administrator()) {
if (td_->chat_manager_->is_broadcast_channel(channel_id) &&
!td_->chat_manager_->get_channel_status(channel_id).is_administrator()) {
return query_promise.set_error(Status::Error(400, "Administrator list is inaccessible"));
}
auto hash = get_vector_hash(transform(dialog_administrators, [](const DialogAdministrator &administrator) {
@ -1380,8 +1379,8 @@ void DialogParticipantManager::send_update_chat_member(DialogId dialog_id, UserI
td_->dialog_manager_->get_chat_id_object(dialog_id, "updateChatMember"),
td_->user_manager_->get_user_id_object(agent_user_id, "updateChatMember"), date,
invite_link.get_chat_invite_link_object(td_->user_manager_.get()), via_dialog_filter_invite_link,
td_->contacts_manager_->get_chat_member_object(old_dialog_participant, "updateChatMember old"),
td_->contacts_manager_->get_chat_member_object(new_dialog_participant, "updateChatMember new")));
td_->chat_manager_->get_chat_member_object(old_dialog_participant, "updateChatMember old"),
td_->chat_manager_->get_chat_member_object(new_dialog_participant, "updateChatMember new")));
}
void DialogParticipantManager::on_update_bot_stopped(UserId user_id, int32 date, bool is_stopped, bool force) {
@ -1423,12 +1422,12 @@ void DialogParticipantManager::on_update_chat_participant(
return;
}
if (!td_->contacts_manager_->have_chat(chat_id)) {
if (!td_->chat_manager_->have_chat(chat_id)) {
LOG(ERROR) << "Receive updateChatParticipant in unknown " << chat_id;
return;
}
auto chat_date = td_->contacts_manager_->get_chat_date(chat_id);
auto chat_status = td_->contacts_manager_->get_chat_status(chat_id);
auto chat_date = td_->chat_manager_->get_chat_date(chat_id);
auto chat_status = td_->chat_manager_->get_chat_status(chat_id);
auto is_creator = chat_status.is_creator();
DialogParticipant old_dialog_participant;
@ -1470,14 +1469,14 @@ void DialogParticipantManager::on_update_channel_participant(
<< ": " << to_string(old_participant) << " -> " << to_string(new_participant);
return;
}
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
LOG(ERROR) << "Receive updateChannelParticipant in unknown " << channel_id;
return;
}
DialogParticipant old_dialog_participant;
DialogParticipant new_dialog_participant;
auto channel_type = td_->contacts_manager_->get_channel_type(channel_id);
auto channel_type = td_->chat_manager_->get_channel_type(channel_id);
if (old_participant != nullptr) {
old_dialog_participant = DialogParticipant(std::move(old_participant), channel_type);
if (new_participant == nullptr) {
@ -1509,7 +1508,7 @@ void DialogParticipantManager::on_update_channel_participant(
add_channel_participant_to_cache(channel_id, new_dialog_participant, true);
}
auto channel_status = td_->contacts_manager_->get_channel_status(channel_id);
auto channel_status = td_->chat_manager_->get_channel_status(channel_id);
if (new_dialog_participant.dialog_id_ == td_->dialog_manager_->get_my_dialog_id() &&
new_dialog_participant.status_ != channel_status && false) {
LOG(ERROR) << "Have status " << channel_status << " after receiving updateChannelParticipant in " << channel_id
@ -1565,8 +1564,7 @@ void DialogParticipantManager::finish_get_dialog_participant(
return promise.set_error(Status::Error(400, "Member not found"));
}
promise.set_value(
td_->contacts_manager_->get_chat_member_object(dialog_participant, "finish_get_dialog_participant"));
promise.set_value(td_->chat_manager_->get_chat_member_object(dialog_participant, "finish_get_dialog_participant"));
}
void DialogParticipantManager::do_get_dialog_participant(DialogId dialog_id, DialogId participant_dialog_id,
@ -1593,8 +1591,8 @@ void DialogParticipantManager::do_get_dialog_participant(DialogId dialog_id, Dia
if (participant_dialog_id.get_type() != DialogType::User) {
return promise.set_value(DialogParticipant::left(participant_dialog_id));
}
return td_->contacts_manager_->get_chat_participant(dialog_id.get_chat_id(), participant_dialog_id.get_user_id(),
std::move(promise));
return td_->chat_manager_->get_chat_participant(dialog_id.get_chat_id(), participant_dialog_id.get_user_id(),
std::move(promise));
case DialogType::Channel:
return get_channel_participant(dialog_id.get_channel_id(), participant_dialog_id, std::move(promise));
case DialogType::SecretChat: {
@ -1719,7 +1717,7 @@ void DialogParticipantManager::search_chat_participants(ChatId chat_id, const st
std::move(promise));
}
});
td_->contacts_manager_->load_chat_full(chat_id, false, std::move(load_chat_full_promise), "search_chat_participants");
td_->chat_manager_->load_chat_full(chat_id, false, std::move(load_chat_full_promise), "search_chat_participants");
}
void DialogParticipantManager::do_search_chat_participants(ChatId chat_id, const string &query, int32 limit,
@ -1727,7 +1725,7 @@ void DialogParticipantManager::do_search_chat_participants(ChatId chat_id, const
Promise<DialogParticipants> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
const auto *participants = td_->contacts_manager_->get_chat_participants(chat_id);
const auto *participants = td_->chat_manager_->get_chat_participants(chat_id);
if (participants == nullptr) {
return promise.set_error(Status::Error(500, "Can't find basic group full info"));
}
@ -1769,8 +1767,8 @@ void DialogParticipantManager::get_channel_participants(ChannelId channel_id,
return promise.set_error(Status::Error(400, "Parameter offset must be non-negative"));
}
if (td_->contacts_manager_->is_broadcast_channel(channel_id) &&
!td_->contacts_manager_->get_channel_status(channel_id).is_administrator()) {
if (td_->chat_manager_->is_broadcast_channel(channel_id) &&
!td_->chat_manager_->get_channel_status(channel_id).is_administrator()) {
return promise.set_error(Status::Error(400, "Member list is inaccessible"));
}
@ -1798,17 +1796,17 @@ void DialogParticipantManager::on_get_channel_participants(
TRY_STATUS_PROMISE(promise, G()->close_status());
td_->user_manager_->on_get_users(std::move(channel_participants->users_), "on_get_channel_participants");
td_->contacts_manager_->on_get_chats(std::move(channel_participants->chats_), "on_get_channel_participants");
td_->chat_manager_->on_get_chats(std::move(channel_participants->chats_), "on_get_channel_participants");
int32 total_count = channel_participants->count_;
auto participants = std::move(channel_participants->participants_);
LOG(INFO) << "Receive " << participants.size() << " " << filter << " members in " << channel_id;
bool is_full = offset == 0 && static_cast<int32>(participants.size()) < limit && total_count < limit;
bool has_hidden_participants =
td_->contacts_manager_->get_channel_effective_has_hidden_participants(channel_id, "on_get_channel_participants");
td_->chat_manager_->get_channel_effective_has_hidden_participants(channel_id, "on_get_channel_participants");
bool is_full_recent = is_full && filter.is_recent() && !has_hidden_participants;
auto channel_type = td_->contacts_manager_->get_channel_type(channel_id);
auto channel_type = td_->chat_manager_->get_channel_type(channel_id);
vector<DialogParticipant> result;
for (auto &participant_ptr : participants) {
auto debug_participant = to_string(participant_ptr);
@ -1847,7 +1845,7 @@ void DialogParticipantManager::on_get_channel_participants(
total_count = static_cast<int32>(result.size());
}
auto is_megagroup = td_->contacts_manager_->is_megagroup_channel(channel_id);
auto is_megagroup = td_->chat_manager_->is_megagroup_channel(channel_id);
const auto max_participant_count = is_megagroup ? 975 : 195;
auto participant_count =
filter.is_recent() && !has_hidden_participants && total_count != 0 && total_count < max_participant_count
@ -1896,7 +1894,7 @@ void DialogParticipantManager::on_get_channel_participants(
on_update_dialog_administrators(DialogId(channel_id), std::move(administrators), true, false);
}
if (filter.is_bots() || is_full_recent) {
td_->contacts_manager_->on_update_channel_bot_user_ids(channel_id, std::move(bot_user_ids));
td_->chat_manager_->on_update_channel_bot_user_ids(channel_id, std::move(bot_user_ids));
}
}
if (have_channel_participant_cache(channel_id)) {
@ -1906,10 +1904,10 @@ void DialogParticipantManager::on_get_channel_participants(
}
if (participant_count != -1) {
td_->contacts_manager_->on_update_channel_participant_count(channel_id, participant_count);
td_->chat_manager_->on_update_channel_participant_count(channel_id, participant_count);
}
if (administrator_count != -1) {
td_->contacts_manager_->on_update_channel_administrator_count(channel_id, administrator_count);
td_->chat_manager_->on_update_channel_administrator_count(channel_id, administrator_count);
}
if (!additional_query.empty()) {
@ -2101,7 +2099,7 @@ void DialogParticipantManager::leave_dialog(DialogId dialog_id, Promise<Unit> &&
std::move(promise));
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
auto old_status = td_->contacts_manager_->get_channel_status(channel_id);
auto old_status = td_->chat_manager_->get_channel_status(channel_id);
auto new_status = old_status;
new_status.set_is_member(false);
return restrict_channel_participant(channel_id, td_->dialog_manager_->get_my_dialog_id(), std::move(new_status),
@ -2117,8 +2115,8 @@ void DialogParticipantManager::leave_dialog(DialogId dialog_id, Promise<Unit> &&
void DialogParticipantManager::add_chat_participant(ChatId chat_id, UserId user_id, int32 forward_limit,
Promise<Unit> &&promise) {
if (!td_->contacts_manager_->get_chat_is_active(chat_id)) {
if (!td_->contacts_manager_->have_chat(chat_id)) {
if (!td_->chat_manager_->get_chat_is_active(chat_id)) {
if (!td_->chat_manager_->have_chat(chat_id)) {
return promise.set_error(Status::Error(400, "Chat info not found"));
}
return promise.set_error(Status::Error(400, "Chat is deactivated"));
@ -2126,7 +2124,7 @@ void DialogParticipantManager::add_chat_participant(ChatId chat_id, UserId user_
if (forward_limit < 0) {
return promise.set_error(Status::Error(400, "Can't forward negative number of messages"));
}
auto permissions = td_->contacts_manager_->get_chat_permissions(chat_id);
auto permissions = td_->chat_manager_->get_chat_permissions(chat_id);
if (user_id != td_->user_manager_->get_my_id()) {
if (!permissions.can_invite_users()) {
return promise.set_error(Status::Error(400, "Not enough rights to invite members to the group chat"));
@ -2157,8 +2155,8 @@ void DialogParticipantManager::set_chat_participant_status(ChatId chat_id, UserI
return promise.set_error(Status::Error(400, "Can't restrict users in basic group chats"));
}
if (!td_->contacts_manager_->get_chat_is_active(chat_id)) {
if (!td_->contacts_manager_->have_chat(chat_id)) {
if (!td_->chat_manager_->get_chat_is_active(chat_id)) {
if (!td_->chat_manager_->have_chat(chat_id)) {
return promise.set_error(Status::Error(400, "Chat info not found"));
}
return promise.set_error(Status::Error(400, "Chat is deactivated"));
@ -2175,17 +2173,17 @@ void DialogParticipantManager::set_chat_participant_status(ChatId chat_id, UserI
true, std::move(promise));
}
});
return td_->contacts_manager_->load_chat_full(chat_id, false, std::move(load_chat_full_promise),
"set_chat_participant_status");
return td_->chat_manager_->load_chat_full(chat_id, false, std::move(load_chat_full_promise),
"set_chat_participant_status");
}
auto participant = td_->contacts_manager_->get_chat_participant(chat_id, user_id);
auto participant = td_->chat_manager_->get_chat_participant(chat_id, user_id);
if (participant == nullptr && !status.is_administrator()) {
// the user isn't a member, but needs to be added
return add_chat_participant(chat_id, user_id, 0, std::move(promise));
}
auto permissions = td_->contacts_manager_->get_chat_permissions(chat_id);
auto permissions = td_->chat_manager_->get_chat_permissions(chat_id);
if (!permissions.can_promote_members()) {
return promise.set_error(Status::Error(400, "Need owner rights in the group chat"));
}
@ -2223,15 +2221,15 @@ void DialogParticipantManager::send_edit_chat_admin_query(ChatId chat_id, UserId
void DialogParticipantManager::delete_chat_participant(ChatId chat_id, UserId user_id, bool revoke_messages,
Promise<Unit> &&promise) {
if (!td_->contacts_manager_->get_chat_is_active(chat_id)) {
if (!td_->contacts_manager_->have_chat(chat_id)) {
if (!td_->chat_manager_->get_chat_is_active(chat_id)) {
if (!td_->chat_manager_->have_chat(chat_id)) {
return promise.set_error(Status::Error(400, "Chat info not found"));
}
return promise.set_error(Status::Error(400, "Chat is deactivated"));
}
auto my_id = td_->user_manager_->get_my_id();
auto permissions = td_->contacts_manager_->get_chat_permissions(chat_id);
auto permissions = td_->chat_manager_->get_chat_permissions(chat_id);
if (permissions.is_left()) {
if (user_id == my_id) {
if (revoke_messages) {
@ -2280,14 +2278,14 @@ void DialogParticipantManager::add_channel_participant(ChannelId channel_id, Use
return promise.set_error(Status::Error(400, "Bots can't add new chat members"));
}
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
return promise.set_error(Status::Error(400, "Chat info not found"));
}
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
if (user_id == td_->user_manager_->get_my_id()) {
// join the channel
auto my_status = td_->contacts_manager_->get_channel_status(channel_id);
auto my_status = td_->chat_manager_->get_channel_status(channel_id);
if (my_status.is_banned()) {
return promise.set_error(Status::Error(400, "Can't return to kicked from chat"));
}
@ -2298,7 +2296,7 @@ void DialogParticipantManager::add_channel_participant(ChannelId channel_id, Use
auto &queries = join_channel_queries_[channel_id];
queries.push_back(std::move(promise));
if (queries.size() == 1u) {
if (!td_->contacts_manager_->get_channel_join_request(channel_id)) {
if (!td_->chat_manager_->get_channel_join_request(channel_id)) {
auto new_status = my_status;
new_status.set_is_member(true);
speculative_add_channel_user(channel_id, user_id, new_status, my_status);
@ -2311,7 +2309,7 @@ void DialogParticipantManager::add_channel_participant(ChannelId channel_id, Use
return;
}
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_invite_users()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_invite_users()) {
return promise.set_error(Status::Error(400, "Not enough rights to invite members to the supergroup chat"));
}
@ -2343,11 +2341,11 @@ void DialogParticipantManager::add_channel_participants(ChannelId channel_id, co
return promise.set_error(Status::Error(400, "Bots can't add new chat members"));
}
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
return promise.set_error(Status::Error(400, "Chat info not found"));
}
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_invite_users()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_invite_users()) {
return promise.set_error(Status::Error(400, "Not enough rights to invite members to the supergroup chat"));
}
@ -2375,17 +2373,15 @@ void DialogParticipantManager::add_channel_participants(ChannelId channel_id, co
void DialogParticipantManager::set_channel_participant_status(
ChannelId channel_id, DialogId participant_dialog_id,
td_api::object_ptr<td_api::ChatMemberStatus> &&chat_member_status, Promise<Unit> &&promise) {
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
return promise.set_error(Status::Error(400, "Chat info not found"));
}
auto new_status =
get_dialog_participant_status(chat_member_status, td_->contacts_manager_->get_channel_type(channel_id));
auto new_status = get_dialog_participant_status(chat_member_status, td_->chat_manager_->get_channel_type(channel_id));
if (participant_dialog_id == td_->dialog_manager_->get_my_dialog_id()) {
// fast path is needed, because get_channel_status may return Creator, while GetChannelParticipantQuery returning Left
return set_channel_participant_status_impl(channel_id, participant_dialog_id, std::move(new_status),
td_->contacts_manager_->get_channel_status(channel_id),
std::move(promise));
td_->chat_manager_->get_channel_status(channel_id), std::move(promise));
}
if (participant_dialog_id.get_type() != DialogType::User) {
if (new_status.is_administrator() || new_status.is_member() || new_status.is_restricted()) {
@ -2513,7 +2509,7 @@ void DialogParticipantManager::promote_channel_participant(ChannelId channel_id,
CHECK(new_status.is_member());
// allow to demote self. TODO is it allowed server-side?
} else {
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_promote_members()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_promote_members()) {
return promise.set_error(Status::Error(400, "Not enough rights"));
}
@ -2536,10 +2532,10 @@ void DialogParticipantManager::restrict_channel_participant(ChannelId channel_id
LOG(INFO) << "Restrict " << participant_dialog_id << " in " << channel_id << " from " << old_status << " to "
<< new_status;
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
return promise.set_error(Status::Error(400, "Chat info not found"));
}
auto my_status = td_->contacts_manager_->get_channel_status(channel_id);
auto my_status = td_->chat_manager_->get_channel_status(channel_id);
if (!my_status.is_member() && !my_status.is_creator()) {
if (participant_dialog_id == td_->dialog_manager_->get_my_dialog_id()) {
if (new_status.is_member()) {
@ -2585,7 +2581,7 @@ void DialogParticipantManager::restrict_channel_participant(ChannelId channel_id
CHECK(!old_status.is_creator());
CHECK(!new_status.is_creator());
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_restrict_members()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_restrict_members()) {
return promise.set_error(Status::Error(400, "Not enough rights to restrict/unrestrict chat member"));
}
@ -2670,7 +2666,7 @@ void DialogParticipantManager::speculative_add_channel_user(ChannelId channel_id
const DialogParticipantStatus &old_status) {
speculative_update_dialog_administrators(DialogId(channel_id), user_id, new_status, old_status);
td_->contacts_manager_->speculative_add_channel_user(channel_id, user_id, new_status, old_status);
td_->chat_manager_->speculative_add_channel_user(channel_id, user_id, new_status, old_status);
}
void DialogParticipantManager::send_update_add_chat_members_privacy_forbidden(DialogId dialog_id,
@ -2720,7 +2716,7 @@ bool DialogParticipantManager::have_channel_participant_cache(ChannelId channel_
if (!td_->auth_manager_->is_bot()) {
return false;
}
return td_->contacts_manager_->get_channel_status(channel_id).is_administrator();
return td_->chat_manager_->get_channel_status(channel_id).is_administrator();
}
void DialogParticipantManager::add_channel_participant_to_cache(ChannelId channel_id,

View File

@ -9,8 +9,8 @@
#include "td/telegram/AnimationsManager.h"
#include "td/telegram/AttachMenuManager.h"
#include "td/telegram/BackgroundManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
@ -329,12 +329,12 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source
source.photo_id, std::move(promise));
},
[&](const FileSourceChatPhoto &source) {
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_chat, source.chat_id, std::move(promise),
send_closure_later(G()->chat_manager(), &ChatManager::reload_chat, source.chat_id, std::move(promise),
"FileSourceChatPhoto");
},
[&](const FileSourceChannelPhoto &source) {
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_channel, source.channel_id,
std::move(promise), "FileSourceChannelPhoto");
send_closure_later(G()->chat_manager(), &ChatManager::reload_channel, source.channel_id, std::move(promise),
"FileSourceChannelPhoto");
},
[&](const FileSourceWallpapers &source) { promise.set_error(Status::Error("Can't repair old wallpapers")); },
[&](const FileSourceWebPage &source) {
@ -362,11 +362,11 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source
source.access_hash, std::move(promise));
},
[&](const FileSourceChatFull &source) {
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_chat_full, source.chat_id,
std::move(promise), "FileSourceChatFull");
send_closure_later(G()->chat_manager(), &ChatManager::reload_chat_full, source.chat_id, std::move(promise),
"FileSourceChatFull");
},
[&](const FileSourceChannelFull &source) {
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_channel_full, source.channel_id,
send_closure_later(G()->chat_manager(), &ChatManager::reload_channel_full, source.channel_id,
std::move(promise), "FileSourceChannelFull");
},
[&](const FileSourceAppConfig &source) {

View File

@ -11,7 +11,7 @@
#include "td/telegram/BackgroundManager.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileSourceId.h"
#include "td/telegram/MessageFullId.h"
@ -121,12 +121,12 @@ FileSourceId FileReferenceManager::parse_file_source(Td *td, ParserT &parser) {
case 10: {
ChatId chat_id;
td::parse(chat_id, parser);
return td->contacts_manager_->get_chat_full_file_source_id(chat_id);
return td->chat_manager_->get_chat_full_file_source_id(chat_id);
}
case 11: {
ChannelId channel_id;
td::parse(channel_id, parser);
return td->contacts_manager_->get_channel_full_file_source_id(channel_id);
return td->chat_manager_->get_channel_full_file_source_id(channel_id);
}
case 12:
return td->stickers_manager_->get_app_config_file_source_id();

View File

@ -9,7 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/CustomEmojiId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/ForumTopic.h"
@ -76,7 +76,7 @@ class CreateForumTopicQuery final : public Td::ResultHandler {
random_id_ = Random::secure_int64();
} while (random_id_ == 0);
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::channels_createForumTopic(flags, std::move(input_channel), title, icon_color,
@ -118,7 +118,7 @@ class CreateForumTopicQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "CreateForumTopicQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "CreateForumTopicQuery");
promise_.set_error(std::move(status));
}
};
@ -137,7 +137,7 @@ class EditForumTopicQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
top_thread_message_id_ = top_thread_message_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = 0;
@ -158,7 +158,7 @@ class EditForumTopicQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
top_thread_message_id_ = top_thread_message_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = telegram_api::channels_editForumTopic::CLOSED_MASK;
@ -173,7 +173,7 @@ class EditForumTopicQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
top_thread_message_id_ = MessageId(ServerMessageId(1));
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = telegram_api::channels_editForumTopic::HIDDEN_MASK;
@ -199,7 +199,7 @@ class EditForumTopicQuery final : public Td::ResultHandler {
if (status.message() == "TOPIC_NOT_MODIFIED" && !td_->auth_manager_->is_bot()) {
return promise_.set_value(Unit());
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "EditForumTopicQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "EditForumTopicQuery");
promise_.set_error(std::move(status));
}
};
@ -215,7 +215,7 @@ class UpdatePinnedForumTopicQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, MessageId top_thread_message_id, bool is_pinned) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
@ -239,7 +239,7 @@ class UpdatePinnedForumTopicQuery final : public Td::ResultHandler {
if (status.message() == "PINNED_TOPIC_NOT_MODIFIED" && !td_->auth_manager_->is_bot()) {
return promise_.set_value(Unit());
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "UpdatePinnedForumTopicQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "UpdatePinnedForumTopicQuery");
promise_.set_error(std::move(status));
}
};
@ -255,7 +255,7 @@ class ReorderPinnedForumTopicsQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, const vector<MessageId> &top_thread_message_ids) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = telegram_api::channels_reorderPinnedForumTopics::FORCE_MASK;
@ -280,7 +280,7 @@ class ReorderPinnedForumTopicsQuery final : public Td::ResultHandler {
if (status.message() == "PINNED_TOPICS_NOT_MODIFIED" && !td_->auth_manager_->is_bot()) {
return promise_.set_value(Unit());
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ReorderPinnedForumTopicsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "ReorderPinnedForumTopicsQuery");
promise_.set_error(std::move(status));
}
};
@ -299,7 +299,7 @@ class GetForumTopicQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
top_thread_message_id_ = top_thread_message_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
@ -318,7 +318,7 @@ class GetForumTopicQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for GetForumTopicQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetForumTopicQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetForumTopicQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetForumTopicQuery");
if (ptr->topics_.size() != 1u) {
return promise_.set_value(nullptr);
@ -346,7 +346,7 @@ class GetForumTopicQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetForumTopicQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetForumTopicQuery");
promise_.set_error(std::move(status));
}
};
@ -364,7 +364,7 @@ class GetForumTopicsQuery final : public Td::ResultHandler {
MessageId offset_top_thread_message_id, int32 limit) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = 0;
@ -388,7 +388,7 @@ class GetForumTopicsQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for GetForumTopicsQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetForumTopicsQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetForumTopicsQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetForumTopicsQuery");
MessagesInfo messages_info;
messages_info.messages = std::move(ptr->messages_);
@ -413,7 +413,7 @@ class GetForumTopicsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetForumTopicsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetForumTopicsQuery");
promise_.set_error(std::move(status));
}
};
@ -502,7 +502,7 @@ void ForumTopicManager::create_forum_topic(DialogId dialog_id, string &&title,
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_create_topics()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_create_topics()) {
return promise.set_error(Status::Error(400, "Not enough rights to create a topic"));
}
@ -551,7 +551,7 @@ void ForumTopicManager::edit_forum_topic(DialogId dialog_id, MessageId top_threa
TRY_STATUS_PROMISE(promise, can_be_message_thread_id(top_thread_message_id));
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_edit_topics()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_edit_topics()) {
auto topic_info = get_topic_info(dialog_id, top_thread_message_id);
if (topic_info != nullptr && !topic_info->is_outgoing()) {
return promise.set_error(Status::Error(400, "Not enough rights to edit the topic"));
@ -783,7 +783,7 @@ void ForumTopicManager::get_forum_topic_link(DialogId dialog_id, MessageId top_t
sb << LinkManager::get_t_me_url();
bool is_public = false;
auto dialog_username = td_->contacts_manager_->get_channel_first_username(channel_id);
auto dialog_username = td_->chat_manager_->get_channel_first_username(channel_id);
if (!dialog_username.empty()) {
sb << dialog_username;
is_public = true;
@ -857,7 +857,7 @@ void ForumTopicManager::toggle_forum_topic_is_closed(DialogId dialog_id, Message
TRY_STATUS_PROMISE(promise, can_be_message_thread_id(top_thread_message_id));
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_edit_topics()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_edit_topics()) {
auto topic_info = get_topic_info(dialog_id, top_thread_message_id);
if (topic_info != nullptr && !topic_info->is_outgoing()) {
return promise.set_error(Status::Error(400, "Not enough rights to close or open the topic"));
@ -871,7 +871,7 @@ void ForumTopicManager::toggle_forum_topic_is_hidden(DialogId dialog_id, bool is
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_edit_topics()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_edit_topics()) {
return promise.set_error(Status::Error(400, "Not enough rights to close or open the topic"));
}
@ -884,7 +884,7 @@ void ForumTopicManager::toggle_forum_topic_is_pinned(DialogId dialog_id, Message
TRY_STATUS_PROMISE(promise, can_be_message_thread_id(top_thread_message_id));
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_pin_topics()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_pin_topics()) {
return promise.set_error(Status::Error(400, "Not enough rights to pin or unpin the topic"));
}
@ -900,7 +900,7 @@ void ForumTopicManager::set_pinned_forum_topics(DialogId dialog_id, vector<Messa
}
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_pin_topics()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_pin_topics()) {
return promise.set_error(Status::Error(400, "Not enough rights to reorder forum topics"));
}
@ -913,7 +913,7 @@ void ForumTopicManager::delete_forum_topic(DialogId dialog_id, MessageId top_thr
TRY_STATUS_PROMISE(promise, can_be_message_thread_id(top_thread_message_id));
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_delete_messages()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_delete_messages()) {
auto topic_info = get_topic_info(dialog_id, top_thread_message_id);
if (topic_info != nullptr && !topic_info->is_outgoing()) {
return promise.set_error(Status::Error(400, "Not enough rights to delete the topic"));
@ -1071,7 +1071,7 @@ Status ForumTopicManager::is_forum(DialogId dialog_id) {
return Status::Error(400, "Chat not found");
}
if (dialog_id.get_type() != DialogType::Channel ||
!td_->contacts_manager_->is_forum_channel(dialog_id.get_channel_id())) {
!td_->chat_manager_->is_forum_channel(dialog_id.get_channel_id())) {
return Status::Error(400, "The chat is not a forum");
}
return Status::OK();
@ -1079,7 +1079,7 @@ Status ForumTopicManager::is_forum(DialogId dialog_id) {
bool ForumTopicManager::can_be_forum(DialogId dialog_id) const {
return dialog_id.get_type() == DialogType::Channel &&
td_->contacts_manager_->is_megagroup_channel(dialog_id.get_channel_id());
td_->chat_manager_->is_megagroup_channel(dialog_id.get_channel_id());
}
Status ForumTopicManager::can_be_message_thread_id(MessageId top_thread_message_id) {

View File

@ -7,7 +7,7 @@
#include "td/telegram/GiveawayParameters.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
@ -29,9 +29,8 @@ Result<ChannelId> GiveawayParameters::get_boosted_channel_id(Td *td, DialogId di
return Status::Error(400, "Can't boost the chat");
}
auto channel_id = dialog_id.get_channel_id();
auto status = td->contacts_manager_->get_channel_status(channel_id);
if (td->contacts_manager_->is_broadcast_channel(channel_id) ? !status.can_post_messages()
: !status.is_administrator()) {
auto status = td->chat_manager_->get_channel_status(channel_id);
if (td->chat_manager_->is_broadcast_channel(channel_id) ? !status.can_post_messages() : !status.is_administrator()) {
return Status::Error(400, "Not enough rights in the chat");
}
return channel_id;

View File

@ -40,9 +40,9 @@ class BoostManager;
class BusinessConnectionManager;
class BusinessManager;
class CallManager;
class ChatManager;
class ConfigManager;
class ConnectionCreator;
class ContactsManager;
class DialogActionManager;
class DialogFilterManager;
class DialogInviteLinkManager;
@ -256,6 +256,13 @@ class Global final : public ActorContext {
call_manager_ = call_manager;
}
ActorId<ChatManager> chat_manager() const {
return chat_manager_;
}
void set_chat_manager(ActorId<ChatManager> chat_manager) {
chat_manager_ = chat_manager;
}
ActorId<ConfigManager> config_manager() const {
return config_manager_;
}
@ -263,13 +270,6 @@ class Global final : public ActorContext {
config_manager_ = config_manager;
}
ActorId<ContactsManager> contacts_manager() const {
return contacts_manager_;
}
void set_contacts_manager(ActorId<ContactsManager> contacts_manager) {
contacts_manager_ = contacts_manager;
}
ActorId<DialogActionManager> dialog_action_manager() const {
return dialog_action_manager_;
}
@ -642,8 +642,8 @@ class Global final : public ActorContext {
ActorId<BusinessConnectionManager> business_connection_manager_;
ActorId<BusinessManager> business_manager_;
ActorId<CallManager> call_manager_;
ActorId<ChatManager> chat_manager_;
ActorId<ConfigManager> config_manager_;
ActorId<ContactsManager> contacts_manager_;
ActorId<DialogActionManager> dialog_action_manager_;
ActorId<DialogFilterManager> dialog_filter_manager_;
ActorId<DialogInviteLinkManager> dialog_invite_link_manager_;

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogAction.h"
#include "td/telegram/DialogActionManager.h"
#include "td/telegram/DialogManager.h"
@ -143,7 +143,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for GetGroupCallJoinAsQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetGroupCallJoinAsQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetGroupCallJoinAsQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetGroupCallJoinAsQuery");
promise_.set_value(convert_message_senders_object(td_, ptr->peers_));
}
@ -1251,14 +1251,14 @@ Status GroupCallManager::can_manage_group_calls(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
if (!td_->contacts_manager_->get_chat_permissions(chat_id).can_manage_calls()) {
if (!td_->chat_manager_->get_chat_permissions(chat_id).can_manage_calls()) {
return Status::Error(400, "Not enough rights in the chat");
}
break;
}
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_manage_calls()) {
if (!td_->chat_manager_->get_channel_permissions(channel_id).can_manage_calls()) {
return Status::Error(400, "Not enough rights in the chat");
}
break;
@ -1462,7 +1462,7 @@ void GroupCallManager::finish_get_group_call(InputGroupCallId input_group_call_i
if (result.is_ok()) {
td_->user_manager_->on_get_users(std::move(result.ok_ref()->users_), "finish_get_group_call");
td_->contacts_manager_->on_get_chats(std::move(result.ok_ref()->chats_), "finish_get_group_call");
td_->chat_manager_->on_get_chats(std::move(result.ok_ref()->chats_), "finish_get_group_call");
if (update_group_call(result.ok()->call_, DialogId()) != input_group_call_id) {
LOG(ERROR) << "Expected " << input_group_call_id << ", but received " << to_string(result.ok());
@ -1607,7 +1607,7 @@ void GroupCallManager::on_get_group_call_participants(
CHECK(participants != nullptr);
td_->user_manager_->on_get_users(std::move(participants->users_), "on_get_group_call_participants");
td_->contacts_manager_->on_get_chats(std::move(participants->chats_), "on_get_group_call_participants");
td_->chat_manager_->on_get_chats(std::move(participants->chats_), "on_get_group_call_participants");
if (!need_group_call_participants(input_group_call_id)) {
return;
@ -4128,7 +4128,7 @@ void GroupCallManager::on_group_call_left_impl(GroupCall *group_call, bool need_
auto dialog_id = group_call->dialog_id;
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
(dialog_id.get_type() == DialogType::Chat &&
!td_->contacts_manager_->get_chat_status(dialog_id.get_chat_id()).is_member())) {
!td_->chat_manager_->get_chat_status(dialog_id.get_chat_id()).is_member())) {
group_call->need_rejoin = false;
}
}

View File

@ -10,8 +10,8 @@
#include "td/telegram/AnimationsManager.h"
#include "td/telegram/AudiosManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Contact.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
@ -1051,7 +1051,7 @@ uint64 InlineQueriesManager::send_inline_query(UserId bot_user_id, DialogId dial
return dialog_id == DialogId(bot_user_id) ? 3 : 4;
case telegram_api::inputPeerChannel::ID:
case telegram_api::inputPeerChannelFromMessage::ID:
return 5 + static_cast<int>(td_->contacts_manager_->get_channel_type(dialog_id.get_channel_id()));
return 5 + static_cast<int>(td_->chat_manager_->get_channel_type(dialog_id.get_channel_id()));
default:
UNREACHABLE();
return -1;
@ -1603,7 +1603,7 @@ void InlineQueriesManager::on_get_inline_query_results(DialogId dialog_id, UserI
break;
}
if (dialog_type == DialogType::Channel &&
td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
td_->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
continue;
}
if (dialog_type == DialogType::SecretChat) {

View File

@ -6,7 +6,7 @@
//
#include "td/telegram/InputMessageText.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/misc.h"
@ -50,7 +50,7 @@ Result<InputMessageText> process_input_message_text(const Td *td, DialogId dialo
if (disable_web_page_preview ||
(dialog_id.get_type() == DialogType::Channel &&
!td->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id()).can_add_web_page_previews())) {
!td->chat_manager_->get_channel_permissions(dialog_id.get_channel_id()).can_add_web_page_previews())) {
web_page_url.clear();
}
if (web_page_url.empty()) {

View File

@ -7,7 +7,7 @@
#include "td/telegram/MediaArea.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
@ -235,8 +235,7 @@ telegram_api::object_ptr<telegram_api::MediaArea> MediaArea::get_input_media_are
}
case Type::Message:
if (!is_old_message_) {
auto input_channel =
td->contacts_manager_->get_input_channel(message_full_id_.get_dialog_id().get_channel_id());
auto input_channel = td->chat_manager_->get_input_channel(message_full_id_.get_dialog_id().get_channel_id());
if (input_channel == nullptr) {
return nullptr;
}

View File

@ -17,8 +17,8 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChannelType.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Contact.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/CustomEmojiId.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
@ -2653,7 +2653,7 @@ static Result<InputMessageContent> create_input_message_content(
WebPageId web_page_id;
bool can_add_web_page_previews =
dialog_id.get_type() != DialogType::Channel ||
td->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id()).can_add_web_page_previews();
td->chat_manager_->get_channel_permissions(dialog_id.get_channel_id()).can_add_web_page_previews();
if (!is_bot && !disable_web_page_preview && can_add_web_page_previews) {
web_page_id = td->web_pages_manager_->get_web_page_by_url(
web_page_url.empty() ? get_first_url(input_message_text.text).str() : web_page_url);
@ -3589,10 +3589,9 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
case DialogType::User:
return td->user_manager_->get_user_default_permissions(dialog_id.get_user_id());
case DialogType::Chat:
return td->contacts_manager_->get_chat_permissions(dialog_id.get_chat_id()).get_effective_restricted_rights();
return td->chat_manager_->get_chat_permissions(dialog_id.get_chat_id()).get_effective_restricted_rights();
case DialogType::Channel:
return td->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id())
.get_effective_restricted_rights();
return td->chat_manager_->get_channel_permissions(dialog_id.get_channel_id()).get_effective_restricted_rights();
case DialogType::SecretChat:
return td->user_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
case DialogType::None:
@ -3633,8 +3632,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
}
break;
case MessageContentType::Game:
if (dialog_type == DialogType::Channel &&
td->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
if (dialog_type == DialogType::Channel && td->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
// return Status::Error(400, "Games can't be sent to channel chats");
}
if (dialog_type == DialogType::SecretChat) {
@ -3687,8 +3685,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
if (!permissions.can_send_polls()) {
return Status::Error(400, "Not enough rights to send polls to the chat");
}
if (dialog_type == DialogType::Channel &&
td->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id()) &&
if (dialog_type == DialogType::Channel && td->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id()) &&
!td->poll_manager_->get_poll_is_anonymous(static_cast<const MessagePoll *>(content)->poll_id)) {
return Status::Error(400, "Non-anonymous polls can't be sent to channel chats");
}
@ -7092,7 +7089,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
case MessageContentType::ChatMigrateTo: {
const auto *m = static_cast<const MessageChatMigrateTo *>(content);
return make_tl_object<td_api::messageChatUpgradeTo>(
td->contacts_manager_->get_supergroup_id_object(m->migrated_to_channel_id, "MessageChatUpgradeTo"));
td->chat_manager_->get_supergroup_id_object(m->migrated_to_channel_id, "MessageChatUpgradeTo"));
}
case MessageContentType::ChannelCreate: {
const auto *m = static_cast<const MessageChannelCreate *>(content);
@ -7101,8 +7098,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
case MessageContentType::ChannelMigrateFrom: {
const auto *m = static_cast<const MessageChannelMigrateFrom *>(content);
return make_tl_object<td_api::messageChatUpgradeFrom>(
m->title,
td->contacts_manager_->get_basic_group_id_object(m->migrated_from_chat_id, "MessageChatUpgradeFrom"));
m->title, td->chat_manager_->get_basic_group_id_object(m->migrated_from_chat_id, "MessageChatUpgradeFrom"));
}
case MessageContentType::PinMessage: {
const auto *m = static_cast<const MessagePinMessage *>(content);

View File

@ -7,7 +7,7 @@
#include "td/telegram/MessageImportManager.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileManager.h"
@ -306,7 +306,7 @@ Status MessageImportManager::can_import_messages(DialogId dialog_id) {
if (td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
return Status::Error(400, "Can't import messages to channels");
}
if (!td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id()).can_change_info_and_settings()) {
if (!td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id()).can_change_info_and_settings()) {
return Status::Error(400, "Not enough rights to import messages");
}
break;

View File

@ -7,7 +7,7 @@
#include "td/telegram/MessageOrigin.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -67,8 +67,8 @@ Result<MessageOrigin> MessageOrigin::get_message_origin(
return Status::Error("Forward from a non-channel");
} else {
auto channel_id = sender_dialog_id.get_channel_id();
if (!td->contacts_manager_->have_channel(channel_id)) {
LOG(ERROR) << "Receive forward from " << (td->contacts_manager_->have_min_channel(channel_id) ? "min" : "unknown")
if (!td->chat_manager_->have_channel(channel_id)) {
LOG(ERROR) << "Receive forward from " << (td->chat_manager_->have_min_channel(channel_id) ? "min" : "unknown")
<< ' ' << channel_id;
}
td->dialog_manager_->force_create_dialog(sender_dialog_id, "get_message_origin", true);

View File

@ -7,7 +7,7 @@
#include "td/telegram/MessageReaction.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -200,7 +200,7 @@ class GetMessageReactionsListQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for GetMessageReactionsListQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetMessageReactionsListQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetMessageReactionsListQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetMessageReactionsListQuery");
int32 total_count = ptr->count_;
auto received_reaction_count = static_cast<int32>(ptr->reactions_.size());
@ -523,7 +523,7 @@ unique_ptr<MessageReactions> MessageReactions::get_message_reactions(
}
} else if (dialog_type == DialogType::Channel) {
auto channel_id = dialog_id.get_channel_id();
auto min_channel = td->contacts_manager_->get_min_channel(channel_id);
auto min_channel = td->chat_manager_->get_min_channel(channel_id);
if (min_channel == nullptr) {
LOG(ERROR) << "Receive unknown reacted " << channel_id;
continue;
@ -815,7 +815,7 @@ void MessageReactions::add_min_channels(Td *td) const {
for (const auto &reaction : reactions_) {
for (const auto &recent_chooser_min_channel : reaction.get_recent_chooser_min_channels()) {
LOG(INFO) << "Add min reacted " << recent_chooser_min_channel.first;
td->contacts_manager_->add_min_channel(recent_chooser_min_channel.first, recent_chooser_min_channel.second);
td->chat_manager_->add_min_channel(recent_chooser_min_channel.first, recent_chooser_min_channel.second);
}
}
}

View File

@ -6,7 +6,7 @@
//
#include "td/telegram/MessageReplyInfo.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessageSender.h"
#include "td/telegram/ServerMessageId.h"
@ -66,7 +66,7 @@ MessageReplyInfo::MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageRe
}
} else if (dialog_type == DialogType::Channel) {
auto replier_channel_id = dialog_id.get_channel_id();
auto min_channel = td->contacts_manager_->get_min_channel(replier_channel_id);
auto min_channel = td->chat_manager_->get_min_channel(replier_channel_id);
if (min_channel == nullptr) {
LOG(ERROR) << "Receive unknown replied " << replier_channel_id;
continue;
@ -188,7 +188,7 @@ bool MessageReplyInfo::need_reget(const Td *td) const {
for (auto &dialog_id : recent_replier_dialog_ids_) {
if (dialog_id.get_type() != DialogType::User && !td->dialog_manager_->have_dialog_info(dialog_id)) {
if (dialog_id.get_type() == DialogType::Channel &&
td->contacts_manager_->have_min_channel(dialog_id.get_channel_id())) {
td->chat_manager_->have_min_channel(dialog_id.get_channel_id())) {
return false;
}
LOG(INFO) << "Reget a message because of replied " << dialog_id;

View File

@ -7,7 +7,7 @@
#include "td/telegram/MessageSender.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"
@ -72,7 +72,7 @@ td_api::object_ptr<td_api::MessageSender> get_min_message_sender_object(Td *td,
} else {
if (!td->messages_manager_->have_dialog(dialog_id) &&
(td->dialog_manager_->have_dialog_info(dialog_id) ||
(dialog_type == DialogType::Channel && td->contacts_manager_->have_min_channel(dialog_id.get_channel_id())))) {
(dialog_type == DialogType::Channel && td->chat_manager_->have_min_channel(dialog_id.get_channel_id())))) {
LOG(INFO) << "Force creation of " << dialog_id;
td->dialog_manager_->force_create_dialog(dialog_id, source, true);
}

View File

@ -6,7 +6,7 @@
//
#include "td/telegram/MessagesInfo.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/ForumTopicManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
@ -69,7 +69,7 @@ MessagesInfo get_messages_info(Td *td, DialogId dialog_id,
}
td->user_manager_->on_get_users(std::move(users), source);
td->contacts_manager_->on_get_chats(std::move(chats), source);
td->chat_manager_->on_get_chats(std::move(chats), source);
td->forum_topic_manager_->on_get_forum_topic_infos(dialog_id, std::move(topics), source);
return result;

View File

@ -13,8 +13,8 @@
#include "td/telegram/BlockListId.h"
#include "td/telegram/ChainId.h"
#include "td/telegram/ChannelType.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/ChatReactions.hpp"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogAction.h"
#include "td/telegram/DialogActionBar.h"
@ -138,7 +138,7 @@ class GetDialogQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for GetDialogQuery: " << to_string(result);
td_->user_manager_->on_get_users(std::move(result->users_), "GetDialogQuery");
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetDialogQuery");
td_->chat_manager_->on_get_chats(std::move(result->chats_), "GetDialogQuery");
td_->messages_manager_->on_get_dialogs(FolderId(), std::move(result->dialogs_), -1, std::move(result->messages_),
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(),
dialog_id = dialog_id_](Result<> result) {
@ -181,7 +181,7 @@ class GetPinnedDialogsQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive pinned chats in " << folder_id_ << ": " << to_string(result);
td_->user_manager_->on_get_users(std::move(result->users_), "GetPinnedDialogsQuery");
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetPinnedDialogsQuery");
td_->chat_manager_->on_get_chats(std::move(result->chats_), "GetPinnedDialogsQuery");
td_->messages_manager_->on_get_dialogs(folder_id_, std::move(result->dialogs_), -2, std::move(result->messages_),
std::move(promise_));
}
@ -353,7 +353,7 @@ class GetChannelMessagesQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
return;
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelMessagesQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetChannelMessagesQuery");
promise_.set_error(std::move(status));
}
};
@ -582,7 +582,7 @@ class ExportChannelMessageLinkQuery final : public Td::ResultHandler {
message_id_ = message_id;
for_group_ = for_group;
ignore_result_ = ignore_result;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -654,7 +654,7 @@ class GetDialogListQuery final : public Td::ResultHandler {
case telegram_api::messages_dialogs::ID: {
auto dialogs = move_tl_object_as<telegram_api::messages_dialogs>(ptr);
td_->user_manager_->on_get_users(std::move(dialogs->users_), "GetDialogListQuery");
td_->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListQuery");
td_->chat_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListQuery");
td_->messages_manager_->on_get_dialogs(folder_id_, std::move(dialogs->dialogs_),
narrow_cast<int32>(dialogs->dialogs_.size()),
std::move(dialogs->messages_), std::move(promise_));
@ -663,7 +663,7 @@ class GetDialogListQuery final : public Td::ResultHandler {
case telegram_api::messages_dialogsSlice::ID: {
auto dialogs = move_tl_object_as<telegram_api::messages_dialogsSlice>(ptr);
td_->user_manager_->on_get_users(std::move(dialogs->users_), "GetDialogListQuery slice");
td_->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListQuery slice");
td_->chat_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListQuery slice");
td_->messages_manager_->on_get_dialogs(folder_id_, std::move(dialogs->dialogs_), max(dialogs->count_, 0),
std::move(dialogs->messages_), std::move(promise_));
break;
@ -700,7 +700,7 @@ class SearchPublicDialogsQuery final : public Td::ResultHandler {
auto dialogs = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SearchPublicDialogsQuery: " << to_string(dialogs);
td_->user_manager_->on_get_users(std::move(dialogs->users_), "SearchPublicDialogsQuery");
td_->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "SearchPublicDialogsQuery");
td_->chat_manager_->on_get_chats(std::move(dialogs->chats_), "SearchPublicDialogsQuery");
td_->messages_manager_->on_get_public_dialogs_search_result(query_, std::move(dialogs->my_results_),
std::move(dialogs->results_));
}
@ -753,7 +753,7 @@ class GetBlockedDialogsQuery final : public Td::ResultHandler {
auto blocked_peers = move_tl_object_as<telegram_api::contacts_blocked>(ptr);
td_->user_manager_->on_get_users(std::move(blocked_peers->users_), "GetBlockedDialogsQuery");
td_->contacts_manager_->on_get_chats(std::move(blocked_peers->chats_), "GetBlockedDialogsQuery");
td_->chat_manager_->on_get_chats(std::move(blocked_peers->chats_), "GetBlockedDialogsQuery");
td_->messages_manager_->on_get_blocked_dialogs(offset_, limit_,
narrow_cast<int32>(blocked_peers->blocked_.size()),
std::move(blocked_peers->blocked_), std::move(promise_));
@ -763,7 +763,7 @@ class GetBlockedDialogsQuery final : public Td::ResultHandler {
auto blocked_peers = move_tl_object_as<telegram_api::contacts_blockedSlice>(ptr);
td_->user_manager_->on_get_users(std::move(blocked_peers->users_), "GetBlockedDialogsQuery slice");
td_->contacts_manager_->on_get_chats(std::move(blocked_peers->chats_), "GetBlockedDialogsQuery slice");
td_->chat_manager_->on_get_chats(std::move(blocked_peers->chats_), "GetBlockedDialogsQuery slice");
td_->messages_manager_->on_get_blocked_dialogs(offset_, limit_, blocked_peers->count_,
std::move(blocked_peers->blocked_), std::move(promise_));
break;
@ -1003,7 +1003,7 @@ class ToggleViewForumAsMessagesQuery final : public Td::ResultHandler {
view_as_messages_ = view_as_messages;
CHECK(dialog_id.get_type() == DialogType::Channel);
auto input_channel = td_->contacts_manager_->get_input_channel(dialog_id.get_channel_id());
auto input_channel = td_->chat_manager_->get_input_channel(dialog_id.get_channel_id());
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::channels_toggleViewForumAsMessages(std::move(input_channel), view_as_messages), {{dialog_id}}));
@ -1218,7 +1218,7 @@ class GetMessagesViewsQuery final : public Td::ResultHandler {
return on_error(Status::Error(500, "Wrong number of message views returned"));
}
td_->user_manager_->on_get_users(std::move(result->users_), "GetMessagesViewsQuery");
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetMessagesViewsQuery");
td_->chat_manager_->on_get_chats(std::move(result->chats_), "GetMessagesViewsQuery");
for (size_t i = 0; i < message_ids_.size(); i++) {
MessageFullId message_full_id{dialog_id_, message_ids_[i]};
@ -1325,7 +1325,7 @@ class ReadChannelMessagesContentsQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, vector<MessageId> &&message_ids) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
LOG(ERROR) << "Have no input channel for " << channel_id;
return on_error(Status::Error(400, "Can't access the chat"));
@ -1350,7 +1350,7 @@ class ReadChannelMessagesContentsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ReadChannelMessagesContentsQuery")) {
if (!td_->chat_manager_->on_get_channel_error(channel_id_, status, "ReadChannelMessagesContentsQuery")) {
LOG(ERROR) << "Receive error for read messages contents in " << channel_id_ << ": " << status;
}
promise_.set_error(std::move(status));
@ -1546,7 +1546,7 @@ class ReadChannelHistoryQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, MessageId max_message_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -1566,7 +1566,7 @@ class ReadChannelHistoryQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ReadChannelHistoryQuery")) {
if (!td_->chat_manager_->on_get_channel_error(channel_id_, status, "ReadChannelHistoryQuery")) {
LOG(ERROR) << "Receive error for ReadChannelHistoryQuery: " << status;
}
promise_.set_error(std::move(status));
@ -1651,7 +1651,7 @@ class GetSearchResultCalendarQuery final : public Td::ResultHandler {
auto result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetSearchResultCalendarQuery: " << to_string(result);
td_->user_manager_->on_get_users(std::move(result->users_), "GetSearchResultCalendarQuery");
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetSearchResultCalendarQuery");
td_->chat_manager_->on_get_chats(std::move(result->chats_), "GetSearchResultCalendarQuery");
// unused: inexact:flags.0?true min_date:int min_msg_id:int offset_id_offset:flags.1?int
@ -1855,7 +1855,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
CHECK(!saved_messages_topic_id.is_valid());
CHECK(tag_.is_empty());
handle_errors_ = dialog_id.get_type() != DialogType::Channel ||
!td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id());
!td_->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id());
send_query(G()->net_query_creator().create(telegram_api::messages_getReplies(
std::move(input_peer), top_msg_id, offset_id, 0, offset, limit, std::numeric_limits<int32>::max(), 0, 0)));
} else {
@ -2336,7 +2336,7 @@ class DeleteTopicHistoryQuery final : public Td::ResultHandler {
channel_id_ = dialog_id.get_channel_id();
top_thread_message_id_ = top_thread_message_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id_);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id_);
if (input_channel == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2375,7 +2375,7 @@ class DeleteChannelHistoryQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
max_message_id_ = max_message_id;
allow_error_ = allow_error;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2401,7 +2401,7 @@ class DeleteChannelHistoryQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelHistoryQuery")) {
if (!td_->chat_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelHistoryQuery")) {
LOG(ERROR) << "Receive error for DeleteChannelHistoryQuery: " << status;
}
promise_.set_error(std::move(status));
@ -2536,7 +2536,7 @@ class DeleteParticipantHistoryQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
sender_dialog_id_ = sender_dialog_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Chat is not accessible"));
}
@ -2560,7 +2560,7 @@ class DeleteParticipantHistoryQuery final : public Td::ResultHandler {
void on_error(Status status) final {
if (sender_dialog_id_.get_type() != DialogType::Channel) {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteParticipantHistoryQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "DeleteParticipantHistoryQuery");
}
promise_.set_error(std::move(status));
}
@ -3755,7 +3755,7 @@ class DeleteChannelMessagesQuery final : public Td::ResultHandler {
channel_id_ = channel_id;
server_message_ids_ = server_message_ids;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -3781,7 +3781,7 @@ class DeleteChannelMessagesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelMessagesQuery")) {
if (!td_->chat_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelMessagesQuery")) {
if (status.message() != "MESSAGE_DELETE_FORBIDDEN") {
LOG(ERROR) << "Receive error for delete channel messages: " << status;
}
@ -3853,7 +3853,7 @@ class GetPeerSettingsQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetPeerSettingsQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetPeerSettingsQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetPeerSettingsQuery");
td_->messages_manager_->on_get_peer_settings(dialog_id_, std::move(ptr->settings_));
}
@ -6011,7 +6011,7 @@ void MessagesManager::on_update_channel_too_long(tl_object_ptr<telegram_api::upd
LOG(ERROR) << "Receive invalid " << channel_id << " in updateChannelTooLong";
return;
}
if (!td_->contacts_manager_->have_channel_force(channel_id, "on_update_channel_too_long")) {
if (!td_->chat_manager_->have_channel_force(channel_id, "on_update_channel_too_long")) {
LOG(INFO) << "Skip updateChannelTooLong about unknown " << channel_id;
return;
}
@ -6250,15 +6250,15 @@ bool MessagesManager::is_active_message_reply_info(DialogId dialog_id, const Mes
}
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->get_channel_has_linked_channel(channel_id)) {
if (!td_->chat_manager_->get_channel_has_linked_channel(channel_id)) {
return false;
}
auto linked_channel_id =
td_->contacts_manager_->get_channel_linked_channel_id(channel_id, "is_active_message_reply_info");
td_->chat_manager_->get_channel_linked_channel_id(channel_id, "is_active_message_reply_info");
if (!linked_channel_id.is_valid()) {
// keep the comment button while linked channel is unknown
send_closure_later(G()->contacts_manager(), &ContactsManager::load_channel_full, channel_id, false, Promise<Unit>(),
send_closure_later(G()->chat_manager(), &ChatManager::load_channel_full, channel_id, false, Promise<Unit>(),
"is_active_message_reply_info");
return true;
}
@ -6286,8 +6286,8 @@ bool MessagesManager::is_visible_message_reply_info(DialogId dialog_id, const Me
return false;
}
if (m->reply_info.is_comment_ && is_broadcast &&
td_->contacts_manager_->have_channel_force(m->reply_info.channel_id_, "is_visible_message_reply_info") &&
!td_->contacts_manager_->have_input_peer_channel(m->reply_info.channel_id_, AccessRights::Read)) {
td_->chat_manager_->have_channel_force(m->reply_info.channel_id_, "is_visible_message_reply_info") &&
!td_->chat_manager_->have_input_peer_channel(m->reply_info.channel_id_, AccessRights::Read)) {
// keep the comment button while have no information about the linked channel
return false;
}
@ -6868,7 +6868,7 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p
}
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->have_channel(channel_id) && td_->contacts_manager_->have_min_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id) && td_->chat_manager_->have_min_channel(channel_id)) {
td_->updates_manager_->schedule_get_difference("add_pending_channel_update 1");
promise.set_value(Unit());
return;
@ -6881,7 +6881,7 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p
if (d == nullptr) {
auto pts = load_channel_pts(dialog_id);
if (pts > 0) {
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
// do not create dialog if there is no info about the channel
LOG(INFO) << "There is no info about " << channel_id << ", so ignore " << oneline(to_string(update));
promise.set_value(Unit());
@ -6950,8 +6950,7 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p
} else if (old_pts != new_pts - pts_count) {
LOG(INFO) << "Found a gap in the " << dialog_id << " with PTS = " << old_pts << ". new_pts = " << new_pts
<< ", pts_count = " << pts_count << " in update from " << source;
if (d->was_opened || td_->contacts_manager_->get_channel_status(channel_id).is_member() ||
is_dialog_sponsored(d)) {
if (d->was_opened || td_->chat_manager_->get_channel_status(channel_id).is_member() || is_dialog_sponsored(d)) {
add_postponed_channel_update(dialog_id, std::move(update), new_pts, pts_count, std::move(promise));
get_channel_difference(dialog_id, old_pts, new_pts, MessageId(), true,
"add_pending_channel_update PTS mismatch");
@ -9603,7 +9602,7 @@ bool MessagesManager::can_get_message_statistics(DialogId dialog_id, const Messa
m->had_forward_info || (m->forward_info != nullptr && m->forward_info->get_origin().is_channel_post())) {
return false;
}
return td_->contacts_manager_->can_get_channel_message_statistics(dialog_id.get_channel_id());
return td_->chat_manager_->can_get_channel_message_statistics(dialog_id.get_channel_id());
}
bool MessagesManager::can_delete_channel_message(const DialogParticipantStatus &status, const Message *m, bool is_bot) {
@ -9663,7 +9662,7 @@ bool MessagesManager::can_delete_message(DialogId dialog_id, const Message *m) c
case DialogType::Chat:
return true;
case DialogType::Channel: {
auto dialog_status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
auto dialog_status = td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id());
return can_delete_channel_message(dialog_status, m, td_->auth_manager_->is_bot());
}
case DialogType::SecretChat:
@ -9709,8 +9708,7 @@ bool MessagesManager::can_revoke_message(DialogId dialog_id, const Message *m) c
G()->unix_time() - m->date <= revoke_time_limit;
}
case DialogType::Chat: {
bool is_appointed_administrator =
td_->contacts_manager_->is_appointed_chat_administrator(dialog_id.get_chat_id());
bool is_appointed_administrator = td_->chat_manager_->is_appointed_chat_administrator(dialog_id.get_chat_id());
int64 revoke_time_limit =
td_->option_manager_->get_option_integer("revoke_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
@ -10008,7 +10006,7 @@ void MessagesManager::on_failed_scheduled_message_deletion(DialogId dialog_id, c
return;
}
if (td_->dialog_manager_->is_broadcast_channel(dialog_id) &&
!td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).can_post_messages()) {
!td_->chat_manager_->get_channel_status(dialog_id.get_channel_id()).can_post_messages()) {
return;
}
load_dialog_scheduled_messages(dialog_id, false, 0, Promise<Unit>());
@ -10041,15 +10039,15 @@ MessagesManager::CanDeleteDialog MessagesManager::can_delete_dialog(const Dialog
return {true, td_->option_manager_->get_option_boolean("revoke_pm_inbox", true)};
case DialogType::Chat:
// chats can be deleted only for self and can be deleted for everyone by their creator
return {true, td_->contacts_manager_->get_chat_status(d->dialog_id.get_chat_id()).is_creator()};
return {true, td_->chat_manager_->get_chat_status(d->dialog_id.get_chat_id()).is_creator()};
case DialogType::Channel: {
// private non-forum joined supergroups can be deleted for self
auto channel_id = d->dialog_id.get_channel_id();
return {!td_->contacts_manager_->is_broadcast_channel(channel_id) &&
!td_->contacts_manager_->is_channel_public(channel_id) &&
!td_->contacts_manager_->is_forum_channel(channel_id) &&
td_->contacts_manager_->get_channel_status(channel_id).is_member(),
td_->contacts_manager_->get_channel_can_be_deleted(channel_id)};
return {!td_->chat_manager_->is_broadcast_channel(channel_id) &&
!td_->chat_manager_->is_channel_public(channel_id) &&
!td_->chat_manager_->is_forum_channel(channel_id) &&
td_->chat_manager_->get_channel_status(channel_id).is_member(),
td_->chat_manager_->get_channel_can_be_deleted(channel_id)};
}
case DialogType::SecretChat:
if (td_->user_manager_->get_secret_chat_state(d->dialog_id.get_secret_chat_id()) == SecretChatState::Closed) {
@ -10381,10 +10379,10 @@ void MessagesManager::delete_dialog_messages_by_sender(DialogId dialog_id, Dialo
Status::Error(400, "All messages from a sender can be deleted only in supergroup chats"));
case DialogType::Channel: {
channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->is_megagroup_channel(channel_id)) {
if (!td_->chat_manager_->is_megagroup_channel(channel_id)) {
return promise.set_error(Status::Error(400, "The method is available only in supergroup chats"));
}
channel_status = td_->contacts_manager_->get_channel_permissions(channel_id);
channel_status = td_->chat_manager_->get_channel_permissions(channel_id);
if (!channel_status.can_delete_messages()) {
return promise.set_error(Status::Error(400, "Need delete messages administator right in the supergroup chat"));
}
@ -15256,7 +15254,7 @@ void MessagesManager::on_message_deleted(Dialog *d, Message *m, bool is_permanen
case DialogType::Channel:
if (m->message_id.is_server() && !td_->auth_manager_->is_bot()) {
td_->user_manager_->unregister_message_users({d->dialog_id, m->message_id}, get_message_user_ids(m));
td_->contacts_manager_->unregister_message_channels({d->dialog_id, m->message_id}, get_message_channel_ids(m));
td_->chat_manager_->unregister_message_channels({d->dialog_id, m->message_id}, get_message_channel_ids(m));
}
break;
case DialogType::SecretChat:
@ -15412,7 +15410,7 @@ bool MessagesManager::load_dialog(DialogId dialog_id, int left_tries, Promise<Un
break;
}
case DialogType::Chat: {
auto have_chat = td_->contacts_manager_->get_chat(dialog_id.get_chat_id(), left_tries, std::move(promise));
auto have_chat = td_->chat_manager_->get_chat(dialog_id.get_chat_id(), left_tries, std::move(promise));
if (!have_chat) {
return false;
}
@ -15420,7 +15418,7 @@ bool MessagesManager::load_dialog(DialogId dialog_id, int left_tries, Promise<Un
}
case DialogType::Channel: {
auto have_channel =
td_->contacts_manager_->get_channel(dialog_id.get_channel_id(), left_tries, std::move(promise));
td_->chat_manager_->get_channel(dialog_id.get_channel_id(), left_tries, std::move(promise));
if (!have_channel) {
return false;
}
@ -16479,7 +16477,7 @@ Result<MessageFullId> MessagesManager::get_top_thread_message_full_id(DialogId d
return Status::Error(400, "Message has no thread");
}
if (!allow_non_root && m->top_thread_message_id != m->message_id &&
!td_->contacts_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id())) {
!td_->chat_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id())) {
return Status::Error(400, "Root message must be used to get the message thread");
}
return MessageFullId{dialog_id, m->top_thread_message_id};
@ -16544,7 +16542,7 @@ void MessagesManager::process_discussion_message(
LOG(INFO) << "Receive discussion message for " << message_id << " in " << dialog_id << " with expected "
<< expected_message_id << " in " << expected_dialog_id << ": " << to_string(result);
td_->user_manager_->on_get_users(std::move(result->users_), "process_discussion_message");
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "process_discussion_message");
td_->chat_manager_->on_get_chats(std::move(result->chats_), "process_discussion_message");
for (auto &message : result->messages_) {
auto message_dialog_id = DialogId::get_message_dialog_id(message);
@ -16822,20 +16820,20 @@ Status MessagesManager::can_get_message_viewers(DialogId dialog_id, const Messag
case DialogType::User:
return Status::Error(400, "Can't get message viewers in private chats");
case DialogType::Chat:
if (!td_->contacts_manager_->get_chat_is_active(dialog_id.get_chat_id())) {
if (!td_->chat_manager_->get_chat_is_active(dialog_id.get_chat_id())) {
return Status::Error(400, "Chat is deactivated");
}
participant_count = td_->contacts_manager_->get_chat_participant_count(dialog_id.get_chat_id());
participant_count = td_->chat_manager_->get_chat_participant_count(dialog_id.get_chat_id());
break;
case DialogType::Channel:
if (td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
return Status::Error(400, "Can't get message viewers in channel chats");
}
if (td_->contacts_manager_->get_channel_effective_has_hidden_participants(dialog_id.get_channel_id(),
"can_get_message_viewers")) {
if (td_->chat_manager_->get_channel_effective_has_hidden_participants(dialog_id.get_channel_id(),
"can_get_message_viewers")) {
return Status::Error(400, "Participant list is hidden in the chat");
}
participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
participant_count = td_->chat_manager_->get_channel_participant_count(dialog_id.get_channel_id());
break;
case DialogType::SecretChat:
return Status::Error(400, "Can't get message viewers in secret chats");
@ -16909,8 +16907,8 @@ void MessagesManager::on_get_message_viewers(DialogId dialog_id, MessageViewers
switch (dialog_id.get_type()) {
case DialogType::Chat:
return td_->contacts_manager_->reload_chat_full(dialog_id.get_chat_id(), std::move(query_promise),
"on_get_message_viewers");
return td_->chat_manager_->reload_chat_full(dialog_id.get_chat_id(), std::move(query_promise),
"on_get_message_viewers");
case DialogType::Channel:
return td_->dialog_participant_manager_->get_channel_participants(
dialog_id.get_channel_id(), td_api::make_object<td_api::supergroupMembersFilterRecent>(), string(), 0,
@ -17112,8 +17110,8 @@ void MessagesManager::get_messages_from_server(vector<MessageFullId> &&message_i
}
for (auto &it : channel_message_ids) {
td_->contacts_manager_->have_channel_force(it.first, "get_messages_from_server");
auto input_channel = td_->contacts_manager_->get_input_channel(it.first);
td_->chat_manager_->have_channel_force(it.first, "get_messages_from_server");
auto input_channel = td_->chat_manager_->get_input_channel(it.first);
if (input_channel == nullptr) {
LOG(ERROR) << "Can't find info about " << it.first << " to get a message from it from " << source;
mpas.get_promise().set_error(Status::Error(400, "Can't access the chat"));
@ -17202,7 +17200,7 @@ Status MessagesManager::can_get_media_timestamp_link(DialogId dialog_id, const M
bool MessagesManager::can_report_message_reactions(DialogId dialog_id, const Message *m) const {
CHECK(m != nullptr);
if (dialog_id.get_type() != DialogType::Channel || td_->dialog_manager_->is_broadcast_channel(dialog_id) ||
!td_->contacts_manager_->is_channel_public(dialog_id.get_channel_id())) {
!td_->chat_manager_->is_channel_public(dialog_id.get_channel_id())) {
return false;
}
if (m->message_id.is_scheduled() || !m->message_id.is_server()) {
@ -17286,7 +17284,7 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(MessageFullId
CHECK(linked_d != nullptr);
CHECK(linked_dialog_id.get_type() == DialogType::Channel);
auto *linked_m = get_message_force(linked_d, linked_message_id, "get_public_message_link");
auto channel_username = td_->contacts_manager_->get_channel_first_username(linked_dialog_id.get_channel_id());
auto channel_username = td_->chat_manager_->get_channel_first_username(linked_dialog_id.get_channel_id());
if (linked_m != nullptr && is_active_message_reply_info(linked_dialog_id, linked_m->reply_info) &&
linked_message_id.is_server() &&
td_->dialog_manager_->have_input_peer(linked_dialog_id, AccessRights::Read) && !channel_username.empty()) {
@ -17303,7 +17301,7 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(MessageFullId
}
}
auto dialog_username = td_->contacts_manager_->get_channel_first_username(dialog_id.get_channel_id());
auto dialog_username = td_->chat_manager_->get_channel_first_username(dialog_id.get_channel_id());
bool is_public = !dialog_username.empty();
if (m->content->get_type() == MessageContentType::VideoNote &&
td_->dialog_manager_->is_broadcast_channel(dialog_id) && is_public) {
@ -17356,7 +17354,7 @@ string MessagesManager::get_message_embedding_code(MessageFullId message_full_id
return {};
}
if (dialog_id.get_type() != DialogType::Channel ||
td_->contacts_manager_->get_channel_first_username(dialog_id.get_channel_id()).empty()) {
td_->chat_manager_->get_channel_first_username(dialog_id.get_channel_id()).empty()) {
promise.set_error(Status::Error(
400, "Message embedding code is available only for messages in public supergroups and channel chats"));
return {};
@ -17451,7 +17449,7 @@ void MessagesManager::on_get_message_link_message(MessageLinkInfo &&info, Dialog
return promise.set_value(std::move(info));
}
if (td_->contacts_manager_->have_channel_force(m->reply_info.channel_id_, "on_get_message_link_message")) {
if (td_->chat_manager_->have_channel_force(m->reply_info.channel_id_, "on_get_message_link_message")) {
force_create_dialog(DialogId(m->reply_info.channel_id_), "on_get_message_link_message");
on_get_message_link_discussion_message(std::move(info), DialogId(m->reply_info.channel_id_), std::move(promise));
return;
@ -19051,14 +19049,14 @@ void MessagesManager::open_dialog(Dialog *d) {
td_->story_manager_->on_view_dialog_active_stories({dialog_id});
break;
case DialogType::Chat:
td_->contacts_manager_->repair_chat_participants(dialog_id.get_chat_id());
td_->chat_manager_->repair_chat_participants(dialog_id.get_chat_id());
reget_dialog_action_bar(dialog_id, "open_dialog", false);
break;
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
if (!td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(channel_id);
auto has_hidden_participants = td_->contacts_manager_->get_channel_effective_has_hidden_participants(
auto participant_count = td_->chat_manager_->get_channel_participant_count(channel_id);
auto has_hidden_participants = td_->chat_manager_->get_channel_effective_has_hidden_participants(
dialog_id.get_channel_id(), "open_dialog");
if (participant_count < 195 && !has_hidden_participants) { // include unknown participant_count
td_->dialog_participant_manager_->get_channel_participants(
@ -19070,12 +19068,12 @@ void MessagesManager::open_dialog(Dialog *d) {
get_channel_difference(dialog_id, d->pts, 0, MessageId(), true, "open_dialog");
reget_dialog_action_bar(dialog_id, "open_dialog", false);
if (td_->contacts_manager_->get_channel_has_linked_channel(channel_id)) {
auto linked_channel_id = td_->contacts_manager_->get_channel_linked_channel_id(channel_id, "open_dialog");
if (td_->chat_manager_->get_channel_has_linked_channel(channel_id)) {
auto linked_channel_id = td_->chat_manager_->get_channel_linked_channel_id(channel_id, "open_dialog");
if (!linked_channel_id.is_valid()) {
// load linked_channel_id
send_closure_later(G()->contacts_manager(), &ContactsManager::load_channel_full, channel_id, false,
Promise<Unit>(), "open_dialog");
send_closure_later(G()->chat_manager(), &ChatManager::load_channel_full, channel_id, false, Promise<Unit>(),
"open_dialog");
} else {
td_->dialog_manager_->get_dialog_info_full(DialogId(linked_channel_id), Auto(), "open_dialog");
}
@ -22192,7 +22190,7 @@ vector<MessageId> MessagesManager::get_dialog_scheduled_messages(DialogId dialog
return {};
}
if (td_->dialog_manager_->is_broadcast_channel(dialog_id) &&
!td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).can_post_messages()) {
!td_->chat_manager_->get_channel_status(dialog_id.get_channel_id()).can_post_messages()) {
promise.set_error(Status::Error(400, "Not enough rights to get scheduled messages"));
return {};
}
@ -22371,9 +22369,8 @@ ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d,
bool can_use_reactions = true;
if (d->dialog_id.get_type() == DialogType::Channel) {
auto channel_id = d->dialog_id.get_channel_id();
if (td_->contacts_manager_->is_megagroup_channel(channel_id) &&
!td_->contacts_manager_->get_channel_status(channel_id).is_member() &&
can_send_message(d->dialog_id).is_error()) {
if (td_->chat_manager_->is_megagroup_channel(channel_id) &&
!td_->chat_manager_->get_channel_status(channel_id).is_member() && can_send_message(d->dialog_id).is_error()) {
// can't use reactions if can't send messages to the group without joining
if (unavailability_reason != nullptr) {
*unavailability_reason = ReactionUnavailabilityReason::Guest;
@ -22381,7 +22378,7 @@ ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d,
can_use_reactions = false;
} else if (td_->dialog_manager_->is_anonymous_administrator(d->dialog_id, nullptr) &&
!td_->dialog_manager_->is_broadcast_channel(d->dialog_id) &&
!td_->contacts_manager_->get_channel_status(channel_id).is_creator()) {
!td_->chat_manager_->get_channel_status(channel_id).is_creator()) {
// only creator can react as the chat
if (unavailability_reason != nullptr) {
*unavailability_reason = ReactionUnavailabilityReason::AnonymousAdministrator;
@ -22993,7 +22990,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
bool is_channel_post = td_->dialog_manager_->is_broadcast_channel(dialog_id);
if (is_channel_post) {
// sender of the post can be hidden
if (!is_scheduled && td_->contacts_manager_->get_channel_sign_messages(dialog_id.get_channel_id())) {
if (!is_scheduled && td_->chat_manager_->get_channel_sign_messages(dialog_id.get_channel_id())) {
m->author_signature = td_->user_manager_->get_user_title(my_id);
}
m->sender_dialog_id = dialog_id;
@ -23051,14 +23048,14 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
return false;
}
if (is_channel_post) {
return td_->contacts_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id());
return td_->chat_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id());
}
return !m->input_reply_to.is_valid();
}()) {
m->reply_info.reply_count_ = 0;
if (is_channel_post) {
auto linked_channel_id =
td_->contacts_manager_->get_channel_linked_channel_id(dialog_id.get_channel_id(), "create_message_to_send");
td_->chat_manager_->get_channel_linked_channel_id(dialog_id.get_channel_id(), "create_message_to_send");
if (linked_channel_id.is_valid()) {
m->reply_info.is_comment_ = true;
m->reply_info.channel_id_ = linked_channel_id;
@ -23066,7 +23063,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
}
}
if (m->sender_user_id == my_id && dialog_type == DialogType::Channel) {
m->sender_boost_count = td_->contacts_manager_->get_channel_my_boost_count(dialog_id.get_channel_id());
m->sender_boost_count = td_->chat_manager_->get_channel_my_boost_count(dialog_id.get_channel_id());
}
m->content = std::move(content);
m->invert_media = invert_media;
@ -23142,8 +23139,8 @@ Status MessagesManager::can_send_message(DialogId dialog_id) const {
if (dialog_id.get_type() == DialogType::Channel) {
auto channel_id = dialog_id.get_channel_id();
auto channel_type = td_->contacts_manager_->get_channel_type(channel_id);
auto channel_status = td_->contacts_manager_->get_channel_permissions(channel_id);
auto channel_type = td_->chat_manager_->get_channel_type(channel_id);
auto channel_status = td_->chat_manager_->get_channel_permissions(channel_id);
switch (channel_type) {
case ChannelType::Unknown:
@ -23449,7 +23446,7 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, const
}
for (const auto &replier_min_channel : m->reply_info.replier_min_channels_) {
LOG(INFO) << "Add min replied " << replier_min_channel.first;
td_->contacts_manager_->add_min_channel(replier_min_channel.first, replier_min_channel.second);
td_->chat_manager_->add_min_channel(replier_min_channel.first, replier_min_channel.second);
}
for (auto recent_replier_dialog_id : m->reply_info.recent_replier_dialog_ids_) {
dependencies.add_message_sender_dependencies(recent_replier_dialog_id);
@ -23499,12 +23496,12 @@ void MessagesManager::get_dialog_send_message_as_dialog_ids(
std::multimap<int64, Sender> sorted_senders;
bool is_premium = td_->option_manager_->get_option_boolean("is_premium");
auto linked_channel_id = td_->contacts_manager_->get_channel_linked_channel_id(
auto linked_channel_id = td_->chat_manager_->get_channel_linked_channel_id(
dialog_id.get_channel_id(), "get_dialog_send_message_as_dialog_ids");
for (auto channel_id : created_public_broadcasts_) {
int64 score = td_->contacts_manager_->get_channel_participant_count(channel_id);
bool needs_premium = !is_premium && channel_id != linked_channel_id &&
!td_->contacts_manager_->get_channel_is_verified(channel_id);
int64 score = td_->chat_manager_->get_channel_participant_count(channel_id);
bool needs_premium =
!is_premium && channel_id != linked_channel_id && !td_->chat_manager_->get_channel_is_verified(channel_id);
if (needs_premium) {
score -= static_cast<int64>(1) << 40;
}
@ -23531,7 +23528,7 @@ void MessagesManager::get_dialog_send_message_as_dialog_ids(
std::move(promise), true);
}
});
td_->contacts_manager_->get_created_public_dialogs(PublicDialogType::ForPersonalDialog, std::move(new_promise), true);
td_->chat_manager_->get_created_public_dialogs(PublicDialogType::ForPersonalDialog, std::move(new_promise), true);
}
void MessagesManager::set_dialog_default_send_message_as_dialog_id(DialogId dialog_id,
@ -23567,7 +23564,7 @@ void MessagesManager::set_dialog_default_send_message_as_dialog_id(DialogId dial
break;
}
if (!td_->dialog_manager_->is_broadcast_channel(message_sender_dialog_id) ||
td_->contacts_manager_->get_channel_first_username(message_sender_dialog_id.get_channel_id()).empty()) {
td_->chat_manager_->get_channel_first_username(message_sender_dialog_id.get_channel_id()).empty()) {
return promise.set_error(Status::Error(400, "Message sender chat must be a public channel"));
}
break;
@ -24622,10 +24619,10 @@ Result<MessageId> MessagesManager::send_bot_start_message(UserId bot_user_id, Di
}
auto chat_id = dialog_id.get_chat_id();
if (!td_->contacts_manager_->have_input_peer_chat(chat_id, AccessRights::Write)) {
if (!td_->chat_manager_->have_input_peer_chat(chat_id, AccessRights::Write)) {
return Status::Error(400, "Can't access the chat");
}
auto status = td_->contacts_manager_->get_chat_permissions(chat_id);
auto status = td_->chat_manager_->get_chat_permissions(chat_id);
if (!status.can_invite_users()) {
return Status::Error(400, "Need administrator rights to invite a bot to the group chat");
}
@ -24633,10 +24630,10 @@ Result<MessageId> MessagesManager::send_bot_start_message(UserId bot_user_id, Di
}
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->have_input_peer_channel(channel_id, AccessRights::Write)) {
if (!td_->chat_manager_->have_input_peer_channel(channel_id, AccessRights::Write)) {
return Status::Error(400, "Can't access the chat");
}
switch (td_->contacts_manager_->get_channel_type(channel_id)) {
switch (td_->chat_manager_->get_channel_type(channel_id)) {
case ChannelType::Megagroup:
if (!bot_data.can_join_groups) {
return Status::Error(400, "The bot can't join groups");
@ -24648,7 +24645,7 @@ Result<MessageId> MessagesManager::send_bot_start_message(UserId bot_user_id, Di
default:
UNREACHABLE();
}
auto status = td_->contacts_manager_->get_channel_permissions(channel_id);
auto status = td_->chat_manager_->get_channel_permissions(channel_id);
if (!status.can_invite_users()) {
return Status::Error(400, "Need administrator rights to invite a bot to the supergroup chat");
}
@ -24781,7 +24778,7 @@ Result<td_api::object_ptr<td_api::message>> MessagesManager::send_inline_query_r
// ok
break;
case DialogType::Channel: {
auto channel_status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
auto channel_status = td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id());
if (!channel_status.can_use_inline_bots()) {
return Status::Error(400, "Can't use inline bots in the chat");
}
@ -24972,7 +24969,7 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo
}
auto channel_id = dialog_id.get_channel_id();
auto channel_status = td_->contacts_manager_->get_channel_permissions(channel_id);
auto channel_status = td_->chat_manager_->get_channel_permissions(channel_id);
if (m->is_channel_post) {
if (m->message_id.is_scheduled()) {
if (!channel_status.can_post_messages()) {
@ -26105,7 +26102,7 @@ bool MessagesManager::can_set_game_score(DialogId dialog_id, const Message *m) c
break;
}
auto channel_id = dialog_id.get_channel_id();
auto channel_status = td_->contacts_manager_->get_channel_permissions(channel_id);
auto channel_status = td_->chat_manager_->get_channel_permissions(channel_id);
if (m->is_channel_post) {
if (!channel_status.can_edit_messages() && !(channel_status.can_post_messages() && m->is_outgoing)) {
return false;
@ -27166,7 +27163,7 @@ Result<MessageId> MessagesManager::add_local_message(
m->message_id = message_id;
if (is_channel_post) {
// sender of the post can be hidden
if (td_->contacts_manager_->get_channel_sign_messages(dialog_id.get_channel_id())) {
if (td_->chat_manager_->get_channel_sign_messages(dialog_id.get_channel_id())) {
m->author_signature = td_->user_manager_->get_user_title(sender_user_id);
}
m->sender_dialog_id = sender_dialog_id;
@ -27195,7 +27192,7 @@ Result<MessageId> MessagesManager::add_local_message(
m->view_count = 0;
m->forward_count = 0;
if (m->sender_user_id == my_id && dialog_type == DialogType::Channel) {
m->sender_boost_count = td_->contacts_manager_->get_channel_my_boost_count(dialog_id.get_channel_id());
m->sender_boost_count = td_->chat_manager_->get_channel_my_boost_count(dialog_id.get_channel_id());
}
m->content = std::move(message_content.content);
m->invert_media = message_content.invert_media;
@ -28243,13 +28240,13 @@ bool MessagesManager::is_dialog_message_notification_disabled(DialogId dialog_id
case DialogType::User:
break;
case DialogType::Chat:
if (!td_->contacts_manager_->get_chat_is_active(dialog_id.get_chat_id())) {
if (!td_->chat_manager_->get_chat_is_active(dialog_id.get_chat_id())) {
return true;
}
break;
case DialogType::Channel:
if (!td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).is_member() ||
message_date < td_->contacts_manager_->get_channel_date(dialog_id.get_channel_id())) {
if (!td_->chat_manager_->get_channel_status(dialog_id.get_channel_id()).is_member() ||
message_date < td_->chat_manager_->get_channel_date(dialog_id.get_channel_id())) {
return true;
}
break;
@ -29616,8 +29613,7 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) {
if (error.message() == "CHAT_GUEST_SEND_FORBIDDEN") {
error_code = 400;
if (dialog_id.get_type() == DialogType::Channel) {
td_->contacts_manager_->reload_channel(dialog_id.get_channel_id(), Promise<Unit>(),
"CHAT_GUEST_SEND_FORBIDDEN");
td_->chat_manager_->reload_channel(dialog_id.get_channel_id(), Promise<Unit>(), "CHAT_GUEST_SEND_FORBIDDEN");
}
} else if (error.message() != "CHANNEL_PUBLIC_GROUP_NA" && error.message() != "USER_IS_BLOCKED" &&
error.message() != "USER_BOT_INVALID" && error.message() != "USER_DELETED") {
@ -30423,7 +30419,7 @@ void MessagesManager::fix_pending_join_requests(DialogId dialog_id, int32 &pendi
return true;
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_status(chat_id);
auto status = td_->chat_manager_->get_chat_status(chat_id);
if (!status.can_manage_invite_links()) {
return true;
}
@ -30431,7 +30427,7 @@ void MessagesManager::fix_pending_join_requests(DialogId dialog_id, int32 &pendi
}
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
auto status = td_->contacts_manager_->get_channel_permissions(channel_id);
auto status = td_->chat_manager_->get_channel_permissions(channel_id);
if (!status.can_manage_invite_links()) {
return true;
}
@ -31186,7 +31182,7 @@ bool MessagesManager::get_dialog_has_scheduled_messages(const Dialog *d) const {
return false;
}
if (td_->dialog_manager_->is_broadcast_channel(d->dialog_id) &&
!td_->contacts_manager_->get_channel_status(d->dialog_id.get_channel_id()).can_post_messages()) {
!td_->chat_manager_->get_channel_status(d->dialog_id.get_channel_id()).can_post_messages()) {
return false;
}
// TODO send updateChatHasScheduledMessage when can_post_messages changes
@ -31716,15 +31712,15 @@ void MessagesManager::set_dialog_available_reactions(
return promise.set_error(Status::Error(400, "Can't change private chat available reactions"));
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_permissions(chat_id);
auto status = td_->chat_manager_->get_chat_permissions(chat_id);
if (!status.can_change_info_and_settings() ||
(td_->auth_manager_->is_bot() && !td_->contacts_manager_->is_appointed_chat_administrator(chat_id))) {
(td_->auth_manager_->is_bot() && !td_->chat_manager_->is_appointed_chat_administrator(chat_id))) {
return promise.set_error(Status::Error(400, "Not enough rights to change chat available reactions"));
}
break;
}
case DialogType::Channel: {
auto status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
auto status = td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id());
if (!status.can_change_info_and_settings()) {
return promise.set_error(Status::Error(400, "Not enough rights to change chat available reactions"));
}
@ -31772,7 +31768,7 @@ void MessagesManager::set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Prom
break;
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_permissions(chat_id);
auto status = td_->chat_manager_->get_chat_permissions(chat_id);
if (!status.can_change_info_and_settings()) {
return promise.set_error(
Status::Error(400, "Not enough rights to change message auto-delete time in the chat"));
@ -31780,7 +31776,7 @@ void MessagesManager::set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Prom
break;
}
case DialogType::Channel: {
auto status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
auto status = td_->chat_manager_->get_channel_permissions(dialog_id.get_channel_id());
if (!status.can_change_info_and_settings()) {
return promise.set_error(
Status::Error(400, "Not enough rights to change message auto-delete time in the chat"));
@ -32822,14 +32818,14 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
}
if (m->date + 3600 >= now && m->is_outgoing) {
auto channel_id = dialog_id.get_channel_id();
auto slow_mode_delay = td_->contacts_manager_->get_channel_slow_mode_delay(channel_id, "add_message_to_dialog");
auto status = td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id());
auto slow_mode_delay = td_->chat_manager_->get_channel_slow_mode_delay(channel_id, "add_message_to_dialog");
auto status = td_->chat_manager_->get_channel_status(dialog_id.get_channel_id());
if (m->date + slow_mode_delay > now && !status.is_administrator()) {
td_->contacts_manager_->on_update_channel_slow_mode_next_send_date(channel_id, m->date + slow_mode_delay);
td_->chat_manager_->on_update_channel_slow_mode_next_send_date(channel_id, m->date + slow_mode_delay);
}
}
if (m->date > now - 14 * 86400) {
td_->contacts_manager_->remove_inactive_channel(dialog_id.get_channel_id());
td_->chat_manager_->remove_inactive_channel(dialog_id.get_channel_id());
}
}
@ -32950,7 +32946,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
case DialogType::Channel:
if (m->message_id.is_server() && !td_->auth_manager_->is_bot()) {
td_->user_manager_->register_message_users({dialog_id, m->message_id}, get_message_user_ids(m));
td_->contacts_manager_->register_message_channels({dialog_id, m->message_id}, get_message_channel_ids(m));
td_->chat_manager_->register_message_channels({dialog_id, m->message_id}, get_message_channel_ids(m));
}
break;
case DialogType::SecretChat:
@ -34301,7 +34297,7 @@ void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_dialog_info(dialog_id)) {
if (expect_no_access && dialog_id.get_type() == DialogType::Channel &&
td_->contacts_manager_->have_min_channel(dialog_id.get_channel_id())) {
td_->chat_manager_->have_min_channel(dialog_id.get_channel_id())) {
LOG(INFO) << "Created " << dialog_id << " for min-channel from " << source;
} else {
LOG(ERROR) << "Forced to create unknown " << dialog_id << " from " << source;
@ -34378,7 +34374,7 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr<Dialog> &&di
d->is_view_as_messages_inited = true;
break;
case DialogType::Channel: {
if (td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
if (td_->chat_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
d->last_read_outbox_message_id = MessageId::max();
d->is_last_read_outbox_message_id_inited = true;
}
@ -35161,16 +35157,16 @@ void MessagesManager::update_dialog_pos(Dialog *d, const char *source, bool need
switch (d->dialog_id.get_type()) {
case DialogType::Chat: {
auto chat_id = d->dialog_id.get_chat_id();
auto date = td_->contacts_manager_->get_chat_date(chat_id);
auto date = td_->chat_manager_->get_chat_date(chat_id);
LOG(INFO) << "Creation at " << date << " found";
int64 join_order = get_dialog_order(MessageId(), date);
if (join_order > new_order && td_->contacts_manager_->get_chat_status(chat_id).is_member()) {
if (join_order > new_order && td_->chat_manager_->get_chat_status(chat_id).is_member()) {
new_order = join_order;
}
break;
}
case DialogType::Channel: {
auto date = td_->contacts_manager_->get_channel_date(d->dialog_id.get_channel_id());
auto date = td_->chat_manager_->get_channel_date(d->dialog_id.get_channel_id());
LOG(INFO) << "Join at " << date << " found";
int64 join_order = get_dialog_order(MessageId(), date);
if (join_order > new_order) {
@ -35660,8 +35656,8 @@ unique_ptr<MessagesManager::Dialog> MessagesManager::parse_dialog(DialogId dialo
break;
}
if (!d->need_drop_default_send_message_as_dialog_id && d->default_send_message_as_dialog_id.is_valid() &&
dialog_type == DialogType::Channel && !td_->contacts_manager_->is_channel_public(dialog_id.get_channel_id()) &&
!td_->contacts_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id())) {
dialog_type == DialogType::Channel && !td_->chat_manager_->is_channel_public(dialog_id.get_channel_id()) &&
!td_->chat_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id())) {
LOG(INFO) << "Drop message sender in " << dialog_id;
d->need_drop_default_send_message_as_dialog_id = true;
}
@ -36074,7 +36070,7 @@ void MessagesManager::get_channel_difference(DialogId dialog_id, int32 pts, int3
debug_last_get_channel_difference_dialog_id_ = dialog_id;
debug_last_get_channel_difference_source_ = source;
auto input_channel = td_->contacts_manager_->get_input_channel(dialog_id.get_channel_id());
auto input_channel = td_->chat_manager_->get_input_channel(dialog_id.get_channel_id());
if (input_channel == nullptr) {
LOG(ERROR) << "Skip running channels.getDifference for " << dialog_id << " from " << source
<< " because the channel is unknown";
@ -36510,7 +36506,7 @@ void MessagesManager::on_get_channel_difference(DialogId dialog_id, int32 reques
auto difference = static_cast<telegram_api::updates_channelDifference *>(difference_ptr.get());
have_new_messages = !difference->new_messages_.empty();
td_->user_manager_->on_get_users(std::move(difference->users_), "updates.channelDifference");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.channelDifference");
td_->chat_manager_->on_get_chats(std::move(difference->chats_), "updates.channelDifference");
for (const auto &message : difference->new_messages_) {
if (is_invalid_poll_message(message.get())) {
LOG(ERROR) << "Receive invalid poll message in updates.channelDifference: " << oneline(to_string(message));
@ -36525,7 +36521,7 @@ void MessagesManager::on_get_channel_difference(DialogId dialog_id, int32 reques
auto difference = static_cast<telegram_api::updates_channelDifferenceTooLong *>(difference_ptr.get());
have_new_messages = difference->dialog_->get_id() == telegram_api::dialog::ID && !difference->messages_.empty();
td_->user_manager_->on_get_users(std::move(difference->users_), "updates.channelDifferenceTooLong");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.channelDifferenceTooLong");
td_->chat_manager_->on_get_chats(std::move(difference->chats_), "updates.channelDifferenceTooLong");
break;
}
default:
@ -36876,15 +36872,15 @@ void MessagesManager::speculatively_update_channel_participants(DialogId dialog_
bool by_me = m->sender_user_id == my_user_id;
switch (m->content->get_type()) {
case MessageContentType::ChatAddUsers:
send_closure_later(G()->contacts_manager(), &ContactsManager::speculative_add_channel_participants, channel_id,
send_closure_later(G()->chat_manager(), &ChatManager::speculative_add_channel_participants, channel_id,
get_message_content_added_user_ids(m->content.get()), m->sender_user_id, m->date, by_me);
break;
case MessageContentType::ChatJoinedByLink:
send_closure_later(G()->contacts_manager(), &ContactsManager::speculative_add_channel_participants, channel_id,
send_closure_later(G()->chat_manager(), &ChatManager::speculative_add_channel_participants, channel_id,
vector<UserId>{m->sender_user_id}, m->sender_user_id, m->date, by_me);
break;
case MessageContentType::ChatDeleteUser:
send_closure_later(G()->contacts_manager(), &ContactsManager::speculative_delete_channel_participant, channel_id,
send_closure_later(G()->chat_manager(), &ChatManager::speculative_delete_channel_participant, channel_id,
get_message_content_deleted_user_id(m->content.get()), by_me);
break;
default:
@ -36953,7 +36949,7 @@ void MessagesManager::update_top_dialogs(DialogId dialog_id, const Message *m) {
category = TopDialogCategory::Group;
break;
case DialogType::Channel:
switch (td_->contacts_manager_->get_channel_type(dialog_id.get_channel_id())) {
switch (td_->chat_manager_->get_channel_type(dialog_id.get_channel_id())) {
case ChannelType::Broadcast:
category = TopDialogCategory::Channel;
break;
@ -38250,7 +38246,7 @@ void MessagesManager::on_get_sponsored_dialog(tl_object_ptr<telegram_api::Peer>
CHECK(peer != nullptr);
td_->user_manager_->on_get_users(std::move(users), "on_get_sponsored_dialog");
td_->contacts_manager_->on_get_chats(std::move(chats), "on_get_sponsored_dialog");
td_->chat_manager_->on_get_chats(std::move(chats), "on_get_sponsored_dialog");
set_sponsored_dialog(DialogId(peer), std::move(source));
}

View File

@ -10,7 +10,7 @@
#include "td/telegram/AudiosManager.h"
#include "td/telegram/AudiosManager.hpp"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
@ -273,7 +273,7 @@ class GetNotifySettingsExceptionsQuery final : public Td::ResultHandler {
}
}
td_->user_manager_->on_get_users(std::move(users), "GetNotifySettingsExceptionsQuery");
td_->contacts_manager_->on_get_chats(std::move(chats), "GetNotifySettingsExceptionsQuery");
td_->chat_manager_->on_get_chats(std::move(chats), "GetNotifySettingsExceptionsQuery");
for (auto &dialog_id : dialog_ids) {
td_->dialog_manager_->force_create_dialog(dialog_id, "GetNotifySettingsExceptionsQuery");
}
@ -328,7 +328,7 @@ class GetStoryNotifySettingsExceptionsQuery final : public Td::ResultHandler {
}
}
td_->user_manager_->on_get_users(std::move(users), "GetStoryNotifySettingsExceptionsQuery");
td_->contacts_manager_->on_get_chats(std::move(chats), "GetStoryNotifySettingsExceptionsQuery");
td_->chat_manager_->on_get_chats(std::move(chats), "GetStoryNotifySettingsExceptionsQuery");
for (auto &dialog_id : dialog_ids) {
td_->dialog_manager_->force_create_dialog(dialog_id, "GetStoryNotifySettingsExceptionsQuery");
}

View File

@ -10,8 +10,8 @@
#include "td/telegram/AnimationsManager.h"
#include "td/telegram/AttachMenuManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/CountryInfoManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/GitCommitHash.h"
@ -524,7 +524,7 @@ void OptionManager::on_option_updated(Slice name) {
break;
case 'i':
if (name == "ignored_restriction_reasons") {
send_closure(td_->contacts_manager_actor_, &ContactsManager::on_ignored_restriction_reasons_changed);
send_closure(td_->chat_manager_actor_, &ChatManager::on_ignored_restriction_reasons_changed);
send_closure(td_->user_manager_actor_, &UserManager::on_ignored_restriction_reasons_changed);
}
if (name == "is_emulator") {

View File

@ -7,7 +7,7 @@
#include "td/telegram/PeopleNearbyManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/OptionManager.h"
@ -167,7 +167,7 @@ void PeopleNearbyManager::on_get_dialogs_nearby(Result<telegram_api::object_ptr<
LOG(INFO) << "Receive chats nearby in " << to_string(update);
td_->user_manager_->on_get_users(std::move(update->users_), "on_get_dialogs_nearby");
td_->contacts_manager_->on_get_chats(std::move(update->chats_), "on_get_dialogs_nearby");
td_->chat_manager_->on_get_chats(std::move(update->chats_), "on_get_dialogs_nearby");
for (auto &dialog_nearby : users_nearby_) {
user_nearby_timeout_.cancel_timeout(dialog_nearby.dialog_id.get_user_id().get());
@ -374,7 +374,7 @@ int32 PeopleNearbyManager::on_update_peer_located(vector<telegram_api::object_pt
}
} else if (dialog_type == DialogType::Channel) {
auto channel_id = dialog_id.get_channel_id();
if (!td_->contacts_manager_->have_channel(channel_id)) {
if (!td_->chat_manager_->have_channel(channel_id)) {
LOG(ERROR) << "Can't find " << channel_id;
continue;
}

View File

@ -9,7 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ChainId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
@ -384,7 +384,7 @@ void PollManager::on_load_poll_from_database(PollId poll_id, string value) {
}
for (const auto &recent_voter_min_channel : poll->recent_voter_min_channels_) {
LOG(INFO) << "Add min voted " << recent_voter_min_channel.first;
td_->contacts_manager_->add_min_channel(recent_voter_min_channel.first, recent_voter_min_channel.second);
td_->chat_manager_->add_min_channel(recent_voter_min_channel.first, recent_voter_min_channel.second);
}
Dependencies dependencies;
for (auto dialog_id : poll->recent_voter_dialog_ids_) {
@ -1189,7 +1189,7 @@ void PollManager::on_get_poll_voters(PollId poll_id, int32 option_id, string off
auto vote_list = result.move_as_ok();
td_->user_manager_->on_get_users(std::move(vote_list->users_), "on_get_poll_voters");
td_->contacts_manager_->on_get_chats(std::move(vote_list->chats_), "on_get_poll_voters");
td_->chat_manager_->on_get_chats(std::move(vote_list->chats_), "on_get_poll_voters");
voters.next_offset_ = std::move(vote_list->next_offset_);
if (poll->options_[option_id].voter_count_ != vote_list->count_) {

View File

@ -10,7 +10,7 @@
#include "td/telegram/AnimationsManager.h"
#include "td/telegram/Application.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
@ -169,7 +169,7 @@ Result<telegram_api::object_ptr<telegram_api::InputPeer>> get_boost_input_peer(T
if (dialog_id.get_type() != DialogType::Channel) {
return Status::Error(400, "Can't boost the chat");
}
if (!td->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).is_administrator()) {
if (!td->chat_manager_->get_channel_status(dialog_id.get_channel_id()).is_administrator()) {
return Status::Error(400, "Not enough rights in the chat");
}
auto boost_input_peer = td->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
@ -393,7 +393,7 @@ class CheckGiftCodeQuery final : public Td::ResultHandler {
auto result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for CheckGiftCodeQuery: " << to_string(result);
td_->user_manager_->on_get_users(std::move(result->users_), "CheckGiftCodeQuery");
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "CheckGiftCodeQuery");
td_->chat_manager_->on_get_chats(std::move(result->chats_), "CheckGiftCodeQuery");
if (result->date_ <= 0 || result->months_ <= 0 || result->used_date_ < 0) {
LOG(ERROR) << "Receive " << to_string(result);
@ -533,8 +533,7 @@ class GetGiveawayInfoQuery final : public Td::ResultHandler {
}
if (info->admin_disallowed_chat_id_ > 0) {
ChannelId channel_id(info->admin_disallowed_chat_id_);
if (!channel_id.is_valid() ||
!td_->contacts_manager_->have_channel_force(channel_id, "GetGiveawayInfoQuery")) {
if (!channel_id.is_valid() || !td_->chat_manager_->have_channel_force(channel_id, "GetGiveawayInfoQuery")) {
LOG(ERROR) << "Receive " << to_string(info);
} else {
DialogId dialog_id(channel_id);

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/FileReferenceManager.h"
@ -729,7 +729,7 @@ void QuickReplyManager::on_reload_quick_reply_shortcuts(
case telegram_api::messages_quickReplies::ID: {
auto shortcuts = telegram_api::move_object_as<telegram_api::messages_quickReplies>(shortcuts_ptr);
td_->user_manager_->on_get_users(std::move(shortcuts->users_), "messages.quickReplies");
td_->contacts_manager_->on_get_chats(std::move(shortcuts->chats_), "messages.quickReplies");
td_->chat_manager_->on_get_chats(std::move(shortcuts->chats_), "messages.quickReplies");
FlatHashMap<MessageId, telegram_api::object_ptr<telegram_api::Message>, MessageIdHash> message_id_to_message;
for (auto &message : shortcuts->messages_) {
@ -1241,7 +1241,7 @@ void QuickReplyManager::on_reload_quick_reply_messages(
case telegram_api::messages_messages::ID: {
auto messages = telegram_api::move_object_as<telegram_api::messages_messages>(messages_ptr);
td_->user_manager_->on_get_users(std::move(messages->users_), "on_reload_quick_reply_messages");
td_->contacts_manager_->on_get_chats(std::move(messages->chats_), "on_reload_quick_reply_messages");
td_->chat_manager_->on_get_chats(std::move(messages->chats_), "on_reload_quick_reply_messages");
vector<unique_ptr<QuickReplyMessage>> quick_reply_messages;
for (auto &server_message : messages->messages_) {
@ -1368,7 +1368,7 @@ void QuickReplyManager::on_reload_quick_reply_message(
case telegram_api::messages_messages::ID: {
auto messages = telegram_api::move_object_as<telegram_api::messages_messages>(messages_ptr);
td_->user_manager_->on_get_users(std::move(messages->users_), "on_reload_quick_reply_message");
td_->contacts_manager_->on_get_chats(std::move(messages->chats_), "on_reload_quick_reply_message");
td_->chat_manager_->on_get_chats(std::move(messages->chats_), "on_reload_quick_reply_message");
if (messages->messages_.size() > 1u) {
LOG(ERROR) << "Receive " << to_string(messages_ptr);

View File

@ -7,7 +7,7 @@
#include "td/telegram/RecentDialogList.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogListId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/FolderId.h"
@ -57,7 +57,7 @@ void RecentDialogList::save_dialogs() const {
case DialogType::Chat:
break;
case DialogType::Channel:
username = td_->contacts_manager_->get_channel_first_username(dialog_id.get_channel_id());
username = td_->chat_manager_->get_channel_first_username(dialog_id.get_channel_id());
break;
case DialogType::SecretChat:
break;
@ -207,7 +207,7 @@ void RecentDialogList::update_dialogs() {
// always keep
break;
case DialogType::Chat: {
auto channel_id = td_->contacts_manager_->get_chat_migrated_to_channel_id(dialog_id.get_chat_id());
auto channel_id = td_->chat_manager_->get_chat_migrated_to_channel_id(dialog_id.get_chat_id());
if (channel_id.is_valid() && td_->messages_manager_->have_dialog(DialogId(channel_id))) {
dialog_id = DialogId(channel_id);
}

View File

@ -7,7 +7,7 @@
#include "td/telegram/RequestedDialogType.h"
#include "td/telegram/ChannelType.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/UserManager.h"
@ -227,10 +227,10 @@ Status RequestedDialogType::check_shared_dialog(Td *td, DialogId dialog_id) cons
return Status::Error(400, "Wrong has_username value");
}
auto chat_id = dialog_id.get_chat_id();
if (!td->contacts_manager_->get_chat_is_active(chat_id)) {
if (!td->chat_manager_->get_chat_is_active(chat_id)) {
return Status::Error(400, "Chat is deactivated");
}
auto status = td->contacts_manager_->get_chat_status(chat_id);
auto status = td->chat_manager_->get_chat_status(chat_id);
if (is_created_ && !status.is_creator()) {
return Status::Error(400, "The chat must be created by the current user");
}
@ -253,23 +253,23 @@ Status RequestedDialogType::check_shared_dialog(Td *td, DialogId dialog_id) cons
}
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
bool is_broadcast = td->contacts_manager_->is_broadcast_channel(channel_id);
bool is_broadcast = td->chat_manager_->is_broadcast_channel(channel_id);
if (type_ != (is_broadcast ? Type::Channel : Type::Group)) {
return Status::Error(400, "Wrong chat type");
}
if (!is_broadcast && restrict_is_forum_ && td->contacts_manager_->is_forum_channel(channel_id) != is_forum_) {
if (!is_broadcast && restrict_is_forum_ && td->chat_manager_->is_forum_channel(channel_id) != is_forum_) {
return Status::Error(400, "Wrong is_forum value");
}
if (restrict_has_username_ &&
td->contacts_manager_->get_channel_first_username(channel_id).empty() == has_username_) {
td->chat_manager_->get_channel_first_username(channel_id).empty() == has_username_) {
return Status::Error(400, "Wrong has_username value");
}
auto status = td->contacts_manager_->get_channel_status(channel_id);
auto status = td->chat_manager_->get_channel_status(channel_id);
if (is_created_ && !status.is_creator()) {
return Status::Error(400, "The chat must be created by the current user");
}
bool can_invite_bot = status.can_invite_users() &&
(status.is_administrator() || !td->contacts_manager_->is_channel_public(channel_id));
bool can_invite_bot =
status.can_invite_users() && (status.is_administrator() || !td->chat_manager_->is_channel_public(channel_id));
if (!is_broadcast && bot_is_participant_) {
// can't synchronously check that the bot is already participant
if (!can_invite_bot) {

View File

@ -8,7 +8,7 @@
#include "td/telegram/AffectedHistory.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -586,7 +586,7 @@ void SavedMessagesManager::on_get_saved_messages_topics(
UNREACHABLE();
}
td_->user_manager_->on_get_users(std::move(users), "on_get_saved_messages_topics");
td_->contacts_manager_->on_get_chats(std::move(chats), "on_get_saved_messages_topics");
td_->chat_manager_->on_get_chats(std::move(chats), "on_get_saved_messages_topics");
FlatHashMap<MessageId, telegram_api::object_ptr<telegram_api::Message>, MessageIdHash> message_id_to_message;
for (auto &message : messages) {

View File

@ -71,7 +71,7 @@ class SecretChatActor final : public NetQueryCallback {
virtual bool close_flag() = 0;
// We don't want to expose the whole NetQueryDispatcher, MessagesManager and ContactsManager.
// We don't want to expose the whole NetQueryDispatcher, MessagesManager and UserManager.
// So it is more clear which parts of MessagesManager are really used. And it is much easier to create tests.
virtual void send_net_query(NetQueryPtr query, ActorShared<NetQueryCallback> callback, bool ordered) = 0;

View File

@ -7,7 +7,7 @@
#include "td/telegram/SponsoredMessageManager.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogInviteLinkManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -45,7 +45,7 @@ class GetSponsoredMessagesQuery final : public Td::ResultHandler {
void send(ChannelId channel_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Chat info not found"));
}
@ -64,7 +64,7 @@ class GetSponsoredMessagesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetSponsoredMessagesQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetSponsoredMessagesQuery");
promise_.set_error(std::move(status));
}
};
@ -75,7 +75,7 @@ class ViewSponsoredMessageQuery final : public Td::ResultHandler {
public:
void send(ChannelId channel_id, const string &message_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return;
}
@ -91,7 +91,7 @@ class ViewSponsoredMessageQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ViewSponsoredMessageQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "ViewSponsoredMessageQuery");
}
};
@ -105,7 +105,7 @@ class ClickSponsoredMessageQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, const string &message_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_value(Unit());
}
@ -122,7 +122,7 @@ class ClickSponsoredMessageQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ClickSponsoredMessageQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "ClickSponsoredMessageQuery");
promise_.set_error(std::move(status));
}
};
@ -138,7 +138,7 @@ class ReportSponsoredMessageQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, const string &message_id, const string &option_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_value(td_api::make_object<td_api::reportChatSponsoredMessageResultFailed>());
}
@ -185,7 +185,7 @@ class ReportSponsoredMessageQuery final : public Td::ResultHandler {
if (status.message() == "PREMIUM_ACCOUNT_REQUIRED") {
return promise_.set_value(td_api::make_object<td_api::reportChatSponsoredMessageResultPremiumRequired>());
}
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ReportSponsoredMessageQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "ReportSponsoredMessageQuery");
promise_.set_error(std::move(status));
}
};
@ -310,7 +310,7 @@ td_api::object_ptr<td_api::messageSponsor> SponsoredMessageManager::get_message_
}
case DialogType::Channel: {
auto channel_id = sponsored_message.sponsor_dialog_id.get_channel_id();
if (!td_->contacts_manager_->is_broadcast_channel(channel_id)) {
if (!td_->chat_manager_->is_broadcast_channel(channel_id)) {
LOG(ERROR) << "Sponsor " << channel_id << " is not a channel";
return nullptr;
}
@ -325,7 +325,7 @@ td_api::object_ptr<td_api::messageSponsor> SponsoredMessageManager::get_message_
std::move(link));
if (sponsored_message.show_dialog_photo) {
photo = get_chat_photo_info_object(td_->file_manager_.get(),
td_->contacts_manager_->get_channel_dialog_photo(channel_id));
td_->chat_manager_->get_channel_dialog_photo(channel_id));
}
break;
}
@ -444,7 +444,7 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages(
telegram_api::move_object_as<telegram_api::messages_sponsoredMessages>(sponsored_messages_ptr);
td_->user_manager_->on_get_users(std::move(sponsored_messages->users_), "on_get_dialog_sponsored_messages");
td_->contacts_manager_->on_get_chats(std::move(sponsored_messages->chats_), "on_get_dialog_sponsored_messages");
td_->chat_manager_->on_get_chats(std::move(sponsored_messages->chats_), "on_get_dialog_sponsored_messages");
for (auto &sponsored_message : sponsored_messages->messages_) {
DialogId sponsor_dialog_id;

View File

@ -7,7 +7,7 @@
#include "td/telegram/StatisticsManager.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageId.h"
@ -185,7 +185,7 @@ class GetMegagroupStatsQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, bool is_dark, DcId dc_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = 0;
@ -206,7 +206,7 @@ class GetMegagroupStatsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetMegagroupStatsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetMegagroupStatsQuery");
promise_.set_error(std::move(status));
}
};
@ -223,7 +223,7 @@ class GetBroadcastStatsQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, bool is_dark, DcId dc_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = 0;
@ -260,7 +260,7 @@ class GetBroadcastStatsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetBroadcastStatsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetBroadcastStatsQuery");
promise_.set_error(std::move(status));
}
};
@ -284,7 +284,7 @@ class GetMessageStatsQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, MessageId message_id, bool is_dark, DcId dc_id) {
channel_id_ = channel_id;
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
auto input_channel = td_->chat_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Supergroup not found"));
}
@ -309,7 +309,7 @@ class GetMessageStatsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetMessageStatsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetMessageStatsQuery");
promise_.set_error(std::move(status));
}
};
@ -355,7 +355,7 @@ class GetStoryStatsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetStoryStatsQuery");
td_->chat_manager_->on_get_channel_error(channel_id_, status, "GetStoryStatsQuery");
promise_.set_error(std::move(status));
}
};
@ -403,7 +403,7 @@ class GetMessagePublicForwardsQuery final : public Td::ResultHandler {
void send(DcId dc_id, MessageFullId message_full_id, const string &offset, int32 limit) {
dialog_id_ = message_full_id.get_dialog_id();
auto input_channel = td_->contacts_manager_->get_input_channel(dialog_id_.get_channel_id());
auto input_channel = td_->chat_manager_->get_input_channel(dialog_id_.get_channel_id());
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
@ -484,14 +484,14 @@ void StatisticsManager::get_channel_statistics(DialogId dialog_id, bool is_dark,
send_closure(actor_id, &StatisticsManager::send_get_channel_stats_query, r_dc_id.move_as_ok(),
dialog_id.get_channel_id(), is_dark, std::move(promise));
});
td_->contacts_manager_->get_channel_statistics_dc_id(dialog_id, true, std::move(dc_id_promise));
td_->chat_manager_->get_channel_statistics_dc_id(dialog_id, true, std::move(dc_id_promise));
}
void StatisticsManager::send_get_channel_stats_query(DcId dc_id, ChannelId channel_id, bool is_dark,
Promise<td_api::object_ptr<td_api::ChatStatistics>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
if (td_->contacts_manager_->is_megagroup_channel(channel_id)) {
if (td_->chat_manager_->is_megagroup_channel(channel_id)) {
td_->create_handler<GetMegagroupStatsQuery>(std::move(promise))->send(channel_id, is_dark, dc_id);
} else {
td_->create_handler<GetBroadcastStatsQuery>(std::move(promise))->send(channel_id, is_dark, dc_id);
@ -508,8 +508,7 @@ void StatisticsManager::get_channel_message_statistics(
send_closure(actor_id, &StatisticsManager::send_get_channel_message_stats_query, r_dc_id.move_as_ok(),
message_full_id, is_dark, std::move(promise));
});
td_->contacts_manager_->get_channel_statistics_dc_id(message_full_id.get_dialog_id(), false,
std::move(dc_id_promise));
td_->chat_manager_->get_channel_statistics_dc_id(message_full_id.get_dialog_id(), false, std::move(dc_id_promise));
}
void StatisticsManager::send_get_channel_message_stats_query(
@ -539,7 +538,7 @@ void StatisticsManager::get_channel_story_statistics(StoryFullId story_full_id,
send_closure(actor_id, &StatisticsManager::send_get_channel_story_stats_query, r_dc_id.move_as_ok(),
story_full_id, is_dark, std::move(promise));
});
td_->contacts_manager_->get_channel_statistics_dc_id(story_full_id.get_dialog_id(), false, std::move(dc_id_promise));
td_->chat_manager_->get_channel_statistics_dc_id(story_full_id.get_dialog_id(), false, std::move(dc_id_promise));
}
void StatisticsManager::send_get_channel_story_stats_query(
@ -569,7 +568,7 @@ void StatisticsManager::load_statistics_graph(DialogId dialog_id, string token,
send_closure(actor_id, &StatisticsManager::send_load_async_graph_query, r_dc_id.move_as_ok(), std::move(token), x,
std::move(promise));
});
td_->contacts_manager_->get_channel_statistics_dc_id(dialog_id, false, std::move(dc_id_promise));
td_->chat_manager_->get_channel_statistics_dc_id(dialog_id, false, std::move(dc_id_promise));
}
void StatisticsManager::send_load_async_graph_query(DcId dc_id, string token, int64 x,
@ -593,8 +592,7 @@ void StatisticsManager::get_message_public_forwards(MessageFullId message_full_i
send_closure(actor_id, &StatisticsManager::send_get_message_public_forwards_query, r_dc_id.move_as_ok(),
message_full_id, std::move(offset), limit, std::move(promise));
});
td_->contacts_manager_->get_channel_statistics_dc_id(message_full_id.get_dialog_id(), false,
std::move(dc_id_promise));
td_->chat_manager_->get_channel_statistics_dc_id(message_full_id.get_dialog_id(), false, std::move(dc_id_promise));
}
void StatisticsManager::send_get_message_public_forwards_query(
@ -637,7 +635,7 @@ void StatisticsManager::get_story_public_forwards(StoryFullId story_full_id, str
send_closure(actor_id, &StatisticsManager::send_get_story_public_forwards_query, r_dc_id.move_as_ok(),
story_full_id, std::move(offset), limit, std::move(promise));
});
td_->contacts_manager_->get_channel_statistics_dc_id(dialog_id, false, std::move(dc_id_promise));
td_->chat_manager_->get_channel_statistics_dc_id(dialog_id, false, std::move(dc_id_promise));
}
void StatisticsManager::send_get_story_public_forwards_query(
@ -715,7 +713,7 @@ void StatisticsManager::get_channel_differences_if_needed(
telegram_api::object_ptr<telegram_api::stats_publicForwards> &&public_forwards,
Promise<td_api::object_ptr<td_api::publicForwards>> promise, const char *source) {
td_->user_manager_->on_get_users(std::move(public_forwards->users_), "stats_publicForwards");
td_->contacts_manager_->on_get_chats(std::move(public_forwards->chats_), "stats_publicForwards");
td_->chat_manager_->on_get_chats(std::move(public_forwards->chats_), "stats_publicForwards");
vector<const telegram_api::object_ptr<telegram_api::Message> *> messages;
for (const auto &forward : public_forwards->forwards_) {

View File

@ -8,8 +8,8 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/FileReferenceManager.h"
@ -1645,7 +1645,7 @@ bool StoryManager::can_post_stories(DialogId owner_dialog_id) const {
case DialogType::User:
return is_my_story(owner_dialog_id);
case DialogType::Channel:
return td_->contacts_manager_->get_channel_status(owner_dialog_id.get_channel_id()).can_post_stories();
return td_->chat_manager_->get_channel_status(owner_dialog_id.get_channel_id()).can_post_stories();
case DialogType::Chat:
case DialogType::SecretChat:
case DialogType::None:
@ -1659,7 +1659,7 @@ bool StoryManager::can_edit_stories(DialogId owner_dialog_id) const {
case DialogType::User:
return is_my_story(owner_dialog_id);
case DialogType::Channel:
return td_->contacts_manager_->get_channel_status(owner_dialog_id.get_channel_id()).can_edit_stories();
return td_->chat_manager_->get_channel_status(owner_dialog_id.get_channel_id()).can_edit_stories();
case DialogType::Chat:
case DialogType::SecretChat:
case DialogType::None:
@ -1673,7 +1673,7 @@ bool StoryManager::can_delete_stories(DialogId owner_dialog_id) const {
case DialogType::User:
return is_my_story(owner_dialog_id);
case DialogType::Channel:
return td_->contacts_manager_->get_channel_status(owner_dialog_id.get_channel_id()).can_delete_stories();
return td_->chat_manager_->get_channel_status(owner_dialog_id.get_channel_id()).can_delete_stories();
case DialogType::Chat:
case DialogType::SecretChat:
case DialogType::None:
@ -1846,7 +1846,7 @@ bool StoryManager::can_get_story_statistics(StoryFullId story_full_id, const Sto
}
auto dialog_id = story_full_id.get_dialog_id();
return dialog_id.get_type() == DialogType::Channel &&
td_->contacts_manager_->can_get_channel_story_statistics(dialog_id.get_channel_id());
td_->chat_manager_->can_get_channel_story_statistics(dialog_id.get_channel_id());
}
const StoryManager::ActiveStories *StoryManager::get_active_stories(DialogId owner_dialog_id) const {
@ -2102,7 +2102,7 @@ void StoryManager::on_load_active_stories_from_server(
case telegram_api::stories_allStories::ID: {
auto stories = telegram_api::move_object_as<telegram_api::stories_allStories>(all_stories);
td_->user_manager_->on_get_users(std::move(stories->users_), "on_load_active_stories_from_server");
td_->contacts_manager_->on_get_chats(std::move(stories->chats_), "on_load_active_stories_from_server");
td_->chat_manager_->on_get_chats(std::move(stories->chats_), "on_load_active_stories_from_server");
if (stories->state_.empty()) {
LOG(ERROR) << "Receive empty state in " << to_string(stories);
} else {
@ -2503,7 +2503,7 @@ void StoryManager::on_get_dialog_expiring_stories(DialogId owner_dialog_id,
Promise<td_api::object_ptr<td_api::chatActiveStories>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
td_->user_manager_->on_get_users(std::move(stories->users_), "on_get_dialog_expiring_stories");
td_->contacts_manager_->on_get_chats(std::move(stories->chats_), "on_get_dialog_expiring_stories");
td_->chat_manager_->on_get_chats(std::move(stories->chats_), "on_get_dialog_expiring_stories");
owner_dialog_id = on_get_dialog_stories(owner_dialog_id, std::move(stories->stories_), Promise<Unit>());
if (promise) {
CHECK(owner_dialog_id.is_valid());
@ -2895,7 +2895,7 @@ void StoryManager::get_channel_differences_if_needed(
telegram_api::object_ptr<telegram_api::stories_storyViewsList> &&story_views,
Promise<telegram_api::object_ptr<telegram_api::stories_storyViewsList>> promise) {
td_->user_manager_->on_get_users(std::move(story_views->users_), "stories_storyViewsList");
td_->contacts_manager_->on_get_chats(std::move(story_views->chats_), "stories_storyViewsList");
td_->chat_manager_->on_get_chats(std::move(story_views->chats_), "stories_storyViewsList");
vector<const telegram_api::object_ptr<telegram_api::Message> *> messages;
for (const auto &view : story_views->views_) {
@ -3002,7 +3002,7 @@ void StoryManager::get_channel_differences_if_needed(
telegram_api::object_ptr<telegram_api::stories_storyReactionsList> &&story_reactions,
Promise<telegram_api::object_ptr<telegram_api::stories_storyReactionsList>> promise) {
td_->user_manager_->on_get_users(std::move(story_reactions->users_), "stories_storyReactionsList");
td_->contacts_manager_->on_get_chats(std::move(story_reactions->chats_), "stories_storyReactionsList");
td_->chat_manager_->on_get_chats(std::move(story_reactions->chats_), "stories_storyReactionsList");
vector<const telegram_api::object_ptr<telegram_api::Message> *> messages;
for (const auto &reaction : story_reactions->reactions_) {
@ -3797,7 +3797,7 @@ std::pair<int32, vector<StoryId>> StoryManager::on_get_stories(
DialogId owner_dialog_id, vector<StoryId> &&expected_story_ids,
telegram_api::object_ptr<telegram_api::stories_stories> &&stories) {
td_->user_manager_->on_get_users(std::move(stories->users_), "on_get_stories");
td_->contacts_manager_->on_get_chats(std::move(stories->chats_), "on_get_stories");
td_->chat_manager_->on_get_chats(std::move(stories->chats_), "on_get_stories");
vector<StoryId> story_ids;
for (auto &story : stories->stories_) {
@ -3909,7 +3909,7 @@ void StoryManager::on_update_dialog_max_story_ids(DialogId owner_dialog_id, Stor
break;
case DialogType::Channel:
// use send_closure_later because story order can be updated from update_channel
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::on_update_channel_story_ids,
send_closure_later(td_->chat_manager_actor_, &ChatManager::on_update_channel_story_ids,
owner_dialog_id.get_channel_id(), max_story_id, max_read_story_id);
break;
case DialogType::Chat:
@ -3926,7 +3926,7 @@ void StoryManager::on_update_dialog_max_read_story_id(DialogId owner_dialog_id,
td_->user_manager_->on_update_user_max_read_story_id(owner_dialog_id.get_user_id(), max_read_story_id);
break;
case DialogType::Channel:
td_->contacts_manager_->on_update_channel_max_read_story_id(owner_dialog_id.get_channel_id(), max_read_story_id);
td_->chat_manager_->on_update_channel_max_read_story_id(owner_dialog_id.get_channel_id(), max_read_story_id);
break;
case DialogType::Chat:
case DialogType::SecretChat:
@ -3942,8 +3942,7 @@ void StoryManager::on_update_dialog_has_pinned_stories(DialogId owner_dialog_id,
td_->user_manager_->on_update_user_has_pinned_stories(owner_dialog_id.get_user_id(), has_pinned_stories);
break;
case DialogType::Channel:
td_->contacts_manager_->on_update_channel_has_pinned_stories(owner_dialog_id.get_channel_id(),
has_pinned_stories);
td_->chat_manager_->on_update_channel_has_pinned_stories(owner_dialog_id.get_channel_id(), has_pinned_stories);
break;
case DialogType::Chat:
case DialogType::SecretChat:
@ -3959,7 +3958,7 @@ void StoryManager::on_update_dialog_stories_hidden(DialogId owner_dialog_id, boo
td_->user_manager_->on_update_user_stories_hidden(owner_dialog_id.get_user_id(), stories_hidden);
break;
case DialogType::Channel:
td_->contacts_manager_->on_update_channel_stories_hidden(owner_dialog_id.get_channel_id(), stories_hidden);
td_->chat_manager_->on_update_channel_stories_hidden(owner_dialog_id.get_channel_id(), stories_hidden);
break;
case DialogType::Chat:
case DialogType::SecretChat:
@ -4384,7 +4383,7 @@ bool StoryManager::is_subscribed_to_dialog_stories(DialogId owner_dialog_id) con
}
return td_->user_manager_->is_user_contact(owner_dialog_id.get_user_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_status(owner_dialog_id.get_channel_id()).is_member();
return td_->chat_manager_->get_channel_status(owner_dialog_id.get_channel_id()).is_member();
case DialogType::Chat:
case DialogType::SecretChat:
case DialogType::None:
@ -4404,7 +4403,7 @@ StoryListId StoryManager::get_dialog_story_list_id(DialogId owner_dialog_id) con
}
return StoryListId::main();
case DialogType::Channel:
if (td_->contacts_manager_->get_channel_stories_hidden(owner_dialog_id.get_channel_id())) {
if (td_->chat_manager_->get_channel_stories_hidden(owner_dialog_id.get_channel_id())) {
return StoryListId::archive();
}
return StoryListId::main();
@ -4485,7 +4484,7 @@ void StoryManager::on_view_dialog_active_stories(vector<DialogId> dialog_ids) {
case DialogType::User:
return td_->user_manager_->can_poll_user_active_stories(dialog_id.get_user_id());
case DialogType::Channel:
return td_->contacts_manager_->can_poll_channel_active_stories(dialog_id.get_channel_id());
return td_->chat_manager_->can_poll_channel_active_stories(dialog_id.get_channel_id());
case DialogType::Chat:
case DialogType::SecretChat:
case DialogType::None:
@ -4532,7 +4531,7 @@ void StoryManager::on_get_dialog_max_active_story_ids(const vector<DialogId> &di
if (dialog_id.get_type() == DialogType::User) {
td_->user_manager_->on_update_user_story_ids(dialog_id.get_user_id(), max_story_id, StoryId());
} else {
td_->contacts_manager_->on_update_channel_story_ids(dialog_id.get_channel_id(), max_story_id, StoryId());
td_->chat_manager_->on_update_channel_story_ids(dialog_id.get_channel_id(), max_story_id, StoryId());
}
} else {
LOG(ERROR) << "Receive " << max_story_id << " as maximum active story for " << dialog_id;
@ -4702,7 +4701,7 @@ void StoryManager::get_dialogs_to_send_stories(Promise<td_api::object_ptr<td_api
G()->td_db()->get_binlog_pmc()->erase(pmc_key);
} else {
for (auto channel_id : channel_ids) {
if (td_->contacts_manager_->get_channel_status(channel_id).can_post_stories()) {
if (td_->chat_manager_->get_channel_status(channel_id).can_post_stories()) {
channels_to_send_stories_.push_back(channel_id);
}
}
@ -4767,14 +4766,14 @@ void StoryManager::update_dialogs_to_send_stories(ChannelId channel_id, bool can
}
void StoryManager::on_get_dialogs_to_send_stories(vector<tl_object_ptr<telegram_api::Chat>> &&chats) {
auto channel_ids = td_->contacts_manager_->get_channel_ids(std::move(chats), "on_get_dialogs_to_send_stories");
auto channel_ids = td_->chat_manager_->get_channel_ids(std::move(chats), "on_get_dialogs_to_send_stories");
if (channels_to_send_stories_inited_ && channels_to_send_stories_ == channel_ids) {
return;
}
channels_to_send_stories_.clear();
for (auto channel_id : channel_ids) {
td_->dialog_manager_->force_create_dialog(DialogId(channel_id), "on_get_dialogs_to_send_stories");
if (td_->contacts_manager_->get_channel_status(channel_id).can_post_stories()) {
if (td_->chat_manager_->get_channel_status(channel_id).can_post_stories()) {
channels_to_send_stories_.push_back(channel_id);
}
}
@ -4869,7 +4868,7 @@ void StoryManager::send_story(DialogId dialog_id, td_api::object_ptr<td_api::Inp
auto story = make_unique<Story>();
if (dialog_id.get_type() == DialogType::Channel &&
td_->contacts_manager_->is_megagroup_channel(dialog_id.get_channel_id())) {
td_->chat_manager_->is_megagroup_channel(dialog_id.get_channel_id())) {
story->sender_dialog_id_ = td_->messages_manager_->get_dialog_default_send_message_as_dialog_id(dialog_id);
if (story->sender_dialog_id_ == DialogId() &&
!td_->dialog_manager_->is_anonymous_administrator(dialog_id, nullptr)) {

View File

@ -37,9 +37,9 @@
#include "td/telegram/ChannelRecommendationManager.h"
#include "td/telegram/ChannelType.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/CommonDialogManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/CountryInfoManager.h"
#include "td/telegram/CustomEmojiId.h"
#include "td/telegram/DeviceTokenManager.h"
@ -268,7 +268,7 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
auto urls_full = result_ptr.move_as_ok();
td_->user_manager_->on_get_users(std::move(urls_full->users_), "GetRecentMeUrlsQuery");
td_->contacts_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery");
td_->chat_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery");
auto urls = std::move(urls_full->urls_);
auto results = make_tl_object<td_api::tMeUrls>();
@ -300,7 +300,7 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
break;
}
result->type_ = make_tl_object<td_api::tMeUrlTypeSupergroup>(
td_->contacts_manager_->get_supergroup_id_object(channel_id, "tMeUrlTypeSupergroup"));
td_->chat_manager_->get_supergroup_id_object(channel_id, "tMeUrlTypeSupergroup"));
break;
}
case telegram_api::recentMeUrlChatInvite::ID: {
@ -652,11 +652,11 @@ class GetGroupRequest final : public RequestActor<> {
ChatId chat_id_;
void do_run(Promise<Unit> &&promise) final {
td_->contacts_manager_->get_chat(chat_id_, get_tries(), std::move(promise));
td_->chat_manager_->get_chat(chat_id_, get_tries(), std::move(promise));
}
void do_send_result() final {
send_result(td_->contacts_manager_->get_basic_group_object(chat_id_));
send_result(td_->chat_manager_->get_basic_group_object(chat_id_));
}
public:
@ -670,11 +670,11 @@ class GetGroupFullInfoRequest final : public RequestActor<> {
ChatId chat_id_;
void do_run(Promise<Unit> &&promise) final {
td_->contacts_manager_->load_chat_full(chat_id_, get_tries() < 2, std::move(promise), "getBasicGroupFullInfo");
td_->chat_manager_->load_chat_full(chat_id_, get_tries() < 2, std::move(promise), "getBasicGroupFullInfo");
}
void do_send_result() final {
send_result(td_->contacts_manager_->get_basic_group_full_info_object(chat_id_));
send_result(td_->chat_manager_->get_basic_group_full_info_object(chat_id_));
}
public:
@ -687,11 +687,11 @@ class GetSupergroupRequest final : public RequestActor<> {
ChannelId channel_id_;
void do_run(Promise<Unit> &&promise) final {
td_->contacts_manager_->get_channel(channel_id_, get_tries(), std::move(promise));
td_->chat_manager_->get_channel(channel_id_, get_tries(), std::move(promise));
}
void do_send_result() final {
send_result(td_->contacts_manager_->get_supergroup_object(channel_id_));
send_result(td_->chat_manager_->get_supergroup_object(channel_id_));
}
public:
@ -705,12 +705,12 @@ class GetSupergroupFullInfoRequest final : public RequestActor<> {
ChannelId channel_id_;
void do_run(Promise<Unit> &&promise) final {
td_->contacts_manager_->load_channel_full(channel_id_, get_tries() < 2, std::move(promise),
"GetSupergroupFullInfoRequest");
td_->chat_manager_->load_channel_full(channel_id_, get_tries() < 2, std::move(promise),
"GetSupergroupFullInfoRequest");
}
void do_send_result() final {
send_result(td_->contacts_manager_->get_supergroup_full_info_object(channel_id_));
send_result(td_->chat_manager_->get_supergroup_full_info_object(channel_id_));
}
public:
@ -905,7 +905,7 @@ class GetSuitableDiscussionChatsRequest final : public RequestActor<> {
vector<DialogId> dialog_ids_;
void do_run(Promise<Unit> &&promise) final {
dialog_ids_ = td_->contacts_manager_->get_dialogs_for_discussion(std::move(promise));
dialog_ids_ = td_->chat_manager_->get_dialogs_for_discussion(std::move(promise));
}
void do_send_result() final {
@ -921,7 +921,7 @@ class GetInactiveSupergroupChatsRequest final : public RequestActor<> {
vector<DialogId> dialog_ids_;
void do_run(Promise<Unit> &&promise) final {
dialog_ids_ = td_->contacts_manager_->get_inactive_channels(std::move(promise));
dialog_ids_ = td_->chat_manager_->get_inactive_channels(std::move(promise));
}
void do_send_result() final {
@ -3218,7 +3218,7 @@ void Td::dec_actor_refcnt() {
reset_manager(callback_queries_manager_, "CallbackQueriesManager");
reset_manager(channel_recommendation_manager_, "ChannelRecommendationManager");
reset_manager(common_dialog_manager_, "CommonDialogManager");
reset_manager(contacts_manager_, "ContactsManager");
reset_manager(chat_manager_, "ChatManager");
reset_manager(country_info_manager_, "CountryInfoManager");
reset_manager(dialog_action_manager_, "DialogActionManager");
reset_manager(dialog_filter_manager_, "DialogFilterManager");
@ -3395,7 +3395,7 @@ void Td::clear() {
reset_actor(ActorOwn<Actor>(std::move(business_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(channel_recommendation_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(common_dialog_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(contacts_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(chat_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(country_info_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(dialog_action_manager_actor_)));
reset_actor(ActorOwn<Actor>(std::move(dialog_filter_manager_actor_)));
@ -3679,12 +3679,12 @@ void Td::process_binlog_events(TdDb::OpenedDatabase &&events) {
}
for (auto &event : events.channel_events) {
contacts_manager_->on_binlog_channel_event(std::move(event));
chat_manager_->on_binlog_channel_event(std::move(event));
}
// chats may contain links to channels, so should be inited after
for (auto &event : events.chat_events) {
contacts_manager_->on_binlog_chat_event(std::move(event));
chat_manager_->on_binlog_chat_event(std::move(event));
}
for (auto &event : events.secret_chat_events) {
@ -3897,9 +3897,9 @@ void Td::init_managers() {
register_actor("ChannelRecommendationManager", channel_recommendation_manager_.get());
common_dialog_manager_ = make_unique<CommonDialogManager>(this, create_reference());
common_dialog_manager_actor_ = register_actor("CommonDialogManager", common_dialog_manager_.get());
contacts_manager_ = make_unique<ContactsManager>(this, create_reference());
contacts_manager_actor_ = register_actor("ContactsManager", contacts_manager_.get());
G()->set_contacts_manager(contacts_manager_actor_.get());
chat_manager_ = make_unique<ChatManager>(this, create_reference());
chat_manager_actor_ = register_actor("ChatManager", chat_manager_.get());
G()->set_chat_manager(chat_manager_actor_.get());
country_info_manager_ = make_unique<CountryInfoManager>(this, create_reference());
country_info_manager_actor_ = register_actor("CountryInfoManager", country_info_manager_.get());
dialog_action_manager_ = make_unique<DialogActionManager>(this, create_reference());
@ -4335,7 +4335,7 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) {
if (auth_manager_->is_authorized()) {
user_manager_->get_current_state(updates);
contacts_manager_->get_current_state(updates);
chat_manager_->get_current_state(updates);
background_manager_->get_current_state(updates);
@ -5223,13 +5223,13 @@ void Td::on_request(uint64 id, td_api::checkChatUsername &request) {
void Td::on_request(uint64 id, const td_api::getCreatedPublicChats &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
contacts_manager_->get_created_public_dialogs(get_public_dialog_type(request.type_), std::move(promise), false);
chat_manager_->get_created_public_dialogs(get_public_dialog_type(request.type_), std::move(promise), false);
}
void Td::on_request(uint64 id, const td_api::checkCreatedPublicChatsLimit &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->check_created_public_dialogs_limit(get_public_dialog_type(request.type_), std::move(promise));
chat_manager_->check_created_public_dialogs_limit(get_public_dialog_type(request.type_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getSuitableDiscussionChats &request) {
@ -5245,7 +5245,7 @@ void Td::on_request(uint64 id, const td_api::getInactiveSupergroupChats &request
void Td::on_request(uint64 id, const td_api::getSuitablePersonalChats &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
contacts_manager_->get_created_public_dialogs(PublicDialogType::ForPersonalDialog, std::move(promise), false);
chat_manager_->get_created_public_dialogs(PublicDialogType::ForPersonalDialog, std::move(promise), false);
}
void Td::on_request(uint64 id, td_api::searchRecentlyFoundChats &request) {
@ -6128,8 +6128,8 @@ void Td::on_request(uint64 id, td_api::createNewBasicGroupChat &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.title_);
CREATE_REQUEST_PROMISE();
contacts_manager_->create_new_chat(UserId::get_user_ids(request.user_ids_), std::move(request.title_),
MessageTtl(request.message_auto_delete_time_), std::move(promise));
chat_manager_->create_new_chat(UserId::get_user_ids(request.user_ids_), std::move(request.title_),
MessageTtl(request.message_auto_delete_time_), std::move(promise));
}
void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) {
@ -6137,10 +6137,10 @@ void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) {
CLEAN_INPUT_STRING(request.title_);
CLEAN_INPUT_STRING(request.description_);
CREATE_REQUEST_PROMISE();
contacts_manager_->create_new_channel(std::move(request.title_), request.is_forum_, !request.is_channel_,
std::move(request.description_), DialogLocation(std::move(request.location_)),
request.for_import_, MessageTtl(request.message_auto_delete_time_),
std::move(promise));
chat_manager_->create_new_channel(std::move(request.title_), request.is_forum_, !request.is_channel_,
std::move(request.description_), DialogLocation(std::move(request.location_)),
request.for_import_, MessageTtl(request.message_auto_delete_time_),
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::createNewSecretChat &request) {
@ -7006,8 +7006,8 @@ void Td::on_request(uint64 id, td_api::setChatDescription &request) {
void Td::on_request(uint64 id, const td_api::setChatDiscussionGroup &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->set_channel_discussion_group(DialogId(request.chat_id_), DialogId(request.discussion_chat_id_),
std::move(promise));
chat_manager_->set_channel_discussion_group(DialogId(request.chat_id_), DialogId(request.discussion_chat_id_),
std::move(promise));
}
void Td::on_request(uint64 id, td_api::setChatLocation &request) {
@ -7020,8 +7020,7 @@ void Td::on_request(uint64 id, td_api::setChatLocation &request) {
void Td::on_request(uint64 id, const td_api::setChatSlowModeDelay &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->set_channel_slow_mode_delay(DialogId(request.chat_id_), request.slow_mode_delay_,
std::move(promise));
chat_manager_->set_channel_slow_mode_delay(DialogId(request.chat_id_), request.slow_mode_delay_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::pinChatMessage &request) {
@ -7063,7 +7062,7 @@ void Td::on_request(uint64 id, const td_api::leaveChat &request) {
DialogId dialog_id(request.chat_id_);
td_api::object_ptr<td_api::ChatMemberStatus> new_status = td_api::make_object<td_api::chatMemberStatusLeft>();
if (dialog_id.get_type() == DialogType::Channel && dialog_manager_->have_dialog_force(dialog_id, "leaveChat")) {
auto status = contacts_manager_->get_channel_status(dialog_id.get_channel_id());
auto status = chat_manager_->get_channel_status(dialog_id.get_channel_id());
if (status.is_creator()) {
if (!status.is_member()) {
return promise.set_value(Unit());
@ -7975,21 +7974,21 @@ void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.username_);
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->set_channel_username(ChannelId(request.supergroup_id_), request.username_, std::move(promise));
chat_manager_->set_channel_username(ChannelId(request.supergroup_id_), request.username_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::toggleSupergroupUsernameIsActive &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.username_);
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->toggle_channel_username_is_active(ChannelId(request.supergroup_id_), std::move(request.username_),
request.is_active_, std::move(promise));
chat_manager_->toggle_channel_username_is_active(ChannelId(request.supergroup_id_), std::move(request.username_),
request.is_active_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::disableAllSupergroupUsernames &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->disable_all_channel_usernames(ChannelId(request.supergroup_id_), std::move(promise));
chat_manager_->disable_all_channel_usernames(ChannelId(request.supergroup_id_), std::move(promise));
}
void Td::on_request(uint64 id, td_api::reorderSupergroupActiveUsernames &request) {
@ -7998,94 +7997,94 @@ void Td::on_request(uint64 id, td_api::reorderSupergroupActiveUsernames &request
CLEAN_INPUT_STRING(username);
}
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->reorder_channel_usernames(ChannelId(request.supergroup_id_), std::move(request.usernames_),
std::move(promise));
chat_manager_->reorder_channel_usernames(ChannelId(request.supergroup_id_), std::move(request.usernames_),
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setSupergroupStickerSet &request) {
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->set_channel_sticker_set(ChannelId(request.supergroup_id_), StickerSetId(request.sticker_set_id_),
std::move(promise));
chat_manager_->set_channel_sticker_set(ChannelId(request.supergroup_id_), StickerSetId(request.sticker_set_id_),
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setSupergroupCustomEmojiStickerSet &request) {
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->set_channel_emoji_sticker_set(
ChannelId(request.supergroup_id_), StickerSetId(request.custom_emoji_sticker_set_id_), std::move(promise));
chat_manager_->set_channel_emoji_sticker_set(ChannelId(request.supergroup_id_),
StickerSetId(request.custom_emoji_sticker_set_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setSupergroupUnrestrictBoostCount &request) {
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->set_channel_unrestrict_boost_count(ChannelId(request.supergroup_id_),
request.unrestrict_boost_count_, std::move(promise));
chat_manager_->set_channel_unrestrict_boost_count(ChannelId(request.supergroup_id_), request.unrestrict_boost_count_,
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSupergroupSignMessages &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->toggle_channel_sign_messages(ChannelId(request.supergroup_id_), request.sign_messages_,
std::move(promise));
chat_manager_->toggle_channel_sign_messages(ChannelId(request.supergroup_id_), request.sign_messages_,
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSupergroupJoinToSendMessages &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->toggle_channel_join_to_send(ChannelId(request.supergroup_id_), request.join_to_send_messages_,
std::move(promise));
chat_manager_->toggle_channel_join_to_send(ChannelId(request.supergroup_id_), request.join_to_send_messages_,
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSupergroupJoinByRequest &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->toggle_channel_join_request(ChannelId(request.supergroup_id_), request.join_by_request_,
std::move(promise));
chat_manager_->toggle_channel_join_request(ChannelId(request.supergroup_id_), request.join_by_request_,
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSupergroupIsAllHistoryAvailable &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->toggle_channel_is_all_history_available(ChannelId(request.supergroup_id_),
request.is_all_history_available_, std::move(promise));
chat_manager_->toggle_channel_is_all_history_available(ChannelId(request.supergroup_id_),
request.is_all_history_available_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSupergroupHasHiddenMembers &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->toggle_channel_has_hidden_participants(ChannelId(request.supergroup_id_),
request.has_hidden_members_, std::move(promise));
chat_manager_->toggle_channel_has_hidden_participants(ChannelId(request.supergroup_id_), request.has_hidden_members_,
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSupergroupHasAggressiveAntiSpamEnabled &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->toggle_channel_has_aggressive_anti_spam_enabled(
chat_manager_->toggle_channel_has_aggressive_anti_spam_enabled(
ChannelId(request.supergroup_id_), request.has_aggressive_anti_spam_enabled_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSupergroupIsForum &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->toggle_channel_is_forum(ChannelId(request.supergroup_id_), request.is_forum_, std::move(promise));
chat_manager_->toggle_channel_is_forum(ChannelId(request.supergroup_id_), request.is_forum_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleSupergroupIsBroadcastGroup &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->convert_channel_to_gigagroup(ChannelId(request.supergroup_id_), std::move(promise));
chat_manager_->convert_channel_to_gigagroup(ChannelId(request.supergroup_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::reportSupergroupSpam &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->report_channel_spam(ChannelId(request.supergroup_id_),
MessageId::get_message_ids(request.message_ids_), std::move(promise));
chat_manager_->report_channel_spam(ChannelId(request.supergroup_id_),
MessageId::get_message_ids(request.message_ids_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::reportSupergroupAntiSpamFalsePositive &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->report_channel_anti_spam_false_positive(ChannelId(request.supergroup_id_),
MessageId(request.message_id_), std::move(promise));
chat_manager_->report_channel_anti_spam_false_positive(ChannelId(request.supergroup_id_),
MessageId(request.message_id_), std::move(promise));
}
void Td::on_request(uint64 id, td_api::getSupergroupMembers &request) {

View File

@ -51,9 +51,9 @@ class BusinessManager;
class CallManager;
class CallbackQueriesManager;
class ChannelRecommendationManager;
class ChatManager;
class CommonDialogManager;
class ConfigManager;
class ContactsManager;
class CountryInfoManager;
class DeviceTokenManager;
class DialogActionManager;
@ -188,10 +188,10 @@ class Td final : public Actor {
ActorOwn<BusinessManager> business_manager_actor_;
unique_ptr<ChannelRecommendationManager> channel_recommendation_manager_;
ActorOwn<ChannelRecommendationManager> channel_recommendation_manager_actor_;
unique_ptr<ChatManager> chat_manager_;
ActorOwn<ChatManager> chat_manager_actor_;
unique_ptr<CommonDialogManager> common_dialog_manager_;
ActorOwn<CommonDialogManager> common_dialog_manager_actor_;
unique_ptr<ContactsManager> contacts_manager_;
ActorOwn<ContactsManager> contacts_manager_actor_;
unique_ptr<CountryInfoManager> country_info_manager_;
ActorOwn<CountryInfoManager> country_info_manager_actor_;
unique_ptr<DialogActionManager> dialog_action_manager_;

View File

@ -8,7 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
@ -497,7 +497,7 @@ void TopDialogManager::on_get_top_peers(Result<telegram_api::object_ptr<telegram
auto top_peers = move_tl_object_as<telegram_api::contacts_topPeers>(std::move(top_peers_parent));
td_->user_manager_->on_get_users(std::move(top_peers->users_), "on get top chats");
td_->contacts_manager_->on_get_chats(std::move(top_peers->chats_), "on get top chats");
td_->chat_manager_->on_get_chats(std::move(top_peers->chats_), "on get top chats");
for (auto &category : top_peers->categories_) {
auto dialog_category = get_top_dialog_category(category->category_);
auto pos = static_cast<size_t>(dialog_category);

View File

@ -19,8 +19,8 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChannelType.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogAction.h"
#include "td/telegram/DialogActionManager.h"
#include "td/telegram/DialogFilterManager.h"
@ -708,11 +708,11 @@ bool UpdatesManager::is_acceptable_user(UserId user_id) const {
}
bool UpdatesManager::is_acceptable_chat(ChatId chat_id) const {
return td_->contacts_manager_->have_chat_force(chat_id, "is_acceptable_chat");
return td_->chat_manager_->have_chat_force(chat_id, "is_acceptable_chat");
}
bool UpdatesManager::is_acceptable_channel(ChannelId channel_id) const {
return td_->contacts_manager_->have_channel_force(channel_id, "is_acceptable_channel");
return td_->chat_manager_->have_channel_force(channel_id, "is_acceptable_channel");
}
bool UpdatesManager::is_acceptable_peer(const tl_object_ptr<telegram_api::Peer> &peer) const {
@ -878,7 +878,7 @@ bool UpdatesManager::is_acceptable_message_media(
for (auto &page_block : *page_blocks) {
if (page_block->get_id() == telegram_api::pageBlockChannel::ID) {
auto page_block_channel = static_cast<const telegram_api::pageBlockChannel *>(page_block.get());
auto channel_id = ContactsManager::get_channel_id(page_block_channel->channel_);
auto channel_id = ChatManager::get_channel_id(page_block_channel->channel_);
if (channel_id.is_valid()) {
if (!is_acceptable_channel(channel_id)) {
return false;
@ -1232,7 +1232,7 @@ void UpdatesManager::on_get_updates_impl(tl_object_ptr<telegram_api::Updates> up
case telegram_api::updatesCombined::ID: {
auto updates = move_tl_object_as<telegram_api::updatesCombined>(updates_ptr);
td_->user_manager_->on_get_users(std::move(updates->users_), "updatesCombined");
td_->contacts_manager_->on_get_chats(std::move(updates->chats_), "updatesCombined");
td_->chat_manager_->on_get_chats(std::move(updates->chats_), "updatesCombined");
on_pending_updates(std::move(updates->updates_), updates->seq_start_, updates->seq_, updates->date_, Time::now(),
std::move(promise), "telegram_api::updatesCombined");
break;
@ -1246,7 +1246,7 @@ void UpdatesManager::on_get_updates_impl(tl_object_ptr<telegram_api::Updates> up
source = source_str.c_str();
}
td_->user_manager_->on_get_users(std::move(updates->users_), source);
td_->contacts_manager_->on_get_chats(std::move(updates->chats_), source);
td_->chat_manager_->on_get_chats(std::move(updates->chats_), source);
on_pending_updates(std::move(updates->updates_), updates->seq_, updates->seq_, updates->date_, Time::now(),
std::move(promise), "telegram_api::updates");
break;
@ -1616,7 +1616,7 @@ vector<DialogId> UpdatesManager::get_chat_dialog_ids(const telegram_api::Updates
vector<DialogId> dialog_ids;
dialog_ids.reserve(chats->size());
for (const auto &chat : *chats) {
auto dialog_id = ContactsManager::get_dialog_id(chat);
auto dialog_id = ChatManager::get_dialog_id(chat);
if (dialog_id.is_valid()) {
dialog_ids.push_back(dialog_id);
} else {
@ -1624,7 +1624,7 @@ vector<DialogId> UpdatesManager::get_chat_dialog_ids(const telegram_api::Updates
}
}
if (dialog_ids.size() > 1) {
td::remove(dialog_ids, DialogId(ContactsManager::get_unsupported_channel_id()));
td::remove(dialog_ids, DialogId(ChatManager::get_unsupported_channel_id()));
}
return dialog_ids;
}
@ -1908,7 +1908,7 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
VLOG(get_difference) << "In get difference receive " << difference->users_.size() << " users and "
<< difference->chats_.size() << " chats";
td_->user_manager_->on_get_users(std::move(difference->users_), "updates.difference");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.difference");
td_->chat_manager_->on_get_chats(std::move(difference->chats_), "updates.difference");
if (get_difference_retry_count_ <= 5) {
for (const auto &message : difference->new_messages_) {
@ -1944,7 +1944,7 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
VLOG(get_difference) << "In get difference receive " << difference->users_.size() << " users and "
<< difference->chats_.size() << " chats";
td_->user_manager_->on_get_users(std::move(difference->users_), "updates.differenceSlice");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.differenceSlice");
td_->chat_manager_->on_get_chats(std::move(difference->chats_), "updates.differenceSlice");
if (get_difference_retry_count_ <= 5) {
for (const auto &message : difference->new_messages_) {
@ -2041,7 +2041,7 @@ void UpdatesManager::on_get_pts_update(int32 pts,
}
td_->user_manager_->on_get_users(std::move(difference->users_), "on_get_pts_update");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "on_get_pts_update");
td_->chat_manager_->on_get_chats(std::move(difference->chats_), "on_get_pts_update");
for (auto &message : difference->new_messages_) {
difference->other_updates_.push_back(
@ -2236,9 +2236,9 @@ void UpdatesManager::try_reload_data() {
LOG(INFO) << "Reload data";
td_->animations_manager_->reload_saved_animations(true);
td_->autosave_manager_->reload_autosave_settings();
td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::HasUsername, std::move(promise));
td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::IsLocationBased, Auto());
td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::ForPersonalDialog, Auto());
td_->chat_manager_->reload_created_public_dialogs(PublicDialogType::HasUsername, std::move(promise));
td_->chat_manager_->reload_created_public_dialogs(PublicDialogType::IsLocationBased, Auto());
td_->chat_manager_->reload_created_public_dialogs(PublicDialogType::ForPersonalDialog, Auto());
get_default_emoji_statuses(td_, Auto());
get_default_channel_emoji_statuses(td_, Auto());
td_->notification_settings_manager_->reload_saved_ringtones(Auto());
@ -2370,7 +2370,7 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
auto dialog_id = DialogId::get_message_dialog_id(*message_ptr);
if (dialog_id.get_type() == DialogType::Channel) {
auto channel_id = dialog_id.get_channel_id();
if (td_->contacts_manager_->have_channel_force(channel_id, source)) {
if (td_->chat_manager_->have_channel_force(channel_id, source)) {
if (td_->messages_manager_->is_old_channel_update(dialog_id, pts)) {
// the update will be ignored anyway, so there is no reason to replace it or force get_difference
LOG(INFO) << "Allow an outdated unacceptable update from " << source;
@ -3516,7 +3516,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelTooLong>
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannel> update, Promise<Unit> &&promise) {
td_->contacts_manager_->invalidate_channel_full(ChannelId(update->channel_id_), false, "updateChannel");
td_->chat_manager_->invalidate_channel_full(ChannelId(update->channel_id_), false, "updateChannel");
promise.set_value(Unit());
}
@ -4009,27 +4009,26 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotMenuButton>
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatParticipants> update, Promise<Unit> &&promise) {
td_->contacts_manager_->on_get_chat_participants(std::move(update->participants_), true);
td_->chat_manager_->on_get_chat_participants(std::move(update->participants_), true);
promise.set_value(Unit());
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatParticipantAdd> update, Promise<Unit> &&promise) {
td_->contacts_manager_->on_update_chat_add_user(ChatId(update->chat_id_), UserId(update->inviter_id_),
UserId(update->user_id_), update->date_, update->version_);
td_->chat_manager_->on_update_chat_add_user(ChatId(update->chat_id_), UserId(update->inviter_id_),
UserId(update->user_id_), update->date_, update->version_);
promise.set_value(Unit());
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatParticipantAdmin> update,
Promise<Unit> &&promise) {
td_->contacts_manager_->on_update_chat_edit_administrator(ChatId(update->chat_id_), UserId(update->user_id_),
update->is_admin_, update->version_);
td_->chat_manager_->on_update_chat_edit_administrator(ChatId(update->chat_id_), UserId(update->user_id_),
update->is_admin_, update->version_);
promise.set_value(Unit());
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatParticipantDelete> update,
Promise<Unit> &&promise) {
td_->contacts_manager_->on_update_chat_delete_user(ChatId(update->chat_id_), UserId(update->user_id_),
update->version_);
td_->chat_manager_->on_update_chat_delete_user(ChatId(update->chat_id_), UserId(update->user_id_), update->version_);
promise.set_value(Unit());
}
@ -4039,12 +4038,12 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatDefaultBann
auto version = update->version_;
switch (dialog_id.get_type()) {
case DialogType::Chat:
td_->contacts_manager_->on_update_chat_default_permissions(
td_->chat_manager_->on_update_chat_default_permissions(
dialog_id.get_chat_id(), RestrictedRights(update->default_banned_rights_, ChannelType::Unknown), version);
break;
case DialogType::Channel:
LOG_IF(ERROR, version != 0) << "Receive version " << version << " in " << dialog_id;
td_->contacts_manager_->on_update_channel_default_permissions(
td_->chat_manager_->on_update_channel_default_permissions(
dialog_id.get_channel_id(), RestrictedRights(update->default_banned_rights_, ChannelType::Megagroup));
break;
case DialogType::None:

View File

@ -18,9 +18,9 @@
#include "td/telegram/BusinessIntro.h"
#include "td/telegram/BusinessWorkHours.h"
#include "td/telegram/ChannelType.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/CommonDialogManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
@ -1061,7 +1061,7 @@ class UpdatePersonalChannelQuery final : public Td::ResultHandler {
if (channel_id == ChannelId()) {
input_channel = telegram_api::make_object<telegram_api::inputChannelEmpty>();
} else {
input_channel = td_->contacts_manager_->get_input_channel(channel_id);
input_channel = td_->chat_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
}
send_query(G()->net_query_creator().create(telegram_api::account_updatePersonalChannel(std::move(input_channel)),
@ -1166,7 +1166,7 @@ class GetFullUserQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for GetFullUserQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetFullUserQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetFullUserQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetFullUserQuery");
td_->user_manager_->on_get_user_full(std::move(ptr->full_user_));
promise_.set_value(Unit());
}
@ -3882,7 +3882,7 @@ Result<telegram_api::object_ptr<telegram_api::InputUser>> UserManager::get_input
CHECK(!it->second.empty());
auto message_full_id = *it->second.begin();
return telegram_api::make_object<telegram_api::inputUserFromMessage>(
td_->contacts_manager_->get_simple_input_peer(message_full_id.get_dialog_id()),
td_->chat_manager_->get_simple_input_peer(message_full_id.get_dialog_id()),
message_full_id.get_message_id().get_server_message_id().get(), user_id.get());
}
if (u == nullptr) {
@ -3957,7 +3957,7 @@ telegram_api::object_ptr<telegram_api::InputPeer> UserManager::get_input_peer_us
CHECK(!it->second.empty());
auto message_full_id = *it->second.begin();
return telegram_api::make_object<telegram_api::inputPeerUserFromMessage>(
td_->contacts_manager_->get_simple_input_peer(message_full_id.get_dialog_id()),
td_->chat_manager_->get_simple_input_peer(message_full_id.get_dialog_id()),
message_full_id.get_message_id().get_server_message_id().get(), user_id.get());
}
@ -5505,7 +5505,7 @@ void UserManager::apply_pending_user_photo(User *u, UserId user_id) {
void UserManager::register_message_users(MessageFullId message_full_id, vector<UserId> user_ids) {
auto dialog_id = message_full_id.get_dialog_id();
CHECK(dialog_id.get_type() == DialogType::Channel);
if (!td_->contacts_manager_->have_channel(dialog_id.get_channel_id())) {
if (!td_->chat_manager_->have_channel(dialog_id.get_channel_id())) {
return;
}
for (auto user_id : user_ids) {

View File

@ -8,7 +8,7 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Td.h"
@ -36,7 +36,7 @@ void UserPrivacySettingRule::set_dialog_ids(Td *td, const vector<int64> &chat_id
break;
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
if (!td->contacts_manager_->is_megagroup_channel(channel_id)) {
if (!td->chat_manager_->is_megagroup_channel(channel_id)) {
LOG(INFO) << "Ignore broadcast " << channel_id;
break;
}
@ -145,10 +145,10 @@ void UserPrivacySettingRule::set_dialog_ids_from_server(Td *td, const vector<int
for (auto server_chat_id : server_chat_ids) {
ChatId chat_id(server_chat_id);
DialogId dialog_id(chat_id);
if (!td->contacts_manager_->have_chat(chat_id)) {
if (!td->chat_manager_->have_chat(chat_id)) {
ChannelId channel_id(server_chat_id);
dialog_id = DialogId(channel_id);
if (!td->contacts_manager_->have_channel(channel_id)) {
if (!td->chat_manager_->have_channel(channel_id)) {
LOG(ERROR) << "Receive unknown group " << server_chat_id << " from the server";
continue;
}
@ -268,7 +268,7 @@ void UserPrivacySettingRule::add_dependencies(Dependencies &dependencies) const
UserPrivacySettingRules UserPrivacySettingRules::get_user_privacy_setting_rules(
Td *td, telegram_api::object_ptr<telegram_api::account_privacyRules> rules) {
td->user_manager_->on_get_users(std::move(rules->users_), "on get privacy rules");
td->contacts_manager_->on_get_chats(std::move(rules->chats_), "on get privacy rules");
td->chat_manager_->on_get_chats(std::move(rules->chats_), "on get privacy rules");
return get_user_privacy_setting_rules(td, std::move(rules->rules_));
}

View File

@ -12,7 +12,7 @@
#include "td/telegram/AudiosManager.h"
#include "td/telegram/AudiosManager.hpp"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/Dimensions.h"
#include "td/telegram/Document.h"
@ -2204,13 +2204,13 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
return nullptr;
}
if (td->contacts_manager_->have_channel_force(channel_id, "pageBlockChannel")) {
td->contacts_manager_->on_get_chat(std::move(page_block->channel_), "pageBlockChannel");
if (td->chat_manager_->have_channel_force(channel_id, "pageBlockChannel")) {
td->chat_manager_->on_get_chat(std::move(page_block->channel_), "pageBlockChannel");
LOG(INFO) << "Receive known min " << channel_id;
return td::make_unique<WebPageBlockChatLink>(td->contacts_manager_->get_channel_title(channel_id),
*td->contacts_manager_->get_channel_dialog_photo(channel_id),
td->contacts_manager_->get_channel_first_username(channel_id),
td->contacts_manager_->get_channel_accent_color_id(channel_id),
return td::make_unique<WebPageBlockChatLink>(td->chat_manager_->get_channel_title(channel_id),
*td->chat_manager_->get_channel_dialog_photo(channel_id),
td->chat_manager_->get_channel_first_username(channel_id),
td->chat_manager_->get_channel_accent_color_id(channel_id),
channel_id);
} else {
bool has_access_hash = (channel->flags_ & telegram_api::channel::ACCESS_HASH_MASK) != 0;

View File

@ -9,7 +9,7 @@
#include "td/telegram/AnimationsManager.h"
#include "td/telegram/AudiosManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/ChatManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Dimensions.h"
@ -127,7 +127,7 @@ class GetWebPageQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetWebPageQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetWebPageQuery");
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetWebPageQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetWebPageQuery");
auto page = std::move(ptr->webpage_);
if (page->get_id() == telegram_api::webPageNotModified::ID) {
if (web_page_id_.is_valid()) {