From f248f3fffb2cf1142c251dc177ce3a269a5b8fdc Mon Sep 17 00:00:00 2001 From: Kuan Butts Date: Fri, 2 Dec 2016 16:19:38 -0800 Subject: [PATCH 1/5] comment explaining regex stuff on twilio voice response --- app/controllers/voice.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/voice.js b/app/controllers/voice.js index b2b9c312..8399e761 100644 --- a/app/controllers/voice.js +++ b/app/controllers/voice.js @@ -61,6 +61,7 @@ module.exports = { twilioResponse.dial({callerId: organizationNumber, }); } + // this will make the text-to-voice in twilio read the phone number more clearly try { organizationNumber = organizationNumber.replace(/\D+/g, ''); organizationNumber = organizationNumber.replace(/(\d{1})(\d{3})(\d{3})(\d{4})/, '$1 ($2) $3-$4'); From b354d1dccf940fcebc3f8db7698f8eef782d292d Mon Sep 17 00:00:00 2001 From: Kuan Butts Date: Fri, 2 Dec 2016 17:11:55 -0800 Subject: [PATCH 2/5] resolves #239 by adding in process for creating alerts when a notification is sent --- app/models/notifications.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/models/notifications.js b/app/models/notifications.js index 74ac3ae8..5d08cee0 100644 --- a/app/models/notifications.js +++ b/app/models/notifications.js @@ -9,9 +9,11 @@ const moment = require('moment'); const momentTz = require('moment-timezone'); const resourceRequire = require('../lib/resourceRequire'); -const OutboundVoiceMessages = resourceRequire('models', 'OutboundVoiceMessages'); + +const Alerts = resourceRequire('models', 'Alerts'); const Conversations = resourceRequire('models', 'Conversations'); const Messages = resourceRequire('models', 'Messages'); +const OutboundVoiceMessages = resourceRequire('models', 'OutboundVoiceMessages'); const Users = resourceRequire('models', 'Users'); const voice = resourceRequire('lib', 'voice'); @@ -46,8 +48,6 @@ class Notifications extends BaseModel { static checkAndSendNotifications () { return new Promise((fulfill, reject) => { db('notifications') - // .select("notifications.*", "comms.type", "comms.value") - // .leftJoin("comms", "notifications.comm", "comms.commid") .where('send', '<', db.fn.now()) .andWhere('notifications.sent', false) .andWhere('notifications.closed', false) @@ -65,7 +65,17 @@ class Notifications extends BaseModel { } else { return this.sendTextorEmailNotification(notification); } - }).then((resp) => { + }).then((notifications) => { + return new Promise((fulfill, reject) => { + fulfill(notifications); + }); + }).map((notification) => { + let targetUserId = notification.cm; + let createdByUserId = notification.cm; + let subject = 'Notification Sent'; + let message = `Message subject \"${notification.subject}\" was sent and will appear as a sent message in the conversation stream.`; + return Alerts.createForUser(targetUserId, createdByUserId, subject, message); + }).then(() => { fulfill(); }).catch(reject); }); @@ -77,7 +87,7 @@ class Notifications extends BaseModel { .then((ovm) => { return voice.processPendingOutboundVoiceMessages(ovm); }).then(() => { - fulfill(); + fulfill(notification); }).catch(reject); }); }; @@ -103,7 +113,7 @@ class Notifications extends BaseModel { sendMethod.then(() => { return this.markAsSent(notification.notificationid); }).then(() => { - fulfill(); + fulfill(notification); }).catch(reject); }).catch(reject); From 424391be21e9cb706e2b4175b496d640399ea6e2 Mon Sep 17 00:00:00 2001 From: Kuan Butts Date: Mon, 5 Dec 2016 13:17:55 -0800 Subject: [PATCH 3/5] should resolve issue #209, sends empty twiml responses in lieu of string ok --- app/controllers/voice.js | 19 ++++++++++--------- public/js/app.js | 2 -- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/controllers/voice.js b/app/controllers/voice.js index 8399e761..657061be 100644 --- a/app/controllers/voice.js +++ b/app/controllers/voice.js @@ -33,10 +33,6 @@ module.exports = { Organizations.findOneByPhone(toNumber) .then((resp) => { organizationNumber = resp && resp.phone ? resp.phone : ''; - console.log('\n\n');console.log('\n\n'); - console.log('got call');console.log('got call'); - console.log('got call', resp); - console.log('got call - organizationNumber', organizationNumber); return Communications.findByValue(fromNumber); }).then((resp) => { @@ -87,8 +83,10 @@ module.exports = { return message.update({content: req.body.TranscriptionText,}); }); } - }).then(() => res.send('ok')) - .catch(res.error500); + }).then(() => { + const emptyResponse = twilio.TwimlResponse().toString(); + res.send(emptyResponse); + }).catch(res.error500); }, status(req, res) { @@ -111,7 +109,8 @@ module.exports = { return null; } }).then((notification) => { - res.send('ok'); + const emptyResponse = twilio.TwimlResponse().toString(); + res.send(emptyResponse); }).catch(res.error500); } }, @@ -240,8 +239,10 @@ module.exports = { } }); } - }).then(() => res.send('ok')) - .catch(res.error500); + }).then(() => { + const emptyResponse = twilio.TwimlResponse().toString(); + res.send(emptyResponse); + }).catch(res.error500); }, new(req, res) { diff --git a/public/js/app.js b/public/js/app.js index 346d2991..21670487 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -603,8 +603,6 @@ $(function() { } function buildUserActivityChart(users) { - console.log(users); - // Set height based off of remaining users post filter operation var height = Math.max(users.length * 30, 100); c3.generate({ From bbeb15a664f653e71cca9b385f450d4b4e3b05a2 Mon Sep 17 00:00:00 2001 From: Kuan Butts Date: Mon, 5 Dec 2016 14:44:01 -0800 Subject: [PATCH 4/5] resolves issue #253, shows right date on capture board --- app/models/capture.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/capture.js b/app/models/capture.js index 031153bf..e933ad86 100644 --- a/app/models/capture.js +++ b/app/models/capture.js @@ -13,6 +13,15 @@ class CaptureBoard { static findByOrg (orgId) { return new Promise((fulfill, reject) => { db('msgs') + .select('msgs.msgid', + 'msgs.convo', + 'msgs.content', + 'msgs.inbound', + 'msgs.created', + 'convos.subject', + 'comms.type', + 'comms.value', + 'commconns.name') .leftJoin('convos', 'msgs.convo', 'convos.convid') .leftJoin('comms', 'comms.commid', 'msgs.comm') .leftJoin('commconns', 'commconns.commconnid', 'comms.commid') From 1d8764280080dae1b32b4f829402cb4da8a509e0 Mon Sep 17 00:00:00 2001 From: Kuan Butts Date: Mon, 5 Dec 2016 15:41:00 -0800 Subject: [PATCH 5/5] resolves #246 --- ...20161205151256_dob_update_in_clients_table.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 migrations/20161205151256_dob_update_in_clients_table.js diff --git a/migrations/20161205151256_dob_update_in_clients_table.js b/migrations/20161205151256_dob_update_in_clients_table.js new file mode 100644 index 00000000..5b9f81c8 --- /dev/null +++ b/migrations/20161205151256_dob_update_in_clients_table.js @@ -0,0 +1,16 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + + knex.raw('ALTER TABLE clients ALTER COLUMN dob TYPE date'), + + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + + knex.raw('ALTER TABLE clients ALTER COLUMN dob TYPE timestamptz'), + + ]); +};