From 4b6db81c6596c90beca6d1b4d4899df974f5b0c4 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 23 May 2024 20:46:45 +0300 Subject: [PATCH] Check fact check in closed chats. --- td/telegram/FactCheck.h | 2 +- td/telegram/MessagesManager.cpp | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/td/telegram/FactCheck.h b/td/telegram/FactCheck.h index 269a16ed0..30c3c4c78 100644 --- a/td/telegram/FactCheck.h +++ b/td/telegram/FactCheck.h @@ -42,7 +42,7 @@ class FactCheck { } bool need_check() const { - return hash_ == 0; + return need_check_; } void update_from(const FactCheck &old_fact_check); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 32e7ccbe7..73decf55f 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -18807,11 +18807,6 @@ Status MessagesManager::view_messages(DialogId dialog_id, vector mess if (need_poll_message_reactions(d, m)) { viewed_reaction_message_ids.push_back(message_id); } - if (m->fact_check != nullptr && m->fact_check->need_check() && - being_reloaded_fact_checks_.insert({dialog_id, message_id}).second) { - CHECK(message_id.is_server()); - viewed_fact_check_message_ids.push_back(message_id); - } } else { info->recently_viewed_messages.erase(view_id); } @@ -18819,6 +18814,12 @@ Status MessagesManager::view_messages(DialogId dialog_id, vector mess info->recently_viewed_messages[view_id] = message_id; } + if (m->message_id.is_server() && m->fact_check != nullptr && m->fact_check->need_check() && + being_reloaded_fact_checks_.insert({dialog_id, message_id}).second) { + CHECK(message_id.is_server()); + viewed_fact_check_message_ids.push_back(message_id); + } + if (need_invalidate_authentication_code) { extract_authentication_codes(dialog_id, m, authentication_codes); } @@ -18868,17 +18869,17 @@ Status MessagesManager::view_messages(DialogId dialog_id, vector mess if (!viewed_reaction_message_ids.empty()) { queue_message_reactions_reload(dialog_id, viewed_reaction_message_ids); } - if (!viewed_fact_check_message_ids.empty()) { - CHECK(dialog_id.get_type() != DialogType::SecretChat); - auto promise = - PromiseCreator::lambda([actor_id = actor_id(this), dialog_id, message_ids = viewed_fact_check_message_ids]( - Result>> r_fact_checks) { - send_closure(actor_id, &MessagesManager::on_get_message_fact_checks, dialog_id, message_ids, - std::move(r_fact_checks)); - }); - td_->create_handler(std::move(promise)) - ->send(dialog_id, std::move(viewed_fact_check_message_ids)); - } + } + if (!viewed_fact_check_message_ids.empty()) { + CHECK(dialog_id.get_type() != DialogType::SecretChat); + auto promise = + PromiseCreator::lambda([actor_id = actor_id(this), dialog_id, message_ids = viewed_fact_check_message_ids]( + Result>> r_fact_checks) { + send_closure(actor_id, &MessagesManager::on_get_message_fact_checks, dialog_id, message_ids, + std::move(r_fact_checks)); + }); + td_->create_handler(std::move(promise)) + ->send(dialog_id, std::move(viewed_fact_check_message_ids)); } if (td_->is_online() && dialog_viewed_messages_.count(dialog_id) != 0) { update_viewed_messages_timeout_.add_timeout_in(dialog_id.get(), UPDATE_VIEWED_MESSAGES_PERIOD);