Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod queue #26

Merged
merged 10 commits into from
Nov 8, 2016
Merged

Mod queue #26

merged 10 commits into from
Nov 8, 2016

Conversation

gabelula
Copy link

@gabelula gabelula commented Nov 7, 2016

What does this PR do?

Adds endpoints for

  • moderation queue on rejected comments
  • moderation queue on pending comments
  • moderation queue on flagged comments

How do I test this PR?

npm start
  • Try /api/v1/comments/action/flag
  • Try /api/v1/comments/status/pending
  • Try /api/v1/comments/status/rejected

AND

npm test

@coralproject/tech


router.get('/action/:action_type', (req, res, next) => {
Action.find({'action_type': req.params.action_type, 'item_type': 'comment'}).then((actions) => {
Comment.find({'id': {'$in': actions.map(function(a){return a.item_id;})}}).exec(function(err, comments){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint should only return comments that have a flag and an empty status. Aka, have been flagged but do not yet have a moderation action.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor this database call into the model/comment.js file to keep all database access in a common place.

});

router.get('/status/rejected', (req, res, next) => {
Comment.find({'status': 'rejected'}).then((comments) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor to a function on the model.

});

router.get('/status/pending', (req, res, next) => {
Comment.find({'status': ''}).then((comments) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor to a function on the model.

//==============================================================================

router.delete('/:comment_id', (req, res, next) => {
Comment.remove(req.params.comment_id).then(() => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor to a function on the model.

@gabelula gabelula merged commit 28e6f87 into master Nov 8, 2016
@gabelula gabelula deleted the mod-queue branch November 8, 2016 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants