mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
dont call db for guests
This commit is contained in:
@@ -173,37 +173,37 @@ module.exports = function (Topics) {
|
|||||||
db.isSetMembers('tid:' + tid + ':ignorers', uids, next);
|
db.isSetMembers('tid:' + tid + ':ignorers', uids, next);
|
||||||
},
|
},
|
||||||
function (isIgnoring, next) {
|
function (isIgnoring, next) {
|
||||||
var readingUids = uids.filter(function (uid, index) {
|
const readingUids = uids.filter((uid, index) => uid && !isIgnoring[index]);
|
||||||
return uid && !isIgnoring[index];
|
|
||||||
});
|
|
||||||
next(null, readingUids);
|
next(null, readingUids);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.filterWatchedTids = function (tids, uid, callback) {
|
Topics.filterWatchedTids = function (tids, uid, callback) {
|
||||||
|
if (parseInt(uid, 10) <= 0) {
|
||||||
|
return setImmediate(callback, null, []);
|
||||||
|
}
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetScores('uid:' + uid + ':followed_tids', tids, next);
|
db.sortedSetScores('uid:' + uid + ':followed_tids', tids, next);
|
||||||
},
|
},
|
||||||
function (scores, next) {
|
function (scores, next) {
|
||||||
tids = tids.filter(function (tid, index) {
|
tids = tids.filter((tid, index) => tid && !!scores[index]);
|
||||||
return tid && !!scores[index];
|
|
||||||
});
|
|
||||||
next(null, tids);
|
next(null, tids);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.filterNotIgnoredTids = function (tids, uid, callback) {
|
Topics.filterNotIgnoredTids = function (tids, uid, callback) {
|
||||||
|
if (parseInt(uid, 10) <= 0) {
|
||||||
|
return setImmediate(callback, null, tids);
|
||||||
|
}
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetScores('uid:' + uid + ':ignored_tids', tids, next);
|
db.sortedSetScores('uid:' + uid + ':ignored_tids', tids, next);
|
||||||
},
|
},
|
||||||
function (scores, next) {
|
function (scores, next) {
|
||||||
tids = tids.filter(function (tid, index) {
|
tids = tids.filter((tid, index) => tid && !scores[index]);
|
||||||
return tid && !scores[index];
|
|
||||||
});
|
|
||||||
next(null, tids);
|
next(null, tids);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -516,14 +516,15 @@ module.exports = function (Topics) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topics.filterNewTids = function (tids, uid, callback) {
|
Topics.filterNewTids = function (tids, uid, callback) {
|
||||||
|
if (parseInt(uid, 10) <= 0) {
|
||||||
|
return setImmediate(callback, null, []);
|
||||||
|
}
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetScores('uid:' + uid + ':tids_read', tids, next);
|
db.sortedSetScores('uid:' + uid + ':tids_read', tids, next);
|
||||||
},
|
},
|
||||||
function (scores, next) {
|
function (scores, next) {
|
||||||
tids = tids.filter(function (tid, index) {
|
tids = tids.filter((tid, index) => tid && !scores[index]);
|
||||||
return tid && !scores[index];
|
|
||||||
});
|
|
||||||
next(null, tids);
|
next(null, tids);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
@@ -535,9 +536,7 @@ module.exports = function (Topics) {
|
|||||||
db.sortedSetScores('topics:posts', tids, next);
|
db.sortedSetScores('topics:posts', tids, next);
|
||||||
},
|
},
|
||||||
function (scores, next) {
|
function (scores, next) {
|
||||||
tids = tids.filter(function (tid, index) {
|
tids = tids.filter((tid, index) => tid && scores[index] <= 1);
|
||||||
return tid && scores[index] <= 1;
|
|
||||||
});
|
|
||||||
next(null, tids);
|
next(null, tids);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user