diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index dd8fa2b7c..fcc89bfd2 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2609,6 +2609,15 @@ linkPreviewTypeChat type:InviteLinkChatType photo:chatPhoto creates_join_request //@description The link is a link to a general file @document The document description @author Author of the document linkPreviewTypeDocument document:document author:string = LinkPreviewType; +//@description The link is a link to an animation player +//@url URL of the external animation player +//@thumbnail Thumbnail of the animation; may be null if unknown +//@duration Duration of the animation, in seconds +//@author Author of the animation +//@width Expected width of the embedded player +//@height Expected height of the embedded player +linkPreviewTypeEmbeddedAnimationPlayer url:string thumbnail:photo duration:int32 author:string width:int32 height:int32 = LinkPreviewType; + //@description The link is a link to an audio player //@url URL of the external audio player //@thumbnail Thumbnail of the audio; may be null if unknown diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index 293cd5ee4..66873155e 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -1545,13 +1545,18 @@ td_api::object_ptr WebPagesManager::get_link_preview_ty web_page->embed_url_, get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->duration_, web_page->author_, web_page->embed_dimensions_.width, web_page->embed_dimensions_.height); } + if (web_page->type_ == "gif") { + return td_api::make_object( + web_page->embed_url_, get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->duration_, + web_page->author_, web_page->embed_dimensions_.width, web_page->embed_dimensions_.height); + } if (web_page->type_ == "video") { return td_api::make_object( web_page->embed_url_, get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->duration_, web_page->author_, web_page->embed_dimensions_.width, web_page->embed_dimensions_.height); } } else { - // ordinary audio/video + // ordinary animation/audio/video if (web_page->type_ == "audio") { LOG_IF(ERROR, web_page->document_.type != Document::Type::Unknown && web_page->document_.type != Document::Type::Audio) @@ -1570,6 +1575,23 @@ td_api::object_ptr WebPagesManager::get_link_preview_ty return td_api::make_object(); } } + if (web_page->type_ == "gif") { + LOG_IF(ERROR, web_page->document_.type != Document::Type::Unknown && + web_page->document_.type != Document::Type::Animation) + << "Receive wrong document for " << web_page->url_; + auto animation = web_page->document_.type == Document::Type::Animation + ? td_->animations_manager_->get_animation_object(web_page->document_.file_id) + : nullptr; + if (animation != nullptr) { + return td_api::make_object(std::move(animation), web_page->author_); + } else { + if (!web_page->photo_.is_empty()) { + return td_api::make_object( + get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->author_); + } + return td_api::make_object(); + } + } if (web_page->type_ == "video") { LOG_IF(ERROR, web_page->document_.type != Document::Type::Unknown && web_page->document_.type != Document::Type::Video)