From 1dcd78f1ed9781458efc1529a73fcd6762352d8f Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 26 Aug 2023 05:00:15 +0300 Subject: [PATCH] Add source to have_dialog_info_force. --- td/telegram/ContactsManager.cpp | 2 +- td/telegram/DialogFilterManager.cpp | 2 +- td/telegram/ForumTopicInfo.cpp | 2 +- td/telegram/GroupCallManager.cpp | 2 +- td/telegram/MessagesManager.cpp | 29 ++++++++++++++----------- td/telegram/MessagesManager.h | 2 +- td/telegram/SponsoredMessageManager.cpp | 3 ++- td/telegram/StoryManager.cpp | 4 ++-- 8 files changed, 25 insertions(+), 21 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 43d69ed4b..5ae918fca 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -16664,7 +16664,7 @@ void ContactsManager::on_update_channel_participant(ChannelId channel_id, UserId void ContactsManager::on_update_chat_invite_requester(DialogId dialog_id, UserId user_id, string about, int32 date, DialogInviteLink invite_link) { if (!td_->auth_manager_->is_bot() || date <= 0 || !have_user_force(user_id, "on_update_chat_invite_requester") || - !td_->messages_manager_->have_dialog_info_force(dialog_id)) { + !td_->messages_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; return; diff --git a/td/telegram/DialogFilterManager.cpp b/td/telegram/DialogFilterManager.cpp index 76ae070c5..75ecac42f 100644 --- a/td/telegram/DialogFilterManager.cpp +++ b/td/telegram/DialogFilterManager.cpp @@ -944,7 +944,7 @@ void DialogFilterManager::load_dialog_filter(const DialogFilter *dialog_filter, // TODO load dialogs asynchronously if (!td_->messages_manager_->have_dialog_force(dialog_id, "load_dialog_filter")) { if (dialog_id.get_type() == DialogType::SecretChat) { - if (td_->messages_manager_->have_dialog_info_force(dialog_id)) { + if (td_->messages_manager_->have_dialog_info_force(dialog_id, "load_dialog_filter")) { td_->messages_manager_->force_create_dialog(dialog_id, "load_dialog_filter"); } } else { diff --git a/td/telegram/ForumTopicInfo.cpp b/td/telegram/ForumTopicInfo.cpp index 924de3dfd..5809832d6 100644 --- a/td/telegram/ForumTopicInfo.cpp +++ b/td/telegram/ForumTopicInfo.cpp @@ -29,7 +29,7 @@ ForumTopicInfo::ForumTopicInfo(Td *td, const tl_object_ptrdate_; creator_dialog_id_ = DialogId(forum_topic->from_id_); if (creator_dialog_id_.is_valid() && creator_dialog_id_.get_type() != DialogType::User && - td->messages_manager_->have_dialog_info_force(creator_dialog_id_)) { + td->messages_manager_->have_dialog_info_force(creator_dialog_id_, "ForumTopicInfo")) { td->messages_manager_->force_create_dialog(creator_dialog_id_, "ForumTopicInfo", true); } is_outgoing_ = forum_topic->my_; diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index e7d561114..1a3b40bf7 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -4546,7 +4546,7 @@ void GroupCallManager::on_user_speaking_in_group_call(GroupCallId group_call_id, return; } - if (!td_->messages_manager_->have_dialog_info_force(dialog_id) || + if (!td_->messages_manager_->have_dialog_info_force(dialog_id, "on_user_speaking_in_group_call") || (!is_recursive && need_group_call_participants(input_group_call_id, group_call) && get_group_call_participant(input_group_call_id, dialog_id) == nullptr)) { if (is_recursive) { diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index f976b0aa5..73467b7d2 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -6399,11 +6399,11 @@ bool MessagesManager::have_dialog_info(DialogId dialog_id) const { } } -bool MessagesManager::have_dialog_info_force(DialogId dialog_id) const { +bool MessagesManager::have_dialog_info_force(DialogId dialog_id, const char *source) const { 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, "have_dialog_info_force"); + return td_->contacts_manager_->have_user_force(user_id, source); } case DialogType::Chat: { ChatId chat_id = dialog_id.get_chat_id(); @@ -7630,7 +7630,7 @@ void MessagesManager::on_dialog_action(DialogId dialog_id, MessageId top_thread_ return; } } else { - if (!have_dialog_info_force(typing_dialog_id)) { + if (!have_dialog_info_force(typing_dialog_id, "on_dialog_action")) { LOG(DEBUG) << "Ignore " << action << " of unknown " << typing_dialog_id; return; } @@ -14065,7 +14065,7 @@ void MessagesManager::on_get_secret_message(SecretChatId secret_chat_id, UserId message_info.ttl = message->ttl_; Dialog *d = get_dialog_force(message_info.dialog_id, "on_get_secret_message"); - if (d == nullptr && have_dialog_info_force(message_info.dialog_id)) { + if (d == nullptr && have_dialog_info_force(message_info.dialog_id, "on_get_secret_message")) { force_create_dialog(message_info.dialog_id, "on_get_secret_message", true, true); d = get_dialog(message_info.dialog_id); } @@ -14161,7 +14161,7 @@ void MessagesManager::on_secret_chat_screenshot_taken(SecretChatId secret_chat_i message_info.content = create_screenshot_taken_message_content(); Dialog *d = get_dialog_force(message_info.dialog_id, "on_secret_chat_screenshot_taken"); - if (d == nullptr && have_dialog_info_force(message_info.dialog_id)) { + if (d == nullptr && have_dialog_info_force(message_info.dialog_id, "on_secret_chat_screenshot_taken")) { force_create_dialog(message_info.dialog_id, "on_get_secret_message", true, true); d = get_dialog(message_info.dialog_id); } @@ -14199,7 +14199,7 @@ void MessagesManager::on_secret_chat_ttl_changed(SecretChatId secret_chat_id, Us message_info.content = create_chat_set_ttl_message_content(ttl, UserId()); Dialog *d = get_dialog_force(message_info.dialog_id, "on_secret_chat_ttl_changed"); - if (d == nullptr && have_dialog_info_force(message_info.dialog_id)) { + if (d == nullptr && have_dialog_info_force(message_info.dialog_id, "on_secret_chat_ttl_changed")) { force_create_dialog(message_info.dialog_id, "on_get_secret_message", true, true); d = get_dialog(message_info.dialog_id); } @@ -14599,7 +14599,8 @@ std::pair> MessagesManager::creat bool has_forward_info = message_info.forward_header != nullptr; - if (sender_dialog_id.is_valid() && sender_dialog_id != dialog_id && have_dialog_info_force(sender_dialog_id)) { + if (sender_dialog_id.is_valid() && sender_dialog_id != dialog_id && + have_dialog_info_force(sender_dialog_id, "create_message")) { CHECK(sender_dialog_id.get_type() != DialogType::User); force_create_dialog(sender_dialog_id, "create_message", true); } @@ -16766,7 +16767,7 @@ vector MessagesManager::get_dialogs(DialogListId dialog_list_id, Dialo auto dialog_id = input_dialog_id.get_dialog_id(); if (!have_dialog_force(dialog_id, "get_dialogs")) { if (dialog_id.get_type() == DialogType::SecretChat) { - if (have_dialog_info_force(dialog_id)) { + if (have_dialog_info_force(dialog_id, "get_dialogs")) { force_create_dialog(dialog_id, "get_dialogs"); } } else { @@ -17822,7 +17823,7 @@ FullMessageId MessagesManager::get_replied_message(DialogId dialog_id, MessageId auto replied_message_id = get_replied_message_id(dialog_id, m); if (replied_message_id.get_dialog_id() != dialog_id) { dialog_id = replied_message_id.get_dialog_id(); - if (!have_dialog_info_force(dialog_id)) { + if (!have_dialog_info_force(dialog_id, "get_replied_message")) { promise.set_value(Unit()); return {}; } @@ -19747,7 +19748,7 @@ bool MessagesManager::is_dialog_mention_notifications_disabled(const Dialog *d) void MessagesManager::create_dialog(DialogId dialog_id, bool force, Promise &&promise) { if (!have_input_peer(dialog_id, AccessRights::Read)) { - if (!have_dialog_info_force(dialog_id)) { + if (!have_dialog_info_force(dialog_id, "create dialog")) { return promise.set_error(Status::Error(400, "Chat info not found")); } if (!have_input_peer(dialog_id, AccessRights::Read)) { @@ -37685,7 +37686,7 @@ unique_ptr MessagesManager::parse_dialog(DialogId dialo invalidate_message_indexes(d); // and try to reget it from the server if possible - have_dialog_info_force(dialog_id); + have_dialog_info_force(dialog_id, "parse_dialog"); if (have_input_peer(dialog_id, AccessRights::Read)) { if (dialog_id.get_type() != DialogType::SecretChat) { send_get_dialog_query(dialog_id, Auto(), 0, source); @@ -39584,7 +39585,8 @@ void MessagesManager::on_binlog_events(vector &&events) { } auto sender_dialog_id = log_event.sender_dialog_id_; - if (!have_dialog_info_force(sender_dialog_id) || !have_input_peer(sender_dialog_id, AccessRights::Know)) { + if (!have_dialog_info_force(sender_dialog_id, "DeleteAllChannelMessagesFromSenderOnServer") || + !have_input_peer(sender_dialog_id, AccessRights::Know)) { LOG(ERROR) << "Can't find " << sender_dialog_id; binlog_erase(G()->td_db()->get_binlog(), event.id_); break; @@ -39824,7 +39826,8 @@ void MessagesManager::on_binlog_events(vector &&events) { log_event_parse(log_event, event.get_data()).ensure(); auto dialog_id = log_event.dialog_id_; - if (dialog_id.get_type() == DialogType::SecretChat || !have_dialog_info_force(dialog_id) || + if (dialog_id.get_type() == DialogType::SecretChat || + !have_dialog_info_force(dialog_id, "ToggleDialogIsBlockedOnServerLogEvent") || !have_input_peer(dialog_id, AccessRights::Know)) { binlog_erase(G()->td_db()->get_binlog(), event.id_); break; diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index f6a324c6d..5a9f87990 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -597,7 +597,7 @@ class MessagesManager final : public Actor { bool have_dialog_force(DialogId dialog_id, const char *source); bool have_dialog_info(DialogId dialog_id) const; - bool have_dialog_info_force(DialogId dialog_id) const; + bool have_dialog_info_force(DialogId dialog_id, const char *source) const; void reload_dialog_info_full(DialogId dialog_id, const char *source); diff --git a/td/telegram/SponsoredMessageManager.cpp b/td/telegram/SponsoredMessageManager.cpp index 9b78ae442..9ac51c510 100644 --- a/td/telegram/SponsoredMessageManager.cpp +++ b/td/telegram/SponsoredMessageManager.cpp @@ -376,7 +376,8 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages( DialogPhoto site_photo; if (sponsored_message->from_id_ != nullptr) { sponsor_dialog_id = DialogId(sponsored_message->from_id_); - if (!sponsor_dialog_id.is_valid() || !td_->messages_manager_->have_dialog_info_force(sponsor_dialog_id)) { + if (!sponsor_dialog_id.is_valid() || + !td_->messages_manager_->have_dialog_info_force(sponsor_dialog_id, "on_get_dialog_sponsored_messages")) { LOG(ERROR) << "Receive unknown sponsor " << sponsor_dialog_id; continue; } diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index d4d8e4801..1eab27ddb 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -3579,7 +3579,7 @@ void StoryManager::on_update_story_id(int64 random_id, StoryId new_story_id, con } bool StoryManager::on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id) { - if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) { + if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id, "on_update_read_stories")) { LOG(INFO) << "Can't read stories in unknown " << owner_dialog_id; return false; } @@ -3636,7 +3636,7 @@ void StoryManager::on_update_story_chosen_reaction_type(DialogId owner_dialog_id LOG(ERROR) << "Receive chosen reaction in " << story_id << " in " << owner_dialog_id; return; } - if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) { + if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id, "on_update_story_chosen_reaction_type")) { return; } StoryFullId story_full_id{owner_dialog_id, story_id};