From 3efd6485fcea0c906d944350d6f69844afb105e9 Mon Sep 17 00:00:00 2001 From: Darcy Ye Date: Fri, 7 Jul 2023 16:52:56 +0800 Subject: [PATCH] fix(core,connector): use isProduction as email service feature switch --- .../connectors/connector-logto-email/src/constant.ts | 7 ++++++- packages/core/src/utils/connectors/index.ts | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/connectors/connector-logto-email/src/constant.ts b/packages/connectors/connector-logto-email/src/constant.ts index bd47c8eed..633018d6d 100644 --- a/packages/connectors/connector-logto-email/src/constant.ts +++ b/packages/connectors/connector-logto-email/src/constant.ts @@ -1,3 +1,5 @@ +import { getEnv } from '@silverhand/essentials'; + import type { ConnectorMetadata } from '@logto/connector-kit'; import { ConnectorConfigFormItemType } from '@logto/connector-kit'; @@ -102,6 +104,9 @@ export const scope = ['send:email']; export const defaultTimeout = 5000; -export const emailEndpoint = '/services/mails'; +export const oldEmailEndpoint = '/services/send-email'; +export const newEmailEndpoint = '/services/mails'; +export const emailEndpoint = + getEnv('NODE_ENV') === 'production' ? oldEmailEndpoint : newEmailEndpoint; export const usageEndpoint = '/services/mails/usage'; diff --git a/packages/core/src/utils/connectors/index.ts b/packages/core/src/utils/connectors/index.ts index bf678d70a..522e785c2 100644 --- a/packages/core/src/utils/connectors/index.ts +++ b/packages/core/src/utils/connectors/index.ts @@ -8,6 +8,7 @@ import { connectorDirectory } from '@logto/cli/lib/constants.js'; import { getConnectorPackagesFromDirectory } from '@logto/cli/lib/utils.js'; import { demoConnectorIds, + serviceConnectorIds, ConnectorType, type EmailConnector, type SmsConnector, @@ -40,7 +41,10 @@ export const transpileLogtoConnector = async ( ); const { dbEntry, metadata, type } = connector; const { config, connectorId: id } = dbEntry; - const isDemo = demoConnectorIds.includes(id); + /** Temporarily block entering Logto email connector as well until this feature is ready for prod. */ + const isDemo = + demoConnectorIds.includes(id) || + (EnvSet.values.isProduction && serviceConnectorIds.includes(id)); return { type, @@ -61,7 +65,10 @@ export const transpileConnectorFactory = ({ return { type, ...metadata, - isDemo: demoConnectorIds.includes(metadata.id), + /** Temporarily block entering Logto email connector as well until this feature is ready for prod. */ + isDemo: + demoConnectorIds.includes(metadata.id) || + (EnvSet.values.isProduction && serviceConnectorIds.includes(metadata.id)), }; };