Page MenuHomePhabricator

[lib] Introduce `rolePermissionToBitmaskHex`
ClosedPublic

Authored by atul on Oct 31 2023, 3:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Sep 24, 9:28 AM
Unknown Object (File)
Sun, Sep 15, 1:13 PM
Unknown Object (File)
Sun, Sep 15, 1:13 PM
Unknown Object (File)
Sun, Sep 15, 1:13 PM
Unknown Object (File)
Sun, Sep 15, 1:13 PM
Unknown Object (File)
Sun, Sep 15, 1:12 PM
Unknown Object (File)
Sun, Sep 15, 12:54 PM
Unknown Object (File)
Sat, Aug 31, 11:56 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.