mirror of https://github.com/procxx/kepka.git
Use new config fields for revoke settings.
This commit is contained in:
parent
dd1beb1d91
commit
a0eb64428e
|
@ -515,6 +515,9 @@ struct Data {
|
||||||
int32 PushChatLimit = 2;
|
int32 PushChatLimit = 2;
|
||||||
int32 SavedGifsLimit = 200;
|
int32 SavedGifsLimit = 200;
|
||||||
int32 EditTimeLimit = 172800;
|
int32 EditTimeLimit = 172800;
|
||||||
|
int32 RevokeTimeLimit = 172800;
|
||||||
|
int32 RevokePrivateTimeLimit = 172800;
|
||||||
|
bool RevokePrivateInbox = false;
|
||||||
int32 StickersRecentLimit = 30;
|
int32 StickersRecentLimit = 30;
|
||||||
int32 StickersFavedLimit = 5;
|
int32 StickersFavedLimit = 5;
|
||||||
int32 PinnedDialogsCountMax = 5;
|
int32 PinnedDialogsCountMax = 5;
|
||||||
|
@ -634,6 +637,9 @@ DefineVar(Global, int32, PushChatPeriod);
|
||||||
DefineVar(Global, int32, PushChatLimit);
|
DefineVar(Global, int32, PushChatLimit);
|
||||||
DefineVar(Global, int32, SavedGifsLimit);
|
DefineVar(Global, int32, SavedGifsLimit);
|
||||||
DefineVar(Global, int32, EditTimeLimit);
|
DefineVar(Global, int32, EditTimeLimit);
|
||||||
|
DefineVar(Global, int32, RevokeTimeLimit);
|
||||||
|
DefineVar(Global, int32, RevokePrivateTimeLimit);
|
||||||
|
DefineVar(Global, bool, RevokePrivateInbox);
|
||||||
DefineVar(Global, int32, StickersRecentLimit);
|
DefineVar(Global, int32, StickersRecentLimit);
|
||||||
DefineVar(Global, int32, StickersFavedLimit);
|
DefineVar(Global, int32, StickersFavedLimit);
|
||||||
DefineVar(Global, int32, PinnedDialogsCountMax);
|
DefineVar(Global, int32, PinnedDialogsCountMax);
|
||||||
|
|
|
@ -332,6 +332,9 @@ DeclareVar(int32, PushChatPeriod);
|
||||||
DeclareVar(int32, PushChatLimit);
|
DeclareVar(int32, PushChatLimit);
|
||||||
DeclareVar(int32, SavedGifsLimit);
|
DeclareVar(int32, SavedGifsLimit);
|
||||||
DeclareVar(int32, EditTimeLimit);
|
DeclareVar(int32, EditTimeLimit);
|
||||||
|
DeclareVar(int32, RevokeTimeLimit);
|
||||||
|
DeclareVar(int32, RevokePrivateTimeLimit);
|
||||||
|
DeclareVar(bool, RevokePrivateInbox);
|
||||||
DeclareVar(int32, StickersRecentLimit);
|
DeclareVar(int32, StickersRecentLimit);
|
||||||
DeclareVar(int32, StickersFavedLimit);
|
DeclareVar(int32, StickersFavedLimit);
|
||||||
DeclareVar(int32, PinnedDialogsCountMax);
|
DeclareVar(int32, PinnedDialogsCountMax);
|
||||||
|
|
|
@ -367,16 +367,19 @@ bool HistoryItem::canDelete() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryItem::canDeleteForEveryone(TimeId now) const {
|
bool HistoryItem::canDeleteForEveryone(TimeId now) const {
|
||||||
auto messageToMyself = _history->peer->isSelf();
|
const auto peer = history()->peer;
|
||||||
auto messageTooOld = messageToMyself
|
const auto messageToMyself = peer->isSelf();
|
||||||
|
const auto messageTooOld = messageToMyself
|
||||||
? false
|
? false
|
||||||
: (now >= date() + Global::EditTimeLimit());
|
: peer->isUser()
|
||||||
|
? (now >= date() + Global::RevokePrivateTimeLimit())
|
||||||
|
: (now >= date() + Global::RevokeTimeLimit());
|
||||||
if (id < 0 || messageToMyself || messageTooOld || isPost()) {
|
if (id < 0 || messageToMyself || messageTooOld || isPost()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (history()->peer->isChannel()) {
|
if (peer->isChannel()) {
|
||||||
return false;
|
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.
|
// Bots receive all messages and there is no sense in revoking them.
|
||||||
// See https://github.com/telegramdesktop/tdesktop/issues/3818
|
// See https://github.com/telegramdesktop/tdesktop/issues/3818
|
||||||
if (user->botInfo) {
|
if (user->botInfo) {
|
||||||
|
@ -385,17 +388,18 @@ bool HistoryItem::canDeleteForEveryone(TimeId now) const {
|
||||||
}
|
}
|
||||||
if (!toHistoryMessage()) {
|
if (!toHistoryMessage()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (const auto media = this->media()) {
|
||||||
if (const auto media = this->media()) {
|
|
||||||
if (!media->allowsRevoke()) {
|
if (!media->allowsRevoke()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!out()) {
|
if (!out()) {
|
||||||
if (auto chat = history()->peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
if (!chat->amCreator() && (!chat->amAdmin() || !chat->adminsEnabled())) {
|
if (!chat->amCreator() && (!chat->amAdmin() || !chat->adminsEnabled())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if (peer->isUser()) {
|
||||||
|
return Global::RevokePrivateInbox();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -602,6 +602,9 @@ void Instance::Private::configLoadDone(const MTPConfig &result) {
|
||||||
Global::SetPushChatLimit(data.vpush_chat_limit.v);
|
Global::SetPushChatLimit(data.vpush_chat_limit.v);
|
||||||
Global::SetSavedGifsLimit(data.vsaved_gifs_limit.v);
|
Global::SetSavedGifsLimit(data.vsaved_gifs_limit.v);
|
||||||
Global::SetEditTimeLimit(data.vedit_time_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::SetStickersRecentLimit(data.vstickers_recent_limit.v);
|
||||||
Global::SetStickersFavedLimit(data.vstickers_faved_limit.v);
|
Global::SetStickersFavedLimit(data.vstickers_faved_limit.v);
|
||||||
Global::SetPinnedDialogsCountMax(data.vpinned_dialogs_count_max.v);
|
Global::SetPinnedDialogsCountMax(data.vpinned_dialogs_count_max.v);
|
||||||
|
|
Loading…
Reference in New Issue