mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: 1b12 conformance for inbox.create as well
This commit is contained in:
@@ -47,13 +47,15 @@ inbox.create = async (req) => {
|
|||||||
const cid = await topics.getTopicField(response.tid, 'cid');
|
const cid = await topics.getTopicField(response.tid, 'cid');
|
||||||
const followers = await activitypub.notes.getCategoryFollowers(cid);
|
const followers = await activitypub.notes.getCategoryFollowers(cid);
|
||||||
if (followers.length) {
|
if (followers.length) {
|
||||||
await activitypub.send('cid', cid, followers, {
|
await Promise.all([req.body, object].map(async (object) => {
|
||||||
id: `${object.id}#activity/announce/${Date.now()}`,
|
await activitypub.send('cid', cid, followers, {
|
||||||
type: 'Announce',
|
id: `${object.id}#activity/announce/${Date.now()}`,
|
||||||
to: [`${nconf.get('url')}/category/${cid}/followers`],
|
type: 'Announce',
|
||||||
cc: [activitypub._constants.publicAddress],
|
to: [`${nconf.get('url')}/category/${cid}/followers`],
|
||||||
object,
|
cc: [activitypub._constants.publicAddress],
|
||||||
});
|
object,
|
||||||
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -155,27 +155,16 @@ activitypubApi.create.note = enabledCheck(async (caller, { pid }) => {
|
|||||||
await activitypub.send('uid', caller.uid, Array.from(targets), payload);
|
await activitypub.send('uid', caller.uid, Array.from(targets), payload);
|
||||||
|
|
||||||
if (followers.length) {
|
if (followers.length) {
|
||||||
// The 1b12 announce is just a wrapper around the same payload
|
|
||||||
const announce = {
|
|
||||||
id: `${object.id}#activity/announce/${Date.now()}`,
|
|
||||||
type: 'Announce',
|
|
||||||
to: [activitypub._constants.publicAddress],
|
|
||||||
cc: [`${nconf.get('url')}/category/${cid}/followers`],
|
|
||||||
object: payload,
|
|
||||||
};
|
|
||||||
const implicit = {
|
|
||||||
id: `${object.id}#activity/announce/${Date.now()}`,
|
|
||||||
type: 'Announce',
|
|
||||||
to: [activitypub._constants.publicAddress],
|
|
||||||
cc: [`${nconf.get('url')}/category/${cid}/followers`],
|
|
||||||
object: payload.object,
|
|
||||||
};
|
|
||||||
|
|
||||||
setTimeout(() => { // Delay sending to avoid potential race condition
|
setTimeout(() => { // Delay sending to avoid potential race condition
|
||||||
Promise.all([
|
Promise.all([payload, payload.object].map(async (object) => {
|
||||||
activitypub.send('cid', cid, followers, announce),
|
await activitypub.send('cid', cid, followers, {
|
||||||
activitypub.send('cid', cid, followers, implicit),
|
id: `${object.id}#activity/announce/${Date.now()}`,
|
||||||
]).catch(err => winston.error(err.stack));
|
type: 'Announce',
|
||||||
|
to: [activitypub._constants.publicAddress],
|
||||||
|
cc: [`${nconf.get('url')}/category/${cid}/followers`],
|
||||||
|
object,
|
||||||
|
});
|
||||||
|
})).catch(err => winston.error(err.stack));
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user