mirror of
https://github.com/wassname/talk.git
synced 2026-07-07 22:07:09 +08:00
Moderation queue on flagged comments.
This commit is contained in:
@@ -30,9 +30,9 @@ router.get('/:comment_id', (req, res, next) => {
|
||||
|
||||
router.get('/action/:action_type', (req, res, next) => {
|
||||
Action.find({'action_type': req.params.action_type, 'item_type': 'comment'}).then((actions) => {
|
||||
// search all the comments that are in actions by id: item_id
|
||||
// populate user by user_id
|
||||
res.status(200).json(actions);
|
||||
Comment.find({'id': {'$in': actions.map(function(a){return a.item_id;})}}).exec(function(err, comments){
|
||||
res.status(200).json(comments);
|
||||
});
|
||||
}).catch(error => {
|
||||
next(error);
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('Get /comments', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Get moderation queues rejected, pending', () => {
|
||||
describe('Get moderation queues rejected, pending, flags', () => {
|
||||
const comments = [{
|
||||
id: 'abc',
|
||||
body: 'comment 10',
|
||||
@@ -95,10 +95,12 @@ describe('Get moderation queues rejected, pending', () => {
|
||||
|
||||
const actions = [{
|
||||
action_type: 'flag',
|
||||
item_id: 'abc'
|
||||
item_id: 'abc',
|
||||
item_type: 'comment'
|
||||
}, {
|
||||
action_type: 'like',
|
||||
item_id: 'hij'
|
||||
item_id: 'hij',
|
||||
item_type: 'comment'
|
||||
}];
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -132,6 +134,19 @@ describe('Get moderation queues rejected, pending', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return all the flagged comments', function(done){
|
||||
chai.request(app)
|
||||
.get('/api/v1/comments/action/flag')
|
||||
.end(function(err, res){
|
||||
expect(res).to.have.status(200);
|
||||
expect(err).to.be.null;
|
||||
expect(res.body.length).to.equal(1);
|
||||
expect(res.body[0]).to.have.property('id');
|
||||
expect(res.body[0].id).to.equal('abc');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Post /comments', () => {
|
||||
@@ -196,10 +211,12 @@ describe('Get /:comment_id', () => {
|
||||
|
||||
const actions = [{
|
||||
action_type: 'flag',
|
||||
item_id: 'abc'
|
||||
item_id: 'abc',
|
||||
item_type: 'comment'
|
||||
}, {
|
||||
action_type: 'like',
|
||||
item_id: 'hij'
|
||||
item_id: 'hij',
|
||||
item_type: 'comment'
|
||||
}];
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user