From 49129c1529a2c649c31043fa7d5dde9b5c49149e Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Dec 2019 15:28:27 +0300 Subject: [PATCH] Update API scheme to layer 108. --- Telegram/Resources/tl/api.tl | 6 ++++-- Telegram/SourceFiles/data/data_file_origin.cpp | 11 +++++++++-- Telegram/SourceFiles/data/data_session.cpp | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 625964343..982f05af7 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -500,7 +500,7 @@ messages.affectedMessages#84d19185 pts:int pts_count:int = messages.AffectedMess webPageEmpty#eb1477e8 id:long = WebPage; webPagePending#c586da1c id:long date:int = WebPage; -webPage#fa64e172 flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document documents:flags.11?Vector cached_page:flags.10?Page = WebPage; +webPage#e89c45b2 flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page attributes:flags.12?Vector = WebPage; webPageNotModified#85849473 = WebPage; authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; @@ -1105,6 +1105,8 @@ inputThemeSettings#bd507cd1 flags:# base_theme:BaseTheme accent_color:int messag themeSettings#9c14984a flags:# base_theme:BaseTheme accent_color:int message_top_color:flags.0?int message_bottom_color:flags.0?int wallpaper:flags.1?WallPaper = ThemeSettings; +webPageAttributeTheme#54b56617 flags:# documents:flags.0?Vector settings:flags.1?ThemeSettings = WebPageAttribute; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1452,4 +1454,4 @@ folders.deleteFolder#1c295881 folder_id:int = Updates; wallet.sendLiteRequest#e2c9d33e body:bytes = wallet.LiteResponse; wallet.getKeySecretSalt#b57f346 revoke:Bool = wallet.KeySecretSalt; -// LAYER 107 +// LAYER 108 diff --git a/Telegram/SourceFiles/data/data_file_origin.cpp b/Telegram/SourceFiles/data/data_file_origin.cpp index cab02c365..db6133b03 100644 --- a/Telegram/SourceFiles/data/data_file_origin.cpp +++ b/Telegram/SourceFiles/data/data_file_origin.cpp @@ -53,13 +53,20 @@ struct FileReferenceAccumulator { }, [&](const MTPDthemeDocumentNotModified &data) { }); } + void push(const MTPWebPageAttribute &data) { + data.match([&](const MTPDwebPageAttributeTheme &data) { + if (const auto documents = data.vdocuments()) { + push(*documents); + } + }); + } void push(const MTPWebPage &data) { data.match([&](const MTPDwebPage &data) { if (const auto document = data.vdocument()) { push(*document); } - if (const auto documents = data.vdocuments()) { - push(*documents); + if (const auto attributes = data.vattributes()) { + push(*attributes); } if (const auto photo = data.vphoto()) { push(*photo); diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 2fe40d28f..b965cea4e 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -2719,7 +2719,8 @@ void Session::webpageApplyFields( const auto pendingTill = TimeId(0); const auto photo = data.vphoto(); const auto document = data.vdocument(); - const auto lookupThemeDocument = [&]() -> DocumentData* { + const auto lookupInAttribute = [&]( + const MTPDwebPageAttributeTheme &data) -> DocumentData* { if (const auto documents = data.vdocuments()) { for (const auto &document : documents->v) { const auto processed = processDocument(document); @@ -2730,6 +2731,20 @@ void Session::webpageApplyFields( } return nullptr; }; + const auto lookupThemeDocument = [&]() -> DocumentData* { + if (const auto attributes = data.vattributes()) { + for (const auto &attribute : attributes->v) { + const auto result = attribute.match([&]( + const MTPDwebPageAttributeTheme &data) { + return lookupInAttribute(data); + }); + if (result) { + return result; + } + } + } + return nullptr; + }; webpageApplyFields( page, ParseWebPageType(data),