From 242776e8177fde3d57a1953e1b53a7981547864c Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 24 May 2022 20:45:03 +0300 Subject: [PATCH] Add td_api::viewPremiumFeature. --- td/generate/scheme/td_api.tl | 3 +++ td/telegram/Premium.cpp | 13 +++++++++++++ td/telegram/Premium.h | 2 ++ td/telegram/Td.cpp | 6 ++++++ td/telegram/Td.h | 2 ++ td/telegram/cli.cpp | 3 +++ 6 files changed, 29 insertions(+) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a9ac555cc..92353df2b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6322,6 +6322,9 @@ getPremiumLimit limit_type:PremiumLimitType = PremiumLimit; //@description Returns information about features, available to Premium users @source Source of the request; pass null if the method is called from some non-standard source getPremiumFeatures source:PremiumSource = PremiumFeatures; +//@description Informs TDLib that the user viewed detailed information about a Premium feature on the Premium features screen @feature The viewed premium feature +viewPremiumFeature feature:PremiumFeature = Ok; + //@description Accepts Telegram terms of services @terms_of_service_id Terms of service identifier acceptTermsOfService terms_of_service_id:string = Ok; diff --git a/td/telegram/Premium.cpp b/td/telegram/Premium.cpp index c12592417..7979e7887 100644 --- a/td/telegram/Premium.cpp +++ b/td/telegram/Premium.cpp @@ -255,4 +255,17 @@ void get_premium_features(Td *td, const td_api::object_ptr(std::move(features), std::move(limits), std::move(payment_link))); } +void view_premium_feature(Td *td, const td_api::object_ptr &feature, Promise &&promise) { + auto source = get_premium_source(feature.get()); + if (source.empty()) { + return promise.set_error(Status::Error(400, "Feature must be non-empty")); + } + + vector> data; + data.push_back( + make_tl_object("item", make_tl_object(source))); + save_app_log(td, "premium.promo_screen_tap", DialogId(), make_tl_object(std::move(data)), + std::move(promise)); +} + } // namespace td diff --git a/td/telegram/Premium.h b/td/telegram/Premium.h index 230df99f3..266ef9976 100644 --- a/td/telegram/Premium.h +++ b/td/telegram/Premium.h @@ -25,4 +25,6 @@ void get_premium_limit(const td_api::object_ptr &limit void get_premium_features(Td *td, const td_api::object_ptr &source, Promise> &&promise); +void view_premium_feature(Td *td, const td_api::object_ptr &feature, Promise &&promise); + } // namespace td diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 7a1ca43bc..054327a28 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7838,6 +7838,12 @@ void Td::on_request(uint64 id, const td_api::getPremiumFeatures &request) { get_premium_features(this, request.source_, std::move(promise)); } +void Td::on_request(uint64 id, const td_api::viewPremiumFeature &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + view_premium_feature(this, request.feature_, std::move(promise)); +} + void Td::on_request(uint64 id, td_api::acceptTermsOfService &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.terms_of_service_id_); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 06278a38d..768591a14 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1292,6 +1292,8 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::getPremiumFeatures &request); + void on_request(uint64 id, const td_api::viewPremiumFeature &request); + void on_request(uint64 id, td_api::acceptTermsOfService &request); void on_request(uint64 id, const td_api::getCountries &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 27164af84..c1a4a3657 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2550,6 +2550,9 @@ class CliClient final : public Actor { auto source = td_api::make_object( td_api::make_object()); send_request(td_api::make_object(std::move(source))); + } else if (op == "vprf") { + auto feature = td_api::make_object(); + send_request(td_api::make_object(std::move(feature))); } else if (op == "atos") { send_request(td_api::make_object(args)); } else if (op == "gdli") {