mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closes #1630
This commit is contained in:
@@ -105,6 +105,9 @@ function sendNotificationToPostOwner(data, uid, notification) {
|
||||
},
|
||||
slug: function(next) {
|
||||
topics.getTopicField(postData.tid, 'slug', next);
|
||||
},
|
||||
index: function(next) {
|
||||
posts.getPidIndex(data.pid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
@@ -113,7 +116,7 @@ function sendNotificationToPostOwner(data, uid, notification) {
|
||||
|
||||
notifications.create({
|
||||
text: '[[' + notification + ', ' + results.username + ']]',
|
||||
path: nconf.get('relative_path') + '/topic/' + results.slug + '#' + data.pid,
|
||||
path: nconf.get('relative_path') + '/topic/' + results.slug + '/' + results.index,
|
||||
uniqueId: 'post:' + data.pid,
|
||||
from: uid
|
||||
}, function(nid) {
|
||||
@@ -277,7 +280,11 @@ SocketPosts.flag = function(socket, pid, callback) {
|
||||
topics.getTopicField(postData.tid, 'slug', next);
|
||||
},
|
||||
function(topicSlug, next) {
|
||||
path = nconf.get('relative_path') + '/topic/' + topicSlug + '#' + pid;
|
||||
path = nconf.get('relative_path') + '/topic/' + topicSlug;
|
||||
posts.getPidIndex(pid, next);
|
||||
},
|
||||
function(postIndex, next) {
|
||||
path += '/' + postIndex;
|
||||
groups.get('administrators', {}, next);
|
||||
},
|
||||
function(adminGroup, next) {
|
||||
|
||||
@@ -6,6 +6,7 @@ var async = require('async'),
|
||||
|
||||
db = require('../database'),
|
||||
user = require('../user'),
|
||||
posts = require('../posts'),
|
||||
notifications = require('../notifications');
|
||||
|
||||
module.exports = function(Topics) {
|
||||
@@ -22,26 +23,30 @@ module.exports = function(Topics) {
|
||||
Topics.notifyFollowers = function(tid, pid, exceptUid) {
|
||||
async.parallel({
|
||||
nid: function(next) {
|
||||
Topics.getTopicFields(tid, ['title', 'slug'], function(err, topicData) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
async.parallel({
|
||||
topicData: function(next) {
|
||||
Topics.getTopicFields(tid, ['title', 'slug'], next);
|
||||
},
|
||||
username: function(next) {
|
||||
user.getUserField(exceptUid, 'username', next);
|
||||
},
|
||||
postIndex: function(next) {
|
||||
posts.getPidIndex(pid, next);
|
||||
}
|
||||
|
||||
user.getUserField(exceptUid, 'username', function(err, username) {
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
notifications.create({
|
||||
text: '[[notifications:user_posted_to, ' + username + ', ' + topicData.title + ']]',
|
||||
path: nconf.get('relative_path') + '/topic/' + topicData.slug + '#' + pid,
|
||||
text: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
|
||||
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.postIndex,
|
||||
uniqueId: 'topic:' + tid,
|
||||
from: exceptUid
|
||||
}, function(nid) {
|
||||
next(null, nid);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
followers: function(next) {
|
||||
Topics.getFollowers(tid, next);
|
||||
|
||||
@@ -9,6 +9,7 @@ var async = require('async'),
|
||||
utils = require('../../public/src/utils'),
|
||||
db = require('../database'),
|
||||
notifications = require('../notifications'),
|
||||
posts = require('../posts'),
|
||||
topics = require('../topics');
|
||||
|
||||
(function(UserNotifications) {
|
||||
@@ -146,23 +147,37 @@ var async = require('async'),
|
||||
};
|
||||
|
||||
UserNotifications.sendPostNotificationToFollowers = function(uid, tid, pid) {
|
||||
user.getUserField(uid, 'username', function(err, username) {
|
||||
db.getSetMembers('followers:' + uid, function(err, followers) {
|
||||
if (followers && followers.length) {
|
||||
topics.getTopicField(tid, 'slug', function(err, slug) {
|
||||
var message = '[[notifications:user_made_post, ' + username + ']]';
|
||||
if (err || !followers || !followers.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
usename: function(next) {
|
||||
user.getUserField(uid, 'username', next);
|
||||
},
|
||||
slug: function(next) {
|
||||
topics.getTopicField(tid, 'slug', next);
|
||||
},
|
||||
postIndex: function(next) {
|
||||
posts.getPidIndex(pid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
var message = '[[notifications:user_made_post, ' + results.username + ']]';
|
||||
|
||||
notifications.create({
|
||||
text: message,
|
||||
path: nconf.get('relative_path') + '/topic/' + slug + '#' + pid,
|
||||
path: nconf.get('relative_path') + '/topic/' + results.slug + '/' + results.postIndex,
|
||||
uniqueId: 'topic:' + tid,
|
||||
from: uid
|
||||
}, function(nid) {
|
||||
notifications.push(nid, followers);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user