diff --git a/package.json b/package.json index 03743bd..296d393 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,10 @@ "express": "~3.5.1" , "authbox": "^0.9.2" , "jade": "~0.14.2" + , "mixpanel": "~0.0.19" , "nodemailer": "~0.6.1" , "redis-url": "~0.2.0" , "underscore": "~1.6.0" - , "mixpanel": "~0.0.19" } , "devDependencies": { } diff --git a/server/app.js b/server/app.js index a880323..40f1674 100644 --- a/server/app.js +++ b/server/app.js @@ -1,15 +1,23 @@ var express = require('express') , app = express() - , authbox = require('authbox') , _ = require('underscore') + , authbox = require('authbox') + , crypto = require('crypto') + , exec = require('child_process').exec , fs = require('fs') , mixpanel = require('mixpanel') - , exec = require('child_process').exec - , spawn = require('child_process').spawn - , Stream = require('stream') , redis = require('redis-url').connect() + , spawn = require('child_process').spawn , text = require('../lib/text'); +// Express config +app.set('views', __dirname + '/views'); +app.set('view engine', 'jade'); + +app.use(express.cookieParser()); +app.use(express.static(__dirname + '/public')); +app.use(express.bodyParser()); + // Enable log messages when sending texts. text.debug(true); @@ -34,6 +42,7 @@ try { try { authbox_config = require('./authbox_config.js'); authbox.configure(authbox_config); + app.use(authbox.middleware); } catch(e) { authbox = {log: function() {}}; } @@ -48,15 +57,6 @@ try { access_keys = {}; } -// Express config -app.set('views', __dirname + '/views'); -app.set('view engine', 'jade'); - -app.use(express.cookieParser()); -app.use(express.static(__dirname + '/public')); -app.use(authbox.middleware); -app.use(express.bodyParser()); - // App routes app.get('/', function(req, res) { fs.readFile(__dirname + '/views/index.html', 'utf8', function(err, text){ @@ -103,12 +103,14 @@ function textRequestHandler(req, res, number, region, key) { var message = req.body.message; if (message.indexOf(':') > -1) { // Handle problem with vtext where message would not get sent properly if it - // contains a colon + // contains a colon. message = ' ' + message; } + shasum.update(number); + var authbox_digest = shasum.digest('hex'); _.extend(authbox_details, { - recipient__phone: number, + recipient: number, message__text: message });