fix(api): 🐛 Properly await notification result

This commit is contained in:
Jesse Wierzbinski 2025-01-02 04:27:52 +01:00
parent cde2836982
commit bedc25bacf
No known key found for this signature in database

View file

@ -18,6 +18,10 @@ export const getPushWorker = (): Worker<PushJobData, void, PushJobType> =>
data: { psId, relatedUserId, type, noteId, notificationId }, data: { psId, relatedUserId, type, noteId, notificationId },
} = job; } = job;
await job.log(
`Sending push notification for note [${notificationId}]`,
);
const ps = await PushSubscription.fromId(psId); const ps = await PushSubscription.fromId(psId);
if (!ps) { if (!ps) {
@ -87,7 +91,7 @@ export const getPushWorker = (): Worker<PushJobData, void, PushJobType> =>
? htmlToText(note.data.spoilerText || note.data.content) ? htmlToText(note.data.spoilerText || note.data.content)
: htmlToText(relatedUser.data.note); : htmlToText(relatedUser.data.note);
sendNotification( await sendNotification(
{ {
endpoint: ps.data.endpoint, endpoint: ps.data.endpoint,
keys: { keys: {
@ -115,6 +119,10 @@ export const getPushWorker = (): Worker<PushJobData, void, PushJobType> =>
}, },
}, },
); );
await job.log(
`✔ Finished delivering push notification for note [${notificationId}]`,
);
}, },
{ {
connection, connection,