check post exists before delete restore

This commit is contained in:
barisusakli
2015-10-02 16:44:48 -04:00
parent f88d822fe2
commit b301daf126

View File

@@ -19,6 +19,12 @@ module.exports = function(Posts) {
function togglePostDelete(uid, pid, isDelete, callback) {
async.waterfall([
function (next) {
Posts.exists(pid, next);
},
function (exists, next) {
if (!exists) {
return next(new Error('[[error:no-post]]'));
}
Posts.getPostField(pid, 'deleted', next);
},
function (deleted, next) {