diff --git a/td/telegram/DocumentsManager.cpp b/td/telegram/DocumentsManager.cpp index 79d90127f..7cc9e8a64 100644 --- a/td/telegram/DocumentsManager.cpp +++ b/td/telegram/DocumentsManager.cpp @@ -21,6 +21,7 @@ #include "td/telegram/secret_api.h" #include "td/telegram/StickerFormat.h" #include "td/telegram/StickersManager.h" +#include "td/telegram/StickerType.h" #include "td/telegram/Td.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" @@ -422,7 +423,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo default_extension = Slice("webm"); } if (file_type == FileType::Encrypted && document_type == Document::Type::Sticker && - size > get_max_sticker_file_size(sticker_format, false)) { + size > get_max_sticker_file_size(sticker_format, StickerType::Regular, false)) { document_type = Document::Type::General; } diff --git a/td/telegram/StickerFormat.cpp b/td/telegram/StickerFormat.cpp index 8e5a678c7..c0d471334 100644 --- a/td/telegram/StickerFormat.cpp +++ b/td/telegram/StickerFormat.cpp @@ -146,15 +146,16 @@ bool is_sticker_format_vector(StickerFormat sticker_format) { } } -int64 get_max_sticker_file_size(StickerFormat sticker_format, bool for_thumbnail) { +int64 get_max_sticker_file_size(StickerFormat sticker_format, StickerType sticker_type, bool for_thumbnail) { + bool is_emoji = sticker_type == StickerType::Emoji; switch (sticker_format) { case StickerFormat::Unknown: case StickerFormat::Webp: - return for_thumbnail ? (1 << 17) : (1 << 19); + return for_thumbnail ? (1 << 17) : (is_emoji ? (1 << 17) : (1 << 19)); case StickerFormat::Tgs: return for_thumbnail ? (1 << 15) : (1 << 16); case StickerFormat::Webm: - return for_thumbnail ? (1 << 15) : (1 << 18); + return for_thumbnail ? (1 << 15) : (is_emoji ? (1 << 16) : (1 << 18)); default: UNREACHABLE(); return 0; diff --git a/td/telegram/StickerFormat.h b/td/telegram/StickerFormat.h index 5b3110f53..27dfa929d 100644 --- a/td/telegram/StickerFormat.h +++ b/td/telegram/StickerFormat.h @@ -7,6 +7,7 @@ #pragma once #include "td/telegram/PhotoFormat.h" +#include "td/telegram/StickerType.h" #include "td/telegram/td_api.h" #include "td/utils/common.h" @@ -36,7 +37,7 @@ bool is_sticker_format_animated(StickerFormat sticker_format); bool is_sticker_format_vector(StickerFormat sticker_format); -int64 get_max_sticker_file_size(StickerFormat sticker_format, bool for_thumbnail); +int64 get_max_sticker_file_size(StickerFormat sticker_format, StickerType sticker_type, bool for_thumbnail); StringBuilder &operator<<(StringBuilder &string_builder, StickerFormat sticker_format); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 001346aa7..48c3903d9 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -6028,11 +6028,12 @@ Result> StickersManager::prepare_i return Status::Error(400, "Sticker format must be non-empty"); } - return prepare_input_file(sticker->sticker_, get_sticker_format(sticker->format_), false); + return prepare_input_file(sticker->sticker_, get_sticker_format(sticker->format_), get_sticker_type(sticker->type_), + false); } Result> StickersManager::prepare_input_file( - const tl_object_ptr &input_file, StickerFormat format, bool for_thumbnail) { + const tl_object_ptr &input_file, StickerFormat format, StickerType type, bool for_thumbnail) { auto file_type = format == StickerFormat::Tgs ? FileType::Sticker : FileType::Document; auto r_file_id = td_->file_manager_->get_input_file_id(file_type, input_file, DialogId(), for_thumbnail, false); if (r_file_id.is_error()) { @@ -6070,7 +6071,7 @@ Result> StickersManager::prepare_i is_url = true; } else { if (file_view.has_local_location() && - file_view.expected_size() > get_max_sticker_file_size(format, for_thumbnail)) { + file_view.expected_size() > get_max_sticker_file_size(format, type, for_thumbnail)) { return Status::Error(400, "File is too big"); } is_local = true; @@ -6547,7 +6548,7 @@ void StickersManager::do_set_sticker_set_thumbnail(UserId user_id, string short_ return promise.set_error(Status::Error(400, "Sticker set not found")); } - auto r_file_id = prepare_input_file(thumbnail, sticker_set->sticker_format, true); + auto r_file_id = prepare_input_file(thumbnail, sticker_set->sticker_format, sticker_set->sticker_type, true); if (r_file_id.is_error()) { return promise.set_error(r_file_id.move_as_error()); } diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 024cb4e34..516021810 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -668,7 +668,7 @@ class StickersManager final : public Actor { std::pair, vector> split_stickers_by_premium(const vector &sticker_ids) const; Result> prepare_input_file( - const tl_object_ptr &input_file, StickerFormat format, bool for_thumbnail); + const tl_object_ptr &input_file, StickerFormat format, StickerType type, bool for_thumbnail); Result> prepare_input_sticker(td_api::inputSticker *sticker);