Add separate td_api::InputMessageReplyTo.

This commit is contained in:
levlam 2023-10-06 11:58:05 +03:00
parent 3e3b4e8aa6
commit 811a7c60e1
9 changed files with 74 additions and 62 deletions

View File

@ -1182,15 +1182,25 @@ messageSendingStateFailed error:error can_retry:Bool need_another_sender:Bool re
//@class MessageReplyTo @description Contains information about the message or the story a message is replying to
//@description Describes a replied message
//@chat_id The identifier of the chat to which the replied message belongs; ignored for outgoing replies. For example, messages in the Replies chat are replies to messages in different chats
//@message_id The identifier of the replied message
//@description Describes a message replied by a given message
//@chat_id The identifier of the chat to which the message belongs
//@message_id The identifier of the message
messageReplyToMessage chat_id:int53 message_id:int53 = MessageReplyTo;
//@description Describes a replied story @story_sender_chat_id The identifier of the sender of the replied story. Currently, stories can be replied only in the sender's chat @story_id The identifier of the replied story
//@description Describes a story replied by a given message @story_sender_chat_id The identifier of the sender of the story @story_id The identifier of the story
messageReplyToStory story_sender_chat_id:int53 story_id:int32 = MessageReplyTo;
//@class InputMessageReplyTo @description Contains information about the message or the story to be replied
//@description Describes a message to be replied
//@message_id The identifier of the message to be replied in the same chat
inputMessageReplyToMessage message_id:int53 = InputMessageReplyTo;
//@description Describes a story to be replied @story_sender_chat_id The identifier of the sender of the story. Currently, stories can be replied only in the sender's chat @story_id The identifier of the story
inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessageReplyTo;
//@description Describes a message
//@id Message identifier; unique for the chat to which the message belongs
//@sender_id Identifier of the sender of the message
@ -6865,7 +6875,7 @@ setChatMessageSender chat_id:int53 message_sender_id:MessageSender = Ok;
//@options Options to be used to send the message; pass null to use default options
//@reply_markup Markup for replying to the message; pass null if none; for bots only
//@input_message_content The content of the message to be sent
sendMessage chat_id:int53 message_thread_id:int53 reply_to:MessageReplyTo options:messageSendOptions reply_markup:ReplyMarkup input_message_content:InputMessageContent = Message;
sendMessage chat_id:int53 message_thread_id:int53 reply_to:InputMessageReplyTo options:messageSendOptions reply_markup:ReplyMarkup input_message_content:InputMessageContent = Message;
//@description Sends 2-10 messages grouped together into an album. Currently, only audio, document, photo and video messages can be grouped into an album. Documents and audio files can be only grouped in an album with messages of the same type. Returns sent messages
//@chat_id Target chat
@ -6874,7 +6884,7 @@ sendMessage chat_id:int53 message_thread_id:int53 reply_to:MessageReplyTo option
//@options Options to be used to send the messages; pass null to use default options
//@input_message_contents Contents of messages to be sent. At most 10 messages can be added to an album
//@only_preview Pass true to get fake messages instead of actually sending them
sendMessageAlbum chat_id:int53 message_thread_id:int53 reply_to:MessageReplyTo options:messageSendOptions input_message_contents:vector<InputMessageContent> only_preview:Bool = Messages;
sendMessageAlbum chat_id:int53 message_thread_id:int53 reply_to:InputMessageReplyTo options:messageSendOptions input_message_contents:vector<InputMessageContent> only_preview:Bool = Messages;
//@description Invites a bot to a chat (if it is not yet a member) and sends it the /start command. Bots can't be invited to a private chat other than the chat with the bot. Bots can't be invited to channels (although they can be added as admins) and secret chats. Returns the sent message
//@bot_user_id Identifier of the bot
@ -6890,7 +6900,7 @@ sendBotStartMessage bot_user_id:int53 chat_id:int53 parameter:string = Message;
//@query_id Identifier of the inline query
//@result_id Identifier of the inline query result
//@hide_via_bot Pass true to hide the bot, via which the message is sent. Can be used only for bots getOption("animation_search_bot_username"), getOption("photo_search_bot_username"), and getOption("venue_search_bot_username")
sendInlineQueryResultMessage chat_id:int53 message_thread_id:int53 reply_to:MessageReplyTo options:messageSendOptions query_id:int64 result_id:string hide_via_bot:Bool = Message;
sendInlineQueryResultMessage chat_id:int53 message_thread_id:int53 reply_to:InputMessageReplyTo options:messageSendOptions query_id:int64 result_id:string hide_via_bot:Bool = Message;
//@description Forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can't be forwarded, null will be returned instead of the message
//@chat_id Identifier of the chat to which to forward messages
@ -6915,7 +6925,7 @@ resendMessages chat_id:int53 message_ids:vector<int53> = Messages;
//@reply_to Identifier of the replied message or story; pass null if none
//@disable_notification Pass true to disable notification for the message
//@input_message_content The content of the message to be added
addLocalMessage chat_id:int53 sender_id:MessageSender reply_to:MessageReplyTo disable_notification:Bool input_message_content:InputMessageContent = Message;
addLocalMessage chat_id:int53 sender_id:MessageSender reply_to:InputMessageReplyTo disable_notification:Bool input_message_content:InputMessageContent = Message;
//@description Deletes messages @chat_id Chat identifier @message_ids Identifiers of the messages to be deleted @revoke Pass true to delete messages for all chat members. Always true for supergroups, channels and secret chats
deleteMessages chat_id:int53 message_ids:vector<int53> revoke:Bool = Ok;
@ -7264,7 +7274,7 @@ sendWebAppData bot_user_id:int53 button_text:string data:string = Ok;
//@application_name Short name of the application; 0-64 English letters, digits, and underscores
//@message_thread_id If not 0, a message thread identifier in which the message will be sent
//@reply_to Identifier of the replied message or story for the message sent by the Web App; pass null if none
openWebApp chat_id:int53 bot_user_id:int53 url:string theme:themeParameters application_name:string message_thread_id:int53 reply_to:MessageReplyTo = WebAppInfo;
openWebApp chat_id:int53 bot_user_id:int53 url:string theme:themeParameters application_name:string message_thread_id:int53 reply_to:InputMessageReplyTo = WebAppInfo;
//@description Informs TDLib that a previously opened Web App was closed @web_app_launch_id Identifier of Web App launch, received from openWebApp
closeWebApp web_app_launch_id:int64 = Ok;

View File

@ -835,7 +835,7 @@ void AttachMenuManager::request_app_web_view(DialogId dialog_id, UserId bot_user
}
void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id, MessageId top_thread_message_id,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to, string &&url,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, string &&url,
td_api::object_ptr<td_api::themeParameters> &&theme, string &&platform,
Promise<td_api::object_ptr<td_api::webAppInfo>> &&promise) {
TRY_STATUS_PROMISE(promise, td_->contacts_manager_->get_bot_data(bot_user_id));

View File

@ -43,7 +43,7 @@ class AttachMenuManager final : public Actor {
string &&platform, bool allow_write_access, Promise<string> &&promise);
void request_web_view(DialogId dialog_id, UserId bot_user_id, MessageId top_thread_message_id,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to, string &&url,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, string &&url,
td_api::object_ptr<td_api::themeParameters> &&theme, string &&platform,
Promise<td_api::object_ptr<td_api::webAppInfo>> &&promise);

View File

@ -209,7 +209,7 @@ Result<unique_ptr<DraftMessage>> DraftMessage::get_draft_message(
td->messages_manager_
->get_message_input_reply_to(
dialog_id, top_thread_message_id,
td_api::make_object<td_api::messageReplyToMessage>(0, result->reply_to_message_id_.get()), true)
td_api::make_object<td_api::inputMessageReplyToMessage>(result->reply_to_message_id_.get()), true)
.message_id_;
auto input_message_content = std::move(draft_message->input_message_text_);

View File

@ -15,18 +15,18 @@
namespace td {
/*
MessageInputReplyTo::MessageInputReplyTo(const td_api::object_ptr<td_api::MessageReplyTo> &reply_to_ptr) {
MessageInputReplyTo::MessageInputReplyTo(const td_api::object_ptr<td_api::InputMessageReplyTo> &reply_to_ptr) {
if (reply_to_ptr == nullptr) {
return;
}
switch (reply_to_ptr->get_id()) {
case td_api::messageReplyToMessage::ID: {
auto reply_to = static_cast<const td_api::messageReplyToMessage *>(reply_to_ptr.get());
case td_api::inputMessageReplyToMessage::ID: {
auto reply_to = static_cast<const td_api::inputMessageReplyToMessage *>(reply_to_ptr.get());
message_id_ = MessageId(reply_to->message_id_);
break;
}
case td_api::messageReplyToStory::ID: {
auto reply_to = static_cast<const td_api::messageReplyToStory *>(reply_to_ptr.get());
case td_api::inputMessageReplyToStory::ID: {
auto reply_to = static_cast<const td_api::inputMessageReplyToStory *>(reply_to_ptr.get());
story_full_id_ = {DialogId(reply_to->story_sender_chat_id_), StoryId(reply_to->story_id_)};
break;
}

View File

@ -34,7 +34,7 @@ struct MessageInputReplyTo {
CHECK(!story_full_id_.is_valid() || !message_id_.is_valid());
}
//explicit MessageInputReplyTo(const td_api::object_ptr<td_api::MessageReplyTo> &reply_to_ptr);
//explicit MessageInputReplyTo(const td_api::object_ptr<td_api::InputMessageReplyTo> &reply_to_ptr);
telegram_api::object_ptr<telegram_api::InputReplyTo> get_input_reply_to(Td *td,
MessageId top_thread_message_id) const;

View File

@ -24199,9 +24199,9 @@ DialogId MessagesManager::get_dialog_default_send_message_as_dialog_id(DialogId
return d->default_send_message_as_dialog_id;
}
MessageInputReplyTo MessagesManager::get_message_input_reply_to(DialogId dialog_id, MessageId top_thread_message_id,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to,
bool for_draft) {
MessageInputReplyTo MessagesManager::get_message_input_reply_to(
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
bool for_draft) {
return get_message_input_reply_to(get_dialog(dialog_id), top_thread_message_id, std::move(reply_to), for_draft);
}
@ -24434,17 +24434,17 @@ MessageId MessagesManager::get_persistent_message_id(const Dialog *d, MessageId
return message_id;
}
MessageInputReplyTo MessagesManager::get_message_input_reply_to(Dialog *d, MessageId top_thread_message_id,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to,
bool for_draft) {
MessageInputReplyTo MessagesManager::get_message_input_reply_to(
Dialog *d, MessageId top_thread_message_id, td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
bool for_draft) {
CHECK(d != nullptr);
if (top_thread_message_id.is_valid() &&
!have_message_force(d, top_thread_message_id, "get_message_input_reply_to 1")) {
LOG(INFO) << "Have reply in the thread of unknown " << top_thread_message_id;
}
if (reply_to != nullptr && reply_to->get_id() == td_api::messageReplyToStory::ID) {
if (reply_to != nullptr && reply_to->get_id() == td_api::inputMessageReplyToStory::ID) {
CHECK(!for_draft);
auto reply_to_story = td_api::move_object_as<td_api::messageReplyToStory>(reply_to);
auto reply_to_story = td_api::move_object_as<td_api::inputMessageReplyToStory>(reply_to);
auto story_id = StoryId(reply_to_story->story_id_);
auto sender_dialog_id = DialogId(reply_to_story->story_sender_chat_id_);
if (d->dialog_id != sender_dialog_id || sender_dialog_id.get_type() != DialogType::User) {
@ -24458,8 +24458,8 @@ MessageInputReplyTo MessagesManager::get_message_input_reply_to(Dialog *d, Messa
return {MessageId(), StoryFullId(sender_dialog_id, story_id)};
}
MessageId message_id;
if (reply_to != nullptr && reply_to->get_id() == td_api::messageReplyToMessage::ID) {
auto reply_to_message = td_api::move_object_as<td_api::messageReplyToMessage>(reply_to);
if (reply_to != nullptr && reply_to->get_id() == td_api::inputMessageReplyToMessage::ID) {
auto reply_to_message = td_api::move_object_as<td_api::inputMessageReplyToMessage>(reply_to);
message_id = MessageId(reply_to_message->message_id_);
}
if (!message_id.is_valid()) {
@ -24848,7 +24848,7 @@ class MessagesManager::SendMessageLogEvent {
};
Result<td_api::object_ptr<td_api::message>> MessagesManager::send_message(
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::MessageReplyTo> &&reply_to,
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
tl_object_ptr<td_api::messageSendOptions> &&options, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) {
if (input_message_content == nullptr) {
@ -25088,7 +25088,7 @@ int64 MessagesManager::generate_new_media_album_id() {
}
Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_message_group(
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::MessageReplyTo> &&reply_to,
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
tl_object_ptr<td_api::messageSendOptions> &&options,
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents, bool only_preview) {
if (input_message_contents.size() > MAX_GROUPED_MESSAGES) {
@ -25980,7 +25980,7 @@ void MessagesManager::do_send_bot_start_message(UserId bot_user_id, DialogId dia
}
Result<MessageId> MessagesManager::send_inline_query_result_message(
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::MessageReplyTo> &&reply_to,
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
tl_object_ptr<td_api::messageSendOptions> &&options, int64 query_id, const string &result_id, bool hide_via_bot) {
Dialog *d = get_dialog_force(dialog_id, "send_inline_query_result_message");
if (d == nullptr) {
@ -28342,7 +28342,7 @@ void MessagesManager::share_dialog_with_bot(MessageFullId message_full_id, int32
Result<MessageId> MessagesManager::add_local_message(
DialogId dialog_id, td_api::object_ptr<td_api::MessageSender> &&sender,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to, bool disable_notification,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, bool disable_notification,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) {
if (input_message_content == nullptr) {
return Status::Error(400, "Can't add local message without content");

View File

@ -428,15 +428,16 @@ class MessagesManager final : public Actor {
DialogId get_dialog_default_send_message_as_dialog_id(DialogId dialog_id) const;
MessageInputReplyTo get_message_input_reply_to(DialogId dialog_id, MessageId top_thread_message_id,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to, bool for_draft);
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
bool for_draft);
Result<td_api::object_ptr<td_api::message>> send_message(
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::MessageReplyTo> &&reply_to,
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
tl_object_ptr<td_api::messageSendOptions> &&options, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) TD_WARN_UNUSED_RESULT;
Result<td_api::object_ptr<td_api::messages>> send_message_group(
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::MessageReplyTo> &&reply_to,
DialogId dialog_id, MessageId top_thread_message_id, td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
tl_object_ptr<td_api::messageSendOptions> &&options,
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents,
bool only_preview) TD_WARN_UNUSED_RESULT;
@ -445,7 +446,7 @@ class MessagesManager final : public Actor {
const string &parameter) TD_WARN_UNUSED_RESULT;
Result<MessageId> send_inline_query_result_message(DialogId dialog_id, MessageId top_thread_message_id,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
tl_object_ptr<td_api::messageSendOptions> &&options,
int64 query_id, const string &result_id,
bool hide_via_bot) TD_WARN_UNUSED_RESULT;
@ -464,10 +465,10 @@ class MessagesManager final : public Actor {
void share_dialog_with_bot(MessageFullId message_full_id, int32 button_id, DialogId shared_dialog_id,
bool expect_user, bool only_check, Promise<Unit> &&promise);
Result<MessageId> add_local_message(DialogId dialog_id, td_api::object_ptr<td_api::MessageSender> &&sender,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to, bool disable_notification,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content)
TD_WARN_UNUSED_RESULT;
Result<MessageId> add_local_message(
DialogId dialog_id, td_api::object_ptr<td_api::MessageSender> &&sender,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, bool disable_notification,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) TD_WARN_UNUSED_RESULT;
void get_message_file_type(const string &message_file_head,
Promise<td_api::object_ptr<td_api::MessageFileType>> &&promise);
@ -1828,7 +1829,8 @@ class MessagesManager final : public Actor {
static MessageFullId get_replied_message_id(DialogId dialog_id, const Message *m);
MessageInputReplyTo get_message_input_reply_to(Dialog *d, MessageId top_thread_message_id,
td_api::object_ptr<td_api::MessageReplyTo> &&reply_to, bool for_draft);
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
bool for_draft);
void fix_server_reply_to_message_id(DialogId dialog_id, MessageId message_id, DialogId reply_in_dialog_id,
MessageId &reply_to_message_id) const;

View File

@ -919,29 +919,29 @@ class CliClient final : public Actor {
arg.file_id = as_file_id(args);
}
struct MessageReplyTo {
struct InputMessageReplyTo {
int64 message_id = 0;
// or
int64 user_id = 0;
int32 story_id = 0;
static MessageReplyTo get_default() {
static InputMessageReplyTo get_default() {
return {};
}
operator td_api::object_ptr<td_api::MessageReplyTo>() const {
operator td_api::object_ptr<td_api::InputMessageReplyTo>() const {
if (message_id == 0 && user_id == 0 && story_id == 0) {
return nullptr;
}
if (message_id != 0) {
return td_api::make_object<td_api::messageReplyToMessage>(-1, message_id);
return td_api::make_object<td_api::inputMessageReplyToMessage>(message_id);
} else {
return td_api::make_object<td_api::messageReplyToStory>(user_id, story_id);
return td_api::make_object<td_api::inputMessageReplyToStory>(user_id, story_id);
}
}
};
void get_args(string &args, MessageReplyTo &arg) const {
void get_args(string &args, InputMessageReplyTo &arg) const {
if (!args.empty() && args != "0") {
if (args.find('_') == string::npos) {
arg.message_id = as_message_id(args);
@ -2235,9 +2235,9 @@ class CliClient final : public Actor {
void send_message(int64 chat_id, td_api::object_ptr<td_api::InputMessageContent> &&input_message_content,
bool disable_notification = false, bool from_background = false,
MessageReplyTo message_reply_to = MessageReplyTo::get_default()) {
InputMessageReplyTo reply_to = InputMessageReplyTo::get_default()) {
auto id = send_request(td_api::make_object<td_api::sendMessage>(
chat_id, message_thread_id_, message_reply_to,
chat_id, message_thread_id_, reply_to,
td_api::make_object<td_api::messageSendOptions>(disable_notification, from_background, true, true,
as_message_scheduling_state(schedule_date_),
Random::fast(1, 1000)),
@ -4371,11 +4371,11 @@ class CliClient final : public Actor {
ChatId chat_id;
UserId bot_user_id;
string url;
MessageReplyTo message_reply_to;
InputMessageReplyTo reply_to;
MessageThreadId message_thread_id;
get_args(args, chat_id, bot_user_id, url, message_reply_to, message_thread_id);
get_args(args, chat_id, bot_user_id, url, reply_to, message_thread_id);
send_request(td_api::make_object<td_api::openWebApp>(chat_id, bot_user_id, url, as_theme_parameters(), "android",
message_thread_id, message_reply_to));
message_thread_id, reply_to));
} else if (op == "cwa") {
int64 launch_id;
get_args(args, launch_id);
@ -4429,17 +4429,17 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::setChatMessageSender>(chat_id, as_message_sender(sender_id)));
} else if (op == "sm" || op == "sms" || op == "smr" || op == "smf") {
ChatId chat_id;
MessageReplyTo message_reply_to;
InputMessageReplyTo reply_to;
string message;
get_args(args, chat_id, message);
if (op == "smr") {
get_args(message, message_reply_to, message);
get_args(message, reply_to, message);
}
if (op == "smf") {
message = string(5097, 'a');
}
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true),
op == "sms", false, message_reply_to);
op == "sms", false, reply_to);
} else if (op == "smce") {
ChatId chat_id;
get_args(args, chat_id);
@ -4455,21 +4455,21 @@ class CliClient final : public Actor {
} else if (op == "alm" || op == "almr") {
ChatId chat_id;
string sender_id;
MessageReplyTo message_reply_to;
InputMessageReplyTo reply_to;
string message;
get_args(args, chat_id, sender_id, message);
if (op == "almr") {
get_args(message, message_reply_to, message);
get_args(message, reply_to, message);
}
send_request(td_api::make_object<td_api::addLocalMessage>(
chat_id, as_message_sender(sender_id), message_reply_to, false,
chat_id, as_message_sender(sender_id), reply_to, false,
td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true)));
} else if (op == "smap" || op == "smapr" || op == "smapp" || op == "smaprp") {
ChatId chat_id;
MessageReplyTo message_reply_to;
InputMessageReplyTo reply_to;
get_args(args, chat_id, args);
if (op == "smapr" || op == "smaprp") {
get_args(args, message_reply_to, args);
get_args(args, reply_to, args);
}
auto input_message_contents = transform(full_split(args), [this](const string &photo) {
td_api::object_ptr<td_api::InputMessageContent> content = td_api::make_object<td_api::inputMessagePhoto>(
@ -4478,8 +4478,8 @@ class CliClient final : public Actor {
return content;
});
send_request(td_api::make_object<td_api::sendMessageAlbum>(
chat_id, message_thread_id_, message_reply_to, default_message_send_options(),
std::move(input_message_contents), op == "smapp" || op == "smaprp"));
chat_id, message_thread_id_, reply_to, default_message_send_options(), std::move(input_message_contents),
op == "smapp" || op == "smaprp"));
} else if (op == "smad" || op == "smadp") {
ChatId chat_id;
get_args(args, chat_id, args);