Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3371023
D13013.id43228.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
D13013.id43228.diff
View Options
diff --git a/lib/permissions/prefixes.js b/lib/permissions/prefixes.js
--- a/lib/permissions/prefixes.js
+++ b/lib/permissions/prefixes.js
@@ -1,14 +1,14 @@
// @flow
-import type {
- ThreadPermission,
- ThreadPermissionFilterPrefix,
- ThreadPermissionPropagationPrefix,
-} from '../types/thread-permission-types.js';
import {
+ type ThreadPermission,
+ type ThreadPermissionFilterPrefix,
+ type ThreadPermissionPropagationPrefix,
+ type ThreadPermissionMembershipPrefix,
assertThreadPermissions,
threadPermissionFilterPrefixes,
threadPermissionPropagationPrefixes,
+ threadPermissionMembershipPrefixes,
} from '../types/thread-permission-types.js';
import {
threadTypes,
@@ -20,6 +20,7 @@
+permission: ThreadPermission,
+propagationPrefix: ?ThreadPermissionPropagationPrefix,
+filterPrefix: ?ThreadPermissionFilterPrefix,
+ +membershipPrefix: ?ThreadPermissionMembershipPrefix,
};
function parseThreadPermissionString(
threadPermissionString: string,
@@ -48,9 +49,20 @@
break;
}
+ let membershipPrefix;
+ for (const key in threadPermissionMembershipPrefixes) {
+ const prefix = threadPermissionMembershipPrefixes[key];
+ if (!remainingString.startsWith(prefix)) {
+ continue;
+ }
+ membershipPrefix = prefix;
+ remainingString = remainingString.substr(prefix.length);
+ break;
+ }
+
const permission = assertThreadPermissions(remainingString);
- return { permission, propagationPrefix, filterPrefix };
+ return { permission, propagationPrefix, filterPrefix, membershipPrefix };
}
function includeThreadPermissionForThreadType(
diff --git a/lib/types/thread-permission-types.js b/lib/types/thread-permission-types.js
--- a/lib/types/thread-permission-types.js
+++ b/lib/types/thread-permission-types.js
@@ -82,6 +82,7 @@
}
const threadPermissionValidator = t.enums.of(values(threadPermissions));
+
export const threadPermissionPropagationPrefixes = Object.freeze({
DESCENDANT: 'descendant_',
CHILD: 'child_',
@@ -89,6 +90,7 @@
export type ThreadPermissionPropagationPrefix = $Values<
typeof threadPermissionPropagationPrefixes,
>;
+
export const threadPermissionFilterPrefixes = Object.freeze({
// includes only SIDEBAR, COMMUNITY_OPEN_SUBTHREAD,
// COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD
@@ -103,6 +105,13 @@
typeof threadPermissionFilterPrefixes,
>;
+export const threadPermissionMembershipPrefixes = Object.freeze({
+ MEMBER: 'member_',
+});
+export type ThreadPermissionMembershipPrefix = $Values<
+ typeof threadPermissionMembershipPrefixes,
+>;
+
// These are the set of user-facing permissions that we display as configurable
// to the user when they are creating a custom role for their given community.
// They are per-community rather than per-thread, so when configured they are
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 4:20 AM (19 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587904
Default Alt Text
D13013.id43228.diff (2 KB)
Attached To
Mode
D13013: [lib] Introduce member_ prefix for permission strings
Attached
Detach File
Event Timeline
Log In to Comment