From: Daniele Cinti Date: Wed, 14 Sep 2016 15:12:42 +0000 (+0200) Subject: Built motion from commit 6436f3a.|0.0.141 X-Git-Tag: 20/10/16~71 X-Git-Url: http://repos.xcallymotion.com/base/%22angular-material.themes.css//%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%20%201011license.mail?a=commitdiff_plain;h=85876226d72beaa2205aea336daee4be4ec5f9a6;p=motion.git Built motion from commit 6436f3a.|0.0.141 --- diff --git a/release-notes/changelog_0.0.141.txt b/release-notes/changelog_0.0.141.txt index 06553bb..513bf82 100644 --- a/release-notes/changelog_0.0.141.txt +++ b/release-notes/changelog_0.0.141.txt @@ -1,5 +1,6 @@ # xCALLY MOTION Changelog +- * 6436f3a - 2016-09-14: server side config ami update - * 1dd0700 - 2016-09-14: Fixed trunk update - * 23c99a5 - 2016-09-14: Fixed triggers - * 50850a2 - 2016-09-14: add app interval check in agent count for chat status diff --git a/server/config/ami/trunk.js b/server/config/ami/trunk.js index 074a3b1..f3b86d8 100644 --- a/server/config/ami/trunk.js +++ b/server/config/ami/trunk.js @@ -18,7 +18,7 @@ function Trunk(ami) { }); TrunkModel.afterUpdate(function(doc) { - if (doc.active) { + if (doc.active && !doc.changed('status') && !doc.changed('peerstatus')) { trunksRewrite(doc, ami, false); } }); diff --git a/server/config/triggers/index.js b/server/config/triggers/index.js index 87f097b..9b9a1c8 100644 --- a/server/config/triggers/index.js +++ b/server/config/triggers/index.js @@ -90,7 +90,7 @@ module.exports = function(cpAmi) { actions = util.getActionsByTriggers(data, _.filter(_triggers, { channel: 'voice' })); - data.dataValues.membername = data.channel.split(/\/|-/)[1]; + data.membername = data.channel.split(/\/|-/)[1]; console.log('After dial update, Actions are ', actions.length); execActions(actions, data, 'voice', 'outbound', util, voice, mail, cm, jscripty, integration, urlForward); } @@ -118,7 +118,7 @@ module.exports = function(cpAmi) { return chatRoom .getChatVisitor() .then(function(chatVisitor) { - var actions = util.getActionsByTriggers(chatVisitor, _.filter(_triggers, { + var actions = util.getActionsByTriggers(chatVisitor.dataValues, _.filter(_triggers, { channel: 'chat' })); execActions(actions, _.merge(chatVisitor.dataValues, chatRoom.dataValues), 'chat', null, util, voice, mail, cm, jscripty, integration, urlForward, chat); @@ -129,7 +129,7 @@ module.exports = function(cpAmi) { }); SmsMessage.afterCreate(function(smsMessage) { if (smsMessage.status === 'RECEIVED') { - var actions = util.getActionsByTriggers(smsMessage, _.filter(_triggers, { + var actions = util.getActionsByTriggers(smsMessage.dataValues, _.filter(_triggers, { channel: 'sms' })); execActions(actions, smsMessage.dataValues, 'sms', null, util, voice, mail, cm, jscripty, integration, urlForward, chat, sms); @@ -137,12 +137,12 @@ module.exports = function(cpAmi) { }); MailMessage.afterCreate(function(doc) { if (doc.status === 'RECEIVED') { - var actions = util.getActionsByTriggers(doc, _.filter(_triggers, { + var actions = util.getActionsByTriggers(doc.dataValues, _.filter(_triggers, { channel: 'mail', status: true })); - execActions(actions, doc, 'mail', null, util, voice, mail, cm, jscripty, integration, urlForward); + execActions(actions, doc.dataValues, 'mail', null, util, voice, mail, cm, jscripty, integration, urlForward); } }); }) @@ -186,9 +186,9 @@ function getActionVariables(doc, channel) { var channelVariables = _.find(callChannels, { uniqueid: doc.uniqueid }); - return channelVariables ? _.merge(_.clone(doc.dataValues), channelVariables.variables) : _.clone(doc.dataValues); + return channelVariables ? _.merge(_.clone(doc), channelVariables.variables) : _.clone(doc); } else { - return _.clone(doc.dataValues); + return _.clone(doc); } } @@ -198,23 +198,23 @@ function execActions(actions, doc, channel, subtype, util, voice, mail, cm, jscr console.log('Executing action "' + action.action + '"'); switch (action.action) { case 'contactManager': - cm.manageContact(doc.dataValues, channel); + cm.manageContact(doc, channel); break; case 'urlForward': case 'http': - urlForward.sendRequest(doc.dataValues, channel, action, getActionVariables(doc, channel)); + urlForward.sendRequest(doc, channel, action, getActionVariables(doc, channel)); break; case 'jscripty': - jscripty.manageJscripty(action.data1, doc.dataValues, channel); + jscripty.manageJscripty(action.data1, doc, channel); break; case 'integration': case 'motionbar': - integration.manageEvent(action, doc.dataValues, channel, subtype, getActionVariables(doc, channel)); + integration.manageEvent(action, doc, channel, subtype, getActionVariables(doc, channel)); break; case 'tag': switch (channel) { case 'mail': - mail.tag(action, doc.dataValues); + mail.tag(action, doc); break; case 'chat': chat.tag(action, doc); @@ -229,7 +229,7 @@ function execActions(actions, doc, channel, subtype, util, voice, mail, cm, jscr // case 'http': //commented cause urlforward does the same, so we don't repeat the same function // switch (channel) { // case 'mail': - // mail.http(action, doc.dataValues); + // mail.http(action, doc); // break; // case 'chat': // chat.http(action, doc); @@ -242,7 +242,7 @@ function execActions(actions, doc, channel, subtype, util, voice, mail, cm, jscr // // break; case 'email': - mail.email(action, doc.dataValues); + mail.email(action, doc); break; case 'accountEmail': switch (channel) { @@ -257,10 +257,10 @@ function execActions(actions, doc, channel, subtype, util, voice, mail, cm, jscr break; case 'forward': - mail.forward(action, doc.dataValues); + mail.forward(action, doc); break; case 'template': - mail.template(action, doc.dataValues); + mail.template(action, doc); break; case 'accountTemplate': mail.accountTemplate(action, doc); @@ -268,7 +268,7 @@ function execActions(actions, doc, channel, subtype, util, voice, mail, cm, jscr case 'close': switch (channel) { case 'mail': - mail.close(action, doc.dataValues); + mail.close(action, doc); break; case 'chat': chat.close(action, doc); diff --git a/server/config/triggers/util.js b/server/config/triggers/util.js index 97bd1dc..1bff931 100644 --- a/server/config/triggers/util.js +++ b/server/config/triggers/util.js @@ -8,18 +8,19 @@ function Util() { Util.prototype.getActionsByTriggers = function(doc, triggers) { var actions = []; - doc.dataValues.from = doc.dataValues.from ? doc.dataValues.from.split(';') : []; - doc.dataValues.cc = doc.dataValues.cc ? doc.dataValues.cc.split(';') : []; - doc.dataValues.to = doc.dataValues.to ? doc.dataValues.to.split(';') : []; + doc = doc.datavalues || doc; //in case I forgot something + doc.from = doc.from ? doc.from.split(';') : []; + doc.cc = doc.cc ? doc.cc.split(';') : []; + doc.to = doc.to ? doc.to.split(';') : []; triggers.forEach(function(trigger) { if (trigger.status) { var All = []; var Any = []; trigger.All.forEach(function(condition) { - All.push(checkCondition(condition.dataValues || condition, doc.dataValues)); + All.push(checkCondition(condition || condition, doc)); }); trigger.Any.forEach(function(condition) { - Any.push(checkCondition(condition.dataValues || condition, doc.dataValues)); + Any.push(checkCondition(condition || condition, doc)); }); var allResult = [], @@ -42,9 +43,9 @@ Util.prototype.getActionsByTriggers = function(doc, triggers) { } } }); - doc.dataValues.from = doc.dataValues.from.join(';'); - doc.dataValues.cc = doc.dataValues.cc.join(';'); - doc.dataValues.to = doc.dataValues.to.join(';'); + doc.from = doc.from.join(';'); + doc.cc = doc.cc.join(';'); + doc.to = doc.to.join(';'); //return actions array return actions; }