mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
closes #5354
This commit is contained in:
@@ -2,15 +2,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var winston = require('winston');
|
|
||||||
var db = require('../database');
|
var db = require('../database');
|
||||||
var user = require('../user');
|
|
||||||
var posts = require('../posts');
|
var posts = require('../posts');
|
||||||
var privileges = require('../privileges');
|
var privileges = require('../privileges');
|
||||||
var plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
var meta = require('../meta');
|
var meta = require('../meta');
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (Topics) {
|
module.exports = function (Topics) {
|
||||||
|
|
||||||
Topics.createTopicFromPosts = function (uid, title, pids, fromTid, callback) {
|
Topics.createTopicFromPosts = function (uid, title, pids, fromTid, callback) {
|
||||||
@@ -55,11 +53,14 @@ module.exports = function (Topics) {
|
|||||||
}
|
}
|
||||||
Topics.create({uid: results.postData.uid, title: title, cid: cid}, next);
|
Topics.create({uid: results.postData.uid, title: title, cid: cid}, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (_tid, next) {
|
||||||
Topics.updateTopicBookmarks(fromTid, pids, function () { next( null, results );} );
|
Topics.updateTopicBookmarks(fromTid, pids, function (err) {
|
||||||
|
next(err, _tid);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
function (_tid, next) {
|
function (_tid, next) {
|
||||||
function move(pid, next) {
|
tid = _tid;
|
||||||
|
async.eachSeries(pids, function (pid, next) {
|
||||||
privileges.posts.canEdit(pid, uid, function (err, canEdit) {
|
privileges.posts.canEdit(pid, uid, function (err, canEdit) {
|
||||||
if (err || !canEdit.flag) {
|
if (err || !canEdit.flag) {
|
||||||
return next(err || new Error(canEdit.message));
|
return next(err || new Error(canEdit.message));
|
||||||
@@ -67,14 +68,13 @@ module.exports = function (Topics) {
|
|||||||
|
|
||||||
Topics.movePostToTopic(pid, tid, next);
|
Topics.movePostToTopic(pid, tid, next);
|
||||||
});
|
});
|
||||||
}
|
}, next);
|
||||||
tid = _tid;
|
|
||||||
async.eachSeries(pids, move, next);
|
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
Topics.updateTimestamp(tid, Date.now(), next);
|
Topics.updateTimestamp(tid, Date.now(), next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
|
plugins.fireHook('action:topic.fork', {tid: tid, fromTid: fromTid, uid: uid});
|
||||||
Topics.getTopicData(tid, next);
|
Topics.getTopicData(tid, next);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user