From acab5ff541b8a926c01f9c74aab1c94753905c92 Mon Sep 17 00:00:00 2001 From: typpo Date: Sat, 7 Apr 2012 18:50:08 -0400 Subject: [PATCH] bugfixes! --- app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 510cb1d..def301a 100644 --- a/app.js +++ b/app.js @@ -36,6 +36,12 @@ app.get('/', function(req, res) { }); app.post('/text', function(req, res) { + if (!req.body.number || !req.body.message) { + mpq.track('incomplete request'); + res.send({success:false,message:'Incomplete request.'}); + return; + + } mpq.track('text', {number: req.body.number, message: req.body.message, ip: req.connection.remoteAddress}); @@ -76,11 +82,13 @@ app.post('/text', function(req, res) { res.send({success:false,message:'Could not validate IP quota.'}); return; } + /* if (num > 75) { mpq.track('exceeded ip quota'); res.send({success:false,message:'Exceeded quota for this IP address.'}); return; } + */ sendText(req.body.number, req.body.message, function(err) { if (err) { @@ -107,7 +115,7 @@ function dateStr() { } function stripPhone(phone) { - return phone.replace(/\D/g, ''); + return (phone+'').replace(/\D/g, ''); } function validatePhone(phone) {