2023-10-24 13:06:49 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2023-10-24 13:06:49 +02: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/RepliedMessageInfo.h"
|
|
|
|
|
2023-10-26 21:53:25 +02:00
|
|
|
#include "td/telegram/MessageContent.h"
|
2023-10-26 14:52:42 +02:00
|
|
|
#include "td/telegram/MessageEntity.hpp"
|
2023-10-24 13:06:49 +02:00
|
|
|
#include "td/telegram/MessageOrigin.hpp"
|
|
|
|
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void RepliedMessageInfo::store(StorerT &storer) const {
|
2023-10-24 15:34:54 +02:00
|
|
|
bool has_message_id = message_id_.is_valid() || message_id_.is_valid_scheduled();
|
|
|
|
bool has_dialog_id = dialog_id_.is_valid();
|
|
|
|
bool has_origin_date = origin_date_ != 0;
|
|
|
|
bool has_origin = !origin_.is_empty();
|
2023-10-26 21:53:25 +02:00
|
|
|
bool has_content = content_ != nullptr;
|
2024-04-25 14:52:19 +02:00
|
|
|
bool has_quote = !quote_.is_empty();
|
2023-10-24 13:06:49 +02:00
|
|
|
BEGIN_STORE_FLAGS();
|
2023-10-24 15:34:54 +02:00
|
|
|
STORE_FLAG(has_message_id);
|
|
|
|
STORE_FLAG(has_dialog_id);
|
|
|
|
STORE_FLAG(has_origin_date);
|
|
|
|
STORE_FLAG(has_origin);
|
2024-04-25 14:52:19 +02:00
|
|
|
STORE_FLAG(false);
|
|
|
|
STORE_FLAG(false);
|
2023-10-26 21:53:25 +02:00
|
|
|
STORE_FLAG(has_content);
|
2024-04-25 14:52:19 +02:00
|
|
|
STORE_FLAG(false);
|
|
|
|
STORE_FLAG(has_quote);
|
2023-10-24 13:06:49 +02:00
|
|
|
END_STORE_FLAGS();
|
2023-10-24 15:34:54 +02:00
|
|
|
if (has_message_id) {
|
|
|
|
td::store(message_id_, storer);
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
2023-10-24 15:34:54 +02:00
|
|
|
if (has_dialog_id) {
|
|
|
|
td::store(dialog_id_, storer);
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
2023-10-24 15:34:54 +02:00
|
|
|
if (has_origin_date) {
|
|
|
|
td::store(origin_date_, storer);
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
2023-10-24 15:34:54 +02:00
|
|
|
if (has_origin) {
|
|
|
|
td::store(origin_, storer);
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
2023-10-26 21:53:25 +02:00
|
|
|
if (has_content) {
|
|
|
|
store_message_content(content_.get(), storer);
|
|
|
|
}
|
2024-04-25 14:52:19 +02:00
|
|
|
if (has_quote) {
|
|
|
|
td::store(quote_, storer);
|
2023-11-10 11:29:37 +01:00
|
|
|
}
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void RepliedMessageInfo::parse(ParserT &parser) {
|
2023-10-24 15:34:54 +02:00
|
|
|
bool has_message_id;
|
|
|
|
bool has_dialog_id;
|
|
|
|
bool has_origin_date;
|
|
|
|
bool has_origin;
|
2024-04-25 14:52:19 +02:00
|
|
|
bool has_quote_legacy;
|
|
|
|
bool is_quote_manual_legacy;
|
2023-10-26 21:53:25 +02:00
|
|
|
bool has_content;
|
2024-04-25 14:52:19 +02:00
|
|
|
bool has_quote_position_legacy;
|
|
|
|
bool has_quote;
|
2023-10-24 13:06:49 +02:00
|
|
|
BEGIN_PARSE_FLAGS();
|
2023-10-24 15:34:54 +02:00
|
|
|
PARSE_FLAG(has_message_id);
|
|
|
|
PARSE_FLAG(has_dialog_id);
|
|
|
|
PARSE_FLAG(has_origin_date);
|
|
|
|
PARSE_FLAG(has_origin);
|
2024-04-25 14:52:19 +02:00
|
|
|
PARSE_FLAG(has_quote_legacy);
|
|
|
|
PARSE_FLAG(is_quote_manual_legacy);
|
2023-10-26 21:53:25 +02:00
|
|
|
PARSE_FLAG(has_content);
|
2024-04-25 14:52:19 +02:00
|
|
|
PARSE_FLAG(has_quote_position_legacy);
|
|
|
|
PARSE_FLAG(has_quote);
|
2023-10-24 13:06:49 +02:00
|
|
|
END_PARSE_FLAGS();
|
2023-10-24 15:34:54 +02:00
|
|
|
if (has_message_id) {
|
|
|
|
td::parse(message_id_, parser);
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
2023-10-24 15:34:54 +02:00
|
|
|
if (has_dialog_id) {
|
|
|
|
td::parse(dialog_id_, parser);
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
2023-10-24 15:34:54 +02:00
|
|
|
if (has_origin_date) {
|
|
|
|
td::parse(origin_date_, parser);
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
2023-10-24 15:34:54 +02:00
|
|
|
if (has_origin) {
|
|
|
|
td::parse(origin_, parser);
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
2024-04-25 14:52:19 +02:00
|
|
|
FormattedText quote_legacy;
|
|
|
|
if (has_quote_legacy) {
|
|
|
|
td::parse(quote_legacy, parser);
|
2023-10-26 14:52:42 +02:00
|
|
|
}
|
2023-10-26 21:53:25 +02:00
|
|
|
if (has_content) {
|
|
|
|
parse_message_content(content_, parser);
|
|
|
|
}
|
2024-04-25 14:52:19 +02:00
|
|
|
int32 quote_position_legacy = 0;
|
|
|
|
if (has_quote_position_legacy) {
|
|
|
|
td::parse(quote_position_legacy, parser);
|
|
|
|
}
|
|
|
|
if (has_quote) {
|
|
|
|
td::parse(quote_, parser);
|
|
|
|
} else if (has_quote_legacy) {
|
|
|
|
quote_ = MessageQuote(std::move(quote_legacy), quote_position_legacy, is_quote_manual_legacy);
|
2023-11-10 11:29:37 +01:00
|
|
|
}
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|