diff --git a/Telegram/SourceFiles/api/api_chat_invite.cpp b/Telegram/SourceFiles/api/api_chat_invite.cpp index 8a5ae49875..aa6534fd82 100644 --- a/Telegram/SourceFiles/api/api_chat_invite.cpp +++ b/Telegram/SourceFiles/api/api_chat_invite.cpp @@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo.h" #include "data/data_photo_media.h" #include "data/data_channel.h" +#include "data/data_forum.h" #include "data/data_user.h" #include "data/data_file_origin.h" #include "ui/boxes/confirm_box.h" @@ -109,14 +110,25 @@ void CheckChatInvite( const auto session = &controller->session(); const auto weak = base::make_weak(controller); session->api().checkChatInvite(hash, [=](const MTPChatInvite &result) { + const auto strong = weak.get(); + if (!strong) { + return; + } Core::App().hideMediaView(); - result.match([=](const MTPDchatInvite &data) { - const auto strongController = weak.get(); - if (!strongController) { - return; + const auto show = [&](not_null chat) { + if (const auto forum = chat->forum()) { + strong->openForum( + forum->channel(), + Window::SectionShow::Way::Forward); + } else { + strong->showPeerHistory( + chat, + Window::SectionShow::Way::Forward); } + }; + result.match([=](const MTPDchatInvite &data) { const auto isGroup = !data.is_broadcast(); - const auto box = strongController->show(Box( + const auto box = strong->show(Box( session, data, invitePeekChannel, @@ -139,21 +151,13 @@ void CheckChatInvite( if (const auto channel = chat->asChannel()) { channel->clearInvitePeek(); } - if (const auto strong = weak.get()) { - strong->showPeerHistory( - chat, - Window::SectionShow::Way::Forward); - } + show(chat); } }, [=](const MTPDchatInvitePeek &data) { if (const auto chat = session->data().processChat(data.vchat())) { if (const auto channel = chat->asChannel()) { channel->setInvitePeek(hash, data.vexpires().v); - if (const auto strong = weak.get()) { - strong->showPeerHistory( - chat, - Window::SectionShow::Way::Forward); - } + show(chat); } } });