mirror of
https://github.com/wassname/talk.git
synced 2026-07-04 17:57:43 +08:00
Fix changeStatus
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import React from 'react';
|
||||
import timeago from 'timeago.js';
|
||||
import styles from './CommentList.css';
|
||||
@@ -6,6 +5,7 @@ import I18n from 'coral-framework/modules/i18n/i18n';
|
||||
import translations from '../translations.json';
|
||||
import Linkify from 'react-linkify';
|
||||
import {FabButton} from 'coral-ui';
|
||||
import {Icon} from 'react-mdl';
|
||||
|
||||
const linkify = new Linkify();
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ const tableHeaders = [
|
||||
];
|
||||
|
||||
const Community = ({isFetching, commenters, ...props}) => {
|
||||
console.log(commenters);
|
||||
const hasResults = !isFetching && !!commenters.length;
|
||||
return (
|
||||
<Grid>
|
||||
|
||||
+7
-8
@@ -1,7 +1,6 @@
|
||||
const mongoose = require('../mongoose');
|
||||
const uuid = require('uuid');
|
||||
const Action = require('./action');
|
||||
const User = require('./user');
|
||||
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
@@ -40,9 +39,6 @@ const CommentSchema = new Schema({
|
||||
* @param {String} body content of comment
|
||||
*/
|
||||
CommentSchema.statics.new = function(body, author_id, asset_id, parent_id, status, username) {
|
||||
if (username === null && author_id != null) {
|
||||
username = User.findById(author_id)['displayName']
|
||||
};
|
||||
let comment = new Comment({body, author_id, asset_id, parent_id, status, username});
|
||||
return comment.save();
|
||||
};
|
||||
@@ -163,13 +159,16 @@ CommentSchema.statics.moderationQueue = function(moderation) {
|
||||
//==============================================================================
|
||||
|
||||
/**
|
||||
* Set the status of a comment.
|
||||
* Changes the status of a comment.
|
||||
* @param {String} id identifier of the comment (uuid)
|
||||
* @param {String} status the new status of the comment
|
||||
* @return {Promise}
|
||||
*/
|
||||
* @return {Promise}
|
||||
*/
|
||||
CommentSchema.statics.changeStatus = function(id, status) {
|
||||
return Comment.findOneAndUpdate({'id': id}, {$set: {'status': status}});
|
||||
return Comment.findOneAndUpdate({'id': id}, {$set: {'status': status}}, {upsert: false, new: true})
|
||||
.then((comment) => {
|
||||
return comment;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+9
-8
@@ -425,15 +425,16 @@ UserService.setStatus = (id, status, comment_id) => {
|
||||
if (status === 'banned') {
|
||||
return UserService.disableUser(id)
|
||||
.then(() => {
|
||||
return Comment.setStatus(comment_id, 'rejected').then(() => {
|
||||
return UserModel.update({
|
||||
id: id
|
||||
}, {
|
||||
$set: {
|
||||
status: status
|
||||
}
|
||||
return Comment.changeStatus(comment_id, 'rejected')
|
||||
.then(() => {
|
||||
return UserModel.update({
|
||||
id: id
|
||||
}, {
|
||||
$set: {
|
||||
status: status
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ describe('User: models', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not still disable and ban the user if there is no comment', () => {
|
||||
it('should still disable and ban the user if there is no comment', () => {
|
||||
return User
|
||||
.setStatus(mockUsers[0].id, 'banned', '')
|
||||
.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user