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

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

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

@ -83,6 +83,7 @@ var DebugRoute = function(app) {
user.pushNotifCount(2);
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'),
categories = require('./categories'),
CategoryTools = require('./categoryTools'),
user = require('./user'),
async = require('async'),
notifications = require('./notifications'),
posts = require('./posts'),
meta = require('./meta'),
websockets = require('./websockets');
winston = require('winston'),
nconf = require('nconf'),
websockets = require('./websockets'),
events = require('./events');
(function(ThreadTools) {
@ -97,6 +100,8 @@ var db = require('./database'),
db.searchRemove('topic', tid);
events.logTopicDelete(uid, tid);
websockets.in('topic_' + tid).emit('event:topic_deleted', {
tid: tid,
status: 'ok'
@ -112,6 +117,8 @@ var db = require('./database'),
db.incrObjectField('global', 'topicCount');
ThreadTools.unlock(tid);
events.logTopicRestore(uid, tid);
websockets.in('topic_' + tid).emit('event:topic_restored', {
tid: tid,
status: 'ok'

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

Loading…
Cancel
Save