mirror of https://github.com/procxx/kepka.git
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) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
channel->session().api().applyUpdates(result);
|
channel->session().api().applyUpdates(result);
|
||||||
channel->applyEditAdmin(user, oldRights, newRights);
|
channel->applyEditAdmin(user, oldRights, newRights);
|
||||||
|
if (onDone) {
|
||||||
onDone();
|
onDone();
|
||||||
|
}
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
if (error.type() == qstr("USER_NOT_MUTUAL_CONTACT")) {
|
if (error.type() == qstr("USER_NOT_MUTUAL_CONTACT")) {
|
||||||
Ui::show(
|
Ui::show(
|
||||||
|
@ -147,7 +149,9 @@ void SaveChannelAdmin(
|
||||||
: lng_error_admin_limit_channel)),
|
: lng_error_admin_limit_channel)),
|
||||||
LayerOption::KeepOther);
|
LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
if (onFail) {
|
||||||
onFail();
|
onFail();
|
||||||
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,9 +169,13 @@ void SaveChannelRestriction(
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
channel->session().api().applyUpdates(result);
|
channel->session().api().applyUpdates(result);
|
||||||
channel->applyEditBanned(user, oldRights, newRights);
|
channel->applyEditBanned(user, oldRights, newRights);
|
||||||
|
if (onDone) {
|
||||||
onDone();
|
onDone();
|
||||||
|
}
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
|
if (onFail) {
|
||||||
onFail();
|
onFail();
|
||||||
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +191,7 @@ Fn<void(
|
||||||
return [=](
|
return [=](
|
||||||
const MTPChatAdminRights &oldRights,
|
const MTPChatAdminRights &oldRights,
|
||||||
const MTPChatAdminRights &newRights) {
|
const MTPChatAdminRights &newRights) {
|
||||||
const auto done = [=] { onDone(newRights); };
|
const auto done = [=] { if (onDone) onDone(newRights); };
|
||||||
const auto saveForChannel = [=](not_null<ChannelData*> channel) {
|
const auto saveForChannel = [=](not_null<ChannelData*> channel) {
|
||||||
SaveChannelAdmin(
|
SaveChannelAdmin(
|
||||||
channel,
|
channel,
|
||||||
|
@ -226,7 +234,7 @@ Fn<void(
|
||||||
return [=](
|
return [=](
|
||||||
const MTPChatBannedRights &oldRights,
|
const MTPChatBannedRights &oldRights,
|
||||||
const MTPChatBannedRights &newRights) {
|
const MTPChatBannedRights &newRights) {
|
||||||
const auto done = [=] { onDone(newRights); };
|
const auto done = [=] { if (onDone) onDone(newRights); };
|
||||||
const auto saveForChannel = [=](not_null<ChannelData*> channel) {
|
const auto saveForChannel = [=](not_null<ChannelData*> channel) {
|
||||||
SaveChannelRestriction(
|
SaveChannelRestriction(
|
||||||
channel,
|
channel,
|
||||||
|
|
|
@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "boxes/peers/edit_participant_box.h"
|
#include "boxes/peers/edit_participant_box.h"
|
||||||
|
#include "boxes/peers/edit_participants_box.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_document.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) {
|
void InnerWidget::restrictUser(
|
||||||
auto weak = QPointer<InnerWidget>(this);
|
not_null<UserData*> user,
|
||||||
MTP::send(MTPchannels_EditBanned(_channel->inputChannel, user->inputUser, newRights), rpcDone([megagroup = _channel.get(), user, weak, oldRights, newRights](const MTPUpdates &result) {
|
const MTPChatBannedRights &oldRights,
|
||||||
Auth().api().applyUpdates(result);
|
const MTPChatBannedRights &newRights) {
|
||||||
megagroup->applyEditBanned(user, oldRights, newRights);
|
const auto done = [=](const MTPChatBannedRights &newRights) {
|
||||||
if (weak) {
|
restrictUserDone(user, newRights);
|
||||||
weak->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) {
|
void InnerWidget::restrictUserDone(not_null<UserData*> user, const MTPChatBannedRights &rights) {
|
||||||
|
|
Loading…
Reference in New Issue