mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
closes #5692
This commit is contained in:
@@ -129,7 +129,13 @@ module.exports = function (redisClient, module) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
redisClient.zscore(key, value, function (err, score) {
|
redisClient.zscore(key, value, function (err, score) {
|
||||||
callback(err, !err ? parseFloat(score) : null);
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
if (score === null) {
|
||||||
|
return callback(null, score);
|
||||||
|
}
|
||||||
|
callback(null, parseFloat(score));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ module.exports = function (User) {
|
|||||||
async.waterfall([
|
async.waterfall([
|
||||||
async.apply(User.getUserFields, uid, ['banned', 'banned:expire']),
|
async.apply(User.getUserFields, uid, ['banned', 'banned:expire']),
|
||||||
function (userData, next) {
|
function (userData, next) {
|
||||||
var banned = parseInt(userData.banned, 10) === 1;
|
var banned = userData && parseInt(userData.banned, 10) === 1;
|
||||||
if (!banned) {
|
if (!banned) {
|
||||||
return next(null, banned);
|
return next(null, banned);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,6 +190,15 @@ describe('Hash methods', function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return undefined for all fields if object does not exist', function (done) {
|
||||||
|
db.getObjectsFields(['doesnotexist1', 'doesnotexist2'], ['name', 'age'], function (err, data) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(data.name, null);
|
||||||
|
assert.equal(data.age, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getObjectKeys()', function () {
|
describe('getObjectKeys()', function () {
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ describe('Sorted Set methods', function () {
|
|||||||
assert.equal(err, null);
|
assert.equal(err, null);
|
||||||
assert.equal(arguments.length, 2);
|
assert.equal(arguments.length, 2);
|
||||||
assert.equal(!!score, false);
|
assert.equal(!!score, false);
|
||||||
|
assert.strictEqual(score, null);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -312,6 +313,7 @@ describe('Sorted Set methods', function () {
|
|||||||
assert.equal(err, null);
|
assert.equal(err, null);
|
||||||
assert.equal(arguments.length, 2);
|
assert.equal(arguments.length, 2);
|
||||||
assert.equal(!!score, false);
|
assert.equal(!!score, false);
|
||||||
|
assert.strictEqual(score, null);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user