mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +01:00
closes #4800
This commit is contained in:
@@ -150,6 +150,38 @@ module.exports = function(privileges) {
|
||||
});
|
||||
};
|
||||
|
||||
privileges.posts.canDelete = function(pid, uid, callback) {
|
||||
var postData;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
posts.getPostFields(pid, ['tid', 'timestamp'], next);
|
||||
},
|
||||
function(_postData, next) {
|
||||
postData = _postData;
|
||||
async.parallel({
|
||||
isAdminOrMod: async.apply(isAdminOrMod, pid, uid),
|
||||
isLocked: async.apply(topics.isLocked, postData.tid),
|
||||
isOwner: async.apply(posts.isOwner, pid, uid)
|
||||
}, next);
|
||||
}
|
||||
], function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
if (results.isAdminOrMod) {
|
||||
return callback(null, true);
|
||||
}
|
||||
if (results.isLocked) {
|
||||
return callback(new Error('[[error:topic-locked]]'));
|
||||
}
|
||||
var postDeleteDuration = parseInt(meta.config.postDeleteDuration, 10);
|
||||
if (postDeleteDuration && (Date.now() - parseInt(postData.timestamp, 10) > postDeleteDuration * 1000)) {
|
||||
return callback(new Error('[[error:post-delete-duration-expired, ' + meta.config.postDeleteDuration + ']]'));
|
||||
}
|
||||
callback(null, results.isOwner);
|
||||
});
|
||||
};
|
||||
|
||||
privileges.posts.canMove = function(pid, uid, callback) {
|
||||
posts.isMain(pid, function(err, isMain) {
|
||||
if (err || isMain) {
|
||||
|
||||
Reference in New Issue
Block a user