<commit_before>'use strict';

console.log("webhook starting");

var _ = require('underscore'),
    qs = require('querystring'),
    async = require('async'),
    unirest = require('unirest'),
    crypto = require('crypto'),
    AWS = require('aws-sdk'),
    encryptor = require('simple-encryptor')({
      key: process.env.ENCRYPTION_KEY,
      hmac: true,
      debug: true
    });

module.exports.handler = function(event, context, cb) {
  console.log("webhook handler");
  console.log(event);

  if (event.token !== process.env.SLACK_VERIFICATION_TOKEN) {
    return context.fail('Webhook contained an invalid Slack verification token.');
  }

  var s3 = new AWS.S3();

  // TODO: do s3 calls asyncronously
  // var profiles = {slack: {}, github: {}};

  // async.each(['slack', 'github'], function(folder, cb){
  //   var stream = s3.getObject({
  //     Bucket: process.env.S3_BUCKET_NAME_GITRDONE,
  //     Key: folder+'/'+event.user_id,
  //     ResponseContentType: "application/json"<commit_msg>Don't accept empty text payloads<commit_after>'use strict';

console.log("webhook starting");

var _ = require('underscore'),
    qs = require('querystring'),
    async = require('async'),
    unirest = require('unirest'),
    crypto = require('crypto'),
    AWS = require('aws-sdk'),
    encryptor = require('simple-encryptor')({
      key: process.env.ENCRYPTION_KEY,
      hmac: true,
      debug: true
    });

module.exports.handler = function(event, context, cb) {
  console.log("webhook handler");
  console.log(event);

  if (event.token !== process.env.SLACK_VERIFICATION_TOKEN) {
    return context.fail('Webhook contained an invalid Slack verification token.');
  }

  if (!event.text || event.text.length == 0) {
    return cb(null, {text: "You didn't type anything! What did you do?"});
  }

  var s3 = new AWS.S3();

  // TODO: do s3 calls asyncronously
  // var profiles = {slack: {}, github: {}};

  // async.each(['slack', 'github'], function(folder, cb){
  //   var stream = s3.getObject({
  //     Bucket: process.env.S3_BUCKET_NAME_GITRDONE,
  //     Key: folder+'/'+event.user_id,
  //     ResponseContentType: "application/json"
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.00510677808727948, 'mean_word_length': 3.4524793388429753, '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': '4011724', 'n_tokens_mistral': 722, 'n_tokens_neox': 705, 'n_words': 154}