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
@@ -31,6 +31,7 @@ const notDeleted = { deletedAt: null };
async function applyBroadcastFields(broadcast, body) {
if (body.title !== undefined) broadcast.title = body.title;
if (body.message !== undefined) broadcast.message = body.message;
if (body.link_url !== undefined) broadcast.link_url = body.link_url?.trim() || null;
if (body.show_in_sticky !== undefined) broadcast.show_in_sticky = !!body.show_in_sticky;
if (body.show_in_notifications !== undefined) broadcast.show_in_notifications = !!body.show_in_notifications;
@@ -159,6 +160,7 @@ exports.createBroadcast = async (req, res) => {
const {
title,
message,
link_url,
target_type,
target_id,
createdBy,
@@ -186,6 +188,7 @@ exports.createBroadcast = async (req, res) => {
const broadcast = await NotificationBroadcast.build({
title,
message,
link_url: link_url?.trim() || null,
createdBy,
status: 'draft',
target_type,
@@ -272,6 +275,7 @@ exports.sendBroadcast = async (req, res) => {
message: broadcast.message,
targetType,
targetId,
linkUrl: broadcast.link_url,
});
if (targetType === 'admin' || targetType === 'both') {
@@ -308,6 +312,7 @@ exports.sendBroadcast = async (req, res) => {
? NOTIFICATION_REGISTRY.broadcast.build({
title: broadcast.title, message: broadcast.message, targetType, targetId,
groupId: groupByUser[user_id] ?? null,
linkUrl: broadcast.link_url,
})
: baseNotify),
seen: false,