bug fix
This commit is contained in:
@@ -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' });
|
||||||
|
|||||||
Reference in New Issue
Block a user