Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3323499
D13015.id43232.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
D13015.id43232.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,10 +133,15 @@
'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)
@@ -148,8 +153,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 +175,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 +200,18 @@
propagationPrefixString !== null &&
propagationPrefixString !== undefined &&
filterPrefixString !== null &&
- filterPrefixString !== undefined,
+ filterPrefixString !== undefined &&
+ membershipPrefixString !== null &&
+ membershipPrefixString !== undefined,
'invalid bitmask',
);
- return `${propagationPrefixString}${filterPrefixString}${basePermissionString}`;
+ return (
+ propagationPrefixString +
+ filterPrefixString +
+ basePermissionString +
+ membershipPrefixString
+ );
};
const threadRolePermissionsBlobToBitmaskArray = (
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 3:43 AM (18 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2552526
Default Alt Text
D13015.id43232.diff (2 KB)
Attached To
Mode
D13015: [lib] Add support for new member_ prefix to RawThreadInfo encoders
Attached
Detach File
Event Timeline
Log In to Comment