mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-04 14:50:47 +01:00
Revert "fix: use categories.getTopicIds instead of duplicating existing logic to get world tids"
This reverts commit 7bf411383e.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const nconf = require('nconf');
|
||||
|
||||
const db = require('../../database');
|
||||
const user = require('../../user');
|
||||
const topics = require('../../topics');
|
||||
|
||||
@@ -29,6 +30,14 @@ controller.list = async function (req, res) {
|
||||
const start = Math.max(0, (page - 1) * topicsPerPage);
|
||||
const stop = start + topicsPerPage - 1;
|
||||
|
||||
const sortToSet = {
|
||||
recently_replied: `cid:-1:tids`,
|
||||
recently_created: `cid:-1:tids:create`,
|
||||
most_posts: `cid:-1:tids:posts`,
|
||||
most_votes: `cid:-1:tids:votes`,
|
||||
most_views: `cid:-1:tids:views`,
|
||||
};
|
||||
|
||||
const [userPrivileges, tagData, userSettings, rssToken] = await Promise.all([
|
||||
privileges.categories.get('-1', req.uid),
|
||||
helpers.getSelectedTag(req.query.tag),
|
||||
@@ -36,8 +45,16 @@ controller.list = async function (req, res) {
|
||||
user.auth.getFeedToken(req.uid),
|
||||
]);
|
||||
const sort = validSorts.includes(req.query.sort) ? req.query.sort : userSettings.categoryTopicSort;
|
||||
|
||||
let tids = await db.getSortedSetRevRange(sortToSet[sort], 0, 499);
|
||||
const isMembers = await db.isSortedSetMembers(`uid:${req.uid}:inbox`, tids);
|
||||
tids = tids.filter((tid, idx) => isMembers[idx]);
|
||||
const count = tids.length;
|
||||
tids = tids.slice(start, stop + 1);
|
||||
|
||||
const targetUid = await user.getUidByUserslug(req.query.author);
|
||||
const cidQuery = {
|
||||
|
||||
const data = await categories.getCategoryById({
|
||||
uid: req.uid,
|
||||
cid: '-1',
|
||||
start: start,
|
||||
@@ -47,14 +64,12 @@ controller.list = async function (req, res) {
|
||||
query: req.query,
|
||||
tag: req.query.tag,
|
||||
targetUid: targetUid,
|
||||
};
|
||||
});
|
||||
|
||||
const data = await categories.getCategoryById(cidQuery);
|
||||
data.name = '[[activitypub:world.name]]';
|
||||
delete data.children;
|
||||
|
||||
const tids = await categories.getTopicIds(cidQuery);
|
||||
data.topicCount = tids.length;
|
||||
data.topicCount = count;
|
||||
data.topics = await topics.getTopicsByTids(tids, { uid: req.uid });
|
||||
topics.calculateTopicIndices(data.topics, start);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user