Add storePaymentPurposePremiumGiftCodes.
This commit is contained in:
parent
bd36f48054
commit
fa04b6f280
@ -4366,9 +4366,16 @@ premiumState state:formattedText payment_options:vector<premiumStatePaymentOptio
|
||||
//@description The user subscribed to Telegram Premium @is_restore Pass true if this is a restore of a Telegram Premium purchase; only for App Store @is_upgrade Pass true if this is an upgrade from a monthly subscription to early subscription; only for App Store
|
||||
storePaymentPurposePremiumSubscription is_restore:Bool is_upgrade:Bool = StorePaymentPurpose;
|
||||
|
||||
//@description The user gifted Telegram Premium to another user @user_id Identifier of the user for which Premium was gifted @currency ISO 4217 currency code of the payment currency @amount Paid amount, in the smallest units of the currency
|
||||
//@description The user gifted Telegram Premium to another user @user_id Identifier of the user to which Premium was gifted @currency ISO 4217 currency code of the payment currency @amount Paid amount, in the smallest units of the currency
|
||||
storePaymentPurposeGiftedPremium user_id:int53 currency:string amount:int53 = StorePaymentPurpose;
|
||||
|
||||
//@description The user created Telegram Premium gift codes for other users
|
||||
//@user_ids Identifiers of the users which can activate the gift codes
|
||||
//@boosted_chat_id Identifier of the channel chat, which will be automatically boosted by the users for duration of the Premium subscription and which is administered by the user; 0 if none
|
||||
//@currency ISO 4217 currency code of the payment currency
|
||||
//@amount Paid amount, in the smallest units of the currency
|
||||
storePaymentPurposePremiumGiftCodes user_ids:vector<int53> boosted_chat_id:int53 currency:string amount:int53 = StorePaymentPurpose;
|
||||
|
||||
|
||||
//@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
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/PremiumGiftOption.h"
|
||||
#include "td/telegram/SuggestedAction.h"
|
||||
@ -116,6 +117,34 @@ static Result<tl_object_ptr<telegram_api::InputStorePaymentPurpose>> get_input_s
|
||||
return make_tl_object<telegram_api::inputStorePaymentGiftPremium>(std::move(input_user), p->currency_,
|
||||
p->amount_);
|
||||
}
|
||||
case td_api::storePaymentPurposePremiumGiftCodes::ID: {
|
||||
auto p = static_cast<const td_api::storePaymentPurposePremiumGiftCodes *>(purpose.get());
|
||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : p->user_ids_) {
|
||||
TRY_RESULT(input_user, td->contacts_manager_->get_input_user(UserId(user_id)));
|
||||
input_users.push_back(std::move(input_user));
|
||||
}
|
||||
if (p->amount_ <= 0 || !check_currency_amount(p->amount_)) {
|
||||
return Status::Error(400, "Invalid amount of the currency specified");
|
||||
}
|
||||
telegram_api::object_ptr<telegram_api::InputPeer> boost_input_peer;
|
||||
if (p->boosted_chat_id_ != 0) {
|
||||
DialogId dialog_id(p->boosted_chat_id_);
|
||||
if (!td->messages_manager_->have_dialog_force(dialog_id, "storePaymentPurposePremiumGiftCodes")) {
|
||||
return Status::Error(400, "Chat to boost not found");
|
||||
}
|
||||
boost_input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||
if (boost_input_peer == nullptr) {
|
||||
return Status::Error(400, "Can't access the chat");
|
||||
}
|
||||
}
|
||||
int32 flags = 0;
|
||||
if (boost_input_peer != nullptr) {
|
||||
flags |= telegram_api::inputStorePaymentPremiumGiftCode::BOOST_PEER_MASK;
|
||||
}
|
||||
return telegram_api::make_object<telegram_api::inputStorePaymentPremiumGiftCode>(
|
||||
flags, std::move(input_users), std::move(boost_input_peer), p->currency_, p->amount_);
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
|
@ -3092,17 +3092,22 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::clickPremiumSubscriptionButton>());
|
||||
} else if (op == "gprs") {
|
||||
send_request(td_api::make_object<td_api::getPremiumState>());
|
||||
} else if (op == "cppr") {
|
||||
} else if (op == "cppr" || op == "cpprb") {
|
||||
UserId user_id;
|
||||
string currency;
|
||||
int64 amount;
|
||||
get_args(args, user_id, currency, amount);
|
||||
ChatId boosted_chat_id;
|
||||
get_args(args, user_id, currency, amount, boosted_chat_id);
|
||||
if (currency.empty()) {
|
||||
send_request(td_api::make_object<td_api::canPurchasePremium>(
|
||||
td_api::make_object<td_api::storePaymentPurposePremiumSubscription>(false, false)));
|
||||
} else {
|
||||
} else if (op == "cppr") {
|
||||
send_request(td_api::make_object<td_api::canPurchasePremium>(
|
||||
td_api::make_object<td_api::storePaymentPurposeGiftedPremium>(user_id, currency, amount)));
|
||||
} else {
|
||||
send_request(td_api::make_object<td_api::canPurchasePremium>(
|
||||
td_api::make_object<td_api::storePaymentPurposePremiumGiftCodes>(vector<int64>{user_id}, boosted_chat_id,
|
||||
currency, amount)));
|
||||
}
|
||||
} else if (op == "atos") {
|
||||
send_request(td_api::make_object<td_api::acceptTermsOfService>(args));
|
||||
|
Loading…
Reference in New Issue
Block a user