From 5fe9d5feee0050e6684a92a39660f739e305add3 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 7 May 2020 15:43:53 +0300 Subject: [PATCH] Fix forwarding as copy of photos to a lot of chats simultaneously. GitOrigin-RevId: 27edf34c58447a9c2bfd9e1a2679f69b0e05c076 --- td/telegram/MessageContent.cpp | 6 ++++++ td/telegram/MessagesManager.cpp | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 3dce93da..348b678c 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -4020,6 +4020,12 @@ unique_ptr dup_message_content(Td *td, DialogId dialog_id, const CHECK(!result->photo.photos.empty()); if ((result->photo.photos.size() > 2 || result->photo.photos.back().type != 'i') && !to_secret) { // already sent photo + // having remote location is not enough to have InputMedia, because the file may not have valid file_reference + // also file_id needs to be duped, because upload can be called to repair the file_reference and every upload + // request must have unique file_id + if (!td->auth_manager_->is_bot()) { + result->photo.photos.back().file_id = fix_file_id(result->photo.photos.back().file_id); + } return std::move(result); } diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 4bfc4c8c..5aa5465e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -29636,7 +29636,7 @@ MessagesManager::Message *MessagesManager::continue_send_message(DialogId dialog Dialog *d = get_dialog_force(dialog_id); if (d == nullptr) { - LOG(ERROR) << "Can't find " << dialog_id << " to resend a message"; + LOG(ERROR) << "Can't find " << dialog_id << " to continue send a message"; binlog_erase(G()->td_db()->get_binlog(), logevent_id); return nullptr; } @@ -29663,7 +29663,7 @@ MessagesManager::Message *MessagesManager::continue_send_message(DialogId dialog bool need_update = false; bool need_update_dialog_pos = false; auto result_message = - add_message_to_dialog(d, std::move(m), true, &need_update, &need_update_dialog_pos, "resend message"); + add_message_to_dialog(d, std::move(m), true, &need_update, &need_update_dialog_pos, "continue_send_message"); CHECK(result_message != nullptr); send_update_chat_has_scheduled_messages(d, false); @@ -29679,7 +29679,7 @@ MessagesManager::Message *MessagesManager::continue_send_message(DialogId dialog can_send_status = Status::Error(400, "Message is too old to be re-sent automatically"); } if (can_send_status.is_error()) { - LOG(INFO) << "Can't resend a message to " << dialog_id << ": " << can_send_status.error(); + LOG(INFO) << "Can't continue to send a message to " << dialog_id << ": " << can_send_status.error(); fail_send_message({dialog_id, result_message->message_id}, can_send_status.move_as_error()); return nullptr;