From ab165bd34d51b7a1028b7a7c51f135526077f670 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 15 Nov 2022 17:07:05 +0300 Subject: [PATCH] Add ForumTopicManager::can_be_forum. --- td/telegram/ForumTopicManager.cpp | 8 ++++++-- td/telegram/ForumTopicManager.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/td/telegram/ForumTopicManager.cpp b/td/telegram/ForumTopicManager.cpp index 0d929c341..4c7923bb3 100644 --- a/td/telegram/ForumTopicManager.cpp +++ b/td/telegram/ForumTopicManager.cpp @@ -307,8 +307,7 @@ void ForumTopicManager::on_get_forum_topics(DialogId dialog_id, if (forum_topics.empty()) { return; } - if (dialog_id.get_type() != DialogType::Channel || - !td_->contacts_manager_->is_megagroup_channel(dialog_id.get_channel_id())) { + if (!can_be_forum(dialog_id)) { LOG(ERROR) << "Receive forum topics in " << dialog_id << " from " << source; return; } @@ -340,6 +339,11 @@ Status ForumTopicManager::is_forum(DialogId dialog_id) { return Status::OK(); } +bool ForumTopicManager::can_be_forum(DialogId dialog_id) const { + return dialog_id.get_type() == DialogType::Channel && + td_->contacts_manager_->is_megagroup_channel(dialog_id.get_channel_id()); +} + ForumTopicManager::DialogTopics *ForumTopicManager::add_dialog_topics(DialogId dialog_id) { auto *dialog_topics = dialog_topics_.get_pointer(dialog_id); if (dialog_topics == nullptr) { diff --git a/td/telegram/ForumTopicManager.h b/td/telegram/ForumTopicManager.h index 3137ac4f6..38f0a4765 100644 --- a/td/telegram/ForumTopicManager.h +++ b/td/telegram/ForumTopicManager.h @@ -69,6 +69,8 @@ class ForumTopicManager final : public Actor { Status is_forum(DialogId dialog_id); + bool can_be_forum(DialogId dialog_id) const; + DialogTopics *add_dialog_topics(DialogId dialog_id); static Topic *add_topic(DialogTopics *dialog_topics, MessageId top_thread_message_id);