mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Don't create multiple owners when importing credentials or workflows (#9112)
This commit is contained in:
@@ -19,12 +19,7 @@ export async function createManyWorkflows(
|
||||
return await Promise.all(workflowRequests);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a workflow in the DB (without a trigger) and optionally assign it to a user.
|
||||
* @param attributes workflow attributes
|
||||
* @param user user to assign the workflow to
|
||||
*/
|
||||
export async function createWorkflow(attributes: Partial<WorkflowEntity> = {}, user?: User) {
|
||||
export function newWorkflow(attributes: Partial<WorkflowEntity> = {}): WorkflowEntity {
|
||||
const { active, name, nodes, connections, versionId } = attributes;
|
||||
|
||||
const workflowEntity = Container.get(WorkflowRepository).create({
|
||||
@@ -45,7 +40,16 @@ export async function createWorkflow(attributes: Partial<WorkflowEntity> = {}, u
|
||||
...attributes,
|
||||
});
|
||||
|
||||
const workflow = await Container.get(WorkflowRepository).save(workflowEntity);
|
||||
return workflowEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a workflow in the DB (without a trigger) and optionally assign it to a user.
|
||||
* @param attributes workflow attributes
|
||||
* @param user user to assign the workflow to
|
||||
*/
|
||||
export async function createWorkflow(attributes: Partial<WorkflowEntity> = {}, user?: User) {
|
||||
const workflow = await Container.get(WorkflowRepository).save(newWorkflow(attributes));
|
||||
|
||||
if (user) {
|
||||
await Container.get(SharedWorkflowRepository).save({
|
||||
@@ -121,5 +125,9 @@ export async function getAllWorkflows() {
|
||||
return await Container.get(WorkflowRepository).find();
|
||||
}
|
||||
|
||||
export async function getAllSharedWorkflows() {
|
||||
return await Container.get(SharedWorkflowRepository).find();
|
||||
}
|
||||
|
||||
export const getWorkflowById = async (id: string) =>
|
||||
await Container.get(WorkflowRepository).findOneBy({ id });
|
||||
|
||||
Reference in New Issue
Block a user