From 9d81e827210b9bc1c636bec0aef4ae167be8fe9c Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 6 Feb 2019 21:00:00 +0300 Subject: [PATCH] Support pageBlockPhoto URL. GitOrigin-RevId: 12c91546ccfe87f3fa995933dea81a705f5009c0 --- td/generate/scheme/td_api.tl | 4 ++-- td/generate/scheme/td_api.tlo | Bin 141660 -> 141688 bytes td/telegram/Version.h | 2 +- td/telegram/WebPagesManager.cpp | 29 ++++++++++++++++++++++++----- 4 files changed, 27 insertions(+), 8 deletions(-) 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 2eb4255c6b522f6586e328492d73d18f2f9cebea..f1b641358b7225df99f14318fd1348d25de7111b 100644 GIT binary patch delta 620 zcmca}iQ~s5jtw%REN3Q%yKGhveR7=>#JYJ*$cJ(AM?dk&67NO8a+7V|sz4YiZ%rVK zIWUnUZzCWg3hxvk43~EX5Jts2sICR?pt^3r)ck>|F?bJAGyQ`MBUD?@dku(wgHJk> zpTIZ*AE3sYe1NLU_@E*Ib1wrB6gji$aM-pT1c^;v0#!ae;SbE*KQI#%K4w5H==lhB zpuwjAhzQ3gbdeUA$eK?z5H&iVp)Lvd9H0TR3}iV7T$SUBX%TxO!B>!&p6Zm7pPU_# zkzbO}08%sQoXuo~ZvvCg)JRNTpvD0)N#+aGB!@3^AR-UGC|JP!#0WG}`q_O=*5v%M z)FQAA3^4yecxZmM_zH3S=7g^*j1coWzG=YYlx_M)Zbs$FcfL(v1-p83;b(n_swLl{ szE1dIf-YzA1Gn6nA1ZLunSm+BeX_$(NZf7C`FUj`*zoNx-Ha0R07JhAM*si- delta 586 zcmexyiQ~>Cjtw%REIG|DB{wUGKDo{bV%iT5I4xyd$fRUnL%w|rUbU~JZEC+$Ba$GSgY*DU! z1&QgYPC5C>*#Q~(CHV|6M>0)LEK{Fc^BHP|#TTeKF<<6DO#TBCQTQqY_8P=oG_Qqx zg&458=Bo-LMB|cg&``SYZ3ipZNs|jd>qF!Ye23as^TPyPF60Mpxfd`wfuAK{lQwt! PyfP8Y+MdwOC@~KJb8!0M 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);