Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / services / routing / server / index.js
index cd83b5c..49d843a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf3cc=['IntervalId','Intervals','map','interval','rules','message','interaction','isArray','applications','length','existsSync','join','.js','app','toLowerCase','appdata','split','channel','mail','push','slice','dialogflow','dialogflowv2','amazonlex','TagId','%s:%s:%s','./interval','condition','intervals','./applications/','consequence','priority','Push\x20new\x20rule','\x20|\x20','error','Please\x20create\x20a\x20new\x20file\x20under','execute','Applications\x20executed','stringify','matchPath','info','No\x20applications\x20to\x20execute','stack','routing\x20is\x20empty','agent','busy','agents','busyQueue','emit','end','QueueReport','UserId','catch','message\x20is\x20empty','capacity','hasOwnProperty','CurrentCapacity','updateRealtime','agent\x20not\x20found','values','chatQueues','paused','waiting','mailQueues','available','loggedIn','name','openchannelQueues','smsQueues','faxQueues','whatsappQueues','chatQueuesWaitingInteractions','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','faxQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','http','Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','lodash','util','path','jayson/promise','uuid','../../../config/environment','../../../config/logger','../rpc/openchannelQueueReport','../rpc/mailQueueReport','../rpc/smsQueueReport','../rpc/faxQueueReport','../rpc/whatsappQueueReport','../lib/rule-engine','format','%s.%s.%s','isNil'];(function(_0x432682,_0x253044){var _0x463d05=function(_0xa73403){while(--_0xa73403){_0x432682['push'](_0x432682['shift']());}};_0x463d05(++_0x253044);}(_0xf3cc,0x10d));var _0xcf3c=function(_0xd9c529,_0x19f8cc){_0xd9c529=_0xd9c529-0x0;var _0x146760=_0xf3cc[_0xd9c529];return _0x146760;};'use strict';var _=require(_0xcf3c('0x0'));var util=require(_0xcf3c('0x1'));var path=require(_0xcf3c('0x2'));var fs=require('fs');var jayson=require(_0xcf3c('0x3'));var BPromise=require('bluebird');var uuid=require(_0xcf3c('0x4'));var config=require(_0xcf3c('0x5'));var logger=require(_0xcf3c('0x6'))('routing');var rpc={'openchannelQueueReport':require(_0xcf3c('0x7')),'mailQueueReport':require(_0xcf3c('0x8')),'chatQueueReport':require('../rpc/chatQueueReport'),'smsQueueReport':require(_0xcf3c('0x9')),'faxQueueReport':require(_0xcf3c('0xa')),'whatsappQueueReport':require(_0xcf3c('0xb'))};var RuleEngine=require(_0xcf3c('0xc'));function getId(_0x11deda,_0x147e12,_0x1a593f){return util[_0xcf3c('0xd')](_0xcf3c('0xe'),_0x11deda,_0x147e12||0x0,_0x1a593f||0x0);}function getIntervals(_0x367027,_0x534bc8){var _0x58fe7b=[];if(!_[_0xcf3c('0xf')](_0x534bc8[_0xcf3c('0x10')])&&!_[_0xcf3c('0xf')](_0x367027[_0x534bc8[_0xcf3c('0x10')]])&&!_[_0xcf3c('0xf')](_0x367027[_0x534bc8[_0xcf3c('0x10')]][_0xcf3c('0x11')])){_0x58fe7b=_[_0xcf3c('0x12')](_0x367027[_0x534bc8['IntervalId']][_0xcf3c('0x11')],_0xcf3c('0x13'));}else if(!_['isNil'](_0x534bc8[_0xcf3c('0x13')])){_0x58fe7b=[_0x534bc8['interval']];}return _0x58fe7b;}exports['listen']=function(_0x56261f){_0x56261f[_0xcf3c('0x14')]={};return new BPromise(function(_0x598576,_0x2f387b){var _0x1a3565={'Start':function(_0x4e35fc){var _0x3e759f=this;return new Promise(function(_0x540046,_0x30d023){if(_0x4e35fc){try{var _0x1db425=[];var _0x146f3a=getId(_0x4e35fc['channel'],_0x4e35fc[_0xcf3c('0x15')]?_0x4e35fc[_0xcf3c('0x15')]['id']:0x0,_0x4e35fc[_0xcf3c('0x16')]?_0x4e35fc[_0xcf3c('0x16')]['id']:0x0);if(_0x4e35fc['applications']&&_[_0xcf3c('0x17')](_0x4e35fc[_0xcf3c('0x18')])&&_0x4e35fc[_0xcf3c('0x18')][_0xcf3c('0x19')]){for(var _0x3d0e0a=0x0;_0x3d0e0a<_0x4e35fc[_0xcf3c('0x18')][_0xcf3c('0x19')];_0x3d0e0a+=0x1){var _0x391e9b=_0x4e35fc[_0xcf3c('0x18')][_0x3d0e0a];if(fs[_0xcf3c('0x1a')](path[_0xcf3c('0x1b')](__dirname,_0xcf3c('0x18'),_0x391e9b['app']+_0xcf3c('0x1c')))){var _0x54cd87=[];switch(_0x391e9b[_0xcf3c('0x1d')][_0xcf3c('0x1e')]()){case'autoreply':var _0x1bd0f2=_0x391e9b[_0xcf3c('0x1f')][_0xcf3c('0x20')](',');if(_0x4e35fc[_0xcf3c('0x21')]===_0xcf3c('0x22')){_0x54cd87[_0xcf3c('0x23')](_0x1bd0f2[0x0]);_0x54cd87[_0xcf3c('0x23')](_0x1bd0f2[0x1]);_0x54cd87[_0xcf3c('0x23')](_0x1bd0f2['slice'](0x2,_0x1bd0f2[_0xcf3c('0x19')])['join'](','));}else{_0x54cd87[_0xcf3c('0x23')](_0x1bd0f2[0x0]);_0x54cd87[_0xcf3c('0x23')](_0x1bd0f2[_0xcf3c('0x24')](0x1,_0x1bd0f2[_0xcf3c('0x19')])[_0xcf3c('0x1b')](','));}break;case _0xcf3c('0x25'):var _0x5631f1=_0x391e9b[_0xcf3c('0x1f')]['split'](',');_0x54cd87[_0xcf3c('0x23')](_0x5631f1[0x0]);_0x54cd87[_0xcf3c('0x23')](_0x5631f1[0x1]);_0x54cd87[_0xcf3c('0x23')](_0x5631f1['slice'](0x2,_0x5631f1[_0xcf3c('0x19')])['join'](','));break;case _0xcf3c('0x26'):var _0xe22e99=_0x391e9b[_0xcf3c('0x1f')][_0xcf3c('0x20')](',');_0x54cd87['push'](_0xe22e99[0x0]);_0x54cd87[_0xcf3c('0x23')](_0xe22e99[0x1]);_0x54cd87[_0xcf3c('0x23')](_0xe22e99[0x2]);_0x54cd87[_0xcf3c('0x23')](_0xe22e99[0x3]);_0x54cd87[_0xcf3c('0x23')](_0xe22e99['slice'](0x4,_0xe22e99[_0xcf3c('0x19')])[_0xcf3c('0x1b')](','));break;case _0xcf3c('0x27'):var _0x5b6193=_0x391e9b[_0xcf3c('0x1f')][_0xcf3c('0x20')](',');_0x54cd87[_0xcf3c('0x23')](_0x5b6193[0x0]);_0x54cd87['push'](_0x5b6193[0x1]);_0x54cd87[_0xcf3c('0x23')](_0x5b6193[0x2]);_0x54cd87[_0xcf3c('0x23')](_0x5b6193[0x3]);_0x54cd87[_0xcf3c('0x23')](_0x5b6193[_0xcf3c('0x24')](0x4,_0x5b6193[_0xcf3c('0x19')])['join'](','));break;case _0xcf3c('0x15'):_0x54cd87['push'](_0x391e9b[_0xcf3c('0x1f')]);break;case'tag':_0x54cd87[_0xcf3c('0x23')](_0x391e9b[_0xcf3c('0x28')]);_0x54cd87[_0xcf3c('0x23')](_0x391e9b[_0xcf3c('0x1f')]);break;default:_0x54cd87=_[_0xcf3c('0xf')](_0x391e9b[_0xcf3c('0x1f')])?[]:_0x391e9b[_0xcf3c('0x1f')][_0xcf3c('0x20')](',');}var _0x4844f2={'id':util[_0xcf3c('0xd')](_0xcf3c('0x29'),_0x146f3a,_0x391e9b['id'],_0x391e9b[_0xcf3c('0x1d')]),'condition':require(_0xcf3c('0x2a'))[_0xcf3c('0x2b')](_0x146f3a,getIntervals(_0x56261f[_0xcf3c('0x2c')],_0x391e9b),_0x56261f),'consequence':require(_0xcf3c('0x2d')+_0x391e9b[_0xcf3c('0x1d')])[_0xcf3c('0x2e')](_0x146f3a,_0x54cd87,_0x56261f,_0x4e35fc),'p':_0x391e9b[_0xcf3c('0x2f')]||0x0};logger['info'](_0xcf3c('0x30'),_0x4844f2['id'],'on\x20interval',getIntervals(_0x56261f['intervals'],_0x391e9b)['join'](_0xcf3c('0x31')));_0x1db425[_0xcf3c('0x23')](_0x4844f2);}else{logger[_0xcf3c('0x32')](_0xcf3c('0x33'),path['join'](__dirname,'applications',_0x391e9b[_0xcf3c('0x1d')]+_0xcf3c('0x1c')));}}_0x56261f[_0xcf3c('0x14')][_0x146f3a]=new RuleEngine(_0x1db425);_0x56261f[_0xcf3c('0x14')][_0x146f3a][_0xcf3c('0x34')](_0x4e35fc,function(_0x99a4e0){logger['info'](_0xcf3c('0x35'),JSON[_0xcf3c('0x36')](_0x99a4e0[_0xcf3c('0x37')]));if(_0x56261f['rules'][_0x146f3a]){_0x56261f[_0xcf3c('0x14')][_0x146f3a]['emit']('complete');}});return _0x540046({'code':0xc8,'message':_0x4e35fc});}else{logger[_0xcf3c('0x38')](_0xcf3c('0x39'));return _0x540046({'code':0xc8,'message':_0x4e35fc});}}catch(_0x3ec3d8){logger[_0xcf3c('0x32')](_0x3ec3d8[_0xcf3c('0x3a')]);return _0x30d023(_0x3e759f[_0xcf3c('0x32')](0x1f4,_0x3ec3d8));}}return _0x30d023(_0xcf3c('0x3b'));});},'AcceptMessage':function(_0x1224f8){var _0x245c77=this;return new Promise(function(_0x533a9f,_0x5bff1b){if(_0x1224f8[_0xcf3c('0x3c')]&&_0x1224f8[_0xcf3c('0x3c')]['id']){if(_0x56261f['agents'][_0x1224f8[_0xcf3c('0x3c')]['id']]){_0x56261f['agents'][_0x1224f8[_0xcf3c('0x3c')]['id']][_0xcf3c('0x3d')]=![];_0x56261f[_0xcf3c('0x3e')][_0x1224f8[_0xcf3c('0x3c')]['id']][_0xcf3c('0x3f')]=undefined;}}if(_0x1224f8[_0xcf3c('0x15')]&&_0x1224f8[_0xcf3c('0x15')]['id']){try{var _0x13121b=getId(_0x1224f8[_0xcf3c('0x21')],_0x1224f8[_0xcf3c('0x15')]?_0x1224f8[_0xcf3c('0x15')]['id']:0x0,_0x1224f8[_0xcf3c('0x16')]?_0x1224f8[_0xcf3c('0x16')]['id']:0x0);if(_0x56261f[_0xcf3c('0x14')][_0x13121b]){_0x56261f[_0xcf3c('0x14')][_0x13121b][_0xcf3c('0x40')](_0xcf3c('0x41'));if(rpc[_0x1224f8[_0xcf3c('0x21')]+'QueueReport']){rpc[_0x1224f8['channel']+_0xcf3c('0x42')]['update'](_0x13121b,{'UserId':_0x1224f8[_0xcf3c('0x15')][_0xcf3c('0x43')]})[_0xcf3c('0x44')](function(_0x33c576){logger[_0xcf3c('0x32')]('error\x20update\x20queue\x20report');});}}return _0x533a9f({'code':0xc8,'message':_0x1224f8});}catch(_0x5b6802){logger['error'](_0x5b6802[_0xcf3c('0x3a')]);return _0x5bff1b(_0x245c77[_0xcf3c('0x32')](0x1f4,_0x5b6802));}}logger['error'](_0xcf3c('0x45'));return _0x5bff1b(_0x245c77[_0xcf3c('0x32')](0x1f4,_0xcf3c('0x45')));});},'RejectMessage':function(_0x2800d4){var _0x391976=this;return new Promise(function(_0x37da53,_0x592da0){if(_0x2800d4[_0xcf3c('0x3c')]&&_0x2800d4[_0xcf3c('0x3c')]['id']){try{if(_0x56261f[_0xcf3c('0x3e')][_0x2800d4[_0xcf3c('0x3c')]['id']]){_0x56261f[_0xcf3c('0x3e')][_0x2800d4['agent']['id']][_0xcf3c('0x3d')]=![];_0x56261f[_0xcf3c('0x3e')][_0x2800d4[_0xcf3c('0x3c')]['id']][_0xcf3c('0x3f')]=undefined;}return _0x37da53({'code':0xc8,'message':_0x2800d4});}catch(_0x4d0be6){logger[_0xcf3c('0x32')](_0x4d0be6['stack']);return _0x592da0(_0x391976[_0xcf3c('0x32')](0x1f4,_0x4d0be6));}}logger['error']('message\x20is\x20empty');return _0x592da0(_0x391976['error'](0x1f4,'message\x20is\x20empty'));});},'AbandonInteraction':function(_0x1ee0f7){var _0x2c8b0e=this;return new Promise(function(_0x5beab2,_0x37f972){if(_0x1ee0f7[_0xcf3c('0x21')]&&_0x1ee0f7[_0xcf3c('0x16')]&&_0x1ee0f7['interaction']['id']){try{var _0x5b5e6a=getId(_0x1ee0f7[_0xcf3c('0x21')],_0x1ee0f7[_0xcf3c('0x15')]?_0x1ee0f7['message']['id']:0x0,_0x1ee0f7['interaction']?_0x1ee0f7['interaction']['id']:0x0);if(_0x56261f[_0xcf3c('0x14')][_0x5b5e6a]){_0x56261f['rules'][_0x5b5e6a][_0xcf3c('0x40')]('end');}return _0x5beab2({'code':0xc8,'message':_0x1ee0f7});}catch(_0x7c6af9){logger[_0xcf3c('0x32')](_0x7c6af9[_0xcf3c('0x3a')]);return _0x37f972(_0x2c8b0e[_0xcf3c('0x32')](0x1f4,_0x7c6af9));}}logger[_0xcf3c('0x32')]('message\x20is\x20empty');return _0x37f972(_0x2c8b0e[_0xcf3c('0x32')](0x1f4,_0xcf3c('0x45')));});},'AgentCapacity':function(_0x26870b){var _0xab4bb8=this;return new Promise(function(_0x410b19,_0x13a35a){if(_0x56261f[_0xcf3c('0x3e')]['hasOwnProperty'](_0x26870b['id'])){for(var _0x50f21f in _0x26870b['capacity']){if(_0x26870b[_0xcf3c('0x46')]['hasOwnProperty'](_0x50f21f)){if(_0x56261f['agents'][_0x26870b['id']][_0xcf3c('0x47')](_0x50f21f+_0xcf3c('0x48'))){_0x56261f[_0xcf3c('0x3e')][_0x26870b['id']][_0x50f21f+'CurrentCapacity']=parseInt(_0x26870b[_0xcf3c('0x46')][_0x50f21f],0xa);}}}_0x56261f['agents'][_0x26870b['id']][_0xcf3c('0x49')]();return _0x410b19({'code':0xc8,'message':_0x56261f[_0xcf3c('0x3e')][_0x26870b['id']]});}else{return _0x13a35a(_0xab4bb8[_0xcf3c('0x32')](0x1f4,_0xcf3c('0x4a')));}});},'Agents':function(_0x443a20){return new Promise(function(_0x346079,_0x48ec31){var _0x13588c=_[_0xcf3c('0x4b')](_0x56261f[_0xcf3c('0x3e')]);_0x346079({'count':_0x13588c[_0xcf3c('0x19')],'rows':_0x13588c});});},'ChatQueues':function(_0x5578c4){return new Promise(function(_0x2bae67,_0x191cfb){var _0x27dbf1=[];for(var _0x45992c in _0x56261f[_0xcf3c('0x4c')]){if(_0x56261f[_0xcf3c('0x4c')]['hasOwnProperty'](_0x45992c)){var _0xfe4294=_0x56261f['chatQueues'][_0x45992c];var _0x23e1f6={'id':_0xfe4294['id'],'available':_0xfe4294['available'],'loggedIn':_0xfe4294['loggedIn'],'name':_0xfe4294['name'],'paused':_0xfe4294[_0xcf3c('0x4d')],'waiting':_0xfe4294[_0xcf3c('0x4e')]};_0x27dbf1['push'](_0x23e1f6);}}_0x2bae67({'count':_0x27dbf1[_0xcf3c('0x19')],'rows':_0x27dbf1});});},'MailQueues':function(_0x138a4a){return new Promise(function(_0x1b1e4a,_0x4084ac){var _0x121907=[];for(var _0x4518dd in _0x56261f['mailQueues']){if(_0x56261f[_0xcf3c('0x4f')][_0xcf3c('0x47')](_0x4518dd)){var _0x2e01ab=_0x56261f[_0xcf3c('0x4f')][_0x4518dd];var _0x4419e2={'id':_0x2e01ab['id'],'available':_0x2e01ab[_0xcf3c('0x50')],'loggedIn':_0x2e01ab[_0xcf3c('0x51')],'name':_0x2e01ab[_0xcf3c('0x52')],'paused':_0x2e01ab[_0xcf3c('0x4d')],'waiting':_0x2e01ab[_0xcf3c('0x4e')]};_0x121907[_0xcf3c('0x23')](_0x4419e2);}}_0x1b1e4a({'count':_0x121907[_0xcf3c('0x19')],'rows':_0x121907});});},'OpenchannelQueues':function(_0x98cb13){return new Promise(function(_0x43a97c,_0x46600f){var _0x358c71=[];for(var _0x164516 in _0x56261f[_0xcf3c('0x53')]){if(_0x56261f['openchannelQueues'][_0xcf3c('0x47')](_0x164516)){var _0x221bf4=_0x56261f[_0xcf3c('0x53')][_0x164516];var _0x372828={'id':_0x221bf4['id'],'available':_0x221bf4[_0xcf3c('0x50')],'loggedIn':_0x221bf4[_0xcf3c('0x51')],'name':_0x221bf4[_0xcf3c('0x52')],'paused':_0x221bf4[_0xcf3c('0x4d')],'waiting':_0x221bf4[_0xcf3c('0x4e')]};_0x358c71['push'](_0x372828);}}_0x43a97c({'count':_0x358c71[_0xcf3c('0x19')],'rows':_0x358c71});});},'SmsQueues':function(_0x48f93b){return new Promise(function(_0x1789a7,_0x3f6bf5){var _0x2aa10f=[];for(var _0x295d39 in _0x56261f[_0xcf3c('0x54')]){if(_0x56261f['smsQueues']['hasOwnProperty'](_0x295d39)){var _0xe304ee=_0x56261f['smsQueues'][_0x295d39];var _0x4c3924={'id':_0xe304ee['id'],'available':_0xe304ee['available'],'loggedIn':_0xe304ee[_0xcf3c('0x51')],'name':_0xe304ee[_0xcf3c('0x52')],'paused':_0xe304ee[_0xcf3c('0x4d')],'waiting':_0xe304ee[_0xcf3c('0x4e')]};_0x2aa10f['push'](_0x4c3924);}}_0x1789a7({'count':_0x2aa10f[_0xcf3c('0x19')],'rows':_0x2aa10f});});},'FaxQueues':function(_0x4fa83d){return new Promise(function(_0xd2b503,_0x258a4a){var _0x25c0e4=[];for(var _0x5ee248 in _0x56261f[_0xcf3c('0x55')]){if(_0x56261f[_0xcf3c('0x55')][_0xcf3c('0x47')](_0x5ee248)){var _0x95ce18=_0x56261f[_0xcf3c('0x55')][_0x5ee248];var _0x1f2ef2={'id':_0x95ce18['id'],'available':_0x95ce18[_0xcf3c('0x50')],'loggedIn':_0x95ce18[_0xcf3c('0x51')],'name':_0x95ce18[_0xcf3c('0x52')],'paused':_0x95ce18[_0xcf3c('0x4d')],'waiting':_0x95ce18[_0xcf3c('0x4e')]};_0x25c0e4[_0xcf3c('0x23')](_0x1f2ef2);}}_0xd2b503({'count':_0x25c0e4[_0xcf3c('0x19')],'rows':_0x25c0e4});});},'WhatsappQueues':function(_0x2dcbcc){return new Promise(function(_0x450884,_0xaa5bda){var _0x4f732c=[];for(var _0x910ed2 in _0x56261f[_0xcf3c('0x56')]){if(_0x56261f[_0xcf3c('0x56')]['hasOwnProperty'](_0x910ed2)){var _0x14a214=_0x56261f[_0xcf3c('0x56')][_0x910ed2];var _0xdfd54f={'id':_0x14a214['id'],'available':_0x14a214[_0xcf3c('0x50')],'loggedIn':_0x14a214[_0xcf3c('0x51')],'name':_0x14a214[_0xcf3c('0x52')],'paused':_0x14a214[_0xcf3c('0x4d')],'waiting':_0x14a214[_0xcf3c('0x4e')]};_0x4f732c['push'](_0xdfd54f);}}_0x450884({'count':_0x4f732c[_0xcf3c('0x19')],'rows':_0x4f732c});});},'ChatQueuesWaitingInteractions':function(_0x77ded8){return new Promise(function(_0x4aa121,_0x146c0f){var _0x4abd2e=_[_0xcf3c('0x4b')](_0x56261f[_0xcf3c('0x57')]);_0x4aa121({'count':_0x4abd2e[_0xcf3c('0x19')],'rows':_0x4abd2e});});},'MailQueuesWaitingInteractions':function(_0x3f9165){return new Promise(function(_0x4d430d,_0x2a940a){var _0x46f417=_['values'](_0x56261f[_0xcf3c('0x58')]);_0x4d430d({'count':_0x46f417[_0xcf3c('0x19')],'rows':_0x46f417});});},'OpenchannelQueuesWaitingInteractions':function(_0x7a3fab){return new Promise(function(_0x1ded75,_0x2edd54){var _0x54a10b=_[_0xcf3c('0x4b')](_0x56261f[_0xcf3c('0x59')]);_0x1ded75({'count':_0x54a10b[_0xcf3c('0x19')],'rows':_0x54a10b});});},'SmsQueuesWaitingInteractions':function(_0x3e4d19){return new Promise(function(_0x17c117,_0x2634eb){var _0x2ef478=_[_0xcf3c('0x4b')](_0x56261f['smsQueuesWaitingInteractions']);_0x17c117({'count':_0x2ef478[_0xcf3c('0x19')],'rows':_0x2ef478});});},'FaxQueuesWaitingInteractions':function(_0x1627d7){return new Promise(function(_0x1102df,_0xc547a6){var _0x19e62c=_['values'](_0x56261f[_0xcf3c('0x5a')]);_0x1102df({'count':_0x19e62c[_0xcf3c('0x19')],'rows':_0x19e62c});});},'WhatsappQueuesWaitingInteractions':function(_0x4db968){return new Promise(function(_0x59eb68,_0x314c2a){var _0x6e3b88=_[_0xcf3c('0x4b')](_0x56261f[_0xcf3c('0x5b')]);_0x59eb68({'count':_0x6e3b88[_0xcf3c('0x19')],'rows':_0x6e3b88});});}};var _0x16a973=jayson['server'](_0x1a3565)[_0xcf3c('0x5c')]();_0x16a973['on']('error',function(_0x5a3c3c){logger['error'](JSON['stringify'](_0x5a3c3c));return _0x2f387b(_0x5a3c3c);});_0x16a973['listen'](0x232c,'127.0.0.1',function(){console['log'](_0xcf3c('0x5d'),0x232c);return _0x598576(_0xcf3c('0x5e')+0x232c);});});};
\ No newline at end of file
+var _0x5c12=['waiting','mailQueues','loggedIn','paused','openchannelQueues','smsQueues','faxQueues','whatsappQueues','chatQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','server','http','127.0.0.1','log','RPC\x20listening\x20on\x20port:','util','path','bluebird','uuid','../../../config/environment','../../../config/logger','routing','../rpc/openchannelQueueReport','../rpc/mailQueueReport','../rpc/smsQueueReport','../rpc/faxQueueReport','../rpc/whatsappQueueReport','format','%s.%s.%s','isNil','IntervalId','Intervals','interval','rules','channel','message','interaction','isArray','applications','length','join','app','.js','toLowerCase','autoreply','appdata','split','mail','push','slice','dialogflow','dialogflowv2','amazonlex','tag','TagId','%s:%s:%s','./interval','condition','intervals','./applications/','consequence','priority','info','Push\x20new\x20rule','on\x20interval','\x20|\x20','error','Applications\x20executed','stringify','matchPath','complete','No\x20applications\x20to\x20execute','routing\x20is\x20empty','agent','agents','busy','busyQueue','emit','end','QueueReport','UserId','catch','error\x20update\x20queue\x20report','stack','message\x20is\x20empty','hasOwnProperty','capacity','CurrentCapacity','agent\x20not\x20found','values','chatQueues','available','name'];(function(_0x2d7f0e,_0x3e6fbd){var _0x110b07=function(_0x557b00){while(--_0x557b00){_0x2d7f0e['push'](_0x2d7f0e['shift']());}};_0x110b07(++_0x3e6fbd);}(_0x5c12,0x188));var _0x25c1=function(_0x459a0a,_0x25c46f){_0x459a0a=_0x459a0a-0x0;var _0x4ab46c=_0x5c12[_0x459a0a];return _0x4ab46c;};'use strict';var _=require('lodash');var util=require(_0x25c1('0x0'));var path=require(_0x25c1('0x1'));var fs=require('fs');var jayson=require('jayson/promise');var BPromise=require(_0x25c1('0x2'));var uuid=require(_0x25c1('0x3'));var config=require(_0x25c1('0x4'));var logger=require(_0x25c1('0x5'))(_0x25c1('0x6'));var rpc={'openchannelQueueReport':require(_0x25c1('0x7')),'mailQueueReport':require(_0x25c1('0x8')),'chatQueueReport':require('../rpc/chatQueueReport'),'smsQueueReport':require(_0x25c1('0x9')),'faxQueueReport':require(_0x25c1('0xa')),'whatsappQueueReport':require(_0x25c1('0xb'))};var RuleEngine=require('../lib/rule-engine');function getId(_0x5c69b1,_0x24981c,_0x3b69ba){return util[_0x25c1('0xc')](_0x25c1('0xd'),_0x5c69b1,_0x24981c||0x0,_0x3b69ba||0x0);}function getIntervals(_0xf8363f,_0x588f30){var _0x3e062e=[];if(!_[_0x25c1('0xe')](_0x588f30[_0x25c1('0xf')])&&!_[_0x25c1('0xe')](_0xf8363f[_0x588f30[_0x25c1('0xf')]])&&!_['isNil'](_0xf8363f[_0x588f30[_0x25c1('0xf')]][_0x25c1('0x10')])){_0x3e062e=_['map'](_0xf8363f[_0x588f30[_0x25c1('0xf')]][_0x25c1('0x10')],_0x25c1('0x11'));}else if(!_[_0x25c1('0xe')](_0x588f30['interval'])){_0x3e062e=[_0x588f30['interval']];}return _0x3e062e;}exports['listen']=function(_0x54f6f4){_0x54f6f4[_0x25c1('0x12')]={};return new BPromise(function(_0x1412ed,_0x342cd4){var _0x6eba15={'Start':function(_0x17a032){var _0x4ea926=this;return new Promise(function(_0x4638f0,_0x55b62d){if(_0x17a032){try{var _0x5d631e=[];var _0x5b852a=getId(_0x17a032[_0x25c1('0x13')],_0x17a032[_0x25c1('0x14')]?_0x17a032['message']['id']:0x0,_0x17a032['interaction']?_0x17a032[_0x25c1('0x15')]['id']:0x0);if(_0x17a032['applications']&&_[_0x25c1('0x16')](_0x17a032[_0x25c1('0x17')])&&_0x17a032['applications']['length']){for(var _0x542768=0x0;_0x542768<_0x17a032[_0x25c1('0x17')][_0x25c1('0x18')];_0x542768+=0x1){var _0x22a36e=_0x17a032[_0x25c1('0x17')][_0x542768];if(fs['existsSync'](path[_0x25c1('0x19')](__dirname,_0x25c1('0x17'),_0x22a36e[_0x25c1('0x1a')]+_0x25c1('0x1b')))){var _0x517a46=[];switch(_0x22a36e['app'][_0x25c1('0x1c')]()){case _0x25c1('0x1d'):var _0x396ed5=_0x22a36e[_0x25c1('0x1e')][_0x25c1('0x1f')](',');if(_0x17a032[_0x25c1('0x13')]===_0x25c1('0x20')){_0x517a46[_0x25c1('0x21')](_0x396ed5[0x0]);_0x517a46[_0x25c1('0x21')](_0x396ed5[0x1]);_0x517a46[_0x25c1('0x21')](_0x396ed5[_0x25c1('0x22')](0x2,_0x396ed5[_0x25c1('0x18')])[_0x25c1('0x19')](','));}else{_0x517a46['push'](_0x396ed5[0x0]);_0x517a46[_0x25c1('0x21')](_0x396ed5[_0x25c1('0x22')](0x1,_0x396ed5[_0x25c1('0x18')])[_0x25c1('0x19')](','));}break;case _0x25c1('0x23'):var _0x326a5f=_0x22a36e['appdata'][_0x25c1('0x1f')](',');_0x517a46[_0x25c1('0x21')](_0x326a5f[0x0]);_0x517a46[_0x25c1('0x21')](_0x326a5f[0x1]);_0x517a46[_0x25c1('0x21')](_0x326a5f[_0x25c1('0x22')](0x2,_0x326a5f[_0x25c1('0x18')])['join'](','));break;case _0x25c1('0x24'):var _0x478f1e=_0x22a36e[_0x25c1('0x1e')][_0x25c1('0x1f')](',');_0x517a46[_0x25c1('0x21')](_0x478f1e[0x0]);_0x517a46[_0x25c1('0x21')](_0x478f1e[0x1]);_0x517a46[_0x25c1('0x21')](_0x478f1e[0x2]);_0x517a46[_0x25c1('0x21')](_0x478f1e[0x3]);_0x517a46[_0x25c1('0x21')](_0x478f1e[_0x25c1('0x22')](0x4,_0x478f1e[_0x25c1('0x18')])['join'](','));break;case _0x25c1('0x25'):var _0x47f959=_0x22a36e['appdata'][_0x25c1('0x1f')](',');_0x517a46[_0x25c1('0x21')](_0x47f959[0x0]);_0x517a46['push'](_0x47f959[0x1]);_0x517a46[_0x25c1('0x21')](_0x47f959[0x2]);_0x517a46['push'](_0x47f959[0x3]);_0x517a46[_0x25c1('0x21')](_0x47f959['slice'](0x4,_0x47f959[_0x25c1('0x18')])[_0x25c1('0x19')](','));break;case _0x25c1('0x14'):_0x517a46[_0x25c1('0x21')](_0x22a36e[_0x25c1('0x1e')]);break;case _0x25c1('0x26'):_0x517a46[_0x25c1('0x21')](_0x22a36e[_0x25c1('0x27')]);_0x517a46['push'](_0x22a36e[_0x25c1('0x1e')]);break;default:_0x517a46=_['isNil'](_0x22a36e[_0x25c1('0x1e')])?[]:_0x22a36e['appdata'][_0x25c1('0x1f')](',');}var _0x1917e6={'id':util[_0x25c1('0xc')](_0x25c1('0x28'),_0x5b852a,_0x22a36e['id'],_0x22a36e[_0x25c1('0x1a')]),'condition':require(_0x25c1('0x29'))[_0x25c1('0x2a')](_0x5b852a,getIntervals(_0x54f6f4[_0x25c1('0x2b')],_0x22a36e),_0x54f6f4),'consequence':require(_0x25c1('0x2c')+_0x22a36e[_0x25c1('0x1a')])[_0x25c1('0x2d')](_0x5b852a,_0x517a46,_0x54f6f4,_0x17a032),'p':_0x22a36e[_0x25c1('0x2e')]||0x0};logger[_0x25c1('0x2f')](_0x25c1('0x30'),_0x1917e6['id'],_0x25c1('0x31'),getIntervals(_0x54f6f4[_0x25c1('0x2b')],_0x22a36e)[_0x25c1('0x19')](_0x25c1('0x32')));_0x5d631e[_0x25c1('0x21')](_0x1917e6);}else{logger[_0x25c1('0x33')]('Please\x20create\x20a\x20new\x20file\x20under',path[_0x25c1('0x19')](__dirname,_0x25c1('0x17'),_0x22a36e['app']+_0x25c1('0x1b')));}}_0x54f6f4['rules'][_0x5b852a]=new RuleEngine(_0x5d631e);_0x54f6f4[_0x25c1('0x12')][_0x5b852a]['execute'](_0x17a032,function(_0x4326fb){logger[_0x25c1('0x2f')](_0x25c1('0x34'),JSON[_0x25c1('0x35')](_0x4326fb[_0x25c1('0x36')]));if(_0x54f6f4['rules'][_0x5b852a]){_0x54f6f4[_0x25c1('0x12')][_0x5b852a]['emit'](_0x25c1('0x37'));}});return _0x4638f0({'code':0xc8,'message':_0x17a032});}else{logger[_0x25c1('0x2f')](_0x25c1('0x38'));return _0x4638f0({'code':0xc8,'message':_0x17a032});}}catch(_0x17fc23){logger['error'](_0x17fc23['stack']);return _0x55b62d(_0x4ea926['error'](0x1f4,_0x17fc23));}}return _0x55b62d(_0x25c1('0x39'));});},'AcceptMessage':function(_0x2b4c57){var _0x530967=this;return new Promise(function(_0x198dfa,_0x58792d){if(_0x2b4c57[_0x25c1('0x3a')]&&_0x2b4c57[_0x25c1('0x3a')]['id']){if(_0x54f6f4[_0x25c1('0x3b')][_0x2b4c57['agent']['id']]){_0x54f6f4['agents'][_0x2b4c57['agent']['id']][_0x25c1('0x3c')]=![];_0x54f6f4[_0x25c1('0x3b')][_0x2b4c57['agent']['id']][_0x25c1('0x3d')]=undefined;}}if(_0x2b4c57[_0x25c1('0x14')]&&_0x2b4c57[_0x25c1('0x14')]['id']){try{var _0x5d8562=getId(_0x2b4c57['channel'],_0x2b4c57['message']?_0x2b4c57['message']['id']:0x0,_0x2b4c57[_0x25c1('0x15')]?_0x2b4c57[_0x25c1('0x15')]['id']:0x0);if(_0x54f6f4['rules'][_0x5d8562]){_0x54f6f4[_0x25c1('0x12')][_0x5d8562][_0x25c1('0x3e')](_0x25c1('0x3f'));if(rpc[_0x2b4c57[_0x25c1('0x13')]+_0x25c1('0x40')]){rpc[_0x2b4c57[_0x25c1('0x13')]+_0x25c1('0x40')]['update'](_0x5d8562,{'UserId':_0x2b4c57['message'][_0x25c1('0x41')]})[_0x25c1('0x42')](function(_0x389547){logger['error'](_0x25c1('0x43'));});}}return _0x198dfa({'code':0xc8,'message':_0x2b4c57});}catch(_0x1c95e5){logger[_0x25c1('0x33')](_0x1c95e5[_0x25c1('0x44')]);return _0x58792d(_0x530967['error'](0x1f4,_0x1c95e5));}}logger[_0x25c1('0x33')](_0x25c1('0x45'));return _0x58792d(_0x530967[_0x25c1('0x33')](0x1f4,_0x25c1('0x45')));});},'RejectMessage':function(_0x5d2ecc){var _0x59e96b=this;return new Promise(function(_0x13ac06,_0x2cd055){if(_0x5d2ecc[_0x25c1('0x3a')]&&_0x5d2ecc[_0x25c1('0x3a')]['id']){try{if(_0x54f6f4['agents'][_0x5d2ecc[_0x25c1('0x3a')]['id']]){_0x54f6f4[_0x25c1('0x3b')][_0x5d2ecc['agent']['id']][_0x25c1('0x3c')]=![];_0x54f6f4[_0x25c1('0x3b')][_0x5d2ecc[_0x25c1('0x3a')]['id']][_0x25c1('0x3d')]=undefined;}return _0x13ac06({'code':0xc8,'message':_0x5d2ecc});}catch(_0x502018){logger['error'](_0x502018[_0x25c1('0x44')]);return _0x2cd055(_0x59e96b[_0x25c1('0x33')](0x1f4,_0x502018));}}logger[_0x25c1('0x33')]('message\x20is\x20empty');return _0x2cd055(_0x59e96b[_0x25c1('0x33')](0x1f4,_0x25c1('0x45')));});},'AbandonInteraction':function(_0x483721){var _0x354c5d=this;return new Promise(function(_0x1b938e,_0x2b58a3){if(_0x483721[_0x25c1('0x13')]&&_0x483721[_0x25c1('0x15')]&&_0x483721[_0x25c1('0x15')]['id']){try{var _0xa5a154=getId(_0x483721['channel'],_0x483721['message']?_0x483721['message']['id']:0x0,_0x483721[_0x25c1('0x15')]?_0x483721['interaction']['id']:0x0);if(_0x54f6f4[_0x25c1('0x12')][_0xa5a154]){_0x54f6f4[_0x25c1('0x12')][_0xa5a154][_0x25c1('0x3e')](_0x25c1('0x3f'));}return _0x1b938e({'code':0xc8,'message':_0x483721});}catch(_0x40fe57){logger[_0x25c1('0x33')](_0x40fe57['stack']);return _0x2b58a3(_0x354c5d[_0x25c1('0x33')](0x1f4,_0x40fe57));}}logger[_0x25c1('0x33')](_0x25c1('0x45'));return _0x2b58a3(_0x354c5d[_0x25c1('0x33')](0x1f4,_0x25c1('0x45')));});},'AgentCapacity':function(_0xed718b){var _0x54e966=this;return new Promise(function(_0x411c5c,_0x2e741f){if(_0x54f6f4[_0x25c1('0x3b')][_0x25c1('0x46')](_0xed718b['id'])){for(var _0x6b2ebc in _0xed718b['capacity']){if(_0xed718b[_0x25c1('0x47')][_0x25c1('0x46')](_0x6b2ebc)){if(_0x54f6f4['agents'][_0xed718b['id']][_0x25c1('0x46')](_0x6b2ebc+_0x25c1('0x48'))){_0x54f6f4[_0x25c1('0x3b')][_0xed718b['id']][_0x6b2ebc+_0x25c1('0x48')]=parseInt(_0xed718b[_0x25c1('0x47')][_0x6b2ebc],0xa);}}}_0x54f6f4[_0x25c1('0x3b')][_0xed718b['id']]['updateRealtime']();return _0x411c5c({'code':0xc8,'message':_0x54f6f4[_0x25c1('0x3b')][_0xed718b['id']]});}else{return _0x2e741f(_0x54e966[_0x25c1('0x33')](0x1f4,_0x25c1('0x49')));}});},'Agents':function(_0xea5725){return new Promise(function(_0x286800,_0x4052c1){var _0x2745b6=_[_0x25c1('0x4a')](_0x54f6f4[_0x25c1('0x3b')]);_0x286800({'count':_0x2745b6[_0x25c1('0x18')],'rows':_0x2745b6});});},'ChatQueues':function(_0x270d67){return new Promise(function(_0x2d9e6b,_0x3ff0fa){var _0x11908c=[];for(var _0x4d518f in _0x54f6f4[_0x25c1('0x4b')]){if(_0x54f6f4[_0x25c1('0x4b')][_0x25c1('0x46')](_0x4d518f)){var _0x7a1d7a=_0x54f6f4[_0x25c1('0x4b')][_0x4d518f];var _0x3f0a41={'id':_0x7a1d7a['id'],'available':_0x7a1d7a[_0x25c1('0x4c')],'loggedIn':_0x7a1d7a['loggedIn'],'name':_0x7a1d7a[_0x25c1('0x4d')],'paused':_0x7a1d7a['paused'],'waiting':_0x7a1d7a[_0x25c1('0x4e')]};_0x11908c[_0x25c1('0x21')](_0x3f0a41);}}_0x2d9e6b({'count':_0x11908c[_0x25c1('0x18')],'rows':_0x11908c});});},'MailQueues':function(_0x10b7c3){return new Promise(function(_0x3b0785,_0x23ba04){var _0xcd221e=[];for(var _0x19df83 in _0x54f6f4['mailQueues']){if(_0x54f6f4[_0x25c1('0x4f')][_0x25c1('0x46')](_0x19df83)){var _0x3867e6=_0x54f6f4[_0x25c1('0x4f')][_0x19df83];var _0xa41216={'id':_0x3867e6['id'],'available':_0x3867e6[_0x25c1('0x4c')],'loggedIn':_0x3867e6[_0x25c1('0x50')],'name':_0x3867e6['name'],'paused':_0x3867e6[_0x25c1('0x51')],'waiting':_0x3867e6['waiting']};_0xcd221e['push'](_0xa41216);}}_0x3b0785({'count':_0xcd221e['length'],'rows':_0xcd221e});});},'OpenchannelQueues':function(_0x188b51){return new Promise(function(_0x4b1ead,_0x182432){var _0x15cd6d=[];for(var _0x45724c in _0x54f6f4['openchannelQueues']){if(_0x54f6f4[_0x25c1('0x52')]['hasOwnProperty'](_0x45724c)){var _0x1e13a5=_0x54f6f4[_0x25c1('0x52')][_0x45724c];var _0x2029ac={'id':_0x1e13a5['id'],'available':_0x1e13a5[_0x25c1('0x4c')],'loggedIn':_0x1e13a5[_0x25c1('0x50')],'name':_0x1e13a5[_0x25c1('0x4d')],'paused':_0x1e13a5[_0x25c1('0x51')],'waiting':_0x1e13a5['waiting']};_0x15cd6d[_0x25c1('0x21')](_0x2029ac);}}_0x4b1ead({'count':_0x15cd6d[_0x25c1('0x18')],'rows':_0x15cd6d});});},'SmsQueues':function(_0x286a8f){return new Promise(function(_0x95c201,_0x242149){var _0x425f3e=[];for(var _0x4e65f4 in _0x54f6f4[_0x25c1('0x53')]){if(_0x54f6f4['smsQueues'][_0x25c1('0x46')](_0x4e65f4)){var _0x4ff3e6=_0x54f6f4['smsQueues'][_0x4e65f4];var _0x1c66d6={'id':_0x4ff3e6['id'],'available':_0x4ff3e6['available'],'loggedIn':_0x4ff3e6['loggedIn'],'name':_0x4ff3e6['name'],'paused':_0x4ff3e6['paused'],'waiting':_0x4ff3e6[_0x25c1('0x4e')]};_0x425f3e['push'](_0x1c66d6);}}_0x95c201({'count':_0x425f3e[_0x25c1('0x18')],'rows':_0x425f3e});});},'FaxQueues':function(_0x17dd76){return new Promise(function(_0xf61bdd,_0x172e6c){var _0x4bc134=[];for(var _0x5156e2 in _0x54f6f4[_0x25c1('0x54')]){if(_0x54f6f4[_0x25c1('0x54')]['hasOwnProperty'](_0x5156e2)){var _0x21c929=_0x54f6f4[_0x25c1('0x54')][_0x5156e2];var _0x58197a={'id':_0x21c929['id'],'available':_0x21c929['available'],'loggedIn':_0x21c929[_0x25c1('0x50')],'name':_0x21c929['name'],'paused':_0x21c929[_0x25c1('0x51')],'waiting':_0x21c929[_0x25c1('0x4e')]};_0x4bc134[_0x25c1('0x21')](_0x58197a);}}_0xf61bdd({'count':_0x4bc134['length'],'rows':_0x4bc134});});},'WhatsappQueues':function(_0x2ab0b6){return new Promise(function(_0x1812c5,_0x2a3aad){var _0x54bc4e=[];for(var _0x9ab20a in _0x54f6f4[_0x25c1('0x55')]){if(_0x54f6f4[_0x25c1('0x55')][_0x25c1('0x46')](_0x9ab20a)){var _0x2082d7=_0x54f6f4[_0x25c1('0x55')][_0x9ab20a];var _0xbcffa={'id':_0x2082d7['id'],'available':_0x2082d7[_0x25c1('0x4c')],'loggedIn':_0x2082d7[_0x25c1('0x50')],'name':_0x2082d7[_0x25c1('0x4d')],'paused':_0x2082d7[_0x25c1('0x51')],'waiting':_0x2082d7[_0x25c1('0x4e')]};_0x54bc4e[_0x25c1('0x21')](_0xbcffa);}}_0x1812c5({'count':_0x54bc4e[_0x25c1('0x18')],'rows':_0x54bc4e});});},'ChatQueuesWaitingInteractions':function(_0x4e4cac){return new Promise(function(_0x5bd3df,_0x634f6c){var _0x138376=_[_0x25c1('0x4a')](_0x54f6f4[_0x25c1('0x56')]);_0x5bd3df({'count':_0x138376[_0x25c1('0x18')],'rows':_0x138376});});},'MailQueuesWaitingInteractions':function(_0x33b55b){return new Promise(function(_0x15a6f0,_0x28c85b){var _0x46de21=_[_0x25c1('0x4a')](_0x54f6f4['mailQueuesWaitingInteractions']);_0x15a6f0({'count':_0x46de21[_0x25c1('0x18')],'rows':_0x46de21});});},'OpenchannelQueuesWaitingInteractions':function(_0x5cafe6){return new Promise(function(_0x13bcd4,_0x2c7636){var _0x593e17=_[_0x25c1('0x4a')](_0x54f6f4[_0x25c1('0x57')]);_0x13bcd4({'count':_0x593e17[_0x25c1('0x18')],'rows':_0x593e17});});},'SmsQueuesWaitingInteractions':function(_0x48fc08){return new Promise(function(_0x45d843,_0x376117){var _0x4c9abf=_[_0x25c1('0x4a')](_0x54f6f4[_0x25c1('0x58')]);_0x45d843({'count':_0x4c9abf[_0x25c1('0x18')],'rows':_0x4c9abf});});},'FaxQueuesWaitingInteractions':function(_0x50ce85){return new Promise(function(_0x3138fa,_0x2cda27){var _0x3a5e32=_[_0x25c1('0x4a')](_0x54f6f4['faxQueuesWaitingInteractions']);_0x3138fa({'count':_0x3a5e32[_0x25c1('0x18')],'rows':_0x3a5e32});});},'WhatsappQueuesWaitingInteractions':function(_0x4af326){return new Promise(function(_0xd389b7,_0x35153c){var _0x48e3bc=_[_0x25c1('0x4a')](_0x54f6f4['whatsappQueuesWaitingInteractions']);_0xd389b7({'count':_0x48e3bc[_0x25c1('0x18')],'rows':_0x48e3bc});});}};var _0x20dc44=jayson[_0x25c1('0x59')](_0x6eba15)[_0x25c1('0x5a')]();_0x20dc44['on'](_0x25c1('0x33'),function(_0xcbd192){logger[_0x25c1('0x33')](JSON['stringify'](_0xcbd192));return _0x342cd4(_0xcbd192);});_0x20dc44['listen'](0x232c,_0x25c1('0x5b'),function(){console[_0x25c1('0x5c')]('Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!',0x232c);return _0x1412ed(_0x25c1('0x5d')+0x232c);});});};
\ No newline at end of file