fix: #12707 ensure actor matches context attributedTo

This commit is contained in:
Julian Lam
2024-10-24 14:43:50 -04:00
parent 3023b25172
commit 998273cdc4

View File

@@ -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 posts
const { type, id: pid } = await activitypub.helpers.resolveLocalId(object);
@@ -85,9 +85,13 @@ inbox.add = async (req) => {
// Check context of OP
const 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);
}
}
}
};