Node.js based forum software built for the modern web
fix: #12707 ensure actor matches context attributedTo
Julian Lam998273cdc463
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.jsindex 5e20d417f6..eddc8026bd 100644--- a/src/activitypub/inbox.js+++ b/src/activitypub/inbox.js@@ -77,7 +77,7 @@ inbox.create = async (req) => {};inbox.add = async (req) => {- const { object, target } = req.body;+ const { actor, object, target } = req.body;// Only react on Adds pertaining to local postsconst { type, id: pid } = await activitypub.helpers.resolveLocalId(object);@@ -85,9 +85,13 @@ inbox.add = async (req) => {// Check context of OPconst tid = await posts.getPostField(pid, 'tid');const context = await topics.getTopicField(tid, 'context');- if (context && context === target) {- activitypub.helpers.log(`[activitypub/inbox/add] Associating pid ${pid} with new context ${target}`);- await posts.setPostField(pid, 'context', target);+ console.log(context);+ if (context) {+ const { attributedTo } = await activitypub.get('uid', 0, context);+ if (context === target && attributedTo === actor) {+ activitypub.helpers.log(`[activitypub/inbox/add] Associating pid ${pid} with new context ${target}`);+ await posts.setPostField(pid, 'context', target);+ }}}};