mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
remove unnecessary checks
This commit is contained in:
@@ -31,7 +31,7 @@ Categories.getCategoryById = function (data, callback) {
|
||||
Categories.getCategories([data.cid], data.uid, next);
|
||||
},
|
||||
function (categories, next) {
|
||||
if (!Array.isArray(categories) || !categories[0]) {
|
||||
if (!categories[0]) {
|
||||
return next(new Error('[[error:invalid-cid]]'));
|
||||
}
|
||||
category = categories[0];
|
||||
|
||||
@@ -314,7 +314,7 @@ topicsController.teaser = function (req, res, next) {
|
||||
posts.getPostSummaryByPids([pid], req.uid, { stripTags: false }, next);
|
||||
},
|
||||
function (posts) {
|
||||
if (!Array.isArray(posts) || !posts.length) {
|
||||
if (!posts.length) {
|
||||
return res.status(404).json('not-found');
|
||||
}
|
||||
res.json(posts[0]);
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = function (Groups) {
|
||||
Groups.getGroupsData([groupName], next);
|
||||
},
|
||||
function (groupsData, next) {
|
||||
if (!Array.isArray(groupsData) || !groupsData[0]) {
|
||||
if (!groupsData[0]) {
|
||||
return callback();
|
||||
}
|
||||
groupObj = groupsData[0];
|
||||
|
||||
@@ -363,10 +363,6 @@ Notifications.markAllRead = function (uid, callback) {
|
||||
db.getSortedSetRevRange('uid:' + uid + ':notifications:unread', 0, 99, next);
|
||||
},
|
||||
function (nids, next) {
|
||||
if (!Array.isArray(nids) || !nids.length) {
|
||||
return next();
|
||||
}
|
||||
|
||||
Notifications.markReadMultiple(nids, uid, next);
|
||||
},
|
||||
], callback);
|
||||
|
||||
@@ -235,7 +235,7 @@ var social = require('./social');
|
||||
posts.getPidsFromSet(set, start, stop, reverse, next);
|
||||
},
|
||||
function (pids, next) {
|
||||
if ((!Array.isArray(pids) || !pids.length) && !topic.mainPid) {
|
||||
if (!pids.length && !topic.mainPid) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,16 +200,10 @@ module.exports = function (Topics) {
|
||||
Topics.getFollowers(postData.topic.tid, next);
|
||||
},
|
||||
function (followers, next) {
|
||||
if (!Array.isArray(followers) || !followers.length) {
|
||||
return callback();
|
||||
}
|
||||
var index = followers.indexOf(exceptUid.toString());
|
||||
if (index !== -1) {
|
||||
followers.splice(index, 1);
|
||||
}
|
||||
if (!followers.length) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
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);
|
||||
},
|
||||
function (followers, next) {
|
||||
if (!Array.isArray(followers) || !followers.length) {
|
||||
return;
|
||||
}
|
||||
privileges.categories.filterUids('read', topicData.cid, followers, next);
|
||||
},
|
||||
function (_followers, next) {
|
||||
|
||||
Reference in New Issue
Block a user