fix: #5570, create per category user post zsets

This commit is contained in:
Barış Soner Uşaklı
2019-06-24 15:21:43 -04:00
parent 4e513cf38a
commit a39f0ef592
15 changed files with 316 additions and 89 deletions

View File

@@ -3,6 +3,7 @@
var async = require('async');
var topics = require('../../topics');
const categories = require('../../categories');
var privileges = require('../../privileges');
var meta = require('../../meta');
var utils = require('../../utils');
@@ -117,6 +118,18 @@ module.exports = function (SocketTopics) {
topics.getTopicsFromSet(data.set, socket.uid, start, stop, callback);
};
SocketTopics.loadMoreUserTopics = function (socket, data, callback) {
async.waterfall([
function (next) {
categories.getCidsByPrivilege('categories:cid', socket.uid, 'topics:read', next);
},
function (cids, next) {
data.set = cids.map(c => 'cid:' + c + ':uid:' + data.uid + ':tids');
SocketTopics.loadMoreFromSet(socket, data, next);
},
], callback);
};
function calculateStartStop(data) {
var itemsPerPage = Math.min(meta.config.topicsPerPage || 20, parseInt(data.count, 10) || meta.config.topicsPerPage || 20);
var start = Math.max(0, parseInt(data.after, 10));