Support embedded animations.
This commit is contained in:
parent
65057a9802
commit
fa4c3082b1
@ -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
|
//@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;
|
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
|
//@description The link is a link to an audio player
|
||||||
//@url URL of the external audio player
|
//@url URL of the external audio player
|
||||||
//@thumbnail Thumbnail of the audio; may be null if unknown
|
//@thumbnail Thumbnail of the audio; may be null if unknown
|
||||||
|
@ -1545,13 +1545,18 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
|
|||||||
web_page->embed_url_, get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->duration_,
|
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);
|
web_page->author_, web_page->embed_dimensions_.width, web_page->embed_dimensions_.height);
|
||||||
}
|
}
|
||||||
|
if (web_page->type_ == "gif") {
|
||||||
|
return td_api::make_object<td_api::linkPreviewTypeEmbeddedAnimationPlayer>(
|
||||||
|
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") {
|
if (web_page->type_ == "video") {
|
||||||
return td_api::make_object<td_api::linkPreviewTypeEmbeddedVideoPlayer>(
|
return td_api::make_object<td_api::linkPreviewTypeEmbeddedVideoPlayer>(
|
||||||
web_page->embed_url_, get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->duration_,
|
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);
|
web_page->author_, web_page->embed_dimensions_.width, web_page->embed_dimensions_.height);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ordinary audio/video
|
// ordinary animation/audio/video
|
||||||
if (web_page->type_ == "audio") {
|
if (web_page->type_ == "audio") {
|
||||||
LOG_IF(ERROR,
|
LOG_IF(ERROR,
|
||||||
web_page->document_.type != Document::Type::Unknown && web_page->document_.type != Document::Type::Audio)
|
web_page->document_.type != Document::Type::Unknown && web_page->document_.type != Document::Type::Audio)
|
||||||
@ -1570,6 +1575,23 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
|
|||||||
return td_api::make_object<td_api::linkPreviewTypeUnsupported>();
|
return td_api::make_object<td_api::linkPreviewTypeUnsupported>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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<td_api::linkPreviewTypeAnimation>(std::move(animation), web_page->author_);
|
||||||
|
} else {
|
||||||
|
if (!web_page->photo_.is_empty()) {
|
||||||
|
return td_api::make_object<td_api::linkPreviewTypePhoto>(
|
||||||
|
get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->author_);
|
||||||
|
}
|
||||||
|
return td_api::make_object<td_api::linkPreviewTypeUnsupported>();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (web_page->type_ == "video") {
|
if (web_page->type_ == "video") {
|
||||||
LOG_IF(ERROR,
|
LOG_IF(ERROR,
|
||||||
web_page->document_.type != Document::Type::Unknown && web_page->document_.type != Document::Type::Video)
|
web_page->document_.type != Document::Type::Unknown && web_page->document_.type != Document::Type::Video)
|
||||||
|
Loading…
Reference in New Issue
Block a user