This commit is contained in:
2026-03-27 16:15:33 -04:00
parent eea7cb91e7
commit 2b2b184f04

View File

@@ -122,11 +122,15 @@ async function sendPushToUser(schema, userId, payload) {
keys: { p256dh: sub.webpush_p256dh, auth: sub.webpush_auth }, keys: { p256dh: sub.webpush_p256dh, auth: sub.webpush_auth },
}; };
const body = JSON.stringify({ const body = JSON.stringify({
title: payload.title || 'New Message', notification: {
body: payload.body || '', title: payload.title || 'New Message',
url: payload.url || '/', body: payload.body || '',
groupId: payload.groupId ? String(payload.groupId) : '', },
icon: '/icons/icon-192.png', data: {
url: payload.url || '/',
groupId: payload.groupId ? String(payload.groupId) : '',
icon: '/icons/icon-192.png',
},
}); });
try { try {
await wp.sendNotification(subscription, body, { TTL: 86400, urgency: 'high' }); await wp.sendNotification(subscription, body, { TTL: 86400, urgency: 'high' });
@@ -287,7 +291,10 @@ router.post('/test', authMiddleware, async (req, res) => {
try { try {
await wp.sendNotification( await wp.sendNotification(
subscription, subscription,
JSON.stringify({ title: 'RosterChirp Test', body: 'Push notifications are working!', url: '/', icon: '/icons/icon-192.png' }), JSON.stringify({
notification: { title: 'RosterChirp Test', body: 'Push notifications are working!' },
data: { url: '/', icon: '/icons/icon-192.png' },
}),
{ TTL: 300, urgency: 'high' } { TTL: 300, urgency: 'high' }
); );
results.push({ device: sub.device, type: 'webpush', status: 'sent' }); results.push({ device: sub.device, type: 'webpush', status: 'sent' });