Files
starr-philproperties/data/notifications.data.js
T
kennethobsequio 82ea9c77c4 merged
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
2026-07-11 12:12:29 +08:00

84 lines
3.4 KiB
JavaScript

/***********************************************************************************************************************************************************************
* File Name: notifications.data.js
* Type of Program: Data
* Description: Registry of notification types that have no fixed, admin-
* editable wording — content is entirely supplied by the caller
* at trigger time, so there's nothing to template.
*
* Every other system-triggered notification type (task overdue,
* welcome, tier expired, etc.) has been moved to the
* notification_templates table — admin-editable, {{placeholder}}-
* based, rendered via services/notificationTemplate.service.js's
* renderNotification()/renderNotificationContent(). See
* controllers/admin/notification_templates.controller.js.
*
* Each entry here describes one notification type:
* type {string} — stored in the DB 'type' column
* scope {string} — 'admin' | 'user' | 'both'
* trigger {string} — what fires it (event | manual)
* build {function} — takes a data payload, returns the object
* ready to pass to AdminNotification.create()
* or UserNotification.create() / bulkCreate()
*
* Current types:
* User : achievement, announcement
* Both : broadcast (admin-composed, sent via notification_broadcasts CRUD)
*
* Author: Kenneth Obsequio (@lash0000)
* Date Created: Jun. 19, 2026
* Date Modified: Jul. 3, 2026 — fixed-wording types moved into notification_templates
***********************************************************************************************************************************************************************/
'use strict';
const NOTIFICATION_REGISTRY = {
// ── Achievement — title/message come from the achievement definition itself ─
achievement: {
type: 'achievement',
scope: 'user',
trigger: 'event',
build({ label, description, key }) {
return {
type: 'achievement',
title: label,
message: description,
data: { key },
};
},
},
// ── Platform — title/body typed fresh by whoever calls this ─────────────────
announcement: {
type: 'announcement',
scope: 'user',
trigger: 'manual',
build({ title, body }) {
return {
type: 'announcement',
title,
message: body,
data: {},
};
},
},
// ── Broadcast (admin-composed, manual) — title/message typed per-send via
// the notification_broadcasts CRUD, not a fixed template ─────────────────
broadcast: {
type: 'announcement',
scope: 'both',
trigger: 'manual',
build({ title, message, targetType = null, targetId = null, groupId = null, linkUrl = null }) {
return {
type: 'announcement',
title,
message,
data: { targetType, targetId, groupId, linkUrl },
};
},
},
};
module.exports = { NOTIFICATION_REGISTRY };