From 7c275da3f8779232222853da73e70b247bdbae32 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Mon, 19 Jul 2021 01:56:33 +0300 Subject: [PATCH] Message: Fix delete and edit actions for admins (#1293) --- src/modules/selectors/messages.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/selectors/messages.ts b/src/modules/selectors/messages.ts index 85e2ee26..5efac836 100644 --- a/src/modules/selectors/messages.ts +++ b/src/modules/selectors/messages.ts @@ -356,8 +356,12 @@ export function selectAllowedMessageActions(global: GlobalState, message: ApiMes const isOwn = isOwnMessage(message); const isAction = isActionMessage(message); const { content } = message; + const canEditMessagesIndefinitely = isChatWithSelf + || (isSuperGroup && getHasAdminRight(chat, 'pinMessages')) + || (isChannel && getHasAdminRight(chat, 'editMessages')); const isMessageEditable = ( - (isChatWithSelf || Date.now() + serverTimeOffset * 1000 - message.date * 1000 < MESSAGE_EDIT_ALLOWED_TIME_MS) + (canEditMessagesIndefinitely + || Date.now() + serverTimeOffset * 1000 - message.date * 1000 < MESSAGE_EDIT_ALLOWED_TIME_MS) && !( content.sticker || content.contact || content.poll || content.action || content.audio || (content.video && content.video.isRound) @@ -395,7 +399,7 @@ export function selectAllowedMessageActions(global: GlobalState, message: ApiMes const canDeleteForAll = canDelete && !isServiceNotification && ( (isPrivate && !isChatWithSelf) || (isBasicGroup && ( - isOwn || getHasAdminRight(chat, 'deleteMessages') + isOwn || getHasAdminRight(chat, 'deleteMessages') || chat.isCreator )) );