Allow to specify source in getPremiumFeatures.
This commit is contained in:
parent
ab4a5d7499
commit
2d90ccc1bc
@ -2947,6 +2947,21 @@ premiumLimit type:PremiumLimitType default_value:int32 premium_value:int32 = Pre
|
|||||||
premiumFeatures features:vector<PremiumFeature> limits:vector<premiumLimit> = PremiumFeatures;
|
premiumFeatures features:vector<PremiumFeature> limits:vector<premiumLimit> = PremiumFeatures;
|
||||||
|
|
||||||
|
|
||||||
|
//@class PremiumSource @description Describes a source, from which the Premium features screen is opened
|
||||||
|
|
||||||
|
//@description A limit was exceeded @limit_type Type of the exceeded limit
|
||||||
|
premiumSourceLimitExceeded limit_type:PremiumLimitType = PremiumSource;
|
||||||
|
|
||||||
|
//@description A user tried to use a Premium feature @feature The used feature
|
||||||
|
premiumSourceFeature feature:PremiumFeature = PremiumSource;
|
||||||
|
|
||||||
|
//@description A user opened an internal link of the type internalLinkTypePremiumFeatures @referrer The referrer from the link
|
||||||
|
premiumSourceLink referrer:string = PremiumSource;
|
||||||
|
|
||||||
|
//@description A user opened the Premium features screen from settings
|
||||||
|
premiumSourceSettings = PremiumSource;
|
||||||
|
|
||||||
|
|
||||||
//@class DeviceToken @description Represents a data needed to subscribe for push notifications through registerDevice method. To use specific push notification service, the correct application platform must be specified and a valid server authentication data must be uploaded at https://my.telegram.org
|
//@class DeviceToken @description Represents a data needed to subscribe for push notifications through registerDevice method. To use specific push notification service, the correct application platform must be specified and a valid server authentication data must be uploaded at https://my.telegram.org
|
||||||
|
|
||||||
//@description A token for Firebase Cloud Messaging @token Device registration token; may be empty to deregister a device @encrypt True, if push notifications must be additionally encrypted
|
//@description A token for Firebase Cloud Messaging @token Device registration token; may be empty to deregister a device @encrypt True, if push notifications must be additionally encrypted
|
||||||
@ -6300,8 +6315,8 @@ removeStickerFromSet sticker:InputFile = Ok;
|
|||||||
getMapThumbnailFile location:location zoom:int32 width:int32 height:int32 scale:int32 chat_id:int53 = File;
|
getMapThumbnailFile location:location zoom:int32 width:int32 height:int32 scale:int32 chat_id:int53 = File;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns information about features, available to Premium users
|
//@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 = PremiumFeatures;
|
getPremiumFeatures source:PremiumSource = PremiumFeatures;
|
||||||
|
|
||||||
|
|
||||||
//@description Accepts Telegram terms of services @terms_of_service_id Terms of service identifier
|
//@description Accepts Telegram terms of services @terms_of_service_id Terms of service identifier
|
||||||
|
@ -26,7 +26,101 @@ const vector<Slice> &get_premium_limit_keys() {
|
|||||||
return limit_keys;
|
return limit_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_premium_features(Promise<td_api::object_ptr<td_api::premiumFeatures>> &&promise) {
|
static string get_premium_source(const td_api::PremiumLimitType *limit_type) {
|
||||||
|
if (limit_type == nullptr) {
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto key = [&]() {
|
||||||
|
switch (limit_type->get_id()) {
|
||||||
|
case td_api::premiumLimitTypeSupergroupCount::ID:
|
||||||
|
return "channels";
|
||||||
|
case td_api::premiumLimitTypeSavedAnimationCount::ID:
|
||||||
|
return "saved_gifs";
|
||||||
|
case td_api::premiumLimitTypeFavoriteStickerCount::ID:
|
||||||
|
return "stickers_faved";
|
||||||
|
case td_api::premiumLimitTypeChatFilterCount::ID:
|
||||||
|
return "dialog_filters";
|
||||||
|
case td_api::premiumLimitTypeChatFilterChosenChatCount::ID:
|
||||||
|
return "dialog_filters_chats";
|
||||||
|
case td_api::premiumLimitTypePinnedChatCount::ID:
|
||||||
|
return "dialogs_pinned";
|
||||||
|
case td_api::premiumLimitTypePinnedArchivedChatCount::ID:
|
||||||
|
return "dialogs_folder_pinned";
|
||||||
|
case td_api::premiumLimitTypeCreatedPublicChatCount::ID:
|
||||||
|
return "channels_public";
|
||||||
|
case td_api::premiumLimitTypeCaptionLength::ID:
|
||||||
|
return "caption_length";
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
return PSTRING() << "double_limits__" << key;
|
||||||
|
}
|
||||||
|
|
||||||
|
static string get_premium_source(const td_api::PremiumFeature *feature) {
|
||||||
|
if (feature == nullptr) {
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (feature->get_id()) {
|
||||||
|
case td_api::premiumFeatureIncreasedLimits::ID:
|
||||||
|
return "double_limits";
|
||||||
|
case td_api::premiumFeatureIncreasedFileSize::ID:
|
||||||
|
return "more_upload";
|
||||||
|
case td_api::premiumFeatureImprovedDownloadSpeed::ID:
|
||||||
|
return "faster_download";
|
||||||
|
case td_api::premiumFeatureVoiceRecognition::ID:
|
||||||
|
return "voice_to_text";
|
||||||
|
case td_api::premiumFeatureDisabledAds::ID:
|
||||||
|
return "no_ads";
|
||||||
|
case td_api::premiumFeatureUniqueReactions::ID:
|
||||||
|
return "unique_reactions";
|
||||||
|
case td_api::premiumFeatureUniqueStickers::ID:
|
||||||
|
return "premium_stickers";
|
||||||
|
case td_api::premiumFeatureAdvancedChatManagement::ID:
|
||||||
|
return "advanced_chat_management";
|
||||||
|
case td_api::premiumFeatureProfileBadge::ID:
|
||||||
|
return "profile_badge";
|
||||||
|
case td_api::premiumFeatureAnimatedProfilePhoto::ID:
|
||||||
|
return "animated_userpics";
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
|
static string get_premium_source(const td_api::object_ptr<td_api::PremiumSource> &source) {
|
||||||
|
if (source == nullptr) {
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
switch (source->get_id()) {
|
||||||
|
case td_api::premiumSourceLimitExceeded::ID: {
|
||||||
|
auto *limit_type = static_cast<const td_api::premiumSourceLimitExceeded *>(source.get())->limit_type_.get();
|
||||||
|
return get_premium_source(limit_type);
|
||||||
|
}
|
||||||
|
case td_api::premiumSourceFeature::ID: {
|
||||||
|
auto *feature = static_cast<const td_api::premiumSourceFeature *>(source.get())->feature_.get();
|
||||||
|
return get_premium_source(feature);
|
||||||
|
}
|
||||||
|
case td_api::premiumSourceLink::ID: {
|
||||||
|
auto &referrer = static_cast<const td_api::premiumSourceLink *>(source.get())->referrer_;
|
||||||
|
if (referrer.empty()) {
|
||||||
|
return "deeplink";
|
||||||
|
}
|
||||||
|
return PSTRING() << "deeplink_" << referrer;
|
||||||
|
}
|
||||||
|
case td_api::premiumSourceSettings::ID:
|
||||||
|
return "settings";
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_premium_features(const td_api::object_ptr<td_api::PremiumSource> &source,
|
||||||
|
Promise<td_api::object_ptr<td_api::premiumFeatures>> &&promise) {
|
||||||
auto premium_features =
|
auto premium_features =
|
||||||
full_split(G()->shared_config().get_option_string(
|
full_split(G()->shared_config().get_option_string(
|
||||||
"premium_features",
|
"premium_features",
|
||||||
@ -113,6 +207,10 @@ void get_premium_features(Promise<td_api::object_ptr<td_api::premiumFeatures>> &
|
|||||||
limits.push_back(td_api::make_object<td_api::premiumLimit>(std::move(type), default_limit, premium_limit));
|
limits.push_back(td_api::make_object<td_api::premiumLimit>(std::move(type), default_limit, premium_limit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto source_str = get_premium_source(source);
|
||||||
|
// TODO use source_str
|
||||||
|
|
||||||
promise.set_value(td_api::make_object<td_api::premiumFeatures>(std::move(features), std::move(limits)));
|
promise.set_value(td_api::make_object<td_api::premiumFeatures>(std::move(features), std::move(limits)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ namespace td {
|
|||||||
|
|
||||||
const vector<Slice> &get_premium_limit_keys();
|
const vector<Slice> &get_premium_limit_keys();
|
||||||
|
|
||||||
void get_premium_features(Promise<td_api::object_ptr<td_api::premiumFeatures>> &&promise);
|
void get_premium_features(const td_api::object_ptr<td_api::PremiumSource> &source,
|
||||||
|
Promise<td_api::object_ptr<td_api::premiumFeatures>> &&promise);
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -7829,7 +7829,7 @@ void Td::on_request(uint64 id, td_api::removeRecentHashtag &request) {
|
|||||||
void Td::on_request(uint64 id, const td_api::getPremiumFeatures &request) {
|
void Td::on_request(uint64 id, const td_api::getPremiumFeatures &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST_PROMISE();
|
CREATE_REQUEST_PROMISE();
|
||||||
get_premium_features(std::move(promise));
|
get_premium_features(request.source_, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::acceptTermsOfService &request) {
|
void Td::on_request(uint64 id, td_api::acceptTermsOfService &request) {
|
||||||
|
@ -2544,7 +2544,8 @@ class CliClient final : public Actor {
|
|||||||
} else if (op == "gadl") {
|
} else if (op == "gadl") {
|
||||||
send_request(td_api::make_object<td_api::getApplicationDownloadLink>());
|
send_request(td_api::make_object<td_api::getApplicationDownloadLink>());
|
||||||
} else if (op == "gpfs") {
|
} else if (op == "gpfs") {
|
||||||
send_request(td_api::make_object<td_api::getPremiumFeatures>());
|
auto source = td_api::make_object<td_api::premiumSourceLink>("ref");
|
||||||
|
send_request(td_api::make_object<td_api::getPremiumFeatures>(std::move(source)));
|
||||||
} else if (op == "atos") {
|
} else if (op == "atos") {
|
||||||
send_request(td_api::make_object<td_api::acceptTermsOfService>(args));
|
send_request(td_api::make_object<td_api::acceptTermsOfService>(args));
|
||||||
} else if (op == "gdli") {
|
} else if (op == "gdli") {
|
||||||
|
Loading…
Reference in New Issue
Block a user