Page MenuHomePhabricator

[lib] Introduce `rolePermissionToBitmaskHex`
ClosedPublic

Authored by atul on Oct 31 2023, 3:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 22, 1:07 PM
Unknown Object (File)
Tue, Oct 22, 1:07 PM
Unknown Object (File)
Tue, Oct 22, 1:07 PM
Unknown Object (File)
Tue, Oct 22, 1:07 PM
Unknown Object (File)
Tue, Oct 22, 9:18 AM
Unknown Object (File)
Tue, Oct 22, 5:05 AM
Unknown Object (File)
Oct 16 2024, 1:16 AM
Unknown Object (File)
Sep 28 2024, 12:30 PM
Subscribers

Details

Summary

Introduce rolePermissionToBitmaskHex which turns threadRolePermission string into hex-encoded bitmask.

Context: https://linear.app/comm/issue/ENG-5388/encodepermissions-for-rolepermissionsblob

Test Plan

Unit tests, more testing in upcoming diff which handles decoding back to rolePermissionString

Diff Detail

Repository
rCOMM Comm
Branch
arcpatch-D9662 (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul published this revision for review.Oct 31 2023, 3:30 PM
ashoat added inline comments.
lib/permissions/minimally-encoded-thread-permissions.js
74–79 ↗(On Diff #32570)

This took me a bit of thinking to really understand. I wonder if it would be better to reverse the relationship between minimallyEncodedThreadPermissions and baseRolePermissionEncoding.

What if you started by defining baseRolePermissionEncoding using Object.freeze, and then created minimallyEncodedThreadPermissions from that?

This revision is now accepted and ready to land.Nov 1 2023, 10:16 AM
lib/permissions/minimally-encoded-thread-permissions.js
74–79 ↗(On Diff #32570)

It does make sense to have the "starting" Object be "simple" (just BigInt(idx)) and then generate the more "complex" one "programmatically" from it.

Will update this diff (and also add some comments to give future readers a bit more clarity).

address feedback + add comments

lib/permissions/minimally-encoded-thread-permissions.js
12–18

(FYI had ChatGPT rewrite these comments for me, which is why they sound the way they do)

This revision was landed with ongoing or failed builds.Nov 1 2023, 6:35 PM
This revision was automatically updated to reflect the committed changes.