From b6b305a35bd78a1b3cd429cf4f87bf74586c51cd Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Thu, 14 Nov 2024 18:36:30 +0000 Subject: [PATCH] chore: define `BLOCKED_ROLE` as a constant This change should have no impact on functionality, and is a minor change. In [an upcoming change][0], I plan to make several references to the blocked role. This defines the `BLOCKED_ROLE` constant for this purpose. [0]: https://github.com/digidem/comapeo-core/issues/188 --- src/roles.js | 53 ++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/roles.js b/src/roles.js index f3aa6566e..b9bb4811e 100644 --- a/src/roles.js +++ b/src/roles.js @@ -98,6 +98,33 @@ export const CREATOR_ROLE = { }, } +/** + * @type {Role} + */ +const BLOCKED_ROLE = { + roleId: BLOCKED_ROLE_ID, + name: 'Blocked', + docs: mapObject(currentSchemaVersions, (key) => { + return [ + key, + { + readOwn: false, + writeOwn: false, + readOthers: false, + writeOthers: false, + }, + ] + }), + roleAssignment: [], + sync: { + auth: 'blocked', + config: 'blocked', + data: 'blocked', + blobIndex: 'blocked', + blob: 'blocked', + }, +} + /** * This is the role assumed for a device when no role record can be found. This * can happen when an invited device did not manage to sync with the device that @@ -166,29 +193,7 @@ export const ROLES = { blob: 'allowed', }, }, - [BLOCKED_ROLE_ID]: { - roleId: BLOCKED_ROLE_ID, - name: 'Blocked', - docs: mapObject(currentSchemaVersions, (key) => { - return [ - key, - { - readOwn: false, - writeOwn: false, - readOthers: false, - writeOthers: false, - }, - ] - }), - roleAssignment: [], - sync: { - auth: 'blocked', - config: 'blocked', - data: 'blocked', - blobIndex: 'blocked', - blob: 'blocked', - }, - }, + [BLOCKED_ROLE_ID]: BLOCKED_ROLE, [LEFT_ROLE_ID]: { roleId: LEFT_ROLE_ID, name: 'Left', @@ -281,7 +286,7 @@ export class Roles extends TypedEmitter { } } if (!isRoleId(roleId)) { - return ROLES[BLOCKED_ROLE_ID] + return BLOCKED_ROLE } return ROLES[roleId] }