mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-19 05:52:57 +01:00
feat: disallow moving topics to and from remote categories, + basic tests for topic moving
This commit is contained in:
@@ -235,7 +235,7 @@ module.exports = function (Topics) {
|
||||
};
|
||||
|
||||
topicTools.move = async function (tid, data) {
|
||||
const cid = utils.isNumber(data.cid) ? parseInt(data.cid, 10) : data.cid;
|
||||
const cid = parseInt(data.cid, 10);
|
||||
const topicData = await Topics.getTopicData(tid);
|
||||
if (!topicData) {
|
||||
throw new Error('[[error:no-topic]]');
|
||||
@@ -243,6 +243,10 @@ module.exports = function (Topics) {
|
||||
if (cid === topicData.cid) {
|
||||
throw new Error('[[error:cant-move-topic-to-same-category]]');
|
||||
}
|
||||
if (!utils.isNumber(cid) || !utils.isNumber(topicData.cid)) {
|
||||
throw new Error('[[error:cant-move-topic-to-from-remote-categories]]');
|
||||
}
|
||||
|
||||
const tags = await Topics.getTopicTags(tid);
|
||||
await db.sortedSetsRemove([
|
||||
`cid:${topicData.cid}:tids`,
|
||||
|
||||
Reference in New Issue
Block a user