2021-12-22 18:29:54 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2021-12-22 18:29:54 +01:00
|
|
|
//
|
|
|
|
// 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 <class StorerT>
|
|
|
|
void MessageReplyInfo::store(StorerT &storer) const {
|
|
|
|
CHECK(!is_empty());
|
2022-11-21 16:35:28 +01:00
|
|
|
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();
|
2021-12-22 18:29:54 +01:00
|
|
|
BEGIN_STORE_FLAGS();
|
2022-11-21 16:35:28 +01:00
|
|
|
STORE_FLAG(is_comment_);
|
2021-12-22 18:29:54 +01:00
|
|
|
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();
|
2022-11-21 16:35:28 +01:00
|
|
|
td::store(reply_count_, storer);
|
|
|
|
td::store(pts_, storer);
|
2021-12-22 18:29:54 +01:00
|
|
|
if (has_recent_replier_dialog_ids) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::store(recent_replier_dialog_ids_, storer);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_channel_id) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::store(channel_id_, storer);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_max_message_id) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::store(max_message_id_, storer);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_last_read_inbox_message_id) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::store(last_read_inbox_message_id_, storer);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_last_read_outbox_message_id) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::store(last_read_outbox_message_id_, storer);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_replier_min_channels) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::store(replier_min_channels_, storer);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
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();
|
2022-11-21 16:35:28 +01:00
|
|
|
PARSE_FLAG(is_comment_);
|
2021-12-22 18:29:54 +01:00
|
|
|
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();
|
2022-11-21 16:35:28 +01:00
|
|
|
td::parse(reply_count_, parser);
|
|
|
|
td::parse(pts_, parser);
|
2021-12-22 18:29:54 +01:00
|
|
|
if (has_recent_replier_dialog_ids) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::parse(recent_replier_dialog_ids_, parser);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_channel_id) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::parse(channel_id_, parser);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_max_message_id) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::parse(max_message_id_, parser);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_last_read_inbox_message_id) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::parse(last_read_inbox_message_id_, parser);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_last_read_outbox_message_id) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::parse(last_read_outbox_message_id_, parser);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
if (has_replier_min_channels) {
|
2022-11-21 16:35:28 +01:00
|
|
|
td::parse(replier_min_channels_, parser);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
|
2022-11-21 16:35:28 +01:00
|
|
|
if (channel_id_.get() == 777) {
|
2021-12-22 18:29:54 +01:00
|
|
|
*this = MessageReplyInfo();
|
2022-11-21 16:35:28 +01:00
|
|
|
is_dropped_ = true;
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
2022-11-21 16:35:28 +01:00
|
|
|
if (recent_replier_dialog_ids_.size() > MAX_RECENT_REPLIERS) {
|
|
|
|
recent_replier_dialog_ids_.resize(MAX_RECENT_REPLIERS);
|
2021-12-22 18:29:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-27 12:03:50 +01:00
|
|
|
} // namespace td
|