From 1b649299ff282d35f1c120c6386ae1434ac71287 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 17 Jun 2017 12:00:50 +0300 Subject: [PATCH] Show edit admin non-mutual-contact error message. --- .../profile/profile_channel_controllers.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/profile/profile_channel_controllers.cpp b/Telegram/SourceFiles/profile/profile_channel_controllers.cpp index e4267591ad..42704a8ee2 100644 --- a/Telegram/SourceFiles/profile/profile_channel_controllers.cpp +++ b/Telegram/SourceFiles/profile/profile_channel_controllers.cpp @@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "boxes/edit_participant_box.h" #include "boxes/confirm_box.h" +#include "boxes/contacts_box.h" #include "auth_session.h" #include "apiwrap.h" #include "lang/lang_keys.h" @@ -662,13 +663,21 @@ void AddParticipantBoxController::editAdmin(gsl::not_null user, bool } // Finally edit the admin. - _editBox = Ui::show(Box(_channel, user, currentRights, [megagroup = _channel.get(), user, weak](const MTPChannelAdminRights &rights) { - MTP::send(MTPchannels_EditAdmin(megagroup->inputChannel, user->inputUser, rights), rpcDone([megagroup, user, weak, rights](const MTPUpdates &result) { + _editBox = Ui::show(Box(_channel, user, currentRights, [channel = _channel.get(), user, weak](const MTPChannelAdminRights &rights) { + MTP::send(MTPchannels_EditAdmin(channel->inputChannel, user->inputUser, rights), rpcDone([channel, user, weak, rights](const MTPUpdates &result) { AuthSession::Current().api().applyUpdates(result); - megagroup->applyEditAdmin(user, rights); + channel->applyEditAdmin(user, rights); if (weak) { weak->editAdminDone(user, rights); } + }), rpcFail([channel](const RPCError &error) { + if (MTP::isDefaultHandledError(error)) { + return false; + } + if (error.type() == qstr("USER_NOT_MUTUAL_CONTACT")) { + Ui::show(Box(PeerFloodErrorText(channel->isMegagroup() ? PeerFloodType::InviteGroup : PeerFloodType::InviteChannel)), KeepOtherLayers); + } + return true; })); }), KeepOtherLayers); }