Use DialogManager::have_dialog_force.

This commit is contained in:
levlam 2024-01-04 15:26:42 +03:00
parent b2fccc7d9c
commit 978be7206f
25 changed files with 76 additions and 74 deletions

View File

@ -843,7 +843,7 @@ void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id,
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(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, bot_data, td_->contacts_manager_->get_bot_data(bot_user_id));
if (!td_->messages_manager_->have_dialog_force(dialog_id, "request_web_view")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "request_web_view")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }

View File

@ -483,7 +483,7 @@ void AutosaveManager::set_autosave_settings(td_api::object_ptr<td_api::AutosaveS
break; break;
case td_api::autosaveSettingsScopeChat::ID: case td_api::autosaveSettingsScopeChat::ID:
dialog_id = DialogId(static_cast<const td_api::autosaveSettingsScopeChat *>(scope.get())->chat_id_); dialog_id = DialogId(static_cast<const td_api::autosaveSettingsScopeChat *>(scope.get())->chat_id_);
if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_autosave_settings")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "set_autosave_settings")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
old_settings = &settings_.exceptions_[dialog_id]; old_settings = &settings_.exceptions_[dialog_id];

View File

@ -738,7 +738,7 @@ void BackgroundManager::delete_background(bool for_dark_theme, Promise<Unit> &&p
} }
Result<DialogId> BackgroundManager::get_background_dialog(DialogId dialog_id) { Result<DialogId> BackgroundManager::get_background_dialog(DialogId dialog_id) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_dialog_background")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "set_dialog_background")) {
return Status::Error(400, "Chat not found"); return Status::Error(400, "Chat not found");
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {

View File

@ -376,7 +376,7 @@ void BoostManager::get_boost_slots(Promise<td_api::object_ptr<td_api::chatBoostS
void BoostManager::get_dialog_boost_status(DialogId dialog_id, void BoostManager::get_dialog_boost_status(DialogId dialog_id,
Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise) { Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -388,7 +388,7 @@ void BoostManager::get_dialog_boost_status(DialogId dialog_id,
void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids, void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids,
Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise) { Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -402,7 +402,7 @@ void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids,
} }
Result<std::pair<string, bool>> BoostManager::get_dialog_boost_link(DialogId dialog_id) { Result<std::pair<string, bool>> BoostManager::get_dialog_boost_link(DialogId dialog_id) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return Status::Error(400, "Chat not found"); return Status::Error(400, "Chat not found");
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -453,7 +453,7 @@ td_api::object_ptr<td_api::chatBoostLinkInfo> BoostManager::get_chat_boost_link_
void BoostManager::get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, const string &offset, int32 limit, void BoostManager::get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, const string &offset, int32 limit,
Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise) { Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boosts")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boosts")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -468,7 +468,7 @@ void BoostManager::get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, c
void BoostManager::get_user_dialog_boosts(DialogId dialog_id, UserId user_id, void BoostManager::get_user_dialog_boosts(DialogId dialog_id, UserId user_id,
Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise) { Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_user_dialog_boosts")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_user_dialog_boosts")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {

View File

@ -10,7 +10,6 @@
#include "td/telegram/AuthManager.h" #include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h" #include "td/telegram/DialogManager.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
namespace td { namespace td {
@ -63,7 +62,7 @@ Result<BotCommandScope> BotCommandScope::get_bot_command_scope(Td *td,
return BotCommandScope(Type::Default); return BotCommandScope(Type::Default);
} }
if (!td->messages_manager_->have_dialog_force(dialog_id, "get_bot_command_scope")) { if (!td->dialog_manager_->have_dialog_force(dialog_id, "get_bot_command_scope")) {
return Status::Error(400, "Chat not found"); return Status::Error(400, "Chat not found");
} }
if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {

View File

@ -238,7 +238,7 @@ void CallbackQueriesManager::send_callback_query(MessageFullId message_full_id,
} }
auto dialog_id = message_full_id.get_dialog_id(); auto dialog_id = message_full_id.get_dialog_id();
td_->messages_manager_->have_dialog_force(dialog_id, "send_callback_query"); td_->dialog_manager_->have_dialog_force(dialog_id, "send_callback_query");
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat")); return promise.set_error(Status::Error(400, "Can't access the chat"));
} }

View File

@ -8652,7 +8652,7 @@ void ContactsManager::set_channel_discussion_group(DialogId dialog_id, DialogId
ChannelId broadcast_channel_id; ChannelId broadcast_channel_id;
telegram_api::object_ptr<telegram_api::InputChannel> broadcast_input_channel; telegram_api::object_ptr<telegram_api::InputChannel> broadcast_input_channel;
if (dialog_id.is_valid()) { if (dialog_id.is_valid()) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_channel_discussion_group 1")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "set_channel_discussion_group 1")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -8682,7 +8682,7 @@ void ContactsManager::set_channel_discussion_group(DialogId dialog_id, DialogId
ChannelId group_channel_id; ChannelId group_channel_id;
telegram_api::object_ptr<telegram_api::InputChannel> group_input_channel; telegram_api::object_ptr<telegram_api::InputChannel> group_input_channel;
if (discussion_dialog_id.is_valid()) { if (discussion_dialog_id.is_valid()) {
if (!td_->messages_manager_->have_dialog_force(discussion_dialog_id, "set_channel_discussion_group 2")) { if (!td_->dialog_manager_->have_dialog_force(discussion_dialog_id, "set_channel_discussion_group 2")) {
return promise.set_error(Status::Error(400, "Discussion chat not found")); return promise.set_error(Status::Error(400, "Discussion chat not found"));
} }
if (discussion_dialog_id.get_type() != DialogType::Channel) { if (discussion_dialog_id.get_type() != DialogType::Channel) {
@ -8722,7 +8722,7 @@ void ContactsManager::set_channel_location(DialogId dialog_id, const DialogLocat
if (!dialog_id.is_valid()) { if (!dialog_id.is_valid()) {
return promise.set_error(Status::Error(400, "Invalid chat identifier specified")); return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
} }
if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_channel_location")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "set_channel_location")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -8754,7 +8754,7 @@ void ContactsManager::set_channel_slow_mode_delay(DialogId dialog_id, int32 slow
if (!dialog_id.is_valid()) { if (!dialog_id.is_valid()) {
return promise.set_error(Status::Error(400, "Invalid chat identifier specified")); return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
} }
if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_channel_slow_mode_delay")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "set_channel_slow_mode_delay")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -8782,7 +8782,7 @@ void ContactsManager::get_channel_statistics_dc_id(DialogId dialog_id, bool for_
if (!dialog_id.is_valid()) { if (!dialog_id.is_valid()) {
return promise.set_error(Status::Error(400, "Invalid chat identifier specified")); return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
} }
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_channel_statistics_dc_id")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_channel_statistics_dc_id")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -8965,7 +8965,7 @@ void ContactsManager::delete_channel(ChannelId channel_id, Promise<Unit> &&promi
} }
void ContactsManager::delete_dialog(DialogId dialog_id, Promise<Unit> &&promise) { void ContactsManager::delete_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "delete_dialog")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "delete_dialog")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -9376,7 +9376,7 @@ td_api::object_ptr<td_api::CanTransferOwnershipResult> ContactsManager::get_can_
void ContactsManager::transfer_dialog_ownership(DialogId dialog_id, UserId user_id, const string &password, void ContactsManager::transfer_dialog_ownership(DialogId dialog_id, UserId user_id, const string &password,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "transfer_dialog_ownership")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "transfer_dialog_ownership")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!have_user_force(user_id, "transfer_dialog_ownership")) { if (!have_user_force(user_id, "transfer_dialog_ownership")) {
@ -9426,7 +9426,7 @@ void ContactsManager::transfer_channel_ownership(
} }
Status ContactsManager::can_manage_dialog_invite_links(DialogId dialog_id, bool creator_only) { Status ContactsManager::can_manage_dialog_invite_links(DialogId dialog_id, bool creator_only) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "can_manage_dialog_invite_links")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "can_manage_dialog_invite_links")) {
return Status::Error(400, "Chat not found"); return Status::Error(400, "Chat not found");
} }
@ -9938,7 +9938,7 @@ bool ContactsManager::are_suitable_recommended_dialogs(const RecommendedDialogs
void ContactsManager::get_channel_recommendations(DialogId dialog_id, bool return_local, void ContactsManager::get_channel_recommendations(DialogId dialog_id, bool return_local,
Promise<td_api::object_ptr<td_api::chats>> &&chats_promise, Promise<td_api::object_ptr<td_api::chats>> &&chats_promise,
Promise<td_api::object_ptr<td_api::count>> &&count_promise) { Promise<td_api::object_ptr<td_api::count>> &&count_promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_channel_recommendations")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_channel_recommendations")) {
if (chats_promise) { if (chats_promise) {
chats_promise.set_error(Status::Error(400, "Chat not found")); chats_promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -10159,8 +10159,8 @@ void ContactsManager::on_get_channel_recommendations(
void ContactsManager::open_channel_recommended_channel(DialogId dialog_id, DialogId opened_dialog_id, void ContactsManager::open_channel_recommended_channel(DialogId dialog_id, DialogId opened_dialog_id,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "open_channel_recommended_channel") || if (!td_->dialog_manager_->have_dialog_force(dialog_id, "open_channel_recommended_channel") ||
!td_->messages_manager_->have_dialog_force(opened_dialog_id, "open_channel_recommended_channel")) { !td_->dialog_manager_->have_dialog_force(opened_dialog_id, "open_channel_recommended_channel")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (dialog_id.get_type() != DialogType::Channel || opened_dialog_id.get_type() != DialogType::Channel) { if (dialog_id.get_type() != DialogType::Channel || opened_dialog_id.get_type() != DialogType::Channel) {
@ -18983,7 +18983,7 @@ std::pair<int32, vector<DialogId>> ContactsManager::search_among_dialogs(const v
void ContactsManager::add_dialog_participant(DialogId dialog_id, UserId user_id, int32 forward_limit, void ContactsManager::add_dialog_participant(DialogId dialog_id, UserId user_id, int32 forward_limit,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "add_dialog_participant")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "add_dialog_participant")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -19005,7 +19005,7 @@ void ContactsManager::add_dialog_participant(DialogId dialog_id, UserId user_id,
void ContactsManager::add_dialog_participants(DialogId dialog_id, const vector<UserId> &user_ids, void ContactsManager::add_dialog_participants(DialogId dialog_id, const vector<UserId> &user_ids,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "add_dialog_participants")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "add_dialog_participants")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -19030,7 +19030,7 @@ void ContactsManager::add_dialog_participants(DialogId dialog_id, const vector<U
void ContactsManager::set_dialog_participant_status(DialogId dialog_id, DialogId participant_dialog_id, void ContactsManager::set_dialog_participant_status(DialogId dialog_id, DialogId participant_dialog_id,
td_api::object_ptr<td_api::ChatMemberStatus> &&chat_member_status, td_api::object_ptr<td_api::ChatMemberStatus> &&chat_member_status,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_dialog_participant_status")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "set_dialog_participant_status")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -19061,7 +19061,7 @@ void ContactsManager::set_dialog_participant_status(DialogId dialog_id, DialogId
} }
void ContactsManager::leave_dialog(DialogId dialog_id, Promise<Unit> &&promise) { void ContactsManager::leave_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "leave_dialog")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "leave_dialog")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -19088,7 +19088,7 @@ void ContactsManager::leave_dialog(DialogId dialog_id, Promise<Unit> &&promise)
void ContactsManager::ban_dialog_participant(DialogId dialog_id, DialogId participant_dialog_id, void ContactsManager::ban_dialog_participant(DialogId dialog_id, DialogId participant_dialog_id,
int32 banned_until_date, bool revoke_messages, Promise<Unit> &&promise) { int32 banned_until_date, bool revoke_messages, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "ban_dialog_participant")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "ban_dialog_participant")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -19142,7 +19142,7 @@ void ContactsManager::finish_get_dialog_participant(DialogParticipant &&dialog_p
void ContactsManager::do_get_dialog_participant(DialogId dialog_id, DialogId participant_dialog_id, void ContactsManager::do_get_dialog_participant(DialogId dialog_id, DialogId participant_dialog_id,
Promise<DialogParticipant> &&promise) { Promise<DialogParticipant> &&promise) {
LOG(INFO) << "Receive GetChatMember request to get " << participant_dialog_id << " in " << dialog_id; LOG(INFO) << "Receive GetChatMember request to get " << participant_dialog_id << " in " << dialog_id;
if (!td_->messages_manager_->have_dialog_force(dialog_id, "do_get_dialog_participant")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "do_get_dialog_participant")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -19209,7 +19209,7 @@ void ContactsManager::search_dialog_participants(DialogId dialog_id, const strin
Promise<DialogParticipants> &&promise) { Promise<DialogParticipants> &&promise) {
LOG(INFO) << "Receive searchChatMembers request to search for \"" << query << "\" in " << dialog_id << " with filter " LOG(INFO) << "Receive searchChatMembers request to search for \"" << query << "\" in " << dialog_id << " with filter "
<< filter; << filter;
if (!td_->messages_manager_->have_dialog_force(dialog_id, "search_dialog_participants")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "search_dialog_participants")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (limit < 0) { if (limit < 0) {
@ -19416,7 +19416,7 @@ td_api::object_ptr<td_api::chatAdministrators> ContactsManager::get_chat_adminis
void ContactsManager::get_dialog_administrators(DialogId dialog_id, void ContactsManager::get_dialog_administrators(DialogId dialog_id,
Promise<td_api::object_ptr<td_api::chatAdministrators>> &&promise) { Promise<td_api::object_ptr<td_api::chatAdministrators>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_administrators")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_administrators")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }

View File

@ -7,6 +7,7 @@
#include "td/telegram/Dependencies.h" #include "td/telegram/Dependencies.h"
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessagesManager.h" #include "td/telegram/MessagesManager.h"
#include "td/telegram/StoryManager.h" #include "td/telegram/StoryManager.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
@ -128,7 +129,7 @@ bool Dependencies::resolve_force(Td *td, const char *source, bool ignore_errors)
} }
} }
for (auto dialog_id : dialog_ids) { for (auto dialog_id : dialog_ids) {
if (!td->messages_manager_->have_dialog_force(dialog_id, source)) { if (!td->dialog_manager_->have_dialog_force(dialog_id, source)) {
if (!ignore_errors) { if (!ignore_errors) {
LOG(ERROR) << "Can't find " << dialog_id << " from " << source; LOG(ERROR) << "Can't find " << dialog_id << " from " << source;
} }

View File

@ -13,6 +13,7 @@
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogInviteLink.h" #include "td/telegram/DialogInviteLink.h"
#include "td/telegram/DialogLocation.h" #include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogParticipant.h" #include "td/telegram/DialogParticipant.h"
#include "td/telegram/EmojiStatus.h" #include "td/telegram/EmojiStatus.h"
#include "td/telegram/ForumTopicInfo.h" #include "td/telegram/ForumTopicInfo.h"
@ -618,7 +619,7 @@ static telegram_api::object_ptr<telegram_api::channelAdminLogEventsFilter> get_i
void get_dialog_event_log(Td *td, DialogId dialog_id, const string &query, int64 from_event_id, int32 limit, void get_dialog_event_log(Td *td, DialogId dialog_id, const string &query, int64 from_event_id, int32 limit,
const td_api::object_ptr<td_api::chatEventLogFilters> &filters, const td_api::object_ptr<td_api::chatEventLogFilters> &filters,
const vector<UserId> &user_ids, Promise<td_api::object_ptr<td_api::chatEvents>> &&promise) { const vector<UserId> &user_ids, Promise<td_api::object_ptr<td_api::chatEvents>> &&promise) {
if (!td->messages_manager_->have_dialog_force(dialog_id, "get_dialog_event_log")) { if (!td->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_event_log")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }

View File

@ -8,6 +8,7 @@
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h" #include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h" #include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h" #include "td/telegram/MessagesManager.h"
#include "td/telegram/misc.h" #include "td/telegram/misc.h"
@ -704,7 +705,7 @@ vector<DialogId> DialogFilter::get_dialogs_for_invite_link(Td *td) {
vector<DialogId> result; vector<DialogId> result;
for_each_dialog([&](const InputDialogId &input_dialog_id) { for_each_dialog([&](const InputDialogId &input_dialog_id) {
auto dialog_id = input_dialog_id.get_dialog_id(); auto dialog_id = input_dialog_id.get_dialog_id();
if (!td->messages_manager_->have_dialog_force(dialog_id, "get_dialogs_for_invite_link")) { if (!td->dialog_manager_->have_dialog_force(dialog_id, "get_dialogs_for_invite_link")) {
return; return;
} }
bool is_good = false; bool is_good = false;

View File

@ -942,7 +942,7 @@ void DialogFilterManager::load_dialog_filter(const DialogFilter *dialog_filter,
for (const auto &input_dialog_id : needed_dialog_ids) { for (const auto &input_dialog_id : needed_dialog_ids) {
auto dialog_id = input_dialog_id.get_dialog_id(); auto dialog_id = input_dialog_id.get_dialog_id();
// TODO load dialogs asynchronously // TODO load dialogs asynchronously
if (!td_->messages_manager_->have_dialog_force(dialog_id, "load_dialog_filter")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "load_dialog_filter")) {
if (dialog_id.get_type() == DialogType::SecretChat) { if (dialog_id.get_type() == DialogType::SecretChat) {
if (td_->dialog_manager_->have_dialog_info_force(dialog_id, "load_dialog_filter")) { if (td_->dialog_manager_->have_dialog_info_force(dialog_id, "load_dialog_filter")) {
td_->messages_manager_->force_create_dialog(dialog_id, "load_dialog_filter"); td_->messages_manager_->force_create_dialog(dialog_id, "load_dialog_filter");
@ -992,8 +992,8 @@ void DialogFilterManager::on_load_dialog_filter_dialogs(DialogFilterId dialog_fi
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status()); TRY_STATUS_PROMISE(promise, G()->close_status());
td::remove_if(dialog_ids, [messages_manager = td_->messages_manager_.get()](DialogId dialog_id) { td::remove_if(dialog_ids, [dialog_manager = td_->dialog_manager_.get()](DialogId dialog_id) {
return messages_manager->have_dialog_force(dialog_id, "on_load_dialog_filter_dialogs"); return dialog_manager->have_dialog_force(dialog_id, "on_load_dialog_filter_dialogs");
}); });
if (dialog_ids.empty()) { if (dialog_ids.empty()) {
LOG(INFO) << "All chats from " << dialog_filter_id << " were loaded"; LOG(INFO) << "All chats from " << dialog_filter_id << " were loaded";
@ -1898,7 +1898,7 @@ void DialogFilterManager::create_dialog_filter_invite_link(
vector<tl_object_ptr<telegram_api::InputPeer>> input_peers; vector<tl_object_ptr<telegram_api::InputPeer>> input_peers;
input_peers.reserve(dialog_ids.size()); input_peers.reserve(dialog_ids.size());
for (auto &dialog_id : dialog_ids) { for (auto &dialog_id : dialog_ids) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "create_dialog_filter_invite_link")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "create_dialog_filter_invite_link")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write); auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
@ -1936,7 +1936,7 @@ void DialogFilterManager::edit_dialog_filter_invite_link(
vector<tl_object_ptr<telegram_api::InputPeer>> input_peers; vector<tl_object_ptr<telegram_api::InputPeer>> input_peers;
input_peers.reserve(dialog_ids.size()); input_peers.reserve(dialog_ids.size());
for (auto &dialog_id : dialog_ids) { for (auto &dialog_id : dialog_ids) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "edit_dialog_filter_invite_link")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "edit_dialog_filter_invite_link")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write); auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
@ -2035,7 +2035,7 @@ void DialogFilterManager::add_dialog_filter_by_invite_link(const string &invite_
return promise.set_error(Status::Error(400, "Wrong invite link")); return promise.set_error(Status::Error(400, "Wrong invite link"));
} }
for (auto dialog_id : dialog_ids) { for (auto dialog_id : dialog_ids) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "add_dialog_filter_by_invite_link")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "add_dialog_filter_by_invite_link")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Know)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Know)) {
@ -2069,7 +2069,7 @@ void DialogFilterManager::add_dialog_filter_new_chats(DialogFilterId dialog_filt
return promise.set_error(Status::Error(400, "Chat folder must be shareable")); return promise.set_error(Status::Error(400, "Chat folder must be shareable"));
} }
for (auto dialog_id : dialog_ids) { for (auto dialog_id : dialog_ids) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "add_dialog_filter_new_chats")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "add_dialog_filter_new_chats")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Know)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Know)) {

View File

@ -652,7 +652,7 @@ void ForumTopicManager::on_update_forum_topic_notify_settings(
void ForumTopicManager::on_update_forum_topic_is_pinned(DialogId dialog_id, MessageId top_thread_message_id, void ForumTopicManager::on_update_forum_topic_is_pinned(DialogId dialog_id, MessageId top_thread_message_id,
bool is_pinned) { bool is_pinned) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "on_update_forum_topic_is_pinned")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "on_update_forum_topic_is_pinned")) {
return; return;
} }
if (!can_be_forum(dialog_id)) { if (!can_be_forum(dialog_id)) {
@ -675,7 +675,7 @@ void ForumTopicManager::on_update_forum_topic_is_pinned(DialogId dialog_id, Mess
} }
void ForumTopicManager::on_update_pinned_forum_topics(DialogId dialog_id, vector<MessageId> top_thread_message_ids) { void ForumTopicManager::on_update_pinned_forum_topics(DialogId dialog_id, vector<MessageId> top_thread_message_ids) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "on_update_pinned_forum_topics")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "on_update_pinned_forum_topics")) {
return; return;
} }
if (!can_be_forum(dialog_id)) { if (!can_be_forum(dialog_id)) {
@ -1066,7 +1066,7 @@ td_api::object_ptr<td_api::forumTopic> ForumTopicManager::get_forum_topic_object
} }
Status ForumTopicManager::is_forum(DialogId dialog_id) { Status ForumTopicManager::is_forum(DialogId dialog_id) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "ForumTopicManager::is_forum")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "ForumTopicManager::is_forum")) {
return Status::Error(400, "Chat not found"); return Status::Error(400, "Chat not found");
} }
if (dialog_id.get_type() != DialogType::Channel || if (dialog_id.get_type() != DialogType::Channel ||

View File

@ -22,7 +22,7 @@
namespace td { namespace td {
Result<ChannelId> GiveawayParameters::get_boosted_channel_id(Td *td, DialogId dialog_id) { Result<ChannelId> GiveawayParameters::get_boosted_channel_id(Td *td, DialogId dialog_id) {
if (!td->messages_manager_->have_dialog_force(dialog_id, "get_boosted_channel_id")) { if (!td->dialog_manager_->have_dialog_force(dialog_id, "get_boosted_channel_id")) {
return Status::Error(400, "Chat to boost not found"); return Status::Error(400, "Chat to boost not found");
} }
if (dialog_id.get_type() != DialogType::Channel) { if (dialog_id.get_type() != DialogType::Channel) {

View File

@ -1223,7 +1223,7 @@ Status GroupCallManager::can_join_group_calls(DialogId dialog_id) const {
if (!dialog_id.is_valid()) { if (!dialog_id.is_valid()) {
return Status::Error(400, "Invalid chat identifier specified"); return Status::Error(400, "Invalid chat identifier specified");
} }
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_group_call_join_as")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_group_call_join_as")) {
return Status::Error(400, "Chat not found"); return Status::Error(400, "Chat not found");
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -1311,7 +1311,7 @@ void GroupCallManager::set_group_call_default_join_as(DialogId dialog_id, Dialog
break; break;
case DialogType::Chat: case DialogType::Chat:
case DialogType::Channel: case DialogType::Channel:
if (!td_->messages_manager_->have_dialog_force(as_dialog_id, "set_group_call_default_join_as 2")) { if (!td_->dialog_manager_->have_dialog_force(as_dialog_id, "set_group_call_default_join_as 2")) {
return promise.set_error(Status::Error(400, "Participant chat not found")); return promise.set_error(Status::Error(400, "Participant chat not found"));
} }
break; break;
@ -1333,7 +1333,7 @@ void GroupCallManager::create_voice_chat(DialogId dialog_id, string title, int32
if (!dialog_id.is_valid()) { if (!dialog_id.is_valid()) {
return promise.set_error(Status::Error(400, "Invalid chat identifier specified")); return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
} }
if (!td_->messages_manager_->have_dialog_force(dialog_id, "create_voice_chat")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "create_voice_chat")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -1362,7 +1362,7 @@ void GroupCallManager::get_voice_chat_rtmp_stream_url(DialogId dialog_id, bool r
if (!dialog_id.is_valid()) { if (!dialog_id.is_valid()) {
return promise.set_error(Status::Error(400, "Invalid chat identifier specified")); return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
} }
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_voice_chat_rtmp_stream_url")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_voice_chat_rtmp_stream_url")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -2644,7 +2644,7 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_di
have_as_dialog_id = false; have_as_dialog_id = false;
} }
} else { } else {
if (!td_->messages_manager_->have_dialog_force(as_dialog_id, "join_group_call")) { if (!td_->dialog_manager_->have_dialog_force(as_dialog_id, "join_group_call")) {
return promise.set_error(Status::Error(400, "Join as chat not found")); return promise.set_error(Status::Error(400, "Join as chat not found"));
} }
} }

View File

@ -926,7 +926,7 @@ void get_message_added_reactions(Td *td, MessageFullId message_full_id, Reaction
void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId chooser_dialog_id, void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId chooser_dialog_id,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
auto dialog_id = message_full_id.get_dialog_id(); auto dialog_id = message_full_id.get_dialog_id();
if (!td->messages_manager_->have_dialog_force(dialog_id, "send_callback_query")) { if (!td->dialog_manager_->have_dialog_force(dialog_id, "send_callback_query")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {

View File

@ -9,7 +9,6 @@
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h" #include "td/telegram/DialogManager.h"
#include "td/telegram/MessageSender.h" #include "td/telegram/MessageSender.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/ServerMessageId.h" #include "td/telegram/ServerMessageId.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"

View File

@ -158,7 +158,7 @@ Result<DialogId> get_message_sender_dialog_id(Td *td,
bool know_dialog = bool know_dialog =
dialog_id.get_type() == DialogType::User dialog_id.get_type() == DialogType::User
? td->contacts_manager_->have_user_force(dialog_id.get_user_id(), "get_message_sender_dialog_id 2") ? td->contacts_manager_->have_user_force(dialog_id.get_user_id(), "get_message_sender_dialog_id 2")
: td->messages_manager_->have_dialog_force(dialog_id, "get_message_sender_dialog_id"); : td->dialog_manager_->have_dialog_force(dialog_id, "get_message_sender_dialog_id");
if (check_access && !know_dialog) { if (check_access && !know_dialog) {
return Status::Error(400, "Unknown chat identifier specified"); return Status::Error(400, "Unknown chat identifier specified");
} }

View File

@ -106,7 +106,7 @@ Result<telegram_api::object_ptr<telegram_api::InputPeer>> get_boost_input_peer(T
return nullptr; return nullptr;
} }
if (!td->messages_manager_->have_dialog_force(dialog_id, "get_boost_input_peer")) { if (!td->dialog_manager_->have_dialog_force(dialog_id, "get_boost_input_peer")) {
return Status::Error(400, "Chat to boost not found"); return Status::Error(400, "Chat to boost not found");
} }
if (dialog_id.get_type() != DialogType::Channel || if (dialog_id.get_type() != DialogType::Channel ||

View File

@ -318,7 +318,7 @@ td_api::object_ptr<td_api::sponsoredMessages> SponsoredMessageManager::get_spons
void SponsoredMessageManager::get_dialog_sponsored_messages( void SponsoredMessageManager::get_dialog_sponsored_messages(
DialogId dialog_id, Promise<td_api::object_ptr<td_api::sponsoredMessages>> &&promise) { DialogId dialog_id, Promise<td_api::object_ptr<td_api::sponsoredMessages>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_sponsored_message")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_sponsored_message")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (dialog_id.get_type() != DialogType::Channel) { if (dialog_id.get_type() != DialogType::Channel) {

View File

@ -2263,7 +2263,7 @@ void StoryManager::on_synchronized_archive_all_stories(bool set_archive_all_stor
void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, StoryListId story_list_id, void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, StoryListId story_list_id,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "toggle_dialog_stories_hidden")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "toggle_dialog_stories_hidden")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -2286,7 +2286,7 @@ void StoryManager::get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId f
return promise.set_error(Status::Error(400, "Parameter limit must be positive")); return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
} }
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_dialog_pinned_stories")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "get_dialog_pinned_stories")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -2328,7 +2328,7 @@ void StoryManager::get_story_archive(DialogId owner_dialog_id, StoryId from_stor
if (from_story_id != StoryId() && !from_story_id.is_server()) { if (from_story_id != StoryId() && !from_story_id.is_server()) {
return promise.set_error(Status::Error(400, "Invalid value of parameter from_story_id specified")); return promise.set_error(Status::Error(400, "Invalid value of parameter from_story_id specified"));
} }
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_story_archive")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "get_story_archive")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!can_edit_stories(owner_dialog_id)) { if (!can_edit_stories(owner_dialog_id)) {
@ -2360,7 +2360,7 @@ void StoryManager::on_get_story_archive(DialogId owner_dialog_id,
void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id, void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id,
Promise<td_api::object_ptr<td_api::chatActiveStories>> &&promise) { Promise<td_api::object_ptr<td_api::chatActiveStories>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status()); TRY_STATUS_PROMISE(promise, G()->close_status());
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_dialog_expiring_stories")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "get_dialog_expiring_stories")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -2480,7 +2480,7 @@ void StoryManager::on_get_dialog_expiring_stories(DialogId owner_dialog_id,
} }
void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) { void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "open_story")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "open_story")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -2543,7 +2543,7 @@ void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promis
} }
void StoryManager::close_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) { void StoryManager::close_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "close_story")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "close_story")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -2655,7 +2655,7 @@ void StoryManager::on_story_chosen_reaction_changed(StoryFullId story_full_id, S
void StoryManager::set_story_reaction(StoryFullId story_full_id, ReactionType reaction_type, bool add_to_recent, void StoryManager::set_story_reaction(StoryFullId story_full_id, ReactionType reaction_type, bool add_to_recent,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
auto owner_dialog_id = story_full_id.get_dialog_id(); auto owner_dialog_id = story_full_id.get_dialog_id();
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "set_story_reaction")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "set_story_reaction")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -4474,7 +4474,7 @@ void StoryManager::on_reload_story(StoryFullId story_full_id, Result<Unit> &&res
void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id, bool only_local, void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id, bool only_local,
Promise<td_api::object_ptr<td_api::story>> &&promise) { Promise<td_api::object_ptr<td_api::story>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_story")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "get_story")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -4658,7 +4658,7 @@ void StoryManager::save_channels_to_send_stories() {
void StoryManager::can_send_story(DialogId dialog_id, void StoryManager::can_send_story(DialogId dialog_id,
Promise<td_api::object_ptr<td_api::CanSendStoryResult>> &&promise) { Promise<td_api::object_ptr<td_api::CanSendStoryResult>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "can_send_story")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "can_send_story")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!can_post_stories(dialog_id)) { if (!can_post_stories(dialog_id)) {
@ -4673,7 +4673,7 @@ void StoryManager::send_story(DialogId dialog_id, td_api::object_ptr<td_api::Inp
td_api::object_ptr<td_api::StoryPrivacySettings> &&settings, int32 active_period, td_api::object_ptr<td_api::StoryPrivacySettings> &&settings, int32 active_period,
td_api::object_ptr<td_api::storyFullId> &&from_story_full_id, bool is_pinned, td_api::object_ptr<td_api::storyFullId> &&from_story_full_id, bool is_pinned,
bool protect_content, Promise<td_api::object_ptr<td_api::story>> &&promise) { bool protect_content, Promise<td_api::object_ptr<td_api::story>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "send_story")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "send_story")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
if (!can_post_stories(dialog_id)) { if (!can_post_stories(dialog_id)) {
@ -5412,7 +5412,7 @@ void StoryManager::on_binlog_events(vector<BinlogEvent> &&events) {
log_event_parse(log_event, event.get_data()).ensure(); log_event_parse(log_event, event.get_data()).ensure();
auto owner_dialog_id = log_event.story_full_id_.get_dialog_id(); auto owner_dialog_id = log_event.story_full_id_.get_dialog_id();
td_->messages_manager_->have_dialog_force(owner_dialog_id, "DeleteStoryOnServerLogEvent"); td_->dialog_manager_->have_dialog_force(owner_dialog_id, "DeleteStoryOnServerLogEvent");
delete_story_on_server(log_event.story_full_id_, event.id_, Auto()); delete_story_on_server(log_event.story_full_id_, event.id_, Auto());
break; break;
} }
@ -5421,7 +5421,7 @@ void StoryManager::on_binlog_events(vector<BinlogEvent> &&events) {
log_event_parse(log_event, event.get_data()).ensure(); log_event_parse(log_event, event.get_data()).ensure();
auto owner_dialog_id = log_event.dialog_id_; auto owner_dialog_id = log_event.dialog_id_;
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "ReadStoriesOnServerLogEvent")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "ReadStoriesOnServerLogEvent")) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
break; break;
} }
@ -5443,7 +5443,7 @@ void StoryManager::on_binlog_events(vector<BinlogEvent> &&events) {
log_event_parse(log_event, event.get_data()).ensure(); log_event_parse(log_event, event.get_data()).ensure();
auto owner_dialog_id = log_event.dialog_id_; auto owner_dialog_id = log_event.dialog_id_;
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "LoadDialogExpiringStoriesLogEvent")) { if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "LoadDialogExpiringStoriesLogEvent")) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
break; break;
} }

View File

@ -6878,7 +6878,7 @@ void Td::on_request(uint64 id, const td_api::leaveChat &request) {
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
DialogId dialog_id(request.chat_id_); DialogId dialog_id(request.chat_id_);
td_api::object_ptr<td_api::ChatMemberStatus> new_status = td_api::make_object<td_api::chatMemberStatusLeft>(); td_api::object_ptr<td_api::ChatMemberStatus> new_status = td_api::make_object<td_api::chatMemberStatusLeft>();
if (dialog_id.get_type() == DialogType::Channel && messages_manager_->have_dialog_force(dialog_id, "leaveChat")) { if (dialog_id.get_type() == DialogType::Channel && dialog_manager_->have_dialog_force(dialog_id, "leaveChat")) {
auto status = contacts_manager_->get_channel_status(dialog_id.get_channel_id()); auto status = contacts_manager_->get_channel_status(dialog_id.get_channel_id());
if (status.is_creator()) { if (status.is_creator()) {
if (!status.is_member()) { if (!status.is_member()) {
@ -8303,7 +8303,7 @@ void Td::on_request(uint64 id, const td_api::resetAllNotificationSettings &reque
void Td::on_request(uint64 id, const td_api::getMapThumbnailFile &request) { void Td::on_request(uint64 id, const td_api::getMapThumbnailFile &request) {
DialogId dialog_id(request.chat_id_); DialogId dialog_id(request.chat_id_);
if (!messages_manager_->have_dialog_force(dialog_id, "getMapThumbnailFile")) { if (!dialog_manager_->have_dialog_force(dialog_id, "getMapThumbnailFile")) {
dialog_id = DialogId(); dialog_id = DialogId();
} }

View File

@ -239,7 +239,7 @@ void TopDialogManager::remove_dialog(TopDialogCategory category, DialogId dialog
if (category == TopDialogCategory::Size) { if (category == TopDialogCategory::Size) {
return promise.set_error(Status::Error(400, "Top chat category must be non-empty")); return promise.set_error(Status::Error(400, "Top chat category must be non-empty"));
} }
if (!td_->messages_manager_->have_dialog_force(dialog_id, "remove_dialog")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "remove_dialog")) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
CHECK(!td_->auth_manager_->is_bot()); CHECK(!td_->auth_manager_->is_bot());

View File

@ -10,7 +10,6 @@
#include "td/telegram/DialogId.h" #include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h" #include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h" #include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h" #include "td/telegram/telegram_api.h"

View File

@ -23,6 +23,7 @@
#include "td/telegram/DialogFilterManager.h" #include "td/telegram/DialogFilterManager.h"
#include "td/telegram/DialogId.h" #include "td/telegram/DialogId.h"
#include "td/telegram/DialogInviteLink.h" #include "td/telegram/DialogInviteLink.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogParticipant.h" #include "td/telegram/DialogParticipant.h"
#include "td/telegram/DownloadManager.h" #include "td/telegram/DownloadManager.h"
#include "td/telegram/EmojiStatus.h" #include "td/telegram/EmojiStatus.h"
@ -4242,9 +4243,9 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateGroupCallConnec
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateGroupCall> update, Promise<Unit> &&promise) { void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateGroupCall> update, Promise<Unit> &&promise) {
DialogId dialog_id(ChatId(update->chat_id_)); DialogId dialog_id(ChatId(update->chat_id_));
if (!td_->messages_manager_->have_dialog_force(dialog_id, "updateGroupCall")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "updateGroupCall")) {
dialog_id = DialogId(ChannelId(update->chat_id_)); dialog_id = DialogId(ChannelId(update->chat_id_));
if (!td_->messages_manager_->have_dialog_force(dialog_id, "updateGroupCall")) { if (!td_->dialog_manager_->have_dialog_force(dialog_id, "updateGroupCall")) {
dialog_id = DialogId(); dialog_id = DialogId();
} }
} }

View File

@ -10,6 +10,7 @@
#include "td/telegram/ChatId.h" #include "td/telegram/ChatId.h"
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h" #include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessagesManager.h" #include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
@ -24,7 +25,7 @@ void UserPrivacySettingRule::set_dialog_ids(Td *td, const vector<int64> &chat_id
dialog_ids_.clear(); dialog_ids_.clear();
for (auto chat_id : chat_ids) { for (auto chat_id : chat_ids) {
DialogId dialog_id(chat_id); DialogId dialog_id(chat_id);
if (!td->messages_manager_->have_dialog_force(dialog_id, "UserPrivacySettingRule::set_dialog_ids")) { if (!td->dialog_manager_->have_dialog_force(dialog_id, "UserPrivacySettingRule::set_dialog_ids")) {
LOG(INFO) << "Ignore not found " << dialog_id; LOG(INFO) << "Ignore not found " << dialog_id;
continue; continue;
} }