mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-07 05:03:10 +02:00
send notification to all followers when a user makes a post
This commit is contained in:
@@ -284,6 +284,8 @@ marked.setOptions({
|
||||
user.incrementUserFieldBy(uid, 'postcount', 1);
|
||||
user.setUserField(uid, 'lastposttime', timestamp);
|
||||
|
||||
user.sendPostNotificationToFollowers(uid, tid, pid);
|
||||
|
||||
if (callback)
|
||||
callback(pid);
|
||||
});
|
||||
|
||||
12
src/user.js
12
src/user.js
@@ -462,6 +462,18 @@ var utils = require('./../public/src/utils.js'),
|
||||
}
|
||||
}
|
||||
|
||||
User.sendPostNotificationToFollowers = function(uid, tid, pid) {
|
||||
|
||||
User.getUserField(uid, 'username', function(username) {
|
||||
User.getFollowers(uid, function(followers) {
|
||||
var message = username + ' made a new post';
|
||||
notifications.create(message, 5, 'topic/' + tid + '/' + pid, 'notification_'+new Date().getTime(), function(nid) {
|
||||
notifications.push(nid, followers);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
User.isFollowing = function(uid, theirid, callback) {
|
||||
RDB.sismember('user:'+uid+':following', theirid, function(err, data) {
|
||||
|
||||
@@ -286,7 +286,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
userSockets[touid][x].emit('chatMessage', {fromuid:uid, username:username, message:finalMessage});
|
||||
}
|
||||
|
||||
notifications.create(finalMessage, 5, null, 'notification_'+new Date().getTime(), function(nid) {
|
||||
notifications.create(finalMessage, 5, '', 'notification_'+new Date().getTime(), function(nid) {
|
||||
notifications.push(nid, [touid], function(success) {
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user