Merge branch 'master' into subscriptions

This commit is contained in:
Wyatt Johnson
2017-04-18 15:43:25 -06:00
33 changed files with 392 additions and 104 deletions
+6 -3
View File
@@ -16,11 +16,14 @@ 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}, {body, asset_id, parent_id = null, tags = []}, status = 'NONE') => {
let tags = [];
// Building array of tags
tags = tags.map(tag => ({name: tag}));
// If admin or moderator, adding STAFF tag
if (user.hasRoles('ADMIN') || user.hasRoles('MODERATOR')) {
tags = [{name: 'STAFF'}];
tags.push({name: 'STAFF'});
}
return CommentsService.publicCreate({
+2 -2
View File
@@ -2,8 +2,8 @@ const wrapResponse = require('../helpers/response');
const CommentsService = require('../../services/comments');
const RootMutation = {
createComment(_, {asset_id, parent_id, body}, {mutators: {Comment}}) {
return wrapResponse('comment')(Comment.create({asset_id, parent_id, body}));
createComment(_, {comment}, {mutators: {Comment}}) {
return wrapResponse('comment')(Comment.create(comment));
},
createLike(_, {like: {item_id, item_type}}, {mutators: {Action}}) {
return wrapResponse('like')(Action.create({item_id, item_type, action_type: 'LIKE'}));
+21 -1
View File
@@ -602,6 +602,26 @@ input CreateLikeInput {
item_type: ACTION_ITEM_TYPE!
}
enum TAG_TYPE {
STAFF
}
input CreateCommentInput {
# The asset id
asset_id: ID!
# The id of the parent comment
parent_id: ID
# The body of the comment
body: String!
# Tags
tags: [TAG_TYPE]
}
type CreateLikeResponse implements Response {
# The like that was created.
@@ -728,7 +748,7 @@ type StopIgnoringUserResponse implements Response {
type RootMutation {
# Creates a comment on the asset.
createComment(asset_id: ID!, parent_id: ID, body: String!): CreateCommentResponse
createComment(comment: CreateCommentInput!): CreateCommentResponse
# Creates a like on an entity.
createLike(like: CreateLikeInput!): CreateLikeResponse