Skip to content

Node.js based forum software built for the modern web

fix: #12729, replies to existing topics from Pixelfed not asserting properly due to incorrect `toPid`

Julian Lamf481cde1a8db
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;