From 35058bb6a7bcf657b375e1ce139912059484cb21 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 25 Sep 2022 23:40:42 +0300 Subject: [PATCH] Add animatedEmoji.sticker_width/sticker_height. --- td/generate/scheme/td_api.tl | 4 +++- td/telegram/StickersManager.cpp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 022344bfa..5180d5e29 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -334,9 +334,11 @@ voiceNote duration:int32 waveform:bytes mime_type:string speech_recognition_resu //@description Describes an animated or custom representation of an emoji //@sticker Sticker for the emoji; may be null if yet unknown for a custom emoji. If the sticker is a custom emoji, it can have arbitrary format different from stickerFormatTgs +//@sticker_width Expected width of the sticker, which can be used if the sticker is null +//@sticker_height Expected height of the sticker, which can be used if the sticker is null //@fitzpatrick_type Emoji modifier fitzpatrick type; 0-6; 0 if none //@sound File containing the sound to be played when the sticker is clicked; may be null. The sound is encoded with the Opus codec, and stored inside an OGG container -animatedEmoji sticker:sticker fitzpatrick_type:int32 sound:file = AnimatedEmoji; +animatedEmoji sticker:sticker sticker_width:int32 sticker_height:int32 fitzpatrick_type:int32 sound:file = AnimatedEmoji; //@description Describes a user contact @phone_number Phone number of the user @first_name First name of the user; 1-255 characters in length @last_name Last name of the user @vcard Additional data about the user in a form of vCard; 0-2048 bytes in length @user_id Identifier of the user, if known; otherwise 0 contact phone_number:string first_name:string last_name:string vcard:string user_id:int53 = Contact; diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index e53c0b0c7..9bd372583 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -2600,7 +2600,11 @@ td_api::object_ptr StickersManager::get_animated_emoji_ob auto it = custom_emoji_messages_.find(custom_emoji_id); auto sticker_id = it == custom_emoji_messages_.end() ? get_custom_animated_emoji_sticker_id(custom_emoji_id) : it->second->sticker_id_; - return td_api::make_object(get_sticker_object(sticker_id, true), 0, nullptr); + auto sticker = get_sticker_object(sticker_id, true); + auto default_custom_emoji_dimension = static_cast(512 * animated_emoji_zoom_ + 0.5); + auto sticker_width = sticker == nullptr ? default_custom_emoji_dimension : sticker->width_; + auto sticker_height = sticker == nullptr ? default_custom_emoji_dimension : sticker->height_; + return td_api::make_object(std::move(sticker), sticker_width, sticker_height, 0, nullptr); } auto it = emoji_messages_.find(emoji); @@ -2616,8 +2620,12 @@ td_api::object_ptr StickersManager::get_animated_emoji_ob if (!animated_sticker.first.is_valid()) { return nullptr; } + auto sticker = get_sticker_object(animated_sticker.first, true); + CHECK(sticker != nullptr); + auto sticker_width = sticker->width_; + auto sticker_height = sticker->height_; return td_api::make_object( - get_sticker_object(animated_sticker.first, true), animated_sticker.second, + std::move(sticker), sticker_width, sticker_height, animated_sticker.second, sound_file_id.is_valid() ? td_->file_manager_->get_file_object(sound_file_id) : nullptr); }