Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ jobs:
with:
slim: 'true'
- uses: mansagroup/nrwl-nx-action@v3
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
with:
targets: lint,build,test
parallel: 5
Expand Down Expand Up @@ -168,6 +170,7 @@ jobs:
uses: mansagroup/nrwl-nx-action@v3
env:
LOG_LEVEL: 'info'
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
with:
targets: build
projects: '@novu/api'
Expand All @@ -176,6 +179,7 @@ jobs:
uses: mansagroup/nrwl-nx-action@v3
env:
LOG_LEVEL: 'info'
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
with:
targets: lint,build,test
projects: ${{join(fromJson(needs.get-affected.outputs.test-packages), ',')}}
Expand All @@ -195,6 +199,8 @@ jobs:

- name: Run Lint, Build, Test
uses: mansagroup/nrwl-nx-action@v3
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
with:
targets: lint,build,test
projects: ${{join(fromJson(needs.get-affected.outputs.test-libs), ',')}}
Expand Down Expand Up @@ -230,13 +236,17 @@ jobs:
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
name: Lint and build and test
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
with:
targets: build
projects: '@novu/api'
args: ''

- uses: mansagroup/nrwl-nx-action@v3
name: Lint and build and test
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
with:
targets: lint,build,test
projects: ${{matrix.projectName}}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/preview-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
run: pnpm run packages:set-latest

- name: Build
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: pnpm run preview:pkg:build

- name: Release package previews to pkg.pr.new
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prod-deploy-inbound-mail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
- uses: ./.github/actions/setup-project

- name: build api
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: pnpm build:inbound-mail

- uses: crazy-max/ghaction-setup-docker@v2
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ jobs:
fi

- name: Build packages
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: |
if [ "${{ github.event.inputs.release_type }}" != "stable" ]; then
pnpm run build:packages
Expand Down Expand Up @@ -236,6 +238,8 @@ jobs:
pnpm install --frozen-lockfile

- name: Build packages
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: pnpm run build:packages

- name: Publish packages to NPM
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-api-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
name: Start localstack

- name: Build API & Worker
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: CI='' pnpm nx run-many --target=build --all --projects=@novu/api-service,@novu/worker

- name: Start Worker
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-dashboard-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
submodules: true

- name: Build
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: CI='' pnpm build:dashboard --skip-nx-cache

- name: Deploy Dashboard to Netlify
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-dashboard-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ jobs:
echo NODE_ENV=test >> .env.playwright

- uses: mansagroup/nrwl-nx-action@v3
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
with:
targets: build
projects: '@novu/dashboard,@novu/api-service,@novu/worker'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-inbound-mail-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:

# Runs a single command using the runners shell
- name: Build Inbound Mail
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: CI='' pnpm build:inbound-mail

- name: Run unit tests
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-webhook-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:

# Runs a single command using the runners shell
- name: Build Webhook
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: CI='' pnpm build:webhook

# Runs a set of commands using the runners shell
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-worker-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:

# Runs a single command using the runners shell
- name: Build worker
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: CI='' pnpm build:worker

# Runs a set of commands using the runners shell
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-ws-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:

# Runs a single command using the runners shell
- name: Build WS
env:
NX_NO_CLOUD: ${{ secrets.NX_CLOUD_ACCESS_TOKEN == '' && 'true' || 'false' }}
run: CI='' pnpm build:ws

- name: Run unit tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,35 @@ export class CreateSubscriptionPreferencesUsecase {
continue;
}

const createdPreference = await this.preferencesRepository.create({
_environmentId: command.environmentId,
_organizationId: command.organizationId,
_subscriberId: command._subscriberId,
_templateId: workflow._id,
_topicSubscriptionId: command._topicSubscriptionId,
type: PreferencesTypeEnum.SUBSCRIPTION_SUBSCRIBER_WORKFLOW,
preferences: workflowPreferences,
contextKeys: command.contextKeys,
});
let createdPreference;
try {
createdPreference = await this.preferencesRepository.create({
_environmentId: command.environmentId,
_organizationId: command.organizationId,
_subscriberId: command._subscriberId,
_templateId: workflow._id,
_topicSubscriptionId: command._topicSubscriptionId,
type: PreferencesTypeEnum.SUBSCRIPTION_SUBSCRIBER_WORKFLOW,
preferences: workflowPreferences,
contextKeys: command.contextKeys,
});
} catch (error) {
const isDuplicateKeyError = error && typeof error === 'object' && 'code' in error && error.code === 11000;

if (isDuplicateKeyError) {
createdPreference = await this.preferencesRepository.findOne({
_environmentId: command.environmentId,
_subscriberId: command._subscriberId,
_templateId: workflow._id,
_topicSubscriptionId: command._topicSubscriptionId,
type: PreferencesTypeEnum.SUBSCRIPTION_SUBSCRIBER_WORKFLOW,
});
}

if (!isDuplicateKeyError || !createdPreference) {
throw error;
}
}

if (createdPreference) {
preferencesResult.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,31 @@ export class UpsertPreferences {
PreferencesTypeEnum.SUBSCRIBER_GLOBAL,
].includes(command.type);

return await this.preferencesRepository.create({
_subscriberId: command._subscriberId,
_userId: command.userId,
_environmentId: command.environmentId,
_organizationId: command.organizationId,
_templateId: command.templateId,
_topicSubscriptionId: command.topicSubscriptionId,
preferences: command.preferences,
type: command.type,
schedule: command.schedule,
contextKeys: useContextFiltering && isContextScoped ? (command.contextKeys ?? []) : undefined,
});
try {
return await this.preferencesRepository.create({
_subscriberId: command._subscriberId,
_userId: command.userId,
_environmentId: command.environmentId,
_organizationId: command.organizationId,
_templateId: command.templateId,
_topicSubscriptionId: command.topicSubscriptionId,
preferences: command.preferences,
type: command.type,
schedule: command.schedule,
contextKeys: useContextFiltering && isContextScoped ? (command.contextKeys ?? []) : undefined,
});
} catch (error) {
const isDuplicateKeyError = error && typeof error === 'object' && 'code' in error && error.code === 11000;

if (isDuplicateKeyError) {
const existingPreference = await this.getPreference(command);
if (existingPreference) {
return existingPreference;
}
}

throw error;
}
}

private async updatePreferences(
Expand Down
Loading