fix: handle inaccessible boosts

This commit is contained in:
Julian Lam
2024-02-12 15:25:49 -05:00
parent 672a907d54
commit 9439987eda
2 changed files with 8 additions and 1 deletions

View File

@@ -98,6 +98,10 @@ inbox.announce = async (req) => {
} else { } else {
pid = object; pid = object;
tid = await activitypub.notes.assertTopic(0, object); tid = await activitypub.notes.assertTopic(0, object);
if (!tid) {
return;
}
await topics.updateLastPostTime(tid, timestamp); await topics.updateLastPostTime(tid, timestamp);
} }

View File

@@ -122,7 +122,6 @@ Notes.getParentChain = async (uid, input) => {
} }
} catch (e) { } catch (e) {
winston.warn(`[activitypub/notes/getParentChain] Cannot retrieve ${id}, terminating here.`); winston.warn(`[activitypub/notes/getParentChain] Cannot retrieve ${id}, terminating here.`);
chain.delete(id);
} }
} }
}; };
@@ -153,6 +152,10 @@ Notes.assertTopic = async (uid, id) => {
*/ */
const chain = Array.from(await Notes.getParentChain(uid, id)); const chain = Array.from(await Notes.getParentChain(uid, id));
if (!chain.length) {
return null;
}
let { pid: mainPid, tid, uid: authorId, timestamp, name, content } = chain[chain.length - 1]; let { pid: mainPid, tid, uid: authorId, timestamp, name, content } = chain[chain.length - 1];
const members = await db.isSortedSetMembers(`tid:${tid}:posts`, chain.map(p => p.pid)); const members = await db.isSortedSetMembers(`tid:${tid}:posts`, chain.map(p => p.pid));
if (tid && members.every(Boolean)) { if (tid && members.every(Boolean)) {