refactor(core): Ensure getSharedWorkflowIds returns string[] instead of number[] (#4971)

* 🔨 - getSharedWorkflowIds returns string[]

* 🔨 - update the sharedWorkflow function in public api

* 🔨 - update existing code to handle new data type

* simplify code

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
freya
2022-12-19 16:53:36 +00:00
committed by GitHub
parent 445463a605
commit 60b14116f0
7 changed files with 23 additions and 29 deletions

View File

@@ -116,7 +116,7 @@ export class WorkflowsService {
}
// Warning: this function is overriden by EE to disregard role list.
static async getWorkflowIdsForUser(user: User, roles?: string[]) {
static async getWorkflowIdsForUser(user: User, roles?: string[]): Promise<string[]> {
return getSharedWorkflowIds(user, roles);
}
@@ -152,12 +152,10 @@ export class WorkflowsService {
}
// safeguard against querying ids not shared with the user
if (filter?.id !== undefined) {
const workflowId = parseInt(filter.id.toString());
if (workflowId && !sharedWorkflowIds.includes(workflowId)) {
LoggerProxy.verbose(`User ${user.id} attempted to query non-shared workflow ${workflowId}`);
return [];
}
const workflowId = filter?.id?.toString();
if (workflowId !== undefined && !sharedWorkflowIds.includes(workflowId)) {
LoggerProxy.verbose(`User ${user.id} attempted to query non-shared workflow ${workflowId}`);
return [];
}
const fields: Array<keyof WorkflowEntity> = ['id', 'name', 'active', 'createdAt', 'updatedAt'];