Move ForumTopicInfo out of ForumTopic.

This commit is contained in:
levlam 2022-11-15 16:14:57 +03:00
parent 0f357cdb95
commit 24be58d083
2 changed files with 8 additions and 13 deletions

View File

@ -7,6 +7,7 @@
#include "td/telegram/ForumTopic.h"
#include "td/telegram/DraftMessage.h"
#include "td/telegram/ForumTopicInfo.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/Td.h"
@ -20,7 +21,6 @@ ForumTopic::ForumTopic(Td *td, tl_object_ptr<telegram_api::ForumTopic> &&forum_t
LOG(INFO) << "Receive " << to_string(forum_topic_ptr);
return;
}
info_ = ForumTopicInfo(forum_topic_ptr);
auto *forum_topic = static_cast<telegram_api::forumTopic *>(forum_topic_ptr.get());
is_short_ = forum_topic->short_;
if (is_short_) {
@ -40,8 +40,8 @@ ForumTopic::ForumTopic(Td *td, tl_object_ptr<telegram_api::ForumTopic> &&forum_t
draft_message_ = get_draft_message(td->contacts_manager_.get(), std::move(forum_topic->draft_));
}
td_api::object_ptr<td_api::forumTopic> ForumTopic::get_forum_topic_object(Td *td) const {
if (is_empty()) {
td_api::object_ptr<td_api::forumTopic> ForumTopic::get_forum_topic_object(Td *td, const ForumTopicInfo &info) const {
if (info.is_empty()) {
return nullptr;
}
@ -49,7 +49,7 @@ td_api::object_ptr<td_api::forumTopic> ForumTopic::get_forum_topic_object(Td *td
// TODO last_message
auto draft_message = get_draft_message_object(draft_message_);
return td_api::make_object<td_api::forumTopic>(
info_.get_forum_topic_info_object(td), nullptr, is_pinned_, unread_count_, last_read_inbox_message_id_.get(),
info.get_forum_topic_info_object(td), nullptr, is_pinned_, unread_count_, last_read_inbox_message_id_.get(),
last_read_outbox_message_id_.get(), unread_mention_count_, unread_reaction_count_,
get_chat_notification_settings_object(&notification_settings_), std::move(draft_message));
}

View File

@ -7,7 +7,6 @@
#pragma once
#include "td/telegram/DialogNotificationSettings.h"
#include "td/telegram/ForumTopicInfo.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
@ -17,10 +16,10 @@
namespace td {
class DraftMessage;
class ForumTopicInfo;
class Td;
class ForumTopic {
ForumTopicInfo info_;
bool is_short_ = false;
bool is_pinned_ = false;
bool is_hidden_ = false;
@ -38,15 +37,11 @@ class ForumTopic {
ForumTopic(Td *td, tl_object_ptr<telegram_api::ForumTopic> &&forum_topic_ptr);
bool is_empty() const {
return info_.is_empty();
bool is_short() const {
return is_short_;
}
MessageId get_top_thread_message_id() const {
return info_.get_top_thread_message_id();
}
td_api::object_ptr<td_api::forumTopic> get_forum_topic_object(Td *td) const;
td_api::object_ptr<td_api::forumTopic> get_forum_topic_object(Td *td, const ForumTopicInfo &info) const;
};
} // namespace td