Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 23, 2024
1 parent 3046bd1 commit 7cf1bbb
Show file tree
Hide file tree
Showing 63 changed files with 1,180 additions and 320 deletions.
59 changes: 54 additions & 5 deletions Telegram/SourceFiles/api/api_chat_invite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,25 @@ void ConfirmSubscriptionBox(
not_null<Ui::GenericBox*> box,
not_null<Main::Session*> session,
const QString &hash,
#if 0 // mtp
const MTPDchatInvite *data) {
#endif
const TLDchatInviteLinkInfo *data) {
box->setWidth(st::boxWideWidth);
#if 0 // mtp
const auto amount = data->vsubscription_pricing()->data().vamount().v;
const auto formId = data->vsubscription_form_id()->v;
const auto name = qs(data->vtitle());
const auto maybePhoto = session->data().processPhoto(data->vphoto());
const auto photo = maybePhoto->isNull() ? nullptr : maybePhoto.get();
#endif
const auto &pricing = data->vsubscription_info()->data().vpricing();
const auto amount = pricing.data().vstar_count().v;
const auto formId = data->vsubscription_info()->data().vform_id().v;
const auto name = qs(data->vtitle());
const auto photo = data->vphoto()
? session->data().processSmallPhoto(*data->vphoto()).get()
: nullptr;

struct State final {
std::shared_ptr<Data::PhotoMedia> photoMedia;
Expand Down Expand Up @@ -293,22 +305,40 @@ void ConfirmSubscriptionBox(
const auto buttonWidth = state->saveButton
? state->saveButton->width()
: 0;
state->api->request(TLsendPaymentForm(
tl_inputInvoiceTelegram(
tl_telegramPaymentPurposeJoinChat(tl_string(hash))),
tl_int64(formId),
tl_string(), // order_info_id
tl_string(), // shipping_option_id
null, // credentials
tl_int53(0) // tip_amount
)).done([=](const TLpaymentResult &result) {
#if 0 // mtp
state->api->request(
MTPpayments_SendStarsForm(
MTP_long(formId),
MTP_inputInvoiceChatInviteSubscription(MTP_string(hash)))
).done([=](const MTPpayments_PaymentResult &result) {
#endif
state->api = std::nullopt;
state->loading.force_assign(false);
#if 0 // mtp
result.match([&](const MTPDpayments_paymentResult &data) {
session->api().applyUpdates(data.vupdates());
}, [](const MTPDpayments_paymentVerificationNeeded &data) {
});
#endif
if (weak) {
box->closeBox();
}
#if 0 // mtp
}).fail([=](const MTP::Error &error) {
const auto id = error.type();
#endif

}).fail([=](const Error &error) {
const auto id = error.message;
if (weak) {
state->api = std::nullopt;
}
Expand Down Expand Up @@ -400,11 +430,30 @@ void CheckChatInvite(
}, [](const TLDinviteLinkChatTypeChannel&) {
return false;
});
const auto box = strong->show(Box<ConfirmInviteBox>(
session,
data,
invitePeekChannel,
[=] { SubmitChatInvite(weak, session, hash, isGroup); }));
const auto hasPricing = data.vsubscription_info().has_value();
const auto canRefulfill = hasPricing
&& data.vsubscription_info()->data().vcan_reuse().v;
const auto formId = hasPricing
? data.vsubscription_info()->data().vform_id().v
: 0;
if (hasPricing
&& !canRefulfill
&& !formId) {
strong->uiShow()->showToast(
tr::lng_confirm_phone_link_invalid(tr::now));
return;
}
const auto box = (hasPricing && !canRefulfill)
? strong->show(Box(
ConfirmSubscriptionBox,
session,
hash,
&data))
: strong->show(Box<ConfirmInviteBox>(
session,
data,
invitePeekChannel,
[=] { SubmitChatInvite(weak, session, hash, isGroup); }));
if (invitePeekChannel) {
box->boxClosing(
) | rpl::filter([=] {
Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/api/api_chat_participants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ ChatParticipant::ChatParticipant(
_rank = data.vcustom_title().v;
}, [&](const TLDchatMemberStatusMember &data) {
_type = Type::Member;
_subscriptionDate = data.vmember_until_date().v;
}, [&](const TLDchatMemberStatusBanned &data) {
_type = Type::Banned;
}, [&](const TLDchatMemberStatusRestricted &data) {
Expand Down Expand Up @@ -1018,7 +1019,7 @@ void ChatParticipants::unblock(
const auto requestId = _api.request(TLsetChatMemberStatus(
peerToTdbChat(channel->id),
peerToSender(participant->id),
tl_chatMemberStatusMember()
tl_chatMemberStatusMember(tl_int32(0)) // member_until_date
)).done([=] {
_kickRequests.remove(KickRequest(channel, participant));
if (channel->kickedCount() > 0) {
Expand Down
Loading

0 comments on commit 7cf1bbb

Please sign in to comment.