Add td_api::suggestedActionSubscribeToAnnualPremium.

This commit is contained in:
levlam 2023-01-23 16:11:26 +03:00
parent 4a5b702f11
commit a1543b0332
4 changed files with 18 additions and 2 deletions

View File

@ -4868,9 +4868,12 @@ suggestedActionConvertToBroadcastGroup supergroup_id:int53 = SuggestedAction;
//@authorization_delay The number of days to pass between consecutive authorizations if the user declines to set password; if 0, then the user is advised to set the password for security reasons
suggestedActionSetPassword authorization_delay:int32 = SuggestedAction;
//@description Suggests the user to upgrade Premium subscription from monthly payments to annual payments
//@description Suggests the user to upgrade the Premium subscription from monthly payments to annual payments
suggestedActionUpgradePremium = SuggestedAction;
//@description Suggests the user to subscribe to the Premium subscription with annual payments
suggestedActionSubscribeToAnnualPremium = SuggestedAction;
//@description Contains a counter @count Count
count count:int32 = Count;

View File

@ -538,6 +538,7 @@ void assign_app_store_transaction(Td *td, const string &receipt,
td_api::object_ptr<td_api::StorePaymentPurpose> &&purpose, Promise<Unit> &&promise) {
if (purpose != nullptr && purpose->get_id() == td_api::storePaymentPurposePremiumSubscription::ID) {
dismiss_suggested_action(SuggestedAction{SuggestedAction::Type::UpgradePremium}, Promise<Unit>());
dismiss_suggested_action(SuggestedAction{SuggestedAction::Type::SubscribeToAnnualPremium}, Promise<Unit>());
}
td->create_handler<AssignAppStoreTransactionQuery>(std::move(promise))->send(receipt, std::move(purpose));
}
@ -548,6 +549,7 @@ void assign_play_market_transaction(Td *td, const string &package_name, const st
Promise<Unit> &&promise) {
if (purpose != nullptr && purpose->get_id() == td_api::storePaymentPurposePremiumSubscription::ID) {
dismiss_suggested_action(SuggestedAction{SuggestedAction::Type::UpgradePremium}, Promise<Unit>());
dismiss_suggested_action(SuggestedAction{SuggestedAction::Type::SubscribeToAnnualPremium}, Promise<Unit>());
}
td->create_handler<AssignPlayMarketTransactionQuery>(std::move(promise))
->send(package_name, store_product_id, purchase_token, std::move(purpose));

View File

@ -39,6 +39,8 @@ SuggestedAction::SuggestedAction(Slice action_str) {
init(Type::SetPassword);
} else if (action_str == Slice("PREMIUM_UPGRADE")) {
init(Type::UpgradePremium);
} else if (action_str == Slice("PREMIUM_ANNUAL")) {
init(Type::SubscribeToAnnualPremium);
}
}
@ -85,6 +87,9 @@ SuggestedAction::SuggestedAction(const td_api::object_ptr<td_api::SuggestedActio
case td_api::suggestedActionUpgradePremium::ID:
init(Type::UpgradePremium);
break;
case td_api::suggestedActionSubscribeToAnnualPremium::ID:
init(Type::SubscribeToAnnualPremium);
break;
default:
UNREACHABLE();
}
@ -106,6 +111,8 @@ string SuggestedAction::get_suggested_action_str() const {
return "SETUP_PASSWORD";
case Type::UpgradePremium:
return "PREMIUM_UPGRADE";
case Type::SubscribeToAnnualPremium:
return "PREMIUM_ANNUAL";
default:
return string();
}
@ -129,6 +136,8 @@ td_api::object_ptr<td_api::SuggestedAction> SuggestedAction::get_suggested_actio
return td_api::make_object<td_api::suggestedActionSetPassword>(otherwise_relogin_days_);
case Type::UpgradePremium:
return td_api::make_object<td_api::suggestedActionUpgradePremium>();
case Type::SubscribeToAnnualPremium:
return td_api::make_object<td_api::suggestedActionSubscribeToAnnualPremium>();
default:
UNREACHABLE();
return nullptr;
@ -188,6 +197,7 @@ void dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise) {
case SuggestedAction::Type::CheckPhoneNumber:
case SuggestedAction::Type::ViewChecksHint:
case SuggestedAction::Type::UpgradePremium:
case SuggestedAction::Type::SubscribeToAnnualPremium:
return send_closure_later(G()->config_manager(), &ConfigManager::dismiss_suggested_action, std::move(action),
std::move(promise));
case SuggestedAction::Type::ConvertToGigagroup:

View File

@ -24,7 +24,8 @@ struct SuggestedAction {
ConvertToGigagroup,
CheckPassword,
SetPassword,
UpgradePremium
UpgradePremium,
SubscribeToAnnualPremium
};
Type type_ = Type::Empty;
DialogId dialog_id_;