From e9210c20b981d2b366217fd90f9782e7cba3bae8 Mon Sep 17 00:00:00 2001 From: Sergei Samokhvalov Date: Thu, 16 Nov 2023 21:12:11 +0300 Subject: [PATCH] add scope --- .../entry/actions/create-in-workbook.ts | 26 +++++++++---------- .../new/workbook/get-workbook-content.ts | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/services/entry/actions/create-in-workbook.ts b/src/services/entry/actions/create-in-workbook.ts index 6f958b78..578bf74a 100644 --- a/src/services/entry/actions/create-in-workbook.ts +++ b/src/services/entry/actions/create-in-workbook.ts @@ -101,14 +101,12 @@ export async function createEntryInWorkbook( const {accessServiceEnabled} = ctx.config; - let permissions: Optional; + const workbook = await getWorkbook( + {ctx, skipCheckPermissions: isPrivateRoute}, + {workbookId, includePermissionsInfo}, + ); const createdEntry = await transaction(Entry.primary, async (trx) => { - const workbook = await getWorkbook( - {ctx, trx, skipCheckPermissions: isPrivateRoute}, - {workbookId, includePermissionsInfo}, - ); - if (accessServiceEnabled && !isPrivateRoute) { await checkWorkbookPermission({ ctx, @@ -118,13 +116,6 @@ export async function createEntryInWorkbook( }); } - if (includePermissionsInfo) { - permissions = getEntryPermissionsByWorkbook({ - ctx, - workbook, - }); - } - const [entryId, revId] = await Promise.all([getId(), getId()]); // TODO: DLS.addEntity / iam registrate entry @@ -173,6 +164,15 @@ export async function createEntryInWorkbook( }); const resultEntry: Entry & {permissions?: UsPermission} = createdEntry!; + let permissions: Optional; + + if (includePermissionsInfo) { + permissions = getEntryPermissionsByWorkbook({ + ctx, + workbook, + scope: resultEntry.scope, + }); + } if (includePermissionsInfo) { resultEntry.permissions = permissions; diff --git a/src/services/new/workbook/get-workbook-content.ts b/src/services/new/workbook/get-workbook-content.ts index fd40934b..1a9f9c0e 100644 --- a/src/services/new/workbook/get-workbook-content.ts +++ b/src/services/new/workbook/get-workbook-content.ts @@ -112,7 +112,7 @@ export const getWorkbookContent = async ( {ctx, trx, skipValidation: true, skipCheckPermissions}, { workbookId, - includePermissionsInfo, + includePermissionsInfo: true, }, );