Open forum by invite link.

This commit is contained in:
John Preston 2022-11-01 15:26:46 +04:00
parent e6c2aa8021
commit 57dc0c632e

View file

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