v1.18.x
Baris Soner Usakli 11 years ago
parent 845e5e7986
commit 3a00c177d3

@ -1,17 +1,17 @@
var db = require('./database'), var winston = require('winston'),
async = require('async'),
nconf = require('nconf'),
validator = require('validator'),
db = require('./database'),
posts = require('./posts'), posts = require('./posts'),
topics = require('./topics'), topics = require('./topics'),
threadTools = require('./threadTools'), threadTools = require('./threadTools'),
user = require('./user'), user = require('./user'),
websockets = require('./websockets'), websockets = require('./websockets'),
async = require('async'),
nconf = require('nconf'),
validator = require('validator'),
utils = require('../public/src/utils'), utils = require('../public/src/utils'),
plugins = require('./plugins'), plugins = require('./plugins'),
events = require('./events'),
winston = require('winston'),
meta = require('./meta'), meta = require('./meta'),
Feed = require('./feed'); Feed = require('./feed');
@ -70,20 +70,13 @@ var db = require('./database'),
PostTools.edit = function(uid, pid, title, content) { PostTools.edit = function(uid, pid, title, content) {
var success = function() { var success = function() {
async.waterfall([ posts.setPostFields(pid, {
function(next) { edited: Date.now(),
posts.setPostField(pid, 'edited', Date.now()); editor: uid,
next(null); content: content
}, });
function(next) {
posts.setPostField(pid, 'editor', uid); events.logPostEdit(uid, pid);
next(null);
},
function(next) {
posts.setPostField(pid, 'content', content);
next(null);
}
]);
db.searchRemove('post', pid, function() { db.searchRemove('post', pid, function() {
db.searchIndex('post', content, pid); db.searchIndex('post', content, pid);
@ -136,6 +129,8 @@ var db = require('./database'),
db.decrObjectField('global', 'postCount'); db.decrObjectField('global', 'postCount');
db.searchRemove('post', pid); db.searchRemove('post', pid);
events.logPostDelete(uid, pid);
posts.getPostFields(pid, ['tid', 'uid'], function(err, postData) { posts.getPostFields(pid, ['tid', 'uid'], function(err, postData) {
db.incrObjectFieldBy('topic:' + postData.tid, 'postcount', -1); db.incrObjectFieldBy('topic:' + postData.tid, 'postcount', -1);
@ -190,6 +185,8 @@ var db = require('./database'),
posts.setPostField(pid, 'deleted', 0); posts.setPostField(pid, 'deleted', 0);
db.incrObjectField('global', 'postCount'); db.incrObjectField('global', 'postCount');
events.logPostRestore(uid, pid);
posts.getPostFields(pid, ['tid', 'uid', 'content'], function(err, postData) { posts.getPostFields(pid, ['tid', 'uid', 'content'], function(err, postData) {
db.incrObjectFieldBy('topic:' + postData.tid, 'postcount', 1); db.incrObjectFieldBy('topic:' + postData.tid, 'postcount', 1);

@ -332,7 +332,7 @@ var db = require('./database'),
callback(null, newData); callback(null, newData);
}); });
}); });
} };
Posts.getPostFields = function(pid, fields, callback) { Posts.getPostFields = function(pid, fields, callback) {
db.getObjectFields('post:' + pid, fields, function(err, data) { db.getObjectFields('post:' + pid, fields, function(err, data) {
@ -352,7 +352,7 @@ var db = require('./database'),
callback(null, data); callback(null, data);
}); });
}); });
} };
Posts.getPostField = function(pid, field, callback) { Posts.getPostField = function(pid, field, callback) {
Posts.getPostFields(pid, [field], function(err, data) { Posts.getPostFields(pid, [field], function(err, data) {
@ -362,7 +362,7 @@ var db = require('./database'),
callback(null, data[field]); callback(null, data[field]);
}); });
} };
Posts.setPostField = function(pid, field, value, callback) { Posts.setPostField = function(pid, field, value, callback) {
db.setObjectField('post:' + pid, field, value, callback); db.setObjectField('post:' + pid, field, value, callback);
@ -371,7 +371,11 @@ var db = require('./database'),
'field': field, 'field': field,
'value': value 'value': value
}); });
} };
Posts.setPostFields = function(pid, data, callback) {
db.setObject('post:' + pid, data, callback);
};
Posts.getPostsByPids = function(pids, callback) { Posts.getPostsByPids = function(pids, callback) {
var keys = []; var keys = [];

@ -102,6 +102,7 @@
} }
passport.serializeUser(function(user, done) { passport.serializeUser(function(user, done) {
console.log('serializeUser');
done(null, user.uid); done(null, user.uid);
}); });

@ -83,6 +83,7 @@ var DebugRoute = function(app) {
user.pushNotifCount(2); user.pushNotifCount(2);
res.send(); res.send();
}); });
}); });
}; };

@ -1,15 +1,18 @@
var db = require('./database'), var winston = require('winston'),
nconf = require('nconf'),
async = require('async'),
db = require('./database'),
topics = require('./topics'), topics = require('./topics'),
categories = require('./categories'), categories = require('./categories'),
CategoryTools = require('./categoryTools'), CategoryTools = require('./categoryTools'),
user = require('./user'), user = require('./user'),
async = require('async'),
notifications = require('./notifications'), notifications = require('./notifications'),
posts = require('./posts'), posts = require('./posts'),
meta = require('./meta'), meta = require('./meta'),
websockets = require('./websockets'); websockets = require('./websockets'),
winston = require('winston'), events = require('./events');
nconf = require('nconf'),
(function(ThreadTools) { (function(ThreadTools) {
@ -97,6 +100,8 @@ var db = require('./database'),
db.searchRemove('topic', tid); db.searchRemove('topic', tid);
events.logTopicDelete(uid, tid);
websockets.in('topic_' + tid).emit('event:topic_deleted', { websockets.in('topic_' + tid).emit('event:topic_deleted', {
tid: tid, tid: tid,
status: 'ok' status: 'ok'
@ -112,6 +117,8 @@ var db = require('./database'),
db.incrObjectField('global', 'topicCount'); db.incrObjectField('global', 'topicCount');
ThreadTools.unlock(tid); ThreadTools.unlock(tid);
events.logTopicRestore(uid, tid);
websockets.in('topic_' + tid).emit('event:topic_restored', { websockets.in('topic_' + tid).emit('event:topic_restored', {
tid: tid, tid: tid,
status: 'ok' status: 'ok'

@ -15,6 +15,7 @@ var bcrypt = require('bcrypt'),
groups = require('./groups'), groups = require('./groups'),
notifications = require('./notifications'), notifications = require('./notifications'),
topics = require('./topics'), topics = require('./topics'),
events = require('./events'),
websockets = require('./websockets'); websockets = require('./websockets');
@ -260,6 +261,7 @@ var bcrypt = require('bcrypt'),
User.setUserField(uid, 'picture', gravatarpicture); User.setUserField(uid, 'picture', gravatarpicture);
} }
returnData.gravatarpicture = gravatarpicture; returnData.gravatarpicture = gravatarpicture;
events.logEmailChange(uid, userData.email, data.email);
next(null); next(null);
}); });
return; return;
@ -302,7 +304,7 @@ var bcrypt = require('bcrypt'),
if (res) { if (res) {
User.hashPassword(data.newPassword, function(err, hash) { User.hashPassword(data.newPassword, function(err, hash) {
User.setUserField(uid, 'password', hash); User.setUserField(uid, 'password', hash);
events.logPasswordChange(uid);
callback(null); callback(null);
}); });
} else { } else {
@ -809,6 +811,7 @@ var bcrypt = require('bcrypt'),
User.hashPassword(password, function(err, hash) { User.hashPassword(password, function(err, hash) {
User.setUserField(uid, 'password', hash); User.setUserField(uid, 'password', hash);
events.logPasswordReset(uid);
}); });
db.deleteObjectField('reset:uid', code); db.deleteObjectField('reset:uid', code);

Loading…
Cancel
Save