From 97384b2cbd130efca1f3ae2419ce1de7cb800511 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 24 Dec 2024 11:18:12 -0500 Subject: [PATCH] fix: #12941, inherit audience from earlier posts in the chain so as to send a coherent value to Lemmy instances, re: lemmynet/lemmy#5278 --- src/activitypub/mocks.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js index 55b3b7874f..fbe6772e11 100644 --- a/src/activitypub/mocks.js +++ b/src/activitypub/mocks.js @@ -535,6 +535,14 @@ Mocks.notes.public = async (post) => { let context = await posts.getPostField(post.pid, 'context'); context = context || `${nconf.get('url')}/topic/${post.topic.tid}`; + let audience = `${nconf.get('url')}/category/${post.category.cid}`; // default + if (inReplyTo) { + const chain = await activitypub.notes.getParentChain(post.uid, inReplyTo); + chain.forEach((post) => { + audience = post.audience || audience; + }); + } + let object = { '@context': 'https://www.w3.org/ns/activitystreams', id, @@ -547,7 +555,7 @@ Mocks.notes.public = async (post) => { url: id, attributedTo: `${nconf.get('url')}/uid/${post.user.uid}`, context, - audience: `${nconf.get('url')}/category/${post.category.cid}`, + audience, summary: null, name, content: post.content, @@ -558,6 +566,7 @@ Mocks.notes.public = async (post) => { }; ({ object } = await plugins.hooks.fire('filter:activitypub.mocks.note', { object, post, private: false })); + console.log(object); return object; };