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 },
};
const body = JSON.stringify({
notification: {
title: payload.title || 'New Message',
body: payload.body || '',
},
data: {
url: payload.url || '/',
groupId: payload.groupId ? String(payload.groupId) : '',
icon: '/icons/icon-192.png',
},
});
try {
await wp.sendNotification(subscription, body, { TTL: 86400, urgency: 'high' });
@@ -287,7 +291,10 @@ router.post('/test', authMiddleware, async (req, res) => {
try {
await wp.sendNotification(
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' }
);
results.push({ device: sub.device, type: 'webpush', status: 'sent' });