mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-21 15:47:38 +00:00
Allow chat creator/admins to delete for everyone.
Chat creator and admins (if admins are enabled) now can delete any message for everyone, not only outgoing ones.
This commit is contained in:
parent
4c2a0fa630
commit
413eafb240
@ -753,6 +753,10 @@ void HistoryItem::setId(MsgId newId) {
|
||||
}
|
||||
}
|
||||
|
||||
bool HistoryItem::canPin() const {
|
||||
return id > 0 && _history->peer->isMegagroup() && (_history->peer->asChannel()->amEditor() || _history->peer->asChannel()->amCreator()) && toHistoryMessage();
|
||||
}
|
||||
|
||||
bool HistoryItem::canEdit(const QDateTime &cur) const {
|
||||
auto messageToMyself = (_history->peer->id == AuthSession::CurrentUserPeerId());
|
||||
auto messageTooOld = messageToMyself ? false : (date.secsTo(cur) >= Global::EditTimeLimit());
|
||||
@ -779,20 +783,49 @@ bool HistoryItem::canEdit(const QDateTime &cur) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HistoryItem::canDelete() const {
|
||||
auto channel = _history->peer->asChannel();
|
||||
if (!channel) {
|
||||
return !(_flags & MTPDmessage_ClientFlag::f_is_group_migrate);
|
||||
}
|
||||
|
||||
if (id == 1) {
|
||||
return false;
|
||||
}
|
||||
if (channel->amCreator()) {
|
||||
return true;
|
||||
}
|
||||
if (isPost()) {
|
||||
if (channel->amEditor() && out()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return (channel->amEditor() || channel->amModerator() || out());
|
||||
}
|
||||
|
||||
bool HistoryItem::canDeleteForEveryone(const QDateTime &cur) const {
|
||||
auto messageToMyself = (_history->peer->id == AuthSession::CurrentUserPeerId());
|
||||
auto messageTooOld = messageToMyself ? false : (date.secsTo(cur) >= Global::EditTimeLimit());
|
||||
if (id < 0 || messageToMyself || messageTooOld) {
|
||||
if (id < 0 || messageToMyself || messageTooOld || isPost()) {
|
||||
return false;
|
||||
}
|
||||
if (history()->peer->isChannel()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto msg = toHistoryMessage()) {
|
||||
return !isPost() && out();
|
||||
if (!toHistoryMessage()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
if (!out()) {
|
||||
if (auto chat = history()->peer->asChat()) {
|
||||
if (!chat->amCreator() && (!chat->amAdmin() || !chat->adminsEnabled())) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString HistoryItem::directLink() const {
|
||||
|
@ -684,24 +684,9 @@ public:
|
||||
return _text.isEmpty();
|
||||
}
|
||||
|
||||
bool canDelete() const {
|
||||
auto channel = _history->peer->asChannel();
|
||||
if (!channel) return !(_flags & MTPDmessage_ClientFlag::f_is_group_migrate);
|
||||
|
||||
if (id == 1) return false;
|
||||
if (channel->amCreator()) return true;
|
||||
if (isPost()) {
|
||||
if (channel->amEditor() && out()) return true;
|
||||
return false;
|
||||
}
|
||||
return (channel->amEditor() || channel->amModerator() || out());
|
||||
}
|
||||
|
||||
bool canPin() const {
|
||||
return id > 0 && _history->peer->isMegagroup() && (_history->peer->asChannel()->amEditor() || _history->peer->asChannel()->amCreator()) && toHistoryMessage();
|
||||
}
|
||||
|
||||
bool canPin() const;
|
||||
bool canEdit(const QDateTime &cur) const;
|
||||
bool canDelete() const;
|
||||
bool canDeleteForEveryone(const QDateTime &cur) const;
|
||||
|
||||
bool suggestBanReportDeleteAll() const {
|
||||
|
Loading…
Reference in New Issue
Block a user