Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: add route to serve record notification #274

Merged
merged 5 commits into from
Sep 19, 2024
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
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ INSERT CSV ROWS IN ENGLISH ONLY

### Breaking changes

- **Notification Flags** The configuration of various notifications is now controlled from `countryconfig` instead of being handled in the UI, as notification settings are not something that should be changed on the fly. To simplify this process, we have moved the settings to the `application-config.ts` file. From now on, the notifications can be managed in the `notificationForRecord` object defined in the mentioned file. Any changes will take effect after a new deployment.

**_Country implementors must define the `notificationForRecord` object in the `application-config.ts` file to enable the notifications they want. Not doing so will keep notifications disabled by default._**

- **Gateways searchEvents API updated** `operationHistories` only returns `operationType` & `operatedOn` due to the other fields being unused in OpenCRVS
- **Config changes to review/preview and signatures** Core used to provide review/preview section by default which are now removed and need to be provided from countryconfig. The signature field definitions (e.g. informant signature, bride signature etc.) were hard coded in core which also have now been removed. The signatures can now be added through the review/preview sections defined in countryconfig just like any other field. You can use the following section definition as the default which is without any additional fields. We highly recommend checking out our reference country repository which has the signature fields in it's review/preview sections

Expand Down Expand Up @@ -87,12 +91,21 @@ INSERT CSV ROWS IN ENGLISH ONLY
- If there is only one option in the document uploader select, then it stays hidden and only the upload button is showed with the only option being selected by default
- The select options in DOCUMENT_UPLOADER_WITH_OPTION field can now be hidden using the new `optionCondition` property. It works similarly to the same property available in SELECT_WITH_OPTIONS field

* **ElasticSearch reindexing**

Allows reindexing ElasticSearch via a new search-service endpoint `reindex`. We're replacing the original `ocrvs` index with timestamped ones. This is done automatically when upgrading and migrating, but this is an important architectural change that should be noted. More details in [#7033](https://github.com/opencrvs/opencrvs-core/pull/7033).
* **ElasticSearch reindexing** Allows reindexing ElasticSearch via a new search-service endpoint `reindex`. We're replacing the original `ocrvs` index with timestamped ones. This is done automatically when upgrading and migrating, but this is an important architectural change that should be noted. More details in [#7033](https://github.com/opencrvs/opencrvs-core/pull/7033).

- Introduce a new certificate handlebar "preview" which can be used to conditionally render some svg element when previewing the certificate e.g. background image similar to security paper

- **Notification flags**: Added notification flags for `BIRTH`, `DEATH`, and `MARRIAGE` events, including:

- `sent-notification`
- `sent-notification-for-review`
- `sent-for-approval`
- `registered`
- `sent-for-updates`

- **`/record-notification` API**: Endpoint to check enabled notifications for records. The API returns the `notificationForRecord` object for `BIRTH` and `DEATH` events, listing their respective flags. Route configuration includes description and tags for API documentation.


### New content keys requiring translation

```
Expand Down
31 changes: 31 additions & 0 deletions src/api/application/application-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,34 @@ export const applicationConfig = {
}

export const COUNTRY_WIDE_CRUDE_DEATH_RATE = 10

type EventNotificationFlags = {
'sent-notification'?: boolean
'sent-notification-for-review'?: boolean
'sent-for-approval'?: boolean
registered?: boolean
'sent-for-updates'?: boolean
}

type NotificationFlags = {
BIRTH?: EventNotificationFlags
DEATH?: EventNotificationFlags
MARRIAGE?: EventNotificationFlags
}

export const notificationForRecord: NotificationFlags = {
BIRTH: {
'sent-notification': true,
'sent-notification-for-review': true,
'sent-for-approval': true,
registered: true,
'sent-for-updates': true
},
DEATH: {
'sent-notification': true,
'sent-notification-for-review': true,
'sent-for-approval': true,
registered: true,
'sent-for-updates': true
}
}
9 changes: 9 additions & 0 deletions src/api/record-notification/handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as Hapi from '@hapi/hapi'
import { notificationForRecord } from '../application/application-config'

export function recordNotificationHandler(
request: Hapi.Request,
h: Hapi.ResponseToolkit
) {
return h.response(notificationForRecord)
}
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { trackingIDHandler } from './api/tracking-id/handler'
import { dashboardQueriesHandler } from './api/dashboards/handler'
import { fontsHandler } from './api/fonts/handler'
import { certificateConfigurationHandler } from './api/certificate-configuration/handler'
import { recordNotificationHandler } from './api/record-notification/handler'

export interface ITokenPayload {
sub: string
Expand Down Expand Up @@ -534,6 +535,16 @@ export async function createServer() {
}
})

server.route({
method: 'GET',
path: '/record-notification',
handler: recordNotificationHandler,
options: {
tags: ['api'],
description: 'Checks for enabled notification for record'
}
})

server.ext({
type: 'onRequest',
method(request: Hapi.Request & { sentryScope?: any }, h) {
Expand Down
Loading