diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -173,10 +173,11 @@ return hasPermission(threadInfo.currentUser.permissions, permission); } - const threadFrozen = threadFrozenDueToBlock( + const threadFrozen = innerThreadFrozenDueToBlock( threadInfo, loggedInUserInfo.id, userInfos, + true, ); const permissions = threadFrozen @@ -876,15 +877,21 @@ }; } +type ThreadIsWithBlockedUserOnlyOptions = { + +checkOnlyViewerBlock: boolean, + +skipMemberAdminRoleCheck: boolean, +}; + function threadIsWithBlockedUserOnly( threadInfo: LegacyRawThreadInfo | RawThreadInfo | ThreadInfo, viewerID: ?string, userInfos: UserInfos, - checkOnlyViewerBlock: boolean, + options: ThreadIsWithBlockedUserOnlyOptions, ): boolean { + const { checkOnlyViewerBlock, skipMemberAdminRoleCheck } = options; if ( threadOrParentThreadIsGroupChat(threadInfo) || - threadOrParentThreadHasAdminRole(threadInfo) + (!skipMemberAdminRoleCheck && threadOrParentThreadHasAdminRole(threadInfo)) ) { return false; } @@ -908,12 +915,26 @@ ); } +function innerThreadFrozenDueToBlock( + threadInfo: LegacyRawThreadInfo | RawThreadInfo | ThreadInfo, + viewerID: ?string, + userInfos: UserInfos, + skipMemberAdminRoleCheck: boolean, +): boolean { + const options: ThreadIsWithBlockedUserOnlyOptions = { + checkOnlyViewerBlock: false, + skipMemberAdminRoleCheck, + }; + + return threadIsWithBlockedUserOnly(threadInfo, viewerID, userInfos, options); +} + function threadFrozenDueToBlock( threadInfo: LegacyRawThreadInfo | RawThreadInfo | ThreadInfo, viewerID: ?string, userInfos: UserInfos, ): boolean { - return threadIsWithBlockedUserOnly(threadInfo, viewerID, userInfos, false); + return innerThreadFrozenDueToBlock(threadInfo, viewerID, userInfos, false); } function threadFrozenDueToViewerBlock( @@ -922,7 +943,12 @@ viewerID: ?string, userInfos: UserInfos, ): boolean { - return threadIsWithBlockedUserOnly(threadInfo, viewerID, userInfos, true); + const options: ThreadIsWithBlockedUserOnlyOptions = { + checkOnlyViewerBlock: true, + skipMemberAdminRoleCheck: false, + }; + + return threadIsWithBlockedUserOnly(threadInfo, viewerID, userInfos, options); } const threadTypeDescriptions: { [ThreadType]: string } = {