mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: move logic to move topic on note assertion earlier in the flow so it actually runs
This commit is contained in:
@@ -51,6 +51,15 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
let { pid: mainPid, tid, uid: authorId, timestamp, name, content } = mainPost;
|
let { pid: mainPid, tid, uid: authorId, timestamp, name, content } = mainPost;
|
||||||
const hasTid = !!tid;
|
const hasTid = !!tid;
|
||||||
|
|
||||||
|
// Update category if currently uncategorized
|
||||||
|
if (hasTid) {
|
||||||
|
const cid = await topics.getTopicField(tid, 'cid');
|
||||||
|
if (options.cid && cid === -1) {
|
||||||
|
// Move topic
|
||||||
|
await topics.tools.move(tid, { cid: options.cid, uid: 'system' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const members = await db.isSortedSetMembers(`tid:${tid}:posts`, chain.slice(0, -1).map(p => p.pid));
|
const members = await db.isSortedSetMembers(`tid:${tid}:posts`, chain.slice(0, -1).map(p => p.pid));
|
||||||
members.push(await posts.exists(mainPid));
|
members.push(await posts.exists(mainPid));
|
||||||
if (tid && members.every(Boolean)) {
|
if (tid && members.every(Boolean)) {
|
||||||
@@ -63,12 +72,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
let cid;
|
let cid;
|
||||||
let title;
|
let title;
|
||||||
if (hasTid) {
|
if (hasTid) {
|
||||||
({ cid, mainPid } = await topics.getTopicFields(tid, ['tid', 'cid', 'mainPid']));
|
mainPid = await topics.getTopicField(tid, 'mainPid');
|
||||||
|
|
||||||
if (options.cid && cid === -1) {
|
|
||||||
// Move topic
|
|
||||||
await topics.tools.move(tid, { cid: options.cid, uid: 'system' });
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// mainPid ok to leave as-is
|
// mainPid ok to leave as-is
|
||||||
cid = options.cid || -1;
|
cid = options.cid || -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user