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
Changes from 1 commit
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
68 changes: 34 additions & 34 deletions packages/notification/src/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,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 @@ -226,10 +218,12 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
description: 'Sends an sms to a user for birth in-progress entry',
auth: {
scope: [
RouteScope.DECLARE,
RouteScope.VALIDATE,
RouteScope.REGISTER,
RouteScope.CERTIFY
SCOPES.RECORD_DECLARE_BIRTH,
SCOPES.RECORD_DECLARE_DEATH,
SCOPES.RECORD_DECLARE_MARRIAGE,
SCOPES.RECORD_REGISTER,
SCOPES.RECORD_CERTIFY,
SCOPES.RECORD_SUBMIT_FOR_APPROVAL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take a closer look at the endpoints, for example this one is birthInProgressSMS so the following scopes makes sense in this ase:

  SCOPES.RECORD_DECLARE_BIRTH,
  SCOPES.RECORD_REGISTER,
  SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
  SCOPES.RECORD_SUBMIT_FOR_APPROVAL

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also could take a look if this endpoint is actually being used or not? I'm a bit skeptical about that 😅

]
},
validate: {
Expand All @@ -247,10 +241,12 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
'Sends an sms or email to a user for birth declaration entry',
auth: {
scope: [
RouteScope.DECLARE,
RouteScope.VALIDATE,
RouteScope.REGISTER,
RouteScope.CERTIFY
SCOPES.RECORD_DECLARE_BIRTH,
SCOPES.RECORD_DECLARE_DEATH,
SCOPES.RECORD_DECLARE_MARRIAGE,
SCOPES.RECORD_REGISTER,
SCOPES.RECORD_CERTIFY,
SCOPES.RECORD_SUBMIT_FOR_APPROVAL
]
},
validate: {
Expand All @@ -267,7 +263,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
description:
'Sends an sms or email to a user for birth registration entry',
auth: {
scope: [RouteScope.REGISTER]
scope: [SCOPES.RECORD_REGISTER]
},
validate: {
payload: registrationNotificationSchema
Expand All @@ -283,7 +279,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
description:
'Sends an sms or email to a user for birth declaration rejection entry',
auth: {
scope: [RouteScope.VALIDATE, RouteScope.REGISTER]
scope: [SCOPES.RECORD_SUBMIT_FOR_APPROVAL, SCOPES.RECORD_REGISTER]
},
validate: {
payload: rejectionNotificationSchema
Expand All @@ -300,10 +296,12 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
'Sends an sms or email to a user for death in-progress entry',
auth: {
scope: [
RouteScope.DECLARE,
RouteScope.VALIDATE,
RouteScope.REGISTER,
RouteScope.CERTIFY
SCOPES.RECORD_DECLARE_BIRTH,
SCOPES.RECORD_DECLARE_DEATH,
SCOPES.RECORD_DECLARE_MARRIAGE,
SCOPES.RECORD_REGISTER,
SCOPES.RECORD_CERTIFY,
SCOPES.RECORD_SUBMIT_FOR_APPROVAL
]
},
validate: {
Expand All @@ -321,10 +319,12 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
'Sends an sms or email to a user for death declaration entry',
auth: {
scope: [
RouteScope.DECLARE,
RouteScope.VALIDATE,
RouteScope.REGISTER,
RouteScope.CERTIFY
SCOPES.RECORD_DECLARE_BIRTH,
SCOPES.RECORD_DECLARE_DEATH,
SCOPES.RECORD_DECLARE_MARRIAGE,
SCOPES.RECORD_REGISTER,
SCOPES.RECORD_CERTIFY,
SCOPES.RECORD_SUBMIT_FOR_APPROVAL
]
},
validate: {
Expand All @@ -340,7 +340,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
tags: ['api'],
description: 'Sends an sms to a user for death registration entry',
auth: {
scope: [RouteScope.REGISTER]
scope: [SCOPES.RECORD_REGISTER]
},
validate: {
payload: registrationNotificationSchema
Expand All @@ -356,7 +356,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
description:
'Sends an sms to a user for death declaration rejection entry',
auth: {
scope: [RouteScope.VALIDATE, RouteScope.REGISTER]
scope: [SCOPES.RECORD_SUBMIT_FOR_APPROVAL, SCOPES.RECORD_REGISTER]
},
validate: {
payload: rejectionNotificationSchema
Expand All @@ -371,7 +371,7 @@ export default function getRoutes(): ServerRoute<ReqRefDefaults>[] {
tags: ['api'],
description: 'Sends an sms to a user with credentials',
auth: {
scope: [RouteScope.SYSADMIN]
scope: [SCOPES.CONFIG_UPDATE_ALL]
},
validate: {
payload: userCredentialsNotificationSchema
Expand All @@ -386,7 +386,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 +401,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 +416,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.CONFIG_UPDATE_ALL]
},
validate: {
payload: userPasswordResetNotificationSchema
Expand Down Expand Up @@ -454,7 +454,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