diff --git a/server/services/comments/comments.hooks.js b/server/services/comments/comments.hooks.js index a6fdc5d..841fd02 100644 --- a/server/services/comments/comments.hooks.js +++ b/server/services/comments/comments.hooks.js @@ -37,10 +37,10 @@ const xssFields = ['content', 'contentExcerpt']; module.exports = { before: { all: [ - softDelete(), xss({ fields: xssFields }) ], find: [ + softDelete(), // We want to deleted comments to show up iff( hook => hook.params.headers && hook.params.headers.authorization, @@ -52,12 +52,14 @@ module.exports = { } ], get: [ + softDelete(), iff( hook => hook.params.headers && hook.params.headers.authorization, authenticate('jwt') ) ], create: [ + softDelete(), authenticate('jwt'), // Allow seeder to seed comments unless(isProvider('server'), @@ -67,6 +69,7 @@ module.exports = { createExcerpt({ length: 180 }) ], update: [ + softDelete(), authenticate('jwt'), unless(isProvider('server'), isVerified(), @@ -76,6 +79,7 @@ module.exports = { setNow('updatedAt') ], patch: [ + softDelete(), authenticate('jwt'), unless(isProvider('server'), isVerified(), @@ -101,11 +105,18 @@ module.exports = { }) ], remove: [ - authenticate('jwt'), - unless(isProvider('server'), - unless(isModerator(), + iff(isProvider('server'), + softDelete(), + authenticate('jwt') + ).else( // isProvider == false + iff(isModerator(), + softDelete(), + authenticate('jwt') + ).else( // isModerator == false + authenticate('jwt'), isVerified(), - restrictToOwner() + restrictToOwner(), + softDelete() ) ) ]