From 32041db359271387ef49afa86b8984192fbe88b0 Mon Sep 17 00:00:00 2001 From: Shashank Shekhar Date: Tue, 23 Apr 2024 17:43:23 -0700 Subject: [PATCH] #2369 - Create automatic email notifications for SABC staff (Final PR) (#3179) ### As a part of this PR, the following tasks were completed: - Removed the existing env variable that contains the Ministry email and updated the various pieces of code where it was consumed from the codebase and added it to the release instructions. - Created the SQL script and added it to the release instructions to have the emails be updated on PROD for the ministry notification to be sent. - **Code Fix:** Code update to retrieve `institutionLocationName` in `education-program-offering.service.ts`. - Created story for the e2e tests for the notifications sent to the ministry [Link to the story](https://app.zenhub.com/workspaces/student-information-management-system-5fce9df5aa1b45000e937014/issues/gh/bcgov/sims/3184 ) **SQL:** ``` UPDATE sims.notification_messages AS notification_messages SET email_contacts = updated_notification_messages.email_contacts FROM (VALUES (1, '{studentaidbc@gov.bc.ca}'::varchar[]), (18, '{studentaidbc@gov.bc.ca}'::varchar[]), (19, '{studentaidbc@gov.bc.ca}'::varchar[]), (20, '{studentaidbc@gov.bc.ca}'::varchar[]), (21, '{studentaidbc@gov.bc.ca}'::varchar[]), (22, '{sabc.appealsunit@gov.bc.ca}'::varchar[]), (23, '{designat@gov.bc.ca}'::varchar[]), (24, '{designat@gov.bc.ca}'::varchar[]), (25, '{designat@gov.bc.ca}'::varchar[])) AS updated_notification_messages(id, email_contacts) WHERE updated_notification_messages.id = notification_messages.id; COMMIT; ``` **Screenshot of release instructions:** image --- .github/workflows/env-setup-deploy-secrets.yml | 1 - configs/env-example | 1 - devops/Makefile | 1 - devops/openshift/init-secrets.yml | 6 ------ devops/openshift/queue-consumers-deploy.yml | 7 ------- sources/docker-compose.yml | 1 - .../education-program-offering.service.ts | 4 ++-- ...ert-part-time-process-integration.scheduler.e2e-spec.ts | 7 +++---- .../src/notifications/notification/gc-notify.service.ts | 4 ---- .../backend/libs/utilities/src/config/config.models.ts | 1 - .../backend/libs/utilities/src/config/config.service.ts | 1 - sources/tests/docker-compose.yml | 1 - 12 files changed, 5 insertions(+), 30 deletions(-) diff --git a/.github/workflows/env-setup-deploy-secrets.yml b/.github/workflows/env-setup-deploy-secrets.yml index a23842901a..28a596d470 100644 --- a/.github/workflows/env-setup-deploy-secrets.yml +++ b/.github/workflows/env-setup-deploy-secrets.yml @@ -41,7 +41,6 @@ jobs: INSTITUTION_RESPONSE_FOLDER: ${{ vars.INSTITUTION_RESPONSE_FOLDER }} GC_NOTIFY_URL: ${{ secrets.GC_NOTIFY_URL }} GC_NOTIFY_API_KEY: ${{ secrets.GC_NOTIFY_API_KEY }} - GC_NOTIFY_TO_ADDRESS: ${{ secrets.GC_NOTIFY_TO_ADDRESS }} ZEEBE_ADDRESS: ${{ secrets.ZEEBE_ADDRESS }} ZEEBE_CLIENT_ID: ${{ secrets.ZEEBE_CLIENT_ID }} ZEEBE_CLIENT_SECRET: ${{ secrets.ZEEBE_CLIENT_SECRET }} diff --git a/configs/env-example b/configs/env-example index 328c04070f..258f19a3a4 100644 --- a/configs/env-example +++ b/configs/env-example @@ -51,7 +51,6 @@ BCeID_WEB_SERVICE_AUTH_USER_PASSWORD= # GC Notify Web Service - These variables are used to send Email notifications. GC_NOTIFY_URL=https://api.notification.canada.ca/v2/notifications/email GC_NOTIFY_API_KEY= -GC_NOTIFY_TO_ADDRESS= # Devops/openshift Make init-zone-b-sftp-secret INIT_ZONE_B_SFTP_SERVER= diff --git a/devops/Makefile b/devops/Makefile index 40011c2eb3..80df62596b 100644 --- a/devops/Makefile +++ b/devops/Makefile @@ -209,7 +209,6 @@ init-secrets: -p INSTITUTION_RESPONSE_FOLDER=$(INSTITUTION_RESPONSE_FOLDER) \ -p GC_NOTIFY_URL=$(GC_NOTIFY_URL) \ -p GC_NOTIFY_API_KEY=$(GC_NOTIFY_API_KEY) \ - -p GC_NOTIFY_TO_ADDRESS=$(GC_NOTIFY_TO_ADDRESS) \ -p ZEEBE_ADDRESS=$(ZEEBE_ADDRESS) \ -p ZEEBE_CLIENT_ID=$(ZEEBE_CLIENT_ID) \ -p ZEEBE_CLIENT_SECRET=$(ZEEBE_CLIENT_SECRET) \ diff --git a/devops/openshift/init-secrets.yml b/devops/openshift/init-secrets.yml index 2626fb04aa..6f747ee08f 100644 --- a/devops/openshift/init-secrets.yml +++ b/devops/openshift/init-secrets.yml @@ -31,7 +31,6 @@ objects: atbc-app: ${ATBC_APP} gc-notify-url: ${GC_NOTIFY_URL} gc-notify-api-key: ${GC_NOTIFY_API_KEY} - gc-notify-to-address: ${GC_NOTIFY_TO_ADDRESS} zeebe-address: ${ZEEBE_ADDRESS} zeebe-client-id: ${ZEEBE_CLIENT_ID} zeebe-client-secret: ${ZEEBE_CLIENT_SECRET} @@ -159,11 +158,6 @@ parameters: required: true description: | GC notify API key to send email notification. - - name: GC_NOTIFY_TO_ADDRESS - displayName: GC notify to address - required: true - description: | - GC notify to address to send email notification. - name: ZEEBE_ADDRESS displayName: Zeebe address required: true diff --git a/devops/openshift/queue-consumers-deploy.yml b/devops/openshift/queue-consumers-deploy.yml index 87fa76bafb..3bb60071e3 100644 --- a/devops/openshift/queue-consumers-deploy.yml +++ b/devops/openshift/queue-consumers-deploy.yml @@ -135,11 +135,6 @@ objects: secretKeyRef: key: ${GC_NOTIFY_API_KEY_NAME_KEY} name: ${QUEUE_CONSUMERS_SECRET_NAME} - - name: GC_NOTIFY_TO_ADDRESS - valueFrom: - secretKeyRef: - key: ${GC_NOTIFY_TO_ADDRESS_NAME_KEY} - name: ${QUEUE_CONSUMERS_SECRET_NAME} - name: SFAS_RECEIVE_FOLDER valueFrom: secretKeyRef: @@ -383,8 +378,6 @@ parameters: value: gc-notify-url - name: GC_NOTIFY_API_KEY_NAME_KEY value: gc-notify-api-key - - name: GC_NOTIFY_TO_ADDRESS_NAME_KEY - value: gc-notify-to-address - name: SFAS_RECEIVE_FOLDER_NAME_KEY value: sfas-receive-folder - name: ATBC_LOGIN_ENDPOINT diff --git a/sources/docker-compose.yml b/sources/docker-compose.yml index ae62f25719..e533a96b64 100644 --- a/sources/docker-compose.yml +++ b/sources/docker-compose.yml @@ -129,7 +129,6 @@ services: - INSTITUTION_RESPONSE_FOLDER=${INSTITUTION_RESPONSE_FOLDER} - GC_NOTIFY_URL=${GC_NOTIFY_URL} - GC_NOTIFY_API_KEY=${GC_NOTIFY_API_KEY} - - GC_NOTIFY_TO_ADDRESS=${GC_NOTIFY_TO_ADDRESS} - ZONE_B_SFTP_SERVER=${ZONE_B_SFTP_SERVER} - ZONE_B_SFTP_SERVER_PORT=${ZONE_B_SFTP_SERVER_PORT} - ZONE_B_SFTP_USER_NAME=${ZONE_B_SFTP_USER_NAME} diff --git a/sources/packages/backend/apps/api/src/services/education-program-offering/education-program-offering.service.ts b/sources/packages/backend/apps/api/src/services/education-program-offering/education-program-offering.service.ts index 66a9aa6653..011ab404de 100644 --- a/sources/packages/backend/apps/api/src/services/education-program-offering/education-program-offering.service.ts +++ b/sources/packages/backend/apps/api/src/services/education-program-offering/education-program-offering.service.ts @@ -115,7 +115,7 @@ export class EducationProgramOfferingService extends RecordDataModelService; let systemUsersService: SystemUsersService; - let gcNotifyService: GCNotifyService; beforeAll(async () => { // Env variable required for querying the eligible e-Cert records. @@ -60,7 +60,6 @@ describe( // Processor under test. processor = app.get(PartTimeECertProcessIntegrationScheduler); systemUsersService = app.get(SystemUsersService); - gcNotifyService = app.get(GCNotifyService); // Insert fake email contact to send ministry email. await db.notificationMessage.update( { @@ -709,7 +708,7 @@ describe( { initialValue: { messagePayload: { - email_address: gcNotifyService.ministryToAddress(), + email_address: faker.internet.email(), template_id: NotificationMessageType.MinistryNotificationDisbursementBlocked, personalisation: { diff --git a/sources/packages/backend/libs/services/src/notifications/notification/gc-notify.service.ts b/sources/packages/backend/libs/services/src/notifications/notification/gc-notify.service.ts index 73a3a6dbe5..67d6129b2b 100644 --- a/sources/packages/backend/libs/services/src/notifications/notification/gc-notify.service.ts +++ b/sources/packages/backend/libs/services/src/notifications/notification/gc-notify.service.ts @@ -21,10 +21,6 @@ export class GCNotifyService { this.gcNotifyConfig = this.configService.notify; } - ministryToAddress() { - return this.gcNotifyConfig.toAddress; - } - /** * Send email notification by passing the requestPayload. * @param payload email message payload. diff --git a/sources/packages/backend/libs/utilities/src/config/config.models.ts b/sources/packages/backend/libs/utilities/src/config/config.models.ts index 4ce1d7ca91..4d9cf2c041 100644 --- a/sources/packages/backend/libs/utilities/src/config/config.models.ts +++ b/sources/packages/backend/libs/utilities/src/config/config.models.ts @@ -44,7 +44,6 @@ export interface BCeIDConfig { export interface GCNotify { url: string; apiKey: string; - toAddress: string; } export interface UserPasswordCredential { diff --git a/sources/packages/backend/libs/utilities/src/config/config.service.ts b/sources/packages/backend/libs/utilities/src/config/config.service.ts index 7364ac3172..2a4ea90df0 100644 --- a/sources/packages/backend/libs/utilities/src/config/config.service.ts +++ b/sources/packages/backend/libs/utilities/src/config/config.service.ts @@ -57,7 +57,6 @@ export class ConfigService { return this.getCachedConfig("notifyConfig", { url: process.env.GC_NOTIFY_URL, apiKey: process.env.GC_NOTIFY_API_KEY, - toAddress: process.env.GC_NOTIFY_TO_ADDRESS, }); } diff --git a/sources/tests/docker-compose.yml b/sources/tests/docker-compose.yml index b62dde83ab..e32b930b6d 100644 --- a/sources/tests/docker-compose.yml +++ b/sources/tests/docker-compose.yml @@ -127,7 +127,6 @@ services: - INSTITUTION_RESPONSE_FOLDER=${INSTITUTION_RESPONSE_FOLDER} - GC_NOTIFY_URL=${GC_NOTIFY_URL} - GC_NOTIFY_API_KEY=${GC_NOTIFY_API_KEY} - - GC_NOTIFY_TO_ADDRESS=${GC_NOTIFY_TO_ADDRESS} - ZONE_B_SFTP_SERVER=${ZONE_B_SFTP_SERVER} - ZONE_B_SFTP_SERVER_PORT=${ZONE_B_SFTP_SERVER_PORT} - ZONE_B_SFTP_USER_NAME=${ZONE_B_SFTP_USER_NAME}