From 99163ff431a23938a6060d7c8268a5a1e8571310 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 2 Oct 2020 15:01:11 +0300 Subject: [PATCH] Fix canGetMessageThread. GitOrigin-RevId: 688fd7615bc841284611393f77e8598e7d9cba13 --- td/telegram/MessagesManager.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 5d5f7ff34..62d3f7f08 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -15974,15 +15974,24 @@ Result MessagesManager::get_top_thread_full_message_id(DialogId d if (m->message_id.is_scheduled()) { return Status::Error(400, "Message is scheduled"); } - if (m->reply_info.is_comment) { + if (dialog_id.get_type() != DialogType::Channel) { + return Status::Error(400, "Chat can't have message threads"); + } + if (!m->reply_info.is_empty() && m->reply_info.is_comment) { if (!is_visible_message_reply_info(dialog_id, m)) { return Status::Error(400, "Message has no comments"); } return FullMessageId{DialogId(m->reply_info.channel_id), m->linked_top_thread_message_id}; } else { - if (!m->top_thread_message_id.is_valid() || !is_visible_message_reply_info(dialog_id, m)) { + if (!m->top_thread_message_id.is_valid()) { return Status::Error(400, "Message has no thread"); } + if (!m->message_id.is_server()) { + return Status::Error(400, "Message thread is unavailable for the message"); + } + if (!td_->contacts_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id())) { + return Status::Error(400, "Message threads are unavailable in the chat"); + } return FullMessageId{dialog_id, m->top_thread_message_id}; } }