Implement obfuscation behaviour

This commit is contained in:
Robert Schäfer 2019-03-13 21:03:40 +01:00
parent d71cb16a01
commit a252879964

View File

@ -13,13 +13,14 @@ const setDefaultFilters = (resolve, root, args, context, info) => {
return resolve(root, args, context, info)
}
const hideDisabledComments = async (resolve, root, args, context, info) => {
const { comments } = root
if (!Array.isArray(comments)) return resolve(root, args, context, info)
if (!isModerator(context)) {
root.comments = comments.filter((comment) => {
return !comment.disabled
})
const obfuscateDisabled = async (resolve, root, args, context, info) => {
if (!isModerator(context) && root.disabled) {
root.content = 'DELETED'
root.contentExcerpt = 'DELETED'
root.title = 'DELETED'
root.image = 'DELETED'
root.avatar = 'DELETED'
root.about = 'DELETED'
}
return resolve(root, args, context, info)
}
@ -38,6 +39,7 @@ export default {
}
return resolve(root, args, context, info)
},
Post: hideDisabledComments,
User: hideDisabledComments
Post: obfuscateDisabled,
User: obfuscateDisabled,
Comment: obfuscateDisabled
}