remove unnecessary checks

v1.18.x
Barış Soner Uşaklı 8 years ago
parent f1b8492164
commit bcc566fb68

@ -31,7 +31,7 @@ Categories.getCategoryById = function (data, callback) {
Categories.getCategories([data.cid], data.uid, next); Categories.getCategories([data.cid], data.uid, next);
}, },
function (categories, next) { function (categories, next) {
if (!Array.isArray(categories) || !categories[0]) { if (!categories[0]) {
return next(new Error('[[error:invalid-cid]]')); return next(new Error('[[error:invalid-cid]]'));
} }
category = categories[0]; category = categories[0];

@ -314,7 +314,7 @@ topicsController.teaser = function (req, res, next) {
posts.getPostSummaryByPids([pid], req.uid, { stripTags: false }, next); posts.getPostSummaryByPids([pid], req.uid, { stripTags: false }, next);
}, },
function (posts) { function (posts) {
if (!Array.isArray(posts) || !posts.length) { if (!posts.length) {
return res.status(404).json('not-found'); return res.status(404).json('not-found');
} }
res.json(posts[0]); res.json(posts[0]);

@ -14,7 +14,7 @@ module.exports = function (Groups) {
Groups.getGroupsData([groupName], next); Groups.getGroupsData([groupName], next);
}, },
function (groupsData, next) { function (groupsData, next) {
if (!Array.isArray(groupsData) || !groupsData[0]) { if (!groupsData[0]) {
return callback(); return callback();
} }
groupObj = groupsData[0]; groupObj = groupsData[0];

@ -363,10 +363,6 @@ Notifications.markAllRead = function (uid, callback) {
db.getSortedSetRevRange('uid:' + uid + ':notifications:unread', 0, 99, next); db.getSortedSetRevRange('uid:' + uid + ':notifications:unread', 0, 99, next);
}, },
function (nids, next) { function (nids, next) {
if (!Array.isArray(nids) || !nids.length) {
return next();
}
Notifications.markReadMultiple(nids, uid, next); Notifications.markReadMultiple(nids, uid, next);
}, },
], callback); ], callback);

@ -235,7 +235,7 @@ var social = require('./social');
posts.getPidsFromSet(set, start, stop, reverse, next); posts.getPidsFromSet(set, start, stop, reverse, next);
}, },
function (pids, next) { function (pids, next) {
if ((!Array.isArray(pids) || !pids.length) && !topic.mainPid) { if (!pids.length && !topic.mainPid) {
return callback(null, []); return callback(null, []);
} }

@ -200,16 +200,10 @@ module.exports = function (Topics) {
Topics.getFollowers(postData.topic.tid, next); Topics.getFollowers(postData.topic.tid, next);
}, },
function (followers, next) { function (followers, next) {
if (!Array.isArray(followers) || !followers.length) {
return callback();
}
var index = followers.indexOf(exceptUid.toString()); var index = followers.indexOf(exceptUid.toString());
if (index !== -1) { if (index !== -1) {
followers.splice(index, 1); followers.splice(index, 1);
} }
if (!followers.length) {
return callback();
}
privileges.topics.filterUids('read', postData.topic.tid, followers, next); privileges.topics.filterUids('read', postData.topic.tid, followers, next);
}, },

@ -271,9 +271,6 @@ UserNotifications.sendTopicNotificationToFollowers = function (uid, topicData, p
db.getSortedSetRange('followers:' + uid, 0, -1, next); db.getSortedSetRange('followers:' + uid, 0, -1, next);
}, },
function (followers, next) { function (followers, next) {
if (!Array.isArray(followers) || !followers.length) {
return;
}
privileges.categories.filterUids('read', topicData.cid, followers, next); privileges.categories.filterUids('read', topicData.cid, followers, next);
}, },
function (_followers, next) { function (_followers, next) {

Loading…
Cancel
Save