Allow to always reuse photos from inputMessagePhoto.

This commit is contained in:
levlam 2022-09-15 16:08:19 +03:00
parent 111018eadd
commit ce1292ea32
3 changed files with 12 additions and 6 deletions

View File

@ -2086,8 +2086,8 @@ Result<InputMessageContent> get_input_message_content(
}
case td_api::inputMessagePhoto::ID: {
auto input_message = static_cast<td_api::inputMessagePhoto *>(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_);

View File

@ -3145,7 +3145,7 @@ Result<FileId> FileManager::get_input_thumbnail_file_id(const tl_object_ptr<td_a
Result<FileId> FileManager::get_input_file_id(FileType type, const tl_object_ptr<td_api::InputFile> &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<FileId> 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;
}
}
}
}

View File

@ -485,7 +485,8 @@ class FileManager final : public FileLoadManager::Callback {
DialogId owner_dialog_id, bool is_encrypted) TD_WARN_UNUSED_RESULT;
Result<FileId> get_input_file_id(FileType type, const tl_object_ptr<td_api::InputFile> &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<FileId> get_map_thumbnail_file_id(Location location, int32 zoom, int32 width, int32 height, int32 scale,
DialogId owner_dialog_id) TD_WARN_UNUSED_RESULT;