From 6acdfbdf9e7108c69ebad72e107eba6e6cadea04 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 29 Oct 2022 20:18:49 +0300 Subject: [PATCH] Keep information about dropped MessageReplyInfo. --- td/telegram/MessageReplyInfo.cpp | 6 +++++- td/telegram/MessageReplyInfo.h | 5 +++++ td/telegram/MessagesManager.cpp | 12 ++++++------ td/telegram/MessagesManager.h | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/td/telegram/MessageReplyInfo.cpp b/td/telegram/MessageReplyInfo.cpp index 6af9349f8..6a6caf69d 100644 --- a/td/telegram/MessageReplyInfo.cpp +++ b/td/telegram/MessageReplyInfo.cpp @@ -19,13 +19,17 @@ namespace td { MessageReplyInfo::MessageReplyInfo(Td *td, tl_object_ptr &&reply_info, bool is_bot) { - if (reply_info == nullptr || is_bot || reply_info->channel_id_ == 777) { + if (reply_info == nullptr) { return; } if (reply_info->replies_ < 0) { LOG(ERROR) << "Receive wrong " << to_string(reply_info); return; } + if (is_bot || reply_info->channel_id_ == 777) { + is_dropped = true; + return; + } reply_count = reply_info->replies_; pts = reply_info->replies_pts_; diff --git a/td/telegram/MessageReplyInfo.h b/td/telegram/MessageReplyInfo.h index e0fd2b508..fcca30359 100644 --- a/td/telegram/MessageReplyInfo.h +++ b/td/telegram/MessageReplyInfo.h @@ -32,6 +32,7 @@ struct MessageReplyInfo { MessageId last_read_inbox_message_id; MessageId last_read_outbox_message_id; bool is_comment = false; + bool is_dropped = false; static constexpr size_t MAX_RECENT_REPLIERS = 3; @@ -43,6 +44,10 @@ struct MessageReplyInfo { return reply_count < 0; } + bool was_dropped() const { + return is_dropped; + } + bool need_update_to(const MessageReplyInfo &other) const; bool update_max_message_ids(MessageId other_max_message_id, MessageId other_last_read_inbox_message_id, diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 5a64bfa3e..0c84bbb85 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -7010,7 +7010,7 @@ bool MessagesManager::is_thread_message(DialogId dialog_id, const Message *m) co return is_thread_message(dialog_id, m->message_id, m->reply_info, m->content->get_type()); } -bool MessagesManager::is_thread_message(DialogId dialog_id, MessageId message_id, const MessageReplyInfo &info, +bool MessagesManager::is_thread_message(DialogId dialog_id, MessageId message_id, const MessageReplyInfo &reply_info, MessageContentType content_type) const { if (dialog_id.get_type() != DialogType::Channel || is_broadcast_channel(dialog_id)) { return false; @@ -7018,18 +7018,18 @@ bool MessagesManager::is_thread_message(DialogId dialog_id, MessageId message_id if (!message_id.is_valid() || !message_id.is_server()) { return false; } - return !info.is_empty() || content_type == MessageContentType::TopicCreate; + return !reply_info.is_empty() || reply_info.was_dropped() || content_type == MessageContentType::TopicCreate; } -bool MessagesManager::is_active_message_reply_info(DialogId dialog_id, const MessageReplyInfo &info) const { - if (info.is_empty()) { +bool MessagesManager::is_active_message_reply_info(DialogId dialog_id, const MessageReplyInfo &reply_info) const { + if (reply_info.is_empty()) { return false; } if (dialog_id.get_type() != DialogType::Channel) { return false; } - if (!info.is_comment) { + if (!reply_info.is_comment) { return true; } if (!is_broadcast_channel(dialog_id)) { @@ -7049,7 +7049,7 @@ bool MessagesManager::is_active_message_reply_info(DialogId dialog_id, const Mes return true; } - return linked_channel_id == info.channel_id; + return linked_channel_id == reply_info.channel_id; } bool MessagesManager::is_visible_message_reply_info(DialogId dialog_id, const Message *m) const { diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 9ebb19147..437169781 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -2202,10 +2202,10 @@ class MessagesManager final : public Actor { bool is_thread_message(DialogId dialog_id, const Message *m) const; - bool is_thread_message(DialogId dialog_id, MessageId message_id, const MessageReplyInfo &info, + bool is_thread_message(DialogId dialog_id, MessageId message_id, const MessageReplyInfo &reply_info, MessageContentType content_type) const; - bool is_active_message_reply_info(DialogId dialog_id, const MessageReplyInfo &info) const; + bool is_active_message_reply_info(DialogId dialog_id, const MessageReplyInfo &reply_info) const; bool is_visible_message_reply_info(DialogId dialog_id, const Message *m) const;