diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index b964aeeb2..038e018ce 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2582,6 +2582,9 @@ linkPreviewTypeChannelBoost photo:chatPhoto = LinkPreviewType; //@creates_join_request True, if the link only creates join request 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 //@url URL of the external audio player //@duration Duration of the audio, in seconds diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index 208c8384a..3f2e8799f 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -1473,6 +1473,24 @@ 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_ == "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(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(); + } + } + 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(std::move(document), 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 @@ -1494,7 +1512,8 @@ td_api::object_ptr WebPagesManager::get_link_preview_ty return td_api::make_object(); } } - 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 ? td_->videos_manager_->get_video_object(web_page->document_.file_id) : nullptr;