Skip to content

Commit

Permalink
Add getting patents
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey-weber committed Nov 6, 2024
1 parent abc6cf1 commit 345f870
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/services/new/collection/delete-collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ export const deleteCollections = async (
) => {
const {collectionIds} = args;

const {
tenantId,
projectId,
// user: {userId},
} = ctx.get('info');
const {tenantId, projectId} = ctx.get('info');

ctx.log('DELETE_COLLECTIONS_START', {
collectionIds: await Utils.macrotasksMap(collectionIds, (id) => Utils.encodeId(id)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ export const checkAndSetCollectionPermission = async (
const targetTrx = getReplica(trx);
let parentIds: string[] = [];

if (accessServiceEnabled) {
if (collectionInstance.model.parentId !== null) {
parentIds = await getParentIds({
ctx,
trx: targetTrx,
collectionId: collectionInstance.model.parentId,
});
}
}

if (accessServiceEnabled && !skipCheckPermissions && !isPrivateRoute) {
let localPermission: CollectionPermission;

Expand All @@ -44,14 +54,6 @@ export const checkAndSetCollectionPermission = async (
localPermission = CollectionPermission.View;
}

if (collectionInstance.model.parentId !== null) {
parentIds = await getParentIds({
ctx,
trx: targetTrx,
collectionId: collectionInstance.model.parentId,
});
}

ctx.log('CHECK_PERMISSION', {permission: localPermission});

await collectionInstance.checkPermission({
Expand Down
16 changes: 9 additions & 7 deletions src/services/new/workbook/delete-workbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ export const deleteWorkbooks = async (

const workbooksMap: Map<WorkbookInstance, string[]> = new Map();

let parentIds: string[] = [];

const checkDeletePermissionPromises = workbooks.map(async (workbook) => {
if (workbook.model.isTemplate) {
throw new AppError("Workbook template can't be deleted", {
code: US_ERRORS.WORKBOOK_TEMPLATE_CANT_BE_DELETED,
});
}

if (accessServiceEnabled && !skipCheckPermissions) {
let parentIds: string[] = [];

if (accessServiceEnabled) {
if (workbook.model.collectionId !== null) {
parentIds = await getParentIds({
ctx,
Expand All @@ -80,10 +80,12 @@ export const deleteWorkbooks = async (

workbooksMap.set(workbook, parentIds);

await workbook.checkPermission({
parentIds,
permission: WorkbookPermission.Delete,
});
if (!skipCheckPermissions) {
await workbook.checkPermission({
parentIds,
permission: WorkbookPermission.Delete,
});
}
}
});

Expand Down

0 comments on commit 345f870

Please sign in to comment.