2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Allow supergroup members to clear history.

This commit is contained in:
John Preston
2017-11-21 20:38:17 +04:00
parent 75d8d01b17
commit 2387b66e86
12 changed files with 105 additions and 53 deletions

View File

@@ -1059,22 +1059,21 @@ namespace {
return false;
}
template <typename TMTPDclass>
void updateEditedMessage(const TMTPDclass &m) {
auto peerId = peerFromMTP(m.vto_id);
if (m.has_from_id() && peerId == Auth().userPeerId()) {
peerId = peerFromUser(m.vfrom_id);
}
if (auto existing = App::histItemById(peerToChannel(peerId), m.vid.v)) {
existing->applyEdition(m);
}
}
void updateEditedMessage(const MTPMessage &m) {
auto apply = [](const auto &data) {
auto peerId = peerFromMTP(data.vto_id);
if (data.has_from_id() && peerId == Auth().userPeerId()) {
peerId = peerFromUser(data.vfrom_id);
}
if (auto existing = App::histItemById(peerToChannel(peerId), data.vid.v)) {
existing->applyEdition(data);
}
};
if (m.type() == mtpc_message) { // apply message edit
App::updateEditedMessage(m.c_message());
apply(m.c_message());
} else if (m.type() == mtpc_messageService) {
App::updateEditedMessage(m.c_messageService());
apply(m.c_messageService());
}
}