fix: catch exceptions from sendNotifications

isekai-main
Barış Soner Uşaklı 3 years ago
parent d7796f0b73
commit c1ec20470b

@ -1,5 +1,7 @@
'use strict'; 'use strict';
const winston = require('winston');
const user = require('../user'); const user = require('../user');
const notifications = require('../notifications'); const notifications = require('../notifications');
const sockets = require('../socket.io'); const sockets = require('../socket.io');
@ -45,8 +47,12 @@ module.exports = function (Messaging) {
Messaging.notifyQueue[`${fromUid}:${roomId}`] = queueObj; Messaging.notifyQueue[`${fromUid}:${roomId}`] = queueObj;
} }
queueObj.timeout = setTimeout(() => { queueObj.timeout = setTimeout(async () => {
sendNotifications(fromUid, uids, roomId, queueObj.message); try {
await sendNotifications(fromUid, uids, roomId, queueObj.message);
} catch (err) {
winston.error(`[messaging/notifications] Unabled to send notification\n${err.stack}`);
}
}, meta.config.notificationSendDelay * 1000); }, meta.config.notificationSendDelay * 1000);
}; };

Loading…
Cancel
Save