diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 3913429ee5..4c1c37f9a2 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -515,6 +515,9 @@ struct Data { int32 PushChatLimit = 2; int32 SavedGifsLimit = 200; int32 EditTimeLimit = 172800; + int32 RevokeTimeLimit = 172800; + int32 RevokePrivateTimeLimit = 172800; + bool RevokePrivateInbox = false; int32 StickersRecentLimit = 30; int32 StickersFavedLimit = 5; int32 PinnedDialogsCountMax = 5; @@ -634,6 +637,9 @@ DefineVar(Global, int32, PushChatPeriod); DefineVar(Global, int32, PushChatLimit); DefineVar(Global, int32, SavedGifsLimit); DefineVar(Global, int32, EditTimeLimit); +DefineVar(Global, int32, RevokeTimeLimit); +DefineVar(Global, int32, RevokePrivateTimeLimit); +DefineVar(Global, bool, RevokePrivateInbox); DefineVar(Global, int32, StickersRecentLimit); DefineVar(Global, int32, StickersFavedLimit); DefineVar(Global, int32, PinnedDialogsCountMax); diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 3028dcb789..3ec3f7bb08 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -332,6 +332,9 @@ DeclareVar(int32, PushChatPeriod); DeclareVar(int32, PushChatLimit); DeclareVar(int32, SavedGifsLimit); DeclareVar(int32, EditTimeLimit); +DeclareVar(int32, RevokeTimeLimit); +DeclareVar(int32, RevokePrivateTimeLimit); +DeclareVar(bool, RevokePrivateInbox); DeclareVar(int32, StickersRecentLimit); DeclareVar(int32, StickersFavedLimit); DeclareVar(int32, PinnedDialogsCountMax); diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 71014e4e62..dc9b72499e 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -367,16 +367,19 @@ bool HistoryItem::canDelete() const { } bool HistoryItem::canDeleteForEveryone(TimeId now) const { - auto messageToMyself = _history->peer->isSelf(); - auto messageTooOld = messageToMyself + const auto peer = history()->peer; + const auto messageToMyself = peer->isSelf(); + const auto messageTooOld = messageToMyself ? false - : (now >= date() + Global::EditTimeLimit()); + : peer->isUser() + ? (now >= date() + Global::RevokePrivateTimeLimit()) + : (now >= date() + Global::RevokeTimeLimit()); if (id < 0 || messageToMyself || messageTooOld || isPost()) { return false; } - if (history()->peer->isChannel()) { + if (peer->isChannel()) { return false; - } else if (auto user = history()->peer->asUser()) { + } else if (const auto user = peer->asUser()) { // Bots receive all messages and there is no sense in revoking them. // See https://github.com/telegramdesktop/tdesktop/issues/3818 if (user->botInfo) { @@ -385,17 +388,18 @@ bool HistoryItem::canDeleteForEveryone(TimeId now) const { } if (!toHistoryMessage()) { return false; - } - if (const auto media = this->media()) { + } else if (const auto media = this->media()) { if (!media->allowsRevoke()) { return false; } } if (!out()) { - if (auto chat = history()->peer->asChat()) { + if (const auto chat = peer->asChat()) { if (!chat->amCreator() && (!chat->amAdmin() || !chat->adminsEnabled())) { return false; } + } else if (peer->isUser()) { + return Global::RevokePrivateInbox(); } else { return false; } diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index de208b1ad0..d1056d7562 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -602,6 +602,9 @@ void Instance::Private::configLoadDone(const MTPConfig &result) { Global::SetPushChatLimit(data.vpush_chat_limit.v); Global::SetSavedGifsLimit(data.vsaved_gifs_limit.v); Global::SetEditTimeLimit(data.vedit_time_limit.v); + Global::SetRevokeTimeLimit(data.vrevoke_time_limit.v); + Global::SetRevokePrivateTimeLimit(data.vrevoke_pm_time_limit.v); + Global::SetRevokePrivateInbox(data.is_revoke_pm_inbox()); Global::SetStickersRecentLimit(data.vstickers_recent_limit.v); Global::SetStickersFavedLimit(data.vstickers_faved_limit.v); Global::SetPinnedDialogsCountMax(data.vpinned_dialogs_count_max.v);