Message: Fix forwarding service notifications

This commit is contained in:
Alexander Zinchuk 2022-12-07 03:53:40 +01:00
parent 586ed4bdb2
commit 492d0538ed
2 changed files with 11 additions and 5 deletions

View File

@ -15,7 +15,8 @@ import {
selectAllowedMessageActions, selectAllowedMessageActions,
selectCanScheduleUntilOnline, selectCanScheduleUntilOnline,
selectChat, selectChat,
selectCurrentMessageList, selectIsChatProtected, selectIsCurrentUserPremium, selectCurrentMessageList,
selectIsCurrentUserPremium,
selectIsMessageProtected, selectIsMessageProtected,
selectIsPremiumPurchaseBlocked, selectIsPremiumPurchaseBlocked,
selectMessageCustomEmojiSets, selectMessageCustomEmojiSets,
@ -505,6 +506,7 @@ export default memo(withGlobal<OwnProps>(
canRevote, canRevote,
canClosePoll, canClosePoll,
} = (threadId && selectAllowedMessageActions(global, message, threadId)) || {}; } = (threadId && selectAllowedMessageActions(global, message, threadId)) || {};
const isPinned = messageListType === 'pinned'; const isPinned = messageListType === 'pinned';
const isScheduled = messageListType === 'scheduled'; const isScheduled = messageListType === 'scheduled';
const isChannel = chat && isChatChannel(chat); const isChannel = chat && isChatChannel(chat);
@ -524,7 +526,6 @@ export default memo(withGlobal<OwnProps>(
&& !areReactionsEmpty(message.reactions) && message.reactions.canSeeList; && !areReactionsEmpty(message.reactions) && message.reactions.canSeeList;
const canRemoveReaction = isPrivate && message.reactions?.results?.some((l) => l.isChosen); const canRemoveReaction = isPrivate && message.reactions?.results?.some((l) => l.isChosen);
const isProtected = selectIsMessageProtected(global, message); const isProtected = selectIsMessageProtected(global, message);
const isChatProtected = selectIsChatProtected(global, message.chatId);
const canCopyNumber = Boolean(message.content.contact); const canCopyNumber = Boolean(message.content.contact);
const isCurrentUserPremium = selectIsCurrentUserPremium(global); const isCurrentUserPremium = selectIsCurrentUserPremium(global);
@ -544,7 +545,7 @@ export default memo(withGlobal<OwnProps>(
canDelete, canDelete,
canReport, canReport,
canEdit: !isPinned && canEdit, canEdit: !isPinned && canEdit,
canForward: message.isForwardingAllowed && !isChatProtected && !isScheduled && canForward, canForward: !isScheduled && canForward,
canFaveSticker: !isScheduled && canFaveSticker, canFaveSticker: !isScheduled && canFaveSticker,
canUnfaveSticker: !isScheduled && canUnfaveSticker, canUnfaveSticker: !isScheduled && canUnfaveSticker,
canCopy: canCopyNumber || (!isProtected && canCopy), canCopy: canCopyNumber || (!isProtected && canCopy),

View File

@ -446,7 +446,10 @@ export function selectAllowedMessageActions(global: GlobalState, message: ApiMes
|| (isChannel && (chat.isCreator || getHasAdminRight(chat, 'editMessages'))) || (isChannel && (chat.isCreator || getHasAdminRight(chat, 'editMessages')))
); );
const canForward = !isLocal && !isAction; const isChatProtected = selectIsChatProtected(global, message.chatId);
const canForward = (
!isLocal && !isAction && !isChatProtected && (message.isForwardingAllowed || isServiceNotification)
);
const hasSticker = Boolean(message.content.sticker); const hasSticker = Boolean(message.content.sticker);
const hasFavoriteSticker = hasSticker && selectIsStickerFavorite(global, message.content.sticker!); const hasFavoriteSticker = hasSticker && selectIsStickerFavorite(global, message.content.sticker!);
@ -933,7 +936,9 @@ export function selectCanForwardMessages(global: GlobalState, chatId: string, me
const messages = selectChatMessages(global, chatId); const messages = selectChatMessages(global, chatId);
return messageIds.every((messageId) => messages[messageId]?.isForwardingAllowed); return messageIds
.map((id) => messages[id])
.every((message) => message.isForwardingAllowed || isServiceNotificationMessage(message));
} }
export function selectSponsoredMessage(global: GlobalState, chatId: string) { export function selectSponsoredMessage(global: GlobalState, chatId: string) {