Sending a notification
The real scheme-of-work return, from the enum through emit, and the Hub link that does not exist for it.
This page follows one notification that is in the source: a scheme of work returned to its submitter. It is not a template you paste under a new name. NotificationType.ACADEMIC_REPORT_RETURNED is not a member of the enum at a5dff0c208d5193c274d3d1f87787b55344d5d30. The academic-report members that do exist are ACADEMIC_REPORT_RELEASED (academic_report.released) and ACADEMIC_REPORT_APPROVED (academic_report.approved). Neither of those has a case in the Hub link function either.
Read Channels for the full channel matrix and The inbox for how a saved row is listed.
Prerequisites
You are reading Naalya-API and Education-Hub at the SHAs in Sources. Nothing on this page was executed. A successful emit call is what the service is written to do. It is not a delivery receipt.
The type that exists
NotificationType.SCHEME_OF_WORK_RETURNED is 'scheme_of_work.returned'.
Its NotificationDataMap entry is:
{
campusId: string;
schemeOfWorkId: string;
title: string;
reason: string;
}NOTIFICATION_CHANNELS lists IN_APP and EMAIL for this type. It does not list WhatsApp.
CONTENT builds:
- title:
Your scheme of work was returned - body:
`${d.title} was returned: ${d.reason}`
EMAILS has an entry for the same type. The arrow calls approvalEmail. The subject line and template fields inside that helper were not copied.
Who is told
SchemeApprovalService in apps/server/src/app/lesson-planning/scheme-approval.service.ts emits after a return. The call that was read passes:
type: NotificationType.SCHEME_OF_WORK_RETURNEDschoolIdrecipientUserIds: [submitter.userId]actorUserId: returnerUserIddata.campusIdfromscheme.campusIddata.schemeOfWorkIdfromscheme.iddata.titlefromscheme.titledata.reasonfrom thereasonin scope
submitter.userId is a user id on that object, not a staff-profile id. What emit does with actorUserId was not re-read. The lines above the emit that decide to return early were not copied, so this page does not list every case in which the call is skipped.
What the reader should see
| Step | Where | Result the code names | If it does not happen |
|---|---|---|---|
| 1 | Enum and NotificationDataMap | The four fields above compile against CONTENT | A missing map entry fails the build, because CONTENT is a Record of every type |
| 2 | NOTIFICATION_CHANNELS | In-app and email | A missing key fails the build for the same reason |
| 3 | CONTENT | The title and body above | Same |
| 4 | EMAILS | Delegates to approvalEmail | EMAILS is not a Record of every type. A type with EMAIL and no builder was previously documented as NO_EMAIL_TEMPLATE. That failure path was not re-read this pass |
| 5 | emit in SchemeApprovalService | One recipient, the submitter’s user id | If this call is not reached, there is no row. The early-return conditions were not copied |
| 6 | Hub notificationLink | null | There is no case for SCHEME_OF_WORK_RETURNED or SCHEME_OF_WORK_APPROVED. The function’s default returns null |
Step 6 is the important one. The bell can still show the title and body from the saved row. The click target is not built. RECORD_OF_WORK_RETURNED is in-app only. Its title is Your record of work was returned and its body is `${d.title} was returned: ${d.reason}`. The Hub link is label Open record, route /staff-hub/campus/$campusId/schemes-of-work/records/$recordId, when campusId and recordOfWorkId are both non-empty strings. Missing either id returns null. returnRevision emits it after the revision is saved, to the submitter, and a failed notice does not undo the return. Who is skipped is on Where a notification opens.
ACADEMIC_REPORT_RELEASED and ACADEMIC_REPORT_APPROVED also fall through to null. Do not add a report route to this function by copying an older handbook sample. There is no such case to copy.
Adding another type
The files a new member has to touch are the ones this flow already uses: notification.types.ts (enum and NotificationDataMap), notification-channels.ts, notification-content.ts (CONTENT, and EMAILS when the channel list includes email), the service that calls emit, and src/lib/notifications/notification-link.ts when the bell should navigate. The type bus publish (task bus) was not re-run. Skip it and the Hub import of NotificationType will not know a member that exists only on the API.
Do not invent academic_report.returned. A report card return is a status on report_card (ReportStatus.RETURNED). It is documented on Reports. It is not this enum.
Sources
Naalya-API a5dff0c208d5193c274d3d1f87787b55344d5d30: libs/shared/src/notification/notification.types.ts, apps/server/src/app/notification/notification-channels.ts, notification-content.ts (SCHEME_OF_WORK_RETURNED and RECORD_OF_WORK_RETURNED builders), apps/server/src/app/lesson-planning/scheme-approval.service.ts (the emit object). Education-Hub d2d5fe3365d8fb858d18b9a29bc8a7e1b042f06d: src/lib/notifications/notification-link.ts. None of these functions were called.