Add class ForumTopic.
This commit is contained in:
parent
cacdedc8d7
commit
9edfdcfd1e
@ -352,6 +352,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/files/FileUploader.cpp
|
td/telegram/files/FileUploader.cpp
|
||||||
td/telegram/files/PartsManager.cpp
|
td/telegram/files/PartsManager.cpp
|
||||||
td/telegram/files/ResourceManager.cpp
|
td/telegram/files/ResourceManager.cpp
|
||||||
|
td/telegram/ForumTopic.cpp
|
||||||
td/telegram/ForumTopicEditedData.cpp
|
td/telegram/ForumTopicEditedData.cpp
|
||||||
td/telegram/ForumTopicIcon.cpp
|
td/telegram/ForumTopicIcon.cpp
|
||||||
td/telegram/ForumTopicInfo.cpp
|
td/telegram/ForumTopicInfo.cpp
|
||||||
@ -583,6 +584,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/files/ResourceManager.h
|
td/telegram/files/ResourceManager.h
|
||||||
td/telegram/files/ResourceState.h
|
td/telegram/files/ResourceState.h
|
||||||
td/telegram/FolderId.h
|
td/telegram/FolderId.h
|
||||||
|
td/telegram/ForumTopic.h
|
||||||
td/telegram/ForumTopicEditedData.h
|
td/telegram/ForumTopicEditedData.h
|
||||||
td/telegram/ForumTopicIcon.h
|
td/telegram/ForumTopicIcon.h
|
||||||
td/telegram/ForumTopicInfo.h
|
td/telegram/ForumTopicInfo.h
|
||||||
|
@ -1316,7 +1316,7 @@ forumTopicEditedData title:string edit_icon_custom_emoji_id:Bool icon_custom_emo
|
|||||||
forumTopicIcon color:int32 custom_emoji_id:int64 = ForumTopicIcon;
|
forumTopicIcon color:int32 custom_emoji_id:int64 = ForumTopicIcon;
|
||||||
|
|
||||||
//@description Contains basic information about a forum topic
|
//@description Contains basic information about a forum topic
|
||||||
//@message_thread_id Thread identifier of the topic
|
//@message_thread_id Message thread identifier of the topic
|
||||||
//@title Title of the topic
|
//@title Title of the topic
|
||||||
//@icon Icon of the topic
|
//@icon Icon of the topic
|
||||||
//@creation_date Date the topic was created
|
//@creation_date Date the topic was created
|
||||||
@ -1325,6 +1325,19 @@ forumTopicIcon color:int32 custom_emoji_id:int64 = ForumTopicIcon;
|
|||||||
//@is_closed True, if the topic is closed
|
//@is_closed True, if the topic is closed
|
||||||
forumTopicInfo message_thread_id:int53 title:string icon:forumTopicIcon creation_date:int32 creator_id:MessageSender is_outgoing:Bool is_closed:Bool = ForumTopicInfo;
|
forumTopicInfo message_thread_id:int53 title:string icon:forumTopicIcon creation_date:int32 creator_id:MessageSender is_outgoing:Bool is_closed:Bool = ForumTopicInfo;
|
||||||
|
|
||||||
|
//@description Describes a forum topic
|
||||||
|
//@info Basic information about the topic
|
||||||
|
//@last_message Last message in the topic; may be null
|
||||||
|
//@is_pinned True, if the topic is pinned in the topic list
|
||||||
|
//@unread_count Number of unread messages in the topic
|
||||||
|
//@last_read_inbox_message_id Identifier of the last read incoming message
|
||||||
|
//@last_read_outbox_message_id Identifier of the last read outgoing message
|
||||||
|
//@unread_mention_count Number of unread messages with a mention/reply in the topic
|
||||||
|
//@unread_reaction_count Number of messages with unread reactions in the topic
|
||||||
|
//@notification_settings Notification settings for the topic
|
||||||
|
//@draft_message A draft of a message in the topic; may be null
|
||||||
|
forumTopic info:forumTopicInfo last_message:message is_pinned:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings draft_message:draftMessage = ForumTopic;
|
||||||
|
|
||||||
|
|
||||||
//@class RichText @description Describes a text object inside an instant-view web page
|
//@class RichText @description Describes a text object inside an instant-view web page
|
||||||
|
|
||||||
|
51
td/telegram/ForumTopic.cpp
Normal file
51
td/telegram/ForumTopic.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#include "td/telegram/ForumTopic.h"
|
||||||
|
|
||||||
|
#include "td/telegram/DraftMessage.h"
|
||||||
|
#include "td/telegram/Td.h"
|
||||||
|
|
||||||
|
#include "td/utils/logging.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
ForumTopic::ForumTopic(Td *td, tl_object_ptr<telegram_api::ForumTopic> &&forum_topic_ptr) {
|
||||||
|
CHECK(forum_topic_ptr != nullptr);
|
||||||
|
if (forum_topic_ptr->get_id() != telegram_api::forumTopic::ID) {
|
||||||
|
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());
|
||||||
|
|
||||||
|
last_message_id_ = MessageId(ServerMessageId(forum_topic->top_message_));
|
||||||
|
is_pinned_ = forum_topic->pinned_;
|
||||||
|
unread_count_ = forum_topic->unread_count_;
|
||||||
|
last_read_inbox_message_id_ = MessageId(ServerMessageId(forum_topic->read_inbox_max_id_));
|
||||||
|
last_read_outbox_message_id_ = MessageId(ServerMessageId(forum_topic->read_outbox_max_id_));
|
||||||
|
unread_mention_count_ = forum_topic->unread_mentions_count_;
|
||||||
|
unread_reaction_count_ = forum_topic->unread_reactions_count_;
|
||||||
|
notification_settings_ =
|
||||||
|
get_dialog_notification_settings(std::move(forum_topic->notify_settings_), false, false, false, false);
|
||||||
|
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()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO draft_message = can_send_message(dialog_id, info_.get_thread_id()).is_ok() ? ... : nullptr;
|
||||||
|
// 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(),
|
||||||
|
last_read_outbox_message_id_.get(), unread_mention_count_, unread_reaction_count_,
|
||||||
|
get_chat_notification_settings_object(¬ification_settings_), std::move(draft_message));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
50
td/telegram/ForumTopic.h
Normal file
50
td/telegram/ForumTopic.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#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"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
class DraftMessage;
|
||||||
|
class Td;
|
||||||
|
|
||||||
|
class ForumTopic {
|
||||||
|
ForumTopicInfo info_;
|
||||||
|
MessageId last_message_id_;
|
||||||
|
bool is_pinned_ = false;
|
||||||
|
int32 unread_count_ = 0;
|
||||||
|
MessageId last_read_inbox_message_id_;
|
||||||
|
MessageId last_read_outbox_message_id_;
|
||||||
|
int32 unread_mention_count_ = 0;
|
||||||
|
int32 unread_reaction_count_ = 0;
|
||||||
|
DialogNotificationSettings notification_settings_;
|
||||||
|
unique_ptr<DraftMessage> draft_message_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ForumTopic() = default;
|
||||||
|
|
||||||
|
ForumTopic(Td *td, tl_object_ptr<telegram_api::ForumTopic> &&forum_topic_ptr);
|
||||||
|
|
||||||
|
bool is_empty() const {
|
||||||
|
return info_.is_empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageId get_thread_id() const {
|
||||||
|
return info_.get_thread_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::forumTopic> get_forum_topic_object(Td *td) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace td
|
@ -19,7 +19,7 @@ ForumTopicInfo::ForumTopicInfo(const tl_object_ptr<telegram_api::ForumTopic> &fo
|
|||||||
LOG(ERROR) << "Receive " << to_string(forum_topic_ptr);
|
LOG(ERROR) << "Receive " << to_string(forum_topic_ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const telegram_api::forumTopic *forum_topic = static_cast<const telegram_api::forumTopic *>(forum_topic_ptr.get());
|
const auto *forum_topic = static_cast<const telegram_api::forumTopic *>(forum_topic_ptr.get());
|
||||||
|
|
||||||
top_thread_message_id_ = MessageId(ServerMessageId(forum_topic->id_));
|
top_thread_message_id_ = MessageId(ServerMessageId(forum_topic->id_));
|
||||||
title_ = forum_topic->title_;
|
title_ = forum_topic->title_;
|
||||||
|
@ -39,6 +39,10 @@ class ForumTopicInfo {
|
|||||||
return !top_thread_message_id_.is_valid();
|
return !top_thread_message_id_.is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageId get_thread_id() const {
|
||||||
|
return top_thread_message_id_;
|
||||||
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::forumTopicInfo> get_forum_topic_info_object(Td *td) const;
|
td_api::object_ptr<td_api::forumTopicInfo> get_forum_topic_info_object(Td *td) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user