2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Save slowmode settings in groups.

This commit is contained in:
John Preston
2019-07-16 13:46:50 +02:00
parent 1d2c86839b
commit 328b090877
8 changed files with 289 additions and 139 deletions

View File

@@ -1896,43 +1896,6 @@ void ApiWrap::unblockParticipant(
_kickRequests.emplace(kick, requestId);
}
void ApiWrap::saveDefaultRestrictions(
not_null<PeerData*> peer,
const MTPChatBannedRights &rights,
Fn<void(bool)> callback) {
if (_defaultRestrictionsRequests.contains(peer)) {
return;
}
const auto requestId = request(MTPmessages_EditChatDefaultBannedRights(
peer->input,
rights
)).done([=](const MTPUpdates &result) {
_defaultRestrictionsRequests.erase(peer);
applyUpdates(result);
if (callback) {
callback(true);
}
}).fail([=](const RPCError &error) {
_defaultRestrictionsRequests.erase(peer);
if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
if (const auto chat = peer->asChat()) {
chat->setDefaultRestrictions(rights);
} else if (const auto channel = peer->asChannel()) {
channel->setDefaultRestrictions(rights);
} else {
Unexpected("Peer in ApiWrap::saveDefaultRestrictions.");
}
if (callback) {
callback(true);
}
return;
}
if (callback) {
callback(false);
}
}).send();
}
void ApiWrap::deleteAllFromUser(
not_null<ChannelData*> channel,
not_null<UserData*> from) {
@@ -2683,6 +2646,22 @@ void ApiWrap::checkQuitPreventFinished() {
}
}
void ApiWrap::registerModifyRequest(
const QString &key,
mtpRequestId requestId) {
const auto i = _modifyRequests.find(key);
if (i != end(_modifyRequests)) {
request(i->second).cancel();
i->second = requestId;
} else {
_modifyRequests.emplace(key, requestId);
}
}
void ApiWrap::clearModifyRequest(const QString &key) {
_modifyRequests.remove(key);
}
void ApiWrap::applyNotifySettings(
MTPInputNotifyPeer notifyPeer,
const MTPPeerNotifySettings &settings) {