This commit is contained in:
Barış Soner Uşaklı
2017-11-30 12:39:03 -05:00
parent 17c52a515d
commit 4f2f84e47c
6 changed files with 149 additions and 2 deletions

View File

@@ -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) {

View 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);
};
};