mirror of
https://github.com/wassname/talk.git
synced 2026-07-20 12:40:47 +08:00
Working offtopic tag
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user