aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-06-23 23:04:28 +0300
committerlevlam <levlam@telegram.org>2026-06-23 23:04:28 +0300
commitf19946bcdb7be4891022ee0b3d55888ea4dde377 (patch)
treea5aa66104eb37972b8f5bee1ac5e4c33a30c4566
parentddb062e7e16e3cb3dd9427eb0b80523400c42488 (diff)
Add MessageTopic parser and storer.
-rw-r--r--CMakeLists.txt1
-rw-r--r--td/telegram/MessageTopic.h6
-rw-r--r--td/telegram/MessageTopic.hpp78
3 files changed, 85 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a64700e7..be75595fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1211,6 +1211,7 @@ set(TDLIB_SOURCE_PART2
td/telegram/MessageReaction.hpp
td/telegram/MessageReactor.hpp
td/telegram/MessageReplyInfo.hpp
+ td/telegram/MessageTopic.hpp
td/telegram/MinChannel.hpp
td/telegram/NotificationGroupInfo.hpp
td/telegram/OrderInfo.hpp
diff --git a/td/telegram/MessageTopic.h b/td/telegram/MessageTopic.h
index f59eecac8..bed7ef41b 100644
--- a/td/telegram/MessageTopic.h
+++ b/td/telegram/MessageTopic.h
@@ -123,6 +123,12 @@ class MessageTopic {
CHECK(saved_input_peer != nullptr);
return saved_input_peer;
}
+
+ template <class StorerT>
+ void store(StorerT &storer) const;
+
+ template <class ParserT>
+ void parse(ParserT &parser);
};
StringBuilder &operator<<(StringBuilder &string_builder, const MessageTopic &message_topic);
diff --git a/td/telegram/MessageTopic.hpp b/td/telegram/MessageTopic.hpp
new file mode 100644
index 000000000..6bc93c6e6
--- /dev/null
+++ b/td/telegram/MessageTopic.hpp
@@ -0,0 +1,78 @@
+//
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2025
+//
+// 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/MessageTopic.h"
+
+#include "td/utils/common.h"
+#include "td/utils/tl_helpers.h"
+
+namespace td {
+
+template <class StorerT>
+void MessageTopic::store(StorerT &storer) const {
+ bool has_type = type_ != Type::None;
+ bool has_dialog_id = dialog_id_.is_valid();
+ bool has_top_thread_message_id = top_thread_message_id_.is_valid();
+ bool has_forum_topic_id = forum_topic_id_.is_valid();
+ bool has_saved_messages_topic_id = saved_messages_topic_id_.is_valid();
+ BEGIN_STORE_FLAGS();
+ STORE_FLAG(has_type);
+ STORE_FLAG(has_dialog_id);
+ STORE_FLAG(has_top_thread_message_id);
+ STORE_FLAG(has_forum_topic_id);
+ STORE_FLAG(has_saved_messages_topic_id);
+ END_STORE_FLAGS();
+ if (has_type) {
+ td::store(type_, storer);
+ }
+ if (has_dialog_id) {
+ td::store(dialog_id_, storer);
+ }
+ if (has_top_thread_message_id) {
+ td::store(top_thread_message_id_, storer);
+ }
+ if (has_forum_topic_id) {
+ td::store(forum_topic_id_, storer);
+ }
+ if (has_saved_messages_topic_id) {
+ td::store(saved_messages_topic_id_, storer);
+ }
+}
+
+template <class ParserT>
+void MessageTopic::parse(ParserT &parser) {
+ bool has_type;
+ bool has_dialog_id;
+ bool has_top_thread_message_id;
+ bool has_forum_topic_id;
+ bool has_saved_messages_topic_id;
+ BEGIN_PARSE_FLAGS();
+ PARSE_FLAG(has_type);
+ PARSE_FLAG(has_dialog_id);
+ PARSE_FLAG(has_top_thread_message_id);
+ PARSE_FLAG(has_forum_topic_id);
+ PARSE_FLAG(has_saved_messages_topic_id);
+ END_PARSE_FLAGS();
+ if (has_type) {
+ td::parse(type_, parser);
+ }
+ if (has_dialog_id) {
+ td::parse(dialog_id_, parser);
+ }
+ if (has_top_thread_message_id) {
+ td::parse(top_thread_message_id_, parser);
+ }
+ if (has_forum_topic_id) {
+ td::parse(forum_topic_id_, parser);
+ }
+ if (has_saved_messages_topic_id) {
+ td::parse(saved_messages_topic_id_, parser);
+ }
+}
+
+} // namespace td