MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / CheckChatInvite

Function CheckChatInvite

Telegram/SourceFiles/api/api_chat_invite.cpp:669–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

667}
668
669void CheckChatInvite(
670 not_null<Window::SessionController*> controller,
671 const QString &hash,
672 ChannelData *invitePeekChannel,
673 Fn<void()> loaded) {
674 const auto session = &controller->session();
675 const auto weak = base::make_weak(controller);
676 session->api().checkChatInvite(hash, [=](const MTPChatInvite &result) {
677 const auto strong = weak.get();
678 if (!strong) {
679 return;
680 }
681 if (loaded) {
682 loaded();
683 }
684 Core::App().hideMediaView();
685 const auto show = [&](not_null<PeerData*> chat) {
686 const auto way = Window::SectionShow::Way::Forward;
687 if (const auto forum = chat->forum()) {
688 strong->showForum(forum, way);
689 } else {
690 strong->showPeerHistory(chat, way);
691 }
692 };
693 result.match([=](const MTPDchatInvite &data) {
694 const auto isGroup = !data.is_broadcast();
695 const auto hasPricing = !!data.vsubscription_pricing();
696 const auto canRefulfill = data.is_can_refulfill_subscription();
697 if (hasPricing
698 && !canRefulfill
699 && !data.vsubscription_form_id()) {
700 strong->uiShow()->showToast(
701 tr::lng_confirm_phone_link_invalid(tr::now));
702 return;
703 }
704 const auto box = (hasPricing && !canRefulfill)
705 ? strong->show(Box(
706 ConfirmSubscriptionBox,
707 session,
708 hash,
709 &data))
710 : strong->show(Box(
711 ConfirmInviteBox,
712 session,
713 &data,
714 invitePeekChannel,
715 [=] { SubmitChatInvite(weak, session, hash, isGroup); }));
716 if (invitePeekChannel) {
717 box->boxClosing(
718 ) | rpl::filter([=] {
719 return !invitePeekChannel->amIn();
720 }) | rpl::on_next([=] {
721 if (const auto strong = weak.get()) {
722 strong->clearSectionStack(Window::SectionShow(
723 Window::SectionShow::Way::ClearStack,
724 anim::type::normal,
725 anim::activation::background));
726 }

Callers 4

checkInvitePeekMethod · 0.85
JoinGroupByHashFunction · 0.85
privateErrorReceivedMethod · 0.85
GenericCreditsEntryBodyFunction · 0.85

Calls 15

AppClass · 0.85
SubmitChatInviteFunction · 0.85
showFunction · 0.85
IsFloodErrorFunction · 0.85
MakeInformBoxFunction · 0.85
checkChatInviteMethod · 0.80
apiMethod · 0.80
hideMediaViewMethod · 0.80
clearSectionStackMethod · 0.80
processChatMethod · 0.80
asChannelMethod · 0.80
clearInvitePeekMethod · 0.80

Tested by

no test coverage detected