From 826d6011a1168f3fcbaf9537a20d311e4661ec01 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 9 Apr 2019 17:18:47 +0400 Subject: [PATCH] Mask channel as forbidden on CHANNEL_PRIVATE error. Fixes #5902. --- Telegram/SourceFiles/apiwrap.cpp | 3 +++ Telegram/SourceFiles/data/data_channel.cpp | 11 +++++++++++ Telegram/SourceFiles/data/data_channel.h | 2 ++ Telegram/SourceFiles/history/history.cpp | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index ba112e3aa..adff240df 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1661,6 +1661,9 @@ void ApiWrap::requestSelfParticipant(not_null channel) { } const auto finalize = [=](UserId inviter, TimeId inviteDate) { + if (inviter < 0) { + channel->markForbidden(); + } channel->inviter = inviter; channel->inviteDate = inviteDate; if (const auto history = _session->data().historyLoaded(channel)) { diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 438c0382a..23192a786 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -267,6 +267,17 @@ void ChannelData::applyEditBanned(not_null user, const MTPChatBannedR Notify::peerUpdatedDelayed(this, flags); } +void ChannelData::markForbidden() { + owner().processChat(MTP_channelForbidden( + MTP_flags(isMegagroup() + ? MTPDchannelForbidden::Flag::f_megagroup + : MTPDchannelForbidden::Flag::f_broadcast), + MTP_int(bareId()), + MTP_long(access), + MTP_string(name), + MTPint())); +} + bool ChannelData::isGroupAdmin(not_null user) const { if (auto info = mgInfo.get()) { return info->admins.contains(peerToUser(user->id)); diff --git a/Telegram/SourceFiles/data/data_channel.h b/Telegram/SourceFiles/data/data_channel.h index def708ad4..452b96a11 100644 --- a/Telegram/SourceFiles/data/data_channel.h +++ b/Telegram/SourceFiles/data/data_channel.h @@ -180,6 +180,8 @@ public: const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights); + void markForbidden(); + bool isGroupAdmin(not_null user) const; bool lastParticipantsCountOutdated() const { diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 6fbfb14d5..fab66f5f4 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -2454,7 +2454,7 @@ void History::dialogEntryApplied() { if (!chatListMessage()) { if (const auto channel = peer->asChannel()) { const auto inviter = channel->inviter; - if (inviter != 0 && channel->amIn()) { + if (inviter > 0 && channel->amIn()) { if (const auto from = owner().userLoaded(inviter)) { clear(ClearType::Unload); addNewerSlice(QVector());