mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-12 15:41:01 +01:00
This commit is contained in:
@@ -16,6 +16,7 @@ require('./topics/move')(SocketTopics);
|
||||
require('./topics/tools')(SocketTopics);
|
||||
require('./topics/infinitescroll')(SocketTopics);
|
||||
require('./topics/tags')(SocketTopics);
|
||||
require('./topics/merge')(SocketTopics);
|
||||
|
||||
SocketTopics.post = function (socket, data, callback) {
|
||||
if (!data) {
|
||||
|
||||
27
src/socket.io/topics/merge.js
Normal file
27
src/socket.io/topics/merge.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var topics = require('../../topics');
|
||||
var privileges = require('../../privileges');
|
||||
|
||||
module.exports = function (SocketTopics) {
|
||||
SocketTopics.merge = function (socket, tids, callback) {
|
||||
if (!Array.isArray(tids)) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.map(tids, function (tid, next) {
|
||||
privileges.topics.isAdminOrMod(tid, socket.uid, next);
|
||||
}, next);
|
||||
},
|
||||
function (allowed, next) {
|
||||
if (allowed.includes(false)) {
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
topics.merge(tids, next);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user