-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lib] Introduce `minimallyEncodeRawThreadInfo(RawThreadInfo): Minimal…
…lyEncodedRawThreadInfo` Summary: Handy utility function that will make encoding/decoding of permissions/role permissions much simpler at callsite and avoid polluting with a bunch of permission encoding related stuff in eg `rawThreadInfosFromServerThreadInfos`. --- Depends on D9736 Test Plan: Single unit test for now, will add more after `decode` function is introduced. Reviewers: ashoat, ginsu, tomek, rohan Reviewed By: tomek Subscribers: wyilio Differential Revision: https://phab.comm.dev/D9737
- Loading branch information
1 parent
611517f
commit 0a5e5a2
Showing
3 changed files
with
409 additions
and
61 deletions.
There are no files selected for viewing
356 changes: 356 additions & 0 deletions
356
lib/permissions/minimally-encoded-thread-permissions-test-data.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,356 @@ | ||
// @flow | ||
|
||
import type { MinimallyEncodedRawThreadInfo } from './minimally-encoded-thread-permissions.js'; | ||
import { threadTypes } from '../types/thread-types-enum.js'; | ||
import type { RawThreadInfo } from '../types/thread-types.js'; | ||
|
||
const exampleRawThreadInfoA: RawThreadInfo = { | ||
id: '85171', | ||
type: threadTypes.PERSONAL, | ||
name: '', | ||
description: '', | ||
color: '6d49ab', | ||
creationTime: 1675887298557, | ||
parentThreadID: '1', | ||
members: [ | ||
{ | ||
id: '256', | ||
role: null, | ||
permissions: { | ||
know_of: { | ||
value: true, | ||
source: '1', | ||
}, | ||
visible: { | ||
value: true, | ||
source: '1', | ||
}, | ||
voiced: { | ||
value: true, | ||
source: '1', | ||
}, | ||
edit_entries: { | ||
value: true, | ||
source: '1', | ||
}, | ||
edit_thread: { | ||
value: true, | ||
source: '1', | ||
}, | ||
edit_thread_description: { | ||
value: true, | ||
source: '1', | ||
}, | ||
edit_thread_color: { | ||
value: true, | ||
source: '1', | ||
}, | ||
delete_thread: { | ||
value: true, | ||
source: '1', | ||
}, | ||
create_subthreads: { | ||
value: true, | ||
source: '1', | ||
}, | ||
create_sidebars: { | ||
value: true, | ||
source: '1', | ||
}, | ||
join_thread: { | ||
value: true, | ||
source: '1', | ||
}, | ||
edit_permissions: { | ||
value: true, | ||
source: '1', | ||
}, | ||
add_members: { | ||
value: true, | ||
source: '1', | ||
}, | ||
remove_members: { | ||
value: true, | ||
source: '1', | ||
}, | ||
change_role: { | ||
value: true, | ||
source: '1', | ||
}, | ||
leave_thread: { | ||
value: false, | ||
source: null, | ||
}, | ||
react_to_message: { | ||
value: false, | ||
source: null, | ||
}, | ||
edit_message: { | ||
value: false, | ||
source: null, | ||
}, | ||
manage_pins: { | ||
value: true, | ||
source: '1', | ||
}, | ||
}, | ||
isSender: false, | ||
}, | ||
{ | ||
id: '83853', | ||
role: '85172', | ||
permissions: { | ||
know_of: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
visible: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
voiced: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_entries: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_thread: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_thread_description: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_thread_color: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
delete_thread: { | ||
value: false, | ||
source: null, | ||
}, | ||
create_subthreads: { | ||
value: false, | ||
source: null, | ||
}, | ||
create_sidebars: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
join_thread: { | ||
value: false, | ||
source: null, | ||
}, | ||
edit_permissions: { | ||
value: false, | ||
source: null, | ||
}, | ||
add_members: { | ||
value: false, | ||
source: null, | ||
}, | ||
remove_members: { | ||
value: false, | ||
source: null, | ||
}, | ||
change_role: { | ||
value: false, | ||
source: null, | ||
}, | ||
leave_thread: { | ||
value: false, | ||
source: null, | ||
}, | ||
react_to_message: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_message: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
manage_pins: { | ||
value: false, | ||
source: null, | ||
}, | ||
}, | ||
isSender: true, | ||
}, | ||
], | ||
roles: { | ||
'85172': { | ||
id: '85172', | ||
name: 'Members', | ||
permissions: { | ||
know_of: true, | ||
visible: true, | ||
voiced: true, | ||
react_to_message: true, | ||
edit_message: true, | ||
edit_entries: true, | ||
edit_thread: true, | ||
edit_thread_color: true, | ||
edit_thread_description: true, | ||
create_sidebars: true, | ||
descendant_open_know_of: true, | ||
descendant_open_visible: true, | ||
child_open_join_thread: true, | ||
}, | ||
isDefault: true, | ||
}, | ||
}, | ||
currentUser: { | ||
role: '85172', | ||
permissions: { | ||
know_of: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
visible: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
voiced: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_entries: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_thread: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_thread_description: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_thread_color: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
delete_thread: { | ||
value: false, | ||
source: null, | ||
}, | ||
create_subthreads: { | ||
value: false, | ||
source: null, | ||
}, | ||
create_sidebars: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
join_thread: { | ||
value: false, | ||
source: null, | ||
}, | ||
edit_permissions: { | ||
value: false, | ||
source: null, | ||
}, | ||
add_members: { | ||
value: false, | ||
source: null, | ||
}, | ||
remove_members: { | ||
value: false, | ||
source: null, | ||
}, | ||
change_role: { | ||
value: false, | ||
source: null, | ||
}, | ||
leave_thread: { | ||
value: false, | ||
source: null, | ||
}, | ||
react_to_message: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
edit_message: { | ||
value: true, | ||
source: '85171', | ||
}, | ||
manage_pins: { | ||
value: false, | ||
source: null, | ||
}, | ||
}, | ||
subscription: { | ||
home: true, | ||
pushNotifs: true, | ||
}, | ||
unread: false, | ||
}, | ||
repliesCount: 0, | ||
containingThreadID: '1', | ||
community: '1', | ||
pinnedCount: 0, | ||
}; | ||
|
||
const exampleMinimallyEncodedRawThreadInfoA: MinimallyEncodedRawThreadInfo = { | ||
id: '85171', | ||
type: threadTypes.PERSONAL, | ||
name: '', | ||
description: '', | ||
color: '6d49ab', | ||
creationTime: 1675887298557, | ||
parentThreadID: '1', | ||
members: [ | ||
{ | ||
id: '256', | ||
role: null, | ||
permissions: '87fff', | ||
isSender: false, | ||
}, | ||
{ | ||
id: '83853', | ||
role: '85172', | ||
permissions: '3027f', | ||
isSender: true, | ||
}, | ||
], | ||
roles: { | ||
'85172': { | ||
id: '85172', | ||
name: 'Members', | ||
permissions: [ | ||
'000', | ||
'010', | ||
'020', | ||
'100', | ||
'110', | ||
'030', | ||
'040', | ||
'060', | ||
'050', | ||
'090', | ||
'005', | ||
'015', | ||
'0a9', | ||
], | ||
isDefault: true, | ||
}, | ||
}, | ||
currentUser: { | ||
role: '85172', | ||
permissions: '3027f', | ||
subscription: { | ||
home: true, | ||
pushNotifs: true, | ||
}, | ||
unread: false, | ||
}, | ||
repliesCount: 0, | ||
containingThreadID: '1', | ||
community: '1', | ||
pinnedCount: 0, | ||
}; | ||
|
||
export { exampleRawThreadInfoA, exampleMinimallyEncodedRawThreadInfoA }; |
Oops, something went wrong.