Add td_api::viewPremiumFeature.

This commit is contained in:
levlam 2022-05-24 20:45:03 +03:00
parent 987c9487df
commit 242776e817
6 changed files with 29 additions and 0 deletions

View File

@ -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;

View File

@ -255,4 +255,17 @@ void get_premium_features(Td *td, const td_api::object_ptr<td_api::PremiumSource
td_api::make_object<td_api::premiumFeatures>(std::move(features), std::move(limits), std::move(payment_link)));
}
void view_premium_feature(Td *td, const td_api::object_ptr<td_api::PremiumFeature> &feature, Promise<Unit> &&promise) {
auto source = get_premium_source(feature.get());
if (source.empty()) {
return promise.set_error(Status::Error(400, "Feature must be non-empty"));
}
vector<tl_object_ptr<telegram_api::jsonObjectValue>> data;
data.push_back(
make_tl_object<telegram_api::jsonObjectValue>("item", make_tl_object<telegram_api::jsonString>(source)));
save_app_log(td, "premium.promo_screen_tap", DialogId(), make_tl_object<telegram_api::jsonObject>(std::move(data)),
std::move(promise));
}
} // namespace td

View File

@ -25,4 +25,6 @@ void get_premium_limit(const td_api::object_ptr<td_api::PremiumLimitType> &limit
void get_premium_features(Td *td, const td_api::object_ptr<td_api::PremiumSource> &source,
Promise<td_api::object_ptr<td_api::premiumFeatures>> &&promise);
void view_premium_feature(Td *td, const td_api::object_ptr<td_api::PremiumFeature> &feature, Promise<Unit> &&promise);
} // namespace td

View File

@ -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_);

View File

@ -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);

View File

@ -2550,6 +2550,9 @@ class CliClient final : public Actor {
auto source = td_api::make_object<td_api::premiumSourceLimitExceeded>(
td_api::make_object<td_api::premiumLimitTypeChatFilterCount>());
send_request(td_api::make_object<td_api::getPremiumFeatures>(std::move(source)));
} else if (op == "vprf") {
auto feature = td_api::make_object<td_api::premiumFeatureProfileBadge>();
send_request(td_api::make_object<td_api::viewPremiumFeature>(std::move(feature)));
} else if (op == "atos") {
send_request(td_api::make_object<td_api::acceptTermsOfService>(args));
} else if (op == "gdli") {