Skip to content

Node.js based forum software built for the modern web

makes recent unread and category pages a lot faster, added logging when a user changes their username

Baris Soner Usaklia97ee201d841
diff --git a/src/events.js b/src/events.js
index 8dfb922dfa..421b57321b 100644
--- a/src/events.js
+++ b/src/events.js
@@ -21,6 +21,10 @@ var fs = require('fs'),
log(uid,'changed email from "' + oldEmail + '" to "' + newEmail +'"');
}
+ events.logUsernameChange = function(uid, oldUsername, newUsername) {
+ log(uid,'changed username from "' + oldUsername + '" to "' + newUsername +'"');
+ }
+
events.logAdminLogin = function(uid) {
log(uid, 'logged into admin panel');
}
diff --git a/src/threadTools.js b/src/threadTools.js
index d0c0960bb1..c5c0f9e647 100644
--- a/src/threadTools.js
+++ b/src/threadTools.js
@@ -285,7 +285,7 @@ var winston = require('winston'),
}
ThreadTools.getLatestUndeletedPid = function(tid, callback) {
- db.getSortedSetRange('tid:' + tid + ':posts', 0, -1, function(err, pids) {
+ db.getSortedSetRevRange('tid:' + tid + ':posts', 0, -1, function(err, pids) {
if(err) {
return callback(err);
}
@@ -293,14 +293,9 @@ var winston = require('winston'),
return callback(new Error('no-undeleted-pids-found'));
}
- pids.reverse();
async.detectSeries(pids, function(pid, next) {
posts.getPostField(pid, 'deleted', function(err, deleted) {
- if (parseInt(deleted, 10) === 0) {
- next(true);
- } else {
- next(false);
- }
+ next(parseInt(deleted, 10) === 0);
});
}, function(pid) {
if (pid) {
diff --git a/src/topics.js b/src/topics.js
index 970a3c65aa..7f76f181ac 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -982,7 +982,7 @@ var async = require('async'),
return callback(err, null);
}
- posts.getPostFields(pid, ['pid', 'content', 'uid', 'timestamp'], function(err, postData) {
+ posts.getPostFields(pid, ['pid', 'uid', 'timestamp'], function(err, postData) {
if (err) {
return callback(err, null);
} else if(!postData) {
@@ -994,26 +994,13 @@ var async = require('async'),
return callback(err, null);
}
- var stripped = postData.content,
- timestamp = postData.timestamp,
- returnObj = {
- "pid": postData.pid,
- "username": userData.username || 'anonymous',
- "userslug": userData.userslug,
- "picture": userData.picture || gravatar.url('', {}, https = nconf.get('https')),
- "timestamp": timestamp
- };
-
- if (postData.content) {
- stripped = postData.content.replace(/>.+\n\n/, '');
- postTools.parse(stripped, function(err, stripped) {
- returnObj.text = S(stripped).stripTags().s;
- callback(null, returnObj);
- });
- } else {
- returnObj.text = '';
- callback(null, returnObj);
- }
+ callback(null, {
+ pid: postData.pid,
+ username: userData.username || 'anonymous',
+ userslug: userData.userslug,
+ picture: userData.picture || gravatar.url('', {}, https = nconf.get('https')),
+ timestamp: postData.timestamp
+ });
});
});
});
diff --git a/src/user.js b/src/user.js
index 46036d07cf..96e8244eb0 100644
--- a/src/user.js
+++ b/src/user.js
@@ -312,6 +312,7 @@ var bcrypt = require('bcrypt'),
db.searchRemove('user', uid, function() {
db.searchIndex('user', data.username, uid);
});
+ events.logUsernameChange(uid, userData.username, data.username);
}
if(userslug !== userData.userslug) {