mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
Merge branch 'master' into develop
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
var helpers = require('./helpers');
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
|
||||
SocketPosts.bookmark = function (socket, data, callback) {
|
||||
helpers.postCommand(socket, 'bookmark', 'bookmarked', '', data, callback);
|
||||
};
|
||||
@@ -12,5 +11,4 @@ module.exports = function (SocketPosts) {
|
||||
SocketPosts.unbookmark = function (socket, data, callback) {
|
||||
helpers.postCommand(socket, 'unbookmark', 'bookmarked', '', data, callback);
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -11,7 +11,6 @@ var meta = require('../../meta');
|
||||
var websockets = require('../index');
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
|
||||
SocketPosts.edit = function (socket, data, callback) {
|
||||
if (!socket.uid) {
|
||||
return callback(new Error('[[error:not-logged-in]]'));
|
||||
@@ -47,11 +46,11 @@ module.exports = function (SocketPosts) {
|
||||
uid: socket.uid,
|
||||
ip: socket.ip,
|
||||
oldTitle: validator.escape(String(result.topic.oldTitle)),
|
||||
newTitle: validator.escape(String(result.topic.title))
|
||||
newTitle: validator.escape(String(result.topic.title)),
|
||||
});
|
||||
}
|
||||
|
||||
if (parseInt(result.post.deleted) !== 1) {
|
||||
if (parseInt(result.post.deleted, 10) !== 1) {
|
||||
websockets.in('topic_' + result.topic.tid).emit('event:post_edited', result);
|
||||
return callback(null, result.post);
|
||||
}
|
||||
@@ -60,7 +59,7 @@ module.exports = function (SocketPosts) {
|
||||
'administrators',
|
||||
'Global Moderators',
|
||||
'cid:' + result.topic.cid + ':privileges:mods',
|
||||
'cid:' + result.topic.cid + ':privileges:groups:moderate'
|
||||
'cid:' + result.topic.cid + ':privileges:groups:moderate',
|
||||
], next);
|
||||
},
|
||||
function (results, next) {
|
||||
@@ -69,7 +68,7 @@ module.exports = function (SocketPosts) {
|
||||
websockets.in('uid_' + uid).emit('event:post_edited', editResult);
|
||||
});
|
||||
next(null, editResult.post);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ helpers.postCommand = function (socket, command, eventName, notification, data,
|
||||
},
|
||||
deleted: function (next) {
|
||||
posts.getPostField(data.pid, 'deleted', next);
|
||||
}
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
@@ -46,11 +46,11 @@ helpers.postCommand = function (socket, command, eventName, notification, data,
|
||||
filter:post.bookmark
|
||||
filter:post.unbookmark
|
||||
*/
|
||||
plugins.fireHook('filter:post.' + command, {data: data, uid: socket.uid}, next);
|
||||
plugins.fireHook('filter:post.' + command, { data: data, uid: socket.uid }, next);
|
||||
},
|
||||
function (filteredData, next) {
|
||||
executeCommand(socket, command, eventName, notification, filteredData.data, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -71,6 +71,6 @@ function executeCommand(socket, command, eventName, notification, data, callback
|
||||
socketHelpers.rescindUpvoteNotification(data.pid, socket.uid);
|
||||
}
|
||||
next(null, result);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ var topics = require('../../topics');
|
||||
var socketHelpers = require('../helpers');
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
|
||||
SocketPosts.movePost = function (socket, data, callback) {
|
||||
if (!socket.uid) {
|
||||
return callback(new Error('[[error:not-logged-in]]'));
|
||||
@@ -30,8 +29,7 @@ module.exports = function (SocketPosts) {
|
||||
function (next) {
|
||||
socketHelpers.sendNotificationToPostOwner(data.pid, socket.uid, 'move', 'notifications:moved_your_post');
|
||||
next();
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -13,7 +13,6 @@ var plugins = require('../../plugins');
|
||||
var social = require('../../social');
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
|
||||
SocketPosts.loadPostTools = function (socket, data, callback) {
|
||||
if (!data || !data.pid || !data.cid) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
@@ -37,11 +36,11 @@ module.exports = function (SocketPosts) {
|
||||
posts.hasBookmarked(data.pid, socket.uid, next);
|
||||
},
|
||||
tools: function (next) {
|
||||
plugins.fireHook('filter:post.tools', {pid: data.pid, uid: socket.uid, tools: []}, next);
|
||||
plugins.fireHook('filter:post.tools', { pid: data.pid, uid: socket.uid, tools: [] }, next);
|
||||
},
|
||||
postSharing: function (next) {
|
||||
social.getActivePostSharing(next);
|
||||
}
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
@@ -54,7 +53,7 @@ module.exports = function (SocketPosts) {
|
||||
results.posts.display_moderator_tools = results.posts.display_edit_tools || results.posts.display_delete_tools;
|
||||
results.posts.display_move_tools = results.isAdminOrMod;
|
||||
next(null, results);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -85,11 +84,11 @@ module.exports = function (SocketPosts) {
|
||||
type: 'post-delete',
|
||||
uid: socket.uid,
|
||||
pid: data.pid,
|
||||
ip: socket.ip
|
||||
ip: socket.ip,
|
||||
});
|
||||
|
||||
next();
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -103,18 +102,17 @@ module.exports = function (SocketPosts) {
|
||||
posts.tools.restore(socket.uid, data.pid, next);
|
||||
},
|
||||
function (postData, next) {
|
||||
|
||||
websockets.in('topic_' + data.tid).emit('event:post_restored', postData);
|
||||
|
||||
events.log({
|
||||
type: 'post-restore',
|
||||
uid: socket.uid,
|
||||
pid: data.pid,
|
||||
ip: socket.ip
|
||||
ip: socket.ip,
|
||||
});
|
||||
|
||||
setImmediate(next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -123,7 +121,7 @@ module.exports = function (SocketPosts) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
async.eachSeries(data.pids, function (pid, next) {
|
||||
SocketPosts.delete(socket, {pid: pid, tid: data.tid}, next);
|
||||
SocketPosts.delete(socket, { pid: pid, tid: data.tid }, next);
|
||||
}, callback);
|
||||
};
|
||||
|
||||
@@ -132,7 +130,7 @@ module.exports = function (SocketPosts) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
async.eachSeries(data.pids, function (pid, next) {
|
||||
SocketPosts.purge(socket, {pid: pid, tid: data.tid}, next);
|
||||
SocketPosts.purge(socket, { pid: pid, tid: data.tid }, next);
|
||||
}, callback);
|
||||
};
|
||||
|
||||
@@ -158,7 +156,7 @@ module.exports = function (SocketPosts) {
|
||||
posts.getPostField(data.pid, 'toPid', next);
|
||||
},
|
||||
function (toPid, next) {
|
||||
postData = {pid: data.pid, toPid: toPid};
|
||||
postData = { pid: data.pid, toPid: toPid };
|
||||
posts.tools.purge(socket.uid, data.pid, next);
|
||||
},
|
||||
function (next) {
|
||||
@@ -171,9 +169,9 @@ module.exports = function (SocketPosts) {
|
||||
uid: socket.uid,
|
||||
pid: data.pid,
|
||||
ip: socket.ip,
|
||||
title: validator.escape(String(title))
|
||||
title: validator.escape(String(title)),
|
||||
}, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -183,8 +181,8 @@ module.exports = function (SocketPosts) {
|
||||
posts.getTopicFields(pid, ['tid', 'cid'], next);
|
||||
},
|
||||
function (topic, next) {
|
||||
socketTopics.doTopicAction('delete', 'event:topic_deleted', socket, {tids: [topic.tid], cid: topic.cid}, next);
|
||||
}
|
||||
socketTopics.doTopicAction('delete', 'event:topic_deleted', socket, { tids: [topic.tid], cid: topic.cid }, next);
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
|
||||
@@ -197,8 +195,7 @@ module.exports = function (SocketPosts) {
|
||||
posts.getTopicFields(pid, ['postcount'], function (err, topic) {
|
||||
next(err, topic ? parseInt(topic.postcount, 10) === 1 : false);
|
||||
});
|
||||
}
|
||||
},
|
||||
}, callback);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -9,7 +9,6 @@ var privileges = require('../../privileges');
|
||||
var helpers = require('./helpers');
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
|
||||
SocketPosts.getVoters = function (socket, data, callback) {
|
||||
if (!data || !data.pid || !data.cid) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
@@ -30,7 +29,7 @@ module.exports = function (SocketPosts) {
|
||||
},
|
||||
downvoteUids: function (next) {
|
||||
db.getSetMembers('pid:' + data.pid + ':downvote', next);
|
||||
}
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
@@ -46,9 +45,9 @@ module.exports = function (SocketPosts) {
|
||||
},
|
||||
downvoteCount: function (next) {
|
||||
next(null, results.downvoteUids.length);
|
||||
}
|
||||
},
|
||||
}, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -62,7 +61,7 @@ module.exports = function (SocketPosts) {
|
||||
return callback(err, []);
|
||||
}
|
||||
|
||||
async.map(data, function (uids, next) {
|
||||
async.map(data, function (uids, next) {
|
||||
var otherCount = 0;
|
||||
if (uids.length > 6) {
|
||||
otherCount = uids.length - 5;
|
||||
@@ -71,7 +70,7 @@ module.exports = function (SocketPosts) {
|
||||
user.getUsernamesByUids(uids, function (err, usernames) {
|
||||
next(err, {
|
||||
otherCount: otherCount,
|
||||
usernames: usernames
|
||||
usernames: usernames,
|
||||
});
|
||||
});
|
||||
}, callback);
|
||||
@@ -89,4 +88,4 @@ module.exports = function (SocketPosts) {
|
||||
SocketPosts.unvote = function (socket, data, callback) {
|
||||
helpers.postCommand(socket, 'unvote', 'voted', '', data, callback);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user