mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: regression that caused new notes to have undefined cid and fail privilege check
This commit is contained in:
@@ -51,13 +51,10 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
let { pid: mainPid, tid, uid: authorId, timestamp, name, content, _activitypub } = mainPost;
|
let { pid: mainPid, tid, uid: authorId, timestamp, name, content, _activitypub } = mainPost;
|
||||||
const hasTid = !!tid;
|
const hasTid = !!tid;
|
||||||
|
|
||||||
// Update category if currently uncategorized
|
const cid = hasTid ? await topics.getTopicField(tid, 'cid') : options.cid || -1;
|
||||||
if (hasTid) {
|
if (options.cid && cid === -1) {
|
||||||
const cid = await topics.getTopicField(tid, 'cid');
|
// Move topic if currently uncategorized
|
||||||
if (options.cid && cid === -1) {
|
await topics.tools.move(tid, { cid: options.cid, uid: 'system' });
|
||||||
// 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));
|
||||||
@@ -69,7 +66,6 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
return { tid, count: 0 };
|
return { tid, count: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
let cid;
|
|
||||||
let title;
|
let title;
|
||||||
if (hasTid) {
|
if (hasTid) {
|
||||||
mainPid = await topics.getTopicField(tid, 'mainPid');
|
mainPid = await topics.getTopicField(tid, 'mainPid');
|
||||||
@@ -87,7 +83,6 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mainPid ok to leave as-is
|
// mainPid ok to leave as-is
|
||||||
cid = options.cid || -1;
|
|
||||||
title = name || activitypub.helpers.generateTitle(utils.decodeHTMLEntities(content));
|
title = name || activitypub.helpers.generateTitle(utils.decodeHTMLEntities(content));
|
||||||
}
|
}
|
||||||
mainPid = utils.isNumber(mainPid) ? parseInt(mainPid, 10) : mainPid;
|
mainPid = utils.isNumber(mainPid) ? parseInt(mainPid, 10) : mainPid;
|
||||||
|
|||||||
Reference in New Issue
Block a user