Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-11 12:12:29 +08:00
parent e1ffdab190
commit 82ea9c77c4
19 changed files with 530 additions and 122 deletions
+23 -1
View File
@@ -4,6 +4,7 @@
* Description : Admin notification management.
* GET /admin/notifications — paginated list, newest first
* GET /admin/notifications/unseen — unseen count only
* GET /admin/notifications/sticky — current sticky announcement, if any
* PATCH /admin/notifications/:id/seen — mark one as seen
* PATCH /admin/notifications/seen-all — mark all as seen
*
@@ -48,6 +49,27 @@ async function unseenCount(req, res) {
}
}
// ─── GET /admin/notifications/sticky ──────────────────────────────────────────
// Not user-scoped, same as list()/unseenCount() above — one shared sticky
// banner for every admin. Whoever dismisses it first dismisses it for all.
async function stickyAnnouncement(req, res) {
try {
const notification = await AdminNotification.findOne({
where: {
seen: false,
show_in_sticky: true,
type: 'announcement',
},
order: [['createdAt', 'DESC']],
});
return R.success(res, 'Sticky announcement fetched.', { announcement: notification });
} catch (err) {
console.error('[NOTIFICATION] stickyAnnouncement error:', err);
return R.error(res, 'Failed to fetch sticky announcement.');
}
}
// ─── PATCH /admin/notifications/:id/seen ─────────────────────────────────────
async function markSeen(req, res) {
try {
@@ -77,4 +99,4 @@ async function markAllSeen(req, res) {
}
}
module.exports = { list, unseenCount, markSeen, markAllSeen };
module.exports = { list, unseenCount, stickyAnnouncement, markSeen, markAllSeen };