mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Allow saving boosts to lift restrictions.
This commit is contained in:
@@ -198,6 +198,37 @@ void SaveSlowmodeSeconds(
|
||||
api->registerModifyRequest(key, requestId);
|
||||
}
|
||||
|
||||
void SaveBoostsUnrestrict(
|
||||
not_null<ChannelData*> channel,
|
||||
int boostsUnrestrict,
|
||||
Fn<void()> done) {
|
||||
const auto api = &channel->session().api();
|
||||
const auto key = Api::RequestKey("boosts_unrestrict", channel->id);
|
||||
const auto requestId = api->request(
|
||||
MTPchannels_SetBoostsToUnblockRestrictions(
|
||||
channel->inputChannel,
|
||||
MTP_int(boostsUnrestrict))
|
||||
).done([=](const MTPUpdates &result) {
|
||||
api->clearModifyRequest(key);
|
||||
api->applyUpdates(result);
|
||||
channel->setBoostsUnrestrict(
|
||||
channel->boostsApplied(),
|
||||
boostsUnrestrict);
|
||||
done();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
api->clearModifyRequest(key);
|
||||
if (error.type() != u"CHAT_NOT_MODIFIED"_q) {
|
||||
return;
|
||||
}
|
||||
channel->setBoostsUnrestrict(
|
||||
channel->boostsApplied(),
|
||||
boostsUnrestrict);
|
||||
done();
|
||||
}).send();
|
||||
|
||||
api->registerModifyRequest(key, requestId);
|
||||
}
|
||||
|
||||
void ShowEditPermissions(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer) {
|
||||
@@ -215,6 +246,10 @@ void ShowEditPermissions(
|
||||
close);
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
SaveSlowmodeSeconds(channel, result.slowmodeSeconds, close);
|
||||
SaveBoostsUnrestrict(
|
||||
channel,
|
||||
result.boostsUnrestrict,
|
||||
close);
|
||||
}
|
||||
};
|
||||
auto done = [=](EditPeerPermissionsBoxResult result) {
|
||||
@@ -225,7 +260,8 @@ void ShowEditPermissions(
|
||||
|
||||
const auto saveFor = peer->migrateToOrMe();
|
||||
const auto chat = saveFor->asChat();
|
||||
if (!result.slowmodeSeconds || !chat) {
|
||||
if (!chat
|
||||
|| (!result.slowmodeSeconds && !result.boostsUnrestrict)) {
|
||||
save(saveFor, result);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user