mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
closes #3529
This commit is contained in:
@@ -121,7 +121,7 @@ module.exports = function(Topics) {
|
|||||||
return next(new Error('[[error:guest-handle-invalid]]'));
|
return next(new Error('[[error:guest-handle-invalid]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
user.isReadyToPost(data.uid, next);
|
user.isReadyToPost(data.uid, data.cid, next);
|
||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
plugins.fireHook('filter:topic.post', data, next);
|
plugins.fireHook('filter:topic.post', data, next);
|
||||||
@@ -184,22 +184,30 @@ module.exports = function(Topics) {
|
|||||||
content = data.content,
|
content = data.content,
|
||||||
postData;
|
postData;
|
||||||
|
|
||||||
|
var cid;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
|
Topics.getTopicField(tid, 'cid', next);
|
||||||
|
},
|
||||||
|
function(_cid, next) {
|
||||||
|
cid = _cid;
|
||||||
async.parallel({
|
async.parallel({
|
||||||
exists: async.apply(Topics.exists, tid),
|
exists: async.apply(Topics.exists, tid),
|
||||||
locked: async.apply(Topics.isLocked, tid),
|
locked: async.apply(Topics.isLocked, tid),
|
||||||
canReply: async.apply(privileges.topics.can, 'topics:reply', tid, uid),
|
canReply: async.apply(privileges.topics.can, 'topics:reply', tid, uid),
|
||||||
isAdmin: async.apply(user.isAdministrator, uid)
|
isAdmin: async.apply(user.isAdministrator, uid),
|
||||||
|
isModerator: async.apply(user.isModerator, uid, cid)
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function(results, next) {
|
function(results, next) {
|
||||||
if (!results.exists) {
|
if (!results.exists) {
|
||||||
return next(new Error('[[error:no-topic]]'));
|
return next(new Error('[[error:no-topic]]'));
|
||||||
}
|
}
|
||||||
if (results.locked && !results.isAdmin) {
|
|
||||||
|
if (results.locked && !results.isAdmin && !results.isModerator) {
|
||||||
return next(new Error('[[error:topic-locked]]'));
|
return next(new Error('[[error:topic-locked]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!results.canReply) {
|
if (!results.canReply) {
|
||||||
return next(new Error('[[error:no-privileges]]'));
|
return next(new Error('[[error:no-privileges]]'));
|
||||||
}
|
}
|
||||||
@@ -208,7 +216,7 @@ module.exports = function(Topics) {
|
|||||||
return next(new Error('[[error:guest-handle-invalid]]'));
|
return next(new Error('[[error:guest-handle-invalid]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
user.isReadyToPost(uid, next);
|
user.isReadyToPost(uid, cid, next);
|
||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
plugins.fireHook('filter:topic.reply', data, next);
|
plugins.fireHook('filter:topic.reply', data, next);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ var async = require('async'),
|
|||||||
|
|
||||||
module.exports = function(User) {
|
module.exports = function(User) {
|
||||||
|
|
||||||
User.isReadyToPost = function(uid, callback) {
|
User.isReadyToPost = function(uid, cid, callback) {
|
||||||
if (parseInt(uid, 10) === 0) {
|
if (parseInt(uid, 10) === 0) {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,9 @@ module.exports = function(User) {
|
|||||||
},
|
},
|
||||||
isAdmin: function(next) {
|
isAdmin: function(next) {
|
||||||
User.isAdministrator(uid, next);
|
User.isAdministrator(uid, next);
|
||||||
|
},
|
||||||
|
isModerator: function(next) {
|
||||||
|
User.isModerator(uid, cid, next);
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -30,7 +33,7 @@ module.exports = function(User) {
|
|||||||
return callback(new Error('[[error:no-user]]'));
|
return callback(new Error('[[error:no-user]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.isAdmin) {
|
if (results.isAdmin || results.isModerator) {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user