2023-10-24 11:04:45 +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 11:04:45 +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
|
|
|
|
|
2023-10-27 00:41:15 +02:00
|
|
|
#include "td/telegram/ChannelId.h"
|
2023-10-24 11:04:45 +02:00
|
|
|
#include "td/telegram/DialogId.h"
|
2023-10-30 17:04:14 +01:00
|
|
|
#include "td/telegram/files/FileId.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.h"
|
2023-10-27 00:41:15 +02:00
|
|
|
#include "td/telegram/MessageFullId.h"
|
2023-10-24 11:04:45 +02:00
|
|
|
#include "td/telegram/MessageId.h"
|
2023-10-25 16:37:28 +02:00
|
|
|
#include "td/telegram/MessageInputReplyTo.h"
|
2023-10-24 11:04:45 +02:00
|
|
|
#include "td/telegram/MessageOrigin.h"
|
2023-10-25 16:24:24 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
2023-10-24 11:04:45 +02:00
|
|
|
#include "td/telegram/telegram_api.h"
|
2023-10-27 00:41:15 +02:00
|
|
|
#include "td/telegram/UserId.h"
|
2023-10-24 11:04:45 +02:00
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2023-10-30 17:04:14 +01:00
|
|
|
#include "td/utils/StringBuilder.h"
|
2023-10-24 11:04:45 +02:00
|
|
|
|
2023-10-26 00:01:22 +02:00
|
|
|
#include <functional>
|
|
|
|
|
2023-10-24 11:04:45 +02:00
|
|
|
namespace td {
|
|
|
|
|
2023-10-25 16:44:24 +02:00
|
|
|
class Dependencies;
|
|
|
|
|
2023-10-24 11:04:45 +02:00
|
|
|
class Td;
|
|
|
|
|
|
|
|
class RepliedMessageInfo {
|
2023-10-24 15:34:54 +02:00
|
|
|
MessageId message_id_;
|
2023-10-29 12:25:42 +01:00
|
|
|
DialogId dialog_id_; // for replies from another known chats
|
2023-10-26 21:53:25 +02:00
|
|
|
int32 origin_date_ = 0; // for replies in other chats
|
|
|
|
MessageOrigin origin_; // for replies in other chats
|
|
|
|
unique_ptr<MessageContent> content_; // for replies in other chats
|
2023-10-26 14:52:42 +02:00
|
|
|
FormattedText quote_;
|
2023-11-10 11:29:37 +01:00
|
|
|
int32 quote_position_ = 0;
|
2023-10-26 14:52:42 +02:00
|
|
|
bool is_quote_manual_ = false;
|
2023-10-24 11:04:45 +02:00
|
|
|
|
2023-10-24 13:06:49 +02:00
|
|
|
friend bool operator==(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs);
|
|
|
|
|
2023-10-26 00:11:36 +02:00
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const RepliedMessageInfo &info);
|
|
|
|
|
2023-10-24 14:55:52 +02:00
|
|
|
public:
|
2023-10-24 11:04:45 +02:00
|
|
|
RepliedMessageInfo() = default;
|
2023-10-26 21:53:25 +02:00
|
|
|
RepliedMessageInfo(const RepliedMessageInfo &) = delete;
|
|
|
|
RepliedMessageInfo &operator=(const RepliedMessageInfo &) = delete;
|
|
|
|
RepliedMessageInfo(RepliedMessageInfo &&) = default;
|
|
|
|
RepliedMessageInfo &operator=(RepliedMessageInfo &&) = default;
|
|
|
|
~RepliedMessageInfo();
|
2023-10-24 11:04:45 +02:00
|
|
|
|
2023-11-06 16:29:47 +01:00
|
|
|
static RepliedMessageInfo legacy(MessageId reply_to_message_id, DialogId reply_in_dialog_id = DialogId()) {
|
|
|
|
RepliedMessageInfo result;
|
|
|
|
result.message_id_ = reply_to_message_id;
|
|
|
|
result.dialog_id_ = reply_in_dialog_id;
|
|
|
|
return result;
|
2023-10-25 16:24:24 +02:00
|
|
|
}
|
|
|
|
|
2023-10-24 11:04:45 +02:00
|
|
|
RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messageReplyHeader> &&reply_header, DialogId dialog_id,
|
|
|
|
MessageId message_id, int32 date);
|
|
|
|
|
2023-10-25 16:37:28 +02:00
|
|
|
RepliedMessageInfo(Td *td, const MessageInputReplyTo &input_reply_to);
|
|
|
|
|
2023-11-01 15:14:35 +01:00
|
|
|
RepliedMessageInfo clone(Td *td) const;
|
|
|
|
|
2023-10-24 13:06:49 +02:00
|
|
|
bool is_empty() const {
|
2023-11-05 19:51:46 +01:00
|
|
|
return message_id_ == MessageId() && origin_.is_empty();
|
2023-10-24 13:06:49 +02:00
|
|
|
}
|
|
|
|
|
2023-11-01 15:14:35 +01:00
|
|
|
bool is_external() const {
|
|
|
|
return origin_date_ != 0;
|
|
|
|
}
|
|
|
|
|
2023-10-26 22:16:06 +02:00
|
|
|
bool need_reget() const;
|
|
|
|
|
2023-10-26 00:01:22 +02:00
|
|
|
static bool need_reply_changed_warning(
|
2023-10-31 16:20:55 +01:00
|
|
|
const Td *td, const RepliedMessageInfo &old_info, const RepliedMessageInfo &new_info,
|
|
|
|
MessageId old_top_thread_message_id, bool is_yet_unsent,
|
|
|
|
std::function<bool(const RepliedMessageInfo &info)> is_reply_to_deleted_message);
|
2023-10-26 00:01:22 +02:00
|
|
|
|
2023-10-27 00:50:32 +02:00
|
|
|
vector<FileId> get_file_ids(Td *td) const;
|
|
|
|
|
2023-10-27 00:41:15 +02:00
|
|
|
vector<UserId> get_min_user_ids(Td *td) const;
|
|
|
|
|
|
|
|
vector<ChannelId> get_min_channel_ids(Td *td) const;
|
|
|
|
|
2023-10-26 21:53:25 +02:00
|
|
|
void add_dependencies(Dependencies &dependencies, bool is_bot) const;
|
2023-10-25 16:44:24 +02:00
|
|
|
|
2023-10-25 16:24:24 +02:00
|
|
|
td_api::object_ptr<td_api::messageReplyToMessage> get_message_reply_to_message_object(Td *td,
|
|
|
|
DialogId dialog_id) const;
|
|
|
|
|
2023-10-27 13:33:15 +02:00
|
|
|
MessageInputReplyTo get_input_reply_to() const;
|
|
|
|
|
2023-10-27 12:33:00 +02:00
|
|
|
void set_message_id(MessageId new_message_id) {
|
|
|
|
CHECK(message_id_.is_valid() || message_id_.is_valid_scheduled());
|
|
|
|
message_id_ = new_message_id;
|
|
|
|
}
|
|
|
|
|
2023-11-07 01:43:48 +01:00
|
|
|
MessageId get_same_chat_reply_to_message_id(bool ignore_external) const;
|
2023-10-24 11:04:45 +02:00
|
|
|
|
2023-11-07 00:48:01 +01:00
|
|
|
MessageFullId get_reply_message_full_id(DialogId owner_dialog_id, bool ignore_external) const;
|
2023-10-24 13:06:49 +02:00
|
|
|
|
2023-11-06 18:37:17 +01:00
|
|
|
void register_content(Td *td) const;
|
|
|
|
|
|
|
|
void unregister_content(Td *td) const;
|
|
|
|
|
2023-10-24 13:06:49 +02:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2023-10-24 11:04:45 +02:00
|
|
|
};
|
|
|
|
|
2023-10-24 13:06:49 +02:00
|
|
|
bool operator==(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs);
|
|
|
|
|
|
|
|
bool operator!=(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs);
|
|
|
|
|
2023-10-26 00:11:36 +02:00
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const RepliedMessageInfo &info);
|
|
|
|
|
2023-10-24 11:04:45 +02:00
|
|
|
} // namespace td
|