From 686e9643ad2fdaa31e261e0704cc2ae3b7d99dcb Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 9 Sep 2024 14:43:43 +0300 Subject: [PATCH] Replaced channel participant parsing with modern way in admin log. --- .../admin_log/history_admin_log_inner.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index b78878335d..d90bc322ce 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -1550,20 +1550,20 @@ void InnerWidget::suggestRestrictParticipant( _channel->inputChannel, user->input )).done([=](const MTPchannels_ChannelParticipant &result) { - Expects(result.type() == mtpc_channels_channelParticipant); + user->owner().processUsers(result.data().vusers()); - auto &participant = result.c_channels_channelParticipant(); - _channel->owner().processUsers(participant.vusers()); - auto type = participant.vparticipant().type(); - if (type == mtpc_channelParticipantBanned) { - auto &banned = participant.vparticipant().c_channelParticipantBanned(); + const auto participant = Api::ChatParticipant( + result.data().vparticipant(), + user); + using Type = Api::ChatParticipant::Type; + if (participant.type() == Type::Creator + || participant.type() == Type::Admin) { + editRestrictions(true, {}); + } else if (participant.type() == Type::Restricted + || participant.type() == Type::Banned) { editRestrictions( false, - ChatRestrictionsInfo(banned.vbanned_rights())); - } else { - auto hasAdminRights = (type == mtpc_channelParticipantAdmin) - || (type == mtpc_channelParticipantCreator); - editRestrictions(hasAdminRights, ChatRestrictionsInfo()); + participant.restrictions()); } }).fail([=] { editRestrictions(false, ChatRestrictionsInfo());