* Store config fields as JSON in the db

Fewer parseInts

* Remove unnecessary parseInts

* remove some dupe code add tests

* remove console.log

* remove more parseInts

* WIP: read meta.configs defaults from defaults.json

remove more parseInts

* more work

* add log for failing test

* update admin pwd

* fix tests, dont require posts/cache before configs are initialized

* handle saves

* Test boolean conditions

* remove more parseInts

* Fix boolean values

* remove lots more parseInts

* removed json parsing

* renamed var to number

* categories dont have timestamp
This commit is contained in:
Barış Soner Uşaklı
2018-10-21 16:47:51 -04:00
committed by GitHub
parent 60c58870af
commit 9c022afae1
89 changed files with 440 additions and 309 deletions

View File

@@ -12,7 +12,7 @@ module.exports = function (Posts) {
var votesInProgress = {};
Posts.upvote = function (pid, uid, callback) {
if (parseInt(meta.config['reputation:disabled'], 10) === 1) {
if (meta.config['reputation:disabled']) {
return callback(new Error('[[error:reputation-system-disabled]]'));
}
@@ -40,11 +40,11 @@ module.exports = function (Posts) {
};
Posts.downvote = function (pid, uid, callback) {
if (parseInt(meta.config['reputation:disabled'], 10) === 1) {
if (meta.config['reputation:disabled']) {
return callback(new Error('[[error:reputation-system-disabled]]'));
}
if (parseInt(meta.config['downvote:disabled'], 10) === 1) {
if (meta.config['downvote:disabled']) {
return callback(new Error('[[error:downvoting-disabled]]'));
}
@@ -179,7 +179,7 @@ module.exports = function (Posts) {
return callback(new Error('[[error:self-vote]]'));
}
if (command === 'downvote' && parseInt(results.reputation, 10) < parseInt(meta.config['min:rep:downvote'], 10)) {
if (command === 'downvote' && results.reputation < meta.config['min:rep:downvote']) {
return callback(new Error('[[error:not-enough-reputation-to-downvote]]'));
}