Node.js based forum software built for the modern web
fix(activitypub): refetch object when Update arrives via Announce
Julian Lamc4813e42a414
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.jsindex 35868314ed..8882154e4b 100644--- a/src/activitypub/inbox.js+++ b/src/activitypub/inbox.js@@ -180,7 +180,21 @@ inbox.move = async (req) => {};inbox.update = async (req) => {- const { actor, object } = req.body;+ let { actor, object } = req.body;++ // Refetch object by id if Update was announce-wrapped+ if (req.res.locals.apAnnounced) {+ try {+ const refetched = await activitypub.get('uid', 0, object.id);+ if (refetched) {+ object = refetched;+ }+ } catch (e) {+ activitypub.helpers.log(`[activitypub/inbox.update] Failed to refetch object ${object.id}: ${e.message}`);+ return null;+ }+ }+const isPublic = publiclyAddressed([...(object.to || []), ...(object.cc || [])]);// Origin checking@@ -605,6 +619,7 @@ inbox.announce = async (req) => {}req.body = object;+ req.res.locals.apAnnounced = true;await inbox.update(req);break;}