Page MenuHomePhabricator

[lib] Introduce `rolePermissionToBitmaskHex`
ClosedPublic

Authored by atul on Oct 31 2023, 3:30 PM.
Tags
None
Referenced Files
F3397736: D9662.diff
Sun, Dec 1, 7:14 PM
Unknown Object (File)
Sat, Nov 30, 2:24 AM
Unknown Object (File)
Sun, Nov 24, 8:55 PM
Unknown Object (File)
Wed, Nov 20, 4:37 PM
Unknown Object (File)
Wed, Nov 20, 4:37 PM
Unknown Object (File)
Wed, Nov 20, 4:37 PM
Unknown Object (File)
Wed, Nov 20, 4:37 PM
Unknown Object (File)
Wed, Nov 20, 4:36 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 ↗(On Diff #32606)

(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.