Messages: Change permissions for editing messages in groups (#5036)
Co-authored-by: zubiden <19638254+zubiden@users.noreply.github.com>
This commit is contained in:
parent
52865fb7e8
commit
63e5b9529f
@ -627,9 +627,21 @@ export function selectAllowedMessageActionsSlow<T extends GlobalState>(
|
|||||||
const isDocumentSticker = isMessageDocumentSticker(message);
|
const isDocumentSticker = isMessageDocumentSticker(message);
|
||||||
const isBoostMessage = message.content.action?.type === 'chatBoost';
|
const isBoostMessage = message.content.action?.type === 'chatBoost';
|
||||||
|
|
||||||
const canEditMessagesIndefinitely = isChatWithSelf
|
const hasChatPinPermission = (chat.isCreator
|
||||||
|| (isSuperGroup && getHasAdminRight(chat, 'pinMessages'))
|
|| (!isChannel && !isUserRightBanned(chat, 'pinMessages'))
|
||||||
|| (isChannel && getHasAdminRight(chat, 'editMessages'));
|
|| 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 = (
|
const isMessageEditable = (
|
||||||
(
|
(
|
||||||
canEditMessagesIndefinitely
|
canEditMessagesIndefinitely
|
||||||
@ -650,12 +662,6 @@ export function selectAllowedMessageActionsSlow<T extends GlobalState>(
|
|||||||
const canReplyGlobally = canReply || (!isSavedDialog && !isLocal && !isServiceNotification
|
const canReplyGlobally = canReply || (!isSavedDialog && !isLocal && !isServiceNotification
|
||||||
&& (isSuperGroup || isBasicGroup || isChatChannel(chat)));
|
&& (isSuperGroup || isBasicGroup || isChatChannel(chat)));
|
||||||
|
|
||||||
const hasPinPermission = isPrivate || (
|
|
||||||
chat.isCreator
|
|
||||||
|| (!isChannel && !isUserRightBanned(chat, 'pinMessages'))
|
|
||||||
|| getHasAdminRight(chat, 'pinMessages')
|
|
||||||
);
|
|
||||||
|
|
||||||
let canPin = !isLocal && !isServiceNotification && !isAction && hasPinPermission && !isSavedDialog;
|
let canPin = !isLocal && !isServiceNotification && !isAction && hasPinPermission && !isSavedDialog;
|
||||||
let canUnpin = false;
|
let canUnpin = false;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user