Skip to content

Commit 6913c56

Browse files
committed
Allow gift price to decrease.
1 parent 18f6c78 commit 6913c56

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

td/telegram/StarGiftManager.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ class GetGiftPaymentFormQuery final : public Td::ResultHandler {
201201
break;
202202
case telegram_api::payments_paymentFormStarGift::ID: {
203203
auto payment_form = static_cast<const telegram_api::payments_paymentFormStarGift *>(payment_form_ptr.get());
204+
if (!td_->auth_manager_->is_bot()) {
205+
if (payment_form->invoice_->prices_.size() != 1u ||
206+
payment_form->invoice_->prices_[0]->amount_ > star_count_) {
207+
td_->star_manager_->add_pending_owned_star_count(star_count_, false);
208+
return promise_.set_error(400, "Wrong gift price specified");
209+
}
210+
if (payment_form->invoice_->prices_[0]->amount_ != star_count_) {
211+
td_->star_manager_->add_pending_owned_star_count(star_count_ - payment_form->invoice_->prices_[0]->amount_,
212+
false);
213+
star_count_ = payment_form->invoice_->prices_[0]->amount_;
214+
}
215+
}
204216
td_->create_handler<SendGiftQuery>(std::move(promise_))
205217
->send(std::move(send_input_invoice_), payment_form->form_id_, star_count_);
206218
break;

0 commit comments

Comments
 (0)