Page MenuHomePhabricator

D13013.id43228.diff
No OneTemporary

D13013.id43228.diff

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

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)

Event Timeline