mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-21 16:00:26 +01:00
closes #6137
This commit is contained in:
@@ -37,5 +37,6 @@
|
|||||||
"unreadCutoff": 2,
|
"unreadCutoff": 2,
|
||||||
"bookmarkThreshold": 5,
|
"bookmarkThreshold": 5,
|
||||||
"topicsPerList": 20,
|
"topicsPerList": 20,
|
||||||
"autoDetectLang": 1
|
"autoDetectLang": 1,
|
||||||
|
"privileges:flag": 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ Flags.validate = function (payload, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1;
|
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 0;
|
||||||
// Check if reporter meets rep threshold (or can edit the target post, in which case threshold does not apply)
|
// Check if reporter meets rep threshold (or can edit the target post, in which case threshold does not apply)
|
||||||
if (!editable.flag && parseInt(data.reporter.reputation, 10) < minimumReputation) {
|
if (!editable.flag && parseInt(data.reporter.reputation, 10) < minimumReputation) {
|
||||||
return callback(new Error('[[error:not-enough-reputation-to-flag]]'));
|
return callback(new Error('[[error:not-enough-reputation-to-flag]]'));
|
||||||
@@ -257,7 +257,7 @@ Flags.validate = function (payload, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1;
|
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 0;
|
||||||
// Check if reporter meets rep threshold (or can edit the target user, in which case threshold does not apply)
|
// Check if reporter meets rep threshold (or can edit the target user, in which case threshold does not apply)
|
||||||
if (!editable && parseInt(data.reporter.reputation, 10) < minimumReputation) {
|
if (!editable && parseInt(data.reporter.reputation, 10) < minimumReputation) {
|
||||||
return callback(new Error('[[error:not-enough-reputation-to-flag]]'));
|
return callback(new Error('[[error:not-enough-reputation-to-flag]]'));
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ module.exports = function (privileges) {
|
|||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1;
|
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 0;
|
||||||
var canFlag = results.isAdminOrMod || parseInt(results.userReputation, 10) >= minimumReputation;
|
var canFlag = results.isAdminOrMod || parseInt(results.userReputation, 10) >= minimumReputation;
|
||||||
next(null, { flag: canFlag });
|
next(null, { flag: canFlag });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ var topics = require('../src/topics');
|
|||||||
var user = require('../src/user');
|
var user = require('../src/user');
|
||||||
var groups = require('../src/groups');
|
var groups = require('../src/groups');
|
||||||
var helpers = require('./helpers');
|
var helpers = require('./helpers');
|
||||||
|
var meta = require('../src/meta');
|
||||||
|
|
||||||
describe('Admin Controllers', function () {
|
describe('Admin Controllers', function () {
|
||||||
var tid;
|
var tid;
|
||||||
@@ -491,7 +492,6 @@ describe('Admin Controllers', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should load /recent in maintenance mode', function (done) {
|
it('should load /recent in maintenance mode', function (done) {
|
||||||
var meta = require('../src/meta');
|
|
||||||
meta.config.maintenanceMode = 1;
|
meta.config.maintenanceMode = 1;
|
||||||
request(nconf.get('url') + '/api/recent', { jar: jar, json: true }, function (err, res, body) {
|
request(nconf.get('url') + '/api/recent', { jar: jar, json: true }, function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
@@ -554,15 +554,16 @@ describe('Admin Controllers', function () {
|
|||||||
|
|
||||||
it('should error with not enough reputation to flag', function (done) {
|
it('should error with not enough reputation to flag', function (done) {
|
||||||
var socketFlags = require('../src/socket.io/flags');
|
var socketFlags = require('../src/socket.io/flags');
|
||||||
|
var oldValue = meta.config['privileges:flag'];
|
||||||
|
meta.config['privileges:flag'] = 1000;
|
||||||
socketFlags.create({ uid: regularUid }, { id: pid, type: 'post', reason: 'spam' }, function (err) {
|
socketFlags.create({ uid: regularUid }, { id: pid, type: 'post', reason: 'spam' }, function (err) {
|
||||||
assert.equal(err.message, '[[error:not-enough-reputation-to-flag]]');
|
assert.equal(err.message, '[[error:not-enough-reputation-to-flag]]');
|
||||||
|
meta.config['privileges:flag'] = oldValue;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return flag details', function (done) {
|
it('should return flag details', function (done) {
|
||||||
var meta = require('../src/meta');
|
|
||||||
var socketFlags = require('../src/socket.io/flags');
|
var socketFlags = require('../src/socket.io/flags');
|
||||||
var oldValue = meta.config['privileges:flag'];
|
var oldValue = meta.config['privileges:flag'];
|
||||||
meta.config['privileges:flag'] = 0;
|
meta.config['privileges:flag'] = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user