Add suggestedActionUpgradePremium.
This commit is contained in:
parent
136a50d0ae
commit
4a5b702f11
@ -4868,6 +4868,9 @@ 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
|
||||
suggestedActionUpgradePremium = SuggestedAction;
|
||||
|
||||
|
||||
//@description Contains a counter @count Count
|
||||
count count:int32 = Count;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/PremiumGiftOption.h"
|
||||
#include "td/telegram/SuggestedAction.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
@ -535,6 +536,9 @@ void can_purchase_premium(Td *td, td_api::object_ptr<td_api::StorePaymentPurpose
|
||||
|
||||
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>());
|
||||
}
|
||||
td->create_handler<AssignAppStoreTransactionQuery>(std::move(promise))->send(receipt, std::move(purpose));
|
||||
}
|
||||
|
||||
@ -542,6 +546,9 @@ void assign_play_market_transaction(Td *td, const string &package_name, const st
|
||||
const string &purchase_token,
|
||||
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>());
|
||||
}
|
||||
td->create_handler<AssignPlayMarketTransactionQuery>(std::move(promise))
|
||||
->send(package_name, store_product_id, purchase_token, std::move(purpose));
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ SuggestedAction::SuggestedAction(Slice action_str) {
|
||||
init(Type::ViewChecksHint);
|
||||
} else if (action_str == Slice("SETUP_PASSWORD")) {
|
||||
init(Type::SetPassword);
|
||||
} else if (action_str == Slice("PREMIUM_UPGRADE")) {
|
||||
init(Type::UpgradePremium);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,6 +82,9 @@ SuggestedAction::SuggestedAction(const td_api::object_ptr<td_api::SuggestedActio
|
||||
otherwise_relogin_days_ = action->authorization_delay_;
|
||||
break;
|
||||
}
|
||||
case td_api::suggestedActionUpgradePremium::ID:
|
||||
init(Type::UpgradePremium);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -99,6 +104,8 @@ string SuggestedAction::get_suggested_action_str() const {
|
||||
return "CONVERT_GIGAGROUP";
|
||||
case Type::SetPassword:
|
||||
return "SETUP_PASSWORD";
|
||||
case Type::UpgradePremium:
|
||||
return "PREMIUM_UPGRADE";
|
||||
default:
|
||||
return string();
|
||||
}
|
||||
@ -120,6 +127,8 @@ td_api::object_ptr<td_api::SuggestedAction> SuggestedAction::get_suggested_actio
|
||||
return td_api::make_object<td_api::suggestedActionConvertToBroadcastGroup>(dialog_id_.get_channel_id().get());
|
||||
case Type::SetPassword:
|
||||
return td_api::make_object<td_api::suggestedActionSetPassword>(otherwise_relogin_days_);
|
||||
case Type::UpgradePremium:
|
||||
return td_api::make_object<td_api::suggestedActionUpgradePremium>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -178,6 +187,7 @@ void dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise) {
|
||||
case SuggestedAction::Type::CheckPassword:
|
||||
case SuggestedAction::Type::CheckPhoneNumber:
|
||||
case SuggestedAction::Type::ViewChecksHint:
|
||||
case SuggestedAction::Type::UpgradePremium:
|
||||
return send_closure_later(G()->config_manager(), &ConfigManager::dismiss_suggested_action, std::move(action),
|
||||
std::move(promise));
|
||||
case SuggestedAction::Type::ConvertToGigagroup:
|
||||
|
@ -23,7 +23,8 @@ struct SuggestedAction {
|
||||
ViewChecksHint,
|
||||
ConvertToGigagroup,
|
||||
CheckPassword,
|
||||
SetPassword
|
||||
SetPassword,
|
||||
UpgradePremium
|
||||
};
|
||||
Type type_ = Type::Empty;
|
||||
DialogId dialog_id_;
|
||||
|
Loading…
Reference in New Issue
Block a user