Add td_api::linkPreviewTypePhoto.

This commit is contained in:
levlam 2024-07-04 15:26:41 +03:00
parent 14a74af9fd
commit e34f16c3bc
2 changed files with 16 additions and 4 deletions

View File

@ -2593,6 +2593,9 @@ linkPreviewTypeEmbeddedVideoPlayer url:string duration:int32 author:string width
//@description The link is a link to an invoice //@description The link is a link to an invoice
linkPreviewTypeInvoice = LinkPreviewType; 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 //@description The link is a link to a Telegram Premium gift code
linkPreviewTypePremiumGiftCode = LinkPreviewType; linkPreviewTypePremiumGiftCode = LinkPreviewType;

View File

@ -1403,7 +1403,7 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
td_->dialog_manager_->get_chat_id_object(story_sender_dialog_id, "webPage"), story_id.get()); td_->dialog_manager_->get_chat_id_object(story_sender_dialog_id, "webPage"), story_id.get());
} else { } else {
LOG(ERROR) << "Receive telegram story " << web_page->url_ << " without story"; LOG(ERROR) << "Receive telegram story " << web_page->url_ << " without story";
return td_api::make_object<td_api::linkPreviewTypeOther>("unsupported_telegram_story"); return td_api::make_object<td_api::linkPreviewTypeOther>();
} }
} }
if (type == "theme") { if (type == "theme") {
@ -1446,7 +1446,7 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
return td_api::make_object<td_api::linkPreviewTypeAudio>( return td_api::make_object<td_api::linkPreviewTypeAudio>(
web_page->embed_url_, web_page->embed_type_, std::move(audio), web_page->duration_, web_page->author_); web_page->embed_url_, web_page->embed_type_, std::move(audio), web_page->duration_, web_page->author_);
} else { } else {
return td_api::make_object<td_api::linkPreviewTypeOther>(web_page->type_); return td_api::make_object<td_api::linkPreviewTypeOther>();
} }
} }
if (web_page->type_ == "video") { if (web_page->type_ == "video") {
@ -1458,17 +1458,26 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
web_page->embed_url_, web_page->embed_type_, std::move(video), web_page->embed_dimensions_.width, 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_); web_page->embed_dimensions_.height, web_page->duration_, web_page->author_);
} else { } else {
return td_api::make_object<td_api::linkPreviewTypeOther>(web_page->type_); return td_api::make_object<td_api::linkPreviewTypeOther>();
} }
} }
} }
LOG(ERROR) << "Have type = " << web_page->type_ << " for embedded " << web_page->url_; LOG(ERROR) << "Have type = " << web_page->type_ << " for embedded " << web_page->url_;
return td_api::make_object<td_api::linkPreviewTypeOther>(web_page->type_); return td_api::make_object<td_api::linkPreviewTypeOther>();
} }
if (web_page->type_ == "app") { if (web_page->type_ == "app") {
return td_api::make_object<td_api::linkPreviewTypeApp>(get_photo_object(td_->file_manager_.get(), web_page->photo_), return td_api::make_object<td_api::linkPreviewTypeApp>(get_photo_object(td_->file_manager_.get(), web_page->photo_),
web_page->author_); 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<td_api::linkPreviewTypePhoto>(std::move(photo), web_page->author_);
} else {
LOG(ERROR) << "Receive photo without photo for " << web_page->url_;
return td_api::make_object<td_api::linkPreviewTypeOther>();
}
}
if (web_page->type_ == "video") { if (web_page->type_ == "video") {
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)