diff --git a/.source b/.source index d034791c4e3..139dc582124 160000 --- a/.source +++ b/.source @@ -1 +1 @@ -Subproject commit d034791c4e39516d4a9e4161e632fa7dcef5bb39 +Subproject commit 139dc582124cbeae3eb5f5b510fc209628e079ed diff --git a/apps/api/src/.example.env b/apps/api/src/.example.env index 9ba67945c27..a10ede1969e 100644 --- a/apps/api/src/.example.env +++ b/apps/api/src/.example.env @@ -90,5 +90,6 @@ PLAIN_CARDS_HMAC_SECRET_KEY='PLAIN_CARDS_HMAC_SECRET_KEY' NOVU_INTERNAL_SECRET_KEY= NOVU_SECRET_KEY='NOVU_SECRET_KEY' + # expressed in seconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms.js). Eg: 60, "2 days", "10h", "7d" SUBSCRIBER_WIDGET_JWT_EXPIRATION_TIME='15 days' diff --git a/apps/api/src/app/support/usecases/plain-cards.usecase.ts b/apps/api/src/app/support/usecases/plain-cards.usecase.ts index 4592ba09f99..0eb5fd1056b 100644 --- a/apps/api/src/app/support/usecases/plain-cards.usecase.ts +++ b/apps/api/src/app/support/usecases/plain-cards.usecase.ts @@ -35,8 +35,7 @@ export class PlainCardsUsecase { private userRepository: UserRepository ) {} async fetchCustomerDetails(command: PlainCardsCommand) { - const key = process.env.NOVU_REGION === 'eu-west-2' ? 'customer-details-eu' : 'customer-details-us'; - + const key = `customer-details-${process.env.NOVU_REGION}`; if (!command?.customer?.externalId) { return { data: {}, @@ -51,7 +50,7 @@ export class PlainCardsUsecase { }, { componentText: { - text: 'This user is not yet registered on Novu', + text: 'This user is not yet registered in this region', }, }, ], @@ -61,6 +60,29 @@ export class PlainCardsUsecase { } const organizations = await this.organizationRepository.findUserActiveOrganizations(command?.customer?.externalId); + if (!organizations) { + return { + data: {}, + cards: [ + { + key, + components: [ + { + componentSpacer: { + spacerSize: 'S', + }, + }, + { + componentText: { + text: 'This user is not yet registered in this region', + }, + }, + ], + }, + ], + }; + } + const sessions = await this.userRepository.findUserSessions(command?.customer?.externalId); return { diff --git a/apps/api/src/config/env.validators.ts b/apps/api/src/config/env.validators.ts index 2bb75a1a5bb..fa3e94dbcba 100644 --- a/apps/api/src/config/env.validators.ts +++ b/apps/api/src/config/env.validators.ts @@ -42,6 +42,7 @@ export const envValidators = { API_ROOT_URL: url(), NOVU_INVITE_TEAM_MEMBER_NUDGE_TRIGGER_IDENTIFIER: str({ default: undefined }), SUBSCRIBER_WIDGET_JWT_EXPIRATION_TIME: str({ default: '15 days' }), + NOVU_REGION: str({ default: 'local' }), // Novu Cloud third party services ...(processEnv.IS_SELF_HOSTED !== 'true' &&