Keep quote when forwarding replies.

This commit is contained in:
levlam 2023-10-27 14:33:15 +03:00
parent e86539c015
commit 8adea20fd3
3 changed files with 16 additions and 7 deletions

View File

@ -28102,12 +28102,13 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
if (forward_info != nullptr && !forward_info->is_imported) { if (forward_info != nullptr && !forward_info->is_imported) {
forward_info->origin.hide_sender_if_needed(td_); forward_info->origin.hide_sender_if_needed(td_);
} }
MessageId reply_to_message_id; MessageInputReplyTo input_reply_to;
auto original_reply_to_message_id = forwarded_message->replied_message_info.get_same_chat_reply_to_message_id(); auto original_reply_to_message_id = forwarded_message->replied_message_info.get_same_chat_reply_to_message_id();
if (original_reply_to_message_id.is_valid()) { if (original_reply_to_message_id.is_valid()) {
auto it = forwarded_message_id_to_new_message_id.find(original_reply_to_message_id); auto it = forwarded_message_id_to_new_message_id.find(original_reply_to_message_id);
if (it != forwarded_message_id_to_new_message_id.end()) { if (it != forwarded_message_id_to_new_message_id.end()) {
reply_to_message_id = it->second; input_reply_to = forwarded_message->replied_message_info.get_input_reply_to();
input_reply_to.set_message_id(it->second);
} }
} }
@ -28115,9 +28116,9 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
Message *m; Message *m;
if (message_send_options.only_preview) { if (message_send_options.only_preview) {
message = create_message_to_send( message = create_message_to_send(
to_dialog, top_thread_message_id, MessageInputReplyTo{reply_to_message_id, FormattedText()}, to_dialog, top_thread_message_id, std::move(input_reply_to), message_send_options, std::move(content),
message_send_options, std::move(content), forwarded_message_contents[j].invert_media, forwarded_message_contents[j].invert_media, j + 1 != forwarded_message_contents.size(),
j + 1 != forwarded_message_contents.size(), std::move(forward_info), false, DialogId()); std::move(forward_info), false, DialogId());
MessageId new_message_id = MessageId new_message_id =
message_send_options.schedule_date != 0 message_send_options.schedule_date != 0
? get_next_yet_unsent_scheduled_message_id(to_dialog, message_send_options.schedule_date) ? get_next_yet_unsent_scheduled_message_id(to_dialog, message_send_options.schedule_date)
@ -28125,8 +28126,7 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
message->message_id = new_message_id; message->message_id = new_message_id;
m = message.get(); m = message.get();
} else { } else {
m = get_message_to_send(to_dialog, top_thread_message_id, m = get_message_to_send(to_dialog, top_thread_message_id, std::move(input_reply_to), message_send_options,
MessageInputReplyTo{reply_to_message_id, FormattedText()}, message_send_options,
std::move(content), forwarded_message_contents[j].invert_media, &need_update_dialog_pos, std::move(content), forwarded_message_contents[j].invert_media, &need_update_dialog_pos,
j + 1 != forwarded_message_contents.size(), std::move(forward_info)); j + 1 != forwarded_message_contents.size(), std::move(forward_info));
} }

View File

@ -292,6 +292,13 @@ td_api::object_ptr<td_api::messageReplyToMessage> RepliedMessageInfo::get_messag
std::move(content)); std::move(content));
} }
MessageInputReplyTo RepliedMessageInfo::get_input_reply_to() const {
if (message_id_.is_valid() && dialog_id_ == DialogId()) {
return MessageInputReplyTo{message_id_, FormattedText{quote_}};
}
return {};
}
MessageId RepliedMessageInfo::get_same_chat_reply_to_message_id() const { MessageId RepliedMessageInfo::get_same_chat_reply_to_message_id() const {
return is_same_chat_reply() ? message_id_ : MessageId(); return is_same_chat_reply() ? message_id_ : MessageId();
} }

View File

@ -87,6 +87,8 @@ class RepliedMessageInfo {
td_api::object_ptr<td_api::messageReplyToMessage> get_message_reply_to_message_object(Td *td, td_api::object_ptr<td_api::messageReplyToMessage> get_message_reply_to_message_object(Td *td,
DialogId dialog_id) const; DialogId dialog_id) const;
MessageInputReplyTo get_input_reply_to() const;
void set_message_id(MessageId new_message_id) { void set_message_id(MessageId new_message_id) {
CHECK(message_id_.is_valid() || message_id_.is_valid_scheduled()); CHECK(message_id_.is_valid() || message_id_.is_valid_scheduled());
message_id_ = new_message_id; message_id_ = new_message_id;