mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
fix: FEP 1b12 conformance, federate Announce(Create(Note)) instead of Announce(Note), #12434
This commit is contained in:
@@ -144,27 +144,28 @@ activitypubApi.create.note = enabledCheck(async (caller, { pid }) => {
|
|||||||
const { cid } = post.category;
|
const { cid } = post.category;
|
||||||
const followers = await activitypub.notes.getCategoryFollowers(cid);
|
const followers = await activitypub.notes.getCategoryFollowers(cid);
|
||||||
|
|
||||||
const payloads = {
|
const payload = {
|
||||||
create: {
|
|
||||||
id: `${object.id}#activity/create/${Date.now()}`,
|
id: `${object.id}#activity/create/${Date.now()}`,
|
||||||
type: 'Create',
|
type: 'Create',
|
||||||
to,
|
to,
|
||||||
cc,
|
cc,
|
||||||
object,
|
object,
|
||||||
},
|
};
|
||||||
announce: {
|
|
||||||
|
await activitypub.send('uid', caller.uid, Array.from(targets), payload);
|
||||||
|
|
||||||
|
if (followers.length) {
|
||||||
|
// The 1b12 announce is just a wrapper around the same payload
|
||||||
|
const announce = {
|
||||||
id: `${object.id}#activity/announce/${Date.now()}`,
|
id: `${object.id}#activity/announce/${Date.now()}`,
|
||||||
type: 'Announce',
|
type: 'Announce',
|
||||||
to: [activitypub._constants.publicAddress],
|
to: [activitypub._constants.publicAddress],
|
||||||
cc: [`${nconf.get('url')}/category/${cid}/followers`],
|
cc: [`${nconf.get('url')}/category/${cid}/followers`],
|
||||||
object,
|
object: payload,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await activitypub.send('uid', caller.uid, Array.from(targets), payloads.create);
|
|
||||||
if (followers.length) {
|
|
||||||
setTimeout(() => { // Delay sending to avoid potential race condition
|
setTimeout(() => { // Delay sending to avoid potential race condition
|
||||||
activitypub.send('cid', cid, followers, payloads.announce)
|
activitypub.send('cid', cid, followers, announce)
|
||||||
.catch(err => winston.error(err.stack));
|
.catch(err => winston.error(err.stack));
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user