MCPcopy Create free account
hub / github.com/CommE2E/comm / threadHasPermission

Function threadHasPermission

lib/shared/thread-utils.js:127–143  ·  view source on GitHub ↗
(
  threadInfo: ?(ThreadInfo | LegacyRawThreadInfo | RawThreadInfo),
  permission: ThreadPermissionNotAffectedByBlock,
)

Source from the content-addressed store, hash-verified

125} from '../utils/validation-utils.js';
126
127function threadHasPermission(
128 threadInfo: ?(ThreadInfo | LegacyRawThreadInfo | RawThreadInfo),
129 permission: ThreadPermissionNotAffectedByBlock,
130): boolean {
131 if (!threadInfo) {
132 return false;
133 }
134 invariant(
135 !permissionsDisabledByBlock.has(permission) || threadInfo?.uiName,
136 `${permission} can be disabled by a block, but threadHasPermission can't ` +
137 'check for a block on RawThreadInfo. Please pass in ThreadInfo instead!',
138 );
139 if (threadInfo.minimallyEncoded) {
140 return hasPermission(threadInfo.currentUser.permissions, permission);
141 }
142 return permissionLookup(threadInfo.currentUser.permissions, permission);
143}
144
145type CommunityRootMembersToRoleType = {
146 +[threadID: ?string]: {

Callers 5

modifyRoleFunction · 0.90
isThreadWatchedFunction · 0.90
canToggleMessagePinFunction · 0.90
threadInChatListFunction · 0.85

Calls 3

hasPermissionFunction · 0.90
permissionLookupFunction · 0.90
hasMethod · 0.65

Tested by

no test coverage detected