From 155c62e1b80c3f9aed9ecec8b5ace312800ca20d Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Fri, 25 Jul 2025 19:34:51 +0200 Subject: [PATCH] Chat: Fix applying unban (#6075) --- src/api/gramjs/apiBuilders/chats.ts | 18 +++++++----------- .../modals/chatInvite/ChatInviteModal.tsx | 8 +++++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/api/gramjs/apiBuilders/chats.ts b/src/api/gramjs/apiBuilders/chats.ts index 2cc342f87..93e9759d2 100644 --- a/src/api/gramjs/apiBuilders/chats.ts +++ b/src/api/gramjs/apiBuilders/chats.ts @@ -192,7 +192,7 @@ function buildApiChatPermissions(peerEntity: GramJs.TypeUser | GramJs.TypeChat): }; } -function buildApiChatRestrictions(peerEntity: GramJs.TypeUser | GramJs.TypeChat): { +function buildApiChatRestrictions(peerEntity: Entity): { isNotJoined?: boolean; isForbidden?: boolean; isRestricted?: boolean; @@ -212,17 +212,13 @@ function buildApiChatRestrictions(peerEntity: GramJs.TypeUser | GramJs.TypeChat) const restrictions = {}; - if ('restricted' in peerEntity) { - const restrictionReason = peerEntity.restricted - ? buildApiChatRestrictionReason(peerEntity.restrictionReason) - : undefined; + if ('restricted' in peerEntity && !peerEntity.min) { + const restrictionReason = buildApiChatRestrictionReason(peerEntity.restrictionReason); - if (restrictionReason) { - Object.assign(restrictions, { - isRestricted: true, - restrictionReason, - }); - } + Object.assign(restrictions, { + isRestricted: peerEntity.restricted, + restrictionReason, + }); } if (peerEntity instanceof GramJs.Chat) { diff --git a/src/components/modals/chatInvite/ChatInviteModal.tsx b/src/components/modals/chatInvite/ChatInviteModal.tsx index 3e767fd72..97f5ad6f4 100644 --- a/src/components/modals/chatInvite/ChatInviteModal.tsx +++ b/src/components/modals/chatInvite/ChatInviteModal.tsx @@ -43,9 +43,11 @@ const ChatInviteModal = ({ modal }: OwnProps) => { const handleAccept = useLastCallback(() => { acceptChatInvite({ hash: hash! }); - showNotification({ - message: isBroadcast ? lang('RequestToJoinChannelSentDescription') : lang('RequestToJoinGroupSentDescription'), - }); + if (isRequestNeeded) { + showNotification({ + message: isBroadcast ? lang('RequestToJoinChannelSentDescription') : lang('RequestToJoinGroupSentDescription'), + }); + } handleClose(); });