mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +01:00
Parse int (#6853)
* 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:
committed by
GitHub
parent
60c58870af
commit
9c022afae1
@@ -10,7 +10,6 @@ var topics = require('../topics');
|
||||
var user = require('../user');
|
||||
var helpers = require('./helpers');
|
||||
var plugins = require('../plugins');
|
||||
var utils = require('../utils');
|
||||
|
||||
module.exports = function (privileges) {
|
||||
privileges.posts = {};
|
||||
@@ -184,7 +183,7 @@ module.exports = function (privileges) {
|
||||
return next(null, { flag: false, message: '[[error:no-privileges]]' });
|
||||
}
|
||||
|
||||
var postDeleteDuration = parseInt(meta.config.postDeleteDuration, 10);
|
||||
var postDeleteDuration = meta.config.postDeleteDuration;
|
||||
if (postDeleteDuration && (Date.now() - parseInt(postData.timestamp, 10) > postDeleteDuration * 1000)) {
|
||||
return next(null, { flag: false, message: '[[error:post-delete-duration-expired, ' + meta.config.postDeleteDuration + ']]' });
|
||||
}
|
||||
@@ -204,8 +203,8 @@ module.exports = function (privileges) {
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
var minimumReputation = utils.isNumber(meta.config['min:rep:flag']) ? parseInt(meta.config['min:rep:flag'], 10) : 0;
|
||||
var canFlag = results.isAdminOrMod || parseInt(results.userReputation, 10) >= minimumReputation;
|
||||
var minimumReputation = meta.config['min:rep:flag'];
|
||||
var canFlag = results.isAdminOrMod || (results.userReputation >= minimumReputation);
|
||||
next(null, { flag: canFlag });
|
||||
},
|
||||
], callback);
|
||||
@@ -249,8 +248,8 @@ module.exports = function (privileges) {
|
||||
posts.getPostFields(pid, ['tid', 'timestamp'], next);
|
||||
},
|
||||
function (postData, next) {
|
||||
var postEditDuration = parseInt(meta.config.postEditDuration, 10);
|
||||
if (postEditDuration && Date.now() - parseInt(postData.timestamp, 10) > postEditDuration * 1000) {
|
||||
var postEditDuration = meta.config.postEditDuration;
|
||||
if (postEditDuration && (Date.now() - postData.timestamp > postEditDuration * 1000)) {
|
||||
return callback(null, { flag: false, message: '[[error:post-edit-duration-expired, ' + meta.config.postEditDuration + ']]' });
|
||||
}
|
||||
topics.isLocked(postData.tid, next);
|
||||
|
||||
Reference in New Issue
Block a user