Remove expect_jpeg_minithumbnail parameter from get_photo_size.

This commit is contained in:
levlam 2021-03-01 23:29:55 +03:00
parent 1d9b817c9f
commit 8430ba6d19
4 changed files with 12 additions and 12 deletions

View File

@ -265,9 +265,9 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
if (document_type != Document::Type::VoiceNote) { if (document_type != Document::Type::VoiceNote) {
for (auto &thumb : document->thumbs_) { for (auto &thumb : document->thumbs_) {
auto photo_size = get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, id, access_hash, auto photo_size =
file_reference, DcId::create(dc_id), owner_dialog_id, std::move(thumb), get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, id, access_hash, file_reference,
thumbnail_format, document_type != Document::Type::Sticker); DcId::create(dc_id), owner_dialog_id, std::move(thumb), thumbnail_format);
if (photo_size.get_offset() == 0) { if (photo_size.get_offset() == 0) {
if (!thumbnail.file_id.is_valid()) { if (!thumbnail.file_id.is_valid()) {
thumbnail = std::move(photo_size.get<0>()); thumbnail = std::move(photo_size.get<0>());

View File

@ -359,7 +359,7 @@ PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id, Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id,
int64 access_hash, std::string file_reference, DcId dc_id, int64 access_hash, std::string file_reference, DcId dc_id,
DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr, DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr,
PhotoFormat format, bool expect_jpeg_minithumbnail) { PhotoFormat format) {
CHECK(size_ptr != nullptr); CHECK(size_ptr != nullptr);
tl_object_ptr<telegram_api::fileLocationToBeDeprecated> location; tl_object_ptr<telegram_api::fileLocationToBeDeprecated> location;
@ -394,8 +394,8 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSo
} }
case telegram_api::photoStrippedSize::ID: { case telegram_api::photoStrippedSize::ID: {
auto size = move_tl_object_as<telegram_api::photoStrippedSize>(size_ptr); auto size = move_tl_object_as<telegram_api::photoStrippedSize>(size_ptr);
if (!expect_jpeg_minithumbnail) { if (format != PhotoFormat::Jpeg) {
LOG(ERROR) << "Receive unexpected JPEG minithumbnail"; LOG(ERROR) << "Receive unexpected JPEG minithumbnail in photo of format " << format;
return std::move(res); return std::move(res);
} }
return size->bytes_.as_slice().str(); return size->bytes_.as_slice().str();
@ -420,8 +420,8 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSo
} }
case telegram_api::photoPathSize::ID: { case telegram_api::photoPathSize::ID: {
auto size = move_tl_object_as<telegram_api::photoPathSize>(size_ptr); auto size = move_tl_object_as<telegram_api::photoPathSize>(size_ptr);
if (expect_jpeg_minithumbnail) { if (format != PhotoFormat::Tgs && format != PhotoFormat::Webp) {
LOG(ERROR) << "Receive unexpected SVG minithumbnail"; LOG(ERROR) << "Receive unexpected SVG minithumbnail in photo of format " << format;
return std::move(res); return std::move(res);
} }
return size->bytes_.as_slice().str(); return size->bytes_.as_slice().str();
@ -717,7 +717,7 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
for (auto &size_ptr : photo->sizes_) { for (auto &size_ptr : photo->sizes_) {
auto photo_size = get_photo_size(file_manager, {FileType::Photo, 0}, photo->id_, photo->access_hash_, auto photo_size = get_photo_size(file_manager, {FileType::Photo, 0}, photo->id_, photo->access_hash_,
photo->file_reference_.as_slice().str(), dc_id, owner_dialog_id, photo->file_reference_.as_slice().str(), dc_id, owner_dialog_id,
std::move(size_ptr), PhotoFormat::Jpeg, true); std::move(size_ptr), PhotoFormat::Jpeg);
if (photo_size.get_offset() == 0) { if (photo_size.get_offset() == 0) {
PhotoSize &size = photo_size.get<0>(); PhotoSize &size = photo_size.get<0>();
if (size.type == 0 || size.type == 't' || size.type == 'i' || size.type == 'u' || size.type == 'v') { if (size.type == 0 || size.type == 't' || size.type == 'i' || size.type == 'u' || size.type == 'v') {

View File

@ -113,7 +113,7 @@ PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id, Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id,
int64 access_hash, string file_reference, DcId dc_id, int64 access_hash, string file_reference, DcId dc_id,
DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr, DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr,
PhotoFormat format, bool expect_jpeg_minithumbnail); PhotoFormat format);
AnimationSize get_animation_size(FileManager *file_manager, PhotoSizeSource source, int64 id, int64 access_hash, AnimationSize get_animation_size(FileManager *file_manager, PhotoSizeSource source, int64 id, int64 access_hash,
string file_reference, DcId dc_id, DialogId owner_dialog_id, string file_reference, DcId dc_id, DialogId owner_dialog_id,
tl_object_ptr<telegram_api::videoSize> &&size); tl_object_ptr<telegram_api::videoSize> &&size);

View File

@ -1888,7 +1888,7 @@ std::pair<int64, FileId> StickersManager::on_get_sticker_document(
auto photo_size = auto photo_size =
get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, document_id, document->access_hash_, get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, document_id, document->access_hash_,
document->file_reference_.as_slice().str(), dc_id, DialogId(), std::move(thumb), document->file_reference_.as_slice().str(), dc_id, DialogId(), std::move(thumb),
has_webp_thumbnail(sticker) ? PhotoFormat::Webp : PhotoFormat::Jpeg, false); has_webp_thumbnail(sticker) ? PhotoFormat::Webp : PhotoFormat::Jpeg);
if (photo_size.get_offset() == 0) { if (photo_size.get_offset() == 0) {
if (!thumbnail.file_id.is_valid()) { if (!thumbnail.file_id.is_valid()) {
thumbnail = std::move(photo_size.get<0>()); thumbnail = std::move(photo_size.get<0>());
@ -2420,7 +2420,7 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::sti
for (auto &thumb : set->thumbs_) { for (auto &thumb : set->thumbs_) {
auto photo_size = get_photo_size(td_->file_manager_.get(), {set_id.get(), s->access_hash}, 0, 0, "", auto photo_size = get_photo_size(td_->file_manager_.get(), {set_id.get(), s->access_hash}, 0, 0, "",
DcId::create(set->thumb_dc_id_), DialogId(), std::move(thumb), DcId::create(set->thumb_dc_id_), DialogId(), std::move(thumb),
is_animated ? PhotoFormat::Tgs : PhotoFormat::Webp, false); is_animated ? PhotoFormat::Tgs : PhotoFormat::Webp);
if (photo_size.get_offset() == 0) { if (photo_size.get_offset() == 0) {
if (!thumbnail.file_id.is_valid()) { if (!thumbnail.file_id.is_valid()) {
thumbnail = std::move(photo_size.get<0>()); thumbnail = std::move(photo_size.get<0>());