Merge branch 'master' of https://github.com/akhoury/NodeBB into akhoury-master

This commit is contained in:
Baris Soner Usakli
2013-12-20 23:53:53 -05:00
9 changed files with 97 additions and 37 deletions

View File

@@ -205,6 +205,9 @@ var async = require('async'),
}, {
field: 'allowGuestPosting',
value: 0
}, {
field: 'allowGuestSearching',
value: 0
}, {
field: 'minimumTitleLength',
value: 3

View File

@@ -232,7 +232,7 @@ var path = require('path'),
});
app.get('/search', function (req, res) {
if (req.user && req.user.uid) {
if ((req.user && req.user.uid) || meta.config.allowGuestSearching === '1') {
return res.json({
show_no_topics: 'hide',
show_no_posts: 'hide',
@@ -275,7 +275,7 @@ var path = require('path'),
});
}
if (req.user && req.user.uid) {
if ((req.user && req.user.uid) || meta.config.allowGuestSearching === '1') {
async.parallel([searchPosts, searchTopics], function (err, results) {
if (err) {
return next();

View File

@@ -12,7 +12,7 @@ var db = require('./database'),
Upgrade.check = function(callback) {
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
var latestSchema = new Date(2013, 11, 2).getTime();
var latestSchema = new Date(2013, 11, 11).getTime();
db.get('schemaDate', function(err, value) {
if (parseInt(value, 10) >= latestSchema) {
@@ -303,6 +303,23 @@ Upgrade.upgradeRedis = function(callback) {
winston.info('[2013/12/2] Update to global keys skipped');
next();
}
},
function(next) {
thisSchemaDate = new Date(2013, 11, 11).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
RDB.hset('config', 'allowGuestSearching', '0', function(err){
if (err) {
return next(err);
}
winston.info('[2013/12/11] Updated guest search config.');
next();
});
} else {
winston.info('[2013/12/11] Update to guest search skipped');
next();
}
}
// Add new schema updates here
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 12!!!
@@ -333,7 +350,9 @@ Upgrade.upgradeRedis = function(callback) {
};
Upgrade.upgradeMongo = function(callback) {
var MDB = db.client;
// why can't we just use the abstracted db module here? and in upgradeRedis()?
var MDB = db.client,
updatesMade = false;
winston.info('Beginning Mongo database schema update');
@@ -344,6 +363,24 @@ Upgrade.upgradeMongo = function(callback) {
thisSchemaDate = new Date(2013, 11, 6).getTime();
next();
});
},
function(next) {
thisSchemaDate = new Date(2013, 11, 11).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
db.setObjectField('config', 'allowGuestSearching', '0', function(err){
if (err) {
return next(err);
}
winston.info('[2013/12/11] Updated guest search config.');
next();
});
} else {
winston.info('[2013/12/11] Update to guest search skipped');
next();
}
}
// Add new schema updates here
@@ -351,7 +388,11 @@ Upgrade.upgradeMongo = function(callback) {
if (!err) {
db.set('schemaDate', thisSchemaDate, function(err) {
if (!err) {
winston.info('[upgrade] Mongo schema update complete!');
if(updatesMade) {
winston.info('[upgrade] Mongo schema update complete!');
} else {
winston.info('[upgrade] Mongo schema already up to date!');
}
if (callback) {
callback(err);
} else {

View File

@@ -379,7 +379,7 @@ var path = require('path'),
// Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section)
(function () {
var routes = ['login', 'register', 'account', 'recent', '403', '404', '500'],
loginRequired = ['unread', 'search', 'notifications'];
loginRequired = ['unread', 'notifications'];
async.each(routes.concat(loginRequired), function(route, next) {
app.get('/' + route, function (req, res) {
@@ -741,7 +741,7 @@ var path = require('path'),
});
app.get('/search/:term', function (req, res) {
if (!req.user) {
if (!req.user && meta.config.allowGuestSearching !== '1') {
return res.redirect('/403');
}

View File

@@ -236,7 +236,10 @@ websockets.init = function(io) {
email: '',
picture: gravatar.url('', {
s: '24'
}, nconf.get('https'))
}, nconf.get('https')),
config: {
allowGuestSearching: meta.config.allowGuestSearching
}
});
}