From f481cde1a8dbe9aec5baca1bcb24802d667e1c21 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 13 Aug 2024 11:12:43 -0400 Subject: [PATCH] fix: #12729, replies to existing topics from Pixelfed not asserting properly due to incorrect `toPid` Pixelfed supplies an object _url_ instead of the expected _id_ in the `inReplyTo` field, and that tripped up NodeBB because we don't store a backreference for those. The ideal solution here would be to set up a backreference for urls to pids, but in the meantime, this shortcut will function (it assumes that the object that it is in reply to is in the chain/context). --- src/activitypub/notes.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js index 0154af5b77..b2f3d125ea 100644 --- a/src/activitypub/notes.js +++ b/src/activitypub/notes.js @@ -121,8 +121,15 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { tid = tid || utils.generateUUID(); mainPost.tid = tid; + const urlMap = chain.reduce((map, post) => (post.url ? map.set(post.url, post.id) : map), new Map()); const unprocessed = chain.map((post) => { post.tid = tid; // add tid to post hash + + // Ensure toPids in replies are ids + if (urlMap.has(post.toPid)) { + post.toPid = urlMap.get(post.toPid); + } + return post; }).filter((p, idx) => !members[idx]); const count = unprocessed.length;