diff --git a/keyserver/src/fetchers/role-fetchers.js b/keyserver/src/fetchers/role-fetchers.js --- a/keyserver/src/fetchers/role-fetchers.js +++ b/keyserver/src/fetchers/role-fetchers.js @@ -1,26 +1,27 @@ // @flow import { specialRoles } from 'lib/permissions/special-roles.js'; -import type { ClientLegacyRoleInfo } from 'lib/types/thread-types.js'; +import type { ServerLegacyRoleInfo } from 'lib/types/thread-types.js'; import { dbQuery, SQL } from '../database/database.js'; -async function fetchRoles(threadID: string): Promise { +async function fetchRoles(threadID: string): Promise { const query = SQL` - SELECT id, name, permissions, + SELECT id, name, permissions, special_role, special_role = ${specialRoles.DEFAULT_ROLE} AS is_default FROM roles WHERE thread = ${threadID} `; const [result] = await dbQuery(query); - const roles: Array = []; + const roles: Array = []; for (const row of result) { roles.push({ id: row.id.toString(), name: row.name, permissions: JSON.parse(row.permissions), isDefault: Boolean(row.is_default), + specialRole: row.special_role, }); } return roles; diff --git a/keyserver/src/updaters/role-updaters.js b/keyserver/src/updaters/role-updaters.js --- a/keyserver/src/updaters/role-updaters.js +++ b/keyserver/src/updaters/role-updaters.js @@ -6,6 +6,7 @@ import { getRolePermissionBlobs } from 'lib/permissions/thread-permissions.js'; import type { ThreadRolePermissionsBlob } from 'lib/types/thread-permission-types.js'; import type { ThreadType } from 'lib/types/thread-types-enum.js'; +import type { ServerLegacyRoleInfo } from 'lib/types/thread-types.js'; import createIDs from '../creators/id-creator.js'; import { dbQuery, SQL } from '../database/database.js'; @@ -17,7 +18,8 @@ threadID: string, threadType: ThreadType, ): Promise { - const currentRoles = await fetchRoles(threadID); + const currentRoles: $ReadOnlyArray = + await fetchRoles(threadID); const currentRolePermissions: { [string]: ThreadRolePermissionsBlob } = {}; const currentRoleIDs: { [string]: string } = {};