Changed new comment's status from null to NONE.

This commit is contained in:
Wyatt Johnson
2017-02-15 13:21:15 -07:00
parent 5b16df44ed
commit 57d4f9d757
7 changed files with 25 additions and 16 deletions
+3 -3
View File
@@ -18,7 +18,7 @@ const getCountsByAssetID = (context, asset_ids) => {
$in: asset_ids
},
status: {
$in: [null, 'ACCEPTED']
$in: ['NONE', 'ACCEPTED']
},
parent_id: null
}
@@ -51,7 +51,7 @@ const getCountsByParentID = (context, parent_ids) => {
$in: parent_ids
},
status: {
$in: [null, 'ACCEPTED']
$in: ['NONE', 'ACCEPTED']
}
}
},
@@ -88,7 +88,7 @@ const getCommentsByQuery = ({user}, {ids, statuses, asset_id, parent_id, author_
} else {
comments = comments.where({
status: {
$in: [null, 'ACCEPTED']
$in: ['NONE', 'ACCEPTED']
}
});
}
+3 -3
View File
@@ -11,10 +11,10 @@ const Wordlist = require('../../services/wordlist');
* @param {String} body body of the comment
* @param {String} asset_id asset for the comment
* @param {String} parent_id optional parent of the comment
* @param {String} [status=null] the status of the new comment
* @param {String} [status='NONE'] the status of the new comment
* @return {Promise} resolves to the created comment
*/
const createComment = ({user, loaders: {Comments}}, {body, asset_id, parent_id = null}, status = null) => {
const createComment = ({user, loaders: {Comments}}, {body, asset_id, parent_id = null}, status = 'NONE') => {
return CommentsService.publicCreate({
body,
asset_id,
@@ -105,7 +105,7 @@ const resolveNewCommentStatus = (context, {asset_id, body}, wordlist = {}) => {
if (charCountEnable && body.length > charCount) {
return 'REJECTED';
}
return moderation === 'PRE' ? 'PREMOD' : null;
return moderation === 'PRE' ? 'PREMOD' : 'NONE';
});
}
+6 -2
View File
@@ -67,6 +67,10 @@ type Tag {
# The statuses that a comment may have.
enum COMMENT_STATUS {
# The comment is not PREMOD, but was not applied a moderation status by a
# moderator.
NONE
# The comment has been accepted by a moderator.
ACCEPTED
@@ -93,7 +97,7 @@ enum ACTION_TYPE {
input CommentsQuery {
# current status of a comment.
statuses: [COMMENT_STATUS]
statuses: [COMMENT_STATUS!]
# asset that a comment is on.
asset_id: ID
@@ -152,7 +156,7 @@ type Comment {
asset: Asset
# The current status of a comment.
status: COMMENT_STATUS
status: COMMENT_STATUS!
# The time when the comment was created
created_at: Date!
+6 -2
View File
@@ -6,7 +6,7 @@ const STATUSES = [
'ACCEPTED',
'REJECTED',
'PREMOD',
null
'NONE'
];
/**
@@ -66,7 +66,11 @@ const CommentSchema = new Schema({
asset_id: String,
author_id: String,
status_history: [StatusSchema],
status: {type: String, default: null},
status: {
type: String,
enum: STATUSES,
default: 'NONE'
},
tags: [TagSchema],
parent_id: String
}, {
+1 -1
View File
@@ -52,7 +52,7 @@ router.get('/', (req, res, next) => {
if (user_id) {
query = CommentsService.findByUserId(user_id, authorization.has(req.user, 'ADMIN'));
} else if (status) {
query = assetIDWrap(CommentsService.findByStatus(status === 'NEW' ? null : status));
query = assetIDWrap(CommentsService.findByStatus(status === 'NEW' ? 'NONE' : status));
} else if (action_type) {
query = CommentsService
.findIdsByActionType(action_type)
+4 -3
View File
@@ -11,6 +11,7 @@ const STATUSES = [
'ACCEPTED',
'REJECTED',
'PREMOD',
'NONE',
];
module.exports = class CommentsService {
@@ -31,7 +32,7 @@ module.exports = class CommentsService {
body,
asset_id,
parent_id,
status = null,
status = 'NONE',
author_id
} = comment;
@@ -146,7 +147,7 @@ module.exports = class CommentsService {
* @param {String} status status of the comment to search for
* @return {Promise} resovles to comment array
*/
static findByStatus(status = null) {
static findByStatus(status = 'NONE') {
return CommentModel.find({status});
}
@@ -155,7 +156,7 @@ module.exports = class CommentsService {
* @param {String} asset_id
* @return {Promise}
*/
static moderationQueue(status = null, asset_id = null) {
static moderationQueue(status = 'NONE', asset_id = null) {
// Fetch the comments with statuses.
let comments = CommentModel.find({status});
+2 -2
View File
@@ -131,7 +131,7 @@ describe('services.CommentsService', () => {
expect(c2).to.not.be.null;
expect(c2.id).to.be.uuid;
expect(c2.status).to.be.null;
expect(c2.status).to.be.equal('NONE');
expect(c3).to.not.be.null;
expect(c3.id).to.be.uuid;
@@ -225,7 +225,7 @@ describe('services.CommentsService', () => {
return CommentsService.findById(comment_id)
.then((c) => {
expect(c.status).to.be.null;
expect(c.status).to.be.equal('NONE');
return CommentsService.pushStatus(comment_id, 'REJECTED', '123');
})