diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index f220979b..5883ba5b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -759,8 +759,8 @@ pageBlockAnimation animation:animation caption:pageBlockCaption need_autoplay:Bo //@description An audio file @audio Audio file; may be null @caption Audio file caption pageBlockAudio audio:audio caption:pageBlockCaption = PageBlock; -//@description A photo @photo Photo file; may be null @caption Photo caption -pageBlockPhoto photo:photo caption:pageBlockCaption = PageBlock; +//@description A photo @photo Photo file; may be null @caption Photo caption @url URL associated with the photo +pageBlockPhoto photo:photo caption:pageBlockCaption url:string = PageBlock; //@description A video @video Video file; may be null @caption Video caption @need_autoplay True, if the video should be played automatically @is_looped True, if the video should be looped pageBlockVideo video:video caption:pageBlockCaption need_autoplay:Bool is_looped:Bool = PageBlock; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 2eb4255c..f1b64135 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/Version.h b/td/telegram/Version.h index 681fc18f..41f8a19b 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -27,7 +27,7 @@ enum class Version : int32 { AddTermsOfService, AddContactVcard, AddMessageUnsupportedVersion, - InstantView2_0Support, + SupportInstantView2_0, Next }; diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index 38ce3cef..6a60346e 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -469,7 +469,7 @@ class WebPagesManager::PageBlockCaption { void parse(T &parser) { using ::td::parse; parse(text, parser); - if (parser.version() >= static_cast(Version::InstantView2_0Support)) { + if (parser.version() >= static_cast(Version::SupportInstantView2_0)) { parse(credit, parser); } else { credit = RichText(); @@ -1097,10 +1097,13 @@ class WebPagesManager::PageBlockAnimation : public PageBlock { class WebPagesManager::PageBlockPhoto : public PageBlock { Photo photo; PageBlockCaption caption; + string url; + WebPageId web_page_id; public: PageBlockPhoto() = default; - PageBlockPhoto(Photo photo, PageBlockCaption &&caption) : photo(std::move(photo)), caption(std::move(caption)) { + PageBlockPhoto(Photo photo, PageBlockCaption &&caption, string &&url, WebPageId web_page_id) + : photo(std::move(photo)), caption(std::move(caption)), url(std::move(url)), web_page_id(web_page_id) { } Type get_type() const override { @@ -1114,7 +1117,7 @@ class WebPagesManager::PageBlockPhoto : public PageBlock { tl_object_ptr get_page_block_object() const override { return make_tl_object( get_photo_object(G()->td().get_actor_unsafe()->file_manager_.get(), &photo), - get_page_block_caption_object(caption)); + get_page_block_caption_object(caption), url); } template @@ -1122,6 +1125,8 @@ class WebPagesManager::PageBlockPhoto : public PageBlock { using ::td::store; store(photo, storer); store(caption, storer); + store(url, storer); + store(web_page_id, storer); } template @@ -1129,6 +1134,13 @@ class WebPagesManager::PageBlockPhoto : public PageBlock { using ::td::parse; parse(photo, parser); parse(caption, parser); + if (parser.version() >= static_cast(Version::SupportInstantView2_0)) { + parse(url, parser); + parse(web_page_id, parser); + } else { + url.clear(); + web_page_id = WebPageId(); + } } }; @@ -2695,8 +2707,15 @@ unique_ptr WebPagesManager::get_page_block( } else { photo = it->second; } - return make_unique(std::move(photo), - get_page_block_caption(std::move(page_block->caption_), documents)); + string url; + WebPageId web_page_id; + if ((page_block->flags_ & telegram_api::pageBlockPhoto::URL_MASK) != 0) { + url = std::move(page_block->url_); + web_page_id = WebPageId(page_block->webpage_id_); + } + return td::make_unique(std::move(photo), + get_page_block_caption(std::move(page_block->caption_), documents), + std::move(url), web_page_id); } case telegram_api::pageBlockVideo::ID: { auto page_block = move_tl_object_as(page_block_ptr);