Add MessageInputReplyTo storer/parser.
This commit is contained in:
parent
a213820013
commit
017d1a531d
@ -867,6 +867,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/MediaAreaCoordinates.hpp
|
||||
td/telegram/MessageEntity.hpp
|
||||
td/telegram/MessageExtendedMedia.hpp
|
||||
td/telegram/MessageInputReplyTo.hpp
|
||||
td/telegram/MessageOrigin.hpp
|
||||
td/telegram/MessageReaction.hpp
|
||||
td/telegram/MessageReplyInfo.hpp
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/StoryId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
@ -66,6 +67,28 @@ telegram_api::object_ptr<telegram_api::InputReplyTo> MessageInputReplyTo::get_in
|
||||
nullptr, string(), Auto());
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::InputMessageReplyTo> MessageInputReplyTo::get_input_message_reply_to_object(
|
||||
Td *td, DialogId dialog_id) const {
|
||||
CHECK(dialog_id.is_valid());
|
||||
if (story_full_id_.is_valid()) {
|
||||
return td_api::make_object<td_api::inputMessageReplyToStory>(
|
||||
td->messages_manager_->get_chat_id_object(story_full_id_.get_dialog_id(), "inputMessageReplyToStory"),
|
||||
story_full_id_.get_story_id().get());
|
||||
}
|
||||
if (!message_id_.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::inputMessageReplyToMessage>(message_id_.get());
|
||||
}
|
||||
|
||||
bool operator==(const MessageInputReplyTo &lhs, const MessageInputReplyTo &rhs) {
|
||||
return lhs.message_id_ == rhs.message_id_ && lhs.story_full_id_ == rhs.story_full_id_;
|
||||
}
|
||||
|
||||
bool operator!=(const MessageInputReplyTo &lhs, const MessageInputReplyTo &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageInputReplyTo &input_reply_to) {
|
||||
if (input_reply_to.message_id_.is_valid()) {
|
||||
return string_builder << input_reply_to.message_id_;
|
||||
|
@ -23,9 +23,7 @@ struct MessageInputReplyTo {
|
||||
// or
|
||||
StoryFullId story_full_id_;
|
||||
|
||||
bool is_valid() const {
|
||||
return message_id_.is_valid() || story_full_id_.is_valid();
|
||||
}
|
||||
friend bool operator==(const MessageInputReplyTo &lhs, const MessageInputReplyTo &rhs);
|
||||
|
||||
MessageInputReplyTo() = default;
|
||||
|
||||
@ -35,10 +33,30 @@ struct MessageInputReplyTo {
|
||||
explicit MessageInputReplyTo(StoryFullId story_full_id) : story_full_id_(story_full_id) {
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
return !message_id_.is_valid() && !story_full_id_.is_valid();
|
||||
}
|
||||
|
||||
bool is_valid() const {
|
||||
return !is_empty();
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::InputReplyTo> get_input_reply_to(Td *td,
|
||||
MessageId top_thread_message_id) const;
|
||||
|
||||
td_api::object_ptr<td_api::InputMessageReplyTo> get_input_message_reply_to_object(Td *td, DialogId dialog_id) const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser);
|
||||
};
|
||||
|
||||
bool operator==(const MessageInputReplyTo &lhs, const MessageInputReplyTo &rhs);
|
||||
|
||||
bool operator!=(const MessageInputReplyTo &lhs, const MessageInputReplyTo &rhs);
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageInputReplyTo &input_reply_to);
|
||||
|
||||
} // namespace td
|
||||
|
49
td/telegram/MessageInputReplyTo.hpp
Normal file
49
td/telegram/MessageInputReplyTo.hpp
Normal file
@ -0,0 +1,49 @@
|
||||
//
|
||||
// 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/MessageInputReplyTo.h"
|
||||
|
||||
#include "td/telegram/MessageOrigin.hpp"
|
||||
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void MessageInputReplyTo::store(StorerT &storer) const {
|
||||
bool has_message_id = message_id_.is_valid();
|
||||
bool has_story_full_id = story_full_id_.is_valid();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_message_id);
|
||||
STORE_FLAG(has_story_full_id);
|
||||
END_STORE_FLAGS();
|
||||
if (has_message_id) {
|
||||
td::store(message_id_, storer);
|
||||
}
|
||||
if (has_story_full_id) {
|
||||
td::store(story_full_id_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void MessageInputReplyTo::parse(ParserT &parser) {
|
||||
bool has_message_id = message_id_.is_valid();
|
||||
bool has_story_full_id = story_full_id_.is_valid();
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_message_id);
|
||||
PARSE_FLAG(has_story_full_id);
|
||||
END_PARSE_FLAGS();
|
||||
if (has_message_id) {
|
||||
td::parse(message_id_, parser);
|
||||
}
|
||||
if (has_story_full_id) {
|
||||
td::parse(story_full_id_, parser);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
@ -46,6 +46,11 @@ class MessageOrigin {
|
||||
static Result<MessageOrigin> get_message_origin(
|
||||
Td *td, telegram_api::object_ptr<telegram_api::messageFwdHeader> &&forward_header);
|
||||
|
||||
bool is_empty() const {
|
||||
return !sender_user_id_.is_valid() && !sender_dialog_id_.is_valid() && !message_id_.is_valid() &&
|
||||
author_signature_.empty() && sender_name_.empty();
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::MessageForwardOrigin> get_message_forward_origin_object(const Td *td) const;
|
||||
|
||||
bool is_sender_hidden() const;
|
||||
|
Loading…
Reference in New Issue
Block a user