Fix disable_minithumbnails

This commit is contained in:
Andrea Cavalli 2021-04-03 13:10:25 +02:00
parent 1ce823b0e6
commit 9c67d7a6b7
3 changed files with 26 additions and 5 deletions

View File

@ -401,10 +401,18 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSo
} else {
LOG(ERROR) << "Receive unexpected JPEG minithumbnail in photo of format " << format;
}
if (G()->shared_config().get_option_boolean("disable_minithumbnails")) {
return "";
} else {
return std::move(res);
}
}
if (G()->shared_config().get_option_boolean("disable_minithumbnails")) {
return "";
} else {
return size->bytes_.as_slice().str();
}
}
case telegram_api::photoSizeProgressive::ID: {
auto size = move_tl_object_as<telegram_api::photoSizeProgressive>(size_ptr);
@ -733,10 +741,14 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
continue;
}
res.photos.push_back(std::move(size));
} else {
if (G()->shared_config().get_option_boolean("disable_minithumbnails")) {
res.minithumbnail = "";
} else {
res.minithumbnail = std::move(photo_size.get<1>());
}
}
}
for (auto &size_ptr : photo->video_sizes_) {
auto animation =

View File

@ -12,6 +12,7 @@
#include "td/telegram/files/FileManager.h"
#include "td/telegram/SecretChatActor.h"
#include "td/telegram/ConfigShared.h"
#include "td/telegram/Td.h"
#include "td/utils/logging.h"
@ -170,7 +171,11 @@ void VideoNotesManager::create_video_note(FileId file_id, string minithumbnail,
} else {
LOG(INFO) << "Receive wrong video note dimensions " << dimensions;
}
if (G()->shared_config().get_option_boolean("disable_minithumbnails")) {
v->minithumbnail = "";
} else {
v->minithumbnail = std::move(minithumbnail);
}
v->thumbnail = std::move(thumbnail);
on_get_video_note(std::move(v), replace);
}

View File

@ -215,7 +215,11 @@ void VideosManager::create_video(FileId file_id, string minithumbnail, PhotoSize
v->mime_type = std::move(mime_type);
v->duration = max(duration, 0);
v->dimensions = dimensions;
if (G()->shared_config().get_option_boolean("disable_minithumbnails")) {
v->minithumbnail = "";
} else {
v->minithumbnail = std::move(minithumbnail);
}
v->thumbnail = std::move(thumbnail);
v->animated_thumbnail = std::move(animated_thumbnail);
v->supports_streaming = supports_streaming;