<commit_before>
/**
 * Module dependencies.
 */

var mongoose = require('mongoose')
var utils = require('../../lib/utils')

/**
 * Load comment
 */

exports.load = function (req, res, next, id) {
  var article = req.article
  utils.findByParam(article.comments, { id: id }, function (err, comment) {
    if (err) return next(err)
    req.comment = comment
    next()
  })
}

/**
 * Create comment
 */

exports.create = function (req, res) {
  var article = req.article
  var user = req.user

  if (!req.body.body) return res.redirect('/articles/'+ article.id)

  article.addComment(user, req.body, function (err) {
    if (err) return res.render('500')
    res.redirect('/articles/'+ article.id)
  })
}

/**
 * Delete comment
 */

exports.destroy = function (req, res) {
  var article = req.article
  article.removeComment(req.param('commentId'), function (err) {
    if (err) {
      req.flash('errors', 'Oops! The comment was not found')
    } else {
      req.flash('info', 'Removed comment')
    }
    res.redirect('/articles/' + article.id)
  })
}<commit_msg>fix type of flash message<commit_after>
/**
 * Module dependencies.
 */

var mongoose = require('mongoose')
var utils = require('../../lib/utils')

/**
 * Load comment
 */

exports.load = function (req, res, next, id) {
  var article = req.article
  utils.findByParam(article.comments, { id: id }, function (err, comment) {
    if (err) return next(err)
    req.comment = comment
    next()
  })
}

/**
 * Create comment
 */

exports.create = function (req, res) {
  var article = req.article
  var user = req.user

  if (!req.body.body) return res.redirect('/articles/'+ article.id)

  article.addComment(user, req.body, function (err) {
    if (err) return res.render('500')
    res.redirect('/articles/'+ article.id)
  })
}

/**
 * Delete comment
 */

exports.destroy = function (req, res) {
  var article = req.article
  article.removeComment(req.param('commentId'), function (err) {
    if (err) {
      req.flash('error', 'Oops! The comment was not found')
    } else {
      req.flash('info', 'Removed comment')
    }
    res.redirect('/articles/' + article.id)
  })
}
{'fraction_non_alphanumeric': 0.17110799438990182, 'fraction_numerical': 0.002805049088359046, 'mean_word_length': 3.0607210626185957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1177815', 'n_tokens_mistral': 711, 'n_tokens_neox': 701, 'n_words': 178}