|
|
@ -5,6 +5,7 @@ const user = require('../../user');
|
|
|
|
const posts = require('../../posts');
|
|
|
|
const posts = require('../../posts');
|
|
|
|
const topics = require('../../topics');
|
|
|
|
const topics = require('../../topics');
|
|
|
|
const categories = require('../../categories');
|
|
|
|
const categories = require('../../categories');
|
|
|
|
|
|
|
|
const privileges = require('../../privileges');
|
|
|
|
const pagination = require('../../pagination');
|
|
|
|
const pagination = require('../../pagination');
|
|
|
|
const helpers = require('../helpers');
|
|
|
|
const helpers = require('../helpers');
|
|
|
|
const accountHelpers = require('./helpers');
|
|
|
|
const accountHelpers = require('./helpers');
|
|
|
@ -55,6 +56,27 @@ const templateToData = {
|
|
|
|
const cids = await categories.getCidsByPrivilege('categories:cid', callerUid, 'topics:read');
|
|
|
|
const cids = await categories.getCidsByPrivilege('categories:cid', callerUid, 'topics:read');
|
|
|
|
return cids.map(c => `cid:${c}:uid:${userData.uid}:pids:votes`);
|
|
|
|
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 postObjs = await posts.getPostSummaryByPids(pids, req.uid, { stripTags: false });
|
|
|
|
|
|
|
|
return { posts: postObjs, nextStart: stop + 1 };
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
'account/controversial': {
|
|
|
|
|
|
|
|
type: 'posts',
|
|
|
|
|
|
|
|
noItemsFoundKey: '[[user:has_no_voted_posts]]',
|
|
|
|
|
|
|
|
crumb: '[[global:controversial]]',
|
|
|
|
|
|
|
|
getSets: async function (callerUid, userData) {
|
|
|
|
|
|
|
|
const cids = await categories.getCidsByPrivilege('categories:cid', callerUid, 'topics:read');
|
|
|
|
|
|
|
|
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 postObjs = await posts.getPostSummaryByPids(pids, req.uid, { stripTags: false });
|
|
|
|
|
|
|
|
return { posts: postObjs, nextStart: stop + 1 };
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'account/watched': {
|
|
|
|
'account/watched': {
|
|
|
|
type: 'topics',
|
|
|
|
type: 'topics',
|
|
|
@ -128,6 +150,10 @@ postsController.getBestPosts = async function (req, res, next) {
|
|
|
|
await getPostsFromUserSet('account/best', req, res, next);
|
|
|
|
await getPostsFromUserSet('account/best', req, res, next);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
postsController.getControversialPosts = async function (req, res, next) {
|
|
|
|
|
|
|
|
await getPostsFromUserSet('account/controversial', req, res, next);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
postsController.getWatchedTopics = async function (req, res, next) {
|
|
|
|
postsController.getWatchedTopics = async function (req, res, next) {
|
|
|
|
await getPostsFromUserSet('account/watched', req, res, next);
|
|
|
|
await getPostsFromUserSet('account/watched', req, res, next);
|
|
|
|
};
|
|
|
|
};
|
|
|
|