fix: #12941, inherit audience from earlier posts in the chain so as to send a coherent value to Lemmy instances, re: lemmynet/lemmy#5278

This commit is contained in:
Julian Lam
2024-12-24 11:18:12 -05:00
parent b537437c78
commit 97384b2cbd

View File

@@ -535,6 +535,14 @@ Mocks.notes.public = async (post) => {
let context = await posts.getPostField(post.pid, 'context'); let context = await posts.getPostField(post.pid, 'context');
context = context || `${nconf.get('url')}/topic/${post.topic.tid}`; 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 = { let object = {
'@context': 'https://www.w3.org/ns/activitystreams', '@context': 'https://www.w3.org/ns/activitystreams',
id, id,
@@ -547,7 +555,7 @@ Mocks.notes.public = async (post) => {
url: id, url: id,
attributedTo: `${nconf.get('url')}/uid/${post.user.uid}`, attributedTo: `${nconf.get('url')}/uid/${post.user.uid}`,
context, context,
audience: `${nconf.get('url')}/category/${post.category.cid}`, audience,
summary: null, summary: null,
name, name,
content: post.content, 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 })); ({ object } = await plugins.hooks.fire('filter:activitypub.mocks.note', { object, post, private: false }));
console.log(object);
return object; return object;
}; };