Skip to content

Commit

Permalink
Revert "[lib] Introduce basic permissionsToBitmask and `hasPermissi…
Browse files Browse the repository at this point in the history
…on`"

This reverts commit c307122.
  • Loading branch information
atulsmadhugiri committed Oct 24, 2023
1 parent 7b83cf8 commit ab6b2a2
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 135 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"root": true,
"env": {
"es6": true,
"es2020": true
"es6": true
},
"extends": [
"eslint:recommended",
Expand Down
5 changes: 5 additions & 0 deletions keyserver/src/responders/responder-validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('user responder validators', () => {
role: '83796',
permissions: {
know_of: { value: true, source: '1' },
membership: { value: false, source: null },
visible: { value: true, source: '1' },
voiced: { value: true, source: '1' },
edit_entries: { value: true, source: '1' },
Expand Down Expand Up @@ -135,6 +136,7 @@ describe('user responder validators', () => {
role: '83795',
permissions: {
know_of: { value: true, source: '1' },
membership: { value: false, source: null },
visible: { value: true, source: '1' },
voiced: { value: false, source: null },
edit_entries: { value: false, source: null },
Expand Down Expand Up @@ -225,6 +227,7 @@ describe('user responder validators', () => {
role: '83796',
permissions: {
know_of: { value: true, source: '1' },
membership: { value: false, source: null },
visible: { value: true, source: '1' },
voiced: { value: true, source: '1' },
edit_entries: { value: true, source: '1' },
Expand All @@ -250,6 +253,7 @@ describe('user responder validators', () => {
role: '83795',
permissions: {
know_of: { value: true, source: '1' },
membership: { value: false, source: null },
visible: { value: true, source: '1' },
voiced: { value: false, source: null },
edit_entries: { value: false, source: null },
Expand Down Expand Up @@ -327,6 +331,7 @@ describe('user responder validators', () => {
role: '83795',
permissions: {
know_of: { value: true, source: '1' },
membership: { value: false, source: null },
visible: { value: true, source: '1' },
voiced: { value: false, source: null },
edit_entries: { value: false, source: null },
Expand Down
78 changes: 0 additions & 78 deletions lib/permissions/minimally-encoded-thread-permissions.js

This file was deleted.

53 changes: 0 additions & 53 deletions lib/permissions/minimally-encoded-thread-permissions.test.js

This file was deleted.

2 changes: 2 additions & 0 deletions lib/types/thread-permission-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { tBool, tShape, tID } from '../utils/validation-utils.js';
// across all roles, it should be added to `universalCommunityPermissions`.
export const threadPermissions = Object.freeze({
KNOW_OF: 'know_of',
MEMBERSHIP_DEPRECATED: 'membership',
VISIBLE: 'visible',
VOICED: 'voiced',
EDIT_ENTRIES: 'edit_entries',
Expand Down Expand Up @@ -40,6 +41,7 @@ export function assertThreadPermissions(
): ThreadPermission {
invariant(
ourThreadPermissions === 'know_of' ||
ourThreadPermissions === 'membership' ||
ourThreadPermissions === 'visible' ||
ourThreadPermissions === 'voiced' ||
ourThreadPermissions === 'edit_entries' ||
Expand Down
12 changes: 12 additions & 0 deletions lib/types/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ const thread = {
value: true,
source: '1',
},
membership: {
value: false,
source: null,
},
visible: {
value: true,
source: '1',
Expand Down Expand Up @@ -446,6 +450,10 @@ const thread = {
value: true,
source: '85171',
},
membership: {
value: false,
source: null,
},
visible: {
value: true,
source: '85171',
Expand Down Expand Up @@ -551,6 +559,10 @@ const thread = {
value: true,
source: '85171',
},
membership: {
value: false,
source: null,
},
visible: {
value: true,
source: '85171',
Expand Down
20 changes: 18 additions & 2 deletions lib/utils/thread-ops-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const rawThreadInfo: RawThreadInfo = {
value: true,
source: '1',
},
membership: {
value: false,
source: null,
},
visible: {
value: true,
source: '1',
Expand Down Expand Up @@ -105,6 +109,10 @@ const rawThreadInfo: RawThreadInfo = {
value: true,
source: '84015',
},
membership: {
value: false,
source: null,
},
visible: {
value: true,
source: '84015',
Expand Down Expand Up @@ -184,6 +192,10 @@ const rawThreadInfo: RawThreadInfo = {
value: true,
source: '84015',
},
membership: {
value: false,
source: null,
},
visible: {
value: true,
source: '84015',
Expand Down Expand Up @@ -285,6 +297,10 @@ const rawThreadInfo: RawThreadInfo = {
value: true,
source: '84015',
},
membership: {
value: false,
source: null,
},
visible: {
value: true,
source: '84015',
Expand Down Expand Up @@ -375,11 +391,11 @@ const clientDBThreadInfo: ClientDBThreadInfo = {
creationTime: '1679595843051',
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}},"isSender":false},{"id":"83809","role":"84016","permissions":{"know_of":{"value":true,"source":"84015"},"visible":{"value":true,"source":"84015"},"voiced":{"value":true,"source":"84015"},"edit_entries":{"value":true,"source":"84015"},"edit_thread":{"value":true,"source":"84015"},"edit_thread_description":{"value":true,"source":"84015"},"edit_thread_color":{"value":true,"source":"84015"},"delete_thread":{"value":false,"source":null},"create_subthreads":{"value":false,"source":null},"create_sidebars":{"value":true,"source":"84015"},"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":"84015"},"edit_message":{"value":true,"source":"84015"}},"isSender":true},{"id":"83969","role":"84016","permissions":{"know_of":{"value":true,"source":"84015"},"visible":{"value":true,"source":"84015"},"voiced":{"value":true,"source":"84015"},"edit_entries":{"value":true,"source":"84015"},"edit_thread":{"value":true,"source":"84015"},"edit_thread_description":{"value":true,"source":"84015"},"edit_thread_color":{"value":true,"source":"84015"},"delete_thread":{"value":false,"source":null},"create_subthreads":{"value":false,"source":null},"create_sidebars":{"value":true,"source":"84015"},"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":"84015"},"edit_message":{"value":true,"source":"84015"}},"isSender":true}]',
'[{"id":"256","role":null,"permissions":{"know_of":{"value":true,"source":"1"},"membership":{"value":false,"source":null},"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}},"isSender":false},{"id":"83809","role":"84016","permissions":{"know_of":{"value":true,"source":"84015"},"membership":{"value":false,"source":null},"visible":{"value":true,"source":"84015"},"voiced":{"value":true,"source":"84015"},"edit_entries":{"value":true,"source":"84015"},"edit_thread":{"value":true,"source":"84015"},"edit_thread_description":{"value":true,"source":"84015"},"edit_thread_color":{"value":true,"source":"84015"},"delete_thread":{"value":false,"source":null},"create_subthreads":{"value":false,"source":null},"create_sidebars":{"value":true,"source":"84015"},"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":"84015"},"edit_message":{"value":true,"source":"84015"}},"isSender":true},{"id":"83969","role":"84016","permissions":{"know_of":{"value":true,"source":"84015"},"membership":{"value":false,"source":null},"visible":{"value":true,"source":"84015"},"voiced":{"value":true,"source":"84015"},"edit_entries":{"value":true,"source":"84015"},"edit_thread":{"value":true,"source":"84015"},"edit_thread_description":{"value":true,"source":"84015"},"edit_thread_color":{"value":true,"source":"84015"},"delete_thread":{"value":false,"source":null},"create_subthreads":{"value":false,"source":null},"create_sidebars":{"value":true,"source":"84015"},"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":"84015"},"edit_message":{"value":true,"source":"84015"}},"isSender":true}]',
roles:
'{"84016":{"id":"84016","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":"84016","permissions":{"know_of":{"value":true,"source":"84015"},"visible":{"value":true,"source":"84015"},"voiced":{"value":true,"source":"84015"},"edit_entries":{"value":true,"source":"84015"},"edit_thread":{"value":true,"source":"84015"},"edit_thread_description":{"value":true,"source":"84015"},"edit_thread_color":{"value":true,"source":"84015"},"delete_thread":{"value":false,"source":null},"create_subthreads":{"value":false,"source":null},"create_sidebars":{"value":true,"source":"84015"},"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":"84015"},"edit_message":{"value":true,"source":"84015"}},"subscription":{"home":true,"pushNotifs":true},"unread":false}',
'{"role":"84016","permissions":{"know_of":{"value":true,"source":"84015"},"membership":{"value":false,"source":null},"visible":{"value":true,"source":"84015"},"voiced":{"value":true,"source":"84015"},"edit_entries":{"value":true,"source":"84015"},"edit_thread":{"value":true,"source":"84015"},"edit_thread_description":{"value":true,"source":"84015"},"edit_thread_color":{"value":true,"source":"84015"},"delete_thread":{"value":false,"source":null},"create_subthreads":{"value":false,"source":null},"create_sidebars":{"value":true,"source":"84015"},"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":"84015"},"edit_message":{"value":true,"source":"84015"}},"subscription":{"home":true,"pushNotifs":true},"unread":false}',
repliesCount: 0,
containingThreadID: '1',
community: '1',
Expand Down

0 comments on commit ab6b2a2

Please sign in to comment.