From 87f0d68ba2307bb938101ad764dcba85b9920062 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 3 Feb 2016 20:58:26 +0200 Subject: [PATCH] send flag notifications to global mods as well push notifications to unique uids only --- src/notifications.js | 4 ++-- src/socket.io/posts/flag.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/notifications.js b/src/notifications.js index 191eaf9e09..cb68e347ff 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -120,8 +120,8 @@ var async = require('async'), uids = [uids]; } - uids = uids.filter(function(uid) { - return parseInt(uid, 10); + uids = uids.filter(function(uid, index, array) { + return parseInt(uid, 10) && array.indexOf(uid) === index; }); if (!uids.length) { diff --git a/src/socket.io/posts/flag.js b/src/socket.io/posts/flag.js index 4bb09470bf..f5febe9ea7 100644 --- a/src/socket.io/posts/flag.js +++ b/src/socket.io/posts/flag.js @@ -73,6 +73,9 @@ module.exports = function(SocketPosts) { admins: function(next) { groups.getMembers('administrators', 0, -1, next); }, + globalMods: function (next) { + groups.getMembers('Global Moderators', 0, -1, next); + }, moderators: function(next) { groups.getMembers('cid:' + post.topic.cid + ':privileges:mods', 0, -1, next); } @@ -93,7 +96,7 @@ module.exports = function(SocketPosts) { } plugins.fireHook('action:post.flag', {post: post, flaggingUser: flaggingUser}); - notifications.push(notification, results.admins.concat(results.moderators), next); + notifications.push(notification, results.admins.concat(results.moderators).concat(results.globalMods), next); }); } ], callback);