mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: have category actor send Announce(Note) activity on posts from that cid
re: #12434
This commit is contained in:
@@ -254,3 +254,11 @@ Notes.syncUserInboxes = async function (tid) {
|
|||||||
winston.verbose(`[activitypub/syncUserInboxes] Syncing tid ${tid} with ${uids.size} inboxes`);
|
winston.verbose(`[activitypub/syncUserInboxes] Syncing tid ${tid} with ${uids.size} inboxes`);
|
||||||
await db.sortedSetsAdd(keys, keys.map(() => score || Date.now()), tid);
|
await db.sortedSetsAdd(keys, keys.map(() => score || Date.now()), tid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Notes.getCategoryFollowers = async (cid) => {
|
||||||
|
// Retrieves remote users who have followed a category; used to build recipient list
|
||||||
|
let uids = await db.getSortedSetRangeByScore(`cid:${cid}:uid:watch:state`, 0, -1, categories.watchStates.tracking, categories.watchStates.tracking);
|
||||||
|
uids = uids.filter(uid => !utils.isNumber(uid));
|
||||||
|
|
||||||
|
return uids;
|
||||||
|
};
|
||||||
|
|||||||
@@ -104,15 +104,26 @@ activitypubApi.create.post = enabledCheck(async (caller, { pid }) => {
|
|||||||
|
|
||||||
const object = await activitypub.mocks.note(post);
|
const object = await activitypub.mocks.note(post);
|
||||||
const { targets } = await buildRecipients(object, post.user.uid);
|
const { targets } = await buildRecipients(object, post.user.uid);
|
||||||
|
const { cid } = post.category;
|
||||||
|
const followers = await activitypub.notes.getCategoryFollowers(cid);
|
||||||
|
|
||||||
const payload = {
|
const payloads = {
|
||||||
type: 'Create',
|
create: {
|
||||||
to: object.to,
|
type: 'Create',
|
||||||
cc: object.cc,
|
to: object.to,
|
||||||
object,
|
cc: object.cc,
|
||||||
|
object,
|
||||||
|
},
|
||||||
|
announce: {
|
||||||
|
type: 'Announce',
|
||||||
|
to: [`${nconf.get('url')}/category/${cid}/followers`],
|
||||||
|
cc: [activitypub._constants.publicAddress],
|
||||||
|
object,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
await activitypub.send('uid', caller.uid, Array.from(targets), payload);
|
await activitypub.send('uid', caller.uid, Array.from(targets), payloads.create);
|
||||||
|
await activitypub.send('cid', cid, followers, payloads.announce);
|
||||||
});
|
});
|
||||||
|
|
||||||
activitypubApi.update = {};
|
activitypubApi.update = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user