Ok I figured out this was a problem in the mongodb layer, with redis when you pass in a string as the increment value it is automatically converted to an int. With mongodb this was throwing an error Uncaught AssertionError: { [MongoError: Cannot increment with non-numeric argument: {value: "11"}]
.
This is fixed in https://github.com/NodeBB/NodeBB/commit/cd9e2d17a37fc19639b31c4ea4e06d14b2730cbe
You can also avoid it by just using parseInt()
before sending the value to incrObjectFieldBy. So just change user.incrementUserFieldBy(postData.uid, 'reputation', settings.reputationAwardAmount, next);
to user.incrementUserFieldBy(postData.uid, 'reputation', parseInt(settings.reputationAwardAmount, 10), next);
As for that entire method, this is how I would write it. Fixing the issue I mentioned above.
plugin.awardReputation = function(postData) {
async.waterfall([
function(next){
meta.settings.get('reputation-for-posting', next);
},
function(settings, next) {
user.incrementUserFieldBy(
postData.uid,
'reputation',
parseInt(settings.reputationAwardAmount, 10),
next
);
},
function(newreputation, next) {
db.sortedSetAdd('users:reputation', newreputation, postData.uid, next);
},
function(next) {
rewards.checkConditionAndRewardUser(postData.uid, 'essentials/user.reputation', function(callback) {
user.getUserField(postData.uid, 'reputation', callback);
}, next);
}
], functon(err) {
if (err) {
winston.error(err);
}
});
};
So that all errors are logged properly, in your case mongodb was sending the error but it was just ignored.