Add ForumTopicManager::can_be_forum.

This commit is contained in:
levlam 2022-11-15 17:07:05 +03:00
parent 2ee0eb67f3
commit ab165bd34d
2 changed files with 8 additions and 2 deletions

View File

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

View File

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