diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 875ca6f57..0447fba86 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -2086,8 +2086,8 @@ Result get_input_message_content( } case td_api::inputMessagePhoto::ID: { auto input_message = static_cast(input_message_content.get()); - r_file_id = - td->file_manager_->get_input_file_id(FileType::Photo, input_message->photo_, dialog_id, false, is_secret); + r_file_id = td->file_manager_->get_input_file_id(FileType::Photo, input_message->photo_, dialog_id, false, + is_secret, false, false, true); input_thumbnail = std::move(input_message->thumbnail_); if (!input_message->added_sticker_file_ids_.empty()) { sticker_file_ids = td->stickers_manager_->get_attached_sticker_file_ids(input_message->added_sticker_file_ids_); diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 1119865d5..a8e928289 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -3145,7 +3145,7 @@ Result FileManager::get_input_thumbnail_file_id(const tl_object_ptr FileManager::get_input_file_id(FileType type, const tl_object_ptr &file, DialogId owner_dialog_id, bool allow_zero, bool is_encrypted, - bool get_by_hash, bool is_secure) { + bool get_by_hash, bool is_secure, bool force_reuse) { if (file == nullptr) { if (allow_zero) { return FileId(); @@ -3176,8 +3176,13 @@ Result FileManager::get_input_file_id(FileType type, const tl_object_ptr auto file_id = file_hash_to_file_id_.get(hash); if (file_id.is_valid()) { auto file_view = get_file_view(file_id); - if (!file_view.empty() && file_view.has_remote_location() && !file_view.remote_location().is_web()) { - return file_id; + if (!file_view.empty()) { + if (force_reuse) { + return file_id; + } + if (file_view.has_remote_location() && !file_view.remote_location().is_web()) { + return file_id; + } } } } diff --git a/td/telegram/files/FileManager.h b/td/telegram/files/FileManager.h index f07272c0d..ac53d8f0f 100644 --- a/td/telegram/files/FileManager.h +++ b/td/telegram/files/FileManager.h @@ -485,7 +485,8 @@ class FileManager final : public FileLoadManager::Callback { DialogId owner_dialog_id, bool is_encrypted) TD_WARN_UNUSED_RESULT; Result get_input_file_id(FileType type, const tl_object_ptr &file, DialogId owner_dialog_id, bool allow_zero, bool is_encrypted, - bool get_by_hash = false, bool is_secure = false) TD_WARN_UNUSED_RESULT; + bool get_by_hash = false, bool is_secure = false, + bool force_reuse = false) TD_WARN_UNUSED_RESULT; Result get_map_thumbnail_file_id(Location location, int32 zoom, int32 width, int32 height, int32 scale, DialogId owner_dialog_id) TD_WARN_UNUSED_RESULT;