Node.js based forum software built for the modern web
fix: move logic to move topic on note assertion earlier in the flow so it actually runs
Julian Lamacd1630b9f4e
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.jsindex 228bde68d3..5d8e44b079 100644--- a/src/activitypub/notes.js+++ b/src/activitypub/notes.js@@ -51,6 +51,15 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {let { pid: mainPid, tid, uid: authorId, timestamp, name, content } = mainPost;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));members.push(await posts.exists(mainPid));if (tid && members.every(Boolean)) {@@ -63,12 +72,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {let cid;let title;if (hasTid) {- ({ cid, mainPid } = await topics.getTopicFields(tid, ['tid', 'cid', 'mainPid']));-- if (options.cid && cid === -1) {- // Move topic- await topics.tools.move(tid, { cid: options.cid, uid: 'system' });- }+ mainPid = await topics.getTopicField(tid, 'mainPid');} else {// mainPid ok to leave as-iscid = options.cid || -1;