From 04882ed746caddd665287d4d00d738960e87071a Mon Sep 17 00:00:00 2001 From: leha-bot Date: Wed, 17 Oct 2018 21:22:34 +0300 Subject: [PATCH] Allow edit messages older than 2 days in sgroups This feature is cherry-picked from https://github.com/telegramdesktop/tdesktop/commit/75d8d01b1754e4f9c6ffc601848455bda9c4516d#diff-c0b32cc8ed01e3b1cdbfd5427184a41dL874 --- Telegram/SourceFiles/history/history_item.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index c87e44402..4ca52fda5 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -856,7 +856,15 @@ bool HistoryItem::canForward() const { bool HistoryItem::canEdit(const QDateTime &cur) const { auto messageToMyself = _history->peer->isSelf(); - auto messageTooOld = messageToMyself ? false : (date.secsTo(cur) >= Global::EditTimeLimit()); + auto canPinInMegagroup = [&] { + if (auto megagroup = _history->peer->asMegagroup()) { + return megagroup->canPinMessages(); + } + return false; + }(); + + auto messageTooOld = (messageToMyself || canPinInMegagroup) ? false : (date.secsTo(cur) >= Global::EditTimeLimit()); + if (id < 0 || messageTooOld) { return false; }