Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / services / routing / server / index.js
index 9a34d97..1316e00 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8820=['./interval','condition','intervals','./applications/','consequence','priority','info','Push\x20new\x20rule','on\x20interval','Please\x20create\x20a\x20new\x20file\x20under','.js','execute','Applications\x20executed','stringify','matchPath','complete','No\x20applications\x20to\x20execute','error','stack','emit','end','QueueReport','update','UserId','catch','error\x20update\x20queue\x20report','message\x20is\x20empty','agent','agents','busy','hasOwnProperty','capacity','CurrentCapacity','updateRealtime','agent\x20not\x20found','values','chatQueues','available','loggedIn','paused','waiting','mailQueues','name','openchannelQueues','smsQueues','faxQueues','chatQueuesWaitingInteractions','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','server','127.0.0.1','log','Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','lodash','util','path','uuid','../../../config/environment','../../../config/logger','routing','../rpc/openchannelQueueReport','../rpc/mailQueueReport','../rpc/chatQueueReport','format','%s.%s.%s','isNil','IntervalId','Intervals','map','interval','listen','rules','channel','message','interaction','applications','isArray','length','existsSync','join','app','toLowerCase','autoreply','appdata','split','push','slice','dialogflow','tag','%s:%s:%s'];(function(_0x3ae109,_0x14af4a){var _0x6cf6fe=function(_0x55208b){while(--_0x55208b){_0x3ae109['push'](_0x3ae109['shift']());}};_0x6cf6fe(++_0x14af4a);}(_0x8820,0x93));var _0x0882=function(_0x331dd8,_0x15e211){_0x331dd8=_0x331dd8-0x0;var _0x56408f=_0x8820[_0x331dd8];return _0x56408f;};'use strict';var _=require(_0x0882('0x0'));var util=require(_0x0882('0x1'));var path=require(_0x0882('0x2'));var fs=require('fs');var jayson=require('jayson/promise');var BPromise=require('bluebird');var uuid=require(_0x0882('0x3'));var config=require(_0x0882('0x4'));var logger=require(_0x0882('0x5'))(_0x0882('0x6'));var rpc={'openchannelQueueReport':require('../rpc/openchannelQueueReport')};var rpc={'openchannelQueueReport':require(_0x0882('0x7')),'mailQueueReport':require(_0x0882('0x8')),'chatQueueReport':require(_0x0882('0x9')),'smsQueueReport':require('../rpc/smsQueueReport'),'faxQueueReport':require('../rpc/faxQueueReport')};var RuleEngine=require('../lib/rule-engine');function getId(_0x376279,_0x4f3666,_0x325db6){return util[_0x0882('0xa')](_0x0882('0xb'),_0x376279,_0x4f3666||0x0,_0x325db6||0x0);}function getIntervals(_0x478d9d,_0x2d31bf){var _0x46c0d4=[];if(!_[_0x0882('0xc')](_0x2d31bf[_0x0882('0xd')])&&!_[_0x0882('0xc')](_0x478d9d[_0x2d31bf[_0x0882('0xd')]])&&!_[_0x0882('0xc')](_0x478d9d[_0x2d31bf[_0x0882('0xd')]][_0x0882('0xe')])){_0x46c0d4=_[_0x0882('0xf')](_0x478d9d[_0x2d31bf[_0x0882('0xd')]]['Intervals'],_0x0882('0x10'));}else if(!_['isNil'](_0x2d31bf['interval'])){_0x46c0d4=[_0x2d31bf[_0x0882('0x10')]];}return _0x46c0d4;}exports[_0x0882('0x11')]=function(_0x3a8541){_0x3a8541[_0x0882('0x12')]={};return new BPromise(function(_0x304d3d,_0x2f5985){var _0x2cf006={'Start':function(_0x5ee1ea){var _0x39d283=this;return new Promise(function(_0x3838d2,_0x163a96){if(_0x5ee1ea){try{var _0x277d59=[];var _0x34b0c2=getId(_0x5ee1ea[_0x0882('0x13')],_0x5ee1ea['message']?_0x5ee1ea[_0x0882('0x14')]['id']:0x0,_0x5ee1ea[_0x0882('0x15')]?_0x5ee1ea['interaction']['id']:0x0);if(_0x5ee1ea[_0x0882('0x16')]&&_[_0x0882('0x17')](_0x5ee1ea[_0x0882('0x16')])&&_0x5ee1ea[_0x0882('0x16')]['length']){for(var _0x4c6cb6=0x0;_0x4c6cb6<_0x5ee1ea[_0x0882('0x16')][_0x0882('0x18')];_0x4c6cb6+=0x1){var _0x5f55ad=_0x5ee1ea[_0x0882('0x16')][_0x4c6cb6];if(fs[_0x0882('0x19')](path[_0x0882('0x1a')](__dirname,_0x0882('0x16'),_0x5f55ad[_0x0882('0x1b')]+'.js'))){var _0x147950=[];switch(_0x5f55ad[_0x0882('0x1b')][_0x0882('0x1c')]()){case _0x0882('0x1d'):var _0x30038e=_0x5f55ad[_0x0882('0x1e')][_0x0882('0x1f')](',');_0x147950[_0x0882('0x20')](_0x30038e[0x0]);_0x147950['push'](_0x30038e[_0x0882('0x21')](0x1,_0x30038e['length'])[_0x0882('0x1a')](','));break;case _0x0882('0x22'):var _0xdf6a25=_0x5f55ad[_0x0882('0x1e')][_0x0882('0x1f')](',');_0x147950[_0x0882('0x20')](_0xdf6a25[0x0]);_0x147950['push'](_0xdf6a25[0x1]);_0x147950[_0x0882('0x20')](_0xdf6a25[_0x0882('0x21')](0x2,_0xdf6a25[_0x0882('0x18')])[_0x0882('0x1a')](','));break;case'amazonlex':var _0x182369=_0x5f55ad['appdata'][_0x0882('0x1f')](',');_0x147950['push'](_0x182369[0x0]);_0x147950[_0x0882('0x20')](_0x182369[0x1]);_0x147950[_0x0882('0x20')](_0x182369[0x2]);_0x147950[_0x0882('0x20')](_0x182369[0x3]);_0x147950['push'](_0x182369[_0x0882('0x21')](0x4,_0x182369['length'])[_0x0882('0x1a')](','));break;case _0x0882('0x14'):_0x147950[_0x0882('0x20')](_0x5f55ad[_0x0882('0x1e')]);break;case _0x0882('0x23'):_0x147950[_0x0882('0x20')](_0x5f55ad['TagId']);_0x147950[_0x0882('0x20')](_0x5f55ad[_0x0882('0x1e')]);break;default:_0x147950=_[_0x0882('0xc')](_0x5f55ad[_0x0882('0x1e')])?[]:_0x5f55ad['appdata'][_0x0882('0x1f')](',');}var _0x3b9c24={'id':util['format'](_0x0882('0x24'),_0x34b0c2,_0x5f55ad['id'],_0x5f55ad[_0x0882('0x1b')]),'condition':require(_0x0882('0x25'))[_0x0882('0x26')](_0x34b0c2,getIntervals(_0x3a8541[_0x0882('0x27')],_0x5f55ad),_0x3a8541),'consequence':require(_0x0882('0x28')+_0x5f55ad[_0x0882('0x1b')])[_0x0882('0x29')](_0x34b0c2,_0x147950,_0x3a8541,_0x5ee1ea),'p':_0x5f55ad[_0x0882('0x2a')]||0x0};logger[_0x0882('0x2b')](_0x0882('0x2c'),_0x3b9c24['id'],_0x0882('0x2d'),getIntervals(_0x3a8541['intervals'],_0x5f55ad)['join']('\x20|\x20'));_0x277d59['push'](_0x3b9c24);}else{logger['error'](_0x0882('0x2e'),path['join'](__dirname,_0x0882('0x16'),_0x5f55ad[_0x0882('0x1b')]+_0x0882('0x2f')));}}_0x3a8541[_0x0882('0x12')][_0x34b0c2]=new RuleEngine(_0x277d59);_0x3a8541[_0x0882('0x12')][_0x34b0c2][_0x0882('0x30')](_0x5ee1ea,function(_0x190eaa){logger['info'](_0x0882('0x31'),JSON[_0x0882('0x32')](_0x190eaa[_0x0882('0x33')]));if(_0x3a8541[_0x0882('0x12')][_0x34b0c2]){_0x3a8541['rules'][_0x34b0c2]['emit'](_0x0882('0x34'));}});return _0x3838d2({'code':0xc8,'message':_0x5ee1ea});}else{logger[_0x0882('0x2b')](_0x0882('0x35'));return _0x3838d2({'code':0xc8,'message':_0x5ee1ea});}}catch(_0x3bb847){logger[_0x0882('0x36')](_0x3bb847[_0x0882('0x37')]);return _0x163a96(_0x39d283[_0x0882('0x36')](0x1f4,_0x3bb847));}}return _0x163a96('routing\x20is\x20empty');});},'AcceptMessage':function(_0x322c10){var _0x1a52a5=this;return new Promise(function(_0x42dfcf,_0x3b1978){if(_0x322c10['message']&&_0x322c10[_0x0882('0x14')]['id']){try{var _0x289b04=getId(_0x322c10[_0x0882('0x13')],_0x322c10['message']?_0x322c10['message']['id']:0x0,_0x322c10['interaction']?_0x322c10[_0x0882('0x15')]['id']:0x0);if(_0x3a8541[_0x0882('0x12')][_0x289b04]){_0x3a8541[_0x0882('0x12')][_0x289b04][_0x0882('0x38')](_0x0882('0x39'));if(rpc[_0x322c10[_0x0882('0x13')]+_0x0882('0x3a')]){rpc[_0x322c10[_0x0882('0x13')]+_0x0882('0x3a')][_0x0882('0x3b')](_0x289b04,{'UserId':_0x322c10[_0x0882('0x14')][_0x0882('0x3c')]})[_0x0882('0x3d')](function(_0x3c1f1a){logger[_0x0882('0x36')](_0x0882('0x3e'));});}}return _0x42dfcf({'code':0xc8,'message':_0x322c10});}catch(_0x3df6c5){logger[_0x0882('0x36')](_0x3df6c5[_0x0882('0x37')]);return _0x3b1978(_0x1a52a5[_0x0882('0x36')](0x1f4,_0x3df6c5));}}logger[_0x0882('0x36')](_0x0882('0x3f'));return _0x3b1978(_0x1a52a5[_0x0882('0x36')](0x1f4,_0x0882('0x3f')));});},'RejectMessage':function(_0x420210){var _0x6fd3df=this;return new Promise(function(_0x148117,_0x45799a){if(_0x420210['agent']&&_0x420210[_0x0882('0x40')]['id']){try{if(_0x3a8541[_0x0882('0x41')][_0x420210[_0x0882('0x40')]['id']]){_0x3a8541[_0x0882('0x41')][_0x420210[_0x0882('0x40')]['id']][_0x0882('0x42')]=![];_0x3a8541['agents'][_0x420210['agent']['id']]['busyQueue']=undefined;}return _0x148117({'code':0xc8,'message':_0x420210});}catch(_0x5d9f39){logger['error'](_0x5d9f39['stack']);return _0x45799a(_0x6fd3df['error'](0x1f4,_0x5d9f39));}}logger[_0x0882('0x36')]('message\x20is\x20empty');return _0x45799a(_0x6fd3df[_0x0882('0x36')](0x1f4,_0x0882('0x3f')));});},'AbandonInteraction':function(_0x36aa3d){var _0x487c7c=this;return new Promise(function(_0x46f458,_0x2497d4){if(_0x36aa3d['channel']&&_0x36aa3d[_0x0882('0x15')]&&_0x36aa3d[_0x0882('0x15')]['id']){try{var _0x2eddd4=getId(_0x36aa3d['channel'],_0x36aa3d['message']?_0x36aa3d[_0x0882('0x14')]['id']:0x0,_0x36aa3d[_0x0882('0x15')]?_0x36aa3d[_0x0882('0x15')]['id']:0x0);if(_0x3a8541[_0x0882('0x12')][_0x2eddd4]){_0x3a8541[_0x0882('0x12')][_0x2eddd4]['emit'](_0x0882('0x39'));}return _0x46f458({'code':0xc8,'message':_0x36aa3d});}catch(_0x244876){logger[_0x0882('0x36')](_0x244876[_0x0882('0x37')]);return _0x2497d4(_0x487c7c[_0x0882('0x36')](0x1f4,_0x244876));}}logger['error'](_0x0882('0x3f'));return _0x2497d4(_0x487c7c[_0x0882('0x36')](0x1f4,_0x0882('0x3f')));});},'AgentCapacity':function(_0x9acd50){var _0x37ff00=this;return new Promise(function(_0x19c955,_0x1d868b){if(_0x3a8541[_0x0882('0x41')][_0x0882('0x43')](_0x9acd50['id'])){for(var _0x4a2b92 in _0x9acd50[_0x0882('0x44')]){if(_0x9acd50[_0x0882('0x44')][_0x0882('0x43')](_0x4a2b92)){if(_0x3a8541[_0x0882('0x41')][_0x9acd50['id']][_0x0882('0x43')](_0x4a2b92+_0x0882('0x45'))){_0x3a8541['agents'][_0x9acd50['id']][_0x4a2b92+_0x0882('0x45')]=parseInt(_0x9acd50[_0x0882('0x44')][_0x4a2b92],0xa);}}}_0x3a8541[_0x0882('0x41')][_0x9acd50['id']][_0x0882('0x46')]();return _0x19c955({'code':0xc8,'message':_0x3a8541['agents'][_0x9acd50['id']]});}else{return _0x1d868b(_0x37ff00[_0x0882('0x36')](0x1f4,_0x0882('0x47')));}});},'Agents':function(_0x337abf){return new Promise(function(_0x138c59,_0x31dae4){var _0x3a4b84=_[_0x0882('0x48')](_0x3a8541['agents']);_0x138c59({'count':_0x3a4b84[_0x0882('0x18')],'rows':_0x3a4b84});});},'ChatQueues':function(_0x507064){return new Promise(function(_0x25ee36,_0xb81bb5){var _0x37bdce=[];for(var _0x4bdf25 in _0x3a8541['chatQueues']){if(_0x3a8541[_0x0882('0x49')][_0x0882('0x43')](_0x4bdf25)){var _0x804536=_0x3a8541[_0x0882('0x49')][_0x4bdf25];var _0x329c0e={'id':_0x804536['id'],'available':_0x804536[_0x0882('0x4a')],'loggedIn':_0x804536[_0x0882('0x4b')],'name':_0x804536['name'],'paused':_0x804536[_0x0882('0x4c')],'waiting':_0x804536[_0x0882('0x4d')]};_0x37bdce['push'](_0x329c0e);}}_0x25ee36({'count':_0x37bdce['length'],'rows':_0x37bdce});});},'MailQueues':function(_0x10794f){return new Promise(function(_0x5c1b06,_0x32ce75){var _0x2a63f3=[];for(var _0x492679 in _0x3a8541['mailQueues']){if(_0x3a8541[_0x0882('0x4e')][_0x0882('0x43')](_0x492679)){var _0x39eaa0=_0x3a8541[_0x0882('0x4e')][_0x492679];var _0x49bcbe={'id':_0x39eaa0['id'],'available':_0x39eaa0['available'],'loggedIn':_0x39eaa0[_0x0882('0x4b')],'name':_0x39eaa0[_0x0882('0x4f')],'paused':_0x39eaa0[_0x0882('0x4c')],'waiting':_0x39eaa0['waiting']};_0x2a63f3['push'](_0x49bcbe);}}_0x5c1b06({'count':_0x2a63f3[_0x0882('0x18')],'rows':_0x2a63f3});});},'OpenchannelQueues':function(_0x2e6dbf){return new Promise(function(_0x198283,_0x489eb3){var _0x33e201=[];for(var _0x1d962f in _0x3a8541[_0x0882('0x50')]){if(_0x3a8541[_0x0882('0x50')]['hasOwnProperty'](_0x1d962f)){var _0x20aab2=_0x3a8541[_0x0882('0x50')][_0x1d962f];var _0x3d4a80={'id':_0x20aab2['id'],'available':_0x20aab2[_0x0882('0x4a')],'loggedIn':_0x20aab2[_0x0882('0x4b')],'name':_0x20aab2['name'],'paused':_0x20aab2[_0x0882('0x4c')],'waiting':_0x20aab2[_0x0882('0x4d')]};_0x33e201[_0x0882('0x20')](_0x3d4a80);}}_0x198283({'count':_0x33e201[_0x0882('0x18')],'rows':_0x33e201});});},'SmsQueues':function(_0x28132d){return new Promise(function(_0x1809f8,_0xbf5c0f){var _0x3d50e8=[];for(var _0x4307df in _0x3a8541['smsQueues']){if(_0x3a8541[_0x0882('0x51')][_0x0882('0x43')](_0x4307df)){var _0x1d0c34=_0x3a8541[_0x0882('0x51')][_0x4307df];var _0x104458={'id':_0x1d0c34['id'],'available':_0x1d0c34[_0x0882('0x4a')],'loggedIn':_0x1d0c34['loggedIn'],'name':_0x1d0c34[_0x0882('0x4f')],'paused':_0x1d0c34[_0x0882('0x4c')],'waiting':_0x1d0c34[_0x0882('0x4d')]};_0x3d50e8[_0x0882('0x20')](_0x104458);}}_0x1809f8({'count':_0x3d50e8[_0x0882('0x18')],'rows':_0x3d50e8});});},'FaxQueues':function(_0x5bab35){return new Promise(function(_0x5f3dfb,_0xbd199b){var _0x5cb9b3=[];for(var _0x49dfc6 in _0x3a8541[_0x0882('0x52')]){if(_0x3a8541['faxQueues'][_0x0882('0x43')](_0x49dfc6)){var _0x17d604=_0x3a8541['faxQueues'][_0x49dfc6];var _0x485bda={'id':_0x17d604['id'],'available':_0x17d604[_0x0882('0x4a')],'loggedIn':_0x17d604[_0x0882('0x4b')],'name':_0x17d604[_0x0882('0x4f')],'paused':_0x17d604[_0x0882('0x4c')],'waiting':_0x17d604['waiting']};_0x5cb9b3[_0x0882('0x20')](_0x485bda);}}_0x5f3dfb({'count':_0x5cb9b3['length'],'rows':_0x5cb9b3});});},'ChatQueuesWaitingInteractions':function(_0x9bbeed){return new Promise(function(_0x28d49c,_0x38c7c4){var _0x138c85=_[_0x0882('0x48')](_0x3a8541[_0x0882('0x53')]);_0x28d49c({'count':_0x138c85['length'],'rows':_0x138c85});});},'MailQueuesWaitingInteractions':function(_0x5670e3){return new Promise(function(_0x476105,_0x18a99e){var _0x576ac2=_[_0x0882('0x48')](_0x3a8541[_0x0882('0x54')]);_0x476105({'count':_0x576ac2[_0x0882('0x18')],'rows':_0x576ac2});});},'OpenchannelQueuesWaitingInteractions':function(_0x222033){return new Promise(function(_0x22220c,_0x4e82c5){var _0x38c62e=_[_0x0882('0x48')](_0x3a8541[_0x0882('0x55')]);_0x22220c({'count':_0x38c62e[_0x0882('0x18')],'rows':_0x38c62e});});},'SmsQueuesWaitingInteractions':function(_0x1a130c){return new Promise(function(_0x200a19,_0x2cf9b2){var _0x5d1e52=_[_0x0882('0x48')](_0x3a8541[_0x0882('0x56')]);_0x200a19({'count':_0x5d1e52[_0x0882('0x18')],'rows':_0x5d1e52});});},'FaxQueuesWaitingInteractions':function(_0x105d80){return new Promise(function(_0x5bf32e,_0x5cf7c0){var _0x32a4a9=_[_0x0882('0x48')](_0x3a8541[_0x0882('0x57')]);_0x5bf32e({'count':_0x32a4a9[_0x0882('0x18')],'rows':_0x32a4a9});});}};var _0x299aa7=jayson[_0x0882('0x58')](_0x2cf006)['http']();_0x299aa7['on'](_0x0882('0x36'),function(_0x150740){logger['error'](JSON[_0x0882('0x32')](_0x150740));return _0x2f5985(_0x150740);});_0x299aa7['listen'](0x232c,_0x0882('0x59'),function(){console[_0x0882('0x5a')](_0x0882('0x5b'),0x232c);return _0x304d3d('RPC\x20listening\x20on\x20port:'+0x232c);});});};
\ No newline at end of file
+var _0xa446=['127.0.0.1','log','Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','lodash','util','jayson/promise','uuid','../../../config/environment','routing','../rpc/openchannelQueueReport','../rpc/mailQueueReport','../rpc/chatQueueReport','../rpc/smsQueueReport','../rpc/faxQueueReport','../lib/rule-engine','format','isNil','IntervalId','Intervals','interval','listen','rules','channel','message','interaction','applications','isArray','length','existsSync','join','.js','toLowerCase','autoreply','appdata','split','mail','push','slice','dialogflow','dialogflowv2','amazonlex','tag','TagId','tvox','getMustacheRender','account','ChatWebsiteId','ContactId','body','%s:%s:%s','app','./interval','condition','./applications/','consequence','info','Push\x20new\x20rule','error','Please\x20create\x20a\x20new\x20file\x20under','execute','Applications\x20executed','stringify','emit','complete','No\x20applications\x20to\x20execute','routing\x20is\x20empty','agent','agents','busy','busyQueue','end','QueueReport','catch','message\x20is\x20empty','stack','hasOwnProperty','capacity','CurrentCapacity','updateRealtime','values','chatQueues','available','loggedIn','name','paused','waiting','openchannelQueues','smsQueues','faxQueues','whatsappQueues','chatQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','server','http'];(function(_0x21ecc8,_0x2bdead){var _0x510c1d=function(_0x3b6862){while(--_0x3b6862){_0x21ecc8['push'](_0x21ecc8['shift']());}};_0x510c1d(++_0x2bdead);}(_0xa446,0xc6));var _0x6a44=function(_0x4d822c,_0x3ae665){_0x4d822c=_0x4d822c-0x0;var _0xdc2439=_0xa446[_0x4d822c];return _0xdc2439;};'use strict';var _=require(_0x6a44('0x0'));var util=require(_0x6a44('0x1'));var path=require('path');var fs=require('fs');var jayson=require(_0x6a44('0x2'));var BPromise=require('bluebird');var uuid=require(_0x6a44('0x3'));var utils=require('./applications/utils');var config=require(_0x6a44('0x4'));var logger=require('../../../config/logger')(_0x6a44('0x5'));var rpc={'openchannelQueueReport':require(_0x6a44('0x6')),'mailQueueReport':require(_0x6a44('0x7')),'chatQueueReport':require(_0x6a44('0x8')),'smsQueueReport':require(_0x6a44('0x9')),'faxQueueReport':require(_0x6a44('0xa')),'whatsappQueueReport':require('../rpc/whatsappQueueReport')};var RuleEngine=require(_0x6a44('0xb'));function getId(_0x36a426,_0x4f72f8,_0x78c684){return util[_0x6a44('0xc')]('%s.%s.%s',_0x36a426,_0x4f72f8||0x0,_0x78c684||0x0);}function getIntervals(_0x38a9ad,_0x2657b9){var _0x419ccd=[];if(!_[_0x6a44('0xd')](_0x2657b9[_0x6a44('0xe')])&&!_[_0x6a44('0xd')](_0x38a9ad[_0x2657b9[_0x6a44('0xe')]])&&!_['isNil'](_0x38a9ad[_0x2657b9[_0x6a44('0xe')]][_0x6a44('0xf')])){_0x419ccd=_['map'](_0x38a9ad[_0x2657b9[_0x6a44('0xe')]][_0x6a44('0xf')],_0x6a44('0x10'));}else if(!_['isNil'](_0x2657b9[_0x6a44('0x10')])){_0x419ccd=[_0x2657b9[_0x6a44('0x10')]];}return _0x419ccd;}exports[_0x6a44('0x11')]=function(_0xb1d987){_0xb1d987[_0x6a44('0x12')]={};return new BPromise(function(_0x1481ed,_0x553bc1){var _0x52aa9c={'Start':function(_0x260be6){var _0x973938=this;return new Promise(function(_0x577275,_0xa665c0){if(_0x260be6){try{var _0x38f796=[];var _0x41af8f=getId(_0x260be6[_0x6a44('0x13')],_0x260be6[_0x6a44('0x14')]?_0x260be6[_0x6a44('0x14')]['id']:0x0,_0x260be6[_0x6a44('0x15')]?_0x260be6[_0x6a44('0x15')]['id']:0x0);if(_0x260be6[_0x6a44('0x16')]&&_[_0x6a44('0x17')](_0x260be6[_0x6a44('0x16')])&&_0x260be6[_0x6a44('0x16')][_0x6a44('0x18')]){for(var _0x108c4b=0x0;_0x108c4b<_0x260be6['applications']['length'];_0x108c4b+=0x1){var _0x5e3673=_0x260be6[_0x6a44('0x16')][_0x108c4b];if(fs[_0x6a44('0x19')](path[_0x6a44('0x1a')](__dirname,_0x6a44('0x16'),_0x5e3673['app']+_0x6a44('0x1b')))){var _0x24ba62=[];switch(_0x5e3673['app'][_0x6a44('0x1c')]()){case _0x6a44('0x1d'):var _0x406247=_0x5e3673[_0x6a44('0x1e')][_0x6a44('0x1f')](',');if(_0x260be6[_0x6a44('0x13')]===_0x6a44('0x20')){_0x24ba62[_0x6a44('0x21')](_0x406247[0x0]);_0x24ba62[_0x6a44('0x21')](_0x406247[0x1]);_0x24ba62['push'](_0x406247[_0x6a44('0x22')](0x2,_0x406247[_0x6a44('0x18')])[_0x6a44('0x1a')](','));}else{_0x24ba62[_0x6a44('0x21')](_0x406247[0x0]);_0x24ba62['push'](_0x406247[_0x6a44('0x22')](0x1,_0x406247['length'])[_0x6a44('0x1a')](','));}break;case _0x6a44('0x23'):var _0x23d6a1=_0x5e3673[_0x6a44('0x1e')][_0x6a44('0x1f')](',');_0x24ba62[_0x6a44('0x21')](_0x23d6a1[0x0]);_0x24ba62[_0x6a44('0x21')](_0x23d6a1[0x1]);_0x24ba62[_0x6a44('0x21')](_0x23d6a1[_0x6a44('0x22')](0x2,_0x23d6a1['length'])['join'](','));break;case _0x6a44('0x24'):var _0x5abc23=_0x5e3673[_0x6a44('0x1e')]['split'](',');_0x24ba62['push'](_0x5abc23[0x0]);_0x24ba62[_0x6a44('0x21')](_0x5abc23[0x1]);_0x24ba62[_0x6a44('0x21')](_0x5abc23[0x2]);_0x24ba62[_0x6a44('0x21')](_0x5abc23[0x3]);_0x24ba62['push'](_0x5abc23[_0x6a44('0x22')](0x4,_0x5abc23['length'])[_0x6a44('0x1a')](','));break;case _0x6a44('0x25'):var _0x4b41c6=_0x5e3673['appdata'][_0x6a44('0x1f')](',');_0x24ba62[_0x6a44('0x21')](_0x4b41c6[0x0]);_0x24ba62[_0x6a44('0x21')](_0x4b41c6[0x1]);_0x24ba62['push'](_0x4b41c6[0x2]);_0x24ba62['push'](_0x4b41c6[0x3]);_0x24ba62[_0x6a44('0x21')](_0x4b41c6[_0x6a44('0x22')](0x4,_0x4b41c6[_0x6a44('0x18')])['join'](','));break;case _0x6a44('0x14'):_0x24ba62[_0x6a44('0x21')](_0x5e3673[_0x6a44('0x1e')]);break;case _0x6a44('0x26'):_0x24ba62[_0x6a44('0x21')](_0x5e3673[_0x6a44('0x27')]);_0x24ba62[_0x6a44('0x21')](_0x5e3673[_0x6a44('0x1e')]);break;case _0x6a44('0x28'):var _0x42d95a=utils[_0x6a44('0x29')](_0x260be6[_0x6a44('0x2a')]['notificationTemplate'],_0x260be6);var _0x198977=_0x5e3673['appdata']['split'](',');_0x24ba62['push'](_0x198977[0x0]);_0x24ba62['push'](_0x198977[0x1]);_0x24ba62[_0x6a44('0x21')](_0x198977[0x2]);_0x24ba62['push'](_0x198977[0x3]);_0x24ba62[_0x6a44('0x21')](_0x198977[0x4]);_0x24ba62['push'](_0x198977[0x5]);_0x24ba62[_0x6a44('0x21')](_0x198977[0x6]);_0x24ba62[_0x6a44('0x21')](_0x198977[0x7]);_0x24ba62['push'](_0x198977[0x8]);_0x24ba62['push'](_0x198977[0x9]);_0x24ba62[_0x6a44('0x21')](_0x198977[0xa]);_0x24ba62[_0x6a44('0x21')](_0x260be6[_0x6a44('0x15')]['id']);_0x24ba62[_0x6a44('0x21')](_0x260be6['message']['id']);_0x24ba62[_0x6a44('0x21')](_0x5e3673[_0x6a44('0x2b')]);_0x24ba62[_0x6a44('0x21')](_0x260be6[_0x6a44('0x15')][_0x6a44('0x2c')]);_0x24ba62[_0x6a44('0x21')](_0x260be6['body'][_0x6a44('0x2d')]);_0x24ba62[_0x6a44('0x21')](_0x42d95a);break;default:_0x24ba62=_['isNil'](_0x5e3673[_0x6a44('0x1e')])?[]:_0x5e3673['appdata'][_0x6a44('0x1f')](',');}var _0x527df6={'id':util[_0x6a44('0xc')](_0x6a44('0x2e'),_0x41af8f,_0x5e3673['id'],_0x5e3673[_0x6a44('0x2f')]),'condition':require(_0x6a44('0x30'))[_0x6a44('0x31')](_0x41af8f,getIntervals(_0xb1d987['intervals'],_0x5e3673),_0xb1d987),'consequence':require(_0x6a44('0x32')+_0x5e3673[_0x6a44('0x2f')])[_0x6a44('0x33')](_0x41af8f,_0x24ba62,_0xb1d987,_0x260be6),'p':_0x5e3673['priority']||0x0};logger[_0x6a44('0x34')](_0x6a44('0x35'),_0x527df6['id'],'on\x20interval',getIntervals(_0xb1d987['intervals'],_0x5e3673)['join']('\x20|\x20'));_0x38f796[_0x6a44('0x21')](_0x527df6);}else{logger[_0x6a44('0x36')](_0x6a44('0x37'),path[_0x6a44('0x1a')](__dirname,_0x6a44('0x16'),_0x5e3673['app']+'.js'));}}_0xb1d987[_0x6a44('0x12')][_0x41af8f]=new RuleEngine(_0x38f796);_0xb1d987[_0x6a44('0x12')][_0x41af8f][_0x6a44('0x38')](_0x260be6,function(_0x4eb5d6){logger[_0x6a44('0x34')](_0x6a44('0x39'),JSON[_0x6a44('0x3a')](_0x4eb5d6['matchPath']));if(_0xb1d987[_0x6a44('0x12')][_0x41af8f]){_0xb1d987[_0x6a44('0x12')][_0x41af8f][_0x6a44('0x3b')](_0x6a44('0x3c'));}});return _0x577275({'code':0xc8,'message':_0x260be6});}else{logger[_0x6a44('0x34')](_0x6a44('0x3d'));return _0x577275({'code':0xc8,'message':_0x260be6});}}catch(_0x32b24d){logger[_0x6a44('0x36')](_0x32b24d['stack']);return _0xa665c0(_0x973938[_0x6a44('0x36')](0x1f4,_0x32b24d));}}return _0xa665c0(_0x6a44('0x3e'));});},'AcceptMessage':function(_0x2ccdbc){var _0x446fbf=this;return new Promise(function(_0x1362c7,_0x3fcb0b){if(_0x2ccdbc[_0x6a44('0x3f')]&&_0x2ccdbc[_0x6a44('0x3f')]['id']){if(_0xb1d987[_0x6a44('0x40')][_0x2ccdbc['agent']['id']]){_0xb1d987[_0x6a44('0x40')][_0x2ccdbc[_0x6a44('0x3f')]['id']][_0x6a44('0x41')]=![];_0xb1d987[_0x6a44('0x40')][_0x2ccdbc[_0x6a44('0x3f')]['id']][_0x6a44('0x42')]=undefined;}}if(_0x2ccdbc[_0x6a44('0x14')]&&_0x2ccdbc[_0x6a44('0x14')]['id']){try{var _0x4de88b=getId(_0x2ccdbc[_0x6a44('0x13')],_0x2ccdbc[_0x6a44('0x14')]?_0x2ccdbc[_0x6a44('0x14')]['id']:0x0,_0x2ccdbc['interaction']?_0x2ccdbc[_0x6a44('0x15')]['id']:0x0);if(_0xb1d987['rules'][_0x4de88b]){_0xb1d987['rules'][_0x4de88b][_0x6a44('0x3b')](_0x6a44('0x43'));if(rpc[_0x2ccdbc['channel']+'QueueReport']){rpc[_0x2ccdbc[_0x6a44('0x13')]+_0x6a44('0x44')]['update'](_0x4de88b,{'UserId':_0x2ccdbc[_0x6a44('0x14')]['UserId']})[_0x6a44('0x45')](function(_0x434ded){logger[_0x6a44('0x36')]('error\x20update\x20queue\x20report');});}}return _0x1362c7({'code':0xc8,'message':_0x2ccdbc});}catch(_0x52b343){logger['error'](_0x52b343['stack']);return _0x3fcb0b(_0x446fbf[_0x6a44('0x36')](0x1f4,_0x52b343));}}logger[_0x6a44('0x36')](_0x6a44('0x46'));return _0x3fcb0b(_0x446fbf[_0x6a44('0x36')](0x1f4,_0x6a44('0x46')));});},'RejectMessage':function(_0x598d7a){var _0x288224=this;return new Promise(function(_0x560ab2,_0x28855c){if(_0x598d7a[_0x6a44('0x3f')]&&_0x598d7a['agent']['id']){try{if(_0xb1d987[_0x6a44('0x40')][_0x598d7a[_0x6a44('0x3f')]['id']]){_0xb1d987['agents'][_0x598d7a[_0x6a44('0x3f')]['id']][_0x6a44('0x41')]=![];_0xb1d987[_0x6a44('0x40')][_0x598d7a[_0x6a44('0x3f')]['id']][_0x6a44('0x42')]=undefined;}return _0x560ab2({'code':0xc8,'message':_0x598d7a});}catch(_0x40fd42){logger[_0x6a44('0x36')](_0x40fd42[_0x6a44('0x47')]);return _0x28855c(_0x288224[_0x6a44('0x36')](0x1f4,_0x40fd42));}}logger[_0x6a44('0x36')]('message\x20is\x20empty');return _0x28855c(_0x288224[_0x6a44('0x36')](0x1f4,'message\x20is\x20empty'));});},'AbandonInteraction':function(_0x1e3ac1){var _0x2eb803=this;return new Promise(function(_0x224d7c,_0x11d9b2){if(_0x1e3ac1[_0x6a44('0x13')]&&_0x1e3ac1['interaction']&&_0x1e3ac1[_0x6a44('0x15')]['id']){try{var _0x13231c=getId(_0x1e3ac1[_0x6a44('0x13')],_0x1e3ac1[_0x6a44('0x14')]?_0x1e3ac1[_0x6a44('0x14')]['id']:0x0,_0x1e3ac1[_0x6a44('0x15')]?_0x1e3ac1[_0x6a44('0x15')]['id']:0x0);if(_0xb1d987[_0x6a44('0x12')][_0x13231c]){_0xb1d987[_0x6a44('0x12')][_0x13231c][_0x6a44('0x3b')](_0x6a44('0x43'));}return _0x224d7c({'code':0xc8,'message':_0x1e3ac1});}catch(_0x51e7df){logger[_0x6a44('0x36')](_0x51e7df[_0x6a44('0x47')]);return _0x11d9b2(_0x2eb803[_0x6a44('0x36')](0x1f4,_0x51e7df));}}logger[_0x6a44('0x36')](_0x6a44('0x46'));return _0x11d9b2(_0x2eb803[_0x6a44('0x36')](0x1f4,_0x6a44('0x46')));});},'AgentCapacity':function(_0x330263){var _0x276625=this;return new Promise(function(_0x4fabb8,_0x1d6d70){if(_0xb1d987[_0x6a44('0x40')][_0x6a44('0x48')](_0x330263['id'])){for(var _0x800265 in _0x330263['capacity']){if(_0x330263[_0x6a44('0x49')][_0x6a44('0x48')](_0x800265)){if(_0xb1d987[_0x6a44('0x40')][_0x330263['id']]['hasOwnProperty'](_0x800265+_0x6a44('0x4a'))){_0xb1d987['agents'][_0x330263['id']][_0x800265+'CurrentCapacity']=parseInt(_0x330263[_0x6a44('0x49')][_0x800265],0xa);}}}_0xb1d987[_0x6a44('0x40')][_0x330263['id']][_0x6a44('0x4b')]();return _0x4fabb8({'code':0xc8,'message':_0xb1d987[_0x6a44('0x40')][_0x330263['id']]});}else{return _0x1d6d70(_0x276625[_0x6a44('0x36')](0x1f4,'agent\x20not\x20found'));}});},'Agents':function(_0x5b8d44){return new Promise(function(_0x362607,_0x50c12b){var _0x4abebd=_[_0x6a44('0x4c')](_0xb1d987[_0x6a44('0x40')]);_0x362607({'count':_0x4abebd[_0x6a44('0x18')],'rows':_0x4abebd});});},'ChatQueues':function(_0x2aaea3){return new Promise(function(_0x5e02ed,_0x214529){var _0x564be2=[];for(var _0x59b390 in _0xb1d987['chatQueues']){if(_0xb1d987[_0x6a44('0x4d')][_0x6a44('0x48')](_0x59b390)){var _0x418a7e=_0xb1d987['chatQueues'][_0x59b390];var _0x252ea4={'id':_0x418a7e['id'],'available':_0x418a7e[_0x6a44('0x4e')],'loggedIn':_0x418a7e[_0x6a44('0x4f')],'name':_0x418a7e[_0x6a44('0x50')],'paused':_0x418a7e[_0x6a44('0x51')],'waiting':_0x418a7e[_0x6a44('0x52')]};_0x564be2['push'](_0x252ea4);}}_0x5e02ed({'count':_0x564be2[_0x6a44('0x18')],'rows':_0x564be2});});},'MailQueues':function(_0x20d5bf){return new Promise(function(_0x4f3890,_0x3d6dc6){var _0x3fdddf=[];for(var _0x3c95e1 in _0xb1d987['mailQueues']){if(_0xb1d987['mailQueues'][_0x6a44('0x48')](_0x3c95e1)){var _0x30a300=_0xb1d987['mailQueues'][_0x3c95e1];var _0x21f957={'id':_0x30a300['id'],'available':_0x30a300['available'],'loggedIn':_0x30a300[_0x6a44('0x4f')],'name':_0x30a300[_0x6a44('0x50')],'paused':_0x30a300[_0x6a44('0x51')],'waiting':_0x30a300[_0x6a44('0x52')]};_0x3fdddf['push'](_0x21f957);}}_0x4f3890({'count':_0x3fdddf['length'],'rows':_0x3fdddf});});},'OpenchannelQueues':function(_0x1d202c){return new Promise(function(_0x46dbe5,_0x46a77a){var _0x229bc4=[];for(var _0x230932 in _0xb1d987[_0x6a44('0x53')]){if(_0xb1d987[_0x6a44('0x53')][_0x6a44('0x48')](_0x230932)){var _0x36e872=_0xb1d987[_0x6a44('0x53')][_0x230932];var _0x8d2ac7={'id':_0x36e872['id'],'available':_0x36e872[_0x6a44('0x4e')],'loggedIn':_0x36e872[_0x6a44('0x4f')],'name':_0x36e872[_0x6a44('0x50')],'paused':_0x36e872[_0x6a44('0x51')],'waiting':_0x36e872[_0x6a44('0x52')]};_0x229bc4[_0x6a44('0x21')](_0x8d2ac7);}}_0x46dbe5({'count':_0x229bc4[_0x6a44('0x18')],'rows':_0x229bc4});});},'SmsQueues':function(_0x566c17){return new Promise(function(_0x35459e,_0x5374f2){var _0x15fd6d=[];for(var _0x469433 in _0xb1d987[_0x6a44('0x54')]){if(_0xb1d987[_0x6a44('0x54')]['hasOwnProperty'](_0x469433)){var _0x33ddac=_0xb1d987[_0x6a44('0x54')][_0x469433];var _0x984f87={'id':_0x33ddac['id'],'available':_0x33ddac[_0x6a44('0x4e')],'loggedIn':_0x33ddac[_0x6a44('0x4f')],'name':_0x33ddac[_0x6a44('0x50')],'paused':_0x33ddac['paused'],'waiting':_0x33ddac[_0x6a44('0x52')]};_0x15fd6d[_0x6a44('0x21')](_0x984f87);}}_0x35459e({'count':_0x15fd6d[_0x6a44('0x18')],'rows':_0x15fd6d});});},'FaxQueues':function(_0x34e348){return new Promise(function(_0x36c59d,_0x13aead){var _0x57fd0b=[];for(var _0x1c813c in _0xb1d987[_0x6a44('0x55')]){if(_0xb1d987['faxQueues'][_0x6a44('0x48')](_0x1c813c)){var _0x463126=_0xb1d987[_0x6a44('0x55')][_0x1c813c];var _0x4cd9f5={'id':_0x463126['id'],'available':_0x463126[_0x6a44('0x4e')],'loggedIn':_0x463126['loggedIn'],'name':_0x463126[_0x6a44('0x50')],'paused':_0x463126['paused'],'waiting':_0x463126[_0x6a44('0x52')]};_0x57fd0b['push'](_0x4cd9f5);}}_0x36c59d({'count':_0x57fd0b[_0x6a44('0x18')],'rows':_0x57fd0b});});},'WhatsappQueues':function(_0x457d9e){return new Promise(function(_0xeba1e2,_0x4e6082){var _0x576cd9=[];for(var _0x8b5a04 in _0xb1d987[_0x6a44('0x56')]){if(_0xb1d987[_0x6a44('0x56')][_0x6a44('0x48')](_0x8b5a04)){var _0x2f1c3e=_0xb1d987['whatsappQueues'][_0x8b5a04];var _0xdb434a={'id':_0x2f1c3e['id'],'available':_0x2f1c3e[_0x6a44('0x4e')],'loggedIn':_0x2f1c3e[_0x6a44('0x4f')],'name':_0x2f1c3e[_0x6a44('0x50')],'paused':_0x2f1c3e[_0x6a44('0x51')],'waiting':_0x2f1c3e[_0x6a44('0x52')]};_0x576cd9[_0x6a44('0x21')](_0xdb434a);}}_0xeba1e2({'count':_0x576cd9['length'],'rows':_0x576cd9});});},'ChatQueuesWaitingInteractions':function(_0x322129){return new Promise(function(_0x25681f,_0x2ec199){var _0x7c3bc7=_[_0x6a44('0x4c')](_0xb1d987[_0x6a44('0x57')]);_0x25681f({'count':_0x7c3bc7[_0x6a44('0x18')],'rows':_0x7c3bc7});});},'MailQueuesWaitingInteractions':function(_0x2f383e){return new Promise(function(_0x13f364,_0x49d513){var _0x4781fb=_[_0x6a44('0x4c')](_0xb1d987['mailQueuesWaitingInteractions']);_0x13f364({'count':_0x4781fb['length'],'rows':_0x4781fb});});},'OpenchannelQueuesWaitingInteractions':function(_0x417f64){return new Promise(function(_0x44a2e2,_0xcf855c){var _0x1ca4c9=_[_0x6a44('0x4c')](_0xb1d987['openchannelQueuesWaitingInteractions']);_0x44a2e2({'count':_0x1ca4c9[_0x6a44('0x18')],'rows':_0x1ca4c9});});},'SmsQueuesWaitingInteractions':function(_0x5a93ea){return new Promise(function(_0x14096b,_0x1bf50d){var _0x301bce=_['values'](_0xb1d987[_0x6a44('0x58')]);_0x14096b({'count':_0x301bce[_0x6a44('0x18')],'rows':_0x301bce});});},'FaxQueuesWaitingInteractions':function(_0x2b450d){return new Promise(function(_0x3cc19d,_0x114eb0){var _0x43d9d5=_['values'](_0xb1d987[_0x6a44('0x59')]);_0x3cc19d({'count':_0x43d9d5['length'],'rows':_0x43d9d5});});},'WhatsappQueuesWaitingInteractions':function(_0x48fec3){return new Promise(function(_0x1ab60b,_0x44e1f0){var _0x51880a=_['values'](_0xb1d987[_0x6a44('0x5a')]);_0x1ab60b({'count':_0x51880a[_0x6a44('0x18')],'rows':_0x51880a});});}};var _0x10917d=jayson[_0x6a44('0x5b')](_0x52aa9c)[_0x6a44('0x5c')]();_0x10917d['on'](_0x6a44('0x36'),function(_0x208c6e){logger[_0x6a44('0x36')](JSON[_0x6a44('0x3a')](_0x208c6e));return _0x553bc1(_0x208c6e);});_0x10917d[_0x6a44('0x11')](0x232c,_0x6a44('0x5d'),function(){console[_0x6a44('0x5e')](_0x6a44('0x5f'),0x232c);return _0x1481ed(_0x6a44('0x60')+0x232c);});});};
\ No newline at end of file