Don't fix reply_to_message_id in message thread drafts.

This commit is contained in:
levlam 2020-12-30 15:09:41 +03:00
parent b1ffe39759
commit 371ec422e6
2 changed files with 12 additions and 10 deletions

View File

@ -17928,7 +17928,7 @@ Status MessagesManager::set_dialog_draft_message(DialogId dialog_id, MessageId t
new_draft_message = make_unique<DraftMessage>();
new_draft_message->date = G()->unix_time();
new_draft_message->reply_to_message_id =
get_reply_to_message_id(d, top_thread_message_id, MessageId(draft_message->reply_to_message_id_));
get_reply_to_message_id(d, top_thread_message_id, MessageId(draft_message->reply_to_message_id_), true);
auto input_message_content = std::move(draft_message->input_message_text_);
if (input_message_content != nullptr) {
@ -22662,10 +22662,12 @@ MessageId MessagesManager::get_persistent_message_id(const Dialog *d, MessageId
return message_id;
}
MessageId MessagesManager::get_reply_to_message_id(Dialog *d, MessageId top_thread_message_id, MessageId message_id) {
MessageId MessagesManager::get_reply_to_message_id(Dialog *d, MessageId top_thread_message_id, MessageId message_id,
bool for_draft) {
CHECK(d != nullptr);
if (!message_id.is_valid()) {
if (message_id == MessageId() && top_thread_message_id.is_valid() && top_thread_message_id.is_server() &&
if (!for_draft && message_id == MessageId() && top_thread_message_id.is_valid() &&
top_thread_message_id.is_server() &&
get_message_force(d, top_thread_message_id, "get_reply_to_message_id 1") != nullptr) {
return top_thread_message_id;
}
@ -22680,7 +22682,7 @@ MessageId MessagesManager::get_reply_to_message_id(Dialog *d, MessageId top_thre
// allow to reply yet unreceived server message
return message_id;
}
if (top_thread_message_id.is_valid() && top_thread_message_id.is_server() &&
if (!for_draft && top_thread_message_id.is_valid() && top_thread_message_id.is_server() &&
get_message_force(d, top_thread_message_id, "get_reply_to_message_id 3") != nullptr) {
return top_thread_message_id;
}
@ -22889,7 +22891,7 @@ Result<MessageId> MessagesManager::send_message(DialogId dialog_id, MessageId to
LOG(INFO) << "Begin to send message to " << dialog_id << " in reply to " << reply_to_message_id;
reply_to_message_id = get_reply_to_message_id(d, top_thread_message_id, reply_to_message_id);
reply_to_message_id = get_reply_to_message_id(d, top_thread_message_id, reply_to_message_id, false);
if (input_message_content->get_id() == td_api::inputMessageForwarded::ID) {
auto input_message = td_api::move_object_as<td_api::inputMessageForwarded>(input_message_content);
@ -23149,7 +23151,7 @@ Result<vector<MessageId>> MessagesManager::send_message_group(
}
}
reply_to_message_id = get_reply_to_message_id(d, top_thread_message_id, reply_to_message_id);
reply_to_message_id = get_reply_to_message_id(d, top_thread_message_id, reply_to_message_id, false);
TRY_STATUS(can_use_top_thread_message_id(d, top_thread_message_id, reply_to_message_id));
int64 media_album_id = 0;
@ -23950,7 +23952,7 @@ Result<MessageId> MessagesManager::send_inline_query_result_message(DialogId dia
return Status::Error(5, "Inline query result not found");
}
reply_to_message_id = get_reply_to_message_id(d, top_thread_message_id, reply_to_message_id);
reply_to_message_id = get_reply_to_message_id(d, top_thread_message_id, reply_to_message_id, false);
TRY_STATUS(can_use_message_send_options(message_send_options, content->message_content, 0));
TRY_STATUS(can_send_message_content(dialog_id, content->message_content.get(), false));
TRY_STATUS(can_use_top_thread_message_id(d, top_thread_message_id, reply_to_message_id));
@ -25876,7 +25878,7 @@ Result<vector<MessageId>> MessagesManager::resend_messages(DialogId dialog_id, v
get_message_schedule_date(message.get()));
Message *m = get_message_to_send(
d, message->top_thread_message_id,
get_reply_to_message_id(d, message->top_thread_message_id, message->reply_to_message_id), options,
get_reply_to_message_id(d, message->top_thread_message_id, message->reply_to_message_id, false), options,
std::move(new_contents[i]), &need_update_dialog_pos, false, nullptr, message->is_copy);
m->reply_markup = std::move(message->reply_markup);
m->via_bot_user_id = message->via_bot_user_id;
@ -26111,7 +26113,7 @@ Result<MessageId> MessagesManager::add_local_message(
m->sender_dialog_id = sender_dialog_id;
}
m->date = G()->unix_time();
m->reply_to_message_id = get_reply_to_message_id(d, MessageId(), reply_to_message_id);
m->reply_to_message_id = get_reply_to_message_id(d, MessageId(), reply_to_message_id, false);
if (m->reply_to_message_id.is_valid()) {
const Message *reply_m = get_message(d, m->reply_to_message_id);
if (reply_m != nullptr) {

View File

@ -1817,7 +1817,7 @@ class MessagesManager : public Actor {
static FullMessageId get_replied_message_id(DialogId dialog_id, const Message *m);
MessageId get_reply_to_message_id(Dialog *d, MessageId top_thread_message_id, MessageId message_id);
MessageId get_reply_to_message_id(Dialog *d, MessageId top_thread_message_id, MessageId message_id, bool for_draft);
static void fix_server_reply_to_message_id(DialogId dialog_id, MessageId message_id, DialogId reply_in_dialog_id,
MessageId &reply_to_message_id);