fix: controversial posts/bests posts not showing anything

fix upgrade script so posts with negative votes are stored, a post can have 10 upvotes and 2 downvotes
fix missing negative votes checks
remove unnecessary pids flters since the cids are only already filtered by topics:read
This commit is contained in:
Barış Soner Uşaklı
2022-02-04 21:52:44 -05:00
parent e6185883ba
commit 079c487dcb
5 changed files with 16 additions and 24 deletions

View File

@@ -57,8 +57,7 @@ const templateToData = {
return cids.map(c => `cid:${c}:uid:${userData.uid}:pids:votes`);
},
getTopics: async (sets, req, start, stop) => {
let pids = await db.getSortedSetRevRangeByScore(sets, start, stop, '+inf', '1');
pids = await privileges.posts.filter('topics:read', pids, req.uid);
const pids = await db.getSortedSetRevRangeByScore(sets, start, stop - start + 1, '+inf', 1);
const postObjs = await posts.getPostSummaryByPids(pids, req.uid, { stripTags: false });
return { posts: postObjs, nextStart: stop + 1 };
},
@@ -72,8 +71,7 @@ const templateToData = {
return cids.map(c => `cid:${c}:uid:${userData.uid}:pids:votes`);
},
getTopics: async (sets, req, start, stop) => {
let pids = await db.getSortedSetRangeByScore(sets, start, stop, '-inf', '-1');
pids = await privileges.posts.filter('topics:read', pids, req.uid);
const pids = await db.getSortedSetRangeByScore(sets, start, stop - start + 1, '-inf', -1);
const postObjs = await posts.getPostSummaryByPids(pids, req.uid, { stripTags: false });
return { posts: postObjs, nextStart: stop + 1 };
},