Skip to content

Commit

Permalink
feat: update query dsl
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Aug 9, 2023
1 parent 24e1e9a commit 0307540
Showing 1 changed file with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,51 @@ export class WorkspaceSavedObjectsClientWrapper {
throw generateWorkspacePermissionError();
}
} else {
options.workspaces = permittedWorkspaceIds;
const queryDSL = ACL.genereateGetPermittedSavedObjectsQueryDSL(
[PermissionMode.Read, PermissionMode.Write],
principals,
options.type
);
options.workspaces = undefined;
/**
* Select all the docs that
* 1. ACL matches right or write permission OR
* 2. workspaces matches library_read or library_write or management OR
* 3. Records without workspaces field (Advances settings)
*/
options.queryDSL = {
query: {
bool: {
filter: [
{
bool: {
should: [
{
bool: {
must_not: {
exists: {
field: 'workspaces',
},
},
},
},
queryDSL.query,
{
bool: {
should: permittedWorkspaceIds?.map((item) => ({
terms: {
workspaces: [item],
},
})),
},
},
],
},
},
],
},
},
};
}
}

Expand Down

0 comments on commit 0307540

Please sign in to comment.