diff --git a/.commitlintrc.json b/.commitlintrc.json index 7293d5af944..7185c74f33d 100644 --- a/.commitlintrc.json +++ b/.commitlintrc.json @@ -4,7 +4,7 @@ "subject-case": [ 2, "always", - ["sentence-case", "start-case", "pascal-case", "upper-case", "lower-case"] + ["sentence-case", "start-case", "pascal-case", "upper-case", "lower-case", "camel-case"] ], "type-enum": [ 2, diff --git a/apps/api/src/app/events/e2e/delay-events.e2e.ts b/apps/api/src/app/events/e2e/delay-events.e2e.ts index 92c16c216e6..bca7d81b517 100644 --- a/apps/api/src/app/events/e2e/delay-events.e2e.ts +++ b/apps/api/src/app/events/e2e/delay-events.e2e.ts @@ -24,13 +24,13 @@ describe('Trigger event - Delay triggered events - /v1/events/trigger (POST)', f let standardQueueService: StandardQueueService; const messageRepository = new MessageRepository(); - const triggerEvent = async (payload, transactionId?: string, overrides = {}) => { + const triggerEvent = async (payload, transactionId?: string, overrides = {}, to = [subscriber.subscriberId]) => { await axiosInstance.post( `${session.serverUrl}/v1/events/trigger`, { transactionId, name: template.triggers[0].identifier, - to: [subscriber.subscriberId], + to, payload, overrides, }, @@ -330,6 +330,8 @@ describe('Trigger event - Delay triggered events - /v1/events/trigger (POST)', f }); it('should be able to cancel delay', async function () { + const secondSubscriber = await subscriberService.createSubscriber(); + const id = MessageRepository.createObjectId(); template = await session.createTemplate({ steps: [ @@ -342,7 +344,7 @@ describe('Trigger event - Delay triggered events - /v1/events/trigger (POST)', f content: '', metadata: { unit: DigestUnitEnum.SECONDS, - amount: 0.1, + amount: 5, type: DelayTypeEnum.REGULAR, }, }, @@ -357,17 +359,19 @@ describe('Trigger event - Delay triggered events - /v1/events/trigger (POST)', f { customVar: 'Testing of User Name', }, - id + id, + {}, + [subscriber.subscriberId, secondSubscriber.subscriberId] ); - await session.awaitRunningJobs(template?._id, true, 1); + await session.awaitRunningJobs(template?._id, true, 2); await axiosInstance.delete(`${session.serverUrl}/v1/events/trigger/${id}`, { headers: { authorization: `ApiKey ${session.apiKey}`, }, }); - let delayedJob = await jobRepository.findOne({ + let delayedJobs = await jobRepository.find({ _environmentId: session.environment._id, _templateId: template._id, type: StepTypeEnum.DELAY, @@ -380,14 +384,15 @@ describe('Trigger event - Delay triggered events - /v1/events/trigger (POST)', f transactionId: id, }); - expect(pendingJobs).to.equal(1); + expect(pendingJobs).to.equal(2); - delayedJob = await jobRepository.findOne({ + delayedJobs = await jobRepository.find({ _environmentId: session.environment._id, _templateId: template._id, type: StepTypeEnum.DELAY, transactionId: id, }); - expect(delayedJob!.status).to.equal(JobStatusEnum.CANCELED); + expect(delayedJobs[0]!.status).to.equal(JobStatusEnum.CANCELED); + expect(delayedJobs[1]!.status).to.equal(JobStatusEnum.CANCELED); }); }); diff --git a/apps/api/src/app/events/usecases/cancel-delayed/cancel-delayed.usecase.ts b/apps/api/src/app/events/usecases/cancel-delayed/cancel-delayed.usecase.ts index 74da1a23231..954d652394a 100644 --- a/apps/api/src/app/events/usecases/cancel-delayed/cancel-delayed.usecase.ts +++ b/apps/api/src/app/events/usecases/cancel-delayed/cancel-delayed.usecase.ts @@ -7,20 +7,25 @@ export class CancelDelayed { constructor(private jobRepository: JobRepository) {} public async execute(command: CancelDelayedCommand): Promise { - const job = await this.jobRepository.findOne({ - _environmentId: command.environmentId, - transactionId: command.transactionId, - status: JobStatusEnum.DELAYED, - }); + const jobs = await this.jobRepository.find( + { + _environmentId: command.environmentId, + transactionId: command.transactionId, + status: JobStatusEnum.DELAYED, + }, + '_id' + ); - if (!job) { + if (!jobs?.length) { return false; } await this.jobRepository.update( { _environmentId: command.environmentId, - _id: job._id, + _id: { + $in: jobs.map((job) => job._id), + }, }, { $set: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 762f449ad63..f03595ffcdf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17545,46 +17545,6 @@ packages: dev: false /@pmmmwh/react-refresh-webpack-plugin@0.5.10(react-refresh@0.11.0)(webpack-dev-server@4.11.1)(webpack@5.78.0): - resolution: {integrity: sha512-j0Ya0hCFZPd4x40qLzbhGsh9TMtdb+CJQiso+WxLOPNasohq9cc5SNUcwsZaRH6++Xh91Xkm/xHCkuIiIu0LUA==} - engines: {node: '>= 10.13'} - peerDependencies: - '@types/webpack': 4.x || 5.x - react-refresh: '>=0.10.0 <1.0.0' - sockjs-client: ^1.4.0 - type-fest: '>=0.17.0 <4.0.0' - webpack: '>=4.43.0 <6.0.0' - webpack-dev-server: 3.x || 4.x - webpack-hot-middleware: 2.x - webpack-plugin-serve: 0.x || 1.x - peerDependenciesMeta: - '@types/webpack': - optional: true - sockjs-client: - optional: true - type-fest: - optional: true - webpack-dev-server: - optional: true - webpack-hot-middleware: - optional: true - webpack-plugin-serve: - optional: true - dependencies: - ansi-html-community: 0.0.8 - common-path-prefix: 3.0.0 - core-js-pure: 3.30.0 - error-stack-parser: 2.1.4 - find-up: 5.0.0 - html-entities: 2.3.3 - loader-utils: 2.0.4 - react-refresh: 0.11.0 - schema-utils: 3.3.0 - source-map: 0.7.4 - webpack: 5.78.0 - webpack-dev-server: 4.11.1(webpack@5.78.0) - dev: true - - /@pmmmwh/react-refresh-webpack-plugin@0.5.10(react-refresh@0.11.0)(webpack@5.78.0): resolution: {integrity: sha512-j0Ya0hCFZPd4x40qLzbhGsh9TMtdb+CJQiso+WxLOPNasohq9cc5SNUcwsZaRH6++Xh91Xkm/xHCkuIiIu0LUA==} engines: {node: '>= 10.13'} peerDependencies: @@ -17621,6 +17581,7 @@ packages: schema-utils: 3.3.0 source-map: 0.7.4 webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) + webpack-dev-server: 4.11.1(webpack@5.78.0) dev: true /@pmmmwh/react-refresh-webpack-plugin@0.5.10(react-refresh@0.14.0)(webpack-dev-server@4.11.1)(webpack@5.78.0): @@ -21816,7 +21777,7 @@ packages: '@babel/core': 7.23.2 '@babel/preset-flow': 7.22.15(@babel/core@7.23.2) '@babel/preset-react': 7.22.15(@babel/core@7.23.2) - '@pmmmwh/react-refresh-webpack-plugin': 0.5.10(react-refresh@0.11.0)(webpack@5.78.0) + '@pmmmwh/react-refresh-webpack-plugin': 0.5.10(react-refresh@0.11.0)(webpack-dev-server@4.11.1)(webpack@5.78.0) '@storybook/core-webpack': 7.4.2 '@storybook/docs-tools': 7.4.2 '@storybook/node-logger': 7.4.2 @@ -25740,7 +25701,7 @@ packages: loader-utils: 2.0.4 make-dir: 3.1.0 schema-utils: 2.7.1 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /babel-loader@8.3.0(@babel/core@7.23.2)(webpack@5.82.1): @@ -28521,7 +28482,7 @@ packages: postcss-modules-values: 4.0.0(postcss@8.4.31) postcss-value-parser: 4.2.0 semver: 7.5.4 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /css-minimizer-webpack-plugin@3.4.1(esbuild@0.18.20)(webpack@5.78.0): @@ -30747,7 +30708,7 @@ packages: micromatch: 4.0.5 normalize-path: 3.0.0 schema-utils: 4.0.0 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /eslint@7.32.0: @@ -31515,7 +31476,7 @@ packages: dependencies: loader-utils: 2.0.4 schema-utils: 3.3.0 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /file-selector@0.6.0: @@ -31845,7 +31806,7 @@ packages: semver: 7.5.4 tapable: 1.1.3 typescript: 4.9.5 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /fork-ts-checker-webpack-plugin@8.0.0(typescript@4.9.5)(webpack@5.78.0): @@ -33346,7 +33307,7 @@ packages: lodash: 4.17.21 pretty-error: 4.0.0 tapable: 2.2.1 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) /htmlparser2@6.1.0: resolution: {integrity: sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==} @@ -36536,7 +36497,7 @@ packages: less: 4.1.3 loader-utils: 1.4.2 pify: 3.0.0 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /less@4.1.3: @@ -38109,7 +38070,7 @@ packages: webpack: ^5.0.0 dependencies: schema-utils: 4.0.0 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /minimalistic-assert@1.0.1: @@ -41163,7 +41124,7 @@ packages: klona: 2.0.6 postcss: 8.4.31 semver: 7.5.4 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /postcss-loader@7.0.2(postcss@8.4.31)(webpack@5.76.1): @@ -42766,7 +42727,7 @@ packages: peerDependencies: react-scripts: '>=2.1.3' dependencies: - react-scripts: 5.0.1(@babel/plugin-syntax-flow@7.22.5)(@babel/plugin-transform-react-jsx@7.22.15)(eslint-import-resolver-webpack@0.13.7)(eslint@8.51.0)(react@17.0.2)(ts-node@10.9.1)(typescript@4.9.5) + react-scripts: 5.0.1(@babel/plugin-syntax-flow@7.22.5)(@babel/plugin-transform-react-jsx@7.22.15)(@swc/core@1.3.49)(esbuild@0.18.20)(eslint-import-resolver-webpack@0.13.7)(eslint@8.51.0)(react@17.0.2)(ts-node@10.9.1)(typescript@4.9.5) semver: 5.7.2 dev: true @@ -42861,7 +42822,7 @@ packages: strip-ansi: 6.0.1 text-table: 0.2.0 typescript: 4.9.5 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) transitivePeerDependencies: - eslint - supports-color @@ -44598,7 +44559,7 @@ packages: dependencies: klona: 2.0.6 neo-async: 2.6.2 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /sass-loader@13.2.0(sass@1.58.1)(webpack@5.76.1): @@ -45334,7 +45295,7 @@ packages: abab: 2.0.6 iconv-lite: 0.6.3 source-map-js: 1.0.2 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /source-map-loader@4.0.1(webpack@5.76.1): @@ -46023,7 +45984,7 @@ packages: peerDependencies: webpack: ^5.0.0 dependencies: - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) dev: true /stylehacks@5.1.1(postcss@8.4.31): @@ -46690,6 +46651,7 @@ packages: serialize-javascript: 6.0.1 terser: 5.22.0 webpack: 5.78.0 + dev: true /terser-webpack-plugin@5.3.9(webpack@5.88.2): resolution: {integrity: sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA==} @@ -48653,7 +48615,7 @@ packages: mime-types: 2.1.35 range-parser: 1.2.1 schema-utils: 4.0.0 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) /webpack-dev-middleware@6.0.1(webpack@5.76.1): resolution: {integrity: sha512-PZPZ6jFinmqVPJZbisfggDiC+2EeGZ1ZByyMP5sOFJcPPWSexalISz+cvm+j+oYPT7FIJyxT76esjnw9DhE5sw==} @@ -48772,7 +48734,7 @@ packages: serve-index: 1.9.1 sockjs: 0.3.24 spdy: 4.0.2 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) webpack-dev-middleware: 5.3.3(webpack@5.78.0) ws: 8.13.0 transitivePeerDependencies: @@ -48796,7 +48758,7 @@ packages: webpack: ^4.44.2 || ^5.47.0 dependencies: tapable: 2.2.1 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) webpack-sources: 2.3.1 dev: true @@ -48926,6 +48888,7 @@ packages: - '@swc/core' - esbuild - uglify-js + dev: true /webpack@5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4): resolution: {integrity: sha512-gT5DP72KInmE/3azEaQrISjTvLYlSM0j1Ezhht/KLVkrqtv10JoP/RXhwmX/frrutOPuSq3o5Vq0ehR/4Vmd1g==} @@ -49398,7 +49361,7 @@ packages: fast-json-stable-stringify: 2.1.0 pretty-bytes: 5.6.0 upath: 1.2.0 - webpack: 5.78.0 + webpack: 5.78.0(@swc/core@1.3.49)(esbuild@0.18.20)(webpack-cli@5.1.4) webpack-sources: 1.4.3 workbox-build: 6.5.4 transitivePeerDependencies: