Working offtopic tag

This commit is contained in:
Belen Curcio
2017-05-17 09:37:26 -03:00
parent 793f634959
commit 54eb078a13
2 changed files with 13 additions and 7 deletions
+12 -4
View File
@@ -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({
@@ -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) => (
<span>