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,9 +401,17 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSo
} else {
LOG(ERROR) << "Receive unexpected JPEG minithumbnail in photo of format " << format;
}
return std::move(res);
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();
}
return size->bytes_.as_slice().str();
}
case telegram_api::photoSizeProgressive::ID: {
auto size = move_tl_object_as<telegram_api::photoSizeProgressive>(size_ptr);
@ -734,7 +742,11 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
}
res.photos.push_back(std::move(size));
} else {
res.minithumbnail = std::move(photo_size.get<1>());
if (G()->shared_config().get_option_boolean("disable_minithumbnails")) {
res.minithumbnail = "";
} else {
res.minithumbnail = std::move(photo_size.get<1>());
}
}
}

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;
}
v->minithumbnail = std::move(minithumbnail);
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;
v->minithumbnail = std::move(minithumbnail);
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;