Message: Fix delete and edit actions for admins (#1293)

This commit is contained in:
Alexander Zinchuk 2021-07-19 01:56:33 +03:00
parent 2497488eec
commit 7c275da3f8

View File

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