diff --git a/public/src/client/topic/move.js b/public/src/client/topic/move.js index 0b969ef6b9..b29ae964e0 100644 --- a/public/src/client/topic/move.js +++ b/public/src/client/topic/move.js @@ -63,11 +63,15 @@ define('forum/topic/move', ['categorySelector'], function (categorySelector) { } function moveTopics() { - socket.emit(Move.moveAll ? 'topics.moveAll' : 'topics.move', { + var data = { tids: Move.tids, cid: selectedCategory.cid, currentCid: Move.currentCid, - }, function (err) { + }; + + $(window).trigger('action:topic.move', data); + + socket.emit(Move.moveAll ? 'topics.moveAll' : 'topics.move', data, function (err) { modal.modal('hide'); if (err) { diff --git a/src/socket.io/topics/move.js b/src/socket.io/topics/move.js index efd6562d18..21d7543fb8 100644 --- a/src/socket.io/topics/move.js +++ b/src/socket.io/topics/move.js @@ -28,7 +28,8 @@ module.exports = function (SocketTopics) { function (_topicData, next) { topicData = _topicData; topicData.tid = tid; - topics.tools.move(tid, data.cid, socket.uid, next); + data.uid = socket.uid; + topics.tools.move(tid, data, next); }, function (next) { socketHelpers.emitToTopicAndCategory('event:topic_moved', topicData); @@ -59,8 +60,9 @@ module.exports = function (SocketTopics) { categories.getAllTopicIds(data.currentCid, 0, -1, next); }, function (tids, next) { + data.uid = socket.uid; async.eachLimit(tids, 50, function (tid, next) { - topics.tools.move(tid, data.cid, socket.uid, next); + topics.tools.move(tid, data, next); }, next); }, ], callback); diff --git a/src/topics/tools.js b/src/topics/tools.js index 743aa9d38d..bcd0b537e0 100644 --- a/src/topics/tools.js +++ b/src/topics/tools.js @@ -243,9 +243,10 @@ module.exports = function (Topics) { ], callback); }; - topicTools.move = function (tid, cid, uid, callback) { + topicTools.move = function (tid, data, callback) { var topic; var oldCid; + var cid = data.cid; async.waterfall([ function (next) { Topics.exists(tid, next); @@ -311,12 +312,11 @@ module.exports = function (Topics) { }); }, function (next) { - plugins.fireHook('action:topic.move', { - tid: tid, - fromCid: oldCid, - toCid: cid, - uid: uid, - }); + var hookData = _.clone(data); + hookData.fromCid = oldCid; + hookData.toCid = cid; + hookData.tid = tid; + plugins.fireHook('action:topic.move', hookData); next(); }, ], callback);