diff --git a/Telegram/SourceFiles/api/api_credits.cpp b/Telegram/SourceFiles/api/api_credits.cpp index 3ef1d721f..727cee565 100644 --- a/Telegram/SourceFiles/api/api_credits.cpp +++ b/Telegram/SourceFiles/api/api_credits.cpp @@ -134,7 +134,9 @@ rpl::producer CreditsTopupOptions::request() { return [=](auto consumer) { auto lifetime = rpl::lifetime(); - const auto optionsFromTL = [](const auto &options) { + const auto giftBarePeerId = !_peer->isSelf() ? _peer->id.value : 0; + + const auto optionsFromTL = [giftBarePeerId](const auto &options) { return ranges::views::all( options ) | ranges::views::transform([=](const auto &option) { @@ -145,6 +147,7 @@ rpl::producer CreditsTopupOptions::request() { .currency = qs(option.data().vcurrency()), .amount = option.data().vamount().v, .extended = option.data().is_extended(), + .giftBarePeerId = giftBarePeerId, }; }) | ranges::to_vector; }; diff --git a/Telegram/SourceFiles/data/data_credits.h b/Telegram/SourceFiles/data/data_credits.h index d01becf07..ee8d948a7 100644 --- a/Telegram/SourceFiles/data/data_credits.h +++ b/Telegram/SourceFiles/data/data_credits.h @@ -15,6 +15,7 @@ struct CreditTopupOption final { QString currency; uint64 amount = 0; bool extended = false; + uint64 giftBarePeerId = 0; }; using CreditTopupOptions = std::vector; diff --git a/Telegram/SourceFiles/payments/payments_form.cpp b/Telegram/SourceFiles/payments/payments_form.cpp index e9dec016b..8c0a44e10 100644 --- a/Telegram/SourceFiles/payments/payments_form.cpp +++ b/Telegram/SourceFiles/payments/payments_form.cpp @@ -318,6 +318,16 @@ MTPInputInvoice Form::inputInvoice() const { } else if (const auto slug = std::get_if(&_id.value)) { return MTP_inputInvoiceSlug(MTP_string(slug->slug)); } else if (const auto credits = std::get_if(&_id.value)) { + if (const auto userId = peerToUser(credits->giftPeerId)) { + if (const auto user = _session->data().user(userId)) { + return MTP_inputInvoiceStars( + MTP_inputStorePaymentStarsGift( + user->inputUser, + MTP_long(credits->credits), + MTP_string(credits->currency), + MTP_long(credits->amount))); + } + } return MTP_inputInvoiceStars( MTP_inputStorePaymentStarsTopup( MTP_long(credits->credits), diff --git a/Telegram/SourceFiles/payments/payments_form.h b/Telegram/SourceFiles/payments/payments_form.h index c85d946ed..42b6d00b3 100644 --- a/Telegram/SourceFiles/payments/payments_form.h +++ b/Telegram/SourceFiles/payments/payments_form.h @@ -167,6 +167,7 @@ struct InvoiceCredits { QString currency; uint64 amount = 0; bool extended = false; + PeerId giftPeerId = PeerId(0); }; struct InvoiceId { diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 613bf9169..954c07c7b 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -314,6 +314,7 @@ void FillCreditOptions( .currency = option.currency, .amount = option.amount, .extended = option.extended, + .giftPeerId = PeerId(option.giftBarePeerId), }; const auto weak = Ui::MakeWeak(button);