Node.js based forum software built for the modern web
feat: make the /api/world data more category-like
Oplikoe266b447455c
diff --git a/src/categories/data.js b/src/categories/data.jsindex 6d10a23023..a1b0093363 100644--- a/src/categories/data.js+++ b/src/categories/data.js@@ -24,7 +24,10 @@ const worldCategory = {color: '#333',slug: '../world',parentCid: 0,- disabled: 0, // todo+ disabled: 0,+ handle: 'world',+ link: '',+ class: '', // todo};module.exports = function (Categories) {diff --git a/src/controllers/activitypub/topics.js b/src/controllers/activitypub/topics.jsindex a495b856b0..6379c69057 100644--- a/src/controllers/activitypub/topics.js+++ b/src/controllers/activitypub/topics.js@@ -16,6 +16,10 @@ const meta = require('../../meta');const controller = module.exports;+const validSorts = [+ 'recently_replied', 'recently_created', 'most_posts', 'most_votes', 'most_views',+];+controller.list = async function (req, res) {const { topicsPerPage } = await user.getSettings(req.uid);const page = parseInt(req.query.page, 10) || 1;@@ -36,18 +40,33 @@ controller.list = async function (req, res) {weights: sets.map((s, index) => (index ? 0 : 1)),});- const [categoryFields, userPrivileges, rssToken] = await Promise.all([- categories.getCategoryFields(-1, ['name', 'description', 'icon', 'imageClass', 'color', 'bgColor']),- privileges.categories.get(-1, req.uid),+ const [userPrivileges, tagData, userSettings, rssToken] = await Promise.all([+ privileges.categories.get('-1', req.uid),+ helpers.getSelectedTag(req.query.tag),+ user.getSettings(req.uid),user.auth.getFeedToken(req.uid),]);- const data = categoryFields;- data.cid = -1;+ const targetUid = await user.getUidByUserslug(req.query.author);+ const sort = validSorts.includes(req.query.sort) ? req.query.sort : userSettings.categoryTopicSort;++ const data = await categories.getCategoryById({+ uid: req.uid,+ cid: '-1',+ start: start,+ stop: stop,+ sort: sort,+ settings: userSettings,+ query: req.query,+ tag: req.query.tag,+ targetUid: targetUid,+ });+ delete data.children;+data.topicCount = await db.sortedSetIntersectCard(sets);data.topics = await topics.getTopicsByTids(tids, { uid: req.uid });topics.calculateTopicIndices(data.topics, start);- data.title = translator.escape(categoryFields.name);+ data.title = translator.escape(data.name);data.privileges = userPrivileges;data.breadcrumbs = helpers.buildBreadcrumbs([{ text: `[[pages:world]]` }]);