From 5c4ccdb1d6f548791f838b42b40edb51c2f101e2 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 4 Jul 2024 16:11:51 +0300 Subject: [PATCH] Add td_api::linkPreviewTypeAnimation. --- td/generate/scheme/td_api.tl | 3 +++ td/telegram/WebPagesManager.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 176b118c3..33be5dcd8 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2553,6 +2553,9 @@ webPageInstantView page_blocks:vector view_count:int32 version:int32 //@class LinkPreviewType @description Describes type of a link preview +//@description The link is a link to an animation @animation The animation @author Author of the animation +linkPreviewTypeAnimation animation:animation author:string = LinkPreviewType; + //@description The link is a link to an app at App Store or Google Play @photo Photo for the app @author Author of the app linkPreviewTypeApp photo:photo author:string = LinkPreviewType; diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index 5378aa476..db79e9dcf 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -1469,6 +1469,18 @@ td_api::object_ptr WebPagesManager::get_link_preview_ty return td_api::make_object(get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->author_); } + if (web_page->type_ == "gif" || + (web_page->document_.type == Document::Type::Animation && web_page->type_ == "document")) { + 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 { + LOG(ERROR) << "Receive animation without animation for " << web_page->url_; + return td_api::make_object(); + } + } if (web_page->type_ == "photo") { auto photo = get_photo_object(td_->file_manager_.get(), web_page->photo_); if (photo != nullptr) {