2018-09-29 01:45:43 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2018-09-29 01:45:43 +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/DraftMessage.h"
|
|
|
|
|
|
|
|
#include "td/telegram/InputMessageText.hpp"
|
2023-10-25 01:07:37 +02:00
|
|
|
#include "td/telegram/MessageInputReplyTo.hpp"
|
2024-04-25 14:52:19 +02:00
|
|
|
#include "td/telegram/MessageQuote.h"
|
2023-10-30 16:52:49 +01:00
|
|
|
#include "td/telegram/Version.h"
|
2018-09-29 01:45:43 +02:00
|
|
|
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
template <class StorerT>
|
2023-05-31 16:46:06 +02:00
|
|
|
void DraftMessage::store(StorerT &storer) const {
|
2023-10-25 01:07:37 +02:00
|
|
|
bool has_input_message_text = !input_message_text_.is_empty();
|
2024-01-30 14:59:14 +01:00
|
|
|
bool has_message_input_reply_to = !message_input_reply_to_.is_empty();
|
|
|
|
bool has_local_content = local_content_ != nullptr;
|
2024-06-05 15:31:57 +02:00
|
|
|
bool has_message_effect_id = message_effect_id_ != 0;
|
2023-10-25 01:07:37 +02:00
|
|
|
BEGIN_STORE_FLAGS();
|
|
|
|
STORE_FLAG(has_input_message_text);
|
|
|
|
STORE_FLAG(has_message_input_reply_to);
|
2024-01-30 14:59:14 +01:00
|
|
|
STORE_FLAG(has_local_content);
|
2024-06-05 15:31:57 +02:00
|
|
|
STORE_FLAG(has_message_effect_id);
|
2023-10-25 01:07:37 +02:00
|
|
|
END_STORE_FLAGS();
|
2023-05-31 16:46:06 +02:00
|
|
|
td::store(date_, storer);
|
2023-10-25 01:07:37 +02:00
|
|
|
if (has_input_message_text) {
|
|
|
|
td::store(input_message_text_, storer);
|
|
|
|
}
|
|
|
|
if (has_message_input_reply_to) {
|
|
|
|
td::store(message_input_reply_to_, storer);
|
|
|
|
}
|
2024-01-30 14:59:14 +01:00
|
|
|
if (has_local_content) {
|
|
|
|
store_draft_message_content(local_content_.get(), storer);
|
|
|
|
}
|
2024-06-05 15:31:57 +02:00
|
|
|
if (has_message_effect_id) {
|
|
|
|
td::store(message_effect_id_, storer);
|
|
|
|
}
|
2018-09-29 01:45:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
2023-05-31 16:46:06 +02:00
|
|
|
void DraftMessage::parse(ParserT &parser) {
|
2023-10-30 16:52:49 +01:00
|
|
|
bool has_legacy_reply_to_message_id;
|
2024-02-07 15:50:57 +01:00
|
|
|
bool has_input_message_text;
|
2024-01-30 14:59:14 +01:00
|
|
|
bool has_message_input_reply_to = false;
|
|
|
|
bool has_local_content = false;
|
2024-06-05 15:31:57 +02:00
|
|
|
bool has_message_effect_id = false;
|
2023-10-25 01:07:37 +02:00
|
|
|
if (parser.version() >= static_cast<int32>(Version::SupportRepliesInOtherChats)) {
|
2023-10-30 16:52:49 +01:00
|
|
|
has_legacy_reply_to_message_id = false;
|
2023-10-25 01:07:37 +02:00
|
|
|
BEGIN_PARSE_FLAGS();
|
|
|
|
PARSE_FLAG(has_input_message_text);
|
|
|
|
PARSE_FLAG(has_message_input_reply_to);
|
2024-01-30 14:59:14 +01:00
|
|
|
PARSE_FLAG(has_local_content);
|
2024-06-05 15:31:57 +02:00
|
|
|
PARSE_FLAG(has_message_effect_id);
|
2023-10-25 01:07:37 +02:00
|
|
|
END_PARSE_FLAGS();
|
|
|
|
} else {
|
|
|
|
has_legacy_reply_to_message_id = true;
|
2024-02-07 15:50:57 +01:00
|
|
|
has_input_message_text = true;
|
2023-10-25 01:07:37 +02:00
|
|
|
}
|
2023-05-31 16:46:06 +02:00
|
|
|
td::parse(date_, parser);
|
2023-10-25 01:07:37 +02:00
|
|
|
if (has_legacy_reply_to_message_id) {
|
|
|
|
MessageId legacy_reply_to_message_id;
|
|
|
|
td::parse(legacy_reply_to_message_id, parser);
|
2024-04-25 14:52:19 +02:00
|
|
|
message_input_reply_to_ = MessageInputReplyTo{legacy_reply_to_message_id, DialogId(), MessageQuote()};
|
2023-10-25 01:07:37 +02:00
|
|
|
}
|
|
|
|
if (has_input_message_text) {
|
|
|
|
td::parse(input_message_text_, parser);
|
|
|
|
}
|
|
|
|
if (has_message_input_reply_to) {
|
|
|
|
td::parse(message_input_reply_to_, parser);
|
|
|
|
}
|
2024-01-30 14:59:14 +01:00
|
|
|
if (has_local_content) {
|
|
|
|
parse_draft_message_content(local_content_, parser);
|
|
|
|
}
|
2024-06-05 15:31:57 +02:00
|
|
|
if (has_message_effect_id) {
|
|
|
|
td::parse(message_effect_id_, parser);
|
|
|
|
}
|
2018-09-29 01:45:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|