Node.js based forum software built for the modern web
refactor: when accepting/rejecting user register
Barış Soner Uşaklı8dc71a86f241
diff --git a/src/user/approval.js b/src/user/approval.jsindex b144ba2ec4..d1104656a2 100644--- a/src/user/approval.js+++ b/src/user/approval.js@@ -92,7 +92,7 @@ module.exports = function (User) {});}await removeFromQueue(username);- await markNotificationRead(username);+ await rescindNotification(username);await plugins.hooks.fire('filter:register.complete', { uid: uid });await emailer.send('registration_accepted', uid, {username: username,@@ -117,16 +117,15 @@ module.exports = function (User) {}}- async function markNotificationRead(username) {- const nid = `new-register:${username}`;+ async function rescindNotification(username) {+ await notifications.rescind(`new-register:${username}`);const uids = await groups.getMembers('administrators', 0, -1);- const promises = uids.map(uid => notifications.markRead(nid, uid));- await Promise.all(promises);+ uids.forEach(uid => User.notifications.pushCount(uid));}User.rejectRegistration = async function (username) {await removeFromQueue(username);- await markNotificationRead(username);+ await rescindNotification(username);};async function removeFromQueue(username) {diff --git a/src/user/notifications.js b/src/user/notifications.jsindex 15431eb26d..3d8d0f62b6 100644--- a/src/user/notifications.js+++ b/src/user/notifications.js@@ -269,7 +269,11 @@ UserNotifications.sendNameChangeNotification = async function (uid, username) {};UserNotifications.pushCount = async function (uid) {- const websockets = require('../socket.io');- const count = await UserNotifications.getUnreadCount(uid);- websockets.in(`uid_${uid}`).emit('event:notifications.updateCount', count);+ try {+ const websockets = require('../socket.io');+ const count = await UserNotifications.getUnreadCount(uid);+ websockets.in(`uid_${uid}`).emit('event:notifications.updateCount', count);+ } catch (err) {+ winston.error(err.stack);+ }};