send notification to all followers when a user makes a post

This commit is contained in:
Baris Usakli
2013-06-18 10:01:42 -04:00
parent 3b04e277cd
commit b7e2bfff3d
3 changed files with 15 additions and 1 deletions

View File

@@ -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) {