From 67a93da507b62d3a2347ba51393a559a524d628c Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 16 Mar 2026 13:50:39 -0400 Subject: [PATCH] fix: add back 'after' query param handling in /world that was removed accidentally --- src/controllers/activitypub/topics.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/controllers/activitypub/topics.js b/src/controllers/activitypub/topics.js index d45b187761..85659fc466 100644 --- a/src/controllers/activitypub/topics.js +++ b/src/controllers/activitypub/topics.js @@ -23,8 +23,8 @@ controller.list = async function (req, res) { const { topicsPerPage } = await user.getSettings(req.uid); let { page, after } = req.query; page = parseInt(page, 10) || 1; - const start = Math.max(0, (page - 1) * topicsPerPage); - const stop = start + topicsPerPage - 1; + let start = Math.max(0, (page - 1) * topicsPerPage); + let stop = start + topicsPerPage - 1; const [userSettings, userPrivileges] = await Promise.all([ user.getSettings(req.uid), @@ -72,6 +72,16 @@ controller.list = async function (req, res) { }; delete cidQuery.cid; ({ tids, topicCount } = await topics.getSortedTopics(cidQuery)); + + if (after) { + // Update start/stop with values inferred from `after` + const index = tids.indexOf(utils.isNumber(after) ? parseInt(after, 10) : after); + if (index && start - index < 1) { + const count = stop - start; + start = index + 1; + stop = start + count; + } + } tids = tids.slice(start, stop !== -1 ? stop + 1 : undefined); } data.topicCount = topicCount;