<commit_before>'user strict';

var config = require('./config/config'),
  firebase = require('./services/firebase'),
   express = require('express'),
bodyParser = require('body-parser'),
   request = require("request"),
       app = express();

app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies

app.get('/', function (req, res){
  res.send('Hello World!');
});

app.post('/new_message', function (req, res){
  //console.log(req.body);

  if (req.body.token == config.slack.webhookToken){
    var payload = {
      room:  req.body.channel_name,
      token: req.body.token,
      userId: req.body.user_id,
      message: req.body.text,
      username: req.body.user_name,
      timestamp: req.body.timestamp
    }

    if (payload.message == ''){
      return res.send('No message provided');
    }

    getUserProfile(payload,pushToFirebase);

    res.send('success');

  } else {

    res.send('Token is incorrect');
  }

});

var getUserProfile = function(payload, callback){
  request('https://slack.com/api/users.info?token=' + config.slack.apiToken + '&user=' + payload.userId + '&pretty=1',
    function(error,response,body){

      if (error){
        return console.log("Error" + error);
      }

      userInfo = JSON.parse(body).user;

      payload.color  = userInfo.color;
      payload.avatar = userInfo.profile.image_192;

      callback(payload,resizeMessageLength);
    })
}
<commit_msg>Checks tokens for any configured rooms<commit_after>'user strict';

var config = require('./config/config'),
  firebase = require('./services/firebase'),
   express = require('express'),
bodyParser = require('body-parser'),
   request = require("request"),
       app = express();

app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies

app.get('/', function (req, res){
  res.send('Hello World!');
});

app.post('/new_message', function (req, res){
  //console.log(req.body);

  if (checkToken(req.body.token)){
    var payload = {
      room:  req.body.channel_name,
      token: req.body.token,
      userId: req.body.user_id,
      message: req.body.text,
      username: req.body.user_name,
      timestamp: req.body.timestamp
    }

    if (payload.message == ''){
      return res.send('No message provided');
    }

    getUserProfile(payload,pushToFirebase);

    res.send('success');

  } else {

    res.send('Token is incorrect');
  }

});

var checkToken = function(token){
  if (token == config.slack.webhookGeneralToken ||
      token == config.slack.webhookEngineeringToken ||
      token == config.slack.webhookRandomToken){
    return true;
  } else {
    return false;
  }
}

var getUserProfile = function(payload, callback){
  request('https://slack.com/api/users.info?token=' + config.slack.apiToken + '&user=' + payload.userId + '&pretty=1',
    function(error,response,body){

      if (error){
        return console.log("Error" + error);
      }

      userInfo = JSON.parse(body).user;

      payload.color  = userInfo.color;
      payload.avatar = userInfo.profile.image_192;

      callback(payload,resizeMessageLength);
    })
}

{'fraction_non_alphanumeric': 0.16181930693069307, 'fraction_numerical': 0.0024752475247524753, 'mean_word_length': 3.2651715039577835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1802492', 'n_tokens_mistral': 1016, 'n_tokens_neox': 995, 'n_words': 195}