Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3323514
D13015.id43284.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13015.id43284.diff
View Options
diff --git a/lib/permissions/minimally-encoded-thread-permissions.js b/lib/permissions/minimally-encoded-thread-permissions.js
--- a/lib/permissions/minimally-encoded-thread-permissions.js
+++ b/lib/permissions/minimally-encoded-thread-permissions.js
@@ -133,13 +133,20 @@
'toplevel_': BigInt(2),
'opentoplevel_': BigInt(3),
});
+const membershipPrefixes = Object.freeze({
+ '': BigInt(0),
+ 'member_': BigInt(1),
+});
// Role Permission Bitmask Structure
-// [9 8 7 6 5 4 3 2 1 0] - bit positions
-// [b b b b b b p p f f] - symbol representation
+// [10 9 8 7 6 5 4 3 2 1 0] - bit positions
+// [m b b b b b b p p f f] - symbol representation
+// m = membershipPrefix (1 bit)
// b = basePermission (6 bits)
// p = propagationPrefix (2 bits)
// f = filterPrefix (2 bits)
+// membershipPrefix appears at the start because it was added later,
+// and we wanted to maintain backwards compatibility
const rolePermissionToBitmaskHex = (threadRolePermission: string): string => {
const parsed = parseThreadPermissionString(threadRolePermission);
const basePermissionBits =
@@ -148,8 +155,11 @@
propagationPrefixes[parsed.propagationPrefix ?? ''] & BigInt(3);
const filterPrefixBits =
filterPrefixes[parsed.filterPrefix ?? ''] & BigInt(3);
+ const membershipPrefixesBits =
+ membershipPrefixes[parsed.membershipPrefix ?? ''] & BigInt(1);
const bitmask =
+ (membershipPrefixesBits << BigInt(10)) |
(basePermissionBits << BigInt(4)) |
(propagationPrefixBits << BigInt(2)) |
filterPrefixBits;
@@ -167,18 +177,24 @@
const inverseFilterPrefixes: Map<bigint, string> =
invertObjectToMap(filterPrefixes);
+const inverseMembershipPrefixes: Map<bigint, string> =
+ invertObjectToMap(membershipPrefixes);
+
const tHexEncodedRolePermission: TRegex = tRegex(/^[0-9a-fA-F]{3,}$/);
const decodeRolePermissionBitmask = (bitmask: string): string => {
const bitmaskInt = BigInt(`0x${bitmask}`);
const basePermission = (bitmaskInt >> BigInt(4)) & BigInt(63);
const propagationPrefix = (bitmaskInt >> BigInt(2)) & BigInt(3);
const filterPrefix = bitmaskInt & BigInt(3);
+ const membershipPrefix = (bitmaskInt >> BigInt(10)) & BigInt(1);
const basePermissionString =
inverseBaseRolePermissionEncoding.get(basePermission);
const propagationPrefixString =
inversePropagationPrefixes.get(propagationPrefix) ?? '';
const filterPrefixString = inverseFilterPrefixes.get(filterPrefix) ?? '';
+ const membershipPrefixString =
+ inverseMembershipPrefixes.get(membershipPrefix) ?? '';
invariant(
basePermissionString !== null &&
@@ -186,11 +202,18 @@
propagationPrefixString !== null &&
propagationPrefixString !== undefined &&
filterPrefixString !== null &&
- filterPrefixString !== undefined,
+ filterPrefixString !== undefined &&
+ membershipPrefixString !== null &&
+ membershipPrefixString !== undefined,
'invalid bitmask',
);
- return `${propagationPrefixString}${filterPrefixString}${basePermissionString}`;
+ return (
+ propagationPrefixString +
+ filterPrefixString +
+ membershipPrefixString +
+ basePermissionString
+ );
};
const threadRolePermissionsBlobToBitmaskArray = (
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 3:43 AM (17 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2552236
Default Alt Text
D13015.id43284.diff (3 KB)
Attached To
Mode
D13015: [lib] Add support for new member_ prefix to RawThreadInfo encoders
Attached
Detach File
Event Timeline
Log In to Comment