mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-18 08:39:30 +00:00
Use one place for saving restrictions.
This commit is contained in:
parent
287b3509ab
commit
04350af96f
@ -127,7 +127,9 @@ void SaveChannelAdmin(
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
channel->session().api().applyUpdates(result);
|
||||
channel->applyEditAdmin(user, oldRights, newRights);
|
||||
onDone();
|
||||
if (onDone) {
|
||||
onDone();
|
||||
}
|
||||
}).fail([=](const RPCError &error) {
|
||||
if (error.type() == qstr("USER_NOT_MUTUAL_CONTACT")) {
|
||||
Ui::show(
|
||||
@ -147,7 +149,9 @@ void SaveChannelAdmin(
|
||||
: lng_error_admin_limit_channel)),
|
||||
LayerOption::KeepOther);
|
||||
}
|
||||
onFail();
|
||||
if (onFail) {
|
||||
onFail();
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
|
||||
@ -165,9 +169,13 @@ void SaveChannelRestriction(
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
channel->session().api().applyUpdates(result);
|
||||
channel->applyEditBanned(user, oldRights, newRights);
|
||||
onDone();
|
||||
if (onDone) {
|
||||
onDone();
|
||||
}
|
||||
}).fail([=](const RPCError &error) {
|
||||
onFail();
|
||||
if (onFail) {
|
||||
onFail();
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
|
||||
@ -183,7 +191,7 @@ Fn<void(
|
||||
return [=](
|
||||
const MTPChatAdminRights &oldRights,
|
||||
const MTPChatAdminRights &newRights) {
|
||||
const auto done = [=] { onDone(newRights); };
|
||||
const auto done = [=] { if (onDone) onDone(newRights); };
|
||||
const auto saveForChannel = [=](not_null<ChannelData*> channel) {
|
||||
SaveChannelAdmin(
|
||||
channel,
|
||||
@ -226,7 +234,7 @@ Fn<void(
|
||||
return [=](
|
||||
const MTPChatBannedRights &oldRights,
|
||||
const MTPChatBannedRights &newRights) {
|
||||
const auto done = [=] { onDone(newRights); };
|
||||
const auto done = [=] { if (onDone) onDone(newRights); };
|
||||
const auto saveForChannel = [=](not_null<ChannelData*> channel) {
|
||||
SaveChannelRestriction(
|
||||
channel,
|
||||
|
@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/file_utilities.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/peers/edit_participant_box.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
@ -1189,15 +1190,19 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
|
||||
});
|
||||
}
|
||||
|
||||
void InnerWidget::restrictUser(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
|
||||
auto weak = QPointer<InnerWidget>(this);
|
||||
MTP::send(MTPchannels_EditBanned(_channel->inputChannel, user->inputUser, newRights), rpcDone([megagroup = _channel.get(), user, weak, oldRights, newRights](const MTPUpdates &result) {
|
||||
Auth().api().applyUpdates(result);
|
||||
megagroup->applyEditBanned(user, oldRights, newRights);
|
||||
if (weak) {
|
||||
weak->restrictUserDone(user, newRights);
|
||||
}
|
||||
}));
|
||||
void InnerWidget::restrictUser(
|
||||
not_null<UserData*> user,
|
||||
const MTPChatBannedRights &oldRights,
|
||||
const MTPChatBannedRights &newRights) {
|
||||
const auto done = [=](const MTPChatBannedRights &newRights) {
|
||||
restrictUserDone(user, newRights);
|
||||
};
|
||||
const auto callback = SaveRestrictedCallback(
|
||||
_channel,
|
||||
user,
|
||||
crl::guard(this, done),
|
||||
nullptr);
|
||||
callback(oldRights, newRights);
|
||||
}
|
||||
|
||||
void InnerWidget::restrictUserDone(not_null<UserData*> user, const MTPChatBannedRights &rights) {
|
||||
|
Loading…
Reference in New Issue
Block a user