Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: define BLOCKED_ROLE as a constant #961

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions src/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,33 @@ export const CREATOR_ROLE = {
},
}

/**
* @type {Role<typeof BLOCKED_ROLE_ID>}
*/
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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -281,7 +286,7 @@ export class Roles extends TypedEmitter {
}
}
if (!isRoleId(roleId)) {
return ROLES[BLOCKED_ROLE_ID]
return BLOCKED_ROLE
}
return ROLES[roleId]
}
Expand Down
Loading