Minithumbnails option for all media types

This commit is contained in:
Andrea Cavalli 2020-08-05 11:23:52 +02:00
parent a8abec44a0
commit 9dc0b2808c
4 changed files with 66 additions and 7 deletions

View File

@ -15,6 +15,8 @@
#include "td/utils/common.h"
#include "td/utils/tl_helpers.h"
#include "td/telegram/ConfigShared.h"
namespace td {
template <class StorerT>
@ -58,10 +60,27 @@ FileId AnimationsManager::parse_animation(ParserT &parser) {
parse(animation->duration, parser);
}
parse(animation->dimensions, parser);
parse(animation->file_name, parser);
string tmp_filename;
parse(tmp_filename, parser);
parse(animation->mime_type, parser);
if ( G()->shared_config().get_option_boolean("disable_document_filenames") && (
animation->mime_type.rfind("image/") == 0 ||
animation->mime_type.rfind("video/") == 0 ||
animation->mime_type.rfind("audio/") == 0)) {
animation->file_name = "0";
} else {
animation->file_name = tmp_filename;
}
if (parser.version() >= static_cast<int32>(Version::SupportMinithumbnails)) {
parse(animation->minithumbnail, parser);
string tmp_minithumbnail;
parse(tmp_minithumbnail, parser);
if (!G()->shared_config().get_option_boolean("disable_minithumbnails")) {
animation->minithumbnail = tmp_minithumbnail;
}
}
parse(animation->thumbnail, parser);
parse(animation->file_id, parser);

View File

@ -15,6 +15,8 @@
#include "td/utils/common.h"
#include "td/utils/tl_helpers.h"
#include "td/telegram/ConfigShared.h"
namespace td {
template <class StorerT>
@ -37,13 +39,30 @@ void AudiosManager::store_audio(FileId file_id, StorerT &storer) const {
template <class ParserT>
FileId AudiosManager::parse_audio(ParserT &parser) {
auto audio = make_unique<Audio>();
parse(audio->file_name, parser);
string tmp_filename;
parse(tmp_filename, parser);
parse(audio->mime_type, parser);
if ( G()->shared_config().get_option_boolean("disable_document_filenames") && (
audio->mime_type.rfind("image/") == 0 ||
audio->mime_type.rfind("video/") == 0 ||
audio->mime_type.rfind("audio/") == 0)) {
audio->file_name = "0";
} else {
audio->file_name = tmp_filename;
}
parse(audio->duration, parser);
parse(audio->title, parser);
parse(audio->performer, parser);
if (parser.version() >= static_cast<int32>(Version::SupportMinithumbnails)) {
parse(audio->minithumbnail, parser);
string tmp_minithumbnail;
parse(tmp_minithumbnail, parser);
if (!G()->shared_config().get_option_boolean("disable_minithumbnails")) {
audio->minithumbnail = tmp_minithumbnail;
}
}
parse(audio->thumbnail, parser);
parse(audio->file_id, parser);

View File

@ -37,7 +37,11 @@ FileId VideoNotesManager::parse_video_note(ParserT &parser) {
parse(video_note->duration, parser);
parse(video_note->dimensions, parser);
if (parser.version() >= static_cast<int32>(Version::SupportMinithumbnails)) {
parse(video_note->minithumbnail, parser);
string tmp_minithumbnail;
parse(tmp_minithumbnail, parser);
if (!G()->shared_config().get_option_boolean("disable_minithumbnails")) {
video_note->minithumbnail = tmp_minithumbnail;
}
}
parse(video_note->thumbnail, parser);
parse(video_note->file_id, parser);

View File

@ -54,12 +54,29 @@ FileId VideosManager::parse_video(ParserT &parser) {
PARSE_FLAG(video->supports_streaming);
PARSE_FLAG(has_animated_thumbnail);
END_PARSE_FLAGS();
parse(video->file_name, parser);
string tmp_filename;
parse(tmp_filename, parser);
parse(video->mime_type, parser);
if ( G()->shared_config().get_option_boolean("disable_document_filenames") && (
video->mime_type.rfind("image/") == 0 ||
video->mime_type.rfind("video/") == 0 ||
video->mime_type.rfind("audio/") == 0)) {
video->file_name = "0";
} else {
video->file_name = tmp_filename;
}
parse(video->duration, parser);
parse(video->dimensions, parser);
if (parser.version() >= static_cast<int32>(Version::SupportMinithumbnails)) {
parse(video->minithumbnail, parser);
string tmp_minithumbnail;
parse(tmp_minithumbnail, parser);
if (!G()->shared_config().get_option_boolean("disable_minithumbnails")) {
video->minithumbnail = tmp_minithumbnail;
}
}
parse(video->thumbnail, parser);
parse(video->file_id, parser);