mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
closes #1319
This commit is contained in:
16
src/user.js
16
src/user.js
@@ -235,15 +235,25 @@ var bcrypt = require('bcryptjs'),
|
||||
User.onNewPostMade = function(postData) {
|
||||
User.addPostIdToUser(postData.uid, postData.pid, postData.timestamp);
|
||||
|
||||
User.incrementUserFieldBy(postData.uid, 'postcount', 1, function(err, newpostcount) {
|
||||
db.sortedSetAdd('users:postcount', newpostcount, postData.uid);
|
||||
});
|
||||
User.incrementUserPostCountBy(postData.uid, 1);
|
||||
|
||||
User.setUserField(postData.uid, 'lastposttime', postData.timestamp);
|
||||
};
|
||||
|
||||
emitter.on('event:newpost', User.onNewPostMade);
|
||||
|
||||
User.incrementUserPostCountBy = function(uid, value, callback) {
|
||||
User.incrementUserFieldBy(uid, 'postcount', value, function(err, newpostcount) {
|
||||
if (err) {
|
||||
if(typeof callback === 'function') {
|
||||
callback(err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
db.sortedSetAdd('users:postcount', newpostcount, uid, callback);
|
||||
});
|
||||
};
|
||||
|
||||
User.addPostIdToUser = function(uid, pid, timestamp) {
|
||||
db.sortedSetAdd('uid:' + uid + ':posts', timestamp, pid);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user