mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user