From e7d7c502c4276c2effe890e9b5a38089e47885a6 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 18 Apr 2024 15:13:16 +0300 Subject: [PATCH] Support missing file parts. --- td/telegram/QuickReplyManager.cpp | 16 ++++++++++++++-- td/telegram/QuickReplyManager.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/td/telegram/QuickReplyManager.cpp b/td/telegram/QuickReplyManager.cpp index 1b619ebae..1b2b67156 100644 --- a/td/telegram/QuickReplyManager.cpp +++ b/td/telegram/QuickReplyManager.cpp @@ -361,8 +361,8 @@ class QuickReplyManager::SendQuickReplyMediaQuery final : public Td::ResultHandl CHECK(file_id_.is_valid()); auto bad_parts = FileManager::get_missing_file_parts(status); if (!bad_parts.empty()) { - // td_->quick_reply_manager_->on_send_message_file_parts_missing(random_id_, std::move(bad_parts)); - // return; + td_->quick_reply_manager_->on_send_message_file_parts_missing(shortcut_id_, random_id_, std::move(bad_parts)); + return; } else { td_->file_manager_->delete_partial_remote_location_if_needed(file_id_, status); } @@ -1692,6 +1692,18 @@ void QuickReplyManager::do_send_message(const QuickReplyMessage *m, vector } } +void QuickReplyManager::on_send_message_file_parts_missing(QuickReplyShortcutId shortcut_id, int64 random_id, + vector &&bad_parts) { + auto *s = get_shortcut(shortcut_id); + if (s != nullptr) { + for (auto &message : s->messages_) { + if (message->random_id == random_id && message->message_id.is_yet_unsent()) { + do_send_message(message.get(), std::move(bad_parts)); + } + } + } +} + void QuickReplyManager::on_send_message_file_reference_error(QuickReplyShortcutId shortcut_id, int64 random_id) { auto *s = get_shortcut(shortcut_id); if (s != nullptr) { diff --git a/td/telegram/QuickReplyManager.h b/td/telegram/QuickReplyManager.h index 99ab523e4..bcb93585c 100644 --- a/td/telegram/QuickReplyManager.h +++ b/td/telegram/QuickReplyManager.h @@ -331,6 +331,8 @@ class QuickReplyManager final : public Actor { void do_send_message(const QuickReplyMessage *m, vector bad_parts = {}); + void on_send_message_file_parts_missing(QuickReplyShortcutId shortcut_id, int64 random_id, vector &&bad_parts); + void on_send_message_file_reference_error(QuickReplyShortcutId shortcut_id, int64 random_id); void on_upload_media(FileId file_id, telegram_api::object_ptr input_file);