added err to getAllTopics

v1.18.x
Baris Soner Usakli
parent ff50917c29
commit 390937a20b

@ -244,7 +244,7 @@ var user = require('./../user.js'),
}); });
app.get('/topics', function (req, res) { app.get('/topics', function (req, res) {
topics.getAllTopics(10, null, function (topics) { topics.getAllTopics(10, null, function (err, topics) {
res.json({ res.json({
topics: topics, topics: topics,
notopics: topics.length === 0 notopics: topics.length === 0

@ -43,7 +43,7 @@ var path = require('path'),
}, },
function(next) { function(next) {
var topicUrls = []; var topicUrls = [];
topics.getAllTopics(null, null, function(topics) { topics.getAllTopics(null, null, function(err, topics) {
topics.forEach(function(topic) { topics.forEach(function(topic) {
if (topic.deleted !== '1') { if (topic.deleted !== '1') {
topicUrls.push({ topicUrls.push({

@ -588,6 +588,10 @@ var RDB = require('./redis.js'),
Topics.getAllTopics = function(limit, after, callback) { Topics.getAllTopics = function(limit, after, callback) {
RDB.smembers('topics:tid', function(err, tids) { RDB.smembers('topics:tid', function(err, tids) {
if(err) {
return callback(err, null);
}
var topics = [], var topics = [],
numTids, x; numTids, x;
@ -623,7 +627,7 @@ var RDB = require('./redis.js'),
next(); next();
}); });
}, function(err) { }, function(err) {
callback(topics); callback(err, topics);
}); });
}); });
} }

@ -861,7 +861,7 @@ module.exports.init = function(io) {
}); });
socket.on('api:admin.topics.getMore', function(data, callback) { socket.on('api:admin.topics.getMore', function(data, callback) {
topics.getAllTopics(data.limit, data.after, function(topics) { topics.getAllTopics(data.limit, data.after, function(err, topics) {
callback(JSON.stringify(topics)); callback(JSON.stringify(topics));
}); });
}); });

Loading…
Cancel
Save