Add td_api::linkPreviewTypeStory.

This commit is contained in:
levlam 2024-07-03 16:40:32 +03:00
parent 6b408d486c
commit 2ae48540b1
2 changed files with 17 additions and 10 deletions

View File

@ -2565,6 +2565,9 @@ linkPreviewTypeShareableChatFolder = LinkPreviewType;
//@description The link is a link to a sticker set @stickers Up to 4 stickers from the sticker set
linkPreviewTypeStickerSet stickers:vector<sticker> = LinkPreviewType;
//@description The link is a link to a story @story_sender_chat_id The identifier of the chat that posted the story @story_id Story identifier
linkPreviewTypeStory story_sender_chat_id:int53 story_id:int32 = LinkPreviewType;
//@description The link is a link to a cloud theme. TDLib has no theme support yet @documents The list of files with theme description
linkPreviewTypeTheme documents:vector<document> = LinkPreviewType;
@ -2597,10 +2600,8 @@ linkPreviewTypeOther type:string = LinkPreviewType;
//@video Preview of the content as a video, if available; may be null
//@video_note Preview of the content as a video note, if available; may be null
//@voice_note Preview of the content as a voice note, if available; may be null
//@story_sender_chat_id The identifier of the sender of the previewed story; 0 if none
//@story_id The identifier of the previewed story; 0 if none
//@instant_view_version Version of instant view (currently, can be 1 or 2) for the web page; 0 if none
linkPreview url:string display_url:string site_name:string title:string description:formattedText type:LinkPreviewType photo:photo embed_url:string embed_type:string embed_width:int32 embed_height:int32 duration:int32 author:string has_large_media:Bool show_large_media:Bool skip_confirmation:Bool show_above_text:Bool animation:animation audio:audio document:document sticker:sticker video:video video_note:videoNote voice_note:voiceNote story_sender_chat_id:int53 story_id:int32 instant_view_version:int32 = LinkPreview;
linkPreview url:string display_url:string site_name:string title:string description:formattedText type:LinkPreviewType photo:photo embed_url:string embed_type:string embed_width:int32 embed_height:int32 duration:int32 author:string has_large_media:Bool show_large_media:Bool skip_confirmation:Bool show_above_text:Bool animation:animation audio:audio document:document sticker:sticker video:video video_note:videoNote voice_note:voiceNote instant_view_version:int32 = LinkPreview;
//@description Contains information about a country

View File

@ -1355,6 +1355,19 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
});
return td_api::make_object<td_api::linkPreviewTypeStickerSet>(std::move(stickers));
}
if (type == "story") {
DialogId story_sender_dialog_id;
StoryId story_id;
if (web_page->story_full_ids_.size() == 1) {
story_sender_dialog_id = web_page->story_full_ids_[0].get_dialog_id();
story_id = web_page->story_full_ids_[0].get_story_id();
td_api::make_object<td_api::linkPreviewTypeStory>(
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<td_api::linkPreviewTypeOther>("unsupported_telegram_story");
}
}
if (type == "theme") {
vector<td_api::object_ptr<td_api::document>> documents;
for (auto &document : web_page->documents_) {
@ -1467,12 +1480,6 @@ td_api::object_ptr<td_api::linkPreview> WebPagesManager::get_link_preview_object
}
auto duration = get_web_page_media_duration(web_page);
DialogId story_sender_dialog_id;
StoryId story_id;
if (web_page->story_full_ids_.size() == 1) {
story_sender_dialog_id = web_page->story_full_ids_[0].get_dialog_id();
story_id = web_page->story_full_ids_[0].get_story_id();
}
auto show_large_media = [&] {
if (web_page->document_.type == Document::Type::Audio || web_page->document_.type == Document::Type::VoiceNote ||
web_page->document_.type == Document::Type::General) {
@ -1535,7 +1542,6 @@ td_api::object_ptr<td_api::linkPreview> WebPagesManager::get_link_preview_object
web_page->document_.type == Document::Type::VoiceNote
? td_->voice_notes_manager_->get_voice_note_object(web_page->document_.file_id)
: nullptr,
td_->dialog_manager_->get_chat_id_object(story_sender_dialog_id, "webPage"), story_id.get(),
instant_view_version);
}