mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Allow deleting small groups for everyone.
This commit is contained in:
@@ -593,19 +593,49 @@ void Histories::deleteAllMessages(
|
||||
const auto fail = [=](const RPCError &error) {
|
||||
finish();
|
||||
};
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
const auto chat = peer->asChat();
|
||||
const auto channel = peer->asChannel();
|
||||
if (revoke && channel && channel->canDelete()) {
|
||||
return session().api().request(MTPchannels_DeleteChannel(
|
||||
channel->inputChannel
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
session().api().applyUpdates(result);
|
||||
//}).fail([=](const RPCError &error) {
|
||||
// if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
|
||||
// Ui::show(Box<InformBox>(tr::lng_cant_delete_channel(tr::now)));
|
||||
// }
|
||||
}).send();
|
||||
} else if (channel) {
|
||||
return session().api().request(MTPchannels_DeleteHistory(
|
||||
channel->inputChannel,
|
||||
MTP_int(deleteTillId)
|
||||
)).done([=](const MTPBool &result) {
|
||||
finish();
|
||||
}).fail(fail).send();
|
||||
} else if (revoke && peer->isChat() && peer->asChat()->amCreator()) {
|
||||
} else if (revoke && chat && chat->amCreator()) {
|
||||
return session().api().request(MTPmessages_DeleteChat(
|
||||
peer->asChat()->inputChat
|
||||
chat->inputChat
|
||||
)).done([=](const MTPBool &result) {
|
||||
finish();
|
||||
}).fail(fail).send();
|
||||
}).fail([=](const RPCError &error) {
|
||||
if (error.type() == "PEER_ID_INVALID") {
|
||||
// Try to join and delete,
|
||||
// while delete fails for non-joined.
|
||||
session().api().request(MTPmessages_AddChatUser(
|
||||
chat->inputChat,
|
||||
MTP_inputUserSelf(),
|
||||
MTP_int(0)
|
||||
)).done([=](const MTPUpdates &updates) {
|
||||
session().api().applyUpdates(updates);
|
||||
deleteAllMessages(
|
||||
history,
|
||||
deleteTillId,
|
||||
justClear,
|
||||
revoke);
|
||||
}).send();
|
||||
}
|
||||
finish();
|
||||
}).send();
|
||||
} else {
|
||||
using Flag = MTPmessages_DeleteHistory::Flag;
|
||||
const auto flags = Flag(0)
|
||||
|
Reference in New Issue
Block a user