post tests

This commit is contained in:
barisusakli
2017-02-23 17:02:54 +03:00
parent 4cd4414d19
commit 09d0ce4778
3 changed files with 165 additions and 19 deletions

View File

@@ -31,25 +31,26 @@ SocketPosts.reply = function (socket, data, callback) {
data.req = websockets.reqFromSocket(socket);
data.timestamp = Date.now();
topics.reply(data, function (err, postData) {
if (err) {
return callback(err);
async.waterfall([
function (next) {
topics.reply(data, next);
},
function (postData, next) {
var result = {
posts: [postData],
'reputation:disabled': parseInt(meta.config['reputation:disabled'], 10) === 1,
'downvote:disabled': parseInt(meta.config['downvote:disabled'], 10) === 1,
};
next(null, postData);
websockets.in('uid_' + socket.uid).emit('event:new_post', result);
user.updateOnlineUsers(socket.uid);
socketHelpers.notifyNew(socket.uid, 'newPost', result);
}
var result = {
posts: [postData],
'reputation:disabled': parseInt(meta.config['reputation:disabled'], 10) === 1,
'downvote:disabled': parseInt(meta.config['downvote:disabled'], 10) === 1,
};
callback(null, postData);
websockets.in('uid_' + socket.uid).emit('event:new_post', result);
user.updateOnlineUsers(socket.uid);
socketHelpers.notifyNew(socket.uid, 'newPost', result);
});
], callback);
};
SocketPosts.getRawPost = function (socket, pid, callback) {
@@ -120,7 +121,7 @@ SocketPosts.getPidIndex = function (socket, data, callback) {
SocketPosts.getReplies = function (socket, pid, callback) {
if (!utils.isNumber(pid)) {
return callback(new Error('[[error:invalid-data]'));
return callback(new Error('[[error:invalid-data]]'));
}
var postPrivileges;
async.waterfall([