diff --git a/CMakeLists.txt b/CMakeLists.txt index a3ed1d6bf..533b6f838 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -675,6 +675,8 @@ set(TDLIB_SOURCE td/telegram/Game.hpp td/telegram/InputMessageText.hpp td/telegram/MessageEntity.hpp + td/telegram/MessageReplyInfo.hpp + td/telegram/MinChannel.hpp td/telegram/NotificationSettings.hpp td/telegram/Payments.hpp td/telegram/Photo.hpp diff --git a/td/telegram/MessageReplyInfo.h b/td/telegram/MessageReplyInfo.h index be08cb171..62d572d32 100644 --- a/td/telegram/MessageReplyInfo.h +++ b/td/telegram/MessageReplyInfo.h @@ -15,7 +15,6 @@ #include "td/utils/common.h" #include "td/utils/StringBuilder.h" -#include "td/utils/tl_helpers.h" #include @@ -58,90 +57,10 @@ struct MessageReplyInfo { td_api::object_ptr get_message_reply_info_object(Td *td) const; template - void store(StorerT &storer) const { - CHECK(!is_empty()); - bool has_recent_replier_dialog_ids = !recent_replier_dialog_ids.empty(); - bool has_channel_id = channel_id.is_valid(); - bool has_max_message_id = max_message_id.is_valid(); - bool has_last_read_inbox_message_id = last_read_inbox_message_id.is_valid(); - bool has_last_read_outbox_message_id = last_read_outbox_message_id.is_valid(); - bool has_replier_min_channels = !replier_min_channels.empty(); - BEGIN_STORE_FLAGS(); - STORE_FLAG(is_comment); - STORE_FLAG(has_recent_replier_dialog_ids); - STORE_FLAG(has_channel_id); - STORE_FLAG(has_max_message_id); - STORE_FLAG(has_last_read_inbox_message_id); - STORE_FLAG(has_last_read_outbox_message_id); - STORE_FLAG(has_replier_min_channels); - END_STORE_FLAGS(); - td::store(reply_count, storer); - td::store(pts, storer); - if (has_recent_replier_dialog_ids) { - td::store(recent_replier_dialog_ids, storer); - } - if (has_channel_id) { - td::store(channel_id, storer); - } - if (has_max_message_id) { - td::store(max_message_id, storer); - } - if (has_last_read_inbox_message_id) { - td::store(last_read_inbox_message_id, storer); - } - if (has_last_read_outbox_message_id) { - td::store(last_read_outbox_message_id, storer); - } - if (has_replier_min_channels) { - td::store(replier_min_channels, storer); - } - } + void store(StorerT &storer) const; template - void parse(ParserT &parser) { - bool has_recent_replier_dialog_ids; - bool has_channel_id; - bool has_max_message_id; - bool has_last_read_inbox_message_id; - bool has_last_read_outbox_message_id; - bool has_replier_min_channels; - BEGIN_PARSE_FLAGS(); - PARSE_FLAG(is_comment); - PARSE_FLAG(has_recent_replier_dialog_ids); - PARSE_FLAG(has_channel_id); - PARSE_FLAG(has_max_message_id); - PARSE_FLAG(has_last_read_inbox_message_id); - PARSE_FLAG(has_last_read_outbox_message_id); - PARSE_FLAG(has_replier_min_channels); - END_PARSE_FLAGS(); - td::parse(reply_count, parser); - td::parse(pts, parser); - if (has_recent_replier_dialog_ids) { - td::parse(recent_replier_dialog_ids, parser); - } - if (has_channel_id) { - td::parse(channel_id, parser); - } - if (has_max_message_id) { - td::parse(max_message_id, parser); - } - if (has_last_read_inbox_message_id) { - td::parse(last_read_inbox_message_id, parser); - } - if (has_last_read_outbox_message_id) { - td::parse(last_read_outbox_message_id, parser); - } - if (has_replier_min_channels) { - td::parse(replier_min_channels, parser); - } - - if (channel_id.get() == 777) { - *this = MessageReplyInfo(); - } - if (recent_replier_dialog_ids.size() > MAX_RECENT_REPLIERS) { - recent_replier_dialog_ids.resize(MAX_RECENT_REPLIERS); - } - } + void parse(ParserT &parser); }; StringBuilder &operator<<(StringBuilder &string_builder, const MessageReplyInfo &reply_info); diff --git a/td/telegram/MessageReplyInfo.hpp b/td/telegram/MessageReplyInfo.hpp new file mode 100644 index 000000000..52ff45432 --- /dev/null +++ b/td/telegram/MessageReplyInfo.hpp @@ -0,0 +1,103 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021 +// +// 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/MessageReplyInfo.h" +#include "td/telegram/MinChannel.hpp" + +#include "td/utils/common.h" +#include "td/utils/tl_helpers.h" + +namespace td { + +template +void MessageReplyInfo::store(StorerT &storer) const { + CHECK(!is_empty()); + bool has_recent_replier_dialog_ids = !recent_replier_dialog_ids.empty(); + bool has_channel_id = channel_id.is_valid(); + bool has_max_message_id = max_message_id.is_valid(); + bool has_last_read_inbox_message_id = last_read_inbox_message_id.is_valid(); + bool has_last_read_outbox_message_id = last_read_outbox_message_id.is_valid(); + bool has_replier_min_channels = !replier_min_channels.empty(); + BEGIN_STORE_FLAGS(); + STORE_FLAG(is_comment); + STORE_FLAG(has_recent_replier_dialog_ids); + STORE_FLAG(has_channel_id); + STORE_FLAG(has_max_message_id); + STORE_FLAG(has_last_read_inbox_message_id); + STORE_FLAG(has_last_read_outbox_message_id); + STORE_FLAG(has_replier_min_channels); + END_STORE_FLAGS(); + td::store(reply_count, storer); + td::store(pts, storer); + if (has_recent_replier_dialog_ids) { + td::store(recent_replier_dialog_ids, storer); + } + if (has_channel_id) { + td::store(channel_id, storer); + } + if (has_max_message_id) { + td::store(max_message_id, storer); + } + if (has_last_read_inbox_message_id) { + td::store(last_read_inbox_message_id, storer); + } + if (has_last_read_outbox_message_id) { + td::store(last_read_outbox_message_id, storer); + } + if (has_replier_min_channels) { + td::store(replier_min_channels, storer); + } +} + +template +void MessageReplyInfo::parse(ParserT &parser) { + bool has_recent_replier_dialog_ids; + bool has_channel_id; + bool has_max_message_id; + bool has_last_read_inbox_message_id; + bool has_last_read_outbox_message_id; + bool has_replier_min_channels; + BEGIN_PARSE_FLAGS(); + PARSE_FLAG(is_comment); + PARSE_FLAG(has_recent_replier_dialog_ids); + PARSE_FLAG(has_channel_id); + PARSE_FLAG(has_max_message_id); + PARSE_FLAG(has_last_read_inbox_message_id); + PARSE_FLAG(has_last_read_outbox_message_id); + PARSE_FLAG(has_replier_min_channels); + END_PARSE_FLAGS(); + td::parse(reply_count, parser); + td::parse(pts, parser); + if (has_recent_replier_dialog_ids) { + td::parse(recent_replier_dialog_ids, parser); + } + if (has_channel_id) { + td::parse(channel_id, parser); + } + if (has_max_message_id) { + td::parse(max_message_id, parser); + } + if (has_last_read_inbox_message_id) { + td::parse(last_read_inbox_message_id, parser); + } + if (has_last_read_outbox_message_id) { + td::parse(last_read_outbox_message_id, parser); + } + if (has_replier_min_channels) { + td::parse(replier_min_channels, parser); + } + + if (channel_id.get() == 777) { + *this = MessageReplyInfo(); + } + if (recent_replier_dialog_ids.size() > MAX_RECENT_REPLIERS) { + recent_replier_dialog_ids.resize(MAX_RECENT_REPLIERS); + } +} + +} // namespace td \ No newline at end of file diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index f52093458..fa0af5436 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -33,6 +33,7 @@ #include "td/telegram/MessageContent.h" #include "td/telegram/MessageEntity.h" #include "td/telegram/MessageEntity.hpp" +#include "td/telegram/MessageReplyInfo.hpp" #include "td/telegram/MessagesDb.h" #include "td/telegram/MessageSender.h" #include "td/telegram/MinChannel.h" diff --git a/td/telegram/MinChannel.h b/td/telegram/MinChannel.h index 459d29c2a..6b953d0db 100644 --- a/td/telegram/MinChannel.h +++ b/td/telegram/MinChannel.h @@ -7,10 +7,8 @@ #pragma once #include "td/telegram/Photo.h" -#include "td/telegram/Photo.hpp" #include "td/utils/common.h" -#include "td/utils/tl_helpers.h" namespace td { @@ -18,42 +16,6 @@ struct MinChannel { string title_; DialogPhoto photo_; bool is_megagroup_ = false; - - template - void store(StorerT &storer) const { - using td::store; - bool has_title = !title_.empty(); - bool has_photo = photo_.small_file_id.is_valid(); - BEGIN_STORE_FLAGS(); - STORE_FLAG(has_title); - STORE_FLAG(has_photo); - STORE_FLAG(is_megagroup_); - END_STORE_FLAGS(); - if (has_title) { - store(title_, storer); - } - if (has_photo) { - store(photo_, storer); - } - } - - template - void parse(ParserT &parser) { - using td::parse; - bool has_title; - bool has_photo; - BEGIN_PARSE_FLAGS(); - PARSE_FLAG(has_title); - PARSE_FLAG(has_photo); - PARSE_FLAG(is_megagroup_); - END_PARSE_FLAGS(); - if (has_title) { - parse(title_, parser); - } - if (has_photo) { - parse(photo_, parser); - } - } }; } // namespace td diff --git a/td/telegram/MinChannel.hpp b/td/telegram/MinChannel.hpp new file mode 100644 index 000000000..6d224ae5d --- /dev/null +++ b/td/telegram/MinChannel.hpp @@ -0,0 +1,51 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021 +// +// 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/MinChannel.h" +#include "td/telegram/Photo.hpp" + +#include "td/utils/common.h" +#include "td/utils/tl_helpers.h" + +namespace td { + +template +void store(const MinChannel &min_channel, StorerT &storer) { + bool has_title = !min_channel.title_.empty(); + bool has_photo = min_channel.photo_.small_file_id.is_valid(); + BEGIN_STORE_FLAGS(); + STORE_FLAG(has_title); + STORE_FLAG(has_photo); + STORE_FLAG(min_channel.is_megagroup_); + END_STORE_FLAGS(); + if (has_title) { + store(min_channel.title_, storer); + } + if (has_photo) { + store(min_channel.photo_, storer); + } +} + +template +void parse(MinChannel &min_channel, ParserT &parser) { + bool has_title; + bool has_photo; + BEGIN_PARSE_FLAGS(); + PARSE_FLAG(has_title); + PARSE_FLAG(has_photo); + PARSE_FLAG(min_channel.is_megagroup_); + END_PARSE_FLAGS(); + if (has_title) { + parse(min_channel.title_, parser); + } + if (has_photo) { + parse(min_channel.photo_, parser); + } +} + +} // namespace td