<commit_before>module.exports = exports = function(core){

  core.app.get('/dialog', function (req, res) {
    res.render('dialog/index', {
      'title': 'Hunt dialog system example',
      'description': 'If you know user\'s key, you can chat with him/her.',
      'id': req.query.id
    });
  });

  core.app.post('/dialog', function (req, res) {
    if (req.body.id) {
      res.redirect('/dialog/' + req.body.id);
    } else {
      res.redirect('/');
    }
  });


  core.app.get('/dialog/:id', function (req, res) {
    if (req.user) {
      req.model.User.findOne({'_id': req.params.id}, function (err, userFound) {
        if (err) {
          throw err;
        } else {
          if (userFound) {
            if (userFound.id == req.user.id) {
              req.flash('error', 'Talking to yourself is very interesting)');
              res.redirect('/');
            } else {
              userFound.getRecentMessages(100, 0, function(err, messages){
                if(err){
                  throw err;
                } else {
                  console.log(messages);
                  res.render('dialog/dialog', {
                    'title':'Dialog with user "'+userFound.displayName+'"',
                    'user': userFound,
                    'messages': messages
                  });
                }

              });
            }
          } else {
            req.flash('error', 'User with this id do not exists!');
            res.redirect('/');
          }
        }
      });
    } else {
      req.flash('error', 'Authorize or register please!');
      res.redirect('/?id=' + req.params.id);
    }
  });
};<commit_msg>fix in dialog api in example - we use proper command to show messages between two given users, not all messages of user desired<commit_after>module.exports = exports = function(core){

  core.app.get('/dialog', function (req, res) {
    res.render('dialog/index', {
      'title': 'Hunt dialog system example',
      'description': 'If you know user\'s key, you can chat with him/her.',
      'id': req.query.id
    });
  });

  core.app.post('/dialog', function (req, res) {
    if (req.body.id) {
      res.redirect('/dialog/' + req.body.id);
    } else {
      res.redirect('/');
    }
  });


  core.app.get('/dialog/:id', function (req, res) {
    if (req.user) {
      req.model.User.findOne({'_id': req.params.id}, function (err, userFound) {
        if (err) {
          throw err;
        } else {
          if (userFound) {
            if (userFound.id == req.user.id) {
              req.flash('error', 'Talking to yourself is very interesting)');
              res.redirect('/dialog');
            } else {
              userFound.getDialog(req.user, 100, 0, function(err, messages){
                if(err){
                  throw err;
                } else {
                  res.render('dialog/dialog', {
                    'title':'Dialog with user "'+userFound.displayName+'"',
                    'user': userFound,
                    'messages': messages
                  });
                }

              });
            }
          } else {
            req.flash('error', 'User with this id do not exists!');
            res.redirect('/');
          }
        }
      });
    } else {
      req.flash('error', 'Authorize or register please!');
      res.redirect('/?id=' + req.params.id);
    }
  });
};
{'fraction_non_alphanumeric': 0.16011816838995568, 'fraction_numerical': 0.002363367799113737, 'mean_word_length': 1.5593348450491307, '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': '6623927', 'n_tokens_mistral': 994, 'n_tokens_neox': 956, 'n_words': 226}