Skip to content

Node.js based forum software built for the modern web

closes #1989

barisusaklie909e46786c8
diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.json
index 5225cffbe6..5bb153ccbc 100644
--- a/public/language/en_GB/notifications.json
+++ b/public/language/en_GB/notifications.json
@@ -19,6 +19,7 @@
"user_flagged_post": "<strong>%1</strong> flagged a post.",
"user_posted_to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",
"user_mentioned_you_in": "<strong>%1</strong> mentioned you in <strong>%2</strong>",
+ "user_started_following_you": "<strong>%1</strong> started following you.",
"email-confirmed": "Email Confirmed",
"email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.",
diff --git a/src/socket.io/user.js b/src/socket.io/user.js
index 7501c9651b..b3c7bf71dc 100644
--- a/src/socket.io/user.js
+++ b/src/socket.io/user.js
@@ -1,11 +1,13 @@
'use strict';
var async = require('async'),
+ nconf = require('nconf'),
user = require('../user'),
groups = require('../groups'),
topics = require('../topics'),
+ notifications = require('../notifications'),
messaging = require('../messaging'),
- utils = require('./../../public/src/utils'),
+ utils = require('../../public/src/utils'),
meta = require('../meta'),
SocketUser = {};
@@ -159,7 +161,29 @@ SocketUser.changePicture = function(socket, data, callback) {
SocketUser.follow = function(socket, data, callback) {
if (socket.uid && data) {
- user.follow(socket.uid, data.uid, callback);
+ user.follow(socket.uid, data.uid, function(err) {
+ if (err) {
+ return callback(err);
+ }
+
+ user.getUserFields(socket.uid, ['username', 'userslug'], function(err, userData) {
+ if (err) {
+ return callback(err);
+ }
+
+ notifications.create({
+ bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',
+ path: nconf.get('relative_path') + '/user/' + userData.userslug,
+ uniqueId: 'follow:uid:' + socket.uid,
+ from: socket.uid
+ }, function(err, nid) {
+ if (!err) {
+ notifications.push(nid, [data.uid]);
+ }
+ callback(err);
+ });
+ });
+ });
}
};