From f47550d23e34f97ea8a18ad175f89c78066a0ca8 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 16 Dec 2014 15:09:15 -0500 Subject: [PATCH] closes #2533 --- src/socket.io/posts.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index d6bb4b8c53..a7002df2e9 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -371,16 +371,24 @@ SocketPosts.flag = function(socket, pid, callback) { return next(new Error('[[error:post-deleted]]')); } post = postData; - topics.getTopicField(postData.tid, 'title', next); + topics.getTopicFields(postData.tid, ['title', 'cid'], next); }, - function(topicTitle, next) { - message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topicTitle + ']]'; + function(topic, next) { + post.topic = topic; + message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topic.title + ']]'; postTools.parsePost(post, socket.uid, next); }, function(post, next) { - groups.get('administrators', {}, next); + async.parallel({ + admins: function(next) { + groups.getMembers('administrators', next); + }, + moderators: function(next) { + groups.getMembers('cid:' + post.topic.cid + ':privileges:mods', next); + } + }, next); }, - function(adminGroup, next) { + function(results, next) { notifications.create({ bodyShort: message, bodyLong: post.content, @@ -391,7 +399,7 @@ SocketPosts.flag = function(socket, pid, callback) { if (err || !notification) { return next(err); } - notifications.push(notification, adminGroup.members, next); + notifications.push(notification, results.admins.concat(results.moderators), next); }); }, function(next) {