From 7c7aa3d2deec1b158b0a60bd82c8e768a0ad706a Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 24 May 2022 15:42:46 +0300 Subject: [PATCH] Save app log event in getPremiumFeatures. --- td/telegram/Premium.cpp | 17 +++++++++++++++-- td/telegram/Premium.h | 4 +++- td/telegram/Td.cpp | 2 +- td/telegram/cli.cpp | 3 ++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/td/telegram/Premium.cpp b/td/telegram/Premium.cpp index 02ca5d270..3dde11dcc 100644 --- a/td/telegram/Premium.cpp +++ b/td/telegram/Premium.cpp @@ -6,6 +6,7 @@ // #include "td/telegram/Premium.h" +#include "td/telegram/Application.h" #include "td/telegram/ConfigShared.h" #include "td/telegram/Global.h" @@ -173,7 +174,7 @@ void get_premium_limit(const td_api::object_ptr &limit promise.set_value(get_premium_limit_object(get_limit_type_key(limit_type.get()))); } -void get_premium_features(const td_api::object_ptr &source, +void get_premium_features(Td *td, const td_api::object_ptr &source, Promise> &&promise) { auto premium_features = full_split(G()->shared_config().get_option_string( @@ -225,7 +226,19 @@ void get_premium_features(const td_api::object_ptr &sourc td::remove_if(limits, [](auto &limit) { return limit == nullptr; }); auto source_str = get_premium_source(source); - // TODO use source_str + if (!source_str.empty()) { + vector> data; + vector> promo_order; + for (const auto &premium_feature : premium_features) { + promo_order.push_back(make_tl_object(premium_feature)); + } + data.push_back(make_tl_object( + "premium_promo_order", make_tl_object(std::move(promo_order)))); + data.push_back( + make_tl_object("source", make_tl_object(source_str))); + save_app_log(td, "premium.promo_screen_show", DialogId(), make_tl_object(std::move(data)), + Promise()); + } promise.set_value(td_api::make_object(std::move(features), std::move(limits))); } diff --git a/td/telegram/Premium.h b/td/telegram/Premium.h index 4d1d3b062..230df99f3 100644 --- a/td/telegram/Premium.h +++ b/td/telegram/Premium.h @@ -15,12 +15,14 @@ namespace td { +class Td; + const vector &get_premium_limit_keys(); void get_premium_limit(const td_api::object_ptr &limit_type, Promise> &&promise); -void get_premium_features(const td_api::object_ptr &source, +void get_premium_features(Td *td, const td_api::object_ptr &source, Promise> &&promise); } // namespace td diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index d7f15672d..7a1ca43bc 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7835,7 +7835,7 @@ void Td::on_request(uint64 id, const td_api::getPremiumLimit &request) { void Td::on_request(uint64 id, const td_api::getPremiumFeatures &request) { CHECK_IS_USER(); CREATE_REQUEST_PROMISE(); - get_premium_features(request.source_, std::move(promise)); + get_premium_features(this, request.source_, std::move(promise)); } void Td::on_request(uint64 id, td_api::acceptTermsOfService &request) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 8d0f65095..27164af84 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2547,7 +2547,8 @@ class CliClient final : public Actor { auto limit_type = td_api::make_object(); send_request(td_api::make_object(std::move(limit_type))); } else if (op == "gprf") { - auto source = td_api::make_object("ref"); + auto source = td_api::make_object( + td_api::make_object()); send_request(td_api::make_object(std::move(source))); } else if (op == "atos") { send_request(td_api::make_object(args));