refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8212)
Follow-up to: https://github.com/n8n-io/n8n/pull/8186
This commit is contained in:
@@ -15,7 +15,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import type { EntityManager } from 'typeorm';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
|
||||
@Service()
|
||||
@@ -46,13 +45,6 @@ export class EnterpriseWorkflowService {
|
||||
return { ownsWorkflow: true, workflow };
|
||||
}
|
||||
|
||||
async share(transaction: EntityManager, workflow: WorkflowEntity, shareWithIds: string[]) {
|
||||
const users = await this.userRepository.getByIds(transaction, shareWithIds);
|
||||
const role = await this.roleService.findWorkflowEditorRole();
|
||||
|
||||
await this.sharedWorkflowRepository.share(transaction, workflow, users, role.id);
|
||||
}
|
||||
|
||||
addOwnerAndSharings(workflow: WorkflowWithSharingsAndCredentials): void {
|
||||
workflow.ownedBy = null;
|
||||
workflow.sharedWith = [];
|
||||
|
||||
@@ -35,6 +35,7 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository
|
||||
import type { RoleNames } from '@/databases/entities/Role';
|
||||
import { UnauthorizedError } from '@/errors/response-errors/unauthorized.error';
|
||||
import { CredentialsService } from '../credentials/credentials.service';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
|
||||
export const workflowsController = express.Router();
|
||||
|
||||
@@ -428,7 +429,10 @@ workflowsController.put(
|
||||
);
|
||||
|
||||
if (newShareeIds.length) {
|
||||
await Container.get(EnterpriseWorkflowService).share(trx, workflow!, newShareeIds);
|
||||
const users = await Container.get(UserRepository).getByIds(trx, newShareeIds);
|
||||
const role = await Container.get(RoleService).findWorkflowEditorRole();
|
||||
|
||||
await Container.get(SharedWorkflowRepository).share(trx, workflow!, users, role.id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user