From dc1527eb83a3007add4fcb9bdf737b3488293252 Mon Sep 17 00:00:00 2001 From: martmull Date: Tue, 17 Dec 2024 17:26:14 +0100 Subject: [PATCH] Protect serverless endpoint with workflow endpoint --- .../serverless-function.resolver.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.resolver.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.resolver.ts index 2df5d97bad6d..1493c9dc0647 100644 --- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.resolver.ts +++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.resolver.ts @@ -35,17 +35,16 @@ export class ServerlessFunctionResolver { ) {} async checkFeatureFlag(workspaceId: string) { - const isFunctionSettingsEnabled = - await this.featureFlagRepository.findOneBy({ - workspaceId, - key: FeatureFlagKey.IsFunctionSettingsEnabled, - value: true, - }); + const isWorkflowEnabled = await this.featureFlagRepository.findOneBy({ + workspaceId, + key: FeatureFlagKey.IsWorkflowEnabled, + value: true, + }); - if (!isFunctionSettingsEnabled) { + if (!isWorkflowEnabled) { throw new ServerlessFunctionException( - `IS_FUNCTION_SETTINGS_ENABLED feature flag is not set to true for this workspace`, - ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND, + `IS_WORKFLOW_ENABLED feature flag is not set to true for this workspace`, + ServerlessFunctionExceptionCode.FEATURE_FLAG_INVALID, ); } }