fix: incorrect parsing of context items during note assertion, logic error with slicing

This commit is contained in:
Julian Lam
2024-07-19 10:50:14 -04:00
parent bc00835c26
commit 60408f2307

View File

@@ -48,7 +48,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
const { tid } = context; const { tid } = context;
return { tid, count: 0 }; return { tid, count: 0 };
} else if (context.context) { } else if (context.context) {
chain = Array.from(await activitypub.contexts.getItems(uid, context)); chain = Array.from(await activitypub.contexts.getItems(uid, context.context));
} else { } else {
// Fall back to inReplyTo traversal // Fall back to inReplyTo traversal
chain = Array.from(await Notes.getParentChain(uid, input)); chain = Array.from(await Notes.getParentChain(uid, input));
@@ -71,7 +71,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
await topics.tools.move(tid, { cid: options.cid, uid: 'system' }); 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(1).map(p => p.pid));
members.unshift(await posts.exists(mainPid)); members.unshift(await posts.exists(mainPid));
if (tid && members.every(Boolean)) { if (tid && members.every(Boolean)) {
// All cached, return early. // All cached, return early.