action:user.set change #1527

v1.18.x
barisusakli 10 years ago
parent 2e1a098cfa
commit 9363741231

@ -196,14 +196,14 @@ var async = require('async'),
};
User.setUserField = function(uid, field, value, callback) {
plugins.fireHook('action:user.set', field, value, 'set');
plugins.fireHook('action:user.set', {field: field, value: value, type: 'set'});
db.setObjectField('user:' + uid, field, value, callback);
};
User.setUserFields = function(uid, data, callback) {
for (var field in data) {
if (data.hasOwnProperty(field)) {
plugins.fireHook('action:user.set', field, data[field], 'set');
plugins.fireHook('action:user.set', {field: field, value: data[field], type: 'set'});
}
}
@ -211,22 +211,26 @@ var async = require('async'),
};
User.incrementUserFieldBy = function(uid, field, value, callback) {
callback = callback || function() {};
db.incrObjectFieldBy('user:' + uid, field, value, function(err, value) {
plugins.fireHook('action:user.set', field, value, 'increment');
if (typeof callback === 'function') {
callback(err, value);
if (err) {
return callback(err);
}
plugins.fireHook('action:user.set', {field: field, value: value, type: 'increment'});
callback(null, value);
});
};
User.decrementUserFieldBy = function(uid, field, value, callback) {
callback = callback || function() {};
db.incrObjectFieldBy('user:' + uid, field, -value, function(err, value) {
plugins.fireHook('action:user.set', field, value, 'decrement');
if (typeof callback === 'function') {
callback(err, value);
if (err) {
return callback(err);
}
plugins.fireHook('action:user.set', {field: field, value: value, type: 'decrement'});
callback(null, value);
});
};

Loading…
Cancel
Save