Move relevant functions to UserManager.
This commit is contained in:
parent
6010475d26
commit
03a624903e
@ -7,7 +7,6 @@
|
||||
#include "td/telegram/AccountManager.h"
|
||||
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DeviceTokenManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
@ -18,6 +17,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/db/binlog/BinlogEvent.h"
|
||||
#include "td/db/binlog/BinlogHelper.h"
|
||||
@ -461,7 +461,7 @@ class GetWebAuthorizationsQuery final : public Td::ResultHandler {
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetWebAuthorizationsQuery: " << to_string(ptr);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetWebAuthorizationsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetWebAuthorizationsQuery");
|
||||
|
||||
auto results = td_api::make_object<td_api::connectedWebsites>();
|
||||
results->websites_.reserve(ptr->authorizations_.size());
|
||||
@ -475,7 +475,7 @@ class GetWebAuthorizationsQuery final : public Td::ResultHandler {
|
||||
|
||||
results->websites_.push_back(td_api::make_object<td_api::connectedWebsite>(
|
||||
authorization->hash_, authorization->domain_,
|
||||
td_->contacts_manager_->get_user_id_object(bot_user_id, "GetWebAuthorizationsQuery"), authorization->browser_,
|
||||
td_->user_manager_->get_user_id_object(bot_user_id, "GetWebAuthorizationsQuery"), authorization->browser_,
|
||||
authorization->platform_, authorization->date_created_, authorization->date_active_, authorization->ip_,
|
||||
authorization->region_));
|
||||
}
|
||||
@ -591,9 +591,9 @@ class ImportContactTokenQuery final : public Td::ResultHandler {
|
||||
auto user = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for ImportContactTokenQuery: " << to_string(user);
|
||||
|
||||
auto user_id = ContactsManager::get_user_id(user);
|
||||
td_->contacts_manager_->on_get_user(std::move(user), "ImportContactTokenQuery");
|
||||
promise_.set_value(td_->contacts_manager_->get_user_object(user_id));
|
||||
auto user_id = UserManager::get_user_id(user);
|
||||
td_->user_manager_->on_get_user(std::move(user), "ImportContactTokenQuery");
|
||||
promise_.set_value(td_->user_manager_->get_user_object(user_id));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
@ -1117,7 +1117,7 @@ void AccountManager::disconnect_all_websites(Promise<Unit> &&promise) {
|
||||
}
|
||||
|
||||
void AccountManager::get_user_link(Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
||||
td_->contacts_manager_->get_me(
|
||||
td_->user_manager_->get_me(
|
||||
PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||
if (result.is_error()) {
|
||||
promise.set_error(result.move_as_error());
|
||||
@ -1129,7 +1129,7 @@ void AccountManager::get_user_link(Promise<td_api::object_ptr<td_api::userLink>>
|
||||
|
||||
void AccountManager::get_user_link_impl(Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
auto username = td_->contacts_manager_->get_user_first_username(td_->contacts_manager_->get_my_id());
|
||||
auto username = td_->user_manager_->get_user_first_username(td_->user_manager_->get_my_id());
|
||||
if (!username.empty()) {
|
||||
return promise.set_value(
|
||||
td_api::make_object<td_api::userLink>(LinkManager::get_public_dialog_link(username, true), 0));
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/WebApp.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
@ -222,7 +223,7 @@ class ProlongWebViewQuery final : public Td::ResultHandler {
|
||||
dialog_id_ = dialog_id;
|
||||
|
||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(bot_user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(bot_user_id);
|
||||
if (input_peer == nullptr || r_input_user.is_error()) {
|
||||
return;
|
||||
}
|
||||
@ -275,7 +276,7 @@ class InvokeWebViewCustomMethodQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send(UserId bot_user_id, const string &method, const string ¶meters) {
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(bot_user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(bot_user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
return on_error(r_input_user.move_as_error());
|
||||
}
|
||||
@ -770,8 +771,8 @@ void AttachMenuManager::schedule_ping_web_view() {
|
||||
|
||||
void AttachMenuManager::get_web_app(UserId bot_user_id, const string &web_app_short_name,
|
||||
Promise<td_api::object_ptr<td_api::foundWebApp>> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(bot_user_id));
|
||||
auto query_promise =
|
||||
PromiseCreator::lambda([actor_id = actor_id(this), bot_user_id, web_app_short_name, promise = std::move(promise)](
|
||||
Result<telegram_api::object_ptr<telegram_api::messages_botApp>> result) mutable {
|
||||
@ -827,8 +828,8 @@ void AttachMenuManager::request_app_web_view(DialogId dialog_id, UserId bot_user
|
||||
dialog_id.get_type() == DialogType::SecretChat) {
|
||||
dialog_id = DialogId(bot_user_id);
|
||||
}
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(bot_user_id));
|
||||
|
||||
td_->create_handler<RequestAppWebViewQuery>(std::move(promise))
|
||||
->send(dialog_id, std::move(input_user), web_app_short_name, start_parameter, theme, platform,
|
||||
@ -839,9 +840,9 @@ void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id,
|
||||
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, string &&url,
|
||||
td_api::object_ptr<td_api::themeParameters> &&theme, string &&platform,
|
||||
Promise<td_api::object_ptr<td_api::webAppInfo>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, td_->contacts_manager_->get_bot_data(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(bot_user_id));
|
||||
TRY_STATUS_PROMISE(promise, td_->user_manager_->get_bot_data(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(bot_user_id));
|
||||
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "request_web_view")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
@ -917,7 +918,7 @@ void AttachMenuManager::invoke_web_view_custom_method(
|
||||
Result<AttachMenuManager::AttachMenuBot> AttachMenuManager::get_attach_menu_bot(
|
||||
tl_object_ptr<telegram_api::attachMenuBot> &&bot) {
|
||||
UserId user_id(bot->bot_id_);
|
||||
if (!td_->contacts_manager_->have_user(user_id)) {
|
||||
if (!td_->user_manager_->have_user(user_id)) {
|
||||
return Status::Error(PSLICE() << "Have no information about " << user_id);
|
||||
}
|
||||
|
||||
@ -1102,7 +1103,7 @@ void AttachMenuManager::on_reload_attach_menu_bots(
|
||||
CHECK(constructor_id == telegram_api::attachMenuBots::ID);
|
||||
auto attach_menu_bots = move_tl_object_as<telegram_api::attachMenuBots>(attach_menu_bots_ptr);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(attach_menu_bots->users_), "on_reload_attach_menu_bots");
|
||||
td_->user_manager_->on_get_users(std::move(attach_menu_bots->users_), "on_reload_attach_menu_bots");
|
||||
|
||||
auto new_hash = attach_menu_bots->hash_;
|
||||
vector<AttachMenuBot> new_attach_menu_bots;
|
||||
@ -1147,9 +1148,9 @@ void AttachMenuManager::remove_bot_from_attach_menu(UserId user_id) {
|
||||
|
||||
void AttachMenuManager::get_attach_menu_bot(UserId user_id,
|
||||
Promise<td_api::object_ptr<td_api::attachmentMenuBot>> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(user_id));
|
||||
if (!bot_data.can_be_added_to_attach_menu) {
|
||||
return promise.set_error(Status::Error(400, "The bot can't be added to attachment menu"));
|
||||
}
|
||||
@ -1168,7 +1169,7 @@ void AttachMenuManager::reload_attach_menu_bot(UserId user_id, Promise<Unit> &&p
|
||||
return promise.set_error(Status::Error(400, "Can't reload attachment menu bot"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
auto wrapped_promise = PromiseCreator::lambda(
|
||||
[promise = std::move(promise)](Result<td_api::object_ptr<td_api::attachmentMenuBot>> result) mutable {
|
||||
@ -1193,7 +1194,7 @@ void AttachMenuManager::on_get_attach_menu_bot(
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
TRY_RESULT_PROMISE(promise, bot, std::move(result));
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(bot->users_), "on_get_attach_menu_bot");
|
||||
td_->user_manager_->on_get_users(std::move(bot->users_), "on_get_attach_menu_bot");
|
||||
|
||||
auto r_attach_menu_bot = get_attach_menu_bot(std::move(bot->bot_));
|
||||
if (r_attach_menu_bot.is_error()) {
|
||||
@ -1263,10 +1264,10 @@ void AttachMenuManager::toggle_bot_is_added_to_attach_menu(UserId user_id, bool
|
||||
Promise<Unit> &&promise) {
|
||||
CHECK(is_active());
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
if (is_added) {
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(user_id));
|
||||
if (!bot_data.can_be_added_to_attach_menu) {
|
||||
return promise.set_error(Status::Error(400, "The bot can't be added to attachment menu"));
|
||||
}
|
||||
@ -1304,8 +1305,8 @@ td_api::object_ptr<td_api::attachmentMenuBot> AttachMenuManager::get_attachment_
|
||||
};
|
||||
|
||||
return td_api::make_object<td_api::attachmentMenuBot>(
|
||||
td_->contacts_manager_->get_user_id_object(bot.user_id_, "get_attachment_menu_bot_object"),
|
||||
bot.supports_self_dialog_, bot.supports_user_dialogs_, bot.supports_bot_dialogs_, bot.supports_group_dialogs_,
|
||||
td_->user_manager_->get_user_id_object(bot.user_id_, "get_attachment_menu_bot_object"), bot.supports_self_dialog_,
|
||||
bot.supports_user_dialogs_, bot.supports_bot_dialogs_, bot.supports_group_dialogs_,
|
||||
bot.supports_broadcast_dialogs_, bot.request_write_access_, bot.is_added_, bot.show_in_attach_menu_,
|
||||
bot.show_in_side_menu_, bot.side_menu_disclaimer_needed_, bot.name_,
|
||||
get_attach_menu_bot_color_object(bot.name_color_), get_file(bot.default_icon_file_id_),
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "td/telegram/AttachMenuManager.h"
|
||||
#include "td/telegram/AuthManager.hpp"
|
||||
#include "td/telegram/ConfigManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogFilterManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
@ -32,6 +31,7 @@
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/TopDialogManager.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/Version.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
@ -287,7 +287,7 @@ AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> par
|
||||
if (is_bot_str == "true") {
|
||||
is_bot_ = true;
|
||||
}
|
||||
auto my_id = ContactsManager::load_my_id();
|
||||
auto my_id = UserManager::load_my_id();
|
||||
if (my_id.is_valid()) {
|
||||
// just in case
|
||||
LOG(INFO) << "Logged in as " << my_id;
|
||||
@ -295,8 +295,8 @@ AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> par
|
||||
update_state(State::Ok);
|
||||
} else {
|
||||
LOG(ERROR) << "Restore unknown my_id";
|
||||
ContactsManager::send_get_me_query(
|
||||
td_, PromiseCreator::lambda([this](Result<Unit> result) { update_state(State::Ok); }));
|
||||
UserManager::send_get_me_query(td_,
|
||||
PromiseCreator::lambda([this](Result<Unit> result) { update_state(State::Ok); }));
|
||||
}
|
||||
G()->net_query_dispatcher().check_authorization_is_ok();
|
||||
} else if (auth_str == "logout") {
|
||||
@ -1233,9 +1233,9 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
|
||||
user->self_ = true;
|
||||
}
|
||||
}
|
||||
td_->contacts_manager_->on_get_user(std::move(auth->user_), "on_get_authorization");
|
||||
td_->user_manager_->on_get_user(std::move(auth->user_), "on_get_authorization");
|
||||
update_state(State::Ok);
|
||||
if (!td_->contacts_manager_->get_my_id().is_valid()) {
|
||||
if (!td_->user_manager_->get_my_id().is_valid()) {
|
||||
LOG(ERROR) << "Server didsn't send proper authorization";
|
||||
on_current_query_error(Status::Error(500, "Server didn't send proper authorization"));
|
||||
log_out(0);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/db/SqliteKeyValueAsync.h"
|
||||
|
||||
@ -384,7 +385,7 @@ void AutosaveManager::on_get_autosave_settings(
|
||||
}
|
||||
|
||||
auto settings = r_settings.move_as_ok();
|
||||
td_->contacts_manager_->on_get_users(std::move(settings->users_), "on_get_autosave_settings");
|
||||
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");
|
||||
|
||||
DialogAutosaveSettings new_user_settings(settings->users_settings_.get());
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/db/SqliteKeyValueAsync.h"
|
||||
|
||||
@ -785,7 +786,7 @@ Result<DialogId> BackgroundManager::get_background_dialog(DialogId dialog_id) {
|
||||
return dialog_id;
|
||||
}
|
||||
case DialogType::SecretChat: {
|
||||
auto user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
auto user_id = td_->user_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
if (!user_id.is_valid()) {
|
||||
return Status::Error(400, "Can't access the user");
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -41,7 +42,7 @@ static td_api::object_ptr<td_api::chatBoost> get_chat_boost_object(
|
||||
giveaway_message_id = MessageId::min();
|
||||
}
|
||||
return td_api::make_object<td_api::chatBoostSourceGiveaway>(
|
||||
td->contacts_manager_->get_user_id_object(user_id, "chatBoostSourceGiveaway"), boost->used_gift_slug_,
|
||||
td->user_manager_->get_user_id_object(user_id, "chatBoostSourceGiveaway"), boost->used_gift_slug_,
|
||||
giveaway_message_id.get(), boost->unclaimed_);
|
||||
}
|
||||
if (boost->gift_) {
|
||||
@ -50,7 +51,7 @@ static td_api::object_ptr<td_api::chatBoost> get_chat_boost_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatBoostSourceGiftCode>(
|
||||
td->contacts_manager_->get_user_id_object(user_id, "chatBoostSourceGiftCode"), boost->used_gift_slug_);
|
||||
td->user_manager_->get_user_id_object(user_id, "chatBoostSourceGiftCode"), boost->used_gift_slug_);
|
||||
}
|
||||
|
||||
UserId user_id(boost->user_id_);
|
||||
@ -58,7 +59,7 @@ static td_api::object_ptr<td_api::chatBoost> get_chat_boost_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatBoostSourcePremium>(
|
||||
td->contacts_manager_->get_user_id_object(user_id, "chatBoostSourcePremium"));
|
||||
td->user_manager_->get_user_id_object(user_id, "chatBoostSourcePremium"));
|
||||
}();
|
||||
if (source == nullptr) {
|
||||
LOG(ERROR) << "Receive " << to_string(boost);
|
||||
@ -70,7 +71,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->contacts_manager_->on_get_users(std::move(my_boosts->users_), "GetMyBoostsQuery");
|
||||
td->user_manager_->on_get_users(std::move(my_boosts->users_), "GetMyBoostsQuery");
|
||||
td->contacts_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_) {
|
||||
@ -268,7 +269,7 @@ class GetBoostsListQuery final : public Td::ResultHandler {
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for GetBoostsListQuery: " << to_string(result);
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetBoostsListQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetBoostsListQuery");
|
||||
|
||||
auto total_count = result->count_;
|
||||
vector<td_api::object_ptr<td_api::chatBoost>> boosts;
|
||||
@ -302,7 +303,7 @@ class GetUserBoostsQuery final : public Td::ResultHandler {
|
||||
dialog_id_ = dialog_id;
|
||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
|
||||
CHECK(input_peer != nullptr);
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(user_id);
|
||||
CHECK(r_input_user.is_ok());
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::premium_getUserBoosts(std::move(input_peer), r_input_user.move_as_ok())));
|
||||
@ -316,7 +317,7 @@ class GetUserBoostsQuery final : public Td::ResultHandler {
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for GetUserBoostsQuery: " << to_string(result);
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetUserBoostsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetUserBoostsQuery");
|
||||
|
||||
auto total_count = result->count_;
|
||||
vector<td_api::object_ptr<td_api::chatBoost>> boosts;
|
||||
|
@ -7,11 +7,11 @@
|
||||
#include "td/telegram/BotCommand.h"
|
||||
|
||||
#include "td/telegram/BotCommandScope.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -100,7 +100,7 @@ class GetBotCommandsQuery final : public Td::ResultHandler {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
BotCommands commands(td_->contacts_manager_->get_my_id(), result_ptr.move_as_ok());
|
||||
BotCommands commands(td_->user_manager_->get_my_id(), result_ptr.move_as_ok());
|
||||
promise_.set_value(commands.get_bot_commands_object(td_));
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ BotCommands::BotCommands(UserId bot_user_id, vector<telegram_api::object_ptr<tel
|
||||
td_api::object_ptr<td_api::botCommands> BotCommands::get_bot_commands_object(Td *td) const {
|
||||
auto commands = transform(commands_, [](const auto &command) { return command.get_bot_command_object(); });
|
||||
return td_api::make_object<td_api::botCommands>(
|
||||
td->contacts_manager_->get_user_id_object(bot_user_id_, "get_bot_commands_object"), std::move(commands));
|
||||
td->user_manager_->get_user_id_object(bot_user_id_, "get_bot_commands_object"), std::move(commands));
|
||||
}
|
||||
|
||||
bool BotCommands::update_all_bot_commands(vector<BotCommands> &all_bot_commands, BotCommands &&bot_commands) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
@ -54,7 +55,7 @@ Result<BotCommandScope> BotCommandScope::get_bot_command_scope(Td *td,
|
||||
type = Type::DialogParticipant;
|
||||
dialog_id = DialogId(scope->chat_id_);
|
||||
user_id = UserId(scope->user_id_);
|
||||
TRY_STATUS(td->contacts_manager_->get_input_user(user_id));
|
||||
TRY_STATUS(td->user_manager_->get_input_user(user_id));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -94,7 +95,7 @@ telegram_api::object_ptr<telegram_api::BotCommandScope> BotCommandScope::get_inp
|
||||
const Td *td) const {
|
||||
auto input_peer =
|
||||
dialog_id_.is_valid() ? td->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read) : nullptr;
|
||||
auto r_input_user = td->contacts_manager_->get_input_user(user_id_);
|
||||
auto r_input_user = td->user_manager_->get_input_user(user_id_);
|
||||
auto input_user = r_input_user.is_ok() ? r_input_user.move_as_ok() : nullptr;
|
||||
switch (type_) {
|
||||
case Type::Default:
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "td/telegram/BotInfoManager.h"
|
||||
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/NetQueryCreator.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -44,7 +44,7 @@ class SetBotGroupDefaultAdminRightsQuery final : public Td::ResultHandler {
|
||||
|
||||
bool result = result_ptr.move_as_ok();
|
||||
LOG_IF(WARNING, !result) << "Failed to set group default administrator rights";
|
||||
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
|
||||
td_->user_manager_->invalidate_user_full(td_->user_manager_->get_my_id());
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class SetBotGroupDefaultAdminRightsQuery final : public Td::ResultHandler {
|
||||
if (status.message() == "RIGHTS_NOT_MODIFIED") {
|
||||
return promise_.set_value(Unit());
|
||||
}
|
||||
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
|
||||
td_->user_manager_->invalidate_user_full(td_->user_manager_->get_my_id());
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
@ -77,7 +77,7 @@ class SetBotBroadcastDefaultAdminRightsQuery final : public Td::ResultHandler {
|
||||
|
||||
bool result = result_ptr.move_as_ok();
|
||||
LOG_IF(WARNING, !result) << "Failed to set channel default administrator rights";
|
||||
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
|
||||
td_->user_manager_->invalidate_user_full(td_->user_manager_->get_my_id());
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ class SetBotBroadcastDefaultAdminRightsQuery final : public Td::ResultHandler {
|
||||
if (status.message() == "RIGHTS_NOT_MODIFIED") {
|
||||
return promise_.set_value(Unit());
|
||||
}
|
||||
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
|
||||
td_->user_manager_->invalidate_user_full(td_->user_manager_->get_my_id());
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
@ -98,7 +98,7 @@ class CanBotSendMessageQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send(UserId bot_user_id) {
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(bot_user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(bot_user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
return on_error(r_input_user.move_as_error());
|
||||
}
|
||||
@ -132,7 +132,7 @@ class AllowBotSendMessageQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send(UserId bot_user_id) {
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(bot_user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(bot_user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
return on_error(r_input_user.move_as_error());
|
||||
}
|
||||
@ -158,15 +158,15 @@ class AllowBotSendMessageQuery final : public Td::ResultHandler {
|
||||
|
||||
static Result<telegram_api::object_ptr<telegram_api::InputUser>> get_bot_input_user(const Td *td, UserId bot_user_id) {
|
||||
if (td->auth_manager_->is_bot()) {
|
||||
if (bot_user_id != UserId() && bot_user_id != td->contacts_manager_->get_my_id()) {
|
||||
if (bot_user_id != UserId() && bot_user_id != td->user_manager_->get_my_id()) {
|
||||
return Status::Error(400, "Invalid bot user identifier specified");
|
||||
}
|
||||
} else {
|
||||
TRY_RESULT(bot_data, td->contacts_manager_->get_bot_data(bot_user_id));
|
||||
TRY_RESULT(bot_data, td->user_manager_->get_bot_data(bot_user_id));
|
||||
if (!bot_data.can_be_edited) {
|
||||
return Status::Error(400, "The bot can't be edited");
|
||||
}
|
||||
return td->contacts_manager_->get_input_user(bot_user_id);
|
||||
return td->user_manager_->get_input_user(bot_user_id);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -179,7 +179,7 @@ class SetBotInfoQuery final : public Td::ResultHandler {
|
||||
|
||||
void invalidate_bot_info() {
|
||||
if (set_info_) {
|
||||
td_->contacts_manager_->invalidate_user_full(bot_user_id_);
|
||||
td_->user_manager_->invalidate_user_full(bot_user_id_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ class SetBotInfoQuery final : public Td::ResultHandler {
|
||||
flags |= telegram_api::bots_setBotInfo::BOT_MASK;
|
||||
bot_user_id_ = bot_user_id;
|
||||
} else {
|
||||
bot_user_id_ = td_->contacts_manager_->get_my_id();
|
||||
bot_user_id_ = td_->user_manager_->get_my_id();
|
||||
}
|
||||
set_name_ = set_name;
|
||||
set_info_ = set_about || set_description;
|
||||
@ -228,11 +228,11 @@ class SetBotInfoQuery final : public Td::ResultHandler {
|
||||
if (set_info_) {
|
||||
invalidate_bot_info();
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
return td_->contacts_manager_->reload_user_full(bot_user_id_, std::move(promise_), "SetBotInfoQuery");
|
||||
return td_->user_manager_->reload_user_full(bot_user_id_, std::move(promise_), "SetBotInfoQuery");
|
||||
}
|
||||
}
|
||||
if (set_name_) {
|
||||
return td_->contacts_manager_->reload_user(bot_user_id_, std::move(promise_), "SetBotInfoQuery");
|
||||
return td_->user_manager_->reload_user(bot_user_id_, std::move(promise_), "SetBotInfoQuery");
|
||||
}
|
||||
// invalidation is enough for bots if name wasn't changed
|
||||
promise_.set_value(Unit());
|
||||
@ -374,13 +374,13 @@ void BotInfoManager::timeout_expired() {
|
||||
|
||||
void BotInfoManager::set_default_group_administrator_rights(AdministratorRights administrator_rights,
|
||||
Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
|
||||
td_->user_manager_->invalidate_user_full(td_->user_manager_->get_my_id());
|
||||
td_->create_handler<SetBotGroupDefaultAdminRightsQuery>(std::move(promise))->send(administrator_rights);
|
||||
}
|
||||
|
||||
void BotInfoManager::set_default_channel_administrator_rights(AdministratorRights administrator_rights,
|
||||
Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->invalidate_user_full(td_->contacts_manager_->get_my_id());
|
||||
td_->user_manager_->invalidate_user_full(td_->user_manager_->get_my_id());
|
||||
td_->create_handler<SetBotBroadcastDefaultAdminRightsQuery>(std::move(promise))->send(administrator_rights);
|
||||
}
|
||||
|
||||
|
@ -7,12 +7,12 @@
|
||||
#include "td/telegram/BotMenuButton.h"
|
||||
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -29,7 +29,7 @@ class SetBotMenuButtonQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send(UserId user_id, telegram_api::object_ptr<telegram_api::BotMenuButton> input_bot_menu_button) {
|
||||
auto input_user = user_id.is_valid() ? td_->contacts_manager_->get_input_user(user_id).move_as_ok()
|
||||
auto input_user = user_id.is_valid() ? td_->user_manager_->get_input_user(user_id).move_as_ok()
|
||||
: make_tl_object<telegram_api::inputUserEmpty>();
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::bots_setBotMenuButton(std::move(input_user), std::move(input_bot_menu_button))));
|
||||
@ -61,7 +61,7 @@ class GetBotMenuButtonQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send(UserId user_id) {
|
||||
auto input_user = user_id.is_valid() ? td_->contacts_manager_->get_input_user(user_id).move_as_ok()
|
||||
auto input_user = user_id.is_valid() ? td_->user_manager_->get_input_user(user_id).move_as_ok()
|
||||
: make_tl_object<telegram_api::inputUserEmpty>();
|
||||
send_query(G()->net_query_creator().create(telegram_api::bots_getBotMenuButton(std::move(input_user))));
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
//
|
||||
#include "td/telegram/BusinessConnectedBot.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
@ -30,7 +30,7 @@ BusinessConnectedBot::BusinessConnectedBot(td_api::object_ptr<td_api::businessCo
|
||||
td_api::object_ptr<td_api::businessConnectedBot> BusinessConnectedBot::get_business_connected_bot_object(Td *td) const {
|
||||
CHECK(is_valid());
|
||||
return td_api::make_object<td_api::businessConnectedBot>(
|
||||
td->contacts_manager_->get_user_id_object(user_id_, "businessConnectedBot"),
|
||||
td->user_manager_->get_user_id_object(user_id_, "businessConnectedBot"),
|
||||
recipients_.get_business_recipients_object(td), can_reply_);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/format.h"
|
||||
@ -98,7 +99,7 @@ struct BusinessConnectionManager::BusinessConnection {
|
||||
DialogId user_dialog_id(user_id_);
|
||||
td->dialog_manager_->force_create_dialog(user_dialog_id, "get_business_connection_object");
|
||||
return td_api::make_object<td_api::businessConnection>(
|
||||
connection_id_.get(), td->contacts_manager_->get_user_id_object(user_id_, "businessConnection"),
|
||||
connection_id_.get(), td->user_manager_->get_user_id_object(user_id_, "businessConnection"),
|
||||
td->dialog_manager_->get_chat_id_object(user_dialog_id, "businessConnection"), connection_date_, can_reply_,
|
||||
!is_disabled_);
|
||||
}
|
||||
@ -155,7 +156,7 @@ class BusinessConnectionManager::SendBusinessMessageQuery final : public Td::Res
|
||||
|
||||
const FormattedText *message_text = get_message_content_text(message_->content_.get());
|
||||
CHECK(message_text != nullptr);
|
||||
auto entities = get_input_message_entities(td_->contacts_manager_.get(), message_text, "SendBusinessMessageQuery");
|
||||
auto entities = get_input_message_entities(td_->user_manager_.get(), message_text, "SendBusinessMessageQuery");
|
||||
if (!entities.empty()) {
|
||||
flags |= telegram_api::messages_sendMessage::ENTITIES_MASK;
|
||||
}
|
||||
@ -169,7 +170,7 @@ class BusinessConnectionManager::SendBusinessMessageQuery final : public Td::Res
|
||||
telegram_api::messages_sendMessage(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, std::move(input_peer), std::move(reply_to), message_text->text,
|
||||
message_->random_id_, get_input_reply_markup(td_->contacts_manager_.get(), message_->reply_markup_),
|
||||
message_->random_id_, get_input_reply_markup(td_->user_manager_.get(), message_->reply_markup_),
|
||||
std::move(entities), 0, nullptr, nullptr),
|
||||
td_->business_connection_manager_->get_business_connection_dc_id(message_->business_connection_id_),
|
||||
{{message_->dialog_id_}}));
|
||||
@ -225,7 +226,7 @@ class BusinessConnectionManager::SendBusinessMediaQuery final : public Td::Resul
|
||||
}
|
||||
|
||||
const FormattedText *message_text = get_message_content_text(message_->content_.get());
|
||||
auto entities = get_input_message_entities(td_->contacts_manager_.get(), message_text, "SendBusinessMediaQuery");
|
||||
auto entities = get_input_message_entities(td_->user_manager_.get(), message_text, "SendBusinessMediaQuery");
|
||||
if (!entities.empty()) {
|
||||
flags |= telegram_api::messages_sendMedia::ENTITIES_MASK;
|
||||
}
|
||||
@ -240,7 +241,7 @@ class BusinessConnectionManager::SendBusinessMediaQuery final : public Td::Resul
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(input_peer),
|
||||
std::move(reply_to), std::move(input_media),
|
||||
message_text == nullptr ? string() : message_text->text, message_->random_id_,
|
||||
get_input_reply_markup(td_->contacts_manager_.get(), message_->reply_markup_),
|
||||
get_input_reply_markup(td_->user_manager_.get(), message_->reply_markup_),
|
||||
std::move(entities), 0, nullptr, nullptr),
|
||||
td_->business_connection_manager_->get_business_connection_dc_id(message_->business_connection_id_),
|
||||
{{message_->dialog_id_}}));
|
||||
@ -599,7 +600,7 @@ void BusinessConnectionManager::on_get_business_connection(
|
||||
}
|
||||
auto update = telegram_api::move_object_as<telegram_api::updateBotBusinessConnect>(updates->updates_[0]);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(updates->users_), "on_get_business_connection");
|
||||
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");
|
||||
|
||||
auto business_connection = make_unique<BusinessConnection>(update->connection_);
|
||||
@ -763,7 +764,7 @@ void BusinessConnectionManager::process_sent_business_message(
|
||||
}
|
||||
auto update = telegram_api::move_object_as<telegram_api::updateBotNewBusinessMessage>(updates->updates_[0]);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(updates->users_), "SendBusinessMediaQuery");
|
||||
td_->user_manager_->on_get_users(std::move(updates->users_), "SendBusinessMediaQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(updates->chats_), "SendBusinessMediaQuery");
|
||||
|
||||
promise.set_value(td_->messages_manager_->get_business_message_object(std::move(update->message_),
|
||||
@ -1067,7 +1068,7 @@ void BusinessConnectionManager::on_upload_message_album_media(int64 request_id,
|
||||
auto message = std::move(upload_result.message_);
|
||||
int32 flags = 0;
|
||||
const FormattedText *caption = get_message_content_text(message->content_.get());
|
||||
auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption, "on_upload_message_album_media");
|
||||
auto entities = get_input_message_entities(td_->user_manager_.get(), caption, "on_upload_message_album_media");
|
||||
if (!entities.empty()) {
|
||||
flags |= telegram_api::inputSingleMedia::ENTITIES_MASK;
|
||||
}
|
||||
@ -1095,7 +1096,7 @@ void BusinessConnectionManager::process_sent_business_message_album(
|
||||
return promise.set_error(Status::Error(500, "Receive invalid business connection messages"));
|
||||
}
|
||||
}
|
||||
td_->contacts_manager_->on_get_users(std::move(updates->users_), "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");
|
||||
|
||||
auto messages = td_api::make_object<td_api::businessMessages>();
|
||||
|
@ -12,12 +12,12 @@
|
||||
#include "td/telegram/BusinessIntro.h"
|
||||
#include "td/telegram/BusinessRecipients.h"
|
||||
#include "td/telegram/BusinessWorkHours.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogLocation.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -46,7 +46,7 @@ class GetConnectedBotsQuery final : public Td::ResultHandler {
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetConnectedBotsQuery: " << to_string(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetConnectedBotsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetConnectedBotsQuery");
|
||||
if (result->connected_bots_.size() > 1u) {
|
||||
return on_error(Status::Error(500, "Receive invalid response"));
|
||||
}
|
||||
@ -135,7 +135,7 @@ class UpdateBusinessLocationQuery final : public Td::ResultHandler {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
td_->contacts_manager_->on_update_user_location(td_->contacts_manager_->get_my_id(), std::move(location_));
|
||||
td_->user_manager_->on_update_user_location(td_->user_manager_->get_my_id(), std::move(location_));
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
@ -169,7 +169,7 @@ class UpdateBusinessWorkHoursQuery final : public Td::ResultHandler {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
td_->contacts_manager_->on_update_user_work_hours(td_->contacts_manager_->get_my_id(), std::move(work_hours_));
|
||||
td_->user_manager_->on_update_user_work_hours(td_->user_manager_->get_my_id(), std::move(work_hours_));
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
@ -204,8 +204,7 @@ class UpdateBusinessGreetingMessageQuery final : public Td::ResultHandler {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
td_->contacts_manager_->on_update_user_greeting_message(td_->contacts_manager_->get_my_id(),
|
||||
std::move(greeting_message_));
|
||||
td_->user_manager_->on_update_user_greeting_message(td_->user_manager_->get_my_id(), std::move(greeting_message_));
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
@ -240,7 +239,7 @@ class UpdateBusinessAwayMessageQuery final : public Td::ResultHandler {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
td_->contacts_manager_->on_update_user_away_message(td_->contacts_manager_->get_my_id(), std::move(away_message_));
|
||||
td_->user_manager_->on_update_user_away_message(td_->user_manager_->get_my_id(), std::move(away_message_));
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
@ -275,7 +274,7 @@ class UpdateBusinessIntroQuery final : public Td::ResultHandler {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
td_->contacts_manager_->on_update_user_intro(td_->contacts_manager_->get_my_id(), std::move(intro_));
|
||||
td_->user_manager_->on_update_user_intro(td_->user_manager_->get_my_id(), std::move(intro_));
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
@ -302,12 +301,12 @@ void BusinessManager::set_business_connected_bot(td_api::object_ptr<td_api::busi
|
||||
return promise.set_error(Status::Error(400, "Bot must be non-empty"));
|
||||
}
|
||||
BusinessConnectedBot connected_bot(std::move(bot));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(connected_bot.get_user_id()));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(connected_bot.get_user_id()));
|
||||
td_->create_handler<UpdateConnectedBotQuery>(std::move(promise))->send(connected_bot, std::move(input_user));
|
||||
}
|
||||
|
||||
void BusinessManager::delete_business_connected_bot(UserId bot_user_id, Promise<Unit> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
|
||||
td_->create_handler<UpdateConnectedBotQuery>(std::move(promise))->send(std::move(input_user));
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
//
|
||||
#include "td/telegram/BusinessRecipients.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
|
||||
@ -107,7 +107,7 @@ telegram_api::object_ptr<telegram_api::inputBusinessRecipients> BusinessRecipien
|
||||
}
|
||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : user_ids_) {
|
||||
auto r_input_user = td->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td->user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_ok()) {
|
||||
input_users.push_back(r_input_user.move_as_ok());
|
||||
}
|
||||
@ -140,7 +140,7 @@ BusinessRecipients::get_input_business_bot_recipients(Td *td) const {
|
||||
}
|
||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : user_ids_) {
|
||||
auto r_input_user = td->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td->user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_ok()) {
|
||||
input_users.push_back(r_input_user.move_as_ok());
|
||||
}
|
||||
@ -150,7 +150,7 @@ BusinessRecipients::get_input_business_bot_recipients(Td *td) const {
|
||||
}
|
||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> excluded_input_users;
|
||||
for (auto user_id : excluded_user_ids_) {
|
||||
auto r_input_user = td->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td->user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_ok()) {
|
||||
excluded_input_users.push_back(r_input_user.move_as_ok());
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
//
|
||||
#include "td/telegram/CallActor.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DhCache.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
@ -19,6 +18,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/as.h"
|
||||
@ -504,7 +504,7 @@ void CallActor::update_call(tl_object_ptr<telegram_api::PhoneCall> call) {
|
||||
|
||||
void CallActor::update_call_inner(tl_object_ptr<telegram_api::phone_phoneCall> call) {
|
||||
LOG(INFO) << "Update call with " << to_string(call);
|
||||
send_closure(G()->contacts_manager(), &ContactsManager::on_get_users, std::move(call->users_), "UpdatePhoneCall");
|
||||
send_closure(G()->user_manager(), &UserManager::on_get_users, std::move(call->users_), "UpdatePhoneCall");
|
||||
update_call(std::move(call->phone_call_));
|
||||
}
|
||||
|
||||
@ -921,7 +921,7 @@ void CallActor::flush_call_state() {
|
||||
call_state_need_flush_ = false;
|
||||
|
||||
// TODO can't call const function
|
||||
// send_closure(G()->contacts_manager(), &ContactsManager::get_user_id_object, user_id_, "flush_call_state");
|
||||
// send_closure(G()->user_manager(), &UserManager::get_user_id_object, user_id_, "flush_call_state");
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateCall>(make_tl_object<td_api::call>(
|
||||
local_call_id_.get(), is_outgoing_ ? user_id_.get() : call_admin_user_id_.get(), is_outgoing_,
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/InlineQueriesManager.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
|
||||
@ -174,7 +174,7 @@ void CallbackQueriesManager::on_new_query(int32 flags, int64 callback_query_id,
|
||||
LOG(ERROR) << "Receive new callback query from invalid " << sender_user_id << " in " << dialog_id;
|
||||
return;
|
||||
}
|
||||
LOG_IF(ERROR, !td_->contacts_manager_->have_user(sender_user_id)) << "Receive unknown " << sender_user_id;
|
||||
LOG_IF(ERROR, !td_->user_manager_->have_user(sender_user_id)) << "Receive unknown " << sender_user_id;
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
LOG(ERROR) << "Receive new callback query";
|
||||
return;
|
||||
@ -191,10 +191,9 @@ void CallbackQueriesManager::on_new_query(int32 flags, int64 callback_query_id,
|
||||
}
|
||||
|
||||
td_->dialog_manager_->force_create_dialog(dialog_id, "on_new_callback_query", true);
|
||||
send_closure(
|
||||
G()->td(), &Td::send_update,
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
td_api::make_object<td_api::updateNewCallbackQuery>(
|
||||
callback_query_id, td_->contacts_manager_->get_user_id_object(sender_user_id, "updateNewCallbackQuery"),
|
||||
callback_query_id, td_->user_manager_->get_user_id_object(sender_user_id, "updateNewCallbackQuery"),
|
||||
td_->dialog_manager_->get_chat_id_object(dialog_id, "updateNewCallbackQuery"), message_id.get(),
|
||||
chat_instance, std::move(payload)));
|
||||
}
|
||||
@ -207,7 +206,7 @@ void CallbackQueriesManager::on_new_inline_query(
|
||||
LOG(ERROR) << "Receive new callback query from invalid " << sender_user_id;
|
||||
return;
|
||||
}
|
||||
LOG_IF(ERROR, !td_->contacts_manager_->have_user(sender_user_id)) << "Receive unknown " << sender_user_id;
|
||||
LOG_IF(ERROR, !td_->user_manager_->have_user(sender_user_id)) << "Receive unknown " << sender_user_id;
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
LOG(ERROR) << "Receive new callback query";
|
||||
return;
|
||||
@ -221,7 +220,7 @@ void CallbackQueriesManager::on_new_inline_query(
|
||||
send_closure(
|
||||
G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateNewInlineCallbackQuery>(
|
||||
callback_query_id, td_->contacts_manager_->get_user_id_object(sender_user_id, "updateNewInlineCallbackQuery"),
|
||||
callback_query_id, td_->user_manager_->get_user_id_object(sender_user_id, "updateNewInlineCallbackQuery"),
|
||||
InlineQueriesManager::get_inline_message_id(std::move(inline_message_id)), chat_instance,
|
||||
std::move(payload)));
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -94,13 +95,13 @@ void CommonDialogManager::drop_common_dialogs_cache(UserId user_id) {
|
||||
std::pair<int32, vector<DialogId>> CommonDialogManager::get_common_dialogs(UserId user_id, DialogId offset_dialog_id,
|
||||
int32 limit, bool force,
|
||||
Promise<Unit> &&promise) {
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
promise.set_error(r_input_user.move_as_error());
|
||||
return {};
|
||||
}
|
||||
|
||||
if (user_id == td_->contacts_manager_->get_my_id()) {
|
||||
if (user_id == td_->user_manager_->get_my_id()) {
|
||||
promise.set_error(Status::Error(400, "Can't get common chats with self"));
|
||||
return {};
|
||||
}
|
||||
@ -178,7 +179,7 @@ std::pair<int32, vector<DialogId>> CommonDialogManager::get_common_dialogs(UserI
|
||||
void CommonDialogManager::on_get_common_dialogs(UserId user_id, int64 offset_chat_id,
|
||||
vector<tl_object_ptr<telegram_api::Chat>> &&chats, int32 total_count) {
|
||||
CHECK(user_id.is_valid());
|
||||
td_->contacts_manager_->on_update_user_common_chat_count(user_id, total_count);
|
||||
td_->user_manager_->on_update_user_common_chat_count(user_id, total_count);
|
||||
|
||||
auto &common_dialogs = found_common_dialogs_[user_id];
|
||||
if (common_dialogs.is_outdated && offset_chat_id == 0 &&
|
||||
@ -213,7 +214,7 @@ void CommonDialogManager::on_get_common_dialogs(UserId user_id, int64 offset_cha
|
||||
LOG(ERROR) << "Fix total count of common groups with " << user_id << " from " << total_count << " to "
|
||||
<< result.size();
|
||||
total_count = narrow_cast<int32>(result.size());
|
||||
td_->contacts_manager_->on_update_user_common_chat_count(user_id, total_count);
|
||||
td_->user_manager_->on_update_user_common_chat_count(user_id, total_count);
|
||||
}
|
||||
|
||||
result.emplace_back();
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ConnectionState.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/JsonValue.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
@ -32,6 +31,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/TranscriptionManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/mtproto/AuthData.h"
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
@ -1502,7 +1502,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
int32 dialog_filter_update_period = 300;
|
||||
// bool archive_all_stories = false;
|
||||
int32 story_viewers_expire_period = 86400;
|
||||
int64 stories_changelog_user_id = ContactsManager::get_service_notifications_user_id().get();
|
||||
int64 stories_changelog_user_id = UserManager::get_service_notifications_user_id().get();
|
||||
int32 transcribe_audio_trial_weekly_number = 0;
|
||||
int32 transcribe_audio_trial_duration_max = 0;
|
||||
int32 transcribe_audio_trial_cooldown_until = 0;
|
||||
@ -2173,7 +2173,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
} else {
|
||||
options.set_option_empty("gift_premium_from_input_field");
|
||||
}
|
||||
if (stories_changelog_user_id != ContactsManager::get_service_notifications_user_id().get()) {
|
||||
if (stories_changelog_user_id != UserManager::get_service_notifications_user_id().get()) {
|
||||
options.set_option_integer("stories_changelog_user_id", stories_changelog_user_id);
|
||||
} else {
|
||||
options.set_option_empty("stories_changelog_user_id");
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/StoryManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/WebPagesManager.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
@ -92,7 +93,7 @@ void Dependencies::add_message_sender_dependencies(DialogId dialog_id) {
|
||||
bool Dependencies::resolve_force(Td *td, const char *source, bool ignore_errors) const {
|
||||
bool success = true;
|
||||
for (auto user_id : user_ids) {
|
||||
if (!td->contacts_manager_->have_user_force(user_id, source)) {
|
||||
if (!td->user_manager_->have_user_force(user_id, source)) {
|
||||
if (!ignore_errors) {
|
||||
LOG(ERROR) << "Can't find " << user_id << " from " << source;
|
||||
}
|
||||
@ -120,7 +121,7 @@ bool Dependencies::resolve_force(Td *td, const char *source, bool ignore_errors)
|
||||
}
|
||||
}
|
||||
for (auto secret_chat_id : secret_chat_ids) {
|
||||
if (!td->contacts_manager_->have_secret_chat_force(secret_chat_id, source)) {
|
||||
if (!td->user_manager_->have_secret_chat_force(secret_chat_id, source)) {
|
||||
if (!ignore_errors) {
|
||||
LOG(ERROR) << "Can't find " << secret_chat_id << " from " << source;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
@ -113,9 +114,9 @@ void DialogActionBar::fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, Fo
|
||||
}
|
||||
if (dialog_type == DialogType::User) {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
bool is_me = user_id == td->contacts_manager_->get_my_id();
|
||||
bool is_deleted = td->contacts_manager_->is_user_deleted(user_id);
|
||||
bool is_contact = td->contacts_manager_->is_user_contact(user_id);
|
||||
bool is_me = user_id == td->user_manager_->get_my_id();
|
||||
bool is_deleted = td->user_manager_->is_user_deleted(user_id);
|
||||
bool is_contact = td->user_manager_->is_user_contact(user_id);
|
||||
if (is_me || is_dialog_blocked) {
|
||||
can_report_spam_ = false;
|
||||
can_unarchive_ = false;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/BusinessConnectionManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/MessageSender.h"
|
||||
@ -21,6 +20,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/emoji.h"
|
||||
@ -180,7 +180,7 @@ void DialogActionManager::on_dialog_action(DialogId dialog_id, MessageId top_thr
|
||||
}
|
||||
|
||||
if (typing_dialog_type == DialogType::User) {
|
||||
if (!td_->contacts_manager_->have_min_user(typing_dialog_id.get_user_id())) {
|
||||
if (!td_->user_manager_->have_min_user(typing_dialog_id.get_user_id())) {
|
||||
LOG(DEBUG) << "Ignore " << action << " of unknown " << typing_dialog_id.get_user_id();
|
||||
return;
|
||||
}
|
||||
@ -198,13 +198,13 @@ void DialogActionManager::on_dialog_action(DialogId dialog_id, MessageId top_thr
|
||||
|
||||
bool is_canceled = action == DialogAction();
|
||||
if ((!is_canceled || message_content_type != MessageContentType::None) && typing_dialog_type == DialogType::User) {
|
||||
td_->contacts_manager_->on_update_user_local_was_online(typing_dialog_id.get_user_id(), date);
|
||||
td_->user_manager_->on_update_user_local_was_online(typing_dialog_id.get_user_id(), date);
|
||||
}
|
||||
|
||||
if (dialog_type == DialogType::User || dialog_type == DialogType::SecretChat) {
|
||||
CHECK(typing_dialog_type == DialogType::User);
|
||||
auto user_id = typing_dialog_id.get_user_id();
|
||||
if (!td_->contacts_manager_->is_user_bot(user_id) && !td_->contacts_manager_->is_user_status_exact(user_id) &&
|
||||
if (!td_->user_manager_->is_user_bot(user_id) && !td_->user_manager_->is_user_status_exact(user_id) &&
|
||||
!td_->messages_manager_->is_dialog_opened(dialog_id) && !is_canceled) {
|
||||
return;
|
||||
}
|
||||
@ -225,8 +225,7 @@ void DialogActionManager::on_dialog_action(DialogId dialog_id, MessageId top_thr
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(typing_dialog_type == DialogType::User &&
|
||||
td_->contacts_manager_->is_user_bot(typing_dialog_id.get_user_id())) &&
|
||||
if (!(typing_dialog_type == DialogType::User && td_->user_manager_->is_user_bot(typing_dialog_id.get_user_id())) &&
|
||||
!it->action.is_canceled_by_message_of_type(message_content_type)) {
|
||||
return;
|
||||
}
|
||||
|
@ -6,16 +6,16 @@
|
||||
//
|
||||
#include "td/telegram/DialogAdministrator.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
td_api::object_ptr<td_api::chatAdministrator> DialogAdministrator::get_chat_administrator_object(
|
||||
const ContactsManager *contacts_manager) const {
|
||||
CHECK(contacts_manager != nullptr);
|
||||
const UserManager *user_manager) const {
|
||||
CHECK(user_manager != nullptr);
|
||||
CHECK(user_id_.is_valid());
|
||||
return td_api::make_object<td_api::chatAdministrator>(
|
||||
contacts_manager->get_user_id_object(user_id_, "get_chat_administrator_object"), rank_, is_creator_);
|
||||
user_manager->get_user_id_object(user_id_, "get_chat_administrator_object"), rank_, is_creator_);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const DialogAdministrator &administrator) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class ContactsManager;
|
||||
class UserManager;
|
||||
|
||||
class DialogAdministrator {
|
||||
UserId user_id_;
|
||||
@ -31,8 +31,7 @@ class DialogAdministrator {
|
||||
: user_id_(user_id), rank_(rank), is_creator_(is_creator) {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatAdministrator> get_chat_administrator_object(
|
||||
const ContactsManager *contacts_manager) const;
|
||||
td_api::object_ptr<td_api::chatAdministrator> get_chat_administrator_object(const UserManager *user_manager) const;
|
||||
|
||||
UserId get_user_id() const {
|
||||
return user_id_;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -54,7 +55,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberJoinedByInviteLink>(
|
||||
invite_link.get_chat_invite_link_object(td->contacts_manager_.get()), action->via_chatlist_);
|
||||
invite_link.get_chat_invite_link_object(td->user_manager_.get()), action->via_chatlist_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoinByRequest::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByRequest>(action_ptr);
|
||||
@ -65,8 +66,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberJoinedByRequest>(
|
||||
td->contacts_manager_->get_user_id_object(approver_user_id, "chatEventMemberJoinedByRequest"),
|
||||
invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
td->user_manager_->get_user_id_object(approver_user_id, "chatEventMemberJoinedByRequest"),
|
||||
invite_link.get_chat_invite_link_object(td->user_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantLeave::ID:
|
||||
return td_api::make_object<td_api::chatEventMemberLeft>();
|
||||
@ -79,8 +80,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberInvited>(
|
||||
td->contacts_manager_->get_user_id_object(dialog_participant.dialog_id_.get_user_id(),
|
||||
"chatEventMemberInvited"),
|
||||
td->user_manager_->get_user_id_object(dialog_participant.dialog_id_.get_user_id(), "chatEventMemberInvited"),
|
||||
dialog_participant.status_.get_chat_member_status_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantToggleBan::ID: {
|
||||
@ -116,7 +116,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberPromoted>(
|
||||
td->contacts_manager_->get_user_id_object(old_dialog_participant.dialog_id_.get_user_id(),
|
||||
td->user_manager_->get_user_id_object(old_dialog_participant.dialog_id_.get_user_id(),
|
||||
"chatEventMemberPromoted"),
|
||||
old_dialog_participant.status_.get_chat_member_status_object(),
|
||||
new_dialog_participant.status_.get_chat_member_status_object());
|
||||
@ -281,8 +281,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventInviteLinkEdited>(
|
||||
old_invite_link.get_chat_invite_link_object(td->contacts_manager_.get()),
|
||||
new_invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
old_invite_link.get_chat_invite_link_object(td->user_manager_.get()),
|
||||
new_invite_link.get_chat_invite_link_object(td->user_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteRevoke::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteRevoke>(action_ptr);
|
||||
@ -292,7 +292,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventInviteLinkRevoked>(
|
||||
invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
invite_link.get_chat_invite_link_object(td->user_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteDelete::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteDelete>(action_ptr);
|
||||
@ -302,7 +302,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventInviteLinkDeleted>(
|
||||
invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
invite_link.get_chat_invite_link_object(td->user_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionStartGroupCall::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionStartGroupCall>(action_ptr);
|
||||
@ -513,7 +513,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
|
||||
|
||||
auto events = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive in " << channel_id_ << ' ' << to_string(events);
|
||||
td_->contacts_manager_->on_get_users(std::move(events->users_), "on_get_event_log");
|
||||
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");
|
||||
|
||||
auto anti_spam_user_id = UserId(G()->get_option_integer("anti_spam_bot_user_id"));
|
||||
@ -530,7 +530,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
|
||||
LOG(ERROR) << "Receive invalid " << user_id;
|
||||
continue;
|
||||
}
|
||||
LOG_IF(ERROR, !td_->contacts_manager_->have_user(user_id)) << "Receive unknown " << user_id;
|
||||
LOG_IF(ERROR, !td_->user_manager_->have_user(user_id)) << "Receive unknown " << user_id;
|
||||
|
||||
DialogId actor_dialog_id;
|
||||
auto action = get_chat_event_action_object(td_, channel_id_, std::move(event->action_), actor_dialog_id);
|
||||
@ -541,7 +541,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
|
||||
action->get_id() == td_api::chatEventMessageDeleted::ID) {
|
||||
static_cast<td_api::chatEventMessageDeleted *>(action.get())->can_report_anti_spam_false_positive_ = true;
|
||||
}
|
||||
if (user_id == ContactsManager::get_channel_bot_user_id() && actor_dialog_id.is_valid() &&
|
||||
if (user_id == UserManager::get_channel_bot_user_id() && actor_dialog_id.is_valid() &&
|
||||
actor_dialog_id.get_type() != DialogType::User) {
|
||||
user_id = UserId();
|
||||
} else {
|
||||
@ -641,7 +641,7 @@ void get_dialog_event_log(Td *td, DialogId dialog_id, const string &query, int64
|
||||
|
||||
vector<tl_object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : user_ids) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, td->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td->user_manager_->get_input_user(user_id));
|
||||
input_users.push_back(std::move(input_user));
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/emoji.h"
|
||||
@ -692,16 +693,14 @@ void DialogFilter::sort_input_dialog_ids(const Td *td, const char *source) {
|
||||
excluded_dialog_ids_.clear();
|
||||
}
|
||||
|
||||
auto sort_input_dialog_ids = [contacts_manager =
|
||||
td->contacts_manager_.get()](vector<InputDialogId> &input_dialog_ids) {
|
||||
std::sort(input_dialog_ids.begin(), input_dialog_ids.end(),
|
||||
[contacts_manager](InputDialogId lhs, InputDialogId rhs) {
|
||||
auto get_order = [contacts_manager](InputDialogId input_dialog_id) {
|
||||
auto sort_input_dialog_ids = [user_manager = td->user_manager_.get()](vector<InputDialogId> &input_dialog_ids) {
|
||||
std::sort(input_dialog_ids.begin(), input_dialog_ids.end(), [user_manager](InputDialogId lhs, InputDialogId rhs) {
|
||||
auto get_order = [user_manager](InputDialogId input_dialog_id) {
|
||||
auto dialog_id = input_dialog_id.get_dialog_id();
|
||||
if (dialog_id.get_type() != DialogType::SecretChat) {
|
||||
return dialog_id.get() * 10;
|
||||
}
|
||||
auto user_id = contacts_manager->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
auto user_id = user_manager->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
return DialogId(user_id).get() * 10 + 1;
|
||||
};
|
||||
return get_order(lhs) < get_order(rhs);
|
||||
@ -773,7 +772,7 @@ bool DialogFilter::need_dialog(const Td *td, const DialogFilterDialogInfo &dialo
|
||||
return false;
|
||||
}
|
||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
||||
auto user_id = td->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
auto user_id = td->user_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
if (user_id.is_valid()) {
|
||||
auto user_dialog_id = DialogId(user_id);
|
||||
if (is_dialog_included(user_dialog_id)) {
|
||||
@ -798,10 +797,10 @@ bool DialogFilter::need_dialog(const Td *td, const DialogFilterDialogInfo &dialo
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
if (td->contacts_manager_->is_user_bot(user_id)) {
|
||||
if (td->user_manager_->is_user_bot(user_id)) {
|
||||
return include_bots_;
|
||||
}
|
||||
if (user_id == td->contacts_manager_->get_my_id() || td->contacts_manager_->is_user_contact(user_id)) {
|
||||
if (user_id == td->user_manager_->get_my_id() || td->user_manager_->is_user_contact(user_id)) {
|
||||
return include_contacts_;
|
||||
}
|
||||
return include_non_contacts_;
|
||||
@ -812,11 +811,11 @@ bool DialogFilter::need_dialog(const Td *td, const DialogFilterDialogInfo &dialo
|
||||
return td->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id()) ? include_channels_
|
||||
: include_groups_;
|
||||
case DialogType::SecretChat: {
|
||||
auto user_id = td->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
if (td->contacts_manager_->is_user_bot(user_id)) {
|
||||
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)) {
|
||||
return include_bots_;
|
||||
}
|
||||
if (td->contacts_manager_->is_user_contact(user_id)) {
|
||||
if (td->user_manager_->is_user_contact(user_id)) {
|
||||
return include_contacts_;
|
||||
}
|
||||
return include_non_contacts_;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/Version.h"
|
||||
|
||||
#include "td/actor/MultiPromise.h"
|
||||
@ -207,7 +208,7 @@ class GetExportedChatlistInvitesQuery final : public Td::ResultHandler {
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetExportedChatlistInvitesQuery: " << to_string(ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetExportedChatlistInvitesQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetExportedChatlistInvitesQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetExportedChatlistInvitesQuery");
|
||||
auto result = td_api::make_object<td_api::chatFolderInviteLinks>();
|
||||
for (auto &invite : ptr->invites_) {
|
||||
@ -424,7 +425,7 @@ class GetChatlistUpdatesQuery final : public Td::ResultHandler {
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetChatlistUpdatesQuery: " << to_string(ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetChatlistUpdatesQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetChatlistUpdatesQuery");
|
||||
td_->contacts_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"));
|
||||
@ -517,7 +518,7 @@ class GetDialogsQuery final : public Td::ResultHandler {
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetDialogsQuery: " << to_string(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetDialogsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetDialogsQuery");
|
||||
td_->contacts_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_));
|
||||
@ -2130,7 +2131,7 @@ void DialogFilterManager::on_get_chatlist_invite(
|
||||
break;
|
||||
}
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(users), "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");
|
||||
|
||||
auto missing_dialog_ids = td_->dialog_manager_->get_peers_dialog_ids(std::move(missing_peers), true);
|
||||
|
@ -6,8 +6,8 @@
|
||||
//
|
||||
#include "td/telegram/DialogInviteLink.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
@ -99,15 +99,15 @@ bool DialogInviteLink::is_valid_invite_link(Slice invite_link, bool allow_trunca
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatInviteLink> DialogInviteLink::get_chat_invite_link_object(
|
||||
const ContactsManager *contacts_manager) const {
|
||||
CHECK(contacts_manager != nullptr);
|
||||
const UserManager *user_manager) const {
|
||||
CHECK(user_manager != nullptr);
|
||||
if (!is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return td_api::make_object<td_api::chatInviteLink>(
|
||||
invite_link_, title_, contacts_manager->get_user_id_object(creator_user_id_, "get_chat_invite_link_object"),
|
||||
date_, edit_date_, expire_date_, usage_limit_, usage_count_, request_count_, creates_join_request_, is_permanent_,
|
||||
invite_link_, title_, user_manager->get_user_id_object(creator_user_id_, "get_chat_invite_link_object"), date_,
|
||||
edit_date_, expire_date_, usage_limit_, usage_count_, request_count_, creates_join_request_, is_permanent_,
|
||||
is_revoked_);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class ContactsManager;
|
||||
class UserManager;
|
||||
|
||||
class DialogInviteLink {
|
||||
string invite_link_;
|
||||
@ -45,7 +45,7 @@ class DialogInviteLink {
|
||||
|
||||
static bool is_valid_invite_link(Slice invite_link, bool allow_truncated = false);
|
||||
|
||||
td_api::object_ptr<td_api::chatInviteLink> get_chat_invite_link_object(const ContactsManager *contacts_manager) const;
|
||||
td_api::object_ptr<td_api::chatInviteLink> get_chat_invite_link_object(const UserManager *user_manager) const;
|
||||
|
||||
bool is_valid() const {
|
||||
return !invite_link_.empty() && creator_user_id_.is_valid() && date_ > 0;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -151,13 +152,13 @@ class ExportChatInviteQuery final : public Td::ResultHandler {
|
||||
if (!invite_link.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
if (invite_link.get_creator_user_id() != td_->contacts_manager_->get_my_id()) {
|
||||
if (invite_link.get_creator_user_id() != td_->user_manager_->get_my_id()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link creator"));
|
||||
}
|
||||
if (invite_link.is_permanent()) {
|
||||
td_->dialog_invite_link_manager_->on_get_permanent_dialog_invite_link(dialog_id_, invite_link);
|
||||
}
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td_->user_manager_.get()));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
@ -207,13 +208,13 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler {
|
||||
|
||||
auto invite = move_tl_object_as<telegram_api::messages_exportedChatInvite>(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "EditChatInviteLinkQuery");
|
||||
td_->user_manager_->on_get_users(std::move(invite->users_), "EditChatInviteLinkQuery");
|
||||
|
||||
DialogInviteLink invite_link(std::move(invite->invite_), false, "EditChatInviteLinkQuery");
|
||||
if (!invite_link.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td_->user_manager_.get()));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
@ -256,14 +257,14 @@ class GetExportedChatInviteQuery final : public Td::ResultHandler {
|
||||
auto result = move_tl_object_as<telegram_api::messages_exportedChatInvite>(result_ptr.ok_ref());
|
||||
LOG(INFO) << "Receive result for GetExportedChatInviteQuery: " << to_string(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInviteQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetExportedChatInviteQuery");
|
||||
|
||||
DialogInviteLink invite_link(std::move(result->invite_), false, "GetExportedChatInviteQuery");
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid invite link in " << dialog_id_;
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td_->user_manager_.get()));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
@ -311,7 +312,7 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler {
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetExportedChatInvitesQuery: " << to_string(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInvitesQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetExportedChatInvitesQuery");
|
||||
|
||||
int32 total_count = result->count_;
|
||||
if (total_count < static_cast<int32>(result->invites_.size())) {
|
||||
@ -326,7 +327,7 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler {
|
||||
total_count--;
|
||||
continue;
|
||||
}
|
||||
invite_links.push_back(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
invite_links.push_back(invite_link.get_chat_invite_link_object(td_->user_manager_.get()));
|
||||
}
|
||||
promise_.set_value(td_api::make_object<td_api::chatInviteLinks>(total_count, std::move(invite_links)));
|
||||
}
|
||||
@ -365,7 +366,7 @@ class GetChatAdminWithInvitesQuery final : public Td::ResultHandler {
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetChatAdminWithInvitesQuery: " << to_string(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetChatAdminWithInvitesQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetChatAdminWithInvitesQuery");
|
||||
|
||||
vector<td_api::object_ptr<td_api::chatInviteLinkCount>> invite_link_counts;
|
||||
for (auto &admin : result->admins_) {
|
||||
@ -375,7 +376,7 @@ class GetChatAdminWithInvitesQuery final : public Td::ResultHandler {
|
||||
continue;
|
||||
}
|
||||
invite_link_counts.push_back(td_api::make_object<td_api::chatInviteLinkCount>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "chatInviteLinkCount"), admin->invites_count_,
|
||||
td_->user_manager_->get_user_id_object(user_id, "chatInviteLinkCount"), admin->invites_count_,
|
||||
admin->revoked_invites_count_));
|
||||
}
|
||||
promise_.set_value(td_api::make_object<td_api::chatInviteLinkCounts>(std::move(invite_link_counts)));
|
||||
@ -403,7 +404,7 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler {
|
||||
return on_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(offset_user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(offset_user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
r_input_user = make_tl_object<telegram_api::inputUserEmpty>();
|
||||
}
|
||||
@ -423,7 +424,7 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler {
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetChatInviteImportersQuery: " << to_string(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetChatInviteImportersQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetChatInviteImportersQuery");
|
||||
|
||||
int32 total_count = result->count_;
|
||||
if (total_count < static_cast<int32>(result->importers_.size())) {
|
||||
@ -441,9 +442,8 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler {
|
||||
continue;
|
||||
}
|
||||
invite_link_members.push_back(td_api::make_object<td_api::chatInviteLinkMember>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "chatInviteLinkMember"), importer->date_,
|
||||
importer->via_chatlist_,
|
||||
td_->contacts_manager_->get_user_id_object(approver_user_id, "chatInviteLinkMember")));
|
||||
td_->user_manager_->get_user_id_object(user_id, "chatInviteLinkMember"), importer->date_,
|
||||
importer->via_chatlist_, td_->user_manager_->get_user_id_object(approver_user_id, "chatInviteLinkMember")));
|
||||
}
|
||||
promise_.set_value(td_api::make_object<td_api::chatInviteLinkMembers>(total_count, std::move(invite_link_members)));
|
||||
}
|
||||
@ -489,19 +489,19 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
||||
case telegram_api::messages_exportedChatInvite::ID: {
|
||||
auto invite = move_tl_object_as<telegram_api::messages_exportedChatInvite>(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery");
|
||||
td_->user_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery");
|
||||
|
||||
DialogInviteLink invite_link(std::move(invite->invite_), false, "RevokeChatInviteLinkQuery");
|
||||
if (!invite_link.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
links.push_back(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
links.push_back(invite_link.get_chat_invite_link_object(td_->user_manager_.get()));
|
||||
break;
|
||||
}
|
||||
case telegram_api::messages_exportedChatInviteReplaced::ID: {
|
||||
auto invite = move_tl_object_as<telegram_api::messages_exportedChatInviteReplaced>(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery replaced");
|
||||
td_->user_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery replaced");
|
||||
|
||||
DialogInviteLink invite_link(std::move(invite->invite_), false, "RevokeChatInviteLinkQuery replaced");
|
||||
DialogInviteLink new_invite_link(std::move(invite->new_invite_), false,
|
||||
@ -509,12 +509,12 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
||||
if (!invite_link.is_valid() || !new_invite_link.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
if (new_invite_link.get_creator_user_id() == td_->contacts_manager_->get_my_id() &&
|
||||
if (new_invite_link.get_creator_user_id() == td_->user_manager_->get_my_id() &&
|
||||
new_invite_link.is_permanent()) {
|
||||
td_->dialog_invite_link_manager_->on_get_permanent_dialog_invite_link(dialog_id_, new_invite_link);
|
||||
}
|
||||
links.push_back(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
links.push_back(new_invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
links.push_back(invite_link.get_chat_invite_link_object(td_->user_manager_.get()));
|
||||
links.push_back(new_invite_link.get_chat_invite_link_object(td_->user_manager_.get()));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -727,13 +727,13 @@ void DialogInviteLinkManager::on_get_dialog_invite_link_info(
|
||||
auto chat_invite = telegram_api::move_object_as<telegram_api::chatInvite>(chat_invite_ptr);
|
||||
vector<UserId> participant_user_ids;
|
||||
for (auto &user : chat_invite->participants_) {
|
||||
auto user_id = ContactsManager::get_user_id(user);
|
||||
auto user_id = UserManager::get_user_id(user);
|
||||
if (!user_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << user_id;
|
||||
continue;
|
||||
}
|
||||
|
||||
td_->contacts_manager_->on_get_user(std::move(user), "chatInvite");
|
||||
td_->user_manager_->on_get_user(std::move(user), "chatInvite");
|
||||
participant_user_ids.push_back(user_id);
|
||||
}
|
||||
|
||||
@ -850,7 +850,7 @@ td_api::object_ptr<td_api::chatInviteLinkInfo> DialogInviteLinkManager::get_chat
|
||||
accent_color_id_object = td_->theme_manager_->get_accent_color_id_object(invite_link_info->accent_color_id);
|
||||
description = invite_link_info->description;
|
||||
participant_count = invite_link_info->participant_count;
|
||||
member_user_ids = td_->contacts_manager_->get_user_ids_object(invite_link_info->participant_user_ids,
|
||||
member_user_ids = td_->user_manager_->get_user_ids_object(invite_link_info->participant_user_ids,
|
||||
"get_chat_invite_link_info_object");
|
||||
creates_join_request = invite_link_info->creates_join_request;
|
||||
is_public = invite_link_info->is_public;
|
||||
@ -978,7 +978,7 @@ void DialogInviteLinkManager::on_get_permanent_dialog_invite_link(DialogId dialo
|
||||
void DialogInviteLinkManager::export_dialog_invite_link(DialogId dialog_id, string title, int32 expire_date,
|
||||
int32 usage_limit, bool creates_join_request, bool is_permanent,
|
||||
Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise) {
|
||||
td_->contacts_manager_->get_me(PromiseCreator::lambda([actor_id = actor_id(this), dialog_id, title = std::move(title),
|
||||
td_->user_manager_->get_me(PromiseCreator::lambda([actor_id = actor_id(this), dialog_id, title = std::move(title),
|
||||
expire_date, usage_limit, creates_join_request, is_permanent,
|
||||
promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||
if (result.is_error()) {
|
||||
@ -1045,8 +1045,8 @@ void DialogInviteLinkManager::get_dialog_invite_links(DialogId dialog_id, UserId
|
||||
int32 offset_date, const string &offset_invite_link, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::chatInviteLinks>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise,
|
||||
can_manage_dialog_invite_links(dialog_id, creator_user_id != td_->contacts_manager_->get_my_id()));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(creator_user_id));
|
||||
can_manage_dialog_invite_links(dialog_id, creator_user_id != td_->user_manager_->get_my_id()));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(creator_user_id));
|
||||
|
||||
if (limit <= 0) {
|
||||
return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
|
||||
@ -1105,8 +1105,8 @@ void DialogInviteLinkManager::delete_revoked_dialog_invite_link(DialogId dialog_
|
||||
void DialogInviteLinkManager::delete_all_revoked_dialog_invite_links(DialogId dialog_id, UserId creator_user_id,
|
||||
Promise<Unit> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise,
|
||||
can_manage_dialog_invite_links(dialog_id, creator_user_id != td_->contacts_manager_->get_my_id()));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(creator_user_id));
|
||||
can_manage_dialog_invite_links(dialog_id, creator_user_id != td_->user_manager_->get_my_id()));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(creator_user_id));
|
||||
|
||||
td_->create_handler<DeleteRevokedExportedChatInvitesQuery>(std::move(promise))
|
||||
->send(dialog_id, std::move(input_user));
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/Usernames.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
@ -123,7 +124,7 @@ class ResolveUsernameQuery final : public Td::ResultHandler {
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for ResolveUsernameQuery: " << to_string(ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "ResolveUsernameQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "ResolveUsernameQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "ResolveUsernameQuery");
|
||||
|
||||
promise_.set_value(DialogId(ptr->peer_));
|
||||
@ -552,7 +553,7 @@ void DialogManager::tear_down() {
|
||||
}
|
||||
|
||||
DialogId DialogManager::get_my_dialog_id() const {
|
||||
return DialogId(td_->contacts_manager_->get_my_id());
|
||||
return DialogId(td_->user_manager_->get_my_id());
|
||||
}
|
||||
|
||||
InputDialogId DialogManager::get_input_dialog_id(DialogId dialog_id) const {
|
||||
@ -569,7 +570,7 @@ tl_object_ptr<telegram_api::InputPeer> DialogManager::get_input_peer(DialogId di
|
||||
AccessRights access_rights) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_input_peer_user(dialog_id.get_user_id(), access_rights);
|
||||
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);
|
||||
case DialogType::Channel:
|
||||
@ -658,7 +659,7 @@ tl_object_ptr<telegram_api::inputEncryptedChat> DialogManager::get_input_encrypt
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::SecretChat: {
|
||||
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
|
||||
return td_->contacts_manager_->get_input_encrypted_chat(secret_chat_id, access_rights);
|
||||
return td_->user_manager_->get_input_encrypted_chat(secret_chat_id, access_rights);
|
||||
}
|
||||
case DialogType::User:
|
||||
case DialogType::Chat:
|
||||
@ -674,7 +675,7 @@ bool DialogManager::have_input_peer(DialogId dialog_id, AccessRights access_righ
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
UserId user_id = dialog_id.get_user_id();
|
||||
return td_->contacts_manager_->have_input_peer_user(user_id, access_rights);
|
||||
return td_->user_manager_->have_input_peer_user(user_id, access_rights);
|
||||
}
|
||||
case DialogType::Chat: {
|
||||
ChatId chat_id = dialog_id.get_chat_id();
|
||||
@ -686,7 +687,7 @@ bool DialogManager::have_input_peer(DialogId dialog_id, AccessRights access_righ
|
||||
}
|
||||
case DialogType::SecretChat: {
|
||||
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
|
||||
return td_->contacts_manager_->have_input_encrypted_peer(secret_chat_id, access_rights);
|
||||
return td_->user_manager_->have_input_encrypted_peer(secret_chat_id, access_rights);
|
||||
}
|
||||
case DialogType::None:
|
||||
return false;
|
||||
@ -723,7 +724,7 @@ bool DialogManager::have_dialog_info(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
UserId user_id = dialog_id.get_user_id();
|
||||
return td_->contacts_manager_->have_user(user_id);
|
||||
return td_->user_manager_->have_user(user_id);
|
||||
}
|
||||
case DialogType::Chat: {
|
||||
ChatId chat_id = dialog_id.get_chat_id();
|
||||
@ -735,7 +736,7 @@ bool DialogManager::have_dialog_info(DialogId dialog_id) const {
|
||||
}
|
||||
case DialogType::SecretChat: {
|
||||
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
|
||||
return td_->contacts_manager_->have_secret_chat(secret_chat_id);
|
||||
return td_->user_manager_->have_secret_chat(secret_chat_id);
|
||||
}
|
||||
case DialogType::None:
|
||||
default:
|
||||
@ -746,7 +747,7 @@ bool DialogManager::have_dialog_info(DialogId dialog_id) const {
|
||||
bool DialogManager::is_dialog_info_received_from_server(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->is_user_received_from_server(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
@ -760,7 +761,7 @@ bool DialogManager::have_dialog_info_force(DialogId dialog_id, const char *sourc
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
UserId user_id = dialog_id.get_user_id();
|
||||
return td_->contacts_manager_->have_user_force(user_id, source);
|
||||
return td_->user_manager_->have_user_force(user_id, source);
|
||||
}
|
||||
case DialogType::Chat: {
|
||||
ChatId chat_id = dialog_id.get_chat_id();
|
||||
@ -772,7 +773,7 @@ bool DialogManager::have_dialog_info_force(DialogId dialog_id, const char *sourc
|
||||
}
|
||||
case DialogType::SecretChat: {
|
||||
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
|
||||
return td_->contacts_manager_->have_secret_chat_force(secret_chat_id, source);
|
||||
return td_->user_manager_->have_secret_chat_force(secret_chat_id, source);
|
||||
}
|
||||
case DialogType::None:
|
||||
default:
|
||||
@ -783,7 +784,7 @@ bool DialogManager::have_dialog_info_force(DialogId dialog_id, const char *sourc
|
||||
void DialogManager::reload_dialog_info(DialogId dialog_id, Promise<Unit> &&promise) {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->reload_user(dialog_id.get_user_id(), std::move(promise), "reload_dialog_info");
|
||||
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");
|
||||
case DialogType::Channel:
|
||||
@ -797,7 +798,7 @@ void DialogManager::reload_dialog_info(DialogId dialog_id, Promise<Unit> &&promi
|
||||
void DialogManager::get_dialog_info_full(DialogId dialog_id, Promise<Unit> &&promise, const char *source) {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::load_user_full, dialog_id.get_user_id(), false,
|
||||
send_closure_later(td_->user_manager_actor_, &UserManager::load_user_full, dialog_id.get_user_id(), false,
|
||||
std::move(promise), source);
|
||||
return;
|
||||
case DialogType::Chat:
|
||||
@ -825,7 +826,7 @@ void DialogManager::reload_dialog_info_full(DialogId dialog_id, const char *sour
|
||||
LOG(INFO) << "Reload full info about " << dialog_id << " from " << source;
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_user_full, dialog_id.get_user_id(),
|
||||
send_closure_later(td_->user_manager_actor_, &UserManager::reload_user_full, dialog_id.get_user_id(),
|
||||
Promise<Unit>(), source);
|
||||
return;
|
||||
case DialogType::Chat:
|
||||
@ -876,7 +877,7 @@ td_api::object_ptr<td_api::ChatType> DialogManager::get_chat_type_object(DialogI
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_api::make_object<td_api::chatTypePrivate>(
|
||||
td_->contacts_manager_->get_user_id_object(dialog_id.get_user_id(), source));
|
||||
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));
|
||||
@ -888,10 +889,10 @@ td_api::object_ptr<td_api::ChatType> DialogManager::get_chat_type_object(DialogI
|
||||
}
|
||||
case DialogType::SecretChat: {
|
||||
auto secret_chat_id = dialog_id.get_secret_chat_id();
|
||||
auto user_id = td_->contacts_manager_->get_secret_chat_user_id(secret_chat_id);
|
||||
auto user_id = td_->user_manager_->get_secret_chat_user_id(secret_chat_id);
|
||||
return td_api::make_object<td_api::chatTypeSecret>(
|
||||
td_->contacts_manager_->get_secret_chat_id_object(secret_chat_id, source),
|
||||
td_->contacts_manager_->get_user_id_object(user_id, source));
|
||||
td_->user_manager_->get_secret_chat_id_object(secret_chat_id, source),
|
||||
td_->user_manager_->get_user_id_object(user_id, source));
|
||||
}
|
||||
case DialogType::None:
|
||||
default:
|
||||
@ -1066,13 +1067,13 @@ void DialogManager::delete_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
|
||||
string DialogManager::get_dialog_title(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_title(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_title(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_title(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_title(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1083,13 +1084,13 @@ string DialogManager::get_dialog_title(DialogId dialog_id) const {
|
||||
const DialogPhoto *DialogManager::get_dialog_photo(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_dialog_photo(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_dialog_photo(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_dialog_photo(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_dialog_photo(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1100,13 +1101,13 @@ const DialogPhoto *DialogManager::get_dialog_photo(DialogId dialog_id) const {
|
||||
int32 DialogManager::get_dialog_accent_color_id_object(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_accent_color_id_object(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_accent_color_id_object(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_accent_color_id_object(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_accent_color_id_object(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1117,13 +1118,13 @@ int32 DialogManager::get_dialog_accent_color_id_object(DialogId dialog_id) const
|
||||
CustomEmojiId DialogManager::get_dialog_background_custom_emoji_id(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_background_custom_emoji_id(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_background_custom_emoji_id(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_background_custom_emoji_id(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_background_custom_emoji_id(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1134,13 +1135,13 @@ CustomEmojiId DialogManager::get_dialog_background_custom_emoji_id(DialogId dial
|
||||
int32 DialogManager::get_dialog_profile_accent_color_id_object(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_profile_accent_color_id_object(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_profile_accent_color_id_object(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_profile_accent_color_id_object(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_profile_accent_color_id_object(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1151,13 +1152,13 @@ int32 DialogManager::get_dialog_profile_accent_color_id_object(DialogId dialog_i
|
||||
CustomEmojiId DialogManager::get_dialog_profile_background_custom_emoji_id(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_profile_background_custom_emoji_id(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_profile_background_custom_emoji_id(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_profile_background_custom_emoji_id(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_profile_background_custom_emoji_id(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1168,13 +1169,13 @@ CustomEmojiId DialogManager::get_dialog_profile_background_custom_emoji_id(Dialo
|
||||
RestrictedRights DialogManager::get_dialog_default_permissions(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_default_permissions(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_default_permissions(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1186,13 +1187,13 @@ RestrictedRights DialogManager::get_dialog_default_permissions(DialogId dialog_i
|
||||
td_api::object_ptr<td_api::emojiStatus> DialogManager::get_dialog_emoji_status_object(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_emoji_status_object(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_emoji_status_object(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_emoji_status_object(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_emoji_status_object(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1203,13 +1204,13 @@ td_api::object_ptr<td_api::emojiStatus> DialogManager::get_dialog_emoji_status_o
|
||||
string DialogManager::get_dialog_about(DialogId dialog_id) {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_about(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_about(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_about(dialog_id.get_secret_chat_id());
|
||||
return td_->user_manager_->get_secret_chat_about(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1220,14 +1221,14 @@ string DialogManager::get_dialog_about(DialogId dialog_id) {
|
||||
string DialogManager::get_dialog_search_text(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_search_text(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_search_text(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_user_search_text(
|
||||
td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()));
|
||||
return td_->user_manager_->get_user_search_text(
|
||||
td_->user_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()));
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1261,20 +1262,20 @@ bool DialogManager::is_dialog_action_unneeded(DialogId dialog_id) const {
|
||||
if (dialog_type == DialogType::User || dialog_type == DialogType::SecretChat) {
|
||||
UserId user_id = dialog_type == DialogType::User
|
||||
? dialog_id.get_user_id()
|
||||
: td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
if (td_->contacts_manager_->is_user_deleted(user_id)) {
|
||||
: td_->user_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
if (td_->user_manager_->is_user_deleted(user_id)) {
|
||||
return true;
|
||||
}
|
||||
if (td_->contacts_manager_->is_user_bot(user_id) && !td_->contacts_manager_->is_user_support(user_id)) {
|
||||
if (td_->user_manager_->is_user_bot(user_id) && !td_->user_manager_->is_user_support(user_id)) {
|
||||
return true;
|
||||
}
|
||||
if (user_id == td_->contacts_manager_->get_my_id()) {
|
||||
if (user_id == td_->user_manager_->get_my_id()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
if (td_->contacts_manager_->is_user_status_exact(user_id)) {
|
||||
if (!td_->contacts_manager_->is_user_online(user_id, 30)) {
|
||||
if (td_->user_manager_->is_user_status_exact(user_id)) {
|
||||
if (!td_->user_manager_->is_user_online(user_id, 30)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
@ -1369,7 +1370,7 @@ void DialogManager::set_dialog_photo(DialogId dialog_id, const td_api::object_pt
|
||||
switch (input_photo->get_id()) {
|
||||
case td_api::inputChatPhotoPrevious::ID: {
|
||||
auto photo = static_cast<const td_api::inputChatPhotoPrevious *>(input_photo.get());
|
||||
auto file_id = td_->contacts_manager_->get_profile_photo_file_id(photo->chat_photo_id_);
|
||||
auto file_id = td_->user_manager_->get_profile_photo_file_id(photo->chat_photo_id_);
|
||||
if (!file_id.is_valid()) {
|
||||
return promise.set_error(Status::Error(400, "Unknown profile photo ID specified"));
|
||||
}
|
||||
@ -1545,8 +1546,7 @@ void DialogManager::set_dialog_accent_color(DialogId dialog_id, AccentColorId ac
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
if (dialog_id == get_my_dialog_id()) {
|
||||
return td_->contacts_manager_->set_accent_color(accent_color_id, background_custom_emoji_id,
|
||||
std::move(promise));
|
||||
return td_->user_manager_->set_accent_color(accent_color_id, background_custom_emoji_id, std::move(promise));
|
||||
}
|
||||
break;
|
||||
case DialogType::Chat:
|
||||
@ -1573,8 +1573,8 @@ void DialogManager::set_dialog_profile_accent_color(DialogId dialog_id, AccentCo
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
if (dialog_id == get_my_dialog_id()) {
|
||||
return td_->contacts_manager_->set_profile_accent_color(profile_accent_color_id,
|
||||
profile_background_custom_emoji_id, std::move(promise));
|
||||
return td_->user_manager_->set_profile_accent_color(profile_accent_color_id, profile_background_custom_emoji_id,
|
||||
std::move(promise));
|
||||
}
|
||||
break;
|
||||
case DialogType::Chat:
|
||||
@ -1655,7 +1655,7 @@ void DialogManager::set_dialog_emoji_status(DialogId dialog_id, const EmojiStatu
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
if (dialog_id == get_my_dialog_id()) {
|
||||
return td_->contacts_manager_->set_emoji_status(emoji_status, std::move(promise));
|
||||
return td_->user_manager_->set_emoji_status(emoji_status, std::move(promise));
|
||||
}
|
||||
break;
|
||||
case DialogType::Chat:
|
||||
@ -1757,7 +1757,7 @@ bool DialogManager::can_report_dialog(DialogId dialog_id) const {
|
||||
// doesn't include possibility of report from action bar
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->can_report_user(dialog_id.get_user_id());
|
||||
return td_->user_manager_->can_report_user(dialog_id.get_user_id());
|
||||
case DialogType::Chat:
|
||||
return false;
|
||||
case DialogType::Channel:
|
||||
@ -1914,8 +1914,8 @@ void DialogManager::on_update_dialog_bot_commands(
|
||||
LOG(ERROR) << "Receive updateBotCommands about invalid " << bot_user_id;
|
||||
return;
|
||||
}
|
||||
if (!td_->contacts_manager_->have_user_force(bot_user_id, "on_update_dialog_bot_commands") ||
|
||||
!td_->contacts_manager_->is_user_bot(bot_user_id)) {
|
||||
if (!td_->user_manager_->have_user_force(bot_user_id, "on_update_dialog_bot_commands") ||
|
||||
!td_->user_manager_->is_user_bot(bot_user_id)) {
|
||||
return;
|
||||
}
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
@ -1928,7 +1928,7 @@ void DialogManager::on_update_dialog_bot_commands(
|
||||
LOG(ERROR) << "Receive commands of " << bot_user_id << " in " << dialog_id;
|
||||
return;
|
||||
}
|
||||
return td_->contacts_manager_->on_update_user_commands(bot_user_id, std::move(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)));
|
||||
|
@ -6,10 +6,10 @@
|
||||
//
|
||||
#include "td/telegram/DialogParticipantFilter.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/DialogParticipant.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
@ -119,7 +119,7 @@ bool DialogParticipantFilter::is_dialog_participant_suitable(const Td *td, const
|
||||
switch (type_) {
|
||||
case Type::Contacts:
|
||||
return participant.dialog_id_.get_type() == DialogType::User &&
|
||||
td->contacts_manager_->is_user_contact(participant.dialog_id_.get_user_id());
|
||||
td->user_manager_->is_user_contact(participant.dialog_id_.get_user_id());
|
||||
case Type::Administrators:
|
||||
return participant.status_.is_administrator();
|
||||
case Type::Members:
|
||||
@ -132,7 +132,7 @@ bool DialogParticipantFilter::is_dialog_participant_suitable(const Td *td, const
|
||||
return true;
|
||||
case Type::Bots:
|
||||
return participant.dialog_id_.get_type() == DialogType::User &&
|
||||
td->contacts_manager_->is_user_bot(participant.dialog_id_.get_user_id());
|
||||
td->user_manager_->is_user_bot(participant.dialog_id_.get_user_id());
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/db/SqliteKeyValueAsync.h"
|
||||
|
||||
@ -99,7 +100,7 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler {
|
||||
return on_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(offset_user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(offset_user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
r_input_user = make_tl_object<telegram_api::inputUserEmpty>();
|
||||
}
|
||||
@ -125,7 +126,7 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler {
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetChatJoinRequestsQuery: " << to_string(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetChatJoinRequestsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetChatJoinRequestsQuery");
|
||||
|
||||
int32 total_count = result->count_;
|
||||
if (total_count < static_cast<int32>(result->importers_.size())) {
|
||||
@ -146,7 +147,7 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler {
|
||||
recent_requesters.push_back(user_id.get());
|
||||
}
|
||||
join_requests.push_back(td_api::make_object<td_api::chatJoinRequest>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "chatJoinRequest"), request->date_, request->about_));
|
||||
td_->user_manager_->get_user_id_object(user_id, "chatJoinRequest"), request->date_, request->about_));
|
||||
}
|
||||
if (is_full_list_) {
|
||||
td_->messages_manager_->on_update_dialog_pending_join_requests(dialog_id_, total_count,
|
||||
@ -176,7 +177,7 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler {
|
||||
return on_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise_, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise_, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
int32 flags = 0;
|
||||
if (approve) {
|
||||
@ -279,7 +280,7 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler {
|
||||
switch (participants_ptr->get_id()) {
|
||||
case telegram_api::channels_channelParticipants::ID: {
|
||||
auto participants = telegram_api::move_object_as<telegram_api::channels_channelParticipants>(participants_ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(participants->users_), "GetChannelAdministratorsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(participants->users_), "GetChannelAdministratorsQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(participants->chats_), "GetChannelAdministratorsQuery");
|
||||
|
||||
auto channel_type = td_->contacts_manager_->get_channel_type(channel_id_);
|
||||
@ -350,7 +351,7 @@ class GetChannelParticipantQuery final : public Td::ResultHandler {
|
||||
auto participant = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetChannelParticipantQuery: " << to_string(participant);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(participant->users_), "GetChannelParticipantQuery");
|
||||
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_));
|
||||
@ -744,7 +745,7 @@ class CanEditChannelCreatorQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send() {
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(td_->contacts_manager_->get_my_id());
|
||||
auto r_input_user = td_->user_manager_->get_input_user(td_->user_manager_->get_my_id());
|
||||
CHECK(r_input_user.is_ok());
|
||||
send_query(G()->net_query_creator().create(telegram_api::channels_editCreator(
|
||||
telegram_api::make_object<telegram_api::inputChannelEmpty>(), r_input_user.move_as_ok(),
|
||||
@ -784,7 +785,7 @@ class EditChannelCreatorQuery final : public Td::ResultHandler {
|
||||
if (input_channel == nullptr) {
|
||||
return promise_.set_error(Status::Error(400, "Have no access to the chat"));
|
||||
}
|
||||
TRY_RESULT_PROMISE(promise_, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise_, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::channels_editCreator(std::move(input_channel), std::move(input_user),
|
||||
std::move(input_check_password)),
|
||||
@ -1059,8 +1060,8 @@ void DialogParticipantManager::update_dialog_online_member_count(const vector<Di
|
||||
continue;
|
||||
}
|
||||
auto user_id = participant.dialog_id_.get_user_id();
|
||||
if (!td_->contacts_manager_->is_user_deleted(user_id) && !td_->contacts_manager_->is_user_bot(user_id)) {
|
||||
if (td_->contacts_manager_->is_user_online(user_id, 0, unix_time)) {
|
||||
if (!td_->user_manager_->is_user_deleted(user_id) && !td_->user_manager_->is_user_bot(user_id)) {
|
||||
if (td_->user_manager_->is_user_online(user_id, 0, unix_time)) {
|
||||
online_member_count++;
|
||||
}
|
||||
if (is_from_server) {
|
||||
@ -1183,7 +1184,7 @@ void DialogParticipantManager::speculative_update_dialog_administrators(DialogId
|
||||
td_api::object_ptr<td_api::chatAdministrators> DialogParticipantManager::get_chat_administrators_object(
|
||||
const vector<DialogAdministrator> &dialog_administrators) {
|
||||
auto administrator_objects = transform(dialog_administrators, [this](const DialogAdministrator &administrator) {
|
||||
return administrator.get_chat_administrator_object(td_->contacts_manager_.get());
|
||||
return administrator.get_chat_administrator_object(td_->user_manager_.get());
|
||||
});
|
||||
return td_api::make_object<td_api::chatAdministrators>(std::move(administrator_objects));
|
||||
}
|
||||
@ -1259,7 +1260,7 @@ void DialogParticipantManager::on_load_dialog_administrators_from_database(
|
||||
auto lock_promise = load_users_multipromise.get_promise();
|
||||
|
||||
for (auto &administrator : administrators) {
|
||||
td_->contacts_manager_->get_user(administrator.get_user_id(), 3, load_users_multipromise.get_promise());
|
||||
td_->user_manager_->get_user(administrator.get_user_id(), 3, load_users_multipromise.get_promise());
|
||||
}
|
||||
|
||||
lock_promise.set_value(Unit());
|
||||
@ -1377,23 +1378,22 @@ void DialogParticipantManager::send_update_chat_member(DialogId dialog_id, UserI
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
td_api::make_object<td_api::updateChatMember>(
|
||||
td_->dialog_manager_->get_chat_id_object(dialog_id, "updateChatMember"),
|
||||
td_->contacts_manager_->get_user_id_object(agent_user_id, "updateChatMember"), date,
|
||||
invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()), via_dialog_filter_invite_link,
|
||||
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")));
|
||||
}
|
||||
|
||||
void DialogParticipantManager::on_update_bot_stopped(UserId user_id, int32 date, bool is_stopped, bool force) {
|
||||
CHECK(td_->auth_manager_->is_bot());
|
||||
if (date <= 0 || !td_->contacts_manager_->have_user_force(user_id, "on_update_bot_stopped")) {
|
||||
if (date <= 0 || !td_->user_manager_->have_user_force(user_id, "on_update_bot_stopped")) {
|
||||
LOG(ERROR) << "Receive invalid updateBotStopped by " << user_id << " at " << date;
|
||||
return;
|
||||
}
|
||||
auto my_user_id = td_->contacts_manager_->get_my_id();
|
||||
if (!td_->contacts_manager_->have_user_force(my_user_id, "on_update_bot_stopped 2")) {
|
||||
auto my_user_id = td_->user_manager_->get_my_id();
|
||||
if (!td_->user_manager_->have_user_force(my_user_id, "on_update_bot_stopped 2")) {
|
||||
if (!force) {
|
||||
td_->contacts_manager_->get_me(
|
||||
PromiseCreator::lambda([actor_id = actor_id(this), user_id, date, is_stopped](Unit) {
|
||||
td_->user_manager_->get_me(PromiseCreator::lambda([actor_id = actor_id(this), user_id, date, is_stopped](Unit) {
|
||||
send_closure(actor_id, &DialogParticipantManager::on_update_bot_stopped, user_id, date, is_stopped, true);
|
||||
}));
|
||||
return;
|
||||
@ -1449,7 +1449,7 @@ void DialogParticipantManager::on_update_chat_participant(
|
||||
LOG(ERROR) << "Receive wrong updateChatParticipant: " << old_dialog_participant << " -> " << new_dialog_participant;
|
||||
return;
|
||||
}
|
||||
if (new_dialog_participant.dialog_id_ == DialogId(td_->contacts_manager_->get_my_id()) &&
|
||||
if (new_dialog_participant.dialog_id_ == DialogId(td_->user_manager_->get_my_id()) &&
|
||||
new_dialog_participant.status_ != chat_status && false) {
|
||||
LOG(ERROR) << "Have status " << chat_status << " after receiving updateChatParticipant in " << chat_id << " by "
|
||||
<< user_id << " at " << date << " from " << old_dialog_participant << " to " << new_dialog_participant;
|
||||
@ -1495,7 +1495,7 @@ void DialogParticipantManager::on_update_channel_participant(
|
||||
<< new_dialog_participant;
|
||||
return;
|
||||
}
|
||||
if (new_dialog_participant.status_.is_administrator() && user_id == td_->contacts_manager_->get_my_id() &&
|
||||
if (new_dialog_participant.status_.is_administrator() && user_id == td_->user_manager_->get_my_id() &&
|
||||
!new_dialog_participant.status_.can_be_edited()) {
|
||||
LOG(ERROR) << "Fix wrong can_be_edited in " << new_dialog_participant << " from " << channel_id << " changed from "
|
||||
<< old_dialog_participant;
|
||||
@ -1524,7 +1524,7 @@ void DialogParticipantManager::on_update_channel_participant(
|
||||
void DialogParticipantManager::on_update_chat_invite_requester(DialogId dialog_id, UserId user_id, string about,
|
||||
int32 date, DialogInviteLink invite_link) {
|
||||
CHECK(td_->auth_manager_->is_bot());
|
||||
if (date <= 0 || !td_->contacts_manager_->have_user_force(user_id, "on_update_chat_invite_requester") ||
|
||||
if (date <= 0 || !td_->user_manager_->have_user_force(user_id, "on_update_chat_invite_requester") ||
|
||||
!td_->dialog_manager_->have_dialog_info_force(dialog_id, "on_update_chat_invite_requester")) {
|
||||
LOG(ERROR) << "Receive invalid updateBotChatInviteRequester by " << user_id << " in " << dialog_id << " at "
|
||||
<< date;
|
||||
@ -1538,9 +1538,9 @@ void DialogParticipantManager::on_update_chat_invite_requester(DialogId dialog_i
|
||||
td_api::make_object<td_api::updateNewChatJoinRequest>(
|
||||
td_->dialog_manager_->get_chat_id_object(dialog_id, "updateNewChatJoinRequest"),
|
||||
td_api::make_object<td_api::chatJoinRequest>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "updateNewChatJoinRequest"), date, about),
|
||||
td_->user_manager_->get_user_id_object(user_id, "updateNewChatJoinRequest"), date, about),
|
||||
td_->dialog_manager_->get_chat_id_object(user_dialog_id, "updateNewChatJoinRequest 2"),
|
||||
invite_link.get_chat_invite_link_object(td_->contacts_manager_.get())));
|
||||
invite_link.get_chat_invite_link_object(td_->user_manager_.get())));
|
||||
}
|
||||
|
||||
void DialogParticipantManager::get_dialog_participant(DialogId dialog_id, DialogId participant_dialog_id,
|
||||
@ -1560,7 +1560,7 @@ void DialogParticipantManager::finish_get_dialog_participant(
|
||||
|
||||
auto participant_dialog_id = dialog_participant.dialog_id_;
|
||||
bool is_user = participant_dialog_id.get_type() == DialogType::User;
|
||||
if ((is_user && !td_->contacts_manager_->have_user(participant_dialog_id.get_user_id())) ||
|
||||
if ((is_user && !td_->user_manager_->have_user(participant_dialog_id.get_user_id())) ||
|
||||
(!is_user && !td_->messages_manager_->have_dialog(participant_dialog_id))) {
|
||||
return promise.set_error(Status::Error(400, "Member not found"));
|
||||
}
|
||||
@ -1578,7 +1578,7 @@ void DialogParticipantManager::do_get_dialog_participant(DialogId dialog_id, Dia
|
||||
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
auto my_user_id = td_->contacts_manager_->get_my_id();
|
||||
auto my_user_id = td_->user_manager_->get_my_id();
|
||||
auto peer_user_id = dialog_id.get_user_id();
|
||||
if (participant_dialog_id == DialogId(my_user_id)) {
|
||||
return promise.set_value(DialogParticipant::private_member(my_user_id, peer_user_id));
|
||||
@ -1598,8 +1598,8 @@ void DialogParticipantManager::do_get_dialog_participant(DialogId dialog_id, Dia
|
||||
case DialogType::Channel:
|
||||
return get_channel_participant(dialog_id.get_channel_id(), participant_dialog_id, std::move(promise));
|
||||
case DialogType::SecretChat: {
|
||||
auto my_user_id = td_->contacts_manager_->get_my_id();
|
||||
auto peer_user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
auto my_user_id = td_->user_manager_->get_my_id();
|
||||
auto peer_user_id = td_->user_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
if (participant_dialog_id == DialogId(my_user_id)) {
|
||||
return promise.set_value(DialogParticipant::private_member(my_user_id, peer_user_id));
|
||||
}
|
||||
@ -1675,8 +1675,7 @@ std::pair<int32, vector<DialogId>> DialogParticipantManager::search_among_dialog
|
||||
hints.add(dialog_id.get(), td_->dialog_manager_->get_dialog_search_text(dialog_id));
|
||||
}
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
hints.set_rating(dialog_id.get(),
|
||||
-td_->contacts_manager_->get_user_was_online(dialog_id.get_user_id(), unix_time));
|
||||
hints.set_rating(dialog_id.get(), -td_->user_manager_->get_user_was_online(dialog_id.get_user_id(), unix_time));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1687,7 +1686,7 @@ std::pair<int32, vector<DialogId>> DialogParticipantManager::search_among_dialog
|
||||
DialogParticipants DialogParticipantManager::search_private_chat_participants(UserId peer_user_id, const string &query,
|
||||
int32 limit,
|
||||
DialogParticipantFilter filter) const {
|
||||
auto my_user_id = td_->contacts_manager_->get_my_id();
|
||||
auto my_user_id = td_->user_manager_->get_my_id();
|
||||
vector<DialogId> dialog_ids;
|
||||
if (filter.is_dialog_participant_suitable(td_, DialogParticipant::private_member(my_user_id, peer_user_id))) {
|
||||
dialog_ids.push_back(DialogId(my_user_id));
|
||||
@ -1798,7 +1797,7 @@ void DialogParticipantManager::on_get_channel_participants(
|
||||
Promise<DialogParticipants> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(channel_participants->users_), "on_get_channel_participants");
|
||||
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");
|
||||
int32 total_count = channel_participants->count_;
|
||||
auto participants = std::move(channel_participants->participants_);
|
||||
@ -1819,15 +1818,15 @@ void DialogParticipantManager::on_get_channel_participants(
|
||||
if (participant.dialog_id_.get_type() == DialogType::User) {
|
||||
participant_user_id = participant.dialog_id_.get_user_id();
|
||||
}
|
||||
if (!participant.is_valid() || (filter.is_bots() && !td_->contacts_manager_->is_user_bot(participant_user_id)) ||
|
||||
if (!participant.is_valid() || (filter.is_bots() && !td_->user_manager_->is_user_bot(participant_user_id)) ||
|
||||
(filter.is_administrators() && !participant.status_.is_administrator()) ||
|
||||
((filter.is_recent() || filter.is_contacts() || filter.is_search()) && !participant.status_.is_member()) ||
|
||||
(filter.is_contacts() && !td_->contacts_manager_->is_user_contact(participant_user_id)) ||
|
||||
(filter.is_contacts() && !td_->user_manager_->is_user_contact(participant_user_id)) ||
|
||||
(filter.is_restricted() && !participant.status_.is_restricted()) ||
|
||||
(filter.is_banned() && !participant.status_.is_banned())) {
|
||||
bool skip_error = ((filter.is_administrators() || filter.is_bots()) &&
|
||||
td_->contacts_manager_->is_user_deleted(participant_user_id)) ||
|
||||
(filter.is_contacts() && participant_user_id == td_->contacts_manager_->get_my_id());
|
||||
td_->user_manager_->is_user_deleted(participant_user_id)) ||
|
||||
(filter.is_contacts() && participant_user_id == td_->user_manager_->get_my_id());
|
||||
if (!skip_error) {
|
||||
LOG(ERROR) << "Receive " << participant << ", while searching for " << filter << " in " << channel_id
|
||||
<< " with offset " << offset << " and limit " << limit << ": " << oneline(debug_participant);
|
||||
@ -1868,7 +1867,7 @@ void DialogParticipantManager::on_get_channel_participants(
|
||||
administrators.emplace_back(participant_user_id, participant.status_.get_rank(),
|
||||
participant.status_.is_creator());
|
||||
}
|
||||
if (is_full_recent && td_->contacts_manager_->is_user_bot(participant_user_id)) {
|
||||
if (is_full_recent && td_->user_manager_->is_user_bot(participant_user_id)) {
|
||||
bot_user_ids.push_back(participant_user_id);
|
||||
}
|
||||
}
|
||||
@ -1971,7 +1970,7 @@ void DialogParticipantManager::search_dialog_participants(DialogId dialog_id, co
|
||||
}
|
||||
}
|
||||
case DialogType::SecretChat: {
|
||||
auto peer_user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
auto peer_user_id = td_->user_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
return promise.set_value(search_private_chat_participants(peer_user_id, query, limit, filter));
|
||||
}
|
||||
case DialogType::None:
|
||||
@ -2098,7 +2097,7 @@ void DialogParticipantManager::leave_dialog(DialogId dialog_id, Promise<Unit> &&
|
||||
case DialogType::User:
|
||||
return promise.set_error(Status::Error(400, "Can't leave private chats"));
|
||||
case DialogType::Chat:
|
||||
return delete_chat_participant(dialog_id.get_chat_id(), td_->contacts_manager_->get_my_id(), false,
|
||||
return delete_chat_participant(dialog_id.get_chat_id(), td_->user_manager_->get_my_id(), false,
|
||||
std::move(promise));
|
||||
case DialogType::Channel: {
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
@ -2128,7 +2127,7 @@ void DialogParticipantManager::add_chat_participant(ChatId chat_id, UserId user_
|
||||
return promise.set_error(Status::Error(400, "Can't forward negative number of messages"));
|
||||
}
|
||||
auto permissions = td_->contacts_manager_->get_chat_permissions(chat_id);
|
||||
if (user_id != td_->contacts_manager_->get_my_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"));
|
||||
}
|
||||
@ -2137,7 +2136,7 @@ void DialogParticipantManager::add_chat_participant(ChatId chat_id, UserId user_
|
||||
}
|
||||
// TODO upper bound on forward_limit
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
// TODO invoke after
|
||||
td_->create_handler<AddChatUserQuery>(std::move(promise))
|
||||
@ -2191,7 +2190,7 @@ void DialogParticipantManager::set_chat_participant_status(ChatId chat_id, UserI
|
||||
return promise.set_error(Status::Error(400, "Need owner rights in the group chat"));
|
||||
}
|
||||
|
||||
if (user_id == td_->contacts_manager_->get_my_id()) {
|
||||
if (user_id == td_->user_manager_->get_my_id()) {
|
||||
return promise.set_error(Status::Error(400, "Can't promote or demote self"));
|
||||
}
|
||||
|
||||
@ -2216,7 +2215,7 @@ void DialogParticipantManager::set_chat_participant_status(ChatId chat_id, UserI
|
||||
void DialogParticipantManager::send_edit_chat_admin_query(ChatId chat_id, UserId user_id, bool is_administrator,
|
||||
Promise<Unit> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
td_->create_handler<EditChatAdminQuery>(std::move(promise))
|
||||
->send(chat_id, user_id, std::move(input_user), is_administrator);
|
||||
@ -2231,7 +2230,7 @@ void DialogParticipantManager::delete_chat_participant(ChatId chat_id, UserId us
|
||||
return promise.set_error(Status::Error(400, "Chat is deactivated"));
|
||||
}
|
||||
|
||||
auto my_id = td_->contacts_manager_->get_my_id();
|
||||
auto my_id = td_->user_manager_->get_my_id();
|
||||
auto permissions = td_->contacts_manager_->get_chat_permissions(chat_id);
|
||||
if (permissions.is_left()) {
|
||||
if (user_id == my_id) {
|
||||
@ -2268,7 +2267,7 @@ void DialogParticipantManager::delete_chat_participant(ChatId chat_id, UserId us
|
||||
}
|
||||
}
|
||||
*/
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
// TODO invoke after
|
||||
td_->create_handler<DeleteChatUserQuery>(std::move(promise))->send(chat_id, std::move(input_user), revoke_messages);
|
||||
@ -2284,9 +2283,9 @@ void DialogParticipantManager::add_channel_participant(ChannelId channel_id, Use
|
||||
if (!td_->contacts_manager_->have_channel(channel_id)) {
|
||||
return promise.set_error(Status::Error(400, "Chat info not found"));
|
||||
}
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
if (user_id == td_->contacts_manager_->get_my_id()) {
|
||||
if (user_id == td_->user_manager_->get_my_id()) {
|
||||
// join the channel
|
||||
auto my_status = td_->contacts_manager_->get_channel_status(channel_id);
|
||||
if (my_status.is_banned()) {
|
||||
@ -2354,9 +2353,9 @@ void DialogParticipantManager::add_channel_participants(ChannelId channel_id, co
|
||||
|
||||
vector<tl_object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : user_ids) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
if (user_id == td_->contacts_manager_->get_my_id()) {
|
||||
if (user_id == td_->user_manager_->get_my_id()) {
|
||||
// can't invite self
|
||||
continue;
|
||||
}
|
||||
@ -2436,13 +2435,13 @@ void DialogParticipantManager::set_channel_participant_status_impl(ChannelId cha
|
||||
if (!new_status.is_creator()) {
|
||||
return promise.set_error(Status::Error(400, "Can't remove chat owner"));
|
||||
}
|
||||
auto user_id = td_->contacts_manager_->get_my_id();
|
||||
auto user_id = td_->user_manager_->get_my_id();
|
||||
if (participant_dialog_id != DialogId(user_id)) {
|
||||
return promise.set_error(Status::Error(400, "Not enough rights to edit chat owner rights"));
|
||||
}
|
||||
if (new_status.is_member() == old_status.is_member()) {
|
||||
// change rank and is_anonymous
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(user_id);
|
||||
CHECK(r_input_user.is_ok());
|
||||
td_->create_handler<EditChannelAdminQuery>(std::move(promise))
|
||||
->send(channel_id, user_id, r_input_user.move_as_ok(), new_status);
|
||||
@ -2507,7 +2506,7 @@ void DialogParticipantManager::promote_channel_participant(ChannelId channel_id,
|
||||
const DialogParticipantStatus &old_status,
|
||||
Promise<Unit> &&promise) {
|
||||
LOG(INFO) << "Promote " << user_id << " in " << channel_id << " from " << old_status << " to " << new_status;
|
||||
if (user_id == td_->contacts_manager_->get_my_id()) {
|
||||
if (user_id == td_->user_manager_->get_my_id()) {
|
||||
if (new_status.is_administrator()) {
|
||||
return promise.set_error(Status::Error(400, "Can't promote self"));
|
||||
}
|
||||
@ -2522,7 +2521,7 @@ void DialogParticipantManager::promote_channel_participant(ChannelId channel_id,
|
||||
CHECK(!new_status.is_creator());
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
speculative_add_channel_user(channel_id, user_id, new_status, old_status);
|
||||
td_->create_handler<EditChannelAdminQuery>(std::move(promise))
|
||||
@ -2681,7 +2680,7 @@ void DialogParticipantManager::send_update_add_chat_members_privacy_forbidden(Di
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
td_api::make_object<td_api::updateAddChatMembersPrivacyForbidden>(
|
||||
td_->dialog_manager_->get_chat_id_object(dialog_id, "updateAddChatMembersPrivacyForbidden"),
|
||||
td_->contacts_manager_->get_user_ids_object(user_ids, source)));
|
||||
td_->user_manager_->get_user_ids_object(user_ids, source)));
|
||||
}
|
||||
|
||||
void DialogParticipantManager::on_channel_participant_cache_timeout_callback(void *dialog_participant_manager_ptr,
|
||||
@ -2863,7 +2862,7 @@ void DialogParticipantManager::update_cached_channel_participant_status(ChannelI
|
||||
}
|
||||
}
|
||||
if (!is_found && status.is_member()) {
|
||||
participants.emplace_back(DialogId(user_id), td_->contacts_manager_->get_my_id(), G()->unix_time(), status);
|
||||
participants.emplace_back(DialogId(user_id), td_->user_manager_->get_my_id(), G()->unix_time(), status);
|
||||
update_channel_online_member_count(channel_id, false);
|
||||
}
|
||||
}
|
||||
@ -2925,13 +2924,13 @@ void DialogParticipantManager::transfer_dialog_ownership(DialogId dialog_id, Use
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "transfer_dialog_ownership")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->contacts_manager_->have_user_force(user_id, "transfer_dialog_ownership")) {
|
||||
if (!td_->user_manager_->have_user_force(user_id, "transfer_dialog_ownership")) {
|
||||
return promise.set_error(Status::Error(400, "User not found"));
|
||||
}
|
||||
if (td_->contacts_manager_->is_user_bot(user_id)) {
|
||||
if (td_->user_manager_->is_user_bot(user_id)) {
|
||||
return promise.set_error(Status::Error(400, "User is a bot"));
|
||||
}
|
||||
if (td_->contacts_manager_->is_user_deleted(user_id)) {
|
||||
if (td_->user_manager_->is_user_deleted(user_id)) {
|
||||
return promise.set_error(Status::Error(400, "User is deleted"));
|
||||
}
|
||||
if (password.empty()) {
|
||||
|
@ -57,7 +57,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler {
|
||||
flags |= telegram_api::messages_saveDraft::INVERT_MEDIA_MASK;
|
||||
}
|
||||
input_message_entities = get_input_message_entities(
|
||||
td_->contacts_manager_.get(), draft_message->input_message_text_.text.entities, "SaveDraftMessageQuery");
|
||||
td_->user_manager_.get(), draft_message->input_message_text_.text.entities, "SaveDraftMessageQuery");
|
||||
if (!input_message_entities.empty()) {
|
||||
flags |= telegram_api::messages_saveDraft::ENTITIES_MASK;
|
||||
}
|
||||
@ -409,8 +409,7 @@ DraftMessage::DraftMessage(Td *td, telegram_api::object_ptr<telegram_api::draftM
|
||||
CHECK(draft_message != nullptr);
|
||||
date_ = draft_message->date_;
|
||||
message_input_reply_to_ = MessageInputReplyTo(td, std::move(draft_message->reply_to_));
|
||||
auto entities =
|
||||
get_message_entities(td->contacts_manager_.get(), std::move(draft_message->entities_), "draftMessage");
|
||||
auto entities = get_message_entities(td->user_manager_.get(), std::move(draft_message->entities_), "draftMessage");
|
||||
auto status = fix_formatted_text(draft_message->message_, entities, true, true, true, true, true);
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << "Receive error " << status << " while parsing draft " << draft_message->message_;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/StoryManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/WebPageId.h"
|
||||
#include "td/telegram/WebPagesManager.h"
|
||||
|
||||
@ -324,7 +325,7 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source
|
||||
std::move(promise), "FileSourceMessage", nullptr);
|
||||
},
|
||||
[&](const FileSourceUserPhoto &source) {
|
||||
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user_profile_photo, source.user_id,
|
||||
send_closure_later(G()->user_manager(), &UserManager::reload_user_profile_photo, source.user_id,
|
||||
source.photo_id, std::move(promise));
|
||||
},
|
||||
[&](const FileSourceChatPhoto &source) {
|
||||
@ -376,8 +377,8 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source
|
||||
std::move(promise));
|
||||
},
|
||||
[&](const FileSourceUserFull &source) {
|
||||
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user_full, source.user_id,
|
||||
std::move(promise), "FileSourceUserFull");
|
||||
send_closure_later(G()->user_manager(), &UserManager::reload_user_full, source.user_id, std::move(promise),
|
||||
"FileSourceUserFull");
|
||||
},
|
||||
[&](const FileSourceAttachMenuBot &source) {
|
||||
send_closure_later(G()->attach_menu_manager(), &AttachMenuManager::reload_attach_menu_bot, source.user_id,
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "td/telegram/StoryManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/WebPagesManager.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
@ -82,7 +83,7 @@ FileSourceId FileReferenceManager::parse_file_source(Td *td, ParserT &parser) {
|
||||
int64 photo_id;
|
||||
td::parse(user_id, parser);
|
||||
td::parse(photo_id, parser);
|
||||
return td->contacts_manager_->get_user_profile_photo_file_source_id(user_id, photo_id);
|
||||
return td->user_manager_->get_user_profile_photo_file_source_id(user_id, photo_id);
|
||||
}
|
||||
case 2: {
|
||||
ChatId chat_id;
|
||||
@ -134,7 +135,7 @@ FileSourceId FileReferenceManager::parse_file_source(Td *td, ParserT &parser) {
|
||||
case 14: {
|
||||
UserId user_id;
|
||||
td::parse(user_id, parser);
|
||||
return td->contacts_manager_->get_user_full_file_source_id(user_id);
|
||||
return td->user_manager_->get_user_full_file_source_id(user_id);
|
||||
}
|
||||
case 15: {
|
||||
UserId user_id;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -316,7 +317,7 @@ class GetForumTopicQuery final : public Td::ResultHandler {
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetForumTopicQuery: " << to_string(ptr);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetForumTopicQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetForumTopicQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetForumTopicQuery");
|
||||
|
||||
if (ptr->topics_.size() != 1u) {
|
||||
@ -386,7 +387,7 @@ class GetForumTopicsQuery final : public Td::ResultHandler {
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetForumTopicsQuery: " << to_string(ptr);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetForumTopicsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetForumTopicsQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetForumTopicsQuery");
|
||||
|
||||
MessagesInfo messages_info;
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "td/telegram/Game.h"
|
||||
|
||||
#include "td/telegram/AnimationsManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Document.h"
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -91,7 +91,7 @@ bool Game::has_input_media() const {
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::inputMediaGame> Game::get_input_media_game(const Td *td) const {
|
||||
auto input_user = td->contacts_manager_->get_input_user_force(bot_user_id_);
|
||||
auto input_user = td->user_manager_->get_input_user_force(bot_user_id_);
|
||||
return make_tl_object<telegram_api::inputMediaGame>(
|
||||
make_tl_object<telegram_api::inputGameShortName>(std::move(input_user), short_name_));
|
||||
}
|
||||
@ -113,14 +113,14 @@ StringBuilder &operator<<(StringBuilder &string_builder, const Game &game) {
|
||||
<< ", photo = " << game.photo_ << ", animation_file_id = " << game.animation_file_id_ << "]";
|
||||
}
|
||||
|
||||
Result<Game> process_input_message_game(const ContactsManager *contacts_manager,
|
||||
Result<Game> process_input_message_game(const UserManager *user_manager,
|
||||
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) {
|
||||
CHECK(input_message_content != nullptr);
|
||||
CHECK(input_message_content->get_id() == td_api::inputMessageGame::ID);
|
||||
auto input_message_game = move_tl_object_as<td_api::inputMessageGame>(input_message_content);
|
||||
|
||||
UserId bot_user_id(input_message_game->bot_user_id_);
|
||||
TRY_STATUS(contacts_manager->get_input_user(bot_user_id));
|
||||
TRY_STATUS(user_manager->get_input_user(bot_user_id));
|
||||
|
||||
if (!clean_input_string(input_message_game->game_short_name_)) {
|
||||
return Status::Error(400, "Game short name must be encoded in UTF-8");
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class ContactsManager;
|
||||
class UserManager;
|
||||
class Td;
|
||||
|
||||
class Game {
|
||||
@ -79,7 +79,7 @@ bool operator!=(const Game &lhs, const Game &rhs);
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const Game &game);
|
||||
|
||||
Result<Game> process_input_message_game(const ContactsManager *contacts_manager,
|
||||
Result<Game> process_input_message_game(const UserManager *user_manager,
|
||||
tl_object_ptr<td_api::InputMessageContent> &&input_message_content)
|
||||
TD_WARN_UNUSED_RESULT;
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ChainId.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
@ -21,6 +20,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -212,7 +212,7 @@ void GameManager::set_game_score(MessageFullId message_full_id, bool edit_messag
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
if (!td_->messages_manager_->can_set_game_score(message_full_id)) {
|
||||
return promise.set_error(Status::Error(400, "Game score can't be set"));
|
||||
@ -243,7 +243,7 @@ void GameManager::set_inline_game_score(const string &inline_message_id, bool ed
|
||||
return promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
td_->create_handler<SetInlineGameScoreQuery>(std::move(promise))
|
||||
->send(std::move(input_bot_inline_message_id), edit_message, std::move(input_user), score, force);
|
||||
@ -266,7 +266,7 @@ void GameManager::get_game_high_scores(MessageFullId message_full_id, UserId use
|
||||
return promise.set_error(Status::Error(400, "Wrong message identifier specified"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
td_->create_handler<GetGameHighScoresQuery>(std::move(promise))->send(dialog_id, message_id, std::move(input_user));
|
||||
}
|
||||
@ -280,7 +280,7 @@ void GameManager::get_inline_game_high_scores(const string &inline_message_id, U
|
||||
return promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
td_->create_handler<GetInlineGameHighScoresQuery>(std::move(promise))
|
||||
->send(std::move(input_bot_inline_message_id), std::move(input_user));
|
||||
@ -288,7 +288,7 @@ void GameManager::get_inline_game_high_scores(const string &inline_message_id, U
|
||||
|
||||
td_api::object_ptr<td_api::gameHighScores> GameManager::get_game_high_scores_object(
|
||||
telegram_api::object_ptr<telegram_api::messages_highScores> &&high_scores) {
|
||||
td_->contacts_manager_->on_get_users(std::move(high_scores->users_), "get_game_high_scores_object");
|
||||
td_->user_manager_->on_get_users(std::move(high_scores->users_), "get_game_high_scores_object");
|
||||
|
||||
auto result = td_api::make_object<td_api::gameHighScores>();
|
||||
for (const auto &high_score : high_scores->scores_) {
|
||||
@ -300,7 +300,7 @@ td_api::object_ptr<td_api::gameHighScores> GameManager::get_game_high_scores_obj
|
||||
continue;
|
||||
}
|
||||
result->scores_.push_back(make_tl_object<td_api::gameHighScore>(
|
||||
position, td_->contacts_manager_->get_user_id_object(user_id, "get_game_high_scores_object"), score));
|
||||
position, td_->user_manager_->get_user_id_object(user_id, "get_game_high_scores_object"), score));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -141,7 +142,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetGroupCallJoinAsQuery: " << to_string(ptr);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetGroupCallJoinAsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetGroupCallJoinAsQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetGroupCallJoinAsQuery");
|
||||
|
||||
promise_.set_value(convert_message_senders_object(td_, ptr->peers_));
|
||||
@ -1460,7 +1461,7 @@ void GroupCallManager::finish_get_group_call(InputGroupCallId input_group_call_i
|
||||
load_group_call_queries_.erase(it);
|
||||
|
||||
if (result.is_ok()) {
|
||||
td_->contacts_manager_->on_get_users(std::move(result.ok_ref()->users_), "finish_get_group_call");
|
||||
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");
|
||||
|
||||
if (update_group_call(result.ok()->call_, DialogId()) != input_group_call_id) {
|
||||
@ -1605,7 +1606,7 @@ void GroupCallManager::on_get_group_call_participants(
|
||||
LOG(INFO) << "Receive group call participants: " << to_string(participants);
|
||||
|
||||
CHECK(participants != nullptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(participants->users_), "on_get_group_call_participants");
|
||||
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");
|
||||
|
||||
if (!need_group_call_participants(input_group_call_id)) {
|
||||
@ -2642,7 +2643,7 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_di
|
||||
if (as_dialog_id != my_dialog_id) {
|
||||
return promise.set_error(Status::Error(400, "Can't join voice chat as another user"));
|
||||
}
|
||||
if (!td_->contacts_manager_->have_user_force(as_dialog_id.get_user_id(), "join_group_call")) {
|
||||
if (!td_->user_manager_->have_user_force(as_dialog_id.get_user_id(), "join_group_call")) {
|
||||
have_as_dialog_id = false;
|
||||
}
|
||||
} else {
|
||||
@ -3520,9 +3521,9 @@ void GroupCallManager::invite_group_call_participants(GroupCallId group_call_id,
|
||||
TRY_RESULT_PROMISE(promise, input_group_call_id, get_input_group_call_id(group_call_id));
|
||||
|
||||
vector<tl_object_ptr<telegram_api::InputUser>> input_users;
|
||||
auto my_user_id = td_->contacts_manager_->get_my_id();
|
||||
auto my_user_id = td_->user_manager_->get_my_id();
|
||||
for (auto user_id : user_ids) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
if (user_id == my_user_id) {
|
||||
// can't invite self
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/Venue.h"
|
||||
#include "td/telegram/VideosManager.h"
|
||||
#include "td/telegram/VoiceNotesManager.h"
|
||||
@ -372,14 +373,14 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
|
||||
return Status::Error(400, "Inline message must be non-empty");
|
||||
}
|
||||
TRY_RESULT(reply_markup, get_reply_markup(std::move(reply_markup_ptr), true, true, false, true));
|
||||
auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), reply_markup);
|
||||
auto input_reply_markup = get_input_reply_markup(td_->user_manager_.get(), reply_markup);
|
||||
|
||||
auto constructor_id = input_message_content->get_id();
|
||||
if (constructor_id == td_api::inputMessageText::ID) {
|
||||
TRY_RESULT(input_message_text, process_input_message_text(td_, td_->dialog_manager_->get_my_dialog_id(),
|
||||
std::move(input_message_content), true));
|
||||
auto entities = get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities,
|
||||
"get_inline_message");
|
||||
auto entities =
|
||||
get_input_message_entities(td_->user_manager_.get(), input_message_text.text.entities, "get_inline_message");
|
||||
if (!input_message_text.web_page_url.empty()) {
|
||||
int32 flags = 0;
|
||||
if (input_reply_markup != nullptr) {
|
||||
@ -458,7 +459,7 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
|
||||
if (input_reply_markup != nullptr) {
|
||||
flags |= telegram_api::inputBotInlineMessageMediaAuto::REPLY_MARKUP_MASK;
|
||||
}
|
||||
auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "get_inline_message");
|
||||
auto entities = get_input_message_entities(td_->user_manager_.get(), caption.entities, "get_inline_message");
|
||||
if (!entities.empty()) {
|
||||
flags |= telegram_api::inputBotInlineMessageMediaAuto::ENTITIES_MASK;
|
||||
}
|
||||
@ -581,8 +582,8 @@ void InlineQueriesManager::answer_inline_query(
|
||||
void InlineQueriesManager::get_simple_web_view_url(UserId bot_user_id, string &&url,
|
||||
const td_api::object_ptr<td_api::themeParameters> &theme,
|
||||
string &&platform, Promise<string> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(bot_user_id));
|
||||
|
||||
td_->create_handler<RequestSimpleWebViewQuery>(std::move(promise))
|
||||
->send(std::move(input_user), std::move(url), theme, std::move(platform));
|
||||
@ -590,14 +591,14 @@ void InlineQueriesManager::get_simple_web_view_url(UserId bot_user_id, string &&
|
||||
|
||||
void InlineQueriesManager::send_web_view_data(UserId bot_user_id, string &&button_text, string &&data,
|
||||
Promise<Unit> &&promise) const {
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->contacts_manager_->get_bot_data(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(bot_user_id));
|
||||
|
||||
int64 random_id;
|
||||
do {
|
||||
random_id = Random::secure_int64();
|
||||
} while (random_id == 0);
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
|
||||
|
||||
td_->create_handler<SendWebViewDataQuery>(std::move(promise))
|
||||
->send(std::move(input_user), random_id, button_text, data);
|
||||
@ -776,7 +777,7 @@ Result<tl_object_ptr<telegram_api::InputBotInlineResult>> InlineQueriesManager::
|
||||
return r_reply_markup.move_as_error();
|
||||
}
|
||||
|
||||
auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), r_reply_markup.ok());
|
||||
auto input_reply_markup = get_input_reply_markup(td_->user_manager_.get(), r_reply_markup.ok());
|
||||
int32 flags = 0;
|
||||
if (input_reply_markup != nullptr) {
|
||||
flags |= telegram_api::inputBotInlineMessageGame::REPLY_MARKUP_MASK;
|
||||
@ -1022,7 +1023,7 @@ uint64 InlineQueriesManager::send_inline_query(UserId bot_user_id, DialogId dial
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto r_bot_data = td_->contacts_manager_->get_bot_data(bot_user_id);
|
||||
auto r_bot_data = td_->user_manager_->get_bot_data(bot_user_id);
|
||||
if (r_bot_data.is_error()) {
|
||||
promise.set_error(r_bot_data.move_as_error());
|
||||
return 0;
|
||||
@ -1104,7 +1105,7 @@ void InlineQueriesManager::loop() {
|
||||
auto now = Time::now();
|
||||
if (now >= next_inline_query_time_) {
|
||||
LOG(INFO) << "Send inline query " << pending_inline_query_->query_hash;
|
||||
auto r_bot_input_user = td_->contacts_manager_->get_input_user(pending_inline_query_->bot_user_id);
|
||||
auto r_bot_input_user = td_->user_manager_->get_input_user(pending_inline_query_->bot_user_id);
|
||||
if (r_bot_input_user.is_ok()) {
|
||||
if (!sent_query_.empty()) {
|
||||
LOG(INFO) << "Cancel inline query request";
|
||||
@ -1582,7 +1583,7 @@ void InlineQueriesManager::on_get_inline_query_results(DialogId dialog_id, UserI
|
||||
}
|
||||
LOG(INFO) << to_string(results);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(results->users_), "on_get_inline_query_results");
|
||||
td_->user_manager_->on_get_users(std::move(results->users_), "on_get_inline_query_results");
|
||||
|
||||
auto dialog_type = dialog_id.get_type();
|
||||
bool allow_invoice = dialog_type != DialogType::SecretChat;
|
||||
@ -2060,7 +2061,7 @@ void InlineQueriesManager::save_recently_used_bots() {
|
||||
value += ',';
|
||||
value_ids += ',';
|
||||
}
|
||||
value += td_->contacts_manager_->get_user_first_username(bot_user_id);
|
||||
value += td_->user_manager_->get_user_first_username(bot_user_id);
|
||||
value_ids += to_string(bot_user_id.get());
|
||||
}
|
||||
G()->td_db()->get_binlog_pmc()->set("recently_used_inline_bot_usernames", value);
|
||||
@ -2092,7 +2093,7 @@ bool InlineQueriesManager::load_recently_used_bots(Promise<Unit> &promise) {
|
||||
|
||||
for (auto it = bot_ids.rbegin(); it != bot_ids.rend(); ++it) {
|
||||
UserId user_id(to_integer<int64>(*it));
|
||||
if (td_->contacts_manager_->have_user(user_id)) {
|
||||
if (td_->user_manager_->have_user(user_id)) {
|
||||
update_bot_usage(user_id);
|
||||
} else {
|
||||
LOG(ERROR) << "Can't find " << user_id;
|
||||
@ -2120,7 +2121,7 @@ bool InlineQueriesManager::load_recently_used_bots(Promise<Unit> &promise) {
|
||||
} else {
|
||||
for (auto &bot_id : bot_ids) {
|
||||
UserId user_id(to_integer<int64>(bot_id));
|
||||
td_->contacts_manager_->get_user(user_id, 3, resolve_recent_inline_bots_multipromise_.get_promise());
|
||||
td_->user_manager_->get_user(user_id, 3, resolve_recent_inline_bots_multipromise_.get_promise());
|
||||
}
|
||||
}
|
||||
lock.set_value(Unit());
|
||||
@ -2152,7 +2153,7 @@ void InlineQueriesManager::on_new_query(int64 query_id, UserId sender_user_id, L
|
||||
switch (peer_type->get_id()) {
|
||||
case telegram_api::inlineQueryPeerTypeSameBotPM::ID:
|
||||
return td_api::make_object<td_api::chatTypePrivate>(
|
||||
td_->contacts_manager_->get_user_id_object(sender_user_id, "inlineQueryPeerTypeSameBotPM"));
|
||||
td_->user_manager_->get_user_id_object(sender_user_id, "inlineQueryPeerTypeSameBotPM"));
|
||||
case telegram_api::inlineQueryPeerTypeBotPM::ID:
|
||||
case telegram_api::inlineQueryPeerTypePM::ID:
|
||||
return td_api::make_object<td_api::chatTypePrivate>(0);
|
||||
@ -2169,7 +2170,7 @@ void InlineQueriesManager::on_new_query(int64 query_id, UserId sender_user_id, L
|
||||
}();
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateNewInlineQuery>(
|
||||
query_id, td_->contacts_manager_->get_user_id_object(sender_user_id, "updateNewInlineQuery"),
|
||||
query_id, td_->user_manager_->get_user_id_object(sender_user_id, "updateNewInlineQuery"),
|
||||
user_location.get_location_object(), std::move(chat_type), query, offset));
|
||||
}
|
||||
|
||||
@ -2180,14 +2181,14 @@ void InlineQueriesManager::on_chosen_result(
|
||||
LOG(ERROR) << "Receive chosen inline query result from invalid " << user_id;
|
||||
return;
|
||||
}
|
||||
LOG_IF(ERROR, !td_->contacts_manager_->have_user(user_id)) << "Receive unknown " << user_id;
|
||||
LOG_IF(ERROR, !td_->user_manager_->have_user(user_id)) << "Receive unknown " << user_id;
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
LOG(ERROR) << "Receive chosen inline query result";
|
||||
return;
|
||||
}
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateNewChosenInlineResult>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "updateNewChosenInlineResult"),
|
||||
td_->user_manager_->get_user_id_object(user_id, "updateNewChosenInlineResult"),
|
||||
user_location.get_location_object(), query, result_id,
|
||||
get_inline_message_id(std::move(input_bot_inline_message_id))));
|
||||
}
|
||||
@ -2199,7 +2200,7 @@ bool InlineQueriesManager::update_bot_usage(UserId bot_user_id) {
|
||||
if (!recently_used_bot_user_ids_.empty() && recently_used_bot_user_ids_[0] == bot_user_id) {
|
||||
return false;
|
||||
}
|
||||
auto r_bot_data = td_->contacts_manager_->get_bot_data(bot_user_id);
|
||||
auto r_bot_data = td_->user_manager_->get_bot_data(bot_user_id);
|
||||
if (r_bot_data.is_error()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "td/telegram/ChannelId.h"
|
||||
#include "td/telegram/ChannelType.h"
|
||||
#include "td/telegram/ConfigManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/DialogParticipant.h"
|
||||
@ -27,6 +26,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/mtproto/ProxySecret.h"
|
||||
|
||||
@ -877,13 +877,13 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
|
||||
switch (result->get_id()) {
|
||||
case telegram_api::urlAuthResultRequest::ID: {
|
||||
auto request = telegram_api::move_object_as<telegram_api::urlAuthResultRequest>(result);
|
||||
UserId bot_user_id = ContactsManager::get_user_id(request->bot_);
|
||||
UserId bot_user_id = UserManager::get_user_id(request->bot_);
|
||||
if (!bot_user_id.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid bot_user_id"));
|
||||
}
|
||||
td_->contacts_manager_->on_get_user(std::move(request->bot_), "RequestUrlAuthQuery");
|
||||
td_->user_manager_->on_get_user(std::move(request->bot_), "RequestUrlAuthQuery");
|
||||
promise_.set_value(td_api::make_object<td_api::loginUrlInfoRequestConfirmation>(
|
||||
url_, request->domain_, td_->contacts_manager_->get_user_id_object(bot_user_id, "RequestUrlAuthQuery"),
|
||||
url_, request->domain_, td_->user_manager_->get_user_id_object(bot_user_id, "RequestUrlAuthQuery"),
|
||||
request->request_write_access_));
|
||||
break;
|
||||
}
|
||||
|
@ -84,6 +84,7 @@
|
||||
#include "td/telegram/TopDialogManager.h"
|
||||
#include "td/telegram/TranscriptionManager.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/Venue.h"
|
||||
#include "td/telegram/Version.h"
|
||||
#include "td/telegram/VideoNotesManager.h"
|
||||
@ -2470,8 +2471,8 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
|
||||
switch (bot_inline_message->get_id()) {
|
||||
case telegram_api::botInlineMessageText::ID: {
|
||||
auto inline_message = move_tl_object_as<telegram_api::botInlineMessageText>(bot_inline_message);
|
||||
auto entities = get_message_entities(td->contacts_manager_.get(), std::move(inline_message->entities_),
|
||||
"botInlineMessageText");
|
||||
auto entities =
|
||||
get_message_entities(td->user_manager_.get(), std::move(inline_message->entities_), "botInlineMessageText");
|
||||
auto status = fix_formatted_text(inline_message->message_, entities, false, true, true, false, false);
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << "Receive error " << status << " while parsing botInlineMessageText " << inline_message->message_;
|
||||
@ -2496,7 +2497,7 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
|
||||
if (inline_message->manual_) {
|
||||
web_page_url = std::move(inline_message->url_);
|
||||
}
|
||||
auto entities = get_message_entities(td->contacts_manager_.get(), std::move(inline_message->entities_),
|
||||
auto entities = get_message_entities(td->user_manager_.get(), std::move(inline_message->entities_),
|
||||
"botInlineMessageMediaWebPage");
|
||||
auto status =
|
||||
fix_formatted_text(inline_message->message_, entities, !web_page_url.empty(), true, true, false, false);
|
||||
@ -2554,7 +2555,7 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
|
||||
case telegram_api::botInlineMessageMediaAuto::ID: {
|
||||
auto inline_message = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(bot_inline_message);
|
||||
auto caption =
|
||||
get_message_text(td->contacts_manager_.get(), inline_message->message_, std::move(inline_message->entities_),
|
||||
get_message_text(td->user_manager_.get(), inline_message->message_, std::move(inline_message->entities_),
|
||||
true, false, 0, false, "create_inline_message_content");
|
||||
if (allowed_media_content_id == td_api::inputMessageAnimation::ID) {
|
||||
result.message_content = make_unique<MessageAnimation>(file_id, std::move(caption), false);
|
||||
@ -2791,9 +2792,9 @@ static Result<InputMessageContent> create_input_message_content(
|
||||
break;
|
||||
}
|
||||
case td_api::inputMessageGame::ID: {
|
||||
TRY_RESULT(game, process_input_message_game(td->contacts_manager_.get(), std::move(input_message_content)));
|
||||
TRY_RESULT(game, process_input_message_game(td->user_manager_.get(), std::move(input_message_content)));
|
||||
via_bot_user_id = game.get_bot_user_id();
|
||||
if (via_bot_user_id == td->contacts_manager_->get_my_id()) {
|
||||
if (via_bot_user_id == td->user_manager_->get_my_id()) {
|
||||
via_bot_user_id = UserId();
|
||||
}
|
||||
|
||||
@ -3586,18 +3587,18 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
|
||||
}
|
||||
switch (dialog_type) {
|
||||
case DialogType::User:
|
||||
return td->contacts_manager_->get_user_default_permissions(dialog_id.get_user_id());
|
||||
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();
|
||||
case DialogType::Channel:
|
||||
return td->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id())
|
||||
.get_effective_restricted_rights();
|
||||
case DialogType::SecretChat:
|
||||
return td->contacts_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
|
||||
return td->user_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return td->contacts_manager_->get_user_default_permissions(UserId());
|
||||
return td->user_manager_->get_user_default_permissions(UserId());
|
||||
}
|
||||
}();
|
||||
|
||||
@ -3692,7 +3693,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
|
||||
return Status::Error(400, "Non-anonymous polls can't be sent to channel chats");
|
||||
}
|
||||
if (dialog_type == DialogType::User && !is_forward && !td->auth_manager_->is_bot() &&
|
||||
!td->contacts_manager_->is_user_bot(dialog_id.get_user_id())) {
|
||||
!td->user_manager_->is_user_bot(dialog_id.get_user_id())) {
|
||||
return Status::Error(400, "Polls can't be sent to the private chat");
|
||||
}
|
||||
if (dialog_type == DialogType::SecretChat) {
|
||||
@ -3735,7 +3736,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
|
||||
return Status::Error(400, "Not enough rights to send video notes to the chat");
|
||||
}
|
||||
if (dialog_type == DialogType::User &&
|
||||
td->contacts_manager_->get_user_voice_messages_forbidden(dialog_id.get_user_id())) {
|
||||
td->user_manager_->get_user_voice_messages_forbidden(dialog_id.get_user_id())) {
|
||||
return Status::Error(400, "User restricted receiving of voice messages");
|
||||
}
|
||||
break;
|
||||
@ -3744,7 +3745,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
|
||||
return Status::Error(400, "Not enough rights to send voice notes to the chat");
|
||||
}
|
||||
if (dialog_type == DialogType::User &&
|
||||
td->contacts_manager_->get_user_voice_messages_forbidden(dialog_id.get_user_id())) {
|
||||
td->user_manager_->get_user_voice_messages_forbidden(dialog_id.get_user_id())) {
|
||||
return Status::Error(400, "User restricted receiving of video messages");
|
||||
}
|
||||
break;
|
||||
@ -5397,7 +5398,7 @@ void register_message_content(Td *td, const MessageContent *content, MessageFull
|
||||
return td->stickers_manager_->register_premium_gift(static_cast<const MessageGiveaway *>(content)->months,
|
||||
message_full_id, source);
|
||||
case MessageContentType::SuggestProfilePhoto:
|
||||
return td->contacts_manager_->register_suggested_profile_photo(
|
||||
return td->user_manager_->register_suggested_profile_photo(
|
||||
static_cast<const MessageSuggestProfilePhoto *>(content)->photo);
|
||||
case MessageContentType::Story:
|
||||
return td->story_manager_->register_story(static_cast<const MessageStory *>(content)->story_full_id,
|
||||
@ -6052,7 +6053,7 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
case telegram_api::messageMediaContact::ID: {
|
||||
auto media = move_tl_object_as<telegram_api::messageMediaContact>(media_ptr);
|
||||
if (media->user_id_ != 0) {
|
||||
td->contacts_manager_->get_user_id_object(UserId(media->user_id_),
|
||||
td->user_manager_->get_user_id_object(UserId(media->user_id_),
|
||||
"MessageMediaContact"); // to ensure updateUser
|
||||
}
|
||||
return make_unique<MessageContact>(Contact(std::move(media->phone_number_), std::move(media->first_name_),
|
||||
@ -7052,7 +7053,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
case MessageContentType::ChatCreate: {
|
||||
const auto *m = static_cast<const MessageChatCreate *>(content);
|
||||
return make_tl_object<td_api::messageBasicGroupChatCreate>(
|
||||
m->title, td->contacts_manager_->get_user_ids_object(m->participant_user_ids, "MessageChatCreate"));
|
||||
m->title, td->user_manager_->get_user_ids_object(m->participant_user_ids, "MessageChatCreate"));
|
||||
}
|
||||
case MessageContentType::ChatChangeTitle: {
|
||||
const auto *m = static_cast<const MessageChatChangeTitle *>(content);
|
||||
@ -7074,7 +7075,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
case MessageContentType::ChatAddUsers: {
|
||||
const auto *m = static_cast<const MessageChatAddUsers *>(content);
|
||||
return make_tl_object<td_api::messageChatAddMembers>(
|
||||
td->contacts_manager_->get_user_ids_object(m->user_ids, "MessageChatAddUsers"));
|
||||
td->user_manager_->get_user_ids_object(m->user_ids, "MessageChatAddUsers"));
|
||||
}
|
||||
case MessageContentType::ChatJoinedByLink: {
|
||||
const MessageChatJoinedByLink *m = static_cast<const MessageChatJoinedByLink *>(content);
|
||||
@ -7086,7 +7087,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
case MessageContentType::ChatDeleteUser: {
|
||||
const auto *m = static_cast<const MessageChatDeleteUser *>(content);
|
||||
return make_tl_object<td_api::messageChatDeleteMember>(
|
||||
td->contacts_manager_->get_user_id_object(m->user_id, "MessageChatDeleteMember"));
|
||||
td->user_manager_->get_user_id_object(m->user_id, "MessageChatDeleteMember"));
|
||||
}
|
||||
case MessageContentType::ChatMigrateTo: {
|
||||
const auto *m = static_cast<const MessageChatMigrateTo *>(content);
|
||||
@ -7116,7 +7117,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
case MessageContentType::ChatSetTtl: {
|
||||
const auto *m = static_cast<const MessageChatSetTtl *>(content);
|
||||
return make_tl_object<td_api::messageChatSetMessageAutoDeleteTime>(
|
||||
m->ttl, td->contacts_manager_->get_user_id_object(m->from_user_id, "MessageChatSetTtl"));
|
||||
m->ttl, td->user_manager_->get_user_id_object(m->from_user_id, "MessageChatSetTtl"));
|
||||
}
|
||||
case MessageContentType::Call: {
|
||||
const auto *m = static_cast<const MessageCall *>(content);
|
||||
@ -7200,7 +7201,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
const auto *m = static_cast<const MessageInviteToGroupCall *>(content);
|
||||
return make_tl_object<td_api::messageInviteVideoChatParticipants>(
|
||||
td->group_call_manager_->get_group_call_id(m->input_group_call_id, DialogId()).get(),
|
||||
td->contacts_manager_->get_user_ids_object(m->user_ids, "MessageInviteToGroupCall"));
|
||||
td->user_manager_->get_user_ids_object(m->user_ids, "MessageInviteToGroupCall"));
|
||||
}
|
||||
case MessageContentType::ChatSetTheme: {
|
||||
const auto *m = static_cast<const MessageChatSetTheme *>(content);
|
||||
@ -7219,9 +7220,9 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
int64 gifter_user_id = 0;
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
if (user_id != ContactsManager::get_service_notifications_user_id() &&
|
||||
!td->contacts_manager_->is_user_bot(user_id) && !td->contacts_manager_->is_user_support(user_id)) {
|
||||
gifter_user_id = td->contacts_manager_->get_user_id_object(user_id, "MessageGiftPremium");
|
||||
if (user_id != UserManager::get_service_notifications_user_id() && !td->user_manager_->is_user_bot(user_id) &&
|
||||
!td->user_manager_->is_user_support(user_id)) {
|
||||
gifter_user_id = td->user_manager_->get_user_id_object(user_id, "MessageGiftPremium");
|
||||
}
|
||||
}
|
||||
return make_tl_object<td_api::messageGiftedPremium>(
|
||||
@ -7309,7 +7310,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
td->dialog_manager_->get_chat_id_object(DialogId(m->boosted_channel_id), "messagePremiumGiveawayWinners"),
|
||||
m->giveaway_message_id.get(), m->additional_dialog_count, m->winners_selection_date, m->only_new_subscribers,
|
||||
m->was_refunded, m->month_count, m->prize_description, m->winner_count,
|
||||
td->contacts_manager_->get_user_ids_object(m->winner_user_ids, "messagePremiumGiveawayWinners"),
|
||||
td->user_manager_->get_user_ids_object(m->winner_user_ids, "messagePremiumGiveawayWinners"),
|
||||
m->unclaimed_count);
|
||||
}
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
|
@ -6,7 +6,6 @@
|
||||
//
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
@ -15,6 +14,7 @@
|
||||
#include "td/telegram/SecretChatLayer.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/actor/MultiPromise.h"
|
||||
|
||||
@ -162,7 +162,7 @@ tl_object_ptr<td_api::TextEntityType> MessageEntity::get_text_entity_type_object
|
||||
case MessageEntity::Type::TextUrl:
|
||||
return make_tl_object<td_api::textEntityTypeTextUrl>(argument);
|
||||
case MessageEntity::Type::MentionName:
|
||||
// can't use contacts_manager, because can be called from a static request
|
||||
// can't use user_manager, because can be called from a static request
|
||||
return make_tl_object<td_api::textEntityTypeMentionName>(user_id.get());
|
||||
case MessageEntity::Type::Cashtag:
|
||||
return make_tl_object<td_api::textEntityTypeCashtag>();
|
||||
@ -3540,7 +3540,7 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
|
||||
return result;
|
||||
}
|
||||
|
||||
Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contacts_manager,
|
||||
Result<vector<MessageEntity>> get_message_entities(const UserManager *user_manager,
|
||||
vector<tl_object_ptr<td_api::textEntity>> &&input_entities,
|
||||
bool allow_all) {
|
||||
vector<MessageEntity> entities;
|
||||
@ -3613,8 +3613,8 @@ Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contac
|
||||
}
|
||||
auto user_id = LinkManager::get_link_user_id(entity->url_);
|
||||
if (user_id.is_valid()) {
|
||||
if (contacts_manager != nullptr) {
|
||||
TRY_STATUS(contacts_manager->get_input_user(user_id));
|
||||
if (user_manager != nullptr) {
|
||||
TRY_STATUS(user_manager->get_input_user(user_id));
|
||||
}
|
||||
entities.emplace_back(offset, length, user_id);
|
||||
break;
|
||||
@ -3629,8 +3629,8 @@ Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contac
|
||||
case td_api::textEntityTypeMentionName::ID: {
|
||||
auto entity = static_cast<const td_api::textEntityTypeMentionName *>(input_entity->type_.get());
|
||||
UserId user_id(entity->user_id_);
|
||||
if (contacts_manager != nullptr) {
|
||||
TRY_STATUS(contacts_manager->get_input_user(user_id));
|
||||
if (user_manager != nullptr) {
|
||||
TRY_STATUS(user_manager->get_input_user(user_id));
|
||||
}
|
||||
entities.emplace_back(offset, length, user_id);
|
||||
break;
|
||||
@ -3666,7 +3666,7 @@ Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contac
|
||||
return std::move(entities);
|
||||
}
|
||||
|
||||
vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manager,
|
||||
vector<MessageEntity> get_message_entities(const UserManager *user_manager,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
|
||||
const char *source) {
|
||||
vector<MessageEntity> entities;
|
||||
@ -3777,11 +3777,11 @@ vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manag
|
||||
LOG(ERROR) << "Receive invalid " << user_id << " in MentionName from " << source;
|
||||
continue;
|
||||
}
|
||||
if (contacts_manager == nullptr) {
|
||||
if (user_manager == nullptr) {
|
||||
LOG(ERROR) << "Receive unknown " << user_id << " in MentionName from " << source;
|
||||
continue;
|
||||
}
|
||||
auto r_input_user = contacts_manager->get_input_user(user_id);
|
||||
auto r_input_user = user_manager->get_input_user(user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
LOG(ERROR) << "Receive wrong " << user_id << ": " << r_input_user.error() << " from " << source;
|
||||
continue;
|
||||
@ -3942,18 +3942,19 @@ vector<MessageEntity> get_message_entities(Td *td, vector<tl_object_ptr<secret_a
|
||||
return entities;
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::textWithEntities> get_input_text_with_entities(
|
||||
const ContactsManager *contacts_manager, const FormattedText &text, const char *source) {
|
||||
telegram_api::object_ptr<telegram_api::textWithEntities> get_input_text_with_entities(const UserManager *user_manager,
|
||||
const FormattedText &text,
|
||||
const char *source) {
|
||||
return telegram_api::make_object<telegram_api::textWithEntities>(
|
||||
text.text, get_input_message_entities(contacts_manager, text.entities, source));
|
||||
text.text, get_input_message_entities(user_manager, text.entities, source));
|
||||
}
|
||||
|
||||
FormattedText get_formatted_text(const ContactsManager *contacts_manager,
|
||||
FormattedText get_formatted_text(const UserManager *user_manager,
|
||||
telegram_api::object_ptr<telegram_api::textWithEntities> text_with_entities,
|
||||
bool allow_empty, bool skip_new_entities, bool skip_bot_commands,
|
||||
bool skip_media_timestamps, bool skip_trim, const char *source) {
|
||||
CHECK(text_with_entities != nullptr);
|
||||
auto entities = get_message_entities(contacts_manager, std::move(text_with_entities->entities_), source);
|
||||
auto entities = get_message_entities(user_manager, std::move(text_with_entities->entities_), source);
|
||||
auto status = fix_formatted_text(text_with_entities->text_, entities, allow_empty, skip_new_entities,
|
||||
skip_bot_commands, skip_media_timestamps, skip_trim);
|
||||
if (status.is_error()) {
|
||||
@ -4442,11 +4443,11 @@ Status fix_formatted_text(string &text, vector<MessageEntity> &entities, bool al
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
FormattedText get_message_text(const ContactsManager *contacts_manager, string message_text,
|
||||
FormattedText get_message_text(const UserManager *user_manager, string message_text,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
|
||||
bool skip_new_entities, bool skip_media_timestamps, int32 send_date, bool from_album,
|
||||
const char *source) {
|
||||
auto entities = get_message_entities(contacts_manager, std::move(server_entities), source);
|
||||
auto entities = get_message_entities(user_manager, std::move(server_entities), source);
|
||||
auto debug_message_text = message_text;
|
||||
auto debug_entities = entities;
|
||||
auto status = fix_formatted_text(message_text, entities, true, skip_new_entities, true, skip_media_timestamps, false);
|
||||
@ -4528,8 +4529,8 @@ Result<FormattedText> get_formatted_text(const Td *td, DialogId dialog_id,
|
||||
return Status::Error(400, "Text must be non-empty");
|
||||
}
|
||||
|
||||
TRY_RESULT(entities, get_message_entities(td->contacts_manager_.get(), std::move(text->entities_)));
|
||||
auto need_skip_bot_commands = need_always_skip_bot_commands(td->contacts_manager_.get(), dialog_id, is_bot);
|
||||
TRY_RESULT(entities, get_message_entities(td->user_manager_.get(), std::move(text->entities_)));
|
||||
auto need_skip_bot_commands = need_always_skip_bot_commands(td->user_manager_.get(), dialog_id, is_bot);
|
||||
bool parse_markdown = td->option_manager_->get_option_boolean("always_parse_markdown");
|
||||
bool skip_new_entities = is_bot && td->option_manager_->get_option_integer("session_count") > 1;
|
||||
TRY_STATUS(fix_formatted_text(text->text_, entities, allow_empty, skip_new_entities || parse_markdown,
|
||||
@ -4581,7 +4582,7 @@ bool has_bot_commands(const FormattedText *text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool need_always_skip_bot_commands(const ContactsManager *contacts_manager, DialogId dialog_id, bool is_bot) {
|
||||
bool need_always_skip_bot_commands(const UserManager *user_manager, DialogId dialog_id, bool is_bot) {
|
||||
if (!dialog_id.is_valid()) {
|
||||
return true;
|
||||
}
|
||||
@ -4592,11 +4593,11 @@ bool need_always_skip_bot_commands(const ContactsManager *contacts_manager, Dial
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
return user_id == ContactsManager::get_replies_bot_user_id() || !contacts_manager->is_user_bot(user_id);
|
||||
return user_id == UserManager::get_replies_bot_user_id() || !user_manager->is_user_bot(user_id);
|
||||
}
|
||||
case DialogType::SecretChat: {
|
||||
auto user_id = contacts_manager->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
return !user_id.is_valid() || !contacts_manager->is_user_bot(user_id);
|
||||
auto user_id = user_manager->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||
return !user_id.is_valid() || !user_manager->is_user_bot(user_id);
|
||||
}
|
||||
case DialogType::Chat:
|
||||
case DialogType::Channel:
|
||||
@ -4608,7 +4609,7 @@ bool need_always_skip_bot_commands(const ContactsManager *contacts_manager, Dial
|
||||
}
|
||||
}
|
||||
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const UserManager *user_manager,
|
||||
const vector<MessageEntity> &entities,
|
||||
const char *source) {
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> result;
|
||||
@ -4650,7 +4651,7 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
|
||||
make_tl_object<telegram_api::messageEntityTextUrl>(entity.offset, entity.length, entity.argument));
|
||||
break;
|
||||
case MessageEntity::Type::MentionName: {
|
||||
auto input_user = contacts_manager->get_input_user_force(entity.user_id);
|
||||
auto input_user = user_manager->get_input_user_force(entity.user_id);
|
||||
result.push_back(make_tl_object<telegram_api::inputMessageEntityMentionName>(entity.offset, entity.length,
|
||||
std::move(input_user)));
|
||||
break;
|
||||
@ -4690,11 +4691,11 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
|
||||
return result;
|
||||
}
|
||||
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const UserManager *user_manager,
|
||||
const FormattedText *text,
|
||||
const char *source) {
|
||||
if (text != nullptr && !text->entities.empty()) {
|
||||
return get_input_message_entities(contacts_manager, text->entities, source);
|
||||
return get_input_message_entities(user_manager, text->entities, source);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@ -4712,7 +4713,7 @@ void remove_unallowed_entities(const Td *td, FormattedText &text, DialogId dialo
|
||||
}
|
||||
|
||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
||||
auto layer = td->contacts_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id());
|
||||
auto layer = td->user_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id());
|
||||
td::remove_if(text.entities, [layer](const MessageEntity &entity) {
|
||||
if (layer < static_cast<int32>(SecretChatLayer::NewEntities) &&
|
||||
(entity.type == MessageEntity::Type::Underline || entity.type == MessageEntity::Type::Strikethrough ||
|
||||
|
@ -24,10 +24,10 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class ContactsManager;
|
||||
class Dependencies;
|
||||
class MultiPromiseActor;
|
||||
class Td;
|
||||
class UserManager;
|
||||
|
||||
class MessageEntity {
|
||||
public:
|
||||
@ -155,7 +155,7 @@ inline bool operator!=(const FormattedText &lhs, const FormattedText &rhs) {
|
||||
|
||||
const FlatHashSet<Slice, SliceHash> &get_valid_short_usernames();
|
||||
|
||||
Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contacts_manager,
|
||||
Result<vector<MessageEntity>> get_message_entities(const UserManager *user_manager,
|
||||
vector<tl_object_ptr<td_api::textEntity>> &&input_entities,
|
||||
bool allow_all = false);
|
||||
|
||||
@ -201,28 +201,29 @@ FormattedText get_markdown_v3(FormattedText text);
|
||||
|
||||
Result<vector<MessageEntity>> parse_html(string &str);
|
||||
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const UserManager *user_manager,
|
||||
const vector<MessageEntity> &entities,
|
||||
const char *source);
|
||||
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const UserManager *user_manager,
|
||||
const FormattedText *text,
|
||||
const char *source);
|
||||
|
||||
vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entities(
|
||||
const vector<MessageEntity> &entities, int32 layer);
|
||||
|
||||
vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manager,
|
||||
vector<MessageEntity> get_message_entities(const UserManager *user_manager,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
|
||||
const char *source);
|
||||
|
||||
vector<MessageEntity> get_message_entities(Td *td, vector<tl_object_ptr<secret_api::MessageEntity>> &&secret_entities,
|
||||
bool is_premium, MultiPromiseActor &load_data_multipromise);
|
||||
|
||||
telegram_api::object_ptr<telegram_api::textWithEntities> get_input_text_with_entities(
|
||||
const ContactsManager *contacts_manager, const FormattedText &text, const char *source);
|
||||
telegram_api::object_ptr<telegram_api::textWithEntities> get_input_text_with_entities(const UserManager *user_manager,
|
||||
const FormattedText &text,
|
||||
const char *source);
|
||||
|
||||
FormattedText get_formatted_text(const ContactsManager *contacts_manager,
|
||||
FormattedText get_formatted_text(const UserManager *user_manager,
|
||||
telegram_api::object_ptr<telegram_api::textWithEntities> text_with_entities,
|
||||
bool allow_empty, bool skip_new_entities, bool skip_bot_commands,
|
||||
bool skip_media_timestamps, bool skip_trim, const char *source);
|
||||
@ -232,7 +233,7 @@ Status fix_formatted_text(string &text, vector<MessageEntity> &entities, bool al
|
||||
bool skip_bot_commands, bool skip_media_timestamps, bool skip_trim,
|
||||
int32 *ltrim_count = nullptr) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
FormattedText get_message_text(const ContactsManager *contacts_manager, string message_text,
|
||||
FormattedText get_message_text(const UserManager *user_manager, string message_text,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
|
||||
bool skip_new_entities, bool skip_media_timestamps, int32 send_date, bool from_album,
|
||||
const char *source);
|
||||
@ -253,6 +254,6 @@ bool has_media_timestamps(const FormattedText *text, int32 min_media_timestamp,
|
||||
|
||||
bool has_bot_commands(const FormattedText *text);
|
||||
|
||||
bool need_always_skip_bot_commands(const ContactsManager *contacts_manager, DialogId dialog_id, bool is_bot);
|
||||
bool need_always_skip_bot_commands(const UserManager *user_manager, DialogId dialog_id, bool is_bot);
|
||||
|
||||
} // namespace td
|
||||
|
@ -6,13 +6,13 @@
|
||||
//
|
||||
#include "td/telegram/MessageForwardInfo.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/MessageSender.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
@ -33,7 +33,7 @@ void LastForwardedMessageInfo::validate() {
|
||||
|
||||
void LastForwardedMessageInfo::hide_sender_if_needed(Td *td) {
|
||||
if (sender_name_.empty() && sender_dialog_id_.get_type() == DialogType::User) {
|
||||
auto private_forward_name = td->contacts_manager_->get_user_private_forward_name(sender_dialog_id_.get_user_id());
|
||||
auto private_forward_name = td->user_manager_->get_user_private_forward_name(sender_dialog_id_.get_user_id());
|
||||
if (!private_forward_name.empty()) {
|
||||
dialog_id_ = DialogId();
|
||||
message_id_ = MessageId();
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "td/telegram/MessageContent.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -295,7 +296,7 @@ Status MessageImportManager::can_import_messages(DialogId dialog_id) {
|
||||
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
if (!td_->contacts_manager_->is_user_contact(dialog_id.get_user_id(), true)) {
|
||||
if (!td_->user_manager_->is_user_contact(dialog_id.get_user_id(), true)) {
|
||||
return Status::Error(400, "User must be a mutual contact");
|
||||
}
|
||||
break;
|
||||
|
@ -57,8 +57,8 @@ MessageInputReplyTo::MessageInputReplyTo(Td *td,
|
||||
dialog_id_ = dialog_id;
|
||||
|
||||
if (!reply_to->quote_text_.empty()) {
|
||||
auto entities = get_message_entities(td->contacts_manager_.get(), std::move(reply_to->quote_entities_),
|
||||
"inputReplyToMessage");
|
||||
auto entities =
|
||||
get_message_entities(td->user_manager_.get(), std::move(reply_to->quote_entities_), "inputReplyToMessage");
|
||||
auto status = fix_formatted_text(reply_to->quote_text_, entities, true, true, true, true, false);
|
||||
if (status.is_error()) {
|
||||
if (!clean_input_string(reply_to->quote_text_)) {
|
||||
@ -120,7 +120,7 @@ telegram_api::object_ptr<telegram_api::InputReplyTo> MessageInputReplyTo::get_in
|
||||
if (!quote_.text.empty()) {
|
||||
flags |= telegram_api::inputReplyToMessage::QUOTE_TEXT_MASK;
|
||||
}
|
||||
auto quote_entities = get_input_message_entities(td->contacts_manager_.get(), quote_.entities, "get_input_reply_to");
|
||||
auto quote_entities = get_input_message_entities(td->user_manager_.get(), quote_.entities, "get_input_reply_to");
|
||||
if (!quote_entities.empty()) {
|
||||
flags |= telegram_api::inputReplyToMessage::QUOTE_ENTITIES_MASK;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
@ -94,7 +95,7 @@ td_api::object_ptr<td_api::MessageOrigin> MessageOrigin::get_message_origin_obje
|
||||
sender_name_.empty() ? author_signature_ : sender_name_);
|
||||
}
|
||||
return td_api::make_object<td_api::messageOriginUser>(
|
||||
td->contacts_manager_->get_user_id_object(sender_user_id_, "messageOriginUser"));
|
||||
td->user_manager_->get_user_id_object(sender_user_id_, "messageOriginUser"));
|
||||
}
|
||||
|
||||
bool MessageOrigin::is_sender_hidden() const {
|
||||
@ -121,7 +122,7 @@ DialogId MessageOrigin::get_sender() const {
|
||||
|
||||
void MessageOrigin::hide_sender_if_needed(Td *td) {
|
||||
if (!is_sender_hidden() && !message_id_.is_valid() && !sender_dialog_id_.is_valid()) {
|
||||
auto private_forward_name = td->contacts_manager_->get_user_private_forward_name(sender_user_id_);
|
||||
auto private_forward_name = td->user_manager_->get_user_private_forward_name(sender_user_id_);
|
||||
if (!private_forward_name.empty()) {
|
||||
sender_user_id_ = UserId();
|
||||
sender_name_ = std::move(private_forward_name);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
#include "td/actor/SleepActor.h"
|
||||
@ -198,7 +199,7 @@ class GetMessageReactionsListQuery final : public Td::ResultHandler {
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetMessageReactionsListQuery: " << to_string(ptr);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetMessageReactionsListQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetMessageReactionsListQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetMessageReactionsListQuery");
|
||||
|
||||
int32 total_count = ptr->count_;
|
||||
@ -516,7 +517,7 @@ unique_ptr<MessageReactions> MessageReactions::get_message_reactions(
|
||||
auto dialog_type = dialog_id.get_type();
|
||||
if (dialog_type == DialogType::User) {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
if (!td->contacts_manager_->have_min_user(user_id)) {
|
||||
if (!td->user_manager_->have_min_user(user_id)) {
|
||||
LOG(ERROR) << "Receive unknown " << user_id;
|
||||
continue;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/MessageSender.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -59,7 +60,7 @@ MessageReplyInfo::MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageRe
|
||||
auto dialog_type = dialog_id.get_type();
|
||||
if (dialog_type == DialogType::User) {
|
||||
auto replier_user_id = dialog_id.get_user_id();
|
||||
if (!td->contacts_manager_->have_min_user(replier_user_id)) {
|
||||
if (!td->user_manager_->have_min_user(replier_user_id)) {
|
||||
LOG(ERROR) << "Receive unknown replied " << replier_user_id;
|
||||
continue;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -27,9 +28,9 @@ td_api::object_ptr<td_api::MessageSender> get_message_sender_object_const(Td *td
|
||||
if (!user_id.is_valid()) {
|
||||
// can happen only if the server sends a message with wrong sender
|
||||
LOG(ERROR) << "Receive message with wrong sender " << user_id << '/' << dialog_id << " from " << source;
|
||||
user_id = td->contacts_manager_->add_service_notifications_user();
|
||||
user_id = td->user_manager_->add_service_notifications_user();
|
||||
}
|
||||
return td_api::make_object<td_api::messageSenderUser>(td->contacts_manager_->get_user_id_object(user_id, source));
|
||||
return td_api::make_object<td_api::messageSenderUser>(td->user_manager_->get_user_id_object(user_id, source));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::MessageSender> get_message_sender_object_const(Td *td, DialogId dialog_id,
|
||||
@ -46,9 +47,9 @@ td_api::object_ptr<td_api::MessageSender> get_message_sender_object(Td *td, User
|
||||
td->dialog_manager_->force_create_dialog(dialog_id, source, true);
|
||||
}
|
||||
if (!user_id.is_valid() && td->auth_manager_->is_bot()) {
|
||||
td->contacts_manager_->add_anonymous_bot_user();
|
||||
td->contacts_manager_->add_channel_bot_user();
|
||||
td->contacts_manager_->add_service_notifications_user();
|
||||
td->user_manager_->add_anonymous_bot_user();
|
||||
td->user_manager_->add_channel_bot_user();
|
||||
td->user_manager_->add_service_notifications_user();
|
||||
}
|
||||
return get_message_sender_object_const(td, user_id, dialog_id, source);
|
||||
}
|
||||
@ -65,8 +66,8 @@ td_api::object_ptr<td_api::MessageSender> get_min_message_sender_object(Td *td,
|
||||
auto dialog_type = dialog_id.get_type();
|
||||
if (dialog_type == DialogType::User) {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
if (td->contacts_manager_->have_min_user(user_id)) {
|
||||
return td_api::make_object<td_api::messageSenderUser>(td->contacts_manager_->get_user_id_object(user_id, source));
|
||||
if (td->user_manager_->have_min_user(user_id)) {
|
||||
return td_api::make_object<td_api::messageSenderUser>(td->user_manager_->get_user_id_object(user_id, source));
|
||||
}
|
||||
} else {
|
||||
if (!td->messages_manager_->have_dialog(dialog_id) &&
|
||||
@ -95,7 +96,7 @@ vector<DialogId> get_message_sender_dialog_ids(Td *td,
|
||||
continue;
|
||||
}
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
if (!td->contacts_manager_->have_user(dialog_id.get_user_id())) {
|
||||
if (!td->user_manager_->have_user(dialog_id.get_user_id())) {
|
||||
LOG(ERROR) << "Receive unknown " << dialog_id.get_user_id();
|
||||
continue;
|
||||
}
|
||||
@ -140,7 +141,7 @@ Result<DialogId> get_message_sender_dialog_id(Td *td,
|
||||
}
|
||||
return Status::Error(400, "Invalid user identifier specified");
|
||||
}
|
||||
bool know_user = td->contacts_manager_->have_user_force(user_id, "get_message_sender_dialog_id");
|
||||
bool know_user = td->user_manager_->have_user_force(user_id, "get_message_sender_dialog_id");
|
||||
if (check_access && !know_user) {
|
||||
return Status::Error(400, "Unknown user identifier specified");
|
||||
}
|
||||
@ -156,7 +157,7 @@ Result<DialogId> get_message_sender_dialog_id(Td *td,
|
||||
}
|
||||
bool know_dialog =
|
||||
dialog_id.get_type() == DialogType::User
|
||||
? td->contacts_manager_->have_user_force(dialog_id.get_user_id(), "get_message_sender_dialog_id 2")
|
||||
? td->user_manager_->have_user_force(dialog_id.get_user_id(), "get_message_sender_dialog_id 2")
|
||||
: td->dialog_manager_->have_dialog_force(dialog_id, "get_message_sender_dialog_id");
|
||||
if (check_access && !know_dialog) {
|
||||
return Status::Error(400, "Unknown chat identifier specified");
|
||||
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
#include "td/telegram/MessageViewer.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -17,10 +17,9 @@ MessageViewer::MessageViewer(telegram_api::object_ptr<telegram_api::readParticip
|
||||
: MessageViewer(UserId(read_date->user_id_), read_date->date_) {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::messageViewer> MessageViewer::get_message_viewer_object(
|
||||
ContactsManager *contacts_manager) const {
|
||||
td_api::object_ptr<td_api::messageViewer> MessageViewer::get_message_viewer_object(UserManager *user_manager) const {
|
||||
return td_api::make_object<td_api::messageViewer>(
|
||||
contacts_manager->get_user_id_object(user_id_, "get_message_viewer_object"), date_);
|
||||
user_manager->get_user_id_object(user_id_, "get_message_viewer_object"), date_);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewer &viewer) {
|
||||
@ -42,11 +41,10 @@ vector<UserId> MessageViewers::get_user_ids() const {
|
||||
return transform(message_viewers_, [](auto &viewer) { return viewer.get_user_id(); });
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::messageViewers> MessageViewers::get_message_viewers_object(
|
||||
ContactsManager *contacts_manager) const {
|
||||
td_api::object_ptr<td_api::messageViewers> MessageViewers::get_message_viewers_object(UserManager *user_manager) const {
|
||||
return td_api::make_object<td_api::messageViewers>(
|
||||
transform(message_viewers_, [contacts_manager](const MessageViewer &message_viewer) {
|
||||
return message_viewer.get_message_viewer_object(contacts_manager);
|
||||
transform(message_viewers_, [user_manager](const MessageViewer &message_viewer) {
|
||||
return message_viewer.get_message_viewer_object(user_manager);
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class ContactsManager;
|
||||
class UserManager;
|
||||
|
||||
class MessageViewer {
|
||||
UserId user_id_;
|
||||
@ -37,7 +37,7 @@ class MessageViewer {
|
||||
return user_id_ == UserId() && date_ == 0;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::messageViewer> get_message_viewer_object(ContactsManager *contacts_manager) const;
|
||||
td_api::object_ptr<td_api::messageViewer> get_message_viewer_object(UserManager *user_manager) const;
|
||||
};
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewer &viewer);
|
||||
@ -54,7 +54,7 @@ class MessageViewers {
|
||||
|
||||
vector<UserId> get_user_ids() const;
|
||||
|
||||
td_api::object_ptr<td_api::messageViewers> get_message_viewers_object(ContactsManager *contacts_manager) const;
|
||||
td_api::object_ptr<td_api::messageViewers> get_message_viewers_object(UserManager *user_manager) const;
|
||||
};
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewers &viewers);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "td/telegram/ForumTopicManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
@ -67,7 +68,7 @@ MessagesInfo get_messages_info(Td *td, DialogId dialog_id,
|
||||
break;
|
||||
}
|
||||
|
||||
td->contacts_manager_->on_get_users(std::move(users), source);
|
||||
td->user_manager_->on_get_users(std::move(users), source);
|
||||
td->contacts_manager_->on_get_chats(std::move(chats), source);
|
||||
td->forum_topic_manager_->on_get_forum_topic_infos(dialog_id, std::move(topics), source);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,6 @@
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ChannelId.h"
|
||||
#include "td/telegram/ChatId.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DeviceTokenManager.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Document.h"
|
||||
@ -33,6 +32,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
#include "td/mtproto/mtproto_api.h"
|
||||
@ -846,7 +846,7 @@ int32 NotificationManager::get_notification_delay_ms(DialogId dialog_id, const P
|
||||
|
||||
auto server_time = G()->server_time();
|
||||
auto delay_ms = [&] {
|
||||
auto online_info = td_->contacts_manager_->get_my_online_status();
|
||||
auto online_info = td_->user_manager_->get_my_online_status();
|
||||
if (!online_info.is_online_local && online_info.is_online_remote) {
|
||||
// If we are offline, but online from some other client, then delay notification
|
||||
// for 'notification_cloud_delay' seconds.
|
||||
@ -3083,7 +3083,7 @@ void NotificationManager::add_push_notification_user(
|
||||
false /*ignored*/, false /*ignored*/, sender_user_id.get(), sender_access_hash, user_name, string(), string(),
|
||||
string(), std::move(sender_photo), nullptr, 0, Auto(), string(), string(), nullptr,
|
||||
vector<telegram_api::object_ptr<telegram_api::username>>(), 0, nullptr, nullptr);
|
||||
td_->contacts_manager_->on_get_user(std::move(user), "add_push_notification_user");
|
||||
td_->user_manager_->on_get_user(std::move(user), "add_push_notification_user");
|
||||
}
|
||||
|
||||
Status NotificationManager::parse_push_notification_attach(DialogId dialog_id, string &loc_key, JsonObject &custom,
|
||||
@ -3573,7 +3573,7 @@ Status NotificationManager::process_push_notification_payload(string payload, bo
|
||||
}
|
||||
|
||||
if (sender_user_id.is_valid() &&
|
||||
!td_->contacts_manager_->have_user_force(sender_user_id, "process_push_notification_payload")) {
|
||||
!td_->user_manager_->have_user_force(sender_user_id, "process_push_notification_payload")) {
|
||||
int64 sender_access_hash = -1;
|
||||
telegram_api::object_ptr<telegram_api::UserProfilePhoto> sender_photo;
|
||||
TRY_RESULT(mtpeer, custom.extract_optional_field("mtpeer", JsonValue::Type::Object));
|
||||
@ -3847,7 +3847,7 @@ void NotificationManager::add_message_push_notification(DialogId dialog_id, Mess
|
||||
}
|
||||
|
||||
if (sender_user_id.is_valid() &&
|
||||
!td_->contacts_manager_->have_user_force(sender_user_id, "add_message_push_notification")) {
|
||||
!td_->user_manager_->have_user_force(sender_user_id, "add_message_push_notification")) {
|
||||
add_push_notification_user(sender_user_id, -1, sender_name, nullptr);
|
||||
}
|
||||
|
||||
@ -3875,8 +3875,7 @@ void NotificationManager::add_message_push_notification(DialogId dialog_id, Mess
|
||||
auto group_id = info.group_id;
|
||||
CHECK(group_id.is_valid());
|
||||
|
||||
bool is_outgoing =
|
||||
sender_user_id.is_valid() ? td_->contacts_manager_->get_my_id() == sender_user_id : is_from_scheduled;
|
||||
bool is_outgoing = sender_user_id.is_valid() ? td_->user_manager_->get_my_id() == sender_user_id : is_from_scheduled;
|
||||
if (log_event_id != 0) {
|
||||
VLOG(notifications) << "Register temporary " << notification_id << " with log event " << log_event_id;
|
||||
NotificationObjectFullId object_full_id(dialog_id, message_id);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/VoiceNotesManager.h"
|
||||
|
||||
#include "td/db/binlog/BinlogEvent.h"
|
||||
@ -271,7 +272,7 @@ class GetNotifySettingsExceptionsQuery final : public Td::ResultHandler {
|
||||
break;
|
||||
}
|
||||
}
|
||||
td_->contacts_manager_->on_get_users(std::move(users), "GetNotifySettingsExceptionsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(users), "GetNotifySettingsExceptionsQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(chats), "GetNotifySettingsExceptionsQuery");
|
||||
for (auto &dialog_id : dialog_ids) {
|
||||
td_->dialog_manager_->force_create_dialog(dialog_id, "GetNotifySettingsExceptionsQuery");
|
||||
@ -326,7 +327,7 @@ class GetStoryNotifySettingsExceptionsQuery final : public Td::ResultHandler {
|
||||
break;
|
||||
}
|
||||
}
|
||||
td_->contacts_manager_->on_get_users(std::move(users), "GetStoryNotifySettingsExceptionsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(users), "GetStoryNotifySettingsExceptionsQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(chats), "GetStoryNotifySettingsExceptionsQuery");
|
||||
for (auto &dialog_id : dialog_ids) {
|
||||
td_->dialog_manager_->force_create_dialog(dialog_id, "GetStoryNotifySettingsExceptionsQuery");
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/TopDialogManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/db/KeyValueSyncInterface.h"
|
||||
#include "td/db/TsSeqKeyValue.h"
|
||||
@ -98,11 +99,11 @@ OptionManager::OptionManager(Td *td)
|
||||
}
|
||||
};
|
||||
set_default_integer_option("telegram_service_notifications_chat_id",
|
||||
DialogId(ContactsManager::get_service_notifications_user_id()).get());
|
||||
set_default_integer_option("replies_bot_chat_id", DialogId(ContactsManager::get_replies_bot_user_id()).get());
|
||||
set_default_integer_option("group_anonymous_bot_user_id", ContactsManager::get_anonymous_bot_user_id().get());
|
||||
set_default_integer_option("channel_bot_user_id", ContactsManager::get_channel_bot_user_id().get());
|
||||
set_default_integer_option("anti_spam_bot_user_id", ContactsManager::get_anti_spam_bot_user_id().get());
|
||||
DialogId(UserManager::get_service_notifications_user_id()).get());
|
||||
set_default_integer_option("replies_bot_chat_id", DialogId(UserManager::get_replies_bot_user_id()).get());
|
||||
set_default_integer_option("group_anonymous_bot_user_id", UserManager::get_anonymous_bot_user_id().get());
|
||||
set_default_integer_option("channel_bot_user_id", UserManager::get_channel_bot_user_id().get());
|
||||
set_default_integer_option("anti_spam_bot_user_id", UserManager::get_anti_spam_bot_user_id().get());
|
||||
set_default_integer_option("message_caption_length_max", 1024);
|
||||
set_default_integer_option("message_reply_quote_length_max", 1024);
|
||||
set_default_integer_option("story_caption_length_max", 200);
|
||||
@ -524,6 +525,7 @@ void OptionManager::on_option_updated(Slice name) {
|
||||
case 'i':
|
||||
if (name == "ignored_restriction_reasons") {
|
||||
send_closure(td_->contacts_manager_actor_, &ContactsManager::on_ignored_restriction_reasons_changed);
|
||||
send_closure(td_->user_manager_actor_, &UserManager::on_ignored_restriction_reasons_changed);
|
||||
}
|
||||
if (name == "is_emulator") {
|
||||
if (G()->mtproto_header().set_is_emulator(get_option_boolean(name))) {
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "td/telegram/Payments.h"
|
||||
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/GiveawayParameters.h"
|
||||
@ -26,6 +25,7 @@
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -82,7 +82,7 @@ Result<InputInvoiceInfo> get_input_invoice_info(Td *td, td_api::object_ptr<td_ap
|
||||
auto p = static_cast<const td_api::telegramPaymentPurposePremiumGiftCodes *>(invoice->purpose_.get());
|
||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : p->user_ids_) {
|
||||
TRY_RESULT(input_user, td->contacts_manager_->get_input_user(UserId(user_id)));
|
||||
TRY_RESULT(input_user, td->user_manager_->get_input_user(UserId(user_id)));
|
||||
input_users.push_back(std::move(input_user));
|
||||
}
|
||||
if (p->amount_ <= 0 || !check_currency_amount(p->amount_)) {
|
||||
@ -433,7 +433,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
|
||||
auto payment_form = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetPaymentFormQuery: " << to_string(payment_form);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(payment_form->users_), "GetPaymentFormQuery");
|
||||
td_->user_manager_->on_get_users(std::move(payment_form->users_), "GetPaymentFormQuery");
|
||||
|
||||
UserId payments_provider_user_id(payment_form->provider_id_);
|
||||
if (!payments_provider_user_id.is_valid()) {
|
||||
@ -459,8 +459,8 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
|
||||
});
|
||||
promise_.set_value(make_tl_object<td_api::paymentForm>(
|
||||
payment_form->form_id_, convert_invoice(std::move(payment_form->invoice_)),
|
||||
td_->contacts_manager_->get_user_id_object(seller_bot_user_id, "paymentForm seller"),
|
||||
td_->contacts_manager_->get_user_id_object(payments_provider_user_id, "paymentForm provider"),
|
||||
td_->user_manager_->get_user_id_object(seller_bot_user_id, "paymentForm seller"),
|
||||
td_->user_manager_->get_user_id_object(payments_provider_user_id, "paymentForm provider"),
|
||||
std::move(payment_provider), std::move(additional_payment_options),
|
||||
convert_order_info(std::move(payment_form->saved_info_)),
|
||||
convert_saved_credentials(std::move(payment_form->saved_credentials_)), can_save_credentials, need_password,
|
||||
@ -613,7 +613,7 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler {
|
||||
auto payment_receipt = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetPaymentReceiptQuery: " << to_string(payment_receipt);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(payment_receipt->users_), "GetPaymentReceiptQuery");
|
||||
td_->user_manager_->on_get_users(std::move(payment_receipt->users_), "GetPaymentReceiptQuery");
|
||||
|
||||
UserId payments_provider_user_id(payment_receipt->provider_id_);
|
||||
if (!payments_provider_user_id.is_valid()) {
|
||||
@ -634,8 +634,8 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler {
|
||||
promise_.set_value(make_tl_object<td_api::paymentReceipt>(
|
||||
payment_receipt->title_, get_product_description_object(payment_receipt->description_),
|
||||
get_photo_object(td_->file_manager_.get(), photo), payment_receipt->date_,
|
||||
td_->contacts_manager_->get_user_id_object(seller_bot_user_id, "paymentReceipt seller"),
|
||||
td_->contacts_manager_->get_user_id_object(payments_provider_user_id, "paymentReceipt provider"),
|
||||
td_->user_manager_->get_user_id_object(seller_bot_user_id, "paymentReceipt seller"),
|
||||
td_->user_manager_->get_user_id_object(payments_provider_user_id, "paymentReceipt provider"),
|
||||
convert_invoice(std::move(payment_receipt->invoice_)), convert_order_info(std::move(payment_receipt->info_)),
|
||||
convert_shipping_option(std::move(payment_receipt->shipping_)), std::move(payment_receipt->credentials_title_),
|
||||
payment_receipt->tip_amount_));
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -165,7 +166,7 @@ void PeopleNearbyManager::on_get_dialogs_nearby(Result<telegram_api::object_ptr<
|
||||
auto update = telegram_api::move_object_as<telegram_api::updates>(updates_ptr);
|
||||
LOG(INFO) << "Receive chats nearby in " << to_string(update);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(update->users_), "on_get_dialogs_nearby");
|
||||
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");
|
||||
|
||||
for (auto &dialog_nearby : users_nearby_) {
|
||||
@ -364,7 +365,7 @@ int32 PeopleNearbyManager::on_update_peer_located(vector<telegram_api::object_pt
|
||||
auto dialog_type = dialog_id.get_type();
|
||||
if (dialog_type == DialogType::User) {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
if (!td_->contacts_manager_->have_user(user_id)) {
|
||||
if (!td_->user_manager_->have_user(user_id)) {
|
||||
LOG(ERROR) << "Can't find " << user_id;
|
||||
continue;
|
||||
}
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "td/telegram/PhoneNumberManager.h"
|
||||
|
||||
#include "td/telegram/ConfigManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
#include "td/telegram/SuggestedAction.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
@ -168,8 +168,7 @@ void PhoneNumberManager::process_check_code_result(Result<tl_object_ptr<telegram
|
||||
if (result.is_error()) {
|
||||
return on_current_query_error(result.move_as_error());
|
||||
}
|
||||
send_closure(G()->contacts_manager(), &ContactsManager::on_get_user, result.move_as_ok(),
|
||||
"process_check_code_result");
|
||||
send_closure(G()->user_manager(), &UserManager::on_get_user, result.move_as_ok(), "process_check_code_result");
|
||||
state_ = State::Ok;
|
||||
on_current_query_ok();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/db/binlog/BinlogEvent.h"
|
||||
#include "td/db/binlog/BinlogHelper.h"
|
||||
@ -197,7 +198,7 @@ class StopPollQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
int32 flags = telegram_api::messages_editMessage::MEDIA_MASK;
|
||||
auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), reply_markup);
|
||||
auto input_reply_markup = get_input_reply_markup(td_->user_manager_.get(), reply_markup);
|
||||
if (input_reply_markup != nullptr) {
|
||||
flags |= telegram_api::messages_editMessage::REPLY_MARKUP_MASK;
|
||||
}
|
||||
@ -1187,7 +1188,7 @@ void PollManager::on_get_poll_voters(PollId poll_id, int32 option_id, string off
|
||||
}
|
||||
|
||||
auto vote_list = result.move_as_ok();
|
||||
td_->contacts_manager_->on_get_users(std::move(vote_list->users_), "on_get_poll_voters");
|
||||
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");
|
||||
|
||||
voters.next_offset_ = std::move(vote_list->next_offset_);
|
||||
@ -1551,7 +1552,7 @@ tl_object_ptr<telegram_api::InputMedia> PollManager::get_input_media(PollId poll
|
||||
0, poll_flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, poll->question_,
|
||||
transform(poll->options_, get_input_poll_option), poll->open_period_, poll->close_date_),
|
||||
std::move(correct_answers), poll->explanation_.text,
|
||||
get_input_message_entities(td_->contacts_manager_.get(), poll->explanation_.entities, "get_input_media_poll"));
|
||||
get_input_message_entities(td_->user_manager_.get(), poll->explanation_.entities, "get_input_media_poll"));
|
||||
}
|
||||
|
||||
vector<PollManager::PollOption> PollManager::get_poll_options(
|
||||
@ -1811,8 +1812,7 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll
|
||||
}
|
||||
}
|
||||
|
||||
auto entities =
|
||||
get_message_entities(td_->contacts_manager_.get(), std::move(poll_results->solution_entities_), source);
|
||||
auto entities = get_message_entities(td_->user_manager_.get(), std::move(poll_results->solution_entities_), source);
|
||||
auto status = fix_formatted_text(poll_results->solution_, entities, true, true, true, true, false);
|
||||
if (status.is_error()) {
|
||||
if (!clean_input_string(poll_results->solution_)) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -198,7 +199,7 @@ static Result<tl_object_ptr<telegram_api::InputStorePaymentPurpose>> get_input_s
|
||||
case td_api::storePaymentPurposeGiftedPremium::ID: {
|
||||
auto p = static_cast<const td_api::storePaymentPurposeGiftedPremium *>(purpose.get());
|
||||
UserId user_id(p->user_id_);
|
||||
TRY_RESULT(input_user, td->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT(input_user, td->user_manager_->get_input_user(user_id));
|
||||
if (p->amount_ <= 0 || !check_currency_amount(p->amount_)) {
|
||||
return Status::Error(400, "Invalid amount of the currency specified");
|
||||
}
|
||||
@ -209,7 +210,7 @@ static Result<tl_object_ptr<telegram_api::InputStorePaymentPurpose>> get_input_s
|
||||
auto p = static_cast<const td_api::storePaymentPurposePremiumGiftCodes *>(purpose.get());
|
||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : p->user_ids_) {
|
||||
TRY_RESULT(input_user, td->contacts_manager_->get_input_user(UserId(user_id)));
|
||||
TRY_RESULT(input_user, td->user_manager_->get_input_user(UserId(user_id)));
|
||||
input_users.push_back(std::move(input_user));
|
||||
}
|
||||
if (p->amount_ <= 0 || !check_currency_amount(p->amount_)) {
|
||||
@ -259,9 +260,9 @@ class GetPremiumPromoQuery final : public Td::ResultHandler {
|
||||
auto promo = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetPremiumPromoQuery: " << to_string(promo);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(promo->users_), "GetPremiumPromoQuery");
|
||||
td_->user_manager_->on_get_users(std::move(promo->users_), "GetPremiumPromoQuery");
|
||||
|
||||
auto state = get_message_text(td_->contacts_manager_.get(), std::move(promo->status_text_),
|
||||
auto state = get_message_text(td_->user_manager_.get(), std::move(promo->status_text_),
|
||||
std::move(promo->status_entities_), true, true, 0, false, "GetPremiumPromoQuery");
|
||||
|
||||
if (promo->video_sections_.size() != promo->videos_.size()) {
|
||||
@ -391,7 +392,7 @@ class CheckGiftCodeQuery final : public Td::ResultHandler {
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for CheckGiftCodeQuery: " << to_string(result);
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "CheckGiftCodeQuery");
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "CheckGiftCodeQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "CheckGiftCodeQuery");
|
||||
|
||||
if (result->date_ <= 0 || result->months_ <= 0 || result->used_date_ < 0) {
|
||||
@ -429,7 +430,7 @@ class CheckGiftCodeQuery final : public Td::ResultHandler {
|
||||
creator_dialog_id == DialogId() ? nullptr
|
||||
: get_message_sender_object(td_, creator_dialog_id, "premiumGiftCodeInfo"),
|
||||
result->date_, result->via_giveaway_, message_id.get(), result->months_,
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "premiumGiftCodeInfo"), result->used_date_));
|
||||
td_->user_manager_->get_user_id_object(user_id, "premiumGiftCodeInfo"), result->used_date_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
|
@ -6,13 +6,13 @@
|
||||
//
|
||||
#include "td/telegram/PrivacyManager.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/net/NetQueryCreator.h"
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -211,7 +211,7 @@ void PrivacyManager::do_update_privacy(UserPrivacySetting user_privacy_setting,
|
||||
if (!G()->close_flag() && (from_update || was_synchronized)) {
|
||||
switch (user_privacy_setting.type()) {
|
||||
case UserPrivacySetting::Type::UserStatus: {
|
||||
send_closure_later(G()->contacts_manager(), &ContactsManager::on_update_online_status_privacy);
|
||||
send_closure_later(G()->user_manager(), &UserManager::on_update_online_status_privacy);
|
||||
|
||||
auto old_restricted = info.rules_.get_restricted_user_ids();
|
||||
auto new_restricted = privacy_rules.get_restricted_user_ids();
|
||||
@ -223,14 +223,14 @@ void PrivacyManager::do_update_privacy(UserPrivacySetting user_privacy_setting,
|
||||
new_restricted.end(), std::back_inserter(unrestricted),
|
||||
[](UserId lhs, UserId rhs) { return lhs.get() < rhs.get(); });
|
||||
for (auto &user_id : unrestricted) {
|
||||
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user, user_id, Promise<Unit>(),
|
||||
send_closure_later(G()->user_manager(), &UserManager::reload_user, user_id, Promise<Unit>(),
|
||||
"do_update_privacy");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UserPrivacySetting::Type::UserPhoneNumber:
|
||||
send_closure_later(G()->contacts_manager(), &ContactsManager::on_update_phone_number_privacy);
|
||||
send_closure_later(G()->user_manager(), &UserManager::on_update_phone_number_privacy);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/Version.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
@ -535,8 +536,8 @@ unique_ptr<QuickReplyManager::QuickReplyMessage> QuickReplyManager::create_messa
|
||||
bool disable_web_page_preview = false;
|
||||
auto content = get_message_content(
|
||||
td_,
|
||||
get_message_text(td_->contacts_manager_.get(), std::move(message->message_), std::move(message->entities_),
|
||||
true, td_->auth_manager_->is_bot(), 0, media_album_id != 0, source),
|
||||
get_message_text(td_->user_manager_.get(), std::move(message->message_), std::move(message->entities_), true,
|
||||
td_->auth_manager_->is_bot(), 0, media_album_id != 0, source),
|
||||
std::move(message->media_), my_dialog_id, message->date_, true, via_bot_user_id, &ttl,
|
||||
&disable_web_page_preview, source);
|
||||
|
||||
@ -662,9 +663,9 @@ td_api::object_ptr<td_api::quickReplyMessage> QuickReplyManager::get_quick_reply
|
||||
auto can_be_edited = can_edit_quick_reply_message(m);
|
||||
return td_api::make_object<td_api::quickReplyMessage>(
|
||||
m->message_id.get(), get_message_sending_state_object(m), can_be_edited, m->reply_to_message_id.get(),
|
||||
td_->contacts_manager_->get_user_id_object(m->via_bot_user_id, "via_bot_user_id"), m->media_album_id,
|
||||
td_->user_manager_->get_user_id_object(m->via_bot_user_id, "via_bot_user_id"), m->media_album_id,
|
||||
get_quick_reply_message_message_content_object(m),
|
||||
get_reply_markup_object(td_->contacts_manager_.get(), m->reply_markup));
|
||||
get_reply_markup_object(td_->user_manager_.get(), m->reply_markup));
|
||||
}
|
||||
|
||||
int32 QuickReplyManager::get_shortcut_message_count(const Shortcut *s) {
|
||||
@ -727,7 +728,7 @@ void QuickReplyManager::on_reload_quick_reply_shortcuts(
|
||||
break;
|
||||
case telegram_api::messages_quickReplies::ID: {
|
||||
auto shortcuts = telegram_api::move_object_as<telegram_api::messages_quickReplies>(shortcuts_ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(shortcuts->users_), "messages.quickReplies");
|
||||
td_->user_manager_->on_get_users(std::move(shortcuts->users_), "messages.quickReplies");
|
||||
td_->contacts_manager_->on_get_chats(std::move(shortcuts->chats_), "messages.quickReplies");
|
||||
|
||||
FlatHashMap<MessageId, telegram_api::object_ptr<telegram_api::Message>, MessageIdHash> message_id_to_message;
|
||||
@ -1239,7 +1240,7 @@ void QuickReplyManager::on_reload_quick_reply_messages(
|
||||
break;
|
||||
case telegram_api::messages_messages::ID: {
|
||||
auto messages = telegram_api::move_object_as<telegram_api::messages_messages>(messages_ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(messages->users_), "on_reload_quick_reply_messages");
|
||||
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");
|
||||
|
||||
vector<unique_ptr<QuickReplyMessage>> quick_reply_messages;
|
||||
@ -1366,7 +1367,7 @@ void QuickReplyManager::on_reload_quick_reply_message(
|
||||
return promise.set_error(Status::Error(400, "Receive wrong response"));
|
||||
case telegram_api::messages_messages::ID: {
|
||||
auto messages = telegram_api::move_object_as<telegram_api::messages_messages>(messages_ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(messages->users_), "on_reload_quick_reply_message");
|
||||
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");
|
||||
|
||||
if (messages->messages_.size() > 1u) {
|
||||
@ -1413,7 +1414,7 @@ Result<vector<QuickReplyManager::QuickReplyMessageContent>> QuickReplyManager::g
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
return Status::Error(400, "Have no write access to the chat");
|
||||
}
|
||||
if (dialog_id.get_type() != DialogType::User || td_->contacts_manager_->is_user_bot(dialog_id.get_user_id())) {
|
||||
if (dialog_id.get_type() != DialogType::User || td_->user_manager_->is_user_bot(dialog_id.get_user_id())) {
|
||||
return Status::Error(400, "Can't use quick replies in the chat");
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/actor/MultiPromise.h"
|
||||
|
||||
@ -49,8 +50,8 @@ void RecentDialogList::save_dialogs() const {
|
||||
string username;
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
if (!td_->contacts_manager_->is_user_contact(dialog_id.get_user_id())) {
|
||||
username = td_->contacts_manager_->get_user_first_username(dialog_id.get_user_id());
|
||||
if (!td_->user_manager_->is_user_contact(dialog_id.get_user_id())) {
|
||||
username = td_->user_manager_->get_user_first_username(dialog_id.get_user_id());
|
||||
}
|
||||
break;
|
||||
case DialogType::Chat:
|
||||
@ -116,7 +117,7 @@ void RecentDialogList::load_dialogs(Promise<Unit> &&promise) {
|
||||
PromiseCreator::lambda([promise = mpas.get_promise()](td_api::object_ptr<td_api::chats> &&chats) mutable {
|
||||
promise.set_value(Unit());
|
||||
}));
|
||||
td_->contacts_manager_->search_contacts("", 1, mpas.get_promise());
|
||||
td_->user_manager_->search_contacts("", 1, mpas.get_promise());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,8 +117,8 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
|
||||
}
|
||||
if ((!origin_.is_empty() || message_id_ != MessageId()) && !reply_header->quote_text_.empty()) {
|
||||
is_quote_manual_ = reply_header->quote_;
|
||||
auto entities = get_message_entities(td->contacts_manager_.get(), std::move(reply_header->quote_entities_),
|
||||
"RepliedMessageInfo");
|
||||
auto entities =
|
||||
get_message_entities(td->user_manager_.get(), std::move(reply_header->quote_entities_), "RepliedMessageInfo");
|
||||
auto status = fix_formatted_text(reply_header->quote_text_, entities, true, true, true, true, false);
|
||||
if (status.is_error()) {
|
||||
if (!clean_input_string(reply_header->quote_text_)) {
|
||||
|
@ -6,13 +6,13 @@
|
||||
//
|
||||
#include "td/telegram/ReplyMarkup.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -903,7 +903,7 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(con
|
||||
}
|
||||
|
||||
static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(
|
||||
ContactsManager *contacts_manager, const InlineKeyboardButton &keyboard_button) {
|
||||
UserManager *user_manager, const InlineKeyboardButton &keyboard_button) {
|
||||
switch (keyboard_button.type) {
|
||||
case InlineKeyboardButton::Type::Url:
|
||||
return make_tl_object<telegram_api::keyboardButtonUrl>(keyboard_button.text, keyboard_button.data);
|
||||
@ -952,7 +952,7 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(
|
||||
if (!keyboard_button.forward_text.empty()) {
|
||||
flags |= telegram_api::inputKeyboardButtonUrlAuth::FWD_TEXT_MASK;
|
||||
}
|
||||
auto r_input_user = contacts_manager->get_input_user(UserId(bot_user_id));
|
||||
auto r_input_user = user_manager->get_input_user(UserId(bot_user_id));
|
||||
if (r_input_user.is_error()) {
|
||||
LOG(ERROR) << "Failed to get InputUser for " << bot_user_id << ": " << r_input_user.error();
|
||||
return make_tl_object<telegram_api::keyboardButtonUrl>(keyboard_button.text, keyboard_button.data);
|
||||
@ -965,7 +965,7 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(
|
||||
UNREACHABLE();
|
||||
break;
|
||||
case InlineKeyboardButton::Type::User: {
|
||||
auto r_input_user = contacts_manager->get_input_user(keyboard_button.user_id);
|
||||
auto r_input_user = user_manager->get_input_user(keyboard_button.user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
LOG(ERROR) << "Failed to get InputUser for " << keyboard_button.user_id << ": " << r_input_user.error();
|
||||
r_input_user = make_tl_object<telegram_api::inputUserEmpty>();
|
||||
@ -981,7 +981,7 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(
|
||||
}
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> ReplyMarkup::get_input_reply_markup(ContactsManager *contacts_manager) const {
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> ReplyMarkup::get_input_reply_markup(UserManager *user_manager) const {
|
||||
LOG(DEBUG) << "Send " << *this;
|
||||
switch (type) {
|
||||
case ReplyMarkup::Type::InlineKeyboard: {
|
||||
@ -991,7 +991,7 @@ tl_object_ptr<telegram_api::ReplyMarkup> ReplyMarkup::get_input_reply_markup(Con
|
||||
vector<tl_object_ptr<telegram_api::KeyboardButton>> buttons;
|
||||
buttons.reserve(row.size());
|
||||
for (auto &button : row) {
|
||||
buttons.push_back(get_input_keyboard_button(contacts_manager, button));
|
||||
buttons.push_back(get_input_keyboard_button(user_manager, button));
|
||||
}
|
||||
rows.push_back(make_tl_object<telegram_api::keyboardButtonRow>(std::move(buttons)));
|
||||
}
|
||||
@ -1067,7 +1067,7 @@ static tl_object_ptr<td_api::keyboardButton> get_keyboard_button_object(const Ke
|
||||
}
|
||||
|
||||
static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_object(
|
||||
ContactsManager *contacts_manager, const InlineKeyboardButton &keyboard_button) {
|
||||
UserManager *user_manager, const InlineKeyboardButton &keyboard_button) {
|
||||
tl_object_ptr<td_api::InlineKeyboardButtonType> type;
|
||||
switch (keyboard_button.type) {
|
||||
case InlineKeyboardButton::Type::Url:
|
||||
@ -1106,9 +1106,9 @@ static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_ob
|
||||
type = make_tl_object<td_api::inlineKeyboardButtonTypeCallbackWithPassword>(keyboard_button.data);
|
||||
break;
|
||||
case InlineKeyboardButton::Type::User: {
|
||||
bool need_user = contacts_manager != nullptr && !contacts_manager->is_user_bot(contacts_manager->get_my_id());
|
||||
bool need_user = user_manager != nullptr && !user_manager->is_user_bot(user_manager->get_my_id());
|
||||
auto user_id =
|
||||
need_user ? contacts_manager->get_user_id_object(keyboard_button.user_id, "get_inline_keyboard_button_object")
|
||||
need_user ? user_manager->get_user_id_object(keyboard_button.user_id, "get_inline_keyboard_button_object")
|
||||
: keyboard_button.user_id.get();
|
||||
type = make_tl_object<td_api::inlineKeyboardButtonTypeUser>(user_id);
|
||||
break;
|
||||
@ -1123,7 +1123,7 @@ static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_ob
|
||||
return make_tl_object<td_api::inlineKeyboardButton>(keyboard_button.text, std::move(type));
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::ReplyMarkup> ReplyMarkup::get_reply_markup_object(ContactsManager *contacts_manager) const {
|
||||
tl_object_ptr<td_api::ReplyMarkup> ReplyMarkup::get_reply_markup_object(UserManager *user_manager) const {
|
||||
switch (type) {
|
||||
case ReplyMarkup::Type::InlineKeyboard: {
|
||||
vector<vector<tl_object_ptr<td_api::inlineKeyboardButton>>> rows;
|
||||
@ -1132,7 +1132,7 @@ tl_object_ptr<td_api::ReplyMarkup> ReplyMarkup::get_reply_markup_object(Contacts
|
||||
vector<tl_object_ptr<td_api::inlineKeyboardButton>> buttons;
|
||||
buttons.reserve(row.size());
|
||||
for (auto &button : row) {
|
||||
buttons.push_back(get_inline_keyboard_button_object(contacts_manager, button));
|
||||
buttons.push_back(get_inline_keyboard_button_object(user_manager, button));
|
||||
}
|
||||
rows.push_back(std::move(buttons));
|
||||
}
|
||||
@ -1186,22 +1186,22 @@ Status ReplyMarkup::check_shared_dialog_count(int32 button_id, size_t count) con
|
||||
return Status::Error(400, "Button not found");
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(ContactsManager *contacts_manager,
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(UserManager *user_manager,
|
||||
const unique_ptr<ReplyMarkup> &reply_markup) {
|
||||
if (reply_markup == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return reply_markup->get_input_reply_markup(contacts_manager);
|
||||
return reply_markup->get_input_reply_markup(user_manager);
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(ContactsManager *contacts_manager,
|
||||
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(UserManager *user_manager,
|
||||
const unique_ptr<ReplyMarkup> &reply_markup) {
|
||||
if (reply_markup == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return reply_markup->get_reply_markup_object(contacts_manager);
|
||||
return reply_markup->get_reply_markup_object(user_manager);
|
||||
}
|
||||
|
||||
void add_reply_markup_dependencies(Dependencies &dependencies, const ReplyMarkup *reply_markup) {
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class ContactsManager;
|
||||
class Dependencies;
|
||||
class UserManager;
|
||||
|
||||
struct KeyboardButton {
|
||||
// append only
|
||||
@ -86,9 +86,9 @@ struct ReplyMarkup {
|
||||
|
||||
StringBuilder &print(StringBuilder &string_builder) const;
|
||||
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(ContactsManager *contacts_manager) const;
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(UserManager *user_manager) const;
|
||||
|
||||
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(ContactsManager *contacts_manager) const;
|
||||
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(UserManager *user_manager) const;
|
||||
|
||||
Status check_shared_dialog(Td *td, int32 button_id, DialogId dialog_id) const;
|
||||
|
||||
@ -112,10 +112,10 @@ Result<unique_ptr<ReplyMarkup>> get_reply_markup(td_api::object_ptr<td_api::Repl
|
||||
|
||||
unique_ptr<ReplyMarkup> dup_reply_markup(const unique_ptr<ReplyMarkup> &reply_markup);
|
||||
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(ContactsManager *contacts_manager,
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(UserManager *user_manager,
|
||||
const unique_ptr<ReplyMarkup> &reply_markup);
|
||||
|
||||
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(ContactsManager *contacts_manager,
|
||||
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(UserManager *user_manager,
|
||||
const unique_ptr<ReplyMarkup> &reply_markup);
|
||||
|
||||
void add_reply_markup_dependencies(Dependencies &dependencies, const ReplyMarkup *reply_markup);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/ChannelType.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
@ -207,10 +208,10 @@ Status RequestedDialogType::check_shared_dialog(Td *td, DialogId dialog_id) cons
|
||||
return Status::Error(400, "Wrong chat type");
|
||||
}
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
if (restrict_is_bot_ && td->contacts_manager_->is_user_bot(user_id) != is_bot_) {
|
||||
if (restrict_is_bot_ && td->user_manager_->is_user_bot(user_id) != is_bot_) {
|
||||
return Status::Error(400, "Wrong is_bot value");
|
||||
}
|
||||
if (restrict_is_premium_ && td->contacts_manager_->is_user_premium(user_id) != is_premium_) {
|
||||
if (restrict_is_premium_ && td->user_manager_->is_user_premium(user_id) != is_premium_) {
|
||||
return Status::Error(400, "Wrong is_premium value");
|
||||
}
|
||||
break;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -584,7 +585,7 @@ void SavedMessagesManager::on_get_saved_messages_topics(
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
td_->contacts_manager_->on_get_users(std::move(users), "on_get_saved_messages_topics");
|
||||
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");
|
||||
|
||||
FlatHashMap<MessageId, telegram_api::object_ptr<telegram_api::Message>, MessageIdHash> message_id_to_message;
|
||||
|
@ -6,7 +6,6 @@
|
||||
//
|
||||
#include "td/telegram/SecretChatsManager.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DhCache.h"
|
||||
#include "td/telegram/EncryptedFile.h"
|
||||
#include "td/telegram/FolderId.h"
|
||||
@ -20,6 +19,7 @@
|
||||
#include "td/telegram/StateManager.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/mtproto/DhCallback.h"
|
||||
|
||||
@ -366,8 +366,8 @@ unique_ptr<SecretChatActor::Context> SecretChatsManager::make_secret_chat_contex
|
||||
|
||||
void on_update_secret_chat(int64 access_hash, UserId user_id, SecretChatState state, bool is_outbound, int32 ttl,
|
||||
int32 date, string key_hash, int32 layer, FolderId initial_folder_id) final {
|
||||
send_closure(G()->contacts_manager(), &ContactsManager::on_update_secret_chat, secret_chat_id_, access_hash,
|
||||
user_id, state, is_outbound, ttl, date, key_hash, layer, initial_folder_id);
|
||||
send_closure(G()->user_manager(), &UserManager::on_update_secret_chat, secret_chat_id_, access_hash, user_id,
|
||||
state, is_outbound, ttl, date, key_hash, layer, initial_folder_id);
|
||||
}
|
||||
|
||||
void on_inbound_message(UserId user_id, MessageId message_id, int32 date, unique_ptr<EncryptedFile> file,
|
||||
|
@ -6,7 +6,6 @@
|
||||
//
|
||||
#include "td/telegram/SecureManager.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "td/telegram/PasswordManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -987,7 +987,7 @@ void SecureManager::on_get_passport_authorization_form(
|
||||
|
||||
auto authorization_form = r_authorization_form.move_as_ok();
|
||||
LOG(INFO) << "Receive " << to_string(authorization_form);
|
||||
G()->td().get_actor_unsafe()->contacts_manager_->on_get_users(std::move(authorization_form->users_),
|
||||
G()->td().get_actor_unsafe()->user_manager_->on_get_users(std::move(authorization_form->users_),
|
||||
"on_get_passport_authorization_form");
|
||||
|
||||
vector<vector<SuitableSecureValue>> required_types;
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ChannelId.h"
|
||||
#include "td/telegram/ChatId.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
@ -52,7 +52,7 @@ td_api::object_ptr<td_api::sharedUser> SharedDialog::get_shared_user_object(Td *
|
||||
CHECK(is_user());
|
||||
auto user_id = td->auth_manager_->is_bot()
|
||||
? dialog_id_.get_user_id().get()
|
||||
: td->contacts_manager_->get_user_id_object(dialog_id_.get_user_id(), "sharedUser");
|
||||
: td->user_manager_->get_user_id_object(dialog_id_.get_user_id(), "sharedUser");
|
||||
return td_api::make_object<td_api::sharedUser>(user_id, first_name_, last_name_, username_,
|
||||
get_photo_object(td->file_manager_.get(), photo_));
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/WebApp.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
@ -285,11 +286,11 @@ td_api::object_ptr<td_api::messageSponsor> SponsoredMessageManager::get_message_
|
||||
switch (sponsored_message.sponsor_dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
auto user_id = sponsored_message.sponsor_dialog_id.get_user_id();
|
||||
if (!td_->contacts_manager_->is_user_bot(user_id)) {
|
||||
if (!td_->user_manager_->is_user_bot(user_id)) {
|
||||
LOG(ERROR) << "Sponsor " << user_id << " is not a bot";
|
||||
return nullptr;
|
||||
}
|
||||
auto bot_username = td_->contacts_manager_->get_user_first_username(user_id);
|
||||
auto bot_username = td_->user_manager_->get_user_first_username(user_id);
|
||||
if (bot_username.empty()) {
|
||||
LOG(ERROR) << "Sponsor " << user_id << " has no username";
|
||||
return nullptr;
|
||||
@ -298,12 +299,12 @@ td_api::object_ptr<td_api::messageSponsor> SponsoredMessageManager::get_message_
|
||||
type = sponsored_message.web_app.get_message_sponsor_type_web_app(bot_username, sponsored_message.start_param);
|
||||
} else {
|
||||
type = td_api::make_object<td_api::messageSponsorTypeBot>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "messageSponsorTypeBot"),
|
||||
td_->user_manager_->get_user_id_object(user_id, "messageSponsorTypeBot"),
|
||||
td_api::make_object<td_api::internalLinkTypeBotStart>(bot_username, sponsored_message.start_param, false));
|
||||
}
|
||||
if (sponsored_message.show_dialog_photo) {
|
||||
photo = get_chat_photo_info_object(td_->file_manager_.get(),
|
||||
td_->contacts_manager_->get_user_dialog_photo(user_id));
|
||||
photo =
|
||||
get_chat_photo_info_object(td_->file_manager_.get(), td_->user_manager_->get_user_dialog_photo(user_id));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -442,7 +443,7 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages(
|
||||
auto sponsored_messages =
|
||||
telegram_api::move_object_as<telegram_api::messages_sponsoredMessages>(sponsored_messages_ptr);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(sponsored_messages->users_), "on_get_dialog_sponsored_messages");
|
||||
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");
|
||||
|
||||
for (auto &sponsored_message : sponsored_messages->messages_) {
|
||||
@ -493,7 +494,7 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages(
|
||||
continue;
|
||||
}
|
||||
|
||||
auto message_text = get_message_text(td_->contacts_manager_.get(), std::move(sponsored_message->message_),
|
||||
auto message_text = get_message_text(td_->user_manager_.get(), std::move(sponsored_message->message_),
|
||||
std::move(sponsored_message->entities_), true, true, 0, false,
|
||||
"on_get_dialog_sponsored_messages");
|
||||
MessageSelfDestructType ttl;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/buffer.h"
|
||||
@ -84,7 +85,7 @@ static td_api::object_ptr<td_api::chatStatisticsSupergroup> convert_megagroup_st
|
||||
Td *td, telegram_api::object_ptr<telegram_api::stats_megagroupStats> obj) {
|
||||
CHECK(obj != nullptr);
|
||||
|
||||
td->contacts_manager_->on_get_users(std::move(obj->users_), "convert_megagroup_stats");
|
||||
td->user_manager_->on_get_users(std::move(obj->users_), "convert_megagroup_stats");
|
||||
|
||||
// just in case
|
||||
td::remove_if(obj->top_posters_, [](auto &obj) {
|
||||
@ -99,19 +100,19 @@ static td_api::object_ptr<td_api::chatStatisticsSupergroup> convert_megagroup_st
|
||||
auto top_senders = transform(
|
||||
std::move(obj->top_posters_), [td](telegram_api::object_ptr<telegram_api::statsGroupTopPoster> &&top_poster) {
|
||||
return td_api::make_object<td_api::chatStatisticsMessageSenderInfo>(
|
||||
td->contacts_manager_->get_user_id_object(UserId(top_poster->user_id_), "get_top_senders"),
|
||||
td->user_manager_->get_user_id_object(UserId(top_poster->user_id_), "get_top_senders"),
|
||||
top_poster->messages_, top_poster->avg_chars_);
|
||||
});
|
||||
auto top_administrators = transform(
|
||||
std::move(obj->top_admins_), [td](telegram_api::object_ptr<telegram_api::statsGroupTopAdmin> &&top_admin) {
|
||||
return td_api::make_object<td_api::chatStatisticsAdministratorActionsInfo>(
|
||||
td->contacts_manager_->get_user_id_object(UserId(top_admin->user_id_), "get_top_administrators"),
|
||||
td->user_manager_->get_user_id_object(UserId(top_admin->user_id_), "get_top_administrators"),
|
||||
top_admin->deleted_, top_admin->kicked_, top_admin->banned_);
|
||||
});
|
||||
auto top_inviters = transform(
|
||||
std::move(obj->top_inviters_), [td](telegram_api::object_ptr<telegram_api::statsGroupTopInviter> &&top_inviter) {
|
||||
return td_api::make_object<td_api::chatStatisticsInviterInfo>(
|
||||
td->contacts_manager_->get_user_id_object(UserId(top_inviter->user_id_), "get_top_inviters"),
|
||||
td->user_manager_->get_user_id_object(UserId(top_inviter->user_id_), "get_top_inviters"),
|
||||
top_inviter->invitations_);
|
||||
});
|
||||
|
||||
@ -713,7 +714,7 @@ void StatisticsManager::on_get_public_forwards(
|
||||
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_->contacts_manager_->on_get_users(std::move(public_forwards->users_), "stats_publicForwards");
|
||||
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");
|
||||
|
||||
vector<const telegram_api::object_ptr<telegram_api::Message> *> messages;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ConfigManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Document.h"
|
||||
@ -38,6 +37,7 @@
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/Version.h"
|
||||
|
||||
#include "td/db/SqliteKeyValue.h"
|
||||
@ -4405,12 +4405,12 @@ vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string qu
|
||||
if (sticker_type == StickerType::CustomEmoji) {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
if (dialog_id.get_user_id() == td_->contacts_manager_->get_my_id()) {
|
||||
if (dialog_id.get_user_id() == td_->user_manager_->get_my_id()) {
|
||||
allow_premium = true;
|
||||
}
|
||||
break;
|
||||
case DialogType::SecretChat:
|
||||
if (td_->contacts_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id()) <
|
||||
if (td_->user_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id()) <
|
||||
static_cast<int32>(SecretChatLayer::SpoilerAndCustomEmojiEntities)) {
|
||||
promise.set_value(Unit());
|
||||
return {};
|
||||
@ -7845,10 +7845,10 @@ FileId StickersManager::upload_sticker_file(UserId user_id, StickerFormat sticke
|
||||
Promise<Unit> &&promise) {
|
||||
bool is_bot = td_->auth_manager_->is_bot();
|
||||
if (!is_bot) {
|
||||
user_id = td_->contacts_manager_->get_my_id();
|
||||
user_id = td_->user_manager_->get_my_id();
|
||||
}
|
||||
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
promise.set_error(r_input_user.move_as_error());
|
||||
return FileId();
|
||||
@ -7952,10 +7952,10 @@ void StickersManager::create_new_sticker_set(UserId user_id, string title, strin
|
||||
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise) {
|
||||
bool is_bot = td_->auth_manager_->is_bot();
|
||||
if (!is_bot) {
|
||||
user_id = td_->contacts_manager_->get_my_id();
|
||||
user_id = td_->user_manager_->get_my_id();
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
title = strip_empty_characters(title, MAX_STICKER_SET_TITLE_LENGTH);
|
||||
if (title.empty()) {
|
||||
@ -8189,7 +8189,7 @@ void StickersManager::on_new_stickers_uploaded(int64 random_id, Result<Unit> res
|
||||
CHECK(pending_new_sticker_set->upload_files_multipromise_.promise_count() == 0);
|
||||
|
||||
auto &promise = pending_new_sticker_set->promise_;
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(pending_new_sticker_set->user_id_));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(pending_new_sticker_set->user_id_));
|
||||
|
||||
StickerType sticker_type = pending_new_sticker_set->sticker_type_;
|
||||
|
||||
@ -8224,10 +8224,10 @@ void StickersManager::add_sticker_to_set(UserId user_id, string short_name,
|
||||
td_api::object_ptr<td_api::InputFile> &&old_sticker, Promise<Unit> &&promise) {
|
||||
bool is_bot = td_->auth_manager_->is_bot();
|
||||
if (!is_bot) {
|
||||
user_id = td_->contacts_manager_->get_my_id();
|
||||
user_id = td_->user_manager_->get_my_id();
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH));
|
||||
if (short_name.empty()) {
|
||||
@ -8340,10 +8340,10 @@ void StickersManager::set_sticker_set_thumbnail(UserId user_id, string short_nam
|
||||
Promise<Unit> &&promise) {
|
||||
bool is_bot = td_->auth_manager_->is_bot();
|
||||
if (!is_bot) {
|
||||
user_id = td_->contacts_manager_->get_my_id();
|
||||
user_id = td_->user_manager_->get_my_id();
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(user_id));
|
||||
|
||||
short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH));
|
||||
if (short_name.empty()) {
|
||||
|
@ -6,10 +6,10 @@
|
||||
//
|
||||
#include "td/telegram/StoryInteractionInfo.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/FlatHashSet.h"
|
||||
@ -25,7 +25,7 @@ StoryInteractionInfo::StoryInteractionInfo(Td *td, telegram_api::object_ptr<tele
|
||||
}
|
||||
for (auto &viewer_id : story_views->recent_viewers_) {
|
||||
UserId user_id(viewer_id);
|
||||
if (user_id.is_valid() && td->contacts_manager_->have_min_user(user_id)) {
|
||||
if (user_id.is_valid() && td->user_manager_->have_min_user(user_id)) {
|
||||
if (recent_viewer_user_ids_.size() == MAX_RECENT_VIEWERS) {
|
||||
LOG(ERROR) << "Receive too many recent story viewers: " << story_views->recent_viewers_;
|
||||
break;
|
||||
@ -135,7 +135,7 @@ td_api::object_ptr<td_api::storyInteractionInfo> StoryInteractionInfo::get_story
|
||||
}
|
||||
return td_api::make_object<td_api::storyInteractionInfo>(
|
||||
view_count_, forward_count_, reaction_count_,
|
||||
td->contacts_manager_->get_user_ids_object(recent_viewer_user_ids_, "get_story_interaction_info_object"));
|
||||
td->user_manager_->get_user_ids_object(recent_viewer_user_ids_, "get_story_interaction_info_object"));
|
||||
}
|
||||
|
||||
bool operator==(const StoryInteractionInfo &lhs, const StoryInteractionInfo &rhs) {
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/WebPagesManager.h"
|
||||
|
||||
#include "td/db/binlog/BinlogEvent.h"
|
||||
@ -941,7 +942,7 @@ class StoryManager::SendStoryQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
const FormattedText &caption = story->caption_;
|
||||
auto entities = get_input_message_entities(td_->contacts_manager_.get(), &caption, "SendStoryQuery");
|
||||
auto entities = get_input_message_entities(td_->user_manager_.get(), &caption, "SendStoryQuery");
|
||||
if (!td_->option_manager_->get_option_boolean("can_use_text_entities_in_story_caption")) {
|
||||
entities.clear();
|
||||
}
|
||||
@ -1057,7 +1058,7 @@ class StoryManager::EditStoryQuery final : public Td::ResultHandler {
|
||||
flags |= telegram_api::stories_editStory::CAPTION_MASK;
|
||||
if (td_->option_manager_->get_option_boolean("can_use_text_entities_in_story_caption")) {
|
||||
flags |= telegram_api::stories_editStory::ENTITIES_MASK;
|
||||
entities = get_input_message_entities(td_->contacts_manager_.get(), &edited_story->caption_, "EditStoryQuery");
|
||||
entities = get_input_message_entities(td_->user_manager_.get(), &edited_story->caption_, "EditStoryQuery");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2100,7 +2101,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_->contacts_manager_->on_get_users(std::move(stories->users_), "on_load_active_stories_from_server");
|
||||
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");
|
||||
if (stories->state_.empty()) {
|
||||
LOG(ERROR) << "Receive empty state in " << to_string(stories);
|
||||
@ -2143,7 +2144,7 @@ void StoryManager::on_load_active_stories_from_server(
|
||||
} else {
|
||||
LOG(ERROR) << "Receive " << story_date << " after " << max_story_date << " for "
|
||||
<< (is_next ? "next" : "first") << " request with state \"" << old_state << "\" in "
|
||||
<< story_list_id << " of " << td_->contacts_manager_->get_my_id();
|
||||
<< story_list_id << " of " << td_->user_manager_->get_my_id();
|
||||
}
|
||||
owner_dialog_ids.push_back(owner_dialog_id);
|
||||
}
|
||||
@ -2501,7 +2502,7 @@ void StoryManager::on_get_dialog_expiring_stories(DialogId owner_dialog_id,
|
||||
telegram_api::object_ptr<telegram_api::stories_peerStories> &&stories,
|
||||
Promise<td_api::object_ptr<td_api::chatActiveStories>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
td_->contacts_manager_->on_get_users(std::move(stories->users_), "on_get_dialog_expiring_stories");
|
||||
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");
|
||||
owner_dialog_id = on_get_dialog_stories(owner_dialog_id, std::move(stories->stories_), Promise<Unit>());
|
||||
if (promise) {
|
||||
@ -2632,7 +2633,7 @@ void StoryManager::view_story_message(StoryFullId story_full_id) {
|
||||
}
|
||||
|
||||
void StoryManager::on_story_replied(StoryFullId story_full_id, UserId replier_user_id) {
|
||||
if (!replier_user_id.is_valid() || replier_user_id == td_->contacts_manager_->get_my_id() ||
|
||||
if (!replier_user_id.is_valid() || replier_user_id == td_->user_manager_->get_my_id() ||
|
||||
!story_full_id.get_story_id().is_server()) {
|
||||
return;
|
||||
}
|
||||
@ -2893,7 +2894,7 @@ bool StoryManager::has_unexpired_viewers(StoryFullId story_full_id, const Story
|
||||
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_->contacts_manager_->on_get_users(std::move(story_views->users_), "stories_storyViewsList");
|
||||
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");
|
||||
|
||||
vector<const telegram_api::object_ptr<telegram_api::Message> *> messages;
|
||||
@ -3000,7 +3001,7 @@ void StoryManager::on_get_story_interactions(
|
||||
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_->contacts_manager_->on_get_users(std::move(story_reactions->users_), "stories_storyReactionsList");
|
||||
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");
|
||||
|
||||
vector<const telegram_api::object_ptr<telegram_api::Message> *> messages;
|
||||
@ -3408,7 +3409,7 @@ StoryId StoryManager::on_get_new_story(DialogId owner_dialog_id,
|
||||
|
||||
bool is_bot = td_->auth_manager_->is_bot();
|
||||
auto caption =
|
||||
get_message_text(td_->contacts_manager_.get(), std::move(story_item->caption_), std::move(story_item->entities_),
|
||||
get_message_text(td_->user_manager_.get(), std::move(story_item->caption_), std::move(story_item->entities_),
|
||||
true, is_bot, story_item->date_, false, "on_get_new_story");
|
||||
auto content = get_story_content(td_, std::move(story_item->media_), owner_dialog_id);
|
||||
if (content == nullptr) {
|
||||
@ -3795,7 +3796,7 @@ void StoryManager::unregister_story_global_id(const Story *story) {
|
||||
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_->contacts_manager_->on_get_users(std::move(stories->users_), "on_get_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");
|
||||
|
||||
vector<StoryId> story_ids;
|
||||
@ -3903,7 +3904,7 @@ void StoryManager::on_update_dialog_max_story_ids(DialogId owner_dialog_id, Stor
|
||||
switch (owner_dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
// use send_closure_later because story order can be updated from update_user
|
||||
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::on_update_user_story_ids,
|
||||
send_closure_later(td_->user_manager_actor_, &UserManager::on_update_user_story_ids,
|
||||
owner_dialog_id.get_user_id(), max_story_id, max_read_story_id);
|
||||
break;
|
||||
case DialogType::Channel:
|
||||
@ -3922,7 +3923,7 @@ void StoryManager::on_update_dialog_max_story_ids(DialogId owner_dialog_id, Stor
|
||||
void StoryManager::on_update_dialog_max_read_story_id(DialogId owner_dialog_id, StoryId max_read_story_id) {
|
||||
switch (owner_dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
td_->contacts_manager_->on_update_user_max_read_story_id(owner_dialog_id.get_user_id(), max_read_story_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);
|
||||
@ -3938,7 +3939,7 @@ void StoryManager::on_update_dialog_max_read_story_id(DialogId owner_dialog_id,
|
||||
void StoryManager::on_update_dialog_has_pinned_stories(DialogId owner_dialog_id, bool has_pinned_stories) {
|
||||
switch (owner_dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
td_->contacts_manager_->on_update_user_has_pinned_stories(owner_dialog_id.get_user_id(), has_pinned_stories);
|
||||
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(),
|
||||
@ -3955,7 +3956,7 @@ void StoryManager::on_update_dialog_has_pinned_stories(DialogId owner_dialog_id,
|
||||
void StoryManager::on_update_dialog_stories_hidden(DialogId owner_dialog_id, bool stories_hidden) {
|
||||
switch (owner_dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
td_->contacts_manager_->on_update_user_stories_hidden(owner_dialog_id.get_user_id(), stories_hidden);
|
||||
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);
|
||||
@ -4079,7 +4080,7 @@ bool StoryManager::update_active_stories_order(DialogId owner_dialog_id, ActiveS
|
||||
int64 new_private_order = 0;
|
||||
new_private_order += last_story->date_;
|
||||
if (owner_dialog_id.get_type() == DialogType::User &&
|
||||
td_->contacts_manager_->is_user_premium(owner_dialog_id.get_user_id())) {
|
||||
td_->user_manager_->is_user_premium(owner_dialog_id.get_user_id())) {
|
||||
new_private_order += static_cast<int64>(1) << 33;
|
||||
}
|
||||
if (owner_dialog_id == get_changelog_story_dialog_id()) {
|
||||
@ -4369,7 +4370,7 @@ void StoryManager::update_stealth_mode() {
|
||||
|
||||
DialogId StoryManager::get_changelog_story_dialog_id() const {
|
||||
return DialogId(UserId(td_->option_manager_->get_option_integer(
|
||||
"stories_changelog_user_id", ContactsManager::get_service_notifications_user_id().get())));
|
||||
"stories_changelog_user_id", UserManager::get_service_notifications_user_id().get())));
|
||||
}
|
||||
|
||||
bool StoryManager::is_subscribed_to_dialog_stories(DialogId owner_dialog_id) const {
|
||||
@ -4381,7 +4382,7 @@ bool StoryManager::is_subscribed_to_dialog_stories(DialogId owner_dialog_id) con
|
||||
if (is_my_story(owner_dialog_id)) {
|
||||
return true;
|
||||
}
|
||||
return td_->contacts_manager_->is_user_contact(owner_dialog_id.get_user_id());
|
||||
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();
|
||||
case DialogType::Chat:
|
||||
@ -4398,8 +4399,7 @@ StoryListId StoryManager::get_dialog_story_list_id(DialogId owner_dialog_id) con
|
||||
}
|
||||
switch (owner_dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
if (!is_my_story(owner_dialog_id) &&
|
||||
td_->contacts_manager_->get_user_stories_hidden(owner_dialog_id.get_user_id())) {
|
||||
if (!is_my_story(owner_dialog_id) && td_->user_manager_->get_user_stories_hidden(owner_dialog_id.get_user_id())) {
|
||||
return StoryListId::archive();
|
||||
}
|
||||
return StoryListId::main();
|
||||
@ -4432,7 +4432,7 @@ void StoryManager::on_dialog_active_stories_order_updated(DialogId owner_dialog_
|
||||
void StoryManager::on_get_story_views(DialogId owner_dialog_id, const vector<StoryId> &story_ids,
|
||||
telegram_api::object_ptr<telegram_api::stories_storyViews> &&story_views) {
|
||||
schedule_interaction_info_update();
|
||||
td_->contacts_manager_->on_get_users(std::move(story_views->users_), "on_get_story_views");
|
||||
td_->user_manager_->on_get_users(std::move(story_views->users_), "on_get_story_views");
|
||||
if (story_ids.size() != story_views->views_.size()) {
|
||||
LOG(ERROR) << "Receive invalid views for " << story_ids << ": " << to_string(story_views);
|
||||
return;
|
||||
@ -4483,7 +4483,7 @@ void StoryManager::on_view_dialog_active_stories(vector<DialogId> dialog_ids) {
|
||||
bool need_poll = [&] {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->can_poll_user_active_stories(dialog_id.get_user_id());
|
||||
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());
|
||||
case DialogType::Chat:
|
||||
@ -4530,7 +4530,7 @@ void StoryManager::on_get_dialog_max_active_story_ids(const vector<DialogId> &di
|
||||
auto dialog_id = dialog_ids[i];
|
||||
if (max_story_id == StoryId() || max_story_id.is_server()) {
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
td_->contacts_manager_->on_update_user_story_ids(dialog_id.get_user_id(), max_story_id, StoryId());
|
||||
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());
|
||||
}
|
||||
|
@ -6,12 +6,12 @@
|
||||
//
|
||||
#include "td/telegram/Support.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/Status.h"
|
||||
@ -25,7 +25,7 @@ static td_api::object_ptr<td_api::userSupportInfo> get_user_support_info_object(
|
||||
FormattedText message;
|
||||
if (user_info->get_id() == telegram_api::help_userInfo::ID) {
|
||||
auto info = telegram_api::move_object_as<telegram_api::help_userInfo>(user_info);
|
||||
message = get_message_text(td->contacts_manager_.get(), std::move(info->message_), std::move(info->entities_), true,
|
||||
message = get_message_text(td->user_manager_.get(), std::move(info->message_), std::move(info->entities_), true,
|
||||
true, info->date_, false, "get_user_support_info_object");
|
||||
result->author_ = std::move(info->author_);
|
||||
result->date_ = info->date_;
|
||||
@ -43,7 +43,7 @@ class GetUserInfoQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send(UserId user_id) {
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
return on_error(r_input_user.move_as_error());
|
||||
}
|
||||
@ -74,14 +74,14 @@ class EditUserInfoQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send(UserId user_id, FormattedText &&formatted_text) {
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td_->user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
return on_error(r_input_user.move_as_error());
|
||||
}
|
||||
|
||||
send_query(G()->net_query_creator().create(telegram_api::help_editUserInfo(
|
||||
r_input_user.move_as_ok(), formatted_text.text,
|
||||
get_input_message_entities(td_->contacts_manager_.get(), &formatted_text, "EditUserInfoQuery"))));
|
||||
get_input_message_entities(td_->user_manager_.get(), &formatted_text, "EditUserInfoQuery"))));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
|
@ -267,7 +267,7 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
auto urls_full = result_ptr.move_as_ok();
|
||||
td_->contacts_manager_->on_get_users(std::move(urls_full->users_), "GetRecentMeUrlsQuery");
|
||||
td_->user_manager_->on_get_users(std::move(urls_full->users_), "GetRecentMeUrlsQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery");
|
||||
|
||||
auto urls = std::move(urls_full->urls_);
|
||||
@ -286,8 +286,8 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
|
||||
result = nullptr;
|
||||
break;
|
||||
}
|
||||
result->type_ = make_tl_object<td_api::tMeUrlTypeUser>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "tMeUrlTypeUser"));
|
||||
result->type_ =
|
||||
make_tl_object<td_api::tMeUrlTypeUser>(td_->user_manager_->get_user_id_object(user_id, "tMeUrlTypeUser"));
|
||||
break;
|
||||
}
|
||||
case telegram_api::recentMeUrlChat::ID: {
|
||||
@ -601,11 +601,11 @@ class GetMeRequest final : public RequestActor<> {
|
||||
UserId user_id_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
user_id_ = td_->contacts_manager_->get_me(std::move(promise));
|
||||
user_id_ = td_->user_manager_->get_me(std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_user_object(user_id_));
|
||||
send_result(td_->user_manager_->get_user_object(user_id_));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -617,11 +617,11 @@ class GetUserRequest final : public RequestActor<> {
|
||||
UserId user_id_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
td_->contacts_manager_->get_user(user_id_, get_tries(), std::move(promise));
|
||||
td_->user_manager_->get_user(user_id_, get_tries(), std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_user_object(user_id_));
|
||||
send_result(td_->user_manager_->get_user_object(user_id_));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -635,11 +635,11 @@ class GetUserFullInfoRequest final : public RequestActor<> {
|
||||
UserId user_id_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
td_->contacts_manager_->load_user_full(user_id_, get_tries() < 2, std::move(promise), "GetUserFullInfoRequest");
|
||||
td_->user_manager_->load_user_full(user_id_, get_tries() < 2, std::move(promise), "GetUserFullInfoRequest");
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_user_full_info_object(user_id_));
|
||||
send_result(td_->user_manager_->get_user_full_info_object(user_id_));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -723,11 +723,11 @@ class GetSecretChatRequest final : public RequestActor<> {
|
||||
SecretChatId secret_chat_id_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
td_->contacts_manager_->get_secret_chat(secret_chat_id_, get_tries() < 2, std::move(promise));
|
||||
td_->user_manager_->get_secret_chat(secret_chat_id_, get_tries() < 2, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_secret_chat_object(secret_chat_id_));
|
||||
send_result(td_->user_manager_->get_secret_chat_object(secret_chat_id_));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -766,11 +766,11 @@ class SearchUserByPhoneNumberRequest final : public RequestActor<> {
|
||||
UserId user_id_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
user_id_ = td_->contacts_manager_->search_user_by_phone_number(phone_number_, std::move(promise));
|
||||
user_id_ = td_->user_manager_->search_user_by_phone_number(phone_number_, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_user_object(user_id_));
|
||||
send_result(td_->user_manager_->get_user_object(user_id_));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1729,7 +1729,7 @@ class ImportContactsRequest final : public RequestActor<> {
|
||||
std::pair<vector<UserId>, vector<int32>> imported_contacts_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
imported_contacts_ = td_->contacts_manager_->import_contacts(contacts_, random_id_, std::move(promise));
|
||||
imported_contacts_ = td_->user_manager_->import_contacts(contacts_, random_id_, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
@ -1737,7 +1737,7 @@ class ImportContactsRequest final : public RequestActor<> {
|
||||
CHECK(imported_contacts_.second.size() == contacts_.size());
|
||||
send_result(make_tl_object<td_api::importedContacts>(transform(imported_contacts_.first,
|
||||
[this](UserId user_id) {
|
||||
return td_->contacts_manager_->get_user_id_object(
|
||||
return td_->user_manager_->get_user_id_object(
|
||||
user_id, "ImportContactsRequest");
|
||||
}),
|
||||
std::move(imported_contacts_.second)));
|
||||
@ -1757,11 +1757,11 @@ class SearchContactsRequest final : public RequestActor<> {
|
||||
std::pair<int32, vector<UserId>> user_ids_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
user_ids_ = td_->contacts_manager_->search_contacts(query_, limit_, std::move(promise));
|
||||
user_ids_ = td_->user_manager_->search_contacts(query_, limit_, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_users_object(user_ids_.first, user_ids_.second));
|
||||
send_result(td_->user_manager_->get_users_object(user_ids_.first, user_ids_.second));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1774,7 +1774,7 @@ class RemoveContactsRequest final : public RequestActor<> {
|
||||
vector<UserId> user_ids_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
td_->contacts_manager_->remove_contacts(user_ids_, std::move(promise));
|
||||
td_->user_manager_->remove_contacts(user_ids_, std::move(promise));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1788,7 +1788,7 @@ class GetImportedContactCountRequest final : public RequestActor<> {
|
||||
int32 imported_contact_count_ = 0;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
imported_contact_count_ = td_->contacts_manager_->get_imported_contact_count(std::move(promise));
|
||||
imported_contact_count_ = td_->user_manager_->get_imported_contact_count(std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
@ -1808,7 +1808,7 @@ class ChangeImportedContactsRequest final : public RequestActor<> {
|
||||
std::pair<vector<UserId>, vector<int32>> imported_contacts_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
imported_contacts_ = td_->contacts_manager_->change_imported_contacts(contacts_, random_id_, std::move(promise));
|
||||
imported_contacts_ = td_->user_manager_->change_imported_contacts(contacts_, random_id_, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
@ -1816,7 +1816,7 @@ class ChangeImportedContactsRequest final : public RequestActor<> {
|
||||
CHECK(imported_contacts_.second.size() == contacts_size_);
|
||||
send_result(make_tl_object<td_api::importedContacts>(transform(imported_contacts_.first,
|
||||
[this](UserId user_id) {
|
||||
return td_->contacts_manager_->get_user_id_object(
|
||||
return td_->user_manager_->get_user_id_object(
|
||||
user_id, "ChangeImportedContactsRequest");
|
||||
}),
|
||||
std::move(imported_contacts_.second)));
|
||||
@ -1836,11 +1836,11 @@ class GetCloseFriendsRequest final : public RequestActor<> {
|
||||
vector<UserId> user_ids_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
user_ids_ = td_->contacts_manager_->get_close_friends(std::move(promise));
|
||||
user_ids_ = td_->user_manager_->get_close_friends(std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_users_object(-1, user_ids_));
|
||||
send_result(td_->user_manager_->get_users_object(-1, user_ids_));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1856,7 +1856,7 @@ class GetRecentInlineBotsRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_users_object(-1, user_ids_));
|
||||
send_result(td_->user_manager_->get_users_object(-1, user_ids_));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -2597,7 +2597,7 @@ void Td::on_online_updated(bool force, bool send_update) {
|
||||
return;
|
||||
}
|
||||
if (force || is_online_) {
|
||||
contacts_manager_->set_my_online_status(is_online_, send_update, true);
|
||||
user_manager_->set_my_online_status(is_online_, send_update, true);
|
||||
if (!update_status_query_.empty()) {
|
||||
LOG(INFO) << "Cancel previous update status query";
|
||||
cancel_query(update_status_query_);
|
||||
@ -2617,7 +2617,7 @@ void Td::on_update_status_success(bool is_online) {
|
||||
if (!update_status_query_.empty()) {
|
||||
update_status_query_ = NetQueryRef();
|
||||
}
|
||||
contacts_manager_->set_my_online_status(is_online_, true, false);
|
||||
user_manager_->set_my_online_status(is_online_, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3675,7 +3675,7 @@ void Td::init(Parameters parameters, Result<TdDb::OpenedDatabase> r_opened_datab
|
||||
void Td::process_binlog_events(TdDb::OpenedDatabase &&events) {
|
||||
VLOG(td_init) << "Send binlog events";
|
||||
for (auto &event : events.user_events) {
|
||||
contacts_manager_->on_binlog_user_event(std::move(event));
|
||||
user_manager_->on_binlog_user_event(std::move(event));
|
||||
}
|
||||
|
||||
for (auto &event : events.channel_events) {
|
||||
@ -3688,7 +3688,7 @@ void Td::process_binlog_events(TdDb::OpenedDatabase &&events) {
|
||||
}
|
||||
|
||||
for (auto &event : events.secret_chat_events) {
|
||||
contacts_manager_->on_binlog_secret_chat_event(std::move(event));
|
||||
user_manager_->on_binlog_secret_chat_event(std::move(event));
|
||||
}
|
||||
|
||||
for (auto &event : events.web_page_events) {
|
||||
@ -6144,7 +6144,7 @@ void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) {
|
||||
void Td::on_request(uint64 id, const td_api::createNewSecretChat &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
contacts_manager_->create_new_secret_chat(UserId(request.user_id_), std::move(promise));
|
||||
user_manager_->create_new_secret_chat(UserId(request.user_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::createCall &request) {
|
||||
@ -6155,7 +6155,7 @@ void Td::on_request(uint64 id, const td_api::createCall &request) {
|
||||
}
|
||||
|
||||
UserId user_id(request.user_id_);
|
||||
auto r_input_user = contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
return send_error_raw(id, r_input_user.error().code(), r_input_user.error().message());
|
||||
}
|
||||
@ -6696,7 +6696,7 @@ void Td::on_request(uint64 id, td_api::setNewChatPrivacySettings &request) {
|
||||
void Td::on_request(uint64 id, const td_api::canSendMessageToUser &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
contacts_manager_->can_send_message_to_user(UserId(request.user_id_), request.only_local_, std::move(promise));
|
||||
user_manager_->can_send_message_to_user(UserId(request.user_id_), request.only_local_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setChatTitle &request) {
|
||||
@ -7052,7 +7052,7 @@ void Td::on_request(uint64 id, const td_api::unpinAllMessageThreadMessages &requ
|
||||
void Td::on_request(uint64 id, const td_api::joinChat &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
dialog_participant_manager_->add_dialog_participant(DialogId(request.chat_id_), contacts_manager_->get_my_id(), 0,
|
||||
dialog_participant_manager_->add_dialog_participant(DialogId(request.chat_id_), user_manager_->get_my_id(), 0,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
@ -7545,7 +7545,7 @@ void Td::on_request(uint64 id, td_api::addContact &request) {
|
||||
return send_closure(actor_id(this), &Td::send_error, id, r_contact.move_as_error());
|
||||
}
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->add_contact(r_contact.move_as_ok(), request.share_phone_number_, std::move(promise));
|
||||
user_manager_->add_contact(r_contact.move_as_ok(), request.share_phone_number_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::importContacts &request) {
|
||||
@ -7600,7 +7600,7 @@ void Td::on_request(uint64 id, td_api::changeImportedContacts &request) {
|
||||
void Td::on_request(uint64 id, const td_api::clearImportedContacts &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->clear_imported_contacts(std::move(promise));
|
||||
user_manager_->clear_imported_contacts(std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getCloseFriends &request) {
|
||||
@ -7611,19 +7611,19 @@ void Td::on_request(uint64 id, const td_api::getCloseFriends &request) {
|
||||
void Td::on_request(uint64 id, const td_api::setCloseFriends &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_close_friends(UserId::get_user_ids(request.user_ids_), std::move(promise));
|
||||
user_manager_->set_close_friends(UserId::get_user_ids(request.user_ids_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setUserPersonalProfilePhoto &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_user_profile_photo(UserId(request.user_id_), request.photo_, false, std::move(promise));
|
||||
user_manager_->set_user_profile_photo(UserId(request.user_id_), request.photo_, false, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::suggestUserProfilePhoto &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_user_profile_photo(UserId(request.user_id_), request.photo_, true, std::move(promise));
|
||||
user_manager_->set_user_profile_photo(UserId(request.user_id_), request.photo_, true, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::searchUserByPhoneNumber &request) {
|
||||
@ -7635,7 +7635,7 @@ void Td::on_request(uint64 id, td_api::searchUserByPhoneNumber &request) {
|
||||
void Td::on_request(uint64 id, const td_api::sharePhoneNumber &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->share_phone_number(UserId(request.user_id_), std::move(promise));
|
||||
user_manager_->share_phone_number(UserId(request.user_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getRecentInlineBots &request) {
|
||||
@ -7648,28 +7648,28 @@ void Td::on_request(uint64 id, td_api::setName &request) {
|
||||
CLEAN_INPUT_STRING(request.first_name_);
|
||||
CLEAN_INPUT_STRING(request.last_name_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_name(request.first_name_, request.last_name_, std::move(promise));
|
||||
user_manager_->set_name(request.first_name_, request.last_name_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setBio &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.bio_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_bio(request.bio_, std::move(promise));
|
||||
user_manager_->set_bio(request.bio_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setUsername &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.username_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_username(request.username_, std::move(promise));
|
||||
user_manager_->set_username(request.username_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::toggleUsernameIsActive &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.username_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->toggle_username_is_active(std::move(request.username_), request.is_active_, std::move(promise));
|
||||
user_manager_->toggle_username_is_active(std::move(request.username_), request.is_active_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::reorderActiveUsernames &request) {
|
||||
@ -7678,25 +7678,25 @@ void Td::on_request(uint64 id, td_api::reorderActiveUsernames &request) {
|
||||
CLEAN_INPUT_STRING(username);
|
||||
}
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->reorder_usernames(std::move(request.usernames_), std::move(promise));
|
||||
user_manager_->reorder_usernames(std::move(request.usernames_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setBirthdate &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_birthdate(Birthdate(std::move(request.birthdate_)), std::move(promise));
|
||||
user_manager_->set_birthdate(Birthdate(std::move(request.birthdate_)), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setPersonalChat &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_personal_channel(DialogId(request.chat_id_), std::move(promise));
|
||||
user_manager_->set_personal_channel(DialogId(request.chat_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setEmojiStatus &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_emoji_status(EmojiStatus(request.emoji_status_), std::move(promise));
|
||||
user_manager_->set_emoji_status(EmojiStatus(request.emoji_status_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getThemedEmojiStatuses &request) {
|
||||
@ -7822,14 +7822,14 @@ void Td::on_request(uint64 id, const td_api::getBotName &request) {
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setBotProfilePhoto &request) {
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_bot_profile_photo(UserId(request.bot_user_id_), request.photo_, std::move(promise));
|
||||
user_manager_->set_bot_profile_photo(UserId(request.bot_user_id_), request.photo_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::toggleBotUsernameIsActive &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.username_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->toggle_bot_username_is_active(UserId(request.bot_user_id_), std::move(request.username_),
|
||||
user_manager_->toggle_bot_username_is_active(UserId(request.bot_user_id_), std::move(request.username_),
|
||||
request.is_active_, std::move(promise));
|
||||
}
|
||||
|
||||
@ -7839,8 +7839,7 @@ void Td::on_request(uint64 id, td_api::reorderBotActiveUsernames &request) {
|
||||
CLEAN_INPUT_STRING(username);
|
||||
}
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->reorder_bot_usernames(UserId(request.bot_user_id_), std::move(request.usernames_),
|
||||
std::move(promise));
|
||||
user_manager_->reorder_bot_usernames(UserId(request.bot_user_id_), std::move(request.usernames_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setBotInfoDescription &request) {
|
||||
@ -7923,32 +7922,31 @@ void Td::on_request(uint64 id, td_api::setBusinessIntro &request) {
|
||||
void Td::on_request(uint64 id, td_api::setProfilePhoto &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_profile_photo(request.photo_, request.is_public_, std::move(promise));
|
||||
user_manager_->set_profile_photo(request.photo_, request.is_public_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::deleteProfilePhoto &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->delete_profile_photo(request.profile_photo_id_, false, std::move(promise));
|
||||
user_manager_->delete_profile_photo(request.profile_photo_id_, false, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getUserProfilePhotos &request) {
|
||||
CREATE_REQUEST_PROMISE();
|
||||
contacts_manager_->get_user_profile_photos(UserId(request.user_id_), request.offset_, request.limit_,
|
||||
std::move(promise));
|
||||
user_manager_->get_user_profile_photos(UserId(request.user_id_), request.offset_, request.limit_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setAccentColor &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_accent_color(AccentColorId(request.accent_color_id_),
|
||||
user_manager_->set_accent_color(AccentColorId(request.accent_color_id_),
|
||||
CustomEmojiId(request.background_custom_emoji_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setProfileAccentColor &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_profile_accent_color(AccentColorId(request.profile_accent_color_id_),
|
||||
user_manager_->set_profile_accent_color(AccentColorId(request.profile_accent_color_id_),
|
||||
CustomEmojiId(request.profile_background_custom_emoji_id_),
|
||||
std::move(promise));
|
||||
}
|
||||
@ -8984,7 +8982,7 @@ void Td::on_request(uint64 id, const td_api::deletePassportElement &request) {
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setPassportElementErrors &request) {
|
||||
CHECK_IS_BOT();
|
||||
auto r_input_user = contacts_manager_->get_input_user(UserId(request.user_id_));
|
||||
auto r_input_user = user_manager_->get_input_user(UserId(request.user_id_));
|
||||
if (r_input_user.is_error()) {
|
||||
return send_error_raw(id, r_input_user.error().code(), r_input_user.error().message());
|
||||
}
|
||||
@ -9115,7 +9113,7 @@ void Td::on_request(uint64 id, td_api::checkPhoneNumberConfirmationCode &request
|
||||
void Td::on_request(uint64 id, const td_api::getSupportUser &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
contacts_manager_->get_support_user(std::move(promise));
|
||||
user_manager_->get_support_user(std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getInstalledBackgrounds &request) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
@ -408,16 +409,16 @@ void TopDialogManager::on_load_dialogs(GetTopDialogsQuery &&query, vector<Dialog
|
||||
for (auto dialog_id : dialog_ids) {
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
if (td_->contacts_manager_->is_user_deleted(user_id)) {
|
||||
if (td_->user_manager_->is_user_deleted(user_id)) {
|
||||
LOG(INFO) << "Skip deleted " << user_id;
|
||||
continue;
|
||||
}
|
||||
if (td_->contacts_manager_->get_my_id() == user_id) {
|
||||
if (td_->user_manager_->get_my_id() == user_id) {
|
||||
LOG(INFO) << "Skip self " << user_id;
|
||||
continue;
|
||||
}
|
||||
if (query.category == TopDialogCategory::BotInline || query.category == TopDialogCategory::BotPM) {
|
||||
auto r_bot_info = td_->contacts_manager_->get_bot_data(user_id);
|
||||
auto r_bot_info = td_->user_manager_->get_bot_data(user_id);
|
||||
if (r_bot_info.is_error()) {
|
||||
LOG(INFO) << "Skip not a bot " << user_id;
|
||||
continue;
|
||||
@ -495,7 +496,7 @@ void TopDialogManager::on_get_top_peers(Result<telegram_api::object_ptr<telegram
|
||||
set_is_enabled(true); // apply immediately
|
||||
auto top_peers = move_tl_object_as<telegram_api::contacts_topPeers>(std::move(top_peers_parent));
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(top_peers->users_), "on get top chats");
|
||||
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");
|
||||
for (auto &category : top_peers->categories_) {
|
||||
auto dialog_category = get_top_dialog_category(category->category_);
|
||||
|
@ -28,9 +28,8 @@ class TranslateTextQuery final : public Td::ResultHandler {
|
||||
|
||||
void send(vector<FormattedText> &&texts, const string &to_language_code) {
|
||||
int flags = telegram_api::messages_translateText::TEXT_MASK;
|
||||
auto input_texts =
|
||||
transform(std::move(texts), [contacts_manager = td_->contacts_manager_.get()](FormattedText &&text) {
|
||||
return get_input_text_with_entities(contacts_manager, std::move(text), "TranslateTextQuery");
|
||||
auto input_texts = transform(std::move(texts), [user_manager = td_->user_manager_.get()](FormattedText &&text) {
|
||||
return get_input_text_with_entities(user_manager, std::move(text), "TranslateTextQuery");
|
||||
});
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_translateText(
|
||||
flags, nullptr, vector<int32>{}, std::move(input_texts), to_language_code)));
|
||||
@ -87,7 +86,7 @@ void TranslationManager::translate_text(td_api::object_ptr<td_api::formattedText
|
||||
}
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, entities, get_message_entities(td_->contacts_manager_.get(), std::move(text->entities_)));
|
||||
TRY_RESULT_PROMISE(promise, entities, get_message_entities(td_->user_manager_.get(), std::move(text->entities_)));
|
||||
TRY_STATUS_PROMISE(promise, fix_formatted_text(text->text_, entities, true, true, true, true, true));
|
||||
|
||||
translate_text(FormattedText{std::move(text->text_), std::move(entities)}, skip_bot_commands, max_media_timestamp,
|
||||
@ -120,8 +119,7 @@ void TranslationManager::on_get_translated_texts(vector<telegram_api::object_ptr
|
||||
if (texts.size() != 1u) {
|
||||
return promise.set_error(Status::Error(500, "Receive invalid number of results"));
|
||||
}
|
||||
auto formatted_text =
|
||||
get_formatted_text(td_->contacts_manager_.get(), std::move(texts[0]), true, true, skip_bot_commands,
|
||||
auto formatted_text = get_formatted_text(td_->user_manager_.get(), std::move(texts[0]), true, true, skip_bot_commands,
|
||||
max_media_timestamp == -1, true, "on_get_translated_texts");
|
||||
promise.set_value(get_formatted_text_object(formatted_text, skip_bot_commands, max_media_timestamp));
|
||||
}
|
||||
|
@ -81,6 +81,7 @@
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/TimeZoneManager.h"
|
||||
#include "td/telegram/TranscriptionManager.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/Usernames.h"
|
||||
#include "td/telegram/WebPagesManager.h"
|
||||
|
||||
@ -703,8 +704,7 @@ void UpdatesManager::set_date(int32 date, bool from_update, string date_source)
|
||||
}
|
||||
|
||||
bool UpdatesManager::is_acceptable_user(UserId user_id) const {
|
||||
return td_->contacts_manager_->have_user_force(user_id, "is_acceptable_user") &&
|
||||
td_->contacts_manager_->have_user(user_id);
|
||||
return td_->user_manager_->have_user_force(user_id, "is_acceptable_user") && td_->user_manager_->have_user(user_id);
|
||||
}
|
||||
|
||||
bool UpdatesManager::is_acceptable_chat(ChatId chat_id) const {
|
||||
@ -753,7 +753,7 @@ bool UpdatesManager::is_acceptable_message_entities(
|
||||
if (entity->get_id() == telegram_api::messageEntityMentionName::ID) {
|
||||
auto entity_mention_name = static_cast<const telegram_api::messageEntityMentionName *>(entity.get());
|
||||
UserId user_id(entity_mention_name->user_id_);
|
||||
if (!is_acceptable_user(user_id) || td_->contacts_manager_->get_input_user(user_id).is_error()) {
|
||||
if (!is_acceptable_user(user_id) || td_->user_manager_->get_input_user(user_id).is_error()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -770,7 +770,7 @@ bool UpdatesManager::is_acceptable_reply_markup(const tl_object_ptr<telegram_api
|
||||
if (button->get_id() == telegram_api::keyboardButtonUserProfile::ID) {
|
||||
auto user_profile_button = static_cast<const telegram_api::keyboardButtonUserProfile *>(button.get());
|
||||
UserId user_id(user_profile_button->user_id_);
|
||||
if (!is_acceptable_user(user_id) || td_->contacts_manager_->get_input_user(user_id).is_error()) {
|
||||
if (!is_acceptable_user(user_id) || td_->user_manager_->get_input_user(user_id).is_error()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1189,7 +1189,7 @@ void UpdatesManager::on_get_updates_impl(tl_object_ptr<telegram_api::Updates> up
|
||||
break;
|
||||
case telegram_api::updateShortMessage::ID: {
|
||||
auto update = move_tl_object_as<telegram_api::updateShortMessage>(updates_ptr);
|
||||
auto from_id = update->out_ ? td_->contacts_manager_->get_my_id().get() : update->user_id_;
|
||||
auto from_id = update->out_ ? td_->user_manager_->get_my_id().get() : update->user_id_;
|
||||
auto message = make_tl_object<telegram_api::message>(
|
||||
fix_short_message_flags(update->flags_), update->out_, update->mentioned_, update->media_unread_,
|
||||
update->silent_, false, false, false, false, false, false, false, 0, false, update->id_,
|
||||
@ -1231,7 +1231,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_->contacts_manager_->on_get_users(std::move(updates->users_), "updatesCombined");
|
||||
td_->user_manager_->on_get_users(std::move(updates->users_), "updatesCombined");
|
||||
td_->contacts_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");
|
||||
@ -1245,7 +1245,7 @@ void UpdatesManager::on_get_updates_impl(tl_object_ptr<telegram_api::Updates> up
|
||||
source_str = PSTRING() << "update " << updates->updates_[0]->get_id();
|
||||
source = source_str.c_str();
|
||||
}
|
||||
td_->contacts_manager_->on_get_users(std::move(updates->users_), source);
|
||||
td_->user_manager_->on_get_users(std::move(updates->users_), source);
|
||||
td_->contacts_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");
|
||||
@ -1907,7 +1907,7 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
|
||||
auto difference = move_tl_object_as<telegram_api::updates_difference>(difference_ptr);
|
||||
VLOG(get_difference) << "In get difference receive " << difference->users_.size() << " users and "
|
||||
<< difference->chats_.size() << " chats";
|
||||
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.difference");
|
||||
td_->user_manager_->on_get_users(std::move(difference->users_), "updates.difference");
|
||||
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.difference");
|
||||
|
||||
if (get_difference_retry_count_ <= 5) {
|
||||
@ -1943,7 +1943,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_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.differenceSlice");
|
||||
td_->user_manager_->on_get_users(std::move(difference->users_), "updates.differenceSlice");
|
||||
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.differenceSlice");
|
||||
|
||||
if (get_difference_retry_count_ <= 5) {
|
||||
@ -2040,7 +2040,7 @@ void UpdatesManager::on_get_pts_update(int32 pts,
|
||||
return;
|
||||
}
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(difference->users_), "on_get_pts_update");
|
||||
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");
|
||||
|
||||
for (auto &message : difference->new_messages_) {
|
||||
@ -2236,7 +2236,6 @@ 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_contact_birthdates(false);
|
||||
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());
|
||||
@ -2282,6 +2281,7 @@ void UpdatesManager::try_reload_data() {
|
||||
td_->theme_manager_->reload_chat_themes();
|
||||
td_->theme_manager_->reload_profile_accent_colors();
|
||||
td_->time_zone_manager_->reload_time_zones(Auto());
|
||||
td_->user_manager_->reload_contact_birthdates(false);
|
||||
|
||||
schedule_data_reload();
|
||||
}
|
||||
@ -2402,7 +2402,7 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
auto user_id = dialog_id.get_user_id();
|
||||
if (user_id.is_valid()) {
|
||||
td_->contacts_manager_->on_update_user_local_was_online(user_id, date);
|
||||
td_->user_manager_->on_update_user_local_was_online(user_id, date);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3953,36 +3953,36 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelUserTypi
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateEncryptedChatTyping> update, Promise<Unit> &&promise) {
|
||||
SecretChatId secret_chat_id(update->chat_id_);
|
||||
UserId user_id = td_->contacts_manager_->get_secret_chat_user_id(secret_chat_id);
|
||||
UserId user_id = td_->user_manager_->get_secret_chat_user_id(secret_chat_id);
|
||||
td_->dialog_action_manager_->on_dialog_action(DialogId(secret_chat_id), MessageId(), DialogId(user_id),
|
||||
DialogAction::get_typing_action(), get_short_update_date());
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserStatus> update, Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->on_update_user_online(UserId(update->user_id_), std::move(update->status_));
|
||||
td_->user_manager_->on_update_user_online(UserId(update->user_id_), std::move(update->status_));
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserName> update, Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->on_update_user_name(UserId(update->user_id_), std::move(update->first_name_),
|
||||
td_->user_manager_->on_update_user_name(UserId(update->user_id_), std::move(update->first_name_),
|
||||
std::move(update->last_name_),
|
||||
Usernames{string(), std::move(update->usernames_)});
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserPhone> update, Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->on_update_user_phone_number(UserId(update->user_id_), std::move(update->phone_));
|
||||
td_->user_manager_->on_update_user_phone_number(UserId(update->user_id_), std::move(update->phone_));
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUser> update, Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->invalidate_user_full(UserId(update->user_id_));
|
||||
td_->user_manager_->invalidate_user_full(UserId(update->user_id_));
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserEmojiStatus> update, Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->on_update_user_emoji_status(UserId(update->user_id_), std::move(update->emoji_status_));
|
||||
td_->user_manager_->on_update_user_emoji_status(UserId(update->user_id_), std::move(update->emoji_status_));
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
@ -4004,7 +4004,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotCommands> up
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotMenuButton> update, Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->on_update_bot_menu_button(UserId(update->bot_id_), std::move(update->button_));
|
||||
td_->user_manager_->on_update_bot_menu_button(UserId(update->bot_id_), std::move(update->button_));
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
@ -4239,7 +4239,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotShippingQuer
|
||||
send_closure(
|
||||
G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateNewShippingQuery>(
|
||||
update->query_id_, td_->contacts_manager_->get_user_id_object(user_id, "updateNewShippingQuery"),
|
||||
update->query_id_, td_->user_manager_->get_user_id_object(user_id, "updateNewShippingQuery"),
|
||||
update->payload_.as_slice().str(),
|
||||
get_address_object(get_address(std::move(update->shipping_address_))))); // TODO use convert_address
|
||||
}
|
||||
@ -4253,12 +4253,11 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotPrecheckoutQ
|
||||
} else if (update->total_amount_ <= 0 || !check_currency_amount(update->total_amount_)) {
|
||||
LOG(ERROR) << "Receive pre-checkout query with invalid total amount " << update->total_amount_;
|
||||
} else {
|
||||
send_closure(
|
||||
G()->td(), &Td::send_update,
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateNewPreCheckoutQuery>(
|
||||
update->query_id_, td_->contacts_manager_->get_user_id_object(user_id, "updateNewPreCheckoutQuery"),
|
||||
update->currency_, update->total_amount_, update->payload_.as_slice().str(), update->shipping_option_id_,
|
||||
get_order_info_object(get_order_info(std::move(update->info_)))));
|
||||
update->query_id_, td_->user_manager_->get_user_id_object(user_id, "updateNewPreCheckoutQuery"),
|
||||
update->currency_, update->total_amount_, update->payload_.as_slice().str(),
|
||||
update->shipping_option_id_, get_order_info_object(get_order_info(std::move(update->info_)))));
|
||||
}
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
@ -4316,7 +4315,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateGroupCallPartic
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateContactsReset> update, Promise<Unit> &&promise) {
|
||||
td_->contacts_manager_->on_update_contacts_reset();
|
||||
td_->user_manager_->on_update_contacts_reset();
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
@ -4419,7 +4418,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateTheme> update,
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updatePeerWallpaper> update, Promise<Unit> &&promise) {
|
||||
auto dialog_id = DialogId(update->peer_);
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
td_->contacts_manager_->on_update_user_wallpaper_overridden(dialog_id.get_user_id(), update->wallpaper_overridden_);
|
||||
td_->user_manager_->on_update_user_wallpaper_overridden(dialog_id.get_user_id(), update->wallpaper_overridden_);
|
||||
}
|
||||
td_->messages_manager_->on_update_dialog_background(dialog_id, std::move(update->wallpaper_));
|
||||
promise.set_value(Unit());
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -131,7 +132,7 @@ UserPrivacySettingRule::UserPrivacySettingRule(Td *td,
|
||||
UNREACHABLE();
|
||||
}
|
||||
td::remove_if(user_ids_, [td](UserId user_id) {
|
||||
if (!td->contacts_manager_->have_user(user_id)) {
|
||||
if (!td->user_manager_->have_user(user_id)) {
|
||||
LOG(ERROR) << "Receive unknown " << user_id;
|
||||
return true;
|
||||
}
|
||||
@ -171,7 +172,7 @@ td_api::object_ptr<td_api::UserPrivacySettingRule> UserPrivacySettingRule::get_u
|
||||
return make_tl_object<td_api::userPrivacySettingRuleAllowAll>();
|
||||
case Type::AllowUsers:
|
||||
return make_tl_object<td_api::userPrivacySettingRuleAllowUsers>(
|
||||
td->contacts_manager_->get_user_ids_object(user_ids_, "userPrivacySettingRuleAllowUsers"));
|
||||
td->user_manager_->get_user_ids_object(user_ids_, "userPrivacySettingRuleAllowUsers"));
|
||||
case Type::AllowChatParticipants:
|
||||
return make_tl_object<td_api::userPrivacySettingRuleAllowChatMembers>(
|
||||
td->dialog_manager_->get_chat_ids_object(dialog_ids_, "UserPrivacySettingRule"));
|
||||
@ -181,7 +182,7 @@ td_api::object_ptr<td_api::UserPrivacySettingRule> UserPrivacySettingRule::get_u
|
||||
return make_tl_object<td_api::userPrivacySettingRuleRestrictAll>();
|
||||
case Type::RestrictUsers:
|
||||
return make_tl_object<td_api::userPrivacySettingRuleRestrictUsers>(
|
||||
td->contacts_manager_->get_user_ids_object(user_ids_, "userPrivacySettingRuleRestrictUsers"));
|
||||
td->user_manager_->get_user_ids_object(user_ids_, "userPrivacySettingRuleRestrictUsers"));
|
||||
case Type::RestrictChatParticipants:
|
||||
return make_tl_object<td_api::userPrivacySettingRuleRestrictChatMembers>(
|
||||
td->dialog_manager_->get_chat_ids_object(dialog_ids_, "UserPrivacySettingRule"));
|
||||
@ -221,7 +222,7 @@ telegram_api::object_ptr<telegram_api::InputPrivacyRule> UserPrivacySettingRule:
|
||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> UserPrivacySettingRule::get_input_users(Td *td) const {
|
||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> result;
|
||||
for (auto user_id : user_ids_) {
|
||||
auto r_input_user = td->contacts_manager_->get_input_user(user_id);
|
||||
auto r_input_user = td->user_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_ok()) {
|
||||
result.push_back(r_input_user.move_as_ok());
|
||||
} else {
|
||||
@ -266,7 +267,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->contacts_manager_->on_get_users(std::move(rules->users_), "on get privacy 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");
|
||||
return get_user_privacy_setting_rules(td, std::move(rules->rules_));
|
||||
}
|
||||
@ -355,7 +356,7 @@ td_api::object_ptr<td_api::StoryPrivacySettings> UserPrivacySettingRules::get_st
|
||||
if (rules_.size() == 2u && rules_[0].type_ == UserPrivacySettingRule::Type::RestrictUsers &&
|
||||
rules_[1].type_ == UserPrivacySettingRule::Type::AllowAll) {
|
||||
return td_api::make_object<td_api::storyPrivacySettingsEveryone>(
|
||||
td->contacts_manager_->get_user_ids_object(rules_[0].user_ids_, "storyPrivacySettingsEveryone"));
|
||||
td->user_manager_->get_user_ids_object(rules_[0].user_ids_, "storyPrivacySettingsEveryone"));
|
||||
}
|
||||
if (rules_.size() == 1u && rules_[0].type_ == UserPrivacySettingRule::Type::AllowContacts) {
|
||||
return td_api::make_object<td_api::storyPrivacySettingsContacts>();
|
||||
@ -363,14 +364,14 @@ td_api::object_ptr<td_api::StoryPrivacySettings> UserPrivacySettingRules::get_st
|
||||
if (rules_.size() == 2u && rules_[0].type_ == UserPrivacySettingRule::Type::RestrictUsers &&
|
||||
rules_[1].type_ == UserPrivacySettingRule::Type::AllowContacts) {
|
||||
return td_api::make_object<td_api::storyPrivacySettingsContacts>(
|
||||
td->contacts_manager_->get_user_ids_object(rules_[0].user_ids_, "storyPrivacySettingsContacts"));
|
||||
td->user_manager_->get_user_ids_object(rules_[0].user_ids_, "storyPrivacySettingsContacts"));
|
||||
}
|
||||
if (rules_.size() == 1u && rules_[0].type_ == UserPrivacySettingRule::Type::AllowCloseFriends) {
|
||||
return td_api::make_object<td_api::storyPrivacySettingsCloseFriends>();
|
||||
}
|
||||
if (rules_.size() == 1u && rules_[0].type_ == UserPrivacySettingRule::Type::AllowUsers) {
|
||||
return td_api::make_object<td_api::storyPrivacySettingsSelectedUsers>(
|
||||
td->contacts_manager_->get_user_ids_object(rules_[0].user_ids_, "storyPrivacySettingsSelectedUsers"));
|
||||
td->user_manager_->get_user_ids_object(rules_[0].user_ids_, "storyPrivacySettingsSelectedUsers"));
|
||||
}
|
||||
return td_api::make_object<td_api::storyPrivacySettingsSelectedUsers>();
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
#include "td/telegram/VideoNotesManager.h"
|
||||
#include "td/telegram/VideosManager.h"
|
||||
#include "td/telegram/VoiceNotesManager.h"
|
||||
@ -125,7 +126,7 @@ class GetWebPageQuery final : public Td::ResultHandler {
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetWebPageQuery: " << to_string(ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetWebPageQuery");
|
||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetWebPageQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetWebPageQuery");
|
||||
auto page = std::move(ptr->webpage_);
|
||||
if (page->get_id() == telegram_api::webPageNotModified::ID) {
|
||||
@ -920,7 +921,7 @@ void WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formattedT
|
||||
options->link_preview_options_ = std::move(link_preview_options);
|
||||
td_->create_handler<GetWebPagePreviewQuery>(std::move(promise))
|
||||
->send(formatted_text.text,
|
||||
get_input_message_entities(td_->contacts_manager_.get(), formatted_text.entities, "get_web_page_preview"),
|
||||
get_input_message_entities(td_->user_manager_.get(), formatted_text.entities, "get_web_page_preview"),
|
||||
std::move(options));
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ class FakeSecretChatContext final : public SecretChatActor::Context {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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 is really used. And it is much easier to create tests.
|
||||
void send_net_query(NetQueryPtr query, ActorShared<NetQueryCallback> callback, bool ordered) final;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user