diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0fb7268f2..ef17b38f9 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2593,6 +2593,9 @@ linkPreviewTypeEmbeddedVideoPlayer url:string duration:int32 author:string width //@description The link is a link to an invoice linkPreviewTypeInvoice = LinkPreviewType; +//@description The link is a link to a photo @photo The photo @author Author of the photo +linkPreviewTypePhoto photo:photo author:string = LinkPreviewType; + //@description The link is a link to a Telegram Premium gift code linkPreviewTypePremiumGiftCode = LinkPreviewType; diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index ccf20202e..e78e71be2 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -1403,7 +1403,7 @@ td_api::object_ptr WebPagesManager::get_link_preview_ty td_->dialog_manager_->get_chat_id_object(story_sender_dialog_id, "webPage"), story_id.get()); } else { LOG(ERROR) << "Receive telegram story " << web_page->url_ << " without story"; - return td_api::make_object("unsupported_telegram_story"); + return td_api::make_object(); } } if (type == "theme") { @@ -1446,7 +1446,7 @@ td_api::object_ptr WebPagesManager::get_link_preview_ty return td_api::make_object( web_page->embed_url_, web_page->embed_type_, std::move(audio), web_page->duration_, web_page->author_); } else { - return td_api::make_object(web_page->type_); + return td_api::make_object(); } } if (web_page->type_ == "video") { @@ -1458,17 +1458,26 @@ td_api::object_ptr WebPagesManager::get_link_preview_ty web_page->embed_url_, web_page->embed_type_, std::move(video), web_page->embed_dimensions_.width, web_page->embed_dimensions_.height, web_page->duration_, web_page->author_); } else { - return td_api::make_object(web_page->type_); + return td_api::make_object(); } } } LOG(ERROR) << "Have type = " << web_page->type_ << " for embedded " << web_page->url_; - return td_api::make_object(web_page->type_); + return td_api::make_object(); } if (web_page->type_ == "app") { return td_api::make_object(get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->author_); } + if (web_page->type_ == "photo") { + auto photo = get_photo_object(td_->file_manager_.get(), web_page->photo_); + if (photo != nullptr) { + return td_api::make_object(std::move(photo), web_page->author_); + } else { + LOG(ERROR) << "Receive photo without photo for " << web_page->url_; + return td_api::make_object(); + } + } if (web_page->type_ == "video") { auto video = web_page->document_.type == Document::Type::Video ? td_->videos_manager_->get_video_object(web_page->document_.file_id)