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: amend notification changes with scopes #7901

Merged
merged 2 commits into from
Nov 8, 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
185 changes: 9 additions & 176 deletions packages/notification/src/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,12 @@ import {
allUsersEmailHandler,
allUsersEmailPayloadSchema
} from '@notification/features/email/all-user-handler'
import {
sendBirthDeclarationConfirmation,
sendBirthRegistrationConfirmation,
sendBirthRejectionConfirmation,
inProgressNotificationSchema,
declarationNotificationSchema,
registrationNotificationSchema,
rejectionNotificationSchema,
sendBirthInProgressConfirmation
} from '@notification/features/sms/birth-handler'
import {
sendCorrectionApprovedNotification,
sendCorrectionApprovedNotificationInput,
sendCorrectionRejectedNotification,
sendCorrectionRejectedNotificationInput
} from '@notification/features/sms/correction'
import {
sendDeathDeclarationConfirmation,
sendDeathRegistrationConfirmation,
sendDeathRejectionConfirmation,
sendDeathInProgressConfirmation
} from '@notification/features/sms/death-handler'
import {
sendUserCredentials,
retrieveUserName,
Expand Down Expand Up @@ -63,15 +47,7 @@ import {
birthSentForUpdatesNotification,
deathSentForUpdatesNotification
} from '@notification/features/sentForUpdates/handler'

const enum RouteScope {
DECLARE = 'declare',
VALIDATE = 'validate',
REGISTER = 'register',
CERTIFY = 'certify',
SYSADMIN = 'sysadmin',
NATIONAL_SYSTEM_ADMIN = 'natlsysadmin'
}
import { SCOPES } from '@opencrvs/commons/authentication'

const recordValidation: RouteOptionsValidate = {
payload: Joi.object()
Expand Down Expand Up @@ -211,156 +187,13 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
path: '/death/sent-for-updates',
handler: deathSentForUpdatesNotification,
options: {
tags: ['api'],
description:
'Sends a notification to country config for rejected death declaration',
validate: recordValidation
}
},
{
method: 'POST',
path: '/birthInProgressSMS',
handler: sendBirthInProgressConfirmation,
options: {
tags: ['api'],
description: 'Sends an sms to a user for birth in-progress entry',
auth: {
scope: [
RouteScope.DECLARE,
RouteScope.VALIDATE,
RouteScope.REGISTER,
RouteScope.CERTIFY
]
},
validate: {
payload: inProgressNotificationSchema
}
}
},
{
method: 'POST',
path: '/birthDeclarationSMS',
handler: sendBirthDeclarationConfirmation,
options: {
tags: ['api'],
description:
'Sends an sms or email to a user for birth declaration entry',
auth: {
scope: [
RouteScope.DECLARE,
RouteScope.VALIDATE,
RouteScope.REGISTER,
RouteScope.CERTIFY
]
},
validate: {
payload: declarationNotificationSchema
}
}
},
{
method: 'POST',
path: '/birthRegistrationSMS',
handler: sendBirthRegistrationConfirmation,
options: {
tags: ['api'],
description:
'Sends an sms or email to a user for birth registration entry',
auth: {
scope: [RouteScope.REGISTER]
},
validate: {
payload: registrationNotificationSchema
}
}
},
{
method: 'POST',
path: '/birthRejectionSMS',
handler: sendBirthRejectionConfirmation,
options: {
tags: ['api'],
description:
'Sends an sms or email to a user for birth declaration rejection entry',
auth: {
scope: [RouteScope.VALIDATE, RouteScope.REGISTER]
},
validate: {
payload: rejectionNotificationSchema
}
}
},
{
method: 'POST',
path: '/deathInProgressSMS',
handler: sendDeathInProgressConfirmation,
options: {
tags: ['api'],
description:
'Sends an sms or email to a user for death in-progress entry',
auth: {
scope: [
RouteScope.DECLARE,
RouteScope.VALIDATE,
RouteScope.REGISTER,
RouteScope.CERTIFY
]
},
validate: {
payload: inProgressNotificationSchema
}
}
},
{
method: 'POST',
path: '/deathDeclarationSMS',
handler: sendDeathDeclarationConfirmation,
options: {
tags: ['api'],
description:
'Sends an sms or email to a user for death declaration entry',
auth: {
scope: [
RouteScope.DECLARE,
RouteScope.VALIDATE,
RouteScope.REGISTER,
RouteScope.CERTIFY
]
},
validate: {
payload: declarationNotificationSchema
}
}
},
{
method: 'POST',
path: '/deathRegistrationSMS',
handler: sendDeathRegistrationConfirmation,
options: {
tags: ['api'],
description: 'Sends an sms to a user for death registration entry',
auth: {
scope: [RouteScope.REGISTER]
scope: [SCOPES.RECORD_SUBMIT_FOR_UPDATES]
},
validate: {
payload: registrationNotificationSchema
}
}
},
{
method: 'POST',
path: '/deathRejectionSMS',
handler: sendDeathRejectionConfirmation,
options: {
tags: ['api'],
description:
'Sends an sms to a user for death declaration rejection entry',
auth: {
scope: [RouteScope.VALIDATE, RouteScope.REGISTER]
},
validate: {
payload: rejectionNotificationSchema
}
'Sends a notification to country config for rejected death declaration',
validate: recordValidation
}
},
{
Expand All @@ -371,7 +204,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
tags: ['api'],
description: 'Sends an sms to a user with credentials',
auth: {
scope: [RouteScope.SYSADMIN]
scope: [SCOPES.USER_READ]
},
validate: {
payload: userCredentialsNotificationSchema
Expand All @@ -386,7 +219,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
tags: ['api'],
description: 'Sends an sms to a user with credentials',
auth: {
scope: [RouteScope.REGISTER]
scope: [SCOPES.RECORD_REGISTER]
},
validate: {
payload: sendCorrectionRejectedNotificationInput
Expand All @@ -401,7 +234,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
tags: ['api'],
description: 'Sends an sms to a user with credentials',
auth: {
scope: [RouteScope.REGISTER]
scope: [SCOPES.RECORD_REGISTER]
},
validate: {
payload: sendCorrectionApprovedNotificationInput
Expand All @@ -416,7 +249,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
tags: ['api'],
description: 'Sends an sms to a user with new temporary password',
auth: {
scope: [RouteScope.SYSADMIN]
scope: [SCOPES.USER_READ]
},
validate: {
payload: userPasswordResetNotificationSchema
Expand Down Expand Up @@ -454,7 +287,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
options: {
tags: ['api'],
auth: {
scope: [RouteScope.NATIONAL_SYSTEM_ADMIN]
scope: [SCOPES.CONFIG_UPDATE_ALL]
},
description: 'Sends emails to all users given in payload',
validate: {
Expand Down
Loading
Loading