From 54eb078a131e4ac5767e2c2456fd3514eab25b20 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 17 May 2017 09:37:26 -0300 Subject: [PATCH] Working offtopic tag --- graph/mutators/comment.js | 16 ++++++++++++---- .../client/components/OffTopicTag.js | 4 +--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/graph/mutators/comment.js b/graph/mutators/comment.js index 5c39f7b69..4755aa4ac 100644 --- a/graph/mutators/comment.js +++ b/graph/mutators/comment.js @@ -16,16 +16,24 @@ const Wordlist = require('../../services/wordlist'); * @param {String} [status='NONE'] the status of the new comment * @return {Promise} resolves to the created comment */ -const createComment = ({user, loaders: {Comments}, pubsub}, {body, asset_id, parent_id = null}, status = 'NONE') => { +const createComment = ({user, loaders: {Comments}, pubsub}, {tags = [], body, asset_id, parent_id = null}, status = 'NONE') => { + + // Handle Tags + if (!!tags.length) { + tags = tags.map(tag => ({ + tag: { + name: tag + } + })) + } // Add the staff tag for comments created as a staff member. - let tags = []; if (user.hasRoles('ADMIN') || user.hasRoles('MODERATOR')) { - tags = [{ + tags.push({ tag: { name: 'STAFF' } - }]; + }); } return CommentsService.publicCreate({ diff --git a/plugins/coral-plugin-offtopic/client/components/OffTopicTag.js b/plugins/coral-plugin-offtopic/client/components/OffTopicTag.js index 73e2372ed..0b50eb131 100644 --- a/plugins/coral-plugin-offtopic/client/components/OffTopicTag.js +++ b/plugins/coral-plugin-offtopic/client/components/OffTopicTag.js @@ -1,9 +1,7 @@ import React from 'react'; import styles from './styles.css'; -const isOffTopic = (tags) => { - return !!tags.filter(tag => tag.name === 'OFF_TOPIC').length -} +const isOffTopic = tags => !!tags.filter(i => i.tag.name === 'OFF_TOPIC').length; export default (props) => (