Don't log not found chats in load_dialogs.

This commit is contained in:
levlam 2023-09-20 20:44:21 +03:00
parent 606ee063d5
commit 67cf6d7fe5
3 changed files with 18 additions and 8 deletions

View File

@ -89,17 +89,21 @@ void Dependencies::add_message_sender_dependencies(DialogId dialog_id) {
} }
} }
bool Dependencies::resolve_force(Td *td, const char *source) const { bool Dependencies::resolve_force(Td *td, const char *source, bool ignore_errors) const {
bool success = true; bool success = true;
for (auto user_id : user_ids) { for (auto user_id : user_ids) {
if (!td->contacts_manager_->have_user_force(user_id, source)) { if (!td->contacts_manager_->have_user_force(user_id, source)) {
LOG(ERROR) << "Can't find " << user_id << " from " << source; if (!ignore_errors) {
LOG(ERROR) << "Can't find " << user_id << " from " << source;
}
success = false; success = false;
} }
} }
for (auto chat_id : chat_ids) { for (auto chat_id : chat_ids) {
if (!td->contacts_manager_->have_chat_force(chat_id)) { if (!td->contacts_manager_->have_chat_force(chat_id)) {
LOG(ERROR) << "Can't find " << chat_id << " from " << source; if (!ignore_errors) {
LOG(ERROR) << "Can't find " << chat_id << " from " << source;
}
success = false; success = false;
} }
} }
@ -109,19 +113,25 @@ bool Dependencies::resolve_force(Td *td, const char *source) const {
LOG(INFO) << "Can't find " << channel_id << " from " << source << ", but have it as a min-channel"; LOG(INFO) << "Can't find " << channel_id << " from " << source << ", but have it as a min-channel";
continue; continue;
} }
LOG(ERROR) << "Can't find " << channel_id << " from " << source; if (!ignore_errors) {
LOG(ERROR) << "Can't find " << channel_id << " from " << source;
}
success = false; success = false;
} }
} }
for (auto secret_chat_id : secret_chat_ids) { for (auto secret_chat_id : secret_chat_ids) {
if (!td->contacts_manager_->have_secret_chat_force(secret_chat_id)) { if (!td->contacts_manager_->have_secret_chat_force(secret_chat_id)) {
LOG(ERROR) << "Can't find " << secret_chat_id << " from " << source; if (!ignore_errors) {
LOG(ERROR) << "Can't find " << secret_chat_id << " from " << source;
}
success = false; success = false;
} }
} }
for (auto dialog_id : dialog_ids) { for (auto dialog_id : dialog_ids) {
if (!td->messages_manager_->have_dialog_force(dialog_id, source)) { if (!td->messages_manager_->have_dialog_force(dialog_id, source)) {
LOG(ERROR) << "Can't find " << dialog_id << " from " << source; if (!ignore_errors) {
LOG(ERROR) << "Can't find " << dialog_id << " from " << source;
}
td->messages_manager_->force_create_dialog(dialog_id, source, true); td->messages_manager_->force_create_dialog(dialog_id, source, true);
success = false; success = false;
} }

View File

@ -48,7 +48,7 @@ class Dependencies {
void add_message_sender_dependencies(DialogId dialog_id); void add_message_sender_dependencies(DialogId dialog_id);
bool resolve_force(Td *td, const char *source) const; bool resolve_force(Td *td, const char *source, bool ignore_errors = false) const;
const FlatHashSet<DialogId, DialogIdHash> &get_dialog_ids() const { const FlatHashSet<DialogId, DialogIdHash> &get_dialog_ids() const {
return dialog_ids; return dialog_ids;

View File

@ -16649,7 +16649,7 @@ void MessagesManager::load_dialogs(vector<DialogId> dialog_ids, Promise<vector<D
dependencies.add_dialog_dependencies(dialog_id); dependencies.add_dialog_dependencies(dialog_id);
} }
} }
dependencies.resolve_force(td_, "load_dialogs"); dependencies.resolve_force(td_, "load_dialogs", true);
td::remove_if(dialog_ids, [this](DialogId dialog_id) { return !have_dialog_info(dialog_id); }); td::remove_if(dialog_ids, [this](DialogId dialog_id) { return !have_dialog_info(dialog_id); });