mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
style changes
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
var async = require('async');
|
var async = require('async');
|
||||||
var winston = require('winston');
|
var winston = require('winston');
|
||||||
var S = require('string');
|
var S = require('string');
|
||||||
var nconf = require('nconf');
|
|
||||||
|
|
||||||
var websockets = require('./index');
|
var websockets = require('./index');
|
||||||
var user = require('../user');
|
var user = require('../user');
|
||||||
@@ -53,24 +52,24 @@ SocketHelpers.sendNotificationToPostOwner = function(pid, fromuid, notification)
|
|||||||
if (!pid || !fromuid || !notification) {
|
if (!pid || !fromuid || !notification) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
posts.getPostFields(pid, ['tid', 'uid', 'content'], function(err, postData) {
|
fromuid = parseInt(fromuid, 10);
|
||||||
if (err) {
|
var postData;
|
||||||
return;
|
async.waterfall([
|
||||||
}
|
function (next) {
|
||||||
|
posts.getPostFields(pid, ['tid', 'uid', 'content'], next);
|
||||||
|
},
|
||||||
|
function (_postData, next) {
|
||||||
|
postData = _postData;
|
||||||
if (!postData.uid || fromuid === parseInt(postData.uid, 10)) {
|
if (!postData.uid || fromuid === parseInt(postData.uid, 10)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
username: async.apply(user.getUserField, fromuid, 'username'),
|
username: async.apply(user.getUserField, fromuid, 'username'),
|
||||||
topicTitle: async.apply(topics.getTopicField, postData.tid, 'title'),
|
topicTitle: async.apply(topics.getTopicField, postData.tid, 'title'),
|
||||||
postObj: async.apply(posts.parsePost, postData)
|
postObj: async.apply(posts.parsePost, postData)
|
||||||
}, function(err, results) {
|
}, next);
|
||||||
if (err) {
|
},
|
||||||
return;
|
function (results, next) {
|
||||||
}
|
|
||||||
|
|
||||||
var title = S(results.topicTitle).decodeHTMLEntities().s;
|
var title = S(results.topicTitle).decodeHTMLEntities().s;
|
||||||
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
||||||
|
|
||||||
@@ -83,13 +82,16 @@ SocketHelpers.sendNotificationToPostOwner = function(pid, fromuid, notification)
|
|||||||
from: fromuid,
|
from: fromuid,
|
||||||
mergeId: notification + '|' + pid,
|
mergeId: notification + '|' + pid,
|
||||||
topicTitle: results.topicTitle
|
topicTitle: results.topicTitle
|
||||||
}, function(err, notification) {
|
}, next);
|
||||||
if (!err && notification) {
|
}
|
||||||
|
], function(err, notification) {
|
||||||
|
if (err) {
|
||||||
|
return winston.error(err);
|
||||||
|
}
|
||||||
|
if (notification) {
|
||||||
notifications.push(notification, [postData.uid]);
|
notifications.push(notification, [postData.uid]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -98,14 +100,21 @@ SocketHelpers.sendNotificationToTopicOwner = function(tid, fromuid, notification
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fromuid = parseInt(fromuid, 10);
|
||||||
|
|
||||||
|
var ownerUid;
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
username: async.apply(user.getUserField, fromuid, 'username'),
|
username: async.apply(user.getUserField, fromuid, 'username'),
|
||||||
topicData: async.apply(topics.getTopicFields, tid, ['uid', 'slug', 'title']),
|
topicData: async.apply(topics.getTopicFields, tid, ['uid', 'slug', 'title']),
|
||||||
}, function(err, results) {
|
}, next);
|
||||||
if (err || fromuid === parseInt(results.topicData.uid, 10)) {
|
},
|
||||||
|
function (results, next) {
|
||||||
|
if (fromuid === parseInt(results.topicData.uid, 10)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ownerUid = results.topicData.uid;
|
||||||
var title = S(results.topicData.title).decodeHTMLEntities().s;
|
var title = S(results.topicData.title).decodeHTMLEntities().s;
|
||||||
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
||||||
|
|
||||||
@@ -114,11 +123,15 @@ SocketHelpers.sendNotificationToTopicOwner = function(tid, fromuid, notification
|
|||||||
path: '/topic/' + results.topicData.slug,
|
path: '/topic/' + results.topicData.slug,
|
||||||
nid: 'tid:' + tid + ':uid:' + fromuid,
|
nid: 'tid:' + tid + ':uid:' + fromuid,
|
||||||
from: fromuid
|
from: fromuid
|
||||||
}, function(err, notification) {
|
}, next);
|
||||||
if (!err && notification) {
|
}
|
||||||
notifications.push(notification, [results.topicData.uid]);
|
], function(err, notification) {
|
||||||
|
if (err) {
|
||||||
|
return winston.error(err);
|
||||||
|
}
|
||||||
|
if (notification && parseInt(ownerUid, 10)) {
|
||||||
|
notifications.push(notification, [ownerUid]);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -200,13 +200,20 @@ var privileges = require('../privileges');
|
|||||||
};
|
};
|
||||||
|
|
||||||
UserNotifications.sendTopicNotificationToFollowers = function(uid, topicData, postData) {
|
UserNotifications.sendTopicNotificationToFollowers = function(uid, topicData, postData) {
|
||||||
db.getSortedSetRange('followers:' + uid, 0, -1, function(err, followers) {
|
var followers;
|
||||||
if (err || !Array.isArray(followers) || !followers.length) {
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
db.getSortedSetRange('followers:' + uid, 0, -1, next);
|
||||||
|
},
|
||||||
|
function (followers, next) {
|
||||||
|
if (!Array.isArray(followers) || !followers.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
privileges.categories.filterUids('read', topicData.cid, followers, next);
|
||||||
privileges.categories.filterUids('read', topicData.cid, followers, function(err, followers) {
|
},
|
||||||
if (err || !followers.length) {
|
function (_followers, next) {
|
||||||
|
followers = _followers;
|
||||||
|
if (!followers.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,13 +230,17 @@ var privileges = require('../privileges');
|
|||||||
nid: 'tid:' + postData.tid + ':uid:' + uid,
|
nid: 'tid:' + postData.tid + ':uid:' + uid,
|
||||||
tid: postData.tid,
|
tid: postData.tid,
|
||||||
from: uid
|
from: uid
|
||||||
}, function(err, notification) {
|
}, next);
|
||||||
if (!err && notification) {
|
}
|
||||||
|
], function(err, notification) {
|
||||||
|
if (err) {
|
||||||
|
return winston.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notification) {
|
||||||
notifications.push(notification, followers);
|
notifications.push(notification, followers);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
UserNotifications.sendWelcomeNotification = function(uid, callback) {
|
UserNotifications.sendWelcomeNotification = function(uid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user