-
chat_bubble person
+
+
+ chat_bubble
+ person
+
{content}
;
diff --git a/client/coral-plugin-replies/ReplyBox.js b/client/coral-plugin-replies/ReplyBox.js
index c50bca124..807ad6699 100644
--- a/client/coral-plugin-replies/ReplyBox.js
+++ b/client/coral-plugin-replies/ReplyBox.js
@@ -1,21 +1,29 @@
-import React, {PropTypes} from 'react';
+import React, {Component, PropTypes} from 'react';
import CommentBox from '../coral-plugin-commentbox/CommentBox';
const name = 'coral-plugin-replies';
-const ReplyBox = ({styles, postItem, assetId, authorId, addNotification, parentId, commentPostedHandler, setActiveReplyBox}) => (
-
-
-
-);
+class ReplyBox extends Component {
+
+ componentDidMount() {
+ document.getElementById('replyText').focus();
+ }
+
+ render() {
+ const {styles, postItem, assetId, authorId, addNotification, parentId, commentPostedHandler, setActiveReplyBox} = this.props;
+ return
+
+
;
+ }
+}
ReplyBox.propTypes = {
setActiveReplyBox: PropTypes.func.isRequired,
diff --git a/client/coral-ui/components/Button.css b/client/coral-ui/components/Button.css
index 9a2611630..14ed64aa2 100644
--- a/client/coral-ui/components/Button.css
+++ b/client/coral-ui/components/Button.css
@@ -9,7 +9,7 @@
min-width: 64px;
padding: 0 8px;
display: inline-block;
- font-family: 'Roboto','Helvetica','Arial',sans-serif;
+ font-family: inherit;
font-size: 14px;
overflow: hidden;
will-change: box-shadow,transform;
diff --git a/graph/mutators/comment.js b/graph/mutators/comment.js
index 553c3f44c..bcab347d7 100644
--- a/graph/mutators/comment.js
+++ b/graph/mutators/comment.js
@@ -3,6 +3,7 @@ const errors = require('../../errors');
const AssetsService = require('../../services/assets');
const ActionsService = require('../../services/actions');
const CommentsService = require('../../services/comments');
+const linkify = require('linkify-it')();
const Wordlist = require('../../services/wordlist');
@@ -54,13 +55,16 @@ const createComment = ({user, loaders: {Comments}}, {body, asset_id, parent_id =
* @param {String} body body of a comment
* @return {Object} resolves to the wordlist results
*/
-const filterNewComment = (context, {body}) => {
+const filterNewComment = (context, {body, asset_id}) => {
// Create a new instance of the Wordlist.
const wl = new Wordlist();
// Load the wordlist and filter the comment content.
- return wl.load().then(() => wl.scan('body', body));
+ return Promise.all([
+ wl.load().then(() => wl.scan('body', body)),
+ AssetsService.rectifySettings(AssetsService.findById(asset_id))
+ ]);
};
/**
@@ -72,7 +76,7 @@ const filterNewComment = (context, {body}) => {
* @param {Object} [wordlist={}] the results of the wordlist scan
* @return {Promise} resolves to the comment's status
*/
-const resolveNewCommentStatus = (context, {asset_id, body}, wordlist = {}) => {
+const resolveNewCommentStatus = (context, {asset_id, body}, wordlist = {}, settings) => {
// Decide the status based on whether or not the current asset/settings
// has pre-mod enabled or not. If the comment was rejected based on the
@@ -82,6 +86,8 @@ const resolveNewCommentStatus = (context, {asset_id, body}, wordlist = {}) => {
if (wordlist.banned) {
status = Promise.resolve('REJECTED');
+ } else if (settings.premodLinksEnable && linkify.test(body)) {
+ status = Promise.resolve('PREMOD');
} else {
status = AssetsService
.rectifySettings(AssetsService.findById(asset_id).then((asset) => {
@@ -131,13 +137,13 @@ const createPublicComment = (context, commentInput) => {
// We then take the wordlist and the comment into consideration when
// considering what status to assign the new comment, and resolve the new
// status to set the comment to.
- .then((wordlist) => resolveNewCommentStatus(context, commentInput, wordlist)
+ .then(([wordlist, settings]) => resolveNewCommentStatus(context, commentInput, wordlist, settings)
// Then we actually create the comment with the new status.
.then((status) => createComment(context, commentInput, status))
.then((comment) => {
- // If the comment was flagged as being suspect, we need to add a
+ // If the comment has a suspect word or a link, we need to add a
// flag to it to indicate that it needs to be looked at.
// Otherwise just return the new comment.
diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql
index daf9edafa..6cb4cb046 100644
--- a/graph/typeDefs.graphql
+++ b/graph/typeDefs.graphql
@@ -370,6 +370,7 @@ type Settings {
infoBoxEnable: Boolean
infoBoxContent: String
+ premodLinksEnable: Boolean
questionBoxEnable: Boolean
questionBoxContent: String
closeTimeout: Int
diff --git a/models/setting.js b/models/setting.js
index 993384ff1..ac54584a4 100644
--- a/models/setting.js
+++ b/models/setting.js
@@ -40,6 +40,10 @@ const SettingSchema = new Schema({
type: String,
default: ''
},
+ premodLinksEnable: {
+ type: Boolean,
+ default: false
+ },
organizationName: {
type: String
},
diff --git a/package.json b/package.json
index f67a36908..92442efd2 100644
--- a/package.json
+++ b/package.json
@@ -70,6 +70,7 @@
"inquirer": "^3.0.1",
"jsonwebtoken": "^7.1.9",
"kue": "^0.11.5",
+ "linkify-it": "^2.0.3",
"lodash": "^4.16.6",
"metascraper": "^1.0.6",
"minimist": "^1.2.0",
diff --git a/test/client/coral-framework/reducers/notificationReducer.spec.js b/test/client/coral-framework/reducers/notificationReducer.spec.js
deleted file mode 100644
index 40c50d11a..000000000
--- a/test/client/coral-framework/reducers/notificationReducer.spec.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import {Map} from 'immutable';
-import {expect} from 'chai';
-import notificationReducer from '../../../../client/coral-framework/reducers/notification';
-import * as actions from '../../../../client/coral-framework/actions/notification';
-
-describe ('notificationsReducer', () => {
- describe('ADD_NOTIFICATION', () => {
- it('should add a notification', () => {
- const action = {
- type: actions.ADD_NOTIFICATION,
- text: 'Test notification',
- notifType: 'test'
- };
- const store = new Map({});
- const result = notificationReducer(store, action);
- expect(result.get('text')).to.equal(action.text);
- expect(result.get('type')).to.equal(action.notifType);
- });
- });
-
- describe('CLEAR_NOTIFICATION', () => {
- it('should clear a notification', () => {
- const action = {
- type: actions.CLEAR_NOTIFICATION
- };
- const store = new Map({
- text: 'Test notification',
- type: 'test'
- });
- const result = notificationReducer(store, action);
- expect(result.get('text')).to.equal('');
- expect(result.get('type')).to.equal('');
- });
- });
-});
diff --git a/test/client/coral-framework/store/notificationReducer.spec.js b/test/client/coral-framework/store/notificationReducer.spec.js
deleted file mode 100644
index 40c50d11a..000000000
--- a/test/client/coral-framework/store/notificationReducer.spec.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import {Map} from 'immutable';
-import {expect} from 'chai';
-import notificationReducer from '../../../../client/coral-framework/reducers/notification';
-import * as actions from '../../../../client/coral-framework/actions/notification';
-
-describe ('notificationsReducer', () => {
- describe('ADD_NOTIFICATION', () => {
- it('should add a notification', () => {
- const action = {
- type: actions.ADD_NOTIFICATION,
- text: 'Test notification',
- notifType: 'test'
- };
- const store = new Map({});
- const result = notificationReducer(store, action);
- expect(result.get('text')).to.equal(action.text);
- expect(result.get('type')).to.equal(action.notifType);
- });
- });
-
- describe('CLEAR_NOTIFICATION', () => {
- it('should clear a notification', () => {
- const action = {
- type: actions.CLEAR_NOTIFICATION
- };
- const store = new Map({
- text: 'Test notification',
- type: 'test'
- });
- const result = notificationReducer(store, action);
- expect(result.get('text')).to.equal('');
- expect(result.get('type')).to.equal('');
- });
- });
-});