diff --git a/packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts b/packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts index dd7e59c6244b..d79d6188f3a0 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts @@ -12,7 +12,6 @@ import { FileUpload, GraphQLUpload } from 'graphql-upload'; import { FileFolder } from 'src/engine/core-modules/file/interfaces/file-folder.interface'; -import { LoginTokenService } from 'src/engine/core-modules/auth/token/services/login-token.service'; import { BillingSubscription } from 'src/engine/core-modules/billing/entities/billing-subscription.entity'; import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service'; import { DomainManagerService } from 'src/engine/core-modules/domain-manager/service/domain-manager.service'; @@ -54,7 +53,6 @@ import { WorkspaceService } from './services/workspace.service'; export class WorkspaceResolver { constructor( private readonly workspaceService: WorkspaceService, - private readonly loginTokenService: LoginTokenService, private readonly domainManagerService: DomainManagerService, private readonly userWorkspaceService: UserWorkspaceService, private readonly environmentService: EnvironmentService, @@ -186,50 +184,54 @@ export class WorkspaceResolver { @Query(() => PublicWorkspaceDataOutput) async getPublicWorkspaceDataBySubdomain(@OriginHeader() origin: string) { - const workspace = - await this.domainManagerService.getWorkspaceByOriginOrDefaultWorkspace( - origin, + try { + const workspace = + await this.domainManagerService.getWorkspaceByOriginOrDefaultWorkspace( + origin, + ); + + workspaceValidator.assertIsDefinedOrThrow( + workspace, + new WorkspaceException( + 'Workspace not found', + WorkspaceExceptionCode.WORKSPACE_NOT_FOUND, + ), ); - workspaceValidator.assertIsDefinedOrThrow( - workspace, - new WorkspaceException( - 'Workspace not found', - WorkspaceExceptionCode.WORKSPACE_NOT_FOUND, - ), - ); + let workspaceLogoWithToken = ''; - let workspaceLogoWithToken = ''; + if (workspace.logo) { + try { + const workspaceLogoToken = await this.fileService.encodeFileToken({ + workspaceId: workspace.id, + }); - if (workspace.logo) { - try { - const workspaceLogoToken = await this.fileService.encodeFileToken({ - workspaceId: workspace.id, - }); - - workspaceLogoWithToken = `${workspace.logo}?token=${workspaceLogoToken}`; - } catch (e) { - workspaceLogoWithToken = workspace.logo; + workspaceLogoWithToken = `${workspace.logo}?token=${workspaceLogoToken}`; + } catch (e) { + workspaceLogoWithToken = workspace.logo; + } } - } - const systemEnabledProviders: AuthProviders = { - google: this.environmentService.get('AUTH_GOOGLE_ENABLED'), - magicLink: false, - password: this.environmentService.get('AUTH_PASSWORD_ENABLED'), - microsoft: this.environmentService.get('AUTH_MICROSOFT_ENABLED'), - sso: [], - }; - - return { - id: workspace.id, - logo: workspaceLogoWithToken, - displayName: workspace.displayName, - subdomain: workspace.subdomain, - authProviders: getAuthProvidersByWorkspace({ - workspace, - systemEnabledProviders, - }), - }; + const systemEnabledProviders: AuthProviders = { + google: this.environmentService.get('AUTH_GOOGLE_ENABLED'), + magicLink: false, + password: this.environmentService.get('AUTH_PASSWORD_ENABLED'), + microsoft: this.environmentService.get('AUTH_MICROSOFT_ENABLED'), + sso: [], + }; + + return { + id: workspace.id, + logo: workspaceLogoWithToken, + displayName: workspace.displayName, + subdomain: workspace.subdomain, + authProviders: getAuthProvidersByWorkspace({ + workspace, + systemEnabledProviders, + }), + }; + } catch (err) { + workspaceGraphqlApiExceptionHandler(err); + } } }