Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / services / routing / server / index.js
index 0f663c2..73270e8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf725=['busyQueue','end','QueueReport','update','UserId','message\x20is\x20empty','busy','stack','hasOwnProperty','capacity','CurrentCapacity','values','chatQueues','available','loggedIn','name','paused','mailQueues','waiting','openchannelQueues','smsQueues','faxQueues','whatsappQueues','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','http','127.0.0.1','log','Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','lodash','util','path','jayson/promise','bluebird','uuid','../../../config/environment','../../../config/logger','routing','../rpc/openchannelQueueReport','../rpc/chatQueueReport','../rpc/smsQueueReport','../rpc/faxQueueReport','../rpc/whatsappQueueReport','../lib/rule-engine','%s.%s.%s','isNil','IntervalId','Intervals','map','interval','listen','rules','channel','message','interaction','applications','length','join','app','.js','toLowerCase','autoreply','appdata','split','mail','push','slice','amazonlex','tag','format','%s:%s:%s','./interval','condition','intervals','./applications/','consequence','priority','Push\x20new\x20rule','\x20|\x20','error','Please\x20create\x20a\x20new\x20file\x20under','execute','info','Applications\x20executed','stringify','matchPath','emit','complete','routing\x20is\x20empty','agent','agents'];(function(_0x51426b,_0x56069c){var _0xb53cc3=function(_0x24363c){while(--_0x24363c){_0x51426b['push'](_0x51426b['shift']());}};_0xb53cc3(++_0x56069c);}(_0xf725,0x7e));var _0x5f72=function(_0x1b536b,_0x12a816){_0x1b536b=_0x1b536b-0x0;var _0x1aca27=_0xf725[_0x1b536b];return _0x1aca27;};'use strict';var _=require(_0x5f72('0x0'));var util=require(_0x5f72('0x1'));var path=require(_0x5f72('0x2'));var fs=require('fs');var jayson=require(_0x5f72('0x3'));var BPromise=require(_0x5f72('0x4'));var uuid=require(_0x5f72('0x5'));var config=require(_0x5f72('0x6'));var logger=require(_0x5f72('0x7'))(_0x5f72('0x8'));var rpc={'openchannelQueueReport':require(_0x5f72('0x9')),'mailQueueReport':require('../rpc/mailQueueReport'),'chatQueueReport':require(_0x5f72('0xa')),'smsQueueReport':require(_0x5f72('0xb')),'faxQueueReport':require(_0x5f72('0xc')),'whatsappQueueReport':require(_0x5f72('0xd'))};var RuleEngine=require(_0x5f72('0xe'));function getId(_0x4961d1,_0x158aa3,_0x523365){return util['format'](_0x5f72('0xf'),_0x4961d1,_0x158aa3||0x0,_0x523365||0x0);}function getIntervals(_0x3f189d,_0x5b74cf){var _0x994d2e=[];if(!_[_0x5f72('0x10')](_0x5b74cf['IntervalId'])&&!_[_0x5f72('0x10')](_0x3f189d[_0x5b74cf[_0x5f72('0x11')]])&&!_[_0x5f72('0x10')](_0x3f189d[_0x5b74cf[_0x5f72('0x11')]][_0x5f72('0x12')])){_0x994d2e=_[_0x5f72('0x13')](_0x3f189d[_0x5b74cf[_0x5f72('0x11')]]['Intervals'],_0x5f72('0x14'));}else if(!_[_0x5f72('0x10')](_0x5b74cf[_0x5f72('0x14')])){_0x994d2e=[_0x5b74cf[_0x5f72('0x14')]];}return _0x994d2e;}exports[_0x5f72('0x15')]=function(_0x57007a){_0x57007a[_0x5f72('0x16')]={};return new BPromise(function(_0x4f81e9,_0x50f8c8){var _0x1665be={'Start':function(_0x5a036c){var _0x3267a=this;return new Promise(function(_0x4adc76,_0x317eed){if(_0x5a036c){try{var _0x4e0c32=[];var _0x44893b=getId(_0x5a036c[_0x5f72('0x17')],_0x5a036c['message']?_0x5a036c[_0x5f72('0x18')]['id']:0x0,_0x5a036c[_0x5f72('0x19')]?_0x5a036c[_0x5f72('0x19')]['id']:0x0);if(_0x5a036c['applications']&&_['isArray'](_0x5a036c['applications'])&&_0x5a036c[_0x5f72('0x1a')][_0x5f72('0x1b')]){for(var _0x269dae=0x0;_0x269dae<_0x5a036c[_0x5f72('0x1a')][_0x5f72('0x1b')];_0x269dae+=0x1){var _0x16b13e=_0x5a036c[_0x5f72('0x1a')][_0x269dae];if(fs['existsSync'](path[_0x5f72('0x1c')](__dirname,_0x5f72('0x1a'),_0x16b13e[_0x5f72('0x1d')]+_0x5f72('0x1e')))){var _0x471a9c=[];switch(_0x16b13e[_0x5f72('0x1d')][_0x5f72('0x1f')]()){case _0x5f72('0x20'):var _0x27b1f6=_0x16b13e[_0x5f72('0x21')][_0x5f72('0x22')](',');if(_0x5a036c['channel']===_0x5f72('0x23')){_0x471a9c[_0x5f72('0x24')](_0x27b1f6[0x0]);_0x471a9c[_0x5f72('0x24')](_0x27b1f6[0x1]);_0x471a9c[_0x5f72('0x24')](_0x27b1f6['slice'](0x2,_0x27b1f6[_0x5f72('0x1b')])[_0x5f72('0x1c')](','));}else{_0x471a9c['push'](_0x27b1f6[0x0]);_0x471a9c[_0x5f72('0x24')](_0x27b1f6[_0x5f72('0x25')](0x1,_0x27b1f6[_0x5f72('0x1b')])['join'](','));}break;case'dialogflow':var _0x3d4cfe=_0x16b13e[_0x5f72('0x21')][_0x5f72('0x22')](',');_0x471a9c[_0x5f72('0x24')](_0x3d4cfe[0x0]);_0x471a9c[_0x5f72('0x24')](_0x3d4cfe[0x1]);_0x471a9c[_0x5f72('0x24')](_0x3d4cfe[_0x5f72('0x25')](0x2,_0x3d4cfe['length'])[_0x5f72('0x1c')](','));break;case'dialogflowv2':var _0xc8ca5a=_0x16b13e[_0x5f72('0x21')][_0x5f72('0x22')](',');_0x471a9c[_0x5f72('0x24')](_0xc8ca5a[0x0]);_0x471a9c[_0x5f72('0x24')](_0xc8ca5a[0x1]);_0x471a9c['push'](_0xc8ca5a[0x2]);_0x471a9c['push'](_0xc8ca5a[0x3]);_0x471a9c[_0x5f72('0x24')](_0xc8ca5a[_0x5f72('0x25')](0x4,_0xc8ca5a[_0x5f72('0x1b')])[_0x5f72('0x1c')](','));break;case _0x5f72('0x26'):var _0x7ed167=_0x16b13e[_0x5f72('0x21')]['split'](',');_0x471a9c[_0x5f72('0x24')](_0x7ed167[0x0]);_0x471a9c[_0x5f72('0x24')](_0x7ed167[0x1]);_0x471a9c[_0x5f72('0x24')](_0x7ed167[0x2]);_0x471a9c[_0x5f72('0x24')](_0x7ed167[0x3]);_0x471a9c[_0x5f72('0x24')](_0x7ed167['slice'](0x4,_0x7ed167[_0x5f72('0x1b')])[_0x5f72('0x1c')](','));break;case _0x5f72('0x18'):_0x471a9c[_0x5f72('0x24')](_0x16b13e[_0x5f72('0x21')]);break;case _0x5f72('0x27'):_0x471a9c['push'](_0x16b13e['TagId']);_0x471a9c[_0x5f72('0x24')](_0x16b13e[_0x5f72('0x21')]);break;default:_0x471a9c=_['isNil'](_0x16b13e[_0x5f72('0x21')])?[]:_0x16b13e[_0x5f72('0x21')][_0x5f72('0x22')](',');}var _0xf15ac8={'id':util[_0x5f72('0x28')](_0x5f72('0x29'),_0x44893b,_0x16b13e['id'],_0x16b13e[_0x5f72('0x1d')]),'condition':require(_0x5f72('0x2a'))[_0x5f72('0x2b')](_0x44893b,getIntervals(_0x57007a[_0x5f72('0x2c')],_0x16b13e),_0x57007a),'consequence':require(_0x5f72('0x2d')+_0x16b13e[_0x5f72('0x1d')])[_0x5f72('0x2e')](_0x44893b,_0x471a9c,_0x57007a,_0x5a036c),'p':_0x16b13e[_0x5f72('0x2f')]||0x0};logger['info'](_0x5f72('0x30'),_0xf15ac8['id'],'on\x20interval',getIntervals(_0x57007a['intervals'],_0x16b13e)[_0x5f72('0x1c')](_0x5f72('0x31')));_0x4e0c32[_0x5f72('0x24')](_0xf15ac8);}else{logger[_0x5f72('0x32')](_0x5f72('0x33'),path[_0x5f72('0x1c')](__dirname,'applications',_0x16b13e[_0x5f72('0x1d')]+_0x5f72('0x1e')));}}_0x57007a[_0x5f72('0x16')][_0x44893b]=new RuleEngine(_0x4e0c32);_0x57007a[_0x5f72('0x16')][_0x44893b][_0x5f72('0x34')](_0x5a036c,function(_0xccfc5d){logger[_0x5f72('0x35')](_0x5f72('0x36'),JSON[_0x5f72('0x37')](_0xccfc5d[_0x5f72('0x38')]));if(_0x57007a[_0x5f72('0x16')][_0x44893b]){_0x57007a[_0x5f72('0x16')][_0x44893b][_0x5f72('0x39')](_0x5f72('0x3a'));}});return _0x4adc76({'code':0xc8,'message':_0x5a036c});}else{logger[_0x5f72('0x35')]('No\x20applications\x20to\x20execute');return _0x4adc76({'code':0xc8,'message':_0x5a036c});}}catch(_0x594bb4){logger[_0x5f72('0x32')](_0x594bb4['stack']);return _0x317eed(_0x3267a['error'](0x1f4,_0x594bb4));}}return _0x317eed(_0x5f72('0x3b'));});},'AcceptMessage':function(_0x71e8e7){var _0x57d320=this;return new Promise(function(_0x3f0f8d,_0x42298c){if(_0x71e8e7['agent']&&_0x71e8e7[_0x5f72('0x3c')]['id']){if(_0x57007a[_0x5f72('0x3d')][_0x71e8e7[_0x5f72('0x3c')]['id']]){_0x57007a[_0x5f72('0x3d')][_0x71e8e7['agent']['id']]['busy']=![];_0x57007a[_0x5f72('0x3d')][_0x71e8e7[_0x5f72('0x3c')]['id']][_0x5f72('0x3e')]=undefined;}}if(_0x71e8e7[_0x5f72('0x18')]&&_0x71e8e7[_0x5f72('0x18')]['id']){try{var _0x6be017=getId(_0x71e8e7[_0x5f72('0x17')],_0x71e8e7['message']?_0x71e8e7[_0x5f72('0x18')]['id']:0x0,_0x71e8e7[_0x5f72('0x19')]?_0x71e8e7[_0x5f72('0x19')]['id']:0x0);if(_0x57007a[_0x5f72('0x16')][_0x6be017]){_0x57007a['rules'][_0x6be017][_0x5f72('0x39')](_0x5f72('0x3f'));if(rpc[_0x71e8e7[_0x5f72('0x17')]+_0x5f72('0x40')]){rpc[_0x71e8e7['channel']+_0x5f72('0x40')][_0x5f72('0x41')](_0x6be017,{'UserId':_0x71e8e7[_0x5f72('0x18')][_0x5f72('0x42')]})['catch'](function(_0x942c55){logger[_0x5f72('0x32')]('error\x20update\x20queue\x20report');});}}return _0x3f0f8d({'code':0xc8,'message':_0x71e8e7});}catch(_0x1911b0){logger[_0x5f72('0x32')](_0x1911b0['stack']);return _0x42298c(_0x57d320[_0x5f72('0x32')](0x1f4,_0x1911b0));}}logger[_0x5f72('0x32')](_0x5f72('0x43'));return _0x42298c(_0x57d320['error'](0x1f4,_0x5f72('0x43')));});},'RejectMessage':function(_0x5efa48){var _0x30a9b6=this;return new Promise(function(_0x355e23,_0x53e8d0){if(_0x5efa48[_0x5f72('0x3c')]&&_0x5efa48[_0x5f72('0x3c')]['id']){try{if(_0x57007a[_0x5f72('0x3d')][_0x5efa48[_0x5f72('0x3c')]['id']]){_0x57007a['agents'][_0x5efa48[_0x5f72('0x3c')]['id']][_0x5f72('0x44')]=![];_0x57007a[_0x5f72('0x3d')][_0x5efa48[_0x5f72('0x3c')]['id']]['busyQueue']=undefined;}return _0x355e23({'code':0xc8,'message':_0x5efa48});}catch(_0x16a452){logger['error'](_0x16a452[_0x5f72('0x45')]);return _0x53e8d0(_0x30a9b6[_0x5f72('0x32')](0x1f4,_0x16a452));}}logger[_0x5f72('0x32')](_0x5f72('0x43'));return _0x53e8d0(_0x30a9b6[_0x5f72('0x32')](0x1f4,_0x5f72('0x43')));});},'AbandonInteraction':function(_0x28008c){var _0x35116c=this;return new Promise(function(_0xfab233,_0x1d4a2f){if(_0x28008c['channel']&&_0x28008c[_0x5f72('0x19')]&&_0x28008c[_0x5f72('0x19')]['id']){try{var _0x5c5d94=getId(_0x28008c[_0x5f72('0x17')],_0x28008c[_0x5f72('0x18')]?_0x28008c['message']['id']:0x0,_0x28008c[_0x5f72('0x19')]?_0x28008c[_0x5f72('0x19')]['id']:0x0);if(_0x57007a[_0x5f72('0x16')][_0x5c5d94]){_0x57007a[_0x5f72('0x16')][_0x5c5d94][_0x5f72('0x39')]('end');}return _0xfab233({'code':0xc8,'message':_0x28008c});}catch(_0x540144){logger[_0x5f72('0x32')](_0x540144[_0x5f72('0x45')]);return _0x1d4a2f(_0x35116c[_0x5f72('0x32')](0x1f4,_0x540144));}}logger['error'](_0x5f72('0x43'));return _0x1d4a2f(_0x35116c[_0x5f72('0x32')](0x1f4,_0x5f72('0x43')));});},'AgentCapacity':function(_0x587edd){var _0x397b2a=this;return new Promise(function(_0x241231,_0x5e0fd9){if(_0x57007a['agents'][_0x5f72('0x46')](_0x587edd['id'])){for(var _0x57655b in _0x587edd['capacity']){if(_0x587edd[_0x5f72('0x47')][_0x5f72('0x46')](_0x57655b)){if(_0x57007a[_0x5f72('0x3d')][_0x587edd['id']][_0x5f72('0x46')](_0x57655b+_0x5f72('0x48'))){_0x57007a[_0x5f72('0x3d')][_0x587edd['id']][_0x57655b+_0x5f72('0x48')]=parseInt(_0x587edd['capacity'][_0x57655b],0xa);}}}_0x57007a[_0x5f72('0x3d')][_0x587edd['id']]['updateRealtime']();return _0x241231({'code':0xc8,'message':_0x57007a[_0x5f72('0x3d')][_0x587edd['id']]});}else{return _0x5e0fd9(_0x397b2a[_0x5f72('0x32')](0x1f4,'agent\x20not\x20found'));}});},'Agents':function(_0x4c3930){return new Promise(function(_0x2995dc,_0x269f23){var _0x39036d=_[_0x5f72('0x49')](_0x57007a['agents']);_0x2995dc({'count':_0x39036d[_0x5f72('0x1b')],'rows':_0x39036d});});},'ChatQueues':function(_0x1db15b){return new Promise(function(_0x14e20b,_0x48cae9){var _0x12a464=[];for(var _0x29113a in _0x57007a[_0x5f72('0x4a')]){if(_0x57007a[_0x5f72('0x4a')][_0x5f72('0x46')](_0x29113a)){var _0x36774e=_0x57007a[_0x5f72('0x4a')][_0x29113a];var _0x15e9a5={'id':_0x36774e['id'],'available':_0x36774e[_0x5f72('0x4b')],'loggedIn':_0x36774e[_0x5f72('0x4c')],'name':_0x36774e[_0x5f72('0x4d')],'paused':_0x36774e[_0x5f72('0x4e')],'waiting':_0x36774e['waiting']};_0x12a464[_0x5f72('0x24')](_0x15e9a5);}}_0x14e20b({'count':_0x12a464[_0x5f72('0x1b')],'rows':_0x12a464});});},'MailQueues':function(_0x27b9d7){return new Promise(function(_0x339a8d,_0xf1d356){var _0x39bc0e=[];for(var _0x55daf6 in _0x57007a[_0x5f72('0x4f')]){if(_0x57007a[_0x5f72('0x4f')][_0x5f72('0x46')](_0x55daf6)){var _0x419279=_0x57007a['mailQueues'][_0x55daf6];var _0x306c75={'id':_0x419279['id'],'available':_0x419279['available'],'loggedIn':_0x419279[_0x5f72('0x4c')],'name':_0x419279[_0x5f72('0x4d')],'paused':_0x419279[_0x5f72('0x4e')],'waiting':_0x419279[_0x5f72('0x50')]};_0x39bc0e['push'](_0x306c75);}}_0x339a8d({'count':_0x39bc0e[_0x5f72('0x1b')],'rows':_0x39bc0e});});},'OpenchannelQueues':function(_0x86b9a){return new Promise(function(_0x23d8c2,_0xb07770){var _0x59af10=[];for(var _0x50bd1a in _0x57007a[_0x5f72('0x51')]){if(_0x57007a['openchannelQueues']['hasOwnProperty'](_0x50bd1a)){var _0x130e4b=_0x57007a[_0x5f72('0x51')][_0x50bd1a];var _0x2a5dcb={'id':_0x130e4b['id'],'available':_0x130e4b['available'],'loggedIn':_0x130e4b[_0x5f72('0x4c')],'name':_0x130e4b[_0x5f72('0x4d')],'paused':_0x130e4b[_0x5f72('0x4e')],'waiting':_0x130e4b[_0x5f72('0x50')]};_0x59af10[_0x5f72('0x24')](_0x2a5dcb);}}_0x23d8c2({'count':_0x59af10[_0x5f72('0x1b')],'rows':_0x59af10});});},'SmsQueues':function(_0x342a31){return new Promise(function(_0x2475e9,_0x2369ec){var _0x24aa1e=[];for(var _0x196482 in _0x57007a[_0x5f72('0x52')]){if(_0x57007a[_0x5f72('0x52')]['hasOwnProperty'](_0x196482)){var _0x1c0ba1=_0x57007a[_0x5f72('0x52')][_0x196482];var _0x3753b5={'id':_0x1c0ba1['id'],'available':_0x1c0ba1['available'],'loggedIn':_0x1c0ba1[_0x5f72('0x4c')],'name':_0x1c0ba1['name'],'paused':_0x1c0ba1['paused'],'waiting':_0x1c0ba1['waiting']};_0x24aa1e['push'](_0x3753b5);}}_0x2475e9({'count':_0x24aa1e['length'],'rows':_0x24aa1e});});},'FaxQueues':function(_0x1cd273){return new Promise(function(_0x4cc70c,_0x551736){var _0x2a846b=[];for(var _0x2404fd in _0x57007a[_0x5f72('0x53')]){if(_0x57007a[_0x5f72('0x53')][_0x5f72('0x46')](_0x2404fd)){var _0x3352c5=_0x57007a[_0x5f72('0x53')][_0x2404fd];var _0x23ebb4={'id':_0x3352c5['id'],'available':_0x3352c5['available'],'loggedIn':_0x3352c5[_0x5f72('0x4c')],'name':_0x3352c5[_0x5f72('0x4d')],'paused':_0x3352c5[_0x5f72('0x4e')],'waiting':_0x3352c5[_0x5f72('0x50')]};_0x2a846b[_0x5f72('0x24')](_0x23ebb4);}}_0x4cc70c({'count':_0x2a846b[_0x5f72('0x1b')],'rows':_0x2a846b});});},'WhatsappQueues':function(_0x1da7de){return new Promise(function(_0x3317d9,_0x251883){var _0x14b72b=[];for(var _0x18e110 in _0x57007a[_0x5f72('0x54')]){if(_0x57007a[_0x5f72('0x54')][_0x5f72('0x46')](_0x18e110)){var _0x1d5d04=_0x57007a['whatsappQueues'][_0x18e110];var _0x164fba={'id':_0x1d5d04['id'],'available':_0x1d5d04[_0x5f72('0x4b')],'loggedIn':_0x1d5d04[_0x5f72('0x4c')],'name':_0x1d5d04['name'],'paused':_0x1d5d04[_0x5f72('0x4e')],'waiting':_0x1d5d04['waiting']};_0x14b72b[_0x5f72('0x24')](_0x164fba);}}_0x3317d9({'count':_0x14b72b[_0x5f72('0x1b')],'rows':_0x14b72b});});},'ChatQueuesWaitingInteractions':function(_0x43cfc0){return new Promise(function(_0x4281b7,_0x4ee2f6){var _0x8886b4=_[_0x5f72('0x49')](_0x57007a['chatQueuesWaitingInteractions']);_0x4281b7({'count':_0x8886b4[_0x5f72('0x1b')],'rows':_0x8886b4});});},'MailQueuesWaitingInteractions':function(_0x2ee75d){return new Promise(function(_0x3fb18b,_0x2cc457){var _0x2500d1=_[_0x5f72('0x49')](_0x57007a[_0x5f72('0x55')]);_0x3fb18b({'count':_0x2500d1[_0x5f72('0x1b')],'rows':_0x2500d1});});},'OpenchannelQueuesWaitingInteractions':function(_0x5ba635){return new Promise(function(_0x71d3c6,_0x653bd0){var _0xaaae35=_[_0x5f72('0x49')](_0x57007a[_0x5f72('0x56')]);_0x71d3c6({'count':_0xaaae35[_0x5f72('0x1b')],'rows':_0xaaae35});});},'SmsQueuesWaitingInteractions':function(_0x139175){return new Promise(function(_0x28e4e8,_0x50d2ae){var _0x2f1346=_[_0x5f72('0x49')](_0x57007a[_0x5f72('0x57')]);_0x28e4e8({'count':_0x2f1346['length'],'rows':_0x2f1346});});},'FaxQueuesWaitingInteractions':function(_0x3b2cff){return new Promise(function(_0xb078a3,_0x2aff96){var _0x54b9cd=_[_0x5f72('0x49')](_0x57007a[_0x5f72('0x58')]);_0xb078a3({'count':_0x54b9cd[_0x5f72('0x1b')],'rows':_0x54b9cd});});},'WhatsappQueuesWaitingInteractions':function(_0x3afc6a){return new Promise(function(_0xc929da,_0x310930){var _0x43064f=_['values'](_0x57007a['whatsappQueuesWaitingInteractions']);_0xc929da({'count':_0x43064f['length'],'rows':_0x43064f});});}};var _0x4d2539=jayson['server'](_0x1665be)[_0x5f72('0x59')]();_0x4d2539['on']('error',function(_0xa0db47){logger[_0x5f72('0x32')](JSON[_0x5f72('0x37')](_0xa0db47));return _0x50f8c8(_0xa0db47);});_0x4d2539[_0x5f72('0x15')](0x232c,_0x5f72('0x5a'),function(){console[_0x5f72('0x5b')](_0x5f72('0x5c'),0x232c);return _0x4f81e9(_0x5f72('0x5d')+0x232c);});});};
\ No newline at end of file
+var _0xb7c8=['uuid','../../../config/environment','../../../config/logger','../rpc/openchannelQueueReport','../rpc/mailQueueReport','../rpc/chatQueueReport','../rpc/smsQueueReport','../rpc/faxQueueReport','../rpc/whatsappQueueReport','../lib/rule-engine','format','%s.%s.%s','isNil','IntervalId','Intervals','interval','listen','rules','channel','message','interaction','applications','isArray','length','existsSync','join','app','.js','toLowerCase','autoreply','appdata','split','mail','push','slice','dialogflow','dialogflowv2','amazonlex','tag','TagId','%s:%s:%s','condition','intervals','./applications/','priority','info','Push\x20new\x20rule','Please\x20create\x20a\x20new\x20file\x20under','execute','Applications\x20executed','stringify','matchPath','emit','complete','No\x20applications\x20to\x20execute','error','routing\x20is\x20empty','agent','agents','busy','busyQueue','end','QueueReport','update','catch','message\x20is\x20empty','stack','capacity','hasOwnProperty','CurrentCapacity','updateRealtime','agent\x20not\x20found','values','chatQueues','available','loggedIn','name','waiting','mailQueues','paused','openchannelQueues','faxQueues','whatsappQueues','chatQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','127.0.0.1','log','Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','util','path','jayson/promise','bluebird'];(function(_0x119bfb,_0x14375b){var _0x5ef624=function(_0x10f8c2){while(--_0x10f8c2){_0x119bfb['push'](_0x119bfb['shift']());}};_0x5ef624(++_0x14375b);}(_0xb7c8,0x119));var _0x8b7c=function(_0x37f8f9,_0x32753d){_0x37f8f9=_0x37f8f9-0x0;var _0x2990c2=_0xb7c8[_0x37f8f9];return _0x2990c2;};'use strict';var _=require('lodash');var util=require(_0x8b7c('0x0'));var path=require(_0x8b7c('0x1'));var fs=require('fs');var jayson=require(_0x8b7c('0x2'));var BPromise=require(_0x8b7c('0x3'));var uuid=require(_0x8b7c('0x4'));var config=require(_0x8b7c('0x5'));var logger=require(_0x8b7c('0x6'))('routing');var rpc={'openchannelQueueReport':require(_0x8b7c('0x7')),'mailQueueReport':require(_0x8b7c('0x8')),'chatQueueReport':require(_0x8b7c('0x9')),'smsQueueReport':require(_0x8b7c('0xa')),'faxQueueReport':require(_0x8b7c('0xb')),'whatsappQueueReport':require(_0x8b7c('0xc'))};var RuleEngine=require(_0x8b7c('0xd'));function getId(_0x3c8fd6,_0x6afb55,_0x30a924){return util[_0x8b7c('0xe')](_0x8b7c('0xf'),_0x3c8fd6,_0x6afb55||0x0,_0x30a924||0x0);}function getIntervals(_0x48370e,_0x31bf3f){var _0x5986c1=[];if(!_[_0x8b7c('0x10')](_0x31bf3f[_0x8b7c('0x11')])&&!_['isNil'](_0x48370e[_0x31bf3f[_0x8b7c('0x11')]])&&!_[_0x8b7c('0x10')](_0x48370e[_0x31bf3f[_0x8b7c('0x11')]]['Intervals'])){_0x5986c1=_['map'](_0x48370e[_0x31bf3f[_0x8b7c('0x11')]][_0x8b7c('0x12')],_0x8b7c('0x13'));}else if(!_[_0x8b7c('0x10')](_0x31bf3f[_0x8b7c('0x13')])){_0x5986c1=[_0x31bf3f[_0x8b7c('0x13')]];}return _0x5986c1;}exports[_0x8b7c('0x14')]=function(_0x56e02b){_0x56e02b[_0x8b7c('0x15')]={};return new BPromise(function(_0x19c63e,_0x5857ac){var _0x52cfe7={'Start':function(_0xd37a82){var _0x4284a2=this;return new Promise(function(_0x496bc0,_0x3b8d62){if(_0xd37a82){try{var _0xcc0fcc=[];var _0x4262b5=getId(_0xd37a82[_0x8b7c('0x16')],_0xd37a82[_0x8b7c('0x17')]?_0xd37a82['message']['id']:0x0,_0xd37a82[_0x8b7c('0x18')]?_0xd37a82[_0x8b7c('0x18')]['id']:0x0);if(_0xd37a82[_0x8b7c('0x19')]&&_[_0x8b7c('0x1a')](_0xd37a82[_0x8b7c('0x19')])&&_0xd37a82['applications'][_0x8b7c('0x1b')]){for(var _0x2b0874=0x0;_0x2b0874<_0xd37a82[_0x8b7c('0x19')][_0x8b7c('0x1b')];_0x2b0874+=0x1){var _0x7b9e59=_0xd37a82[_0x8b7c('0x19')][_0x2b0874];if(fs[_0x8b7c('0x1c')](path[_0x8b7c('0x1d')](__dirname,_0x8b7c('0x19'),_0x7b9e59[_0x8b7c('0x1e')]+_0x8b7c('0x1f')))){var _0x1fe931=[];switch(_0x7b9e59['app'][_0x8b7c('0x20')]()){case _0x8b7c('0x21'):var _0x247c62=_0x7b9e59[_0x8b7c('0x22')][_0x8b7c('0x23')](',');if(_0xd37a82[_0x8b7c('0x16')]===_0x8b7c('0x24')){_0x1fe931[_0x8b7c('0x25')](_0x247c62[0x0]);_0x1fe931[_0x8b7c('0x25')](_0x247c62[0x1]);_0x1fe931[_0x8b7c('0x25')](_0x247c62['slice'](0x2,_0x247c62['length'])[_0x8b7c('0x1d')](','));}else{_0x1fe931['push'](_0x247c62[0x0]);_0x1fe931[_0x8b7c('0x25')](_0x247c62[_0x8b7c('0x26')](0x1,_0x247c62[_0x8b7c('0x1b')])[_0x8b7c('0x1d')](','));}break;case _0x8b7c('0x27'):var _0x3d2dfa=_0x7b9e59['appdata'][_0x8b7c('0x23')](',');_0x1fe931[_0x8b7c('0x25')](_0x3d2dfa[0x0]);_0x1fe931[_0x8b7c('0x25')](_0x3d2dfa[0x1]);_0x1fe931[_0x8b7c('0x25')](_0x3d2dfa[_0x8b7c('0x26')](0x2,_0x3d2dfa[_0x8b7c('0x1b')])[_0x8b7c('0x1d')](','));break;case _0x8b7c('0x28'):var _0x329998=_0x7b9e59[_0x8b7c('0x22')]['split'](',');_0x1fe931['push'](_0x329998[0x0]);_0x1fe931[_0x8b7c('0x25')](_0x329998[0x1]);_0x1fe931[_0x8b7c('0x25')](_0x329998[0x2]);_0x1fe931[_0x8b7c('0x25')](_0x329998[0x3]);_0x1fe931[_0x8b7c('0x25')](_0x329998[_0x8b7c('0x26')](0x4,_0x329998[_0x8b7c('0x1b')])[_0x8b7c('0x1d')](','));break;case _0x8b7c('0x29'):var _0x256681=_0x7b9e59[_0x8b7c('0x22')]['split'](',');_0x1fe931[_0x8b7c('0x25')](_0x256681[0x0]);_0x1fe931['push'](_0x256681[0x1]);_0x1fe931[_0x8b7c('0x25')](_0x256681[0x2]);_0x1fe931[_0x8b7c('0x25')](_0x256681[0x3]);_0x1fe931['push'](_0x256681[_0x8b7c('0x26')](0x4,_0x256681['length'])[_0x8b7c('0x1d')](','));break;case _0x8b7c('0x17'):_0x1fe931[_0x8b7c('0x25')](_0x7b9e59[_0x8b7c('0x22')]);break;case _0x8b7c('0x2a'):_0x1fe931[_0x8b7c('0x25')](_0x7b9e59[_0x8b7c('0x2b')]);_0x1fe931[_0x8b7c('0x25')](_0x7b9e59[_0x8b7c('0x22')]);break;default:_0x1fe931=_['isNil'](_0x7b9e59[_0x8b7c('0x22')])?[]:_0x7b9e59[_0x8b7c('0x22')]['split'](',');}var _0x56a272={'id':util['format'](_0x8b7c('0x2c'),_0x4262b5,_0x7b9e59['id'],_0x7b9e59[_0x8b7c('0x1e')]),'condition':require('./interval')[_0x8b7c('0x2d')](_0x4262b5,getIntervals(_0x56e02b[_0x8b7c('0x2e')],_0x7b9e59),_0x56e02b),'consequence':require(_0x8b7c('0x2f')+_0x7b9e59[_0x8b7c('0x1e')])['consequence'](_0x4262b5,_0x1fe931,_0x56e02b,_0xd37a82),'p':_0x7b9e59[_0x8b7c('0x30')]||0x0};logger[_0x8b7c('0x31')](_0x8b7c('0x32'),_0x56a272['id'],'on\x20interval',getIntervals(_0x56e02b[_0x8b7c('0x2e')],_0x7b9e59)[_0x8b7c('0x1d')]('\x20|\x20'));_0xcc0fcc['push'](_0x56a272);}else{logger['error'](_0x8b7c('0x33'),path[_0x8b7c('0x1d')](__dirname,_0x8b7c('0x19'),_0x7b9e59[_0x8b7c('0x1e')]+_0x8b7c('0x1f')));}}_0x56e02b[_0x8b7c('0x15')][_0x4262b5]=new RuleEngine(_0xcc0fcc);_0x56e02b['rules'][_0x4262b5][_0x8b7c('0x34')](_0xd37a82,function(_0x59b721){logger[_0x8b7c('0x31')](_0x8b7c('0x35'),JSON[_0x8b7c('0x36')](_0x59b721[_0x8b7c('0x37')]));if(_0x56e02b['rules'][_0x4262b5]){_0x56e02b[_0x8b7c('0x15')][_0x4262b5][_0x8b7c('0x38')](_0x8b7c('0x39'));}});return _0x496bc0({'code':0xc8,'message':_0xd37a82});}else{logger[_0x8b7c('0x31')](_0x8b7c('0x3a'));return _0x496bc0({'code':0xc8,'message':_0xd37a82});}}catch(_0x3252f9){logger['error'](_0x3252f9['stack']);return _0x3b8d62(_0x4284a2[_0x8b7c('0x3b')](0x1f4,_0x3252f9));}}return _0x3b8d62(_0x8b7c('0x3c'));});},'AcceptMessage':function(_0x4ccebb){var _0x50908c=this;return new Promise(function(_0x1c9058,_0x3119be){if(_0x4ccebb[_0x8b7c('0x3d')]&&_0x4ccebb[_0x8b7c('0x3d')]['id']){if(_0x56e02b[_0x8b7c('0x3e')][_0x4ccebb[_0x8b7c('0x3d')]['id']]){_0x56e02b[_0x8b7c('0x3e')][_0x4ccebb[_0x8b7c('0x3d')]['id']][_0x8b7c('0x3f')]=![];_0x56e02b[_0x8b7c('0x3e')][_0x4ccebb[_0x8b7c('0x3d')]['id']][_0x8b7c('0x40')]=undefined;}}if(_0x4ccebb['message']&&_0x4ccebb[_0x8b7c('0x17')]['id']){try{var _0x21a690=getId(_0x4ccebb[_0x8b7c('0x16')],_0x4ccebb[_0x8b7c('0x17')]?_0x4ccebb[_0x8b7c('0x17')]['id']:0x0,_0x4ccebb['interaction']?_0x4ccebb['interaction']['id']:0x0);if(_0x56e02b[_0x8b7c('0x15')][_0x21a690]){_0x56e02b[_0x8b7c('0x15')][_0x21a690][_0x8b7c('0x38')](_0x8b7c('0x41'));if(rpc[_0x4ccebb[_0x8b7c('0x16')]+_0x8b7c('0x42')]){rpc[_0x4ccebb['channel']+'QueueReport'][_0x8b7c('0x43')](_0x21a690,{'UserId':_0x4ccebb[_0x8b7c('0x17')]['UserId']})[_0x8b7c('0x44')](function(_0x18dea0){logger[_0x8b7c('0x3b')]('error\x20update\x20queue\x20report');});}}return _0x1c9058({'code':0xc8,'message':_0x4ccebb});}catch(_0x4c1a90){logger[_0x8b7c('0x3b')](_0x4c1a90['stack']);return _0x3119be(_0x50908c[_0x8b7c('0x3b')](0x1f4,_0x4c1a90));}}logger[_0x8b7c('0x3b')](_0x8b7c('0x45'));return _0x3119be(_0x50908c[_0x8b7c('0x3b')](0x1f4,_0x8b7c('0x45')));});},'RejectMessage':function(_0x39219c){var _0x29aec5=this;return new Promise(function(_0x52e6f4,_0x6179ec){if(_0x39219c[_0x8b7c('0x3d')]&&_0x39219c[_0x8b7c('0x3d')]['id']){try{if(_0x56e02b[_0x8b7c('0x3e')][_0x39219c['agent']['id']]){_0x56e02b['agents'][_0x39219c['agent']['id']][_0x8b7c('0x3f')]=![];_0x56e02b[_0x8b7c('0x3e')][_0x39219c[_0x8b7c('0x3d')]['id']]['busyQueue']=undefined;}return _0x52e6f4({'code':0xc8,'message':_0x39219c});}catch(_0x190192){logger[_0x8b7c('0x3b')](_0x190192[_0x8b7c('0x46')]);return _0x6179ec(_0x29aec5[_0x8b7c('0x3b')](0x1f4,_0x190192));}}logger[_0x8b7c('0x3b')](_0x8b7c('0x45'));return _0x6179ec(_0x29aec5['error'](0x1f4,_0x8b7c('0x45')));});},'AbandonInteraction':function(_0x34413b){var _0x2e2ea8=this;return new Promise(function(_0x5d9307,_0x2c85c1){if(_0x34413b[_0x8b7c('0x16')]&&_0x34413b[_0x8b7c('0x18')]&&_0x34413b[_0x8b7c('0x18')]['id']){try{var _0x4e4a4a=getId(_0x34413b['channel'],_0x34413b[_0x8b7c('0x17')]?_0x34413b[_0x8b7c('0x17')]['id']:0x0,_0x34413b['interaction']?_0x34413b[_0x8b7c('0x18')]['id']:0x0);if(_0x56e02b[_0x8b7c('0x15')][_0x4e4a4a]){_0x56e02b[_0x8b7c('0x15')][_0x4e4a4a]['emit'](_0x8b7c('0x41'));}return _0x5d9307({'code':0xc8,'message':_0x34413b});}catch(_0x119110){logger[_0x8b7c('0x3b')](_0x119110[_0x8b7c('0x46')]);return _0x2c85c1(_0x2e2ea8[_0x8b7c('0x3b')](0x1f4,_0x119110));}}logger[_0x8b7c('0x3b')]('message\x20is\x20empty');return _0x2c85c1(_0x2e2ea8['error'](0x1f4,_0x8b7c('0x45')));});},'AgentCapacity':function(_0xea8953){var _0x4f8828=this;return new Promise(function(_0x539241,_0x4b67b5){if(_0x56e02b[_0x8b7c('0x3e')]['hasOwnProperty'](_0xea8953['id'])){for(var _0x559b98 in _0xea8953[_0x8b7c('0x47')]){if(_0xea8953['capacity'][_0x8b7c('0x48')](_0x559b98)){if(_0x56e02b[_0x8b7c('0x3e')][_0xea8953['id']][_0x8b7c('0x48')](_0x559b98+_0x8b7c('0x49'))){_0x56e02b[_0x8b7c('0x3e')][_0xea8953['id']][_0x559b98+'CurrentCapacity']=parseInt(_0xea8953[_0x8b7c('0x47')][_0x559b98],0xa);}}}_0x56e02b[_0x8b7c('0x3e')][_0xea8953['id']][_0x8b7c('0x4a')]();return _0x539241({'code':0xc8,'message':_0x56e02b[_0x8b7c('0x3e')][_0xea8953['id']]});}else{return _0x4b67b5(_0x4f8828[_0x8b7c('0x3b')](0x1f4,_0x8b7c('0x4b')));}});},'Agents':function(_0x4458fd){return new Promise(function(_0x21e779,_0x3db1a6){var _0x2a50e3=_[_0x8b7c('0x4c')](_0x56e02b[_0x8b7c('0x3e')]);_0x21e779({'count':_0x2a50e3['length'],'rows':_0x2a50e3});});},'ChatQueues':function(_0x2c2403){return new Promise(function(_0x32d2e4,_0x57bb41){var _0x4ac7fe=[];for(var _0x5dbfc6 in _0x56e02b[_0x8b7c('0x4d')]){if(_0x56e02b[_0x8b7c('0x4d')][_0x8b7c('0x48')](_0x5dbfc6)){var _0x4b8075=_0x56e02b[_0x8b7c('0x4d')][_0x5dbfc6];var _0x275071={'id':_0x4b8075['id'],'available':_0x4b8075[_0x8b7c('0x4e')],'loggedIn':_0x4b8075[_0x8b7c('0x4f')],'name':_0x4b8075[_0x8b7c('0x50')],'paused':_0x4b8075['paused'],'waiting':_0x4b8075[_0x8b7c('0x51')]};_0x4ac7fe[_0x8b7c('0x25')](_0x275071);}}_0x32d2e4({'count':_0x4ac7fe[_0x8b7c('0x1b')],'rows':_0x4ac7fe});});},'MailQueues':function(_0x232b26){return new Promise(function(_0x263dde,_0x183a99){var _0x38ab9e=[];for(var _0x6b6b14 in _0x56e02b[_0x8b7c('0x52')]){if(_0x56e02b[_0x8b7c('0x52')][_0x8b7c('0x48')](_0x6b6b14)){var _0x4a3c56=_0x56e02b[_0x8b7c('0x52')][_0x6b6b14];var _0x474dce={'id':_0x4a3c56['id'],'available':_0x4a3c56[_0x8b7c('0x4e')],'loggedIn':_0x4a3c56[_0x8b7c('0x4f')],'name':_0x4a3c56[_0x8b7c('0x50')],'paused':_0x4a3c56[_0x8b7c('0x53')],'waiting':_0x4a3c56[_0x8b7c('0x51')]};_0x38ab9e[_0x8b7c('0x25')](_0x474dce);}}_0x263dde({'count':_0x38ab9e[_0x8b7c('0x1b')],'rows':_0x38ab9e});});},'OpenchannelQueues':function(_0xd1d677){return new Promise(function(_0x1e3817,_0x31b4c0){var _0x16a318=[];for(var _0x88ebe5 in _0x56e02b[_0x8b7c('0x54')]){if(_0x56e02b[_0x8b7c('0x54')][_0x8b7c('0x48')](_0x88ebe5)){var _0x2f28f9=_0x56e02b[_0x8b7c('0x54')][_0x88ebe5];var _0x13f3ae={'id':_0x2f28f9['id'],'available':_0x2f28f9['available'],'loggedIn':_0x2f28f9['loggedIn'],'name':_0x2f28f9['name'],'paused':_0x2f28f9[_0x8b7c('0x53')],'waiting':_0x2f28f9[_0x8b7c('0x51')]};_0x16a318[_0x8b7c('0x25')](_0x13f3ae);}}_0x1e3817({'count':_0x16a318[_0x8b7c('0x1b')],'rows':_0x16a318});});},'SmsQueues':function(_0x24a109){return new Promise(function(_0x4e8624,_0x473c17){var _0x2a3e3a=[];for(var _0x3475c2 in _0x56e02b['smsQueues']){if(_0x56e02b['smsQueues'][_0x8b7c('0x48')](_0x3475c2)){var _0x4e7f41=_0x56e02b['smsQueues'][_0x3475c2];var _0x11d609={'id':_0x4e7f41['id'],'available':_0x4e7f41[_0x8b7c('0x4e')],'loggedIn':_0x4e7f41[_0x8b7c('0x4f')],'name':_0x4e7f41[_0x8b7c('0x50')],'paused':_0x4e7f41['paused'],'waiting':_0x4e7f41[_0x8b7c('0x51')]};_0x2a3e3a[_0x8b7c('0x25')](_0x11d609);}}_0x4e8624({'count':_0x2a3e3a['length'],'rows':_0x2a3e3a});});},'FaxQueues':function(_0x18e9e8){return new Promise(function(_0x1a89c3,_0x57e0a6){var _0x429ebe=[];for(var _0x182632 in _0x56e02b[_0x8b7c('0x55')]){if(_0x56e02b[_0x8b7c('0x55')][_0x8b7c('0x48')](_0x182632)){var _0x5906b6=_0x56e02b['faxQueues'][_0x182632];var _0x368986={'id':_0x5906b6['id'],'available':_0x5906b6['available'],'loggedIn':_0x5906b6[_0x8b7c('0x4f')],'name':_0x5906b6[_0x8b7c('0x50')],'paused':_0x5906b6[_0x8b7c('0x53')],'waiting':_0x5906b6[_0x8b7c('0x51')]};_0x429ebe[_0x8b7c('0x25')](_0x368986);}}_0x1a89c3({'count':_0x429ebe[_0x8b7c('0x1b')],'rows':_0x429ebe});});},'WhatsappQueues':function(_0x3206f3){return new Promise(function(_0x25cd92,_0x3fd9ed){var _0x5a891a=[];for(var _0x3da940 in _0x56e02b[_0x8b7c('0x56')]){if(_0x56e02b[_0x8b7c('0x56')]['hasOwnProperty'](_0x3da940)){var _0x3a1c8f=_0x56e02b['whatsappQueues'][_0x3da940];var _0x5d3b4a={'id':_0x3a1c8f['id'],'available':_0x3a1c8f['available'],'loggedIn':_0x3a1c8f[_0x8b7c('0x4f')],'name':_0x3a1c8f[_0x8b7c('0x50')],'paused':_0x3a1c8f[_0x8b7c('0x53')],'waiting':_0x3a1c8f[_0x8b7c('0x51')]};_0x5a891a[_0x8b7c('0x25')](_0x5d3b4a);}}_0x25cd92({'count':_0x5a891a[_0x8b7c('0x1b')],'rows':_0x5a891a});});},'ChatQueuesWaitingInteractions':function(_0xba04f6){return new Promise(function(_0xc9a4a6,_0x329bd5){var _0x26e228=_[_0x8b7c('0x4c')](_0x56e02b[_0x8b7c('0x57')]);_0xc9a4a6({'count':_0x26e228[_0x8b7c('0x1b')],'rows':_0x26e228});});},'MailQueuesWaitingInteractions':function(_0x3f38b2){return new Promise(function(_0x13e718,_0x297e1f){var _0x56e623=_[_0x8b7c('0x4c')](_0x56e02b['mailQueuesWaitingInteractions']);_0x13e718({'count':_0x56e623[_0x8b7c('0x1b')],'rows':_0x56e623});});},'OpenchannelQueuesWaitingInteractions':function(_0x43bef2){return new Promise(function(_0x17db87,_0x3eef37){var _0x900b5c=_[_0x8b7c('0x4c')](_0x56e02b[_0x8b7c('0x58')]);_0x17db87({'count':_0x900b5c[_0x8b7c('0x1b')],'rows':_0x900b5c});});},'SmsQueuesWaitingInteractions':function(_0x2ad50f){return new Promise(function(_0x21e09d,_0x3b7e24){var _0x5b8d8f=_[_0x8b7c('0x4c')](_0x56e02b[_0x8b7c('0x59')]);_0x21e09d({'count':_0x5b8d8f['length'],'rows':_0x5b8d8f});});},'FaxQueuesWaitingInteractions':function(_0x966e37){return new Promise(function(_0x297224,_0x621699){var _0x39e24f=_[_0x8b7c('0x4c')](_0x56e02b['faxQueuesWaitingInteractions']);_0x297224({'count':_0x39e24f['length'],'rows':_0x39e24f});});},'WhatsappQueuesWaitingInteractions':function(_0x2687a0){return new Promise(function(_0x506ba7,_0x35694f){var _0x166d3c=_[_0x8b7c('0x4c')](_0x56e02b[_0x8b7c('0x5a')]);_0x506ba7({'count':_0x166d3c[_0x8b7c('0x1b')],'rows':_0x166d3c});});}};var _0x48c7dd=jayson['server'](_0x52cfe7)['http']();_0x48c7dd['on'](_0x8b7c('0x3b'),function(_0x2a534b){logger['error'](JSON[_0x8b7c('0x36')](_0x2a534b));return _0x5857ac(_0x2a534b);});_0x48c7dd['listen'](0x232c,_0x8b7c('0x5b'),function(){console[_0x8b7c('0x5c')](_0x8b7c('0x5d'),0x232c);return _0x19c63e(_0x8b7c('0x5e')+0x232c);});});};
\ No newline at end of file