diff --git a/src/global/selectors/messages.ts b/src/global/selectors/messages.ts index e9897af4d..7d97d6e57 100644 --- a/src/global/selectors/messages.ts +++ b/src/global/selectors/messages.ts @@ -627,9 +627,21 @@ export function selectAllowedMessageActionsSlow( const isDocumentSticker = isMessageDocumentSticker(message); const isBoostMessage = message.content.action?.type === 'chatBoost'; - const canEditMessagesIndefinitely = isChatWithSelf - || (isSuperGroup && getHasAdminRight(chat, 'pinMessages')) - || (isChannel && getHasAdminRight(chat, 'editMessages')); + const hasChatPinPermission = (chat.isCreator + || (!isChannel && !isUserRightBanned(chat, 'pinMessages')) + || getHasAdminRight(chat, 'pinMessages')); + + const hasPinPermission = isPrivate || hasChatPinPermission; + + // https://github.com/telegramdesktop/tdesktop/blob/335095a332607c41a8d20b47e61f5bbd66366d4b/Telegram/SourceFiles/data/data_peer.cpp#L653 + const canEditMessagesIndefinitely = (() => { + if (isPrivate) return isChatWithSelf; + if (isBasicGroup) return false; + if (isSuperGroup) return hasChatPinPermission; + if (isChannel) return chat.isCreator || getHasAdminRight(chat, 'editMessages'); + return false; + })(); + const isMessageEditable = ( ( canEditMessagesIndefinitely @@ -650,12 +662,6 @@ export function selectAllowedMessageActionsSlow( const canReplyGlobally = canReply || (!isSavedDialog && !isLocal && !isServiceNotification && (isSuperGroup || isBasicGroup || isChatChannel(chat))); - const hasPinPermission = isPrivate || ( - chat.isCreator - || (!isChannel && !isUserRightBanned(chat, 'pinMessages')) - || getHasAdminRight(chat, 'pinMessages') - ); - let canPin = !isLocal && !isServiceNotification && !isAction && hasPinPermission && !isSavedDialog; let canUnpin = false;