Use new config fields for revoke settings.

This commit is contained in:
John Preston 2018-03-11 21:50:24 +03:00
parent dd1beb1d91
commit a0eb64428e
4 changed files with 24 additions and 8 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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);