mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
fix tests, remove dupe exposeUid
This commit is contained in:
@@ -220,6 +220,9 @@ Messaging.getTeaser = function (uid, roomId, callback) {
|
||||
Messaging.getMessageFields(mids[0], ['fromuid', 'content', 'timestamp'], next);
|
||||
},
|
||||
function (teaser, next) {
|
||||
if (!teaser) {
|
||||
return callback();
|
||||
}
|
||||
user.blocks.is(teaser.fromuid, uid, function (err, blocked) {
|
||||
if (err || blocked) {
|
||||
return callback(err);
|
||||
|
||||
@@ -221,17 +221,6 @@ module.exports = function (middleware) {
|
||||
}
|
||||
};
|
||||
|
||||
middleware.exposeUid = function (req, res, next) {
|
||||
if (!req.params.userslug) {
|
||||
return next();
|
||||
}
|
||||
|
||||
user.getUidByUserslug(req.params.userslug, function (err, uid) {
|
||||
res.locals.uid = uid;
|
||||
next(err, uid);
|
||||
});
|
||||
};
|
||||
|
||||
middleware.handleBlocking = function (req, res, next) {
|
||||
user.blocks.is(res.locals.uid, req.uid, function (err, blocked) {
|
||||
if (err) {
|
||||
|
||||
@@ -76,7 +76,7 @@ module.exports = function (User) {
|
||||
property = 'uid';
|
||||
}
|
||||
|
||||
if (!Array.isArray(set) || !(set[0].hasOwnProperty(property) || typeof set[0] === 'number' || typeof set[0] === 'string')) {
|
||||
if (!Array.isArray(set) || !set.length || !(set[0].hasOwnProperty(property) || typeof set[0] === 'number' || typeof set[0] === 'string')) {
|
||||
return callback(null, set);
|
||||
}
|
||||
|
||||
|
||||
@@ -1783,7 +1783,7 @@ describe('User', function () {
|
||||
it('should automatically increment corresponding user field', function (done) {
|
||||
db.getObjectField('user:1', 'blocksCount', function (err, count) {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(count, '1');
|
||||
assert.strictEqual(parseInt(count, 10), 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -1809,7 +1809,7 @@ describe('User', function () {
|
||||
it('should automatically decrement corresponding user field', function (done) {
|
||||
db.getObjectField('user:1', 'blocksCount', function (err, count) {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(count, '0');
|
||||
assert.strictEqual(parseInt(count, 10), 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user