mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Use DI in execution services (no-changelog) (#8358)
This commit is contained in:
@@ -1,31 +1,53 @@
|
||||
import { ExecutionRequest } from './execution.request';
|
||||
import { ExecutionsService } from './executions.service';
|
||||
import { ExecutionService } from './execution.service';
|
||||
import { Authorized, Get, Post, RestController } from '@/decorators';
|
||||
import { EnterpriseExecutionsService } from './executions.service.ee';
|
||||
import { EnterpriseExecutionsService } from './execution.service.ee';
|
||||
import { isSharingEnabled } from '@/UserManagement/UserManagementHelper';
|
||||
import { WorkflowSharingService } from '@/workflows/workflowSharing.service';
|
||||
import type { User } from '@/databases/entities/User';
|
||||
|
||||
@Authorized()
|
||||
@RestController('/executions')
|
||||
export class ExecutionsController {
|
||||
constructor(
|
||||
private readonly executionService: ExecutionService,
|
||||
private readonly enterpriseExecutionService: EnterpriseExecutionsService,
|
||||
private readonly workflowSharingService: WorkflowSharingService,
|
||||
) {}
|
||||
|
||||
private async getAccessibleWorkflowIds(user: User) {
|
||||
return isSharingEnabled()
|
||||
? this.workflowSharingService.getSharedWorkflowIds(user)
|
||||
: this.workflowSharingService.getSharedWorkflowIds(user, ['owner']);
|
||||
}
|
||||
|
||||
@Get('/')
|
||||
async getExecutionsList(req: ExecutionRequest.GetAll) {
|
||||
return ExecutionsService.getExecutionsList(req);
|
||||
const workflowIds = await this.getAccessibleWorkflowIds(req.user);
|
||||
|
||||
return this.executionService.getExecutionsList(req, workflowIds);
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async getExecution(req: ExecutionRequest.Get) {
|
||||
const workflowIds = await this.getAccessibleWorkflowIds(req.user);
|
||||
|
||||
return isSharingEnabled()
|
||||
? EnterpriseExecutionsService.getExecution(req)
|
||||
: ExecutionsService.getExecution(req);
|
||||
? this.enterpriseExecutionService.getExecution(req, workflowIds)
|
||||
: this.executionService.getExecution(req, workflowIds);
|
||||
}
|
||||
|
||||
@Post('/:id/retry')
|
||||
async retryExecution(req: ExecutionRequest.Retry) {
|
||||
return ExecutionsService.retryExecution(req);
|
||||
const workflowIds = await this.getAccessibleWorkflowIds(req.user);
|
||||
|
||||
return this.executionService.retryExecution(req, workflowIds);
|
||||
}
|
||||
|
||||
@Post('/delete')
|
||||
async deleteExecutions(req: ExecutionRequest.Delete) {
|
||||
return ExecutionsService.deleteExecutions(req);
|
||||
const workflowIds = await this.getAccessibleWorkflowIds(req.user);
|
||||
|
||||
return this.executionService.deleteExecutions(req, workflowIds);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user