Support "document" link preview type.
This commit is contained in:
parent
d193456bf2
commit
70d6969b8a
@ -2582,6 +2582,9 @@ linkPreviewTypeChannelBoost photo:chatPhoto = LinkPreviewType;
|
|||||||
//@creates_join_request True, if the link only creates join request
|
//@creates_join_request True, if the link only creates join request
|
||||||
linkPreviewTypeChat type:InviteLinkChatType photo:chatPhoto creates_join_request:Bool = LinkPreviewType;
|
linkPreviewTypeChat type:InviteLinkChatType photo:chatPhoto creates_join_request:Bool = LinkPreviewType;
|
||||||
|
|
||||||
|
//@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 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
|
||||||
//@duration Duration of the audio, in seconds
|
//@duration Duration of the audio, in seconds
|
||||||
|
@ -1473,6 +1473,24 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
|
|||||||
return td_api::make_object<td_api::linkPreviewTypeArticle>(
|
return td_api::make_object<td_api::linkPreviewTypeArticle>(
|
||||||
get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->author_);
|
get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->author_);
|
||||||
}
|
}
|
||||||
|
if (web_page->type_ == "audio" ||
|
||||||
|
(web_page->document_.type == Document::Type::Audio && web_page->type_ == "document")) {
|
||||||
|
auto audio = web_page->document_.type == Document::Type::Audio
|
||||||
|
? td_->audios_manager_->get_audio_object(web_page->document_.file_id)
|
||||||
|
: nullptr;
|
||||||
|
if (audio != nullptr) {
|
||||||
|
auto duration = audio->duration_;
|
||||||
|
return td_api::make_object<td_api::linkPreviewTypeAudio>(string(), string(), std::move(audio), duration,
|
||||||
|
web_page->author_);
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Receive audio without audio for " << web_page->url_;
|
||||||
|
return td_api::make_object<td_api::linkPreviewTypeUnsupported>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (web_page->document_.type == Document::Type::General && web_page->type_ == "document") {
|
||||||
|
auto document = td_->documents_manager_->get_document_object(web_page->document_.file_id, PhotoFormat::Jpeg);
|
||||||
|
return td_api::make_object<td_api::linkPreviewTypeDocument>(std::move(document), web_page->author_);
|
||||||
|
}
|
||||||
if (web_page->type_ == "gif" ||
|
if (web_page->type_ == "gif" ||
|
||||||
(web_page->document_.type == Document::Type::Animation && web_page->type_ == "document")) {
|
(web_page->document_.type == Document::Type::Animation && web_page->type_ == "document")) {
|
||||||
auto animation = web_page->document_.type == Document::Type::Animation
|
auto animation = web_page->document_.type == Document::Type::Animation
|
||||||
@ -1494,7 +1512,8 @@ 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_ == "video") {
|
if (web_page->type_ == "video" ||
|
||||||
|
(web_page->document_.type == Document::Type::Video && web_page->type_ == "document")) {
|
||||||
auto video = web_page->document_.type == Document::Type::Video
|
auto video = web_page->document_.type == Document::Type::Video
|
||||||
? td_->videos_manager_->get_video_object(web_page->document_.file_id)
|
? td_->videos_manager_->get_video_object(web_page->document_.file_id)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user