Add RepliedMessageInfo parser and storer.
This commit is contained in:
parent
cb70dd7831
commit
a213820013
|
@ -881,6 +881,7 @@ set(TDLIB_SOURCE
|
|||
td/telegram/PremiumGiftOption.hpp
|
||||
td/telegram/ReactionManager.hpp
|
||||
td/telegram/ReactionType.hpp
|
||||
td/telegram/RepliedMessageInfo.hpp
|
||||
td/telegram/ReplyMarkup.hpp
|
||||
td/telegram/RequestedDialogType.hpp
|
||||
td/telegram/ScopeNotificationSettings.hpp
|
||||
|
|
|
@ -84,4 +84,13 @@ MessageFullId RepliedMessageInfo::get_reply_message_full_id() const {
|
|||
return {reply_in_dialog_id_, reply_to_message_id_};
|
||||
}
|
||||
|
||||
bool operator==(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs) {
|
||||
return lhs.reply_to_message_id_ == rhs.reply_to_message_id_ && lhs.reply_in_dialog_id_ == rhs.reply_in_dialog_id_ &&
|
||||
lhs.reply_date_ == rhs.reply_date_ && lhs.reply_origin_ == rhs.reply_origin_;
|
||||
}
|
||||
|
||||
bool operator!=(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
|
|
@ -24,6 +24,8 @@ class RepliedMessageInfo {
|
|||
int32 reply_date_ = 0; // for replies in other chats
|
||||
MessageOrigin reply_origin_; // for replies in other chats
|
||||
|
||||
friend bool operator==(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs);
|
||||
|
||||
RepliedMessageInfo() = default;
|
||||
|
||||
explicit RepliedMessageInfo(MessageId reply_to_message_id) : reply_to_message_id_(reply_to_message_id) {
|
||||
|
@ -36,9 +38,24 @@ class RepliedMessageInfo {
|
|||
return reply_in_dialog_id_ == DialogId() && reply_date_ == 0;
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
return reply_to_message_id_ == MessageId() && reply_in_dialog_id_ == DialogId() && reply_date_ == 0 &&
|
||||
reply_origin_.is_empty();
|
||||
}
|
||||
|
||||
MessageId get_same_chat_reply_to_message_id() const;
|
||||
|
||||
MessageFullId get_reply_message_full_id() const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser);
|
||||
};
|
||||
|
||||
bool operator==(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs);
|
||||
|
||||
bool operator!=(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs);
|
||||
|
||||
} // namespace td
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include "td/telegram/MessageOrigin.hpp"
|
||||
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void RepliedMessageInfo::store(StorerT &storer) const {
|
||||
bool has_reply_to_message_id = reply_to_message_id_.is_valid() || reply_to_message_id_.is_valid_scheduled();
|
||||
bool has_reply_in_dialog_id = reply_in_dialog_id_.is_valid();
|
||||
bool has_reply_date = reply_date_ != 0;
|
||||
bool has_reply_origin = !reply_origin_.is_empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_reply_to_message_id);
|
||||
STORE_FLAG(has_reply_in_dialog_id);
|
||||
STORE_FLAG(has_reply_date);
|
||||
STORE_FLAG(has_reply_origin);
|
||||
END_STORE_FLAGS();
|
||||
if (has_reply_to_message_id) {
|
||||
td::store(reply_to_message_id_, storer);
|
||||
}
|
||||
if (has_reply_in_dialog_id) {
|
||||
td::store(reply_in_dialog_id_, storer);
|
||||
}
|
||||
if (has_reply_date) {
|
||||
td::store(reply_date_, storer);
|
||||
}
|
||||
if (has_reply_origin) {
|
||||
td::store(reply_origin_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void RepliedMessageInfo::parse(ParserT &parser) {
|
||||
bool has_reply_to_message_id;
|
||||
bool has_reply_in_dialog_id;
|
||||
bool has_reply_date;
|
||||
bool has_reply_origin;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_reply_to_message_id);
|
||||
PARSE_FLAG(has_reply_in_dialog_id);
|
||||
PARSE_FLAG(has_reply_date);
|
||||
PARSE_FLAG(has_reply_origin);
|
||||
END_PARSE_FLAGS();
|
||||
if (has_reply_to_message_id) {
|
||||
td::parse(reply_to_message_id_, parser);
|
||||
}
|
||||
if (has_reply_in_dialog_id) {
|
||||
td::parse(reply_in_dialog_id_, parser);
|
||||
}
|
||||
if (has_reply_date) {
|
||||
td::parse(reply_date_, parser);
|
||||
}
|
||||
if (has_reply_origin) {
|
||||
td::parse(reply_origin_, parser);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
Loading…
Reference in New Issue