From 66b27abcc08e7b71a10c80989e9626f963d4601c Mon Sep 17 00:00:00 2001 From: g-tejas Date: Thu, 20 Jun 2024 14:02:31 +0800 Subject: [PATCH 1/6] fix: fix issue where email notifs for storage forms have wrong submission id --- .../encrypt-submission.controller.ts | 75 ++++++++++--------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/src/app/modules/submission/encrypt-submission/encrypt-submission.controller.ts b/src/app/modules/submission/encrypt-submission/encrypt-submission.controller.ts index 5cfbfe215d..cf18910d54 100644 --- a/src/app/modules/submission/encrypt-submission/encrypt-submission.controller.ts +++ b/src/app/modules/submission/encrypt-submission/encrypt-submission.controller.ts @@ -280,41 +280,6 @@ const submitEncryptModeForm = async ( } } - const logMetaWithSubmission = { - ...logMeta, - submissionId: form._id, - responseMetadata, - } - - logger.info({ - message: 'Sending admin notification mail', - meta: logMetaWithSubmission, - }) - - const emailData = new SubmissionEmailObj( - req.body.responses, - new Set(), // the MyInfo prefixes are already inserted in middleware - form.authType, - ) - - // We don't await for email submission, as the submission gets saved for encrypt - // submissions regardless, the email is more of a notification and shouldn't - // stop the storage of the data in the db - if (((form as IEncryptedForm)?.emails || []).length > 0) { - void MailService.sendSubmissionToAdmin({ - replyToEmails: EmailSubmissionService.extractEmailAnswers( - req.body.responses, - ), - form, - submission: { - created: form.created, - id: form._id, - }, - attachments: undefined, // Don't send attachments in the email notifications - formData: emailData.formData, - }) - } - // Save Responses to Database let attachmentMetadata = new Map() @@ -370,6 +335,7 @@ const submitEncryptModeForm = async ( res, logMeta, formId, + form, responses: req.formsg.filteredResponses, responseMetadata, submissionContent, @@ -628,6 +594,7 @@ const _createSubmission = async ({ submissionContent, logMeta, formId, + form, responseMetadata, responses, }: { @@ -636,6 +603,7 @@ const _createSubmission = async ({ responseMetadata: EncryptSubmissionDto['responseMetadata'] responses: ParsedClearFormFieldResponse[] formId: string + form: IPopulatedEncryptedForm submissionContent: EncryptSubmissionContent logMeta: CustomLoggerParams['meta'] }) => { @@ -670,6 +638,41 @@ const _createSubmission = async ({ }, }) + const createdTime = submission.created || new Date() + + const logMetaWithSubmission = { + ...logMeta, + submissionId, + responseMetadata, + } + + logger.info({ + message: 'Sending admin notification mail', + meta: logMetaWithSubmission, + }) + + const emailData = new SubmissionEmailObj( + responses, + new Set(), // the MyInfo prefixes are already inserted in middleware + form.authType, + ) + + // We don't await for email submission, as the submission gets saved for encrypt + // submissions regardless, the email is more of a notification and shouldn't + // stop the storage of the data in the db + if (((form as IEncryptedForm)?.emails || []).length > 0) { + void MailService.sendSubmissionToAdmin({ + replyToEmails: EmailSubmissionService.extractEmailAnswers(responses), + form, + submission: { + created: createdTime, + id: submission.id, + }, + attachments: undefined, // Don't send attachments in the email notifications + formData: emailData.formData, + }) + } + // TODO 6395 make responseMetadata mandatory if (responseMetadata) { reportSubmissionResponseTime(responseMetadata, { @@ -682,7 +685,7 @@ const _createSubmission = async ({ res.json({ message: 'Form submission successful.', submissionId, - timestamp: (submission.created || new Date()).getTime(), + timestamp: createdTime.getTime(), }) return await performEncryptPostSubmissionActions(submission, responses) From a11195b30354fc54f186f9cab815675d42ce1aca Mon Sep 17 00:00:00 2001 From: Kevin Foong Date: Fri, 21 Jun 2024 11:28:26 +0800 Subject: [PATCH 2/6] fix: add default values for postman env variables to docker compose --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9d5fbe3726..66f71b07cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -133,9 +133,9 @@ services: - WOGAA_START_ENDPOINT - WOGAA_SUBMIT_ENDPOINT - WOGAA_FEEDBACK_ENDPOINT - - POSTMAN_MOP_CAMPAIGN_ID - - POSTMAN_MOP_CAMPAIGN_API_KEY - - POSTMAN_BASE_URL + - POSTMAN_MOP_CAMPAIGN_ID=campaign_test + - POSTMAN_MOP_CAMPAIGN_API_KEY=key_test_123 + - POSTMAN_BASE_URL=https://test.postman.gov.sg/api/v2 mockpass: build: https://github.com/opengovsg/mockpass.git#v4.3.1 From 8acefb5b8ee411ceec7b1ca3616f87f9e2760198 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 22:47:41 +0800 Subject: [PATCH 3/6] fix(deps): bump express-session and @types/express-session (#7407) Bumps [express-session](https://github.com/expressjs/session) and [@types/express-session](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/express-session). These dependencies needed to be updated together. Updates `express-session` from 1.17.3 to 1.18.0 - [Release notes](https://github.com/expressjs/session/releases) - [Changelog](https://github.com/expressjs/session/blob/master/HISTORY.md) - [Commits](https://github.com/expressjs/session/compare/v1.17.3...v1.18.0) Updates `@types/express-session` from 1.17.4 to 1.18.0 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/express-session) --- updated-dependencies: - dependency-name: express-session dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: "@types/express-session" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 28 ++++++++++++++++++---------- package.json | 4 ++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6e32f9214..284d655ede 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,7 +49,7 @@ "express": "^4.19.2", "express-rate-limit": "^7.2.0", "express-request-id": "^1.4.1", - "express-session": "^1.17.3", + "express-session": "^1.18.0", "express-winston": "^4.2.0", "fetch-readablestream": "^0.2.0", "file-saver": "^2.0.5", @@ -132,7 +132,7 @@ "@types/ejs": "^3.1.1", "@types/express": "^4.17.21", "@types/express-request-id": "^1.4.3", - "@types/express-session": "^1.17.4", + "@types/express-session": "^1.18.0", "@types/helmet": "4.0.0", "@types/html-escaper": "^3.0.2", "@types/http-errors": "^2.0.1", @@ -9391,9 +9391,10 @@ } }, "node_modules/@types/express-session": { - "version": "1.17.4", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/@types/express-session/-/express-session-1.18.0.tgz", + "integrity": "sha512-27JdDRgor6PoYlURY+Y5kCakqp5ulC0kmf7y+QwaY+hv9jEFuQOThgkjyA53RP3jmKuBsH5GR6qEfFmvb8mwOA==", "dev": true, - "license": "MIT", "dependencies": { "@types/express": "*" } @@ -15783,11 +15784,12 @@ } }, "node_modules/express-session": { - "version": "1.17.3", - "license": "MIT", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.18.0.tgz", + "integrity": "sha512-m93QLWr0ju+rOwApSsyso838LQwgfs44QtOP/WBiwtAgPIo/SAh1a5c6nn2BR6mFNZehTpqKDESzP+fRHVbxwQ==", "dependencies": { - "cookie": "0.4.2", - "cookie-signature": "1.0.6", + "cookie": "0.6.0", + "cookie-signature": "1.0.7", "debug": "2.6.9", "depd": "~2.0.0", "on-headers": "~1.0.2", @@ -15800,12 +15802,18 @@ } }, "node_modules/express-session/node_modules/cookie": { - "version": "0.4.2", - "license": "MIT", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } }, + "node_modules/express-session/node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==" + }, "node_modules/express-session/node_modules/debug": { "version": "2.6.9", "license": "MIT", diff --git a/package.json b/package.json index 192c9b9f1c..f204d2f616 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "express": "^4.19.2", "express-rate-limit": "^7.2.0", "express-request-id": "^1.4.1", - "express-session": "^1.17.3", + "express-session": "^1.18.0", "express-winston": "^4.2.0", "fetch-readablestream": "^0.2.0", "file-saver": "^2.0.5", @@ -178,7 +178,7 @@ "@types/ejs": "^3.1.1", "@types/express": "^4.17.21", "@types/express-request-id": "^1.4.3", - "@types/express-session": "^1.17.4", + "@types/express-session": "^1.18.0", "@types/helmet": "4.0.0", "@types/html-escaper": "^3.0.2", "@types/http-errors": "^2.0.1", From c04e5072ec383f3e67b5d11dce3bef73d90812a9 Mon Sep 17 00:00:00 2001 From: Ken Lee Shu Ming Date: Sun, 23 Jun 2024 16:55:09 +0800 Subject: [PATCH 4/6] chore: update form creation modal wording (#7421) --- .../CreateFormModalContent/CreateFormDetailsScreen.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/features/workspace/components/CreateFormModal/CreateFormModalContent/CreateFormDetailsScreen.tsx b/frontend/src/features/workspace/components/CreateFormModal/CreateFormModalContent/CreateFormDetailsScreen.tsx index c5ecdeb4bf..abe74535cb 100644 --- a/frontend/src/features/workspace/components/CreateFormModal/CreateFormModalContent/CreateFormDetailsScreen.tsx +++ b/frontend/src/features/workspace/components/CreateFormModal/CreateFormModalContent/CreateFormDetailsScreen.tsx @@ -73,9 +73,7 @@ export const CreateFormDetailsScreen = (): JSX.Element => { ) : null} - - How do you want to receive your form responses? - + What type of form do you need? Date: Sun, 23 Jun 2024 22:39:32 +0800 Subject: [PATCH 5/6] chore: update dockerfile casing (#7429) --- Dockerfile.production | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.production b/Dockerfile.production index fda956e05a..9934d510e7 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM node:hydrogen-alpine3.19 as build +FROM node:hydrogen-alpine3.19 AS build # node-modules-builder stage installs/compiles the node_modules folder # Python version must be specified starting in alpine3.12 From 061dc4fa0b106300764268f1b5f0671de75a7213 Mon Sep 17 00:00:00 2001 From: Ken Date: Mon, 24 Jun 2024 12:06:54 +0800 Subject: [PATCH 6/6] chore: bump version to v6.129.0 --- CHANGELOG.md | 14 +++++++++++--- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 178f0cae5e..ffa717b64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,19 +4,27 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -#### [v6.128.0](https://github.com/opengovsg/FormSG/compare/v6.128.0...v6.128.0) +#### [v6.129.0](https://github.com/opengovsg/FormSG/compare/v6.128.0...v6.129.0) -- fix(btn): form admin not fully resolved when retrieved from FormService [`#7420`](https://github.com/opengovsg/FormSG/pull/7420) +- build: merge release v6.128.0 into develop [`#7430`](https://github.com/opengovsg/FormSG/pull/7430) +- chore: update dockerfile casing [`#7429`](https://github.com/opengovsg/FormSG/pull/7429) +- chore: update form creation modal wording [`#7421`](https://github.com/opengovsg/FormSG/pull/7421) +- fix(deps): bump express-session and @types/express-session [`#7407`](https://github.com/opengovsg/FormSG/pull/7407) +- fix: add default values for postman env variables to docker compose [`#7424`](https://github.com/opengovsg/FormSG/pull/7424) +- fix: email notifications with wrong submission id [`#7418`](https://github.com/opengovsg/FormSG/pull/7418) +- build: release v6.128.0 [`#7419`](https://github.com/opengovsg/FormSG/pull/7419) +- fix: fix issue where email notifs for storage forms have wrong submission id [`66b27ab`](https://github.com/opengovsg/FormSG/commit/66b27abcc08e7b71a10c80989e9626f963d4601c) #### [v6.128.0](https://github.com/opengovsg/FormSG/compare/v6.127.1...v6.128.0) > 20 June 2024 +- fix(btn): form admin not fully resolved when retrieved from FormService [`#7420`](https://github.com/opengovsg/FormSG/pull/7420) - feat(btn): frm 1717 mop flow to postman [`#7342`](https://github.com/opengovsg/FormSG/pull/7342) - build: merge release v6.127.1 to develop [`#7416`](https://github.com/opengovsg/FormSG/pull/7416) - fix(deps): bump libphonenumber-js from 1.11.3 to 1.11.4 in /shared [`#7415`](https://github.com/opengovsg/FormSG/pull/7415) - hotfix: dupe form fail [`#7414`](https://github.com/opengovsg/FormSG/pull/7414) -- chore: bump version to v6.128.0 [`4b8cea2`](https://github.com/opengovsg/FormSG/commit/4b8cea2a46a258b96dc9b7be31b480481b8e30e8) +- chore: bump version to v6.128.0 [`8f91bf0`](https://github.com/opengovsg/FormSG/commit/8f91bf0cbe541487bc9cd2775dd4c3c135b13f70) #### [v6.127.1](https://github.com/opengovsg/FormSG/compare/v6.127.0...v6.127.1) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 25cf4810db..0a3635ee0e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "form-frontend", - "version": "6.128.0", + "version": "6.129.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "form-frontend", - "version": "6.128.0", + "version": "6.129.0", "hasInstallScript": true, "dependencies": { "@chakra-ui/react": "^1.8.6", diff --git a/frontend/package.json b/frontend/package.json index d05435fff9..62662cd24f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "form-frontend", - "version": "6.128.0", + "version": "6.129.0", "homepage": ".", "private": true, "dependencies": { diff --git a/package-lock.json b/package-lock.json index 231838e147..4bffcdfd64 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "FormSG", - "version": "6.128.0", + "version": "6.129.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "FormSG", - "version": "6.128.0", + "version": "6.129.0", "hasInstallScript": true, "dependencies": { "@aws-sdk/client-cloudwatch-logs": "^3.536.0", diff --git a/package.json b/package.json index 5cbca7c5aa..76c50e611f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "FormSG", "description": "Form Manager for Government", - "version": "6.128.0", + "version": "6.129.0", "homepage": "https://form.gov.sg", "authors": [ "FormSG "