From 6e87a86d67a00ece3019758c78c315cde9a59053 Mon Sep 17 00:00:00 2001 From: Antoine Moreaux Date: Thu, 19 Dec 2024 15:16:41 +0100 Subject: [PATCH] fix(domain-manager): prioritize non-seed workspaces in selection Updated workspace selection logic to prioritize non-seed workspaces. Returns a seed workspace only if no non-seed workspaces are available to improve filtering consistency and avoid unintended behavior. --- .../service/domain-manager.service.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/twenty-server/src/engine/core-modules/domain-manager/service/domain-manager.service.ts b/packages/twenty-server/src/engine/core-modules/domain-manager/service/domain-manager.service.ts index 27814f53ab..0b0536b5fa 100644 --- a/packages/twenty-server/src/engine/core-modules/domain-manager/service/domain-manager.service.ts +++ b/packages/twenty-server/src/engine/core-modules/domain-manager/service/domain-manager.service.ts @@ -12,6 +12,10 @@ import { import { getDomainNameByEmail } from 'src/utils/get-domain-name-by-email'; import { isDefined } from 'src/utils/is-defined'; import { isWorkEmail } from 'src/utils/is-work-email'; +import { + SEED_ACME_WORKSPACE_ID, + SEED_APPLE_WORKSPACE_ID, +} from 'src/database/typeorm-seeds/core/workspaces'; @Injectable() export class DomainManagerService { @@ -153,7 +157,14 @@ export class DomainManagerService { ); } - return workspaces[0]; + const nonSeedWorkspace = workspaces.find( + (workspace) => + ![SEED_APPLE_WORKSPACE_ID, SEED_ACME_WORKSPACE_ID].includes( + workspace.id, + ), + ); + + return nonSeedWorkspace ?? workspaces[workspaces.length - 1]; } throw new Error(