fix(core): Add sharing data to workflows in EE executions (#6872)

* fix(core): Add sharing data to workflows in EE executions

* Address feedback
This commit is contained in:
Iván Ovejero 2023-08-08 14:28:05 +02:00 committed by GitHub
parent 11440bfd3c
commit 6796d9e5d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,11 @@
import type { User } from '@db/entities/User';
import { getSharedWorkflowIds } from '@/WorkflowHelpers';
import { ExecutionsService } from './executions.service';
import type { ExecutionRequest } from '@/requests';
import type { IExecutionResponse, IExecutionFlattedResponse } from '@/Interfaces';
import { EEWorkflowsService as EEWorkflows } from '../workflows/workflows.services.ee';
import { WorkflowRepository } from '@/databases/repositories';
import Container from 'typedi';
export class EEExecutionsService extends ExecutionsService {
/**
@ -10,4 +15,21 @@ export class EEExecutionsService extends ExecutionsService {
// Get all workflows
return getSharedWorkflowIds(user);
}
static async getExecution(
req: ExecutionRequest.Get,
): Promise<IExecutionResponse | IExecutionFlattedResponse | undefined> {
const execution = await super.getExecution(req);
if (!execution) return;
const workflow = Container.get(WorkflowRepository).create(execution.workflowData);
EEWorkflows.addOwnerAndSharings(workflow);
await EEWorkflows.addCredentialsToWorkflow(workflow, req.user);
execution.workflowData = workflow;
return execution;
}
}