Keep information about dropped MessageReplyInfo.

This commit is contained in:
levlam 2022-10-29 20:18:49 +03:00
parent ba7a1bd895
commit 6acdfbdf9e
4 changed files with 18 additions and 9 deletions

View File

@ -19,13 +19,17 @@
namespace td {
MessageReplyInfo::MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageReplies> &&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_;

View File

@ -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,

View File

@ -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 {

View File

@ -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;