fix: don't trust timestamps on received items

Trust the order you get from reply chain traversal and context retrieval instead.
This commit is contained in:
Julian Lam
2024-10-29 11:16:18 -04:00
parent 7bf411383e
commit b1d779ca6f

View File

@@ -61,6 +61,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
if (!chain || !chain.length) { if (!chain || !chain.length) {
// Fall back to inReplyTo traversal on context retrieval failure // Fall back to inReplyTo traversal on context retrieval failure
chain = Array.from(await Notes.getParentChain(uid, input)); chain = Array.from(await Notes.getParentChain(uid, input));
chain.reverse();
} }
// Can't resolve — give up. // Can't resolve — give up.
@@ -70,7 +71,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
} }
// Reorder chain items by timestamp // Reorder chain items by timestamp
chain = chain.sort((a, b) => a.timestamp - b.timestamp); // chain = chain.sort((a, b) => a.timestamp - b.timestamp);
const mainPost = chain[0]; const mainPost = chain[0];
let { pid: mainPid, tid, uid: authorId, timestamp, name, content, _activitypub } = mainPost; let { pid: mainPid, tid, uid: authorId, timestamp, name, content, _activitypub } = mainPost;