Skip to content

Commit

Permalink
#2369 - Create automatic email notifications for SABC staff (Final PR) (
Browse files Browse the repository at this point in the history
#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, '{[email protected]}'::varchar[]), 
(18, '{[email protected]}'::varchar[]), 
(19, '{[email protected]}'::varchar[]), 
(20, '{[email protected]}'::varchar[]), 
(21, '{[email protected]}'::varchar[]), 
(22, '{[email protected]}'::varchar[]), 
(23, '{[email protected]}'::varchar[]), 
(24, '{[email protected]}'::varchar[]), 
(25, '{[email protected]}'::varchar[])) AS updated_notification_messages(id, email_contacts) WHERE updated_notification_messages.id = notification_messages.id;

COMMIT;
```

**Screenshot of release instructions:**

<img width="874" alt="image"
src="https://github.com/bcgov/SIMS/assets/7859295/c790cbe0-5da7-49b0-b02c-107fcae636f8">
  • Loading branch information
sh16011993 authored Apr 24, 2024
1 parent 6e07840 commit 32041db
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 30 deletions.
1 change: 0 additions & 1 deletion .github/workflows/env-setup-deploy-secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 0 additions & 1 deletion configs/env-example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 0 additions & 1 deletion devops/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
6 changes: 0 additions & 6 deletions devops/openshift/init-secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions devops/openshift/queue-consumers-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion sources/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class EducationProgramOfferingService extends RecordDataModelService<Educ
legalOperatingName: educationProgramOffering.legalOperatingName,
primaryEmail: educationProgramOffering.primaryEmail,
programOfferingStatus: programOffering.offeringStatus,
institutionLocationName: programOffering.institutionLocation.name,
institutionLocationName: educationProgramOffering.locationName,
};
try {
return await this.dataSource.transaction(
Expand Down Expand Up @@ -535,7 +535,7 @@ export class EducationProgramOfferingService extends RecordDataModelService<Educ
legalOperatingName: educationProgramOffering.legalOperatingName,
primaryEmail: educationProgramOffering.primaryEmail,
programOfferingStatus: programOffering.offeringStatus,
institutionLocationName: programOffering.institutionLocation.name,
institutionLocationName: educationProgramOffering.locationName,
};
try {
return await this.dataSource.transaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import * as dayjs from "dayjs";
import { DISBURSEMENT_FILE_GENERATION_ANTICIPATION_DAYS } from "@sims/services/constants";
import { PartTimeCertRecordParser } from "./parsers/part-time-e-cert-record-parser";
import { loadDisbursementSchedules } from "./e-cert-utils";
import { GCNotifyService, SystemUsersService } from "@sims/services";
import { SystemUsersService } from "@sims/services";
import * as faker from "faker";

describe(
describeQueueProcessorRootTest(QueueNames.PartTimeECertIntegration),
Expand All @@ -47,7 +48,6 @@ describe(
let db: E2EDataSources;
let sftpClientMock: DeepMocked<Client>;
let systemUsersService: SystemUsersService;
let gcNotifyService: GCNotifyService;

beforeAll(async () => {
// Env variable required for querying the eligible e-Cert records.
Expand All @@ -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(
{
Expand Down Expand Up @@ -709,7 +708,7 @@ describe(
{
initialValue: {
messagePayload: {
email_address: gcNotifyService.ministryToAddress(),
email_address: faker.internet.email(),
template_id:
NotificationMessageType.MinistryNotificationDisbursementBlocked,
personalisation: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface BCeIDConfig {
export interface GCNotify {
url: string;
apiKey: string;
toAddress: string;
}

export interface UserPasswordCredential {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}

Expand Down
1 change: 0 additions & 1 deletion sources/tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 32041db

Please sign in to comment.