You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/src/socket.io/categories.js

50 lines
1.2 KiB
JavaScript

'use strict';
var categories = require('../categories'),
categoryTools = require('../categoryTools'),
meta = require('./../meta'),
user = require('./../user'),
SocketCategories = {};
SocketCategories.getRecentReplies = function(socket, cid, callback) {
categoryTools.privileges(cid, socket.uid, function(err, privileges) {
if (err) {
return callback(err);
}
11 years ago
if (!privileges || !privileges.read) {
return callback(null, []);
}
categories.getRecentReplies(cid, socket.uid, 4, callback);
});
};
SocketCategories.get = function(socket, data, callback) {
categories.getAllCategories(0, callback);
};
SocketCategories.loadMore = function(socket, data, callback) {
if(!data) {
11 years ago
return callback(new Error('[[error:invalid-data]]'));
}
user.getSettings(socket.uid, function(err, settings) {
var start = parseInt(data.after, 10),
11 years ago
end = start + settings.topicsPerPage - 1;
categories.getCategoryTopics(data.cid, start, end, socket.uid, callback);
});
};
SocketCategories.getPageCount = function(socket, cid, callback) {
categories.getPageCount(cid, socket.uid, callback);
};
11 years ago
SocketCategories.getTopicCount = function(socket, cid, callback) {
categories.getCategoryField(cid, 'topic_count', callback);
};
module.exports = SocketCategories;