Fix forwarding as copy of photos to a lot of chats simultaneously.

GitOrigin-RevId: 27edf34c58447a9c2bfd9e1a2679f69b0e05c076
This commit is contained in:
levlam 2020-05-07 15:43:53 +03:00
parent af5eed2abb
commit 5fe9d5feee
2 changed files with 9 additions and 3 deletions

View File

@ -4020,6 +4020,12 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
CHECK(!result->photo.photos.empty()); CHECK(!result->photo.photos.empty());
if ((result->photo.photos.size() > 2 || result->photo.photos.back().type != 'i') && !to_secret) { if ((result->photo.photos.size() > 2 || result->photo.photos.back().type != 'i') && !to_secret) {
// already sent photo // 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); return std::move(result);
} }

View File

@ -29636,7 +29636,7 @@ MessagesManager::Message *MessagesManager::continue_send_message(DialogId dialog
Dialog *d = get_dialog_force(dialog_id); Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) { 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); binlog_erase(G()->td_db()->get_binlog(), logevent_id);
return nullptr; return nullptr;
} }
@ -29663,7 +29663,7 @@ MessagesManager::Message *MessagesManager::continue_send_message(DialogId dialog
bool need_update = false; bool need_update = false;
bool need_update_dialog_pos = false; bool need_update_dialog_pos = false;
auto result_message = 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); CHECK(result_message != nullptr);
send_update_chat_has_scheduled_messages(d, false); 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"); can_send_status = Status::Error(400, "Message is too old to be re-sent automatically");
} }
if (can_send_status.is_error()) { 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()); fail_send_message({dialog_id, result_message->message_id}, can_send_status.move_as_error());
return nullptr; return nullptr;