Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3725004
D13073.id43398.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13073.id43398.diff
View Options
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
@@ -60,7 +60,6 @@
import {
threadPermissionPropagationPrefixes,
threadPermissions,
- configurableCommunityPermissions,
type ThreadPermission,
type ThreadPermissionsInfo,
type ThreadRolePermissionsBlob,
@@ -108,6 +107,7 @@
} from '../utils/member-info-utils.js';
import { entries, values } from '../utils/objects.js';
import { useSelector } from '../utils/redux-utils.js';
+import { userSurfacedPermissionsFromRolePermissions } from '../utils/role-utils.js';
import { usingOlmViaTunnelbrokerForDMs } from '../utils/services-utils.js';
import { firstLine } from '../utils/string-utils.js';
import { pendingThreadIDRegex } from '../utils/validation-utils.js';
@@ -1577,24 +1577,11 @@
Object.keys(threadInfo.roles).forEach(roleID => {
const roleName = threadInfo.roles[roleID].name;
- const rolePermissions = Object.keys(
- decodeMinimallyEncodedRoleInfo(threadInfo.roles[roleID]).permissions,
- );
-
- const setOfUserSurfacedPermissions = new Set<UserSurfacedPermission>();
-
- rolePermissions.forEach(rolePermission => {
- const userSurfacedPermission = Object.keys(
- configurableCommunityPermissions,
- ).find(key =>
- configurableCommunityPermissions[key].has(rolePermission),
- );
-
- if (userSurfacedPermission) {
- setOfUserSurfacedPermissions.add(userSurfacedPermission);
- }
- });
- roleNamesToPermissions[roleName] = setOfUserSurfacedPermissions;
+ const rolePermissions = decodeMinimallyEncodedRoleInfo(
+ threadInfo.roles[roleID],
+ ).permissions;
+ roleNamesToPermissions[roleName] =
+ userSurfacedPermissionsFromRolePermissions(rolePermissions);
});
return roleNamesToPermissions;
diff --git a/lib/utils/role-utils.js b/lib/utils/role-utils.js
--- a/lib/utils/role-utils.js
+++ b/lib/utils/role-utils.js
@@ -132,9 +132,28 @@
return currentRolePermissions;
}
+function userSurfacedPermissionsFromRolePermissions(
+ rolePermissions: ThreadRolePermissionsBlob,
+): Set<UserSurfacedPermission> {
+ const setOfUserSurfacedPermissions = new Set<UserSurfacedPermission>();
+
+ Object.keys(rolePermissions).forEach(rolePermission => {
+ const userSurfacedPermission = Object.keys(
+ configurableCommunityPermissions,
+ ).find(key => configurableCommunityPermissions[key].has(rolePermission));
+
+ if (userSurfacedPermission) {
+ setOfUserSurfacedPermissions.add(userSurfacedPermission);
+ }
+ });
+
+ return setOfUserSurfacedPermissions;
+}
+
export {
constructRoleDeletionMessagePrompt,
useRolesFromCommunityThreadInfo,
toggleUserSurfacedPermission,
useMembersGroupedByRole,
+ userSurfacedPermissionsFromRolePermissions,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 5:56 PM (10 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2823638
Default Alt Text
D13073.id43398.diff (2 KB)
Attached To
Mode
D13073: [lib] Extract userSurfacedPermissionsFromRolePermissions
Attached
Detach File
Event Timeline
Log In to Comment