v1.18.x
barisusakli 11 years ago
parent 0574022e02
commit e20920c536

@ -105,6 +105,9 @@ function sendNotificationToPostOwner(data, uid, notification) {
}, },
slug: function(next) { slug: function(next) {
topics.getTopicField(postData.tid, 'slug', next); topics.getTopicField(postData.tid, 'slug', next);
},
index: function(next) {
posts.getPidIndex(data.pid, next);
} }
}, function(err, results) { }, function(err, results) {
if (err) { if (err) {
@ -113,7 +116,7 @@ function sendNotificationToPostOwner(data, uid, notification) {
notifications.create({ notifications.create({
text: '[[' + notification + ', ' + results.username + ']]', 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, uniqueId: 'post:' + data.pid,
from: uid from: uid
}, function(nid) { }, function(nid) {
@ -277,7 +280,11 @@ SocketPosts.flag = function(socket, pid, callback) {
topics.getTopicField(postData.tid, 'slug', next); topics.getTopicField(postData.tid, 'slug', next);
}, },
function(topicSlug, 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); groups.get('administrators', {}, next);
}, },
function(adminGroup, next) { function(adminGroup, next) {

@ -6,6 +6,7 @@ var async = require('async'),
db = require('../database'), db = require('../database'),
user = require('../user'), user = require('../user'),
posts = require('../posts'),
notifications = require('../notifications'); notifications = require('../notifications');
module.exports = function(Topics) { module.exports = function(Topics) {
@ -22,24 +23,28 @@ module.exports = function(Topics) {
Topics.notifyFollowers = function(tid, pid, exceptUid) { Topics.notifyFollowers = function(tid, pid, exceptUid) {
async.parallel({ async.parallel({
nid: function(next) { nid: function(next) {
Topics.getTopicFields(tid, ['title', 'slug'], function(err, topicData) { async.parallel({
if(err) { topicData: function(next) {
Topics.getTopicFields(tid, ['title', 'slug'], next);
},
username: function(next) {
user.getUserField(exceptUid, 'username', next);
},
postIndex: function(next) {
posts.getPidIndex(pid, next);
}
}, function(err, results) {
if (err) {
return next(err); return next(err);
} }
user.getUserField(exceptUid, 'username', function(err, username) { notifications.create({
if(err) { text: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
return next(err); path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.postIndex,
} uniqueId: 'topic:' + tid,
from: exceptUid
notifications.create({ }, function(nid) {
text: '[[notifications:user_posted_to, ' + username + ', ' + topicData.title + ']]', next(null, nid);
path: nconf.get('relative_path') + '/topic/' + topicData.slug + '#' + pid,
uniqueId: 'topic:' + tid,
from: exceptUid
}, function(nid) {
next(null, nid);
});
}); });
}); });
}, },

@ -9,6 +9,7 @@ var async = require('async'),
utils = require('../../public/src/utils'), utils = require('../../public/src/utils'),
db = require('../database'), db = require('../database'),
notifications = require('../notifications'), notifications = require('../notifications'),
posts = require('../posts'),
topics = require('../topics'); topics = require('../topics');
(function(UserNotifications) { (function(UserNotifications) {
@ -146,22 +147,36 @@ var async = require('async'),
}; };
UserNotifications.sendPostNotificationToFollowers = function(uid, tid, pid) { UserNotifications.sendPostNotificationToFollowers = function(uid, tid, pid) {
user.getUserField(uid, 'username', function(err, username) { db.getSetMembers('followers:' + uid, function(err, followers) {
db.getSetMembers('followers:' + uid, function(err, followers) { if (err || !followers || !followers.length) {
if (followers && followers.length) { return;
topics.getTopicField(tid, 'slug', function(err, slug) { }
var message = '[[notifications:user_made_post, ' + username + ']]';
async.parallel({
notifications.create({ usename: function(next) {
text: message, user.getUserField(uid, 'username', next);
path: nconf.get('relative_path') + '/topic/' + slug + '#' + pid, },
uniqueId: 'topic:' + tid, slug: function(next) {
from: uid topics.getTopicField(tid, 'slug', next);
}, function(nid) { },
notifications.push(nid, followers); 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/' + results.slug + '/' + results.postIndex,
uniqueId: 'topic:' + tid,
from: uid
}, function(nid) {
notifications.push(nid, followers);
});
}); });
}); });
}; };

Loading…
Cancel
Save