From b317cdd365f267437310d9cbfc2bc8ce6fe24021 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 11 Mar 2026 14:53:06 -0400 Subject: [PATCH] feat: category group actor outbox, #14083 --- src/controllers/activitypub/index.js | 35 ++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/controllers/activitypub/index.js b/src/controllers/activitypub/index.js index 1a55109903..db1441aa1b 100644 --- a/src/controllers/activitypub/index.js +++ b/src/controllers/activitypub/index.js @@ -215,12 +215,39 @@ Controller.getOutbox = async (req, res) => { }; Controller.getCategoryOutbox = async (req, res) => { - // stub + const { cid } = req.params; + const { page } = req.query; + const set = `cid:${cid}:pids`; + const count = await db.sortedSetCard(set); + const collection = await activitypub.helpers.generateCollection({ + set, + count, + page, + perPage: 20, + url: `${nconf.get('url')}/category/1/outbox`, + }); + collection.orderedItems = await Promise.all(collection.orderedItems.map(async (pid) => { + let object; + if (utils.isNumber(pid)) { + const { activity } = await activitypub.mocks.activities.create(pid, 0); + object = activity; + } else { + object = pid; + } + + return { + id: `${nconf.get('url')}/post/${encodeURIComponent(pid)}#activity/announce/cid/${cid}`, + type: 'Announce', + actor: `${nconf.get('url')}/category/${cid}`, + to: [activitypub._constants.publicAddress], + cc: [`${nconf.get('url')}/category/${cid}/followers`], + object, + }; + })); + res.status(200).json({ '@context': 'https://www.w3.org/ns/activitystreams', - type: 'OrderedCollection', - totalItems: 0, - orderedItems: [], + ...collection, }); };