diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a3a6d1fd3..afa962f5c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -219,18 +219,6 @@ thumbnailFormatWebp = ThumbnailFormat; thumbnail format:ThumbnailFormat width:int32 height:int32 file:file = Thumbnail; -//@class StickerFormat @description Describes format of a sticker - -//@description The sticker is in TGS format -stickerFormatTgs = StickerFormat; - -//@description The sticker is in WEBM format -stickerFormatWebm = StickerFormat; - -//@description The sticker is in WEBP format -stickerFormatWebp = StickerFormat; - - //@class MaskPoint @description Part of the face, relative to which a mask is placed //@description The mask is placed relatively to the forehead @@ -252,6 +240,21 @@ maskPointChin = MaskPoint; maskPosition point:MaskPoint x_shift:double y_shift:double scale:double = MaskPosition; +//@class StickerFormat @description Describes format of a sticker + +//@description The sticker is in TGS format +stickerFormatTgs = StickerFormat; + +//@description The sticker is in WEBM format +stickerFormatWebm = StickerFormat; + +//@description The sticker is in WEBP format +stickerFormatWebp = StickerFormat; + +//@description The sticker is a mask in WEBP format to be placed on photos or videos @mask_position Position where the mask is placed; may be null +stickerFormatWebpMask mask_position:maskPosition = StickerFormat; + + //@description Represents a closed vector path. The path begins at the end point of the last command @commands List of vector path commands closedVectorPath commands:vector = ClosedVectorPath; @@ -292,9 +295,9 @@ document file_name:string mime_type:string minithumbnail:minithumbnail thumbnail photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector = Photo; //@description Describes a sticker @set_id The identifier of the sticker set to which the sticker belongs; 0 if none @width Sticker width; as defined by the sender @height Sticker height; as defined by the sender -//@emoji Emoji corresponding to the sticker @format Sticker format @is_mask True, if the sticker is a mask @mask_position Position where the mask is placed; may be null -//@outline Sticker's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner @thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker -sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat is_mask:Bool mask_position:maskPosition outline:vector thumbnail:thumbnail sticker:file = Sticker; +//@emoji Emoji corresponding to the sticker @format Sticker format @outline Sticker's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner +//@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker +sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat outline:vector thumbnail:thumbnail sticker:file = Sticker; //@description Describes a video file @duration Duration of the video, in seconds; as defined by the sender @width Video width; as defined by the sender @height Video height; as defined by the sender //@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file; as defined by the sender @@ -2191,17 +2194,17 @@ emojis emojis:vector = Emojis; //@id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @thumbnail Sticker set thumbnail in WEBP or TGS format with width and height 100; may be null. The file can be downloaded only before the thumbnail is changed //@thumbnail_outline Sticker set thumbnail's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner //@is_installed True, if the sticker set has been installed by the current user @is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously -//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_masks True, if the stickers in the set are masks @is_viewed True for already viewed trending sticker sets +//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_viewed True for already viewed trending sticker sets //@stickers List of stickers in this set @emojis A list of emoji corresponding to the stickers in the same order. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object -stickerSet id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_masks:Bool is_viewed:Bool stickers:vector emojis:vector = StickerSet; +stickerSet id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_viewed:Bool stickers:vector emojis:vector = StickerSet; //@description Represents short information about a sticker set //@id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @thumbnail Sticker set thumbnail in WEBP or TGS format with width and height 100; may be null //@thumbnail_outline Sticker set thumbnail's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner //@is_installed True, if the sticker set has been installed by the current user @is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously -//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_masks True, if the stickers in the set are masks @is_viewed True for already viewed trending sticker sets +//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_viewed True for already viewed trending sticker sets //@size Total number of stickers in the set @covers Up to the first 5 stickers from the set, depending on the context. If the application needs more stickers the full sticker set needs to be requested -stickerSetInfo id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_masks:Bool is_viewed:Bool size:int32 covers:vector = StickerSetInfo; +stickerSetInfo id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_viewed:Bool size:int32 covers:vector = StickerSetInfo; //@description Represents a list of sticker sets @total_count Approximate total number of sticker sets found @sets List of sticker sets stickerSets total_count:int32 sets:vector = StickerSets; diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index f97847c50..e134fe4eb 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -975,21 +975,6 @@ tl_object_ptr copy(const td_api::thumbnail &obj) { return td_api::make_object(std::move(format), obj.width_, obj.height_, copy(obj.file_)); } -template <> -tl_object_ptr copy(const td_api::StickerFormat &obj) { - switch (obj.get_id()) { - case td_api::stickerFormatWebp::ID: - return td_api::make_object(); - case td_api::stickerFormatTgs::ID: - return td_api::make_object(); - case td_api::stickerFormatWebm::ID: - return td_api::make_object(); - default: - UNREACHABLE(); - } - return nullptr; -} - template <> tl_object_ptr copy(const td_api::MaskPoint &obj) { switch (obj.get_id()) { @@ -1012,6 +997,25 @@ tl_object_ptr copy(const td_api::maskPosition &obj) { return td_api::make_object(copy(obj.point_), obj.x_shift_, obj.y_shift_, obj.scale_); } +template <> +tl_object_ptr copy(const td_api::StickerFormat &obj) { + switch (obj.get_id()) { + case td_api::stickerFormatWebp::ID: + return td_api::make_object(); + case td_api::stickerFormatTgs::ID: + return td_api::make_object(); + case td_api::stickerFormatWebm::ID: + return td_api::make_object(); + case td_api::stickerFormatWebpMask::ID: { + auto &mask_position = static_cast(obj).mask_position_; + return td_api::make_object(copy(mask_position)); + } + default: + UNREACHABLE(); + } + return nullptr; +} + template <> tl_object_ptr copy(const td_api::point &obj) { return td_api::make_object(obj.x_, obj.y_); @@ -1078,9 +1082,9 @@ tl_object_ptr copy(const td_api::photo &obj) { template <> tl_object_ptr copy(const td_api::sticker &obj) { - return td_api::make_object( - obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_), obj.is_mask_, copy(obj.mask_position_), - transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_), copy(obj.sticker_)); + return td_api::make_object(obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_), + transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_), + copy(obj.sticker_)); } template <> diff --git a/td/telegram/StickerFormat.cpp b/td/telegram/StickerFormat.cpp index c7f453870..e29c8723c 100644 --- a/td/telegram/StickerFormat.cpp +++ b/td/telegram/StickerFormat.cpp @@ -23,12 +23,16 @@ StickerFormat get_sticker_format(Slice mime_type) { return StickerFormat::Unknown; } -td_api::object_ptr get_sticker_format_object(StickerFormat sticker_format) { +td_api::object_ptr get_sticker_format_object( + StickerFormat sticker_format, bool is_masks, td_api::object_ptr mask_position) { switch (sticker_format) { case StickerFormat::Unknown: LOG(ERROR) << "Have a sticker of unknown format"; return td_api::make_object(); case StickerFormat::Webp: + if (is_masks) { + return td_api::make_object(std::move(mask_position)); + } return td_api::make_object(); case StickerFormat::Tgs: return td_api::make_object(); diff --git a/td/telegram/StickerFormat.h b/td/telegram/StickerFormat.h index f3eec756b..73a7ff9bf 100644 --- a/td/telegram/StickerFormat.h +++ b/td/telegram/StickerFormat.h @@ -19,7 +19,8 @@ enum class StickerFormat : int32 { Unknown, Webp, Tgs, Webm }; StickerFormat get_sticker_format(Slice mime_type); -td_api::object_ptr get_sticker_format_object(StickerFormat sticker_format); +td_api::object_ptr get_sticker_format_object( + StickerFormat sticker_format, bool is_masks, td_api::object_ptr mask_position); string get_sticker_format_mime_type(StickerFormat sticker_format); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index e4d495b8c..d66d24bbc 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1851,8 +1851,9 @@ tl_object_ptr StickersManager::get_sticker_object(FileId file_i height = static_cast(height * zoom + 0.5); } return make_tl_object( - sticker->set_id.get(), width, height, sticker->alt, get_sticker_format_object(sticker->format), sticker->is_mask, - std::move(mask_position), get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom), + sticker->set_id.get(), width, height, sticker->alt, + get_sticker_format_object(sticker->format, sticker->is_mask, std::move(mask_position)), + get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom), std::move(thumbnail_object), td_->file_manager_->get_file_object(file_id)); } @@ -1975,7 +1976,7 @@ tl_object_ptr StickersManager::get_sticker_set_object(Sticke sticker_set->id.get(), sticker_set->title, sticker_set->short_name, std::move(thumbnail), get_sticker_minithumbnail(sticker_set->minithumbnail, sticker_set->id, -2, 1.0), sticker_set->is_installed && !sticker_set->is_archived, sticker_set->is_archived, sticker_set->is_official, - get_sticker_format_object(sticker_set->sticker_format), sticker_set->is_masks, sticker_set->is_viewed, + get_sticker_format_object(sticker_set->sticker_format, sticker_set->is_masks, nullptr), sticker_set->is_viewed, std::move(stickers), std::move(emojis)); } @@ -2022,7 +2023,7 @@ tl_object_ptr StickersManager::get_sticker_set_info_obje sticker_set->id.get(), sticker_set->title, sticker_set->short_name, std::move(thumbnail), get_sticker_minithumbnail(sticker_set->minithumbnail, sticker_set->id, -3, 1.0), sticker_set->is_installed && !sticker_set->is_archived, sticker_set->is_archived, sticker_set->is_official, - get_sticker_format_object(sticker_set->sticker_format), sticker_set->is_masks, sticker_set->is_viewed, + get_sticker_format_object(sticker_set->sticker_format, sticker_set->is_masks, nullptr), sticker_set->is_viewed, sticker_set->was_loaded ? narrow_cast(sticker_set->sticker_ids.size()) : sticker_set->sticker_count, std::move(stickers)); }