Page MenuHomePhabricator

[lib] Introduce `MinimallyEncodedThreadCurrentUserInfo` and validator
ClosedPublic

Authored by atul on Nov 6 2023, 11:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 1:13 AM
Unknown Object (File)
Mon, Dec 16, 4:36 PM
Unknown Object (File)
Mon, Dec 16, 4:15 PM
Unknown Object (File)
Mon, Dec 16, 4:15 PM
Unknown Object (File)
Mon, Dec 16, 4:15 PM
Unknown Object (File)
Mon, Dec 16, 4:15 PM
Unknown Object (File)
Mon, Dec 16, 4:15 PM
Unknown Object (File)
Mon, Dec 16, 4:11 PM
Subscribers

Details

Summary

ThreadCurrentUserInfo type w/ permissions as string instead of ThreadPermissions.

Next diffs:

  • Introduce MinimallyEncodedRawThreadInfo
  • Higher level utilities for translating back/forth from RawThreadInfo <=> MinimallyEncodedRawThreadInfo. Found this to be cleaner API than encoding/decoding RawThreadInfo.currentUser.permissions and RawThreadInfo.members[memberID].permissions "manually" a bunch of different places.
  • Native refactoring + migrations
  • Web refactoring
  • Flipping the switch

Depends on D9731

Test Plan

Unit tests, will be tested implicitly in subsequent diffs as well.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul published this revision for review.Nov 6 2023, 11:12 AM
atul added reviewers: ashoat, rohan, ginsu, tomek.
ashoat requested changes to this revision.Nov 6 2023, 11:41 AM

Confused by the word boundaries... passing back but let me know if I'm missing something

lib/permissions/minimally-encoded-thread-permissions.js
207 ↗(On Diff #32822)
  1. Why the word boundaries?
  2. Is {1,16} really what we want? If we add more permissions in the future, it seems like older clients might reject the longer permission strings. Wouldn't it be better to just use +?
This revision now requires changes to proceed.Nov 6 2023, 11:41 AM

fix regex boundary and add failing test

update regex from {1,16} to +

lib/permissions/minimally-encoded-thread-permissions.js
207 ↗(On Diff #32822)
  1. Was experimenting w/ \b when doing the "multiple 12-bit chunks in one bitmask" approach and failed to update the boundaries
  1. Intention was that things should start breaking when the 65th permission is added to baseRolePermissionEncoding to surface to developer that there's an issue... making this validator break may not be the best way to achieve that.

Updated this diff to address feedback.

This revision is now accepted and ready to land.Nov 6 2023, 12:42 PM
This revision was landed with ongoing or failed builds.Nov 6 2023, 2:03 PM
This revision was automatically updated to reflect the committed changes.