Built motion from commit a9fb64cc6defd8fb3a5cc199221f878e91c0e969. Version 3.0.0...
[motion-next.git] / server / services / routing / server / index.js
index ccc4233..6d6878a 100644 (file)
@@ -1 +1 @@
-const a1217_0x83f7=['split','paused','busyQueue','util','complete','routing\x20is\x20empty','consequence','appdata','applications','lodash','chatQueues','Intervals','agent','autoreply','loggedIn','No\x20applications\x20to\x20execute','./interval','mailQueues','update','127.0.0.1','\x20|\x20','../rpc/whatsappQueueReport','mailQueuesWaitingInteractions','length','faxQueuesWaitingInteractions','../rpc/smsQueueReport','channel','available','name','push','log','QueueReport','updateRealtime','dialogflow','whatsappQueuesWaitingInteractions','busy','app','%s:%s:%s','end','http','../rpc/openchannelQueueReport','waiting','emit','stringify','path','interval','on\x20interval','stack','condition','IntervalId','error','message\x20is\x20empty','../lib/rule-engine','Push\x20new\x20rule','../../../config/logger','../rpc/faxQueueReport','isArray','isNil','smsQueues','intervals','values','.js','undefined','execute','chatQueuesWaitingInteractions','existsSync','interaction','whatsappQueues','format','listen','../rpc/chatQueueReport','map','join','Please\x20create\x20a\x20new\x20file\x20under','error\x20update\x20queue\x20report','./applications/','slice','CurrentCapacity','message','faxQueues','rules','info','priority','agents','../rpc/mailQueueReport','server'];(function(_0x18efbf,_0x83f73d){const _0x5a3363=function(_0x56dc0e){while(--_0x56dc0e){_0x18efbf['push'](_0x18efbf['shift']());}};_0x5a3363(++_0x83f73d);}(a1217_0x83f7,0x192));const a1217_0x5a33=function(_0x18efbf,_0x83f73d){_0x18efbf=_0x18efbf-0x0;let _0x5a3363=a1217_0x83f7[_0x18efbf];return _0x5a3363;};const _0x4c8407=a1217_0x5a33;'use strict';const _=require(_0x4c8407('0x25')),util=require(_0x4c8407('0x1f')),path=require(_0x4c8407('0x48')),fs=require('fs'),jayson=require('jayson/promise'),logger=require(_0x4c8407('0x52'))('routing'),rpc={'openchannelQueueReport':require(_0x4c8407('0x44')),'mailQueueReport':require(_0x4c8407('0x1a')),'chatQueueReport':require(_0x4c8407('0xc')),'smsQueueReport':require(_0x4c8407('0x35')),'faxQueueReport':require(_0x4c8407('0x53')),'whatsappQueueReport':require(_0x4c8407('0x31'))},RuleEngine=require(_0x4c8407('0x50'));function getId(_0x56dc0e,_0x5df6be,_0x253796){return util['format']('%s.%s.%s',_0x56dc0e,_0x5df6be||0x0,_0x253796||0x0);}function getIntervals(_0x22d570,_0x8a7df4){const _0x5aaa8c=_0x4c8407;let _0x2f8129=[];if(!_['isNil'](_0x8a7df4[_0x5aaa8c('0x4d')])&&!_['isNil'](_0x22d570[_0x8a7df4[_0x5aaa8c('0x4d')]])&&!_[_0x5aaa8c('0x55')](_0x22d570[_0x8a7df4['IntervalId']][_0x5aaa8c('0x27')]))_0x2f8129=_[_0x5aaa8c('0xd')](_0x22d570[_0x8a7df4[_0x5aaa8c('0x4d')]][_0x5aaa8c('0x27')],_0x5aaa8c('0x49'));else!_['isNil'](_0x8a7df4[_0x5aaa8c('0x49')])&&(_0x2f8129=[_0x8a7df4['interval']]);return _0x2f8129;}exports[_0x4c8407('0xb')]=function(_0x3ce4fe){const _0x4c4eab=_0x4c8407;return _0x3ce4fe[_0x4c4eab('0x16')]={},new Promise(function(_0x514de5,_0x3cddcf){const _0x2b9083=_0x4c4eab,_0x55f485={'Start':function(_0x26fab5){const _0x13d161=this;return new Promise(function(_0x9e56c2,_0x49d44f){const _0x24b60b=a1217_0x5a33;if(_0x26fab5)try{const _0xef1eb4=[],_0x58d5f0=getId(_0x26fab5[_0x24b60b('0x36')],_0x26fab5[_0x24b60b('0x14')]?_0x26fab5[_0x24b60b('0x14')]['id']:0x0,_0x26fab5[_0x24b60b('0x8')]?_0x26fab5[_0x24b60b('0x8')]['id']:0x0);if(_0x26fab5['applications']&&_[_0x24b60b('0x54')](_0x26fab5[_0x24b60b('0x24')])&&_0x26fab5['applications']['length']){for(let _0x4e4d63=0x0;_0x4e4d63<_0x26fab5[_0x24b60b('0x24')][_0x24b60b('0x33')];_0x4e4d63+=0x1){const _0x2fcc8d=_0x26fab5[_0x24b60b('0x24')][_0x4e4d63];if(fs[_0x24b60b('0x7')](path[_0x24b60b('0xe')](__dirname,_0x24b60b('0x24'),_0x2fcc8d['app']+_0x24b60b('0x3')))){let _0x59eaa7=[];switch(_0x2fcc8d[_0x24b60b('0x40')]['toLowerCase']()){case _0x24b60b('0x29'):{const _0x6cac5f=_0x2fcc8d[_0x24b60b('0x23')][_0x24b60b('0x1c')](',');_0x59eaa7[_0x24b60b('0x39')](_0x6cac5f[0x0]),_0x59eaa7[_0x24b60b('0x39')](_0x6cac5f[_0x24b60b('0x12')](0x1,_0x6cac5f[_0x24b60b('0x33')])[_0x24b60b('0xe')](','));}break;case _0x24b60b('0x3d'):{const _0x56b5f5=_0x2fcc8d[_0x24b60b('0x23')][_0x24b60b('0x1c')](',');_0x59eaa7[_0x24b60b('0x39')](_0x56b5f5[0x0]),_0x59eaa7[_0x24b60b('0x39')](_0x56b5f5[0x1]),_0x59eaa7[_0x24b60b('0x39')](_0x56b5f5[_0x24b60b('0x12')](0x2,_0x56b5f5[_0x24b60b('0x33')])[_0x24b60b('0xe')](','));}break;case'amazonlex':{const _0x147656=_0x2fcc8d[_0x24b60b('0x23')]['split'](',');_0x59eaa7[_0x24b60b('0x39')](_0x147656[0x0]),_0x59eaa7[_0x24b60b('0x39')](_0x147656[0x1]),_0x59eaa7[_0x24b60b('0x39')](_0x147656[0x2]),_0x59eaa7['push'](_0x147656[0x3]),_0x59eaa7[_0x24b60b('0x39')](_0x147656[_0x24b60b('0x12')](0x4,_0x147656['length'])['join'](','));}break;case _0x24b60b('0x14'):_0x59eaa7[_0x24b60b('0x39')](_0x2fcc8d[_0x24b60b('0x23')]);break;case'tag':_0x59eaa7['push'](_0x2fcc8d['TagId']),_0x59eaa7[_0x24b60b('0x39')](_0x2fcc8d[_0x24b60b('0x23')]);break;default:_0x59eaa7=_['isNil'](_0x2fcc8d['appdata'])?[]:_0x2fcc8d[_0x24b60b('0x23')][_0x24b60b('0x1c')](',');}const _0x539136={'id':util[_0x24b60b('0xa')](_0x24b60b('0x41'),_0x58d5f0,_0x2fcc8d['id'],_0x2fcc8d[_0x24b60b('0x40')]),'condition':require(_0x24b60b('0x2c'))[_0x24b60b('0x4c')](_0x58d5f0,getIntervals(_0x3ce4fe[_0x24b60b('0x1')],_0x2fcc8d),_0x3ce4fe),'consequence':require(_0x24b60b('0x11')+_0x2fcc8d['app'])[_0x24b60b('0x22')](_0x58d5f0,_0x59eaa7,_0x3ce4fe,_0x26fab5),'p':_0x2fcc8d[_0x24b60b('0x18')]||0x0};logger[_0x24b60b('0x17')](_0x24b60b('0x51'),_0x539136['id'],_0x24b60b('0x4a'),getIntervals(_0x3ce4fe[_0x24b60b('0x1')],_0x2fcc8d)[_0x24b60b('0xe')](_0x24b60b('0x30'))),_0xef1eb4[_0x24b60b('0x39')](_0x539136);}else logger['error'](_0x24b60b('0xf'),path['join'](__dirname,_0x24b60b('0x24'),_0x2fcc8d[_0x24b60b('0x40')]+_0x24b60b('0x3')));}return _0x3ce4fe[_0x24b60b('0x16')][_0x58d5f0]=new RuleEngine(_0xef1eb4),_0x3ce4fe['rules'][_0x58d5f0][_0x24b60b('0x5')](_0x26fab5,function(_0x19b5ad){const _0x5a7ab8=_0x24b60b;logger[_0x5a7ab8('0x17')]('Applications\x20executed',JSON[_0x5a7ab8('0x47')](_0x19b5ad['matchPath'])),_0x3ce4fe[_0x5a7ab8('0x16')][_0x58d5f0]&&_0x3ce4fe['rules'][_0x58d5f0][_0x5a7ab8('0x46')](_0x5a7ab8('0x20'));}),_0x9e56c2({'code':0xc8,'message':_0x26fab5});}else return logger[_0x24b60b('0x17')](_0x24b60b('0x2b')),_0x9e56c2({'code':0xc8,'message':_0x26fab5});}catch(_0x4396d6){return logger[_0x24b60b('0x4e')](_0x4396d6['stack']),_0x49d44f(_0x13d161[_0x24b60b('0x4e')](0x1f4,_0x4396d6));}return _0x49d44f(_0x24b60b('0x21'));});},'AcceptMessage':function(_0x44632a){const _0x11da80=this;return new Promise(function(_0x5fd1df,_0x1808d0){const _0x178223=a1217_0x5a33;if(_0x44632a[_0x178223('0x14')]&&_0x44632a[_0x178223('0x14')]['id'])try{const _0x6c6d48=getId(_0x44632a[_0x178223('0x36')],_0x44632a[_0x178223('0x14')]?_0x44632a[_0x178223('0x14')]['id']:0x0,_0x44632a[_0x178223('0x8')]?_0x44632a[_0x178223('0x8')]['id']:0x0);return _0x3ce4fe[_0x178223('0x16')][_0x6c6d48]&&(_0x3ce4fe[_0x178223('0x16')][_0x6c6d48][_0x178223('0x46')]('end'),rpc[_0x44632a[_0x178223('0x36')]+_0x178223('0x3b')]&&rpc[_0x44632a[_0x178223('0x36')]+_0x178223('0x3b')][_0x178223('0x2e')](_0x6c6d48,{'UserId':_0x44632a['message']['UserId']})['catch'](function(){const _0x41ae6e=_0x178223;logger[_0x41ae6e('0x4e')](_0x41ae6e('0x10'));})),_0x5fd1df({'code':0xc8,'message':_0x44632a});}catch(_0x23f6f6){return logger['error'](_0x23f6f6['stack']),_0x1808d0(_0x11da80[_0x178223('0x4e')](0x1f4,_0x23f6f6));}return logger[_0x178223('0x4e')]('message\x20is\x20empty'),_0x1808d0(_0x11da80[_0x178223('0x4e')](0x1f4,_0x178223('0x4f')));});},'RejectMessage':function(_0x387f7e){const _0x58d525=this;return new Promise(function(_0x6decb4,_0x380624){const _0xbbe0b0=a1217_0x5a33;if(_0x387f7e[_0xbbe0b0('0x28')]&&_0x387f7e['agent']['id'])try{return _0x3ce4fe[_0xbbe0b0('0x19')][_0x387f7e[_0xbbe0b0('0x28')]['id']]&&(_0x3ce4fe['agents'][_0x387f7e[_0xbbe0b0('0x28')]['id']][_0xbbe0b0('0x3f')]=![],_0x3ce4fe[_0xbbe0b0('0x19')][_0x387f7e[_0xbbe0b0('0x28')]['id']][_0xbbe0b0('0x1e')]=undefined),_0x6decb4({'code':0xc8,'message':_0x387f7e});}catch(_0x39fbbe){return logger[_0xbbe0b0('0x4e')](_0x39fbbe[_0xbbe0b0('0x4b')]),_0x380624(_0x58d525[_0xbbe0b0('0x4e')](0x1f4,_0x39fbbe));}return logger['error'](_0xbbe0b0('0x4f')),_0x380624(_0x58d525['error'](0x1f4,_0xbbe0b0('0x4f')));});},'AbandonInteraction':function(_0x302c18){const _0x391379=this;return new Promise(function(_0x54a174,_0x30f08a){const _0x28d4c3=a1217_0x5a33;if(_0x302c18['channel']&&_0x302c18[_0x28d4c3('0x8')]&&_0x302c18[_0x28d4c3('0x8')]['id'])try{const _0x1246a7=getId(_0x302c18[_0x28d4c3('0x36')],_0x302c18[_0x28d4c3('0x14')]?_0x302c18[_0x28d4c3('0x14')]['id']:0x0,_0x302c18[_0x28d4c3('0x8')]?_0x302c18['interaction']['id']:0x0);return _0x3ce4fe[_0x28d4c3('0x16')][_0x1246a7]&&_0x3ce4fe[_0x28d4c3('0x16')][_0x1246a7][_0x28d4c3('0x46')](_0x28d4c3('0x42')),_0x54a174({'code':0xc8,'message':_0x302c18});}catch(_0x4b67ee){return logger[_0x28d4c3('0x4e')](_0x4b67ee[_0x28d4c3('0x4b')]),_0x30f08a(_0x391379[_0x28d4c3('0x4e')](0x1f4,_0x4b67ee));}return logger[_0x28d4c3('0x4e')](_0x28d4c3('0x4f')),_0x30f08a(_0x391379[_0x28d4c3('0x4e')](0x1f4,_0x28d4c3('0x4f')));});},'AgentCapacity':function(_0x2f4227){const _0x481d4c=this;return new Promise(function(_0x8b8ade,_0x3d2b81){const _0x5bfa1d=a1217_0x5a33;if(typeof _0x3ce4fe[_0x5bfa1d('0x19')][_0x2f4227['id']]!=='undefined'){for(const _0xc57f10 in _0x2f4227['capacity']){typeof _0x2f4227['capacity'][_0xc57f10]!==_0x5bfa1d('0x4')&&(typeof _0x3ce4fe[_0x5bfa1d('0x19')][_0x2f4227['id']][_0xc57f10+_0x5bfa1d('0x13')]!=='undefined'&&(_0x3ce4fe[_0x5bfa1d('0x19')][_0x2f4227['id']][_0xc57f10+_0x5bfa1d('0x13')]=parseInt(_0x2f4227['capacity'][_0xc57f10],0xa)));}return _0x3ce4fe[_0x5bfa1d('0x19')][_0x2f4227['id']][_0x5bfa1d('0x3c')](),_0x8b8ade({'code':0xc8,'message':_0x3ce4fe['agents'][_0x2f4227['id']]});}else return _0x3d2b81(_0x481d4c[_0x5bfa1d('0x4e')](0x1f4,'agent\x20not\x20found'));});},'Agents':function(){return new Promise(function(_0x240912){const _0x39cbfa=a1217_0x5a33,_0x15e121=_[_0x39cbfa('0x2')](_0x3ce4fe[_0x39cbfa('0x19')]);_0x240912({'count':_0x15e121[_0x39cbfa('0x33')],'rows':_0x15e121});});},'ChatQueues':function(){return new Promise(function(_0x3eb733){const _0x24f8b2=a1217_0x5a33,_0x1bdf15=[];for(const _0x4cbef2 in _0x3ce4fe[_0x24f8b2('0x26')]){if(typeof _0x3ce4fe[_0x24f8b2('0x26')][_0x4cbef2]!==_0x24f8b2('0x4')){const _0x34a5c9=_0x3ce4fe['chatQueues'][_0x4cbef2],_0xab6710={'id':_0x34a5c9['id'],'available':_0x34a5c9[_0x24f8b2('0x37')],'loggedIn':_0x34a5c9['loggedIn'],'name':_0x34a5c9[_0x24f8b2('0x38')],'paused':_0x34a5c9[_0x24f8b2('0x1d')],'waiting':_0x34a5c9['waiting']};_0x1bdf15[_0x24f8b2('0x39')](_0xab6710);}}_0x3eb733({'count':_0x1bdf15[_0x24f8b2('0x33')],'rows':_0x1bdf15});});},'MailQueues':function(){return new Promise(function(_0x23998a){const _0x47cb66=a1217_0x5a33,_0x21fb32=[];for(const _0x34c902 in _0x3ce4fe[_0x47cb66('0x2d')]){if(typeof _0x3ce4fe[_0x47cb66('0x2d')][_0x34c902]!==_0x47cb66('0x4')){const _0x2188f7=_0x3ce4fe[_0x47cb66('0x2d')][_0x34c902],_0x5ec274={'id':_0x2188f7['id'],'available':_0x2188f7[_0x47cb66('0x37')],'loggedIn':_0x2188f7[_0x47cb66('0x2a')],'name':_0x2188f7[_0x47cb66('0x38')],'paused':_0x2188f7[_0x47cb66('0x1d')],'waiting':_0x2188f7['waiting']};_0x21fb32[_0x47cb66('0x39')](_0x5ec274);}}_0x23998a({'count':_0x21fb32[_0x47cb66('0x33')],'rows':_0x21fb32});});},'OpenchannelQueues':function(){return new Promise(function(_0x3a9ecb){const _0x35d7c9=a1217_0x5a33,_0x550c56=[];for(const _0x24012e in _0x3ce4fe['openchannelQueues']){if(typeof _0x3ce4fe['openchannelQueues'][_0x24012e]!==_0x35d7c9('0x4')){const _0x4eb1ca=_0x3ce4fe['openchannelQueues'][_0x24012e],_0x30620c={'id':_0x4eb1ca['id'],'available':_0x4eb1ca[_0x35d7c9('0x37')],'loggedIn':_0x4eb1ca[_0x35d7c9('0x2a')],'name':_0x4eb1ca[_0x35d7c9('0x38')],'paused':_0x4eb1ca[_0x35d7c9('0x1d')],'waiting':_0x4eb1ca[_0x35d7c9('0x45')]};_0x550c56['push'](_0x30620c);}}_0x3a9ecb({'count':_0x550c56['length'],'rows':_0x550c56});});},'SmsQueues':function(){return new Promise(function(_0x336a32){const _0x4340d3=a1217_0x5a33,_0x12ed63=[];for(const _0x356d11 in _0x3ce4fe[_0x4340d3('0x0')]){if(typeof _0x3ce4fe[_0x4340d3('0x0')][_0x356d11]!==_0x4340d3('0x4')){const _0x20d804=_0x3ce4fe['smsQueues'][_0x356d11],_0x399e6b={'id':_0x20d804['id'],'available':_0x20d804['available'],'loggedIn':_0x20d804[_0x4340d3('0x2a')],'name':_0x20d804[_0x4340d3('0x38')],'paused':_0x20d804[_0x4340d3('0x1d')],'waiting':_0x20d804[_0x4340d3('0x45')]};_0x12ed63[_0x4340d3('0x39')](_0x399e6b);}}_0x336a32({'count':_0x12ed63[_0x4340d3('0x33')],'rows':_0x12ed63});});},'FaxQueues':function(){return new Promise(function(_0xa853ca){const _0x34ce76=a1217_0x5a33,_0x18c086=[];for(const _0x1829ad in _0x3ce4fe['faxQueues']){if(typeof _0x3ce4fe[_0x34ce76('0x15')][_0x1829ad]!==_0x34ce76('0x4')){const _0x3e6b2c=_0x3ce4fe['faxQueues'][_0x1829ad],_0x2c4ff5={'id':_0x3e6b2c['id'],'available':_0x3e6b2c['available'],'loggedIn':_0x3e6b2c['loggedIn'],'name':_0x3e6b2c[_0x34ce76('0x38')],'paused':_0x3e6b2c[_0x34ce76('0x1d')],'waiting':_0x3e6b2c['waiting']};_0x18c086[_0x34ce76('0x39')](_0x2c4ff5);}}_0xa853ca({'count':_0x18c086[_0x34ce76('0x33')],'rows':_0x18c086});});},'WhatsappQueues':function(){return new Promise(function(_0x366dde){const _0x48573a=a1217_0x5a33,_0x2f9ca9=[];for(const _0x1c938f in _0x3ce4fe[_0x48573a('0x9')]){if(typeof _0x3ce4fe[_0x48573a('0x9')][_0x1c938f]!==_0x48573a('0x4')){const _0x27dcfa=_0x3ce4fe['whatsappQueues'][_0x1c938f],_0x2f3461={'id':_0x27dcfa['id'],'available':_0x27dcfa[_0x48573a('0x37')],'loggedIn':_0x27dcfa[_0x48573a('0x2a')],'name':_0x27dcfa[_0x48573a('0x38')],'paused':_0x27dcfa['paused'],'waiting':_0x27dcfa['waiting']};_0x2f9ca9[_0x48573a('0x39')](_0x2f3461);}}_0x366dde({'count':_0x2f9ca9[_0x48573a('0x33')],'rows':_0x2f9ca9});});},'ChatQueuesWaitingInteractions':function(){return new Promise(function(_0x319d40){const _0x278d75=a1217_0x5a33,_0x5b9751=_[_0x278d75('0x2')](_0x3ce4fe[_0x278d75('0x6')]);_0x319d40({'count':_0x5b9751[_0x278d75('0x33')],'rows':_0x5b9751});});},'MailQueuesWaitingInteractions':function(){return new Promise(function(_0x50b40e){const _0x2b7f31=a1217_0x5a33,_0x2c17bb=_[_0x2b7f31('0x2')](_0x3ce4fe[_0x2b7f31('0x32')]);_0x50b40e({'count':_0x2c17bb[_0x2b7f31('0x33')],'rows':_0x2c17bb});});},'OpenchannelQueuesWaitingInteractions':function(){return new Promise(function(_0x3f6dae){const _0x5ccdea=a1217_0x5a33,_0x515879=_[_0x5ccdea('0x2')](_0x3ce4fe['openchannelQueuesWaitingInteractions']);_0x3f6dae({'count':_0x515879[_0x5ccdea('0x33')],'rows':_0x515879});});},'SmsQueuesWaitingInteractions':function(){return new Promise(function(_0x42fc8f){const _0x2b3d55=a1217_0x5a33,_0x3b049b=_[_0x2b3d55('0x2')](_0x3ce4fe['smsQueuesWaitingInteractions']);_0x42fc8f({'count':_0x3b049b[_0x2b3d55('0x33')],'rows':_0x3b049b});});},'FaxQueuesWaitingInteractions':function(){return new Promise(function(_0x23dffb){const _0x4d1581=a1217_0x5a33,_0x214f1a=_[_0x4d1581('0x2')](_0x3ce4fe[_0x4d1581('0x34')]);_0x23dffb({'count':_0x214f1a[_0x4d1581('0x33')],'rows':_0x214f1a});});},'WhatsappQueuesWaitingInteractions':function(){return new Promise(function(_0x915b4b){const _0x2a8a40=a1217_0x5a33,_0x477b67=_['values'](_0x3ce4fe[_0x2a8a40('0x3e')]);_0x915b4b({'count':_0x477b67[_0x2a8a40('0x33')],'rows':_0x477b67});});}},_0x38b457=jayson[_0x2b9083('0x1b')](_0x55f485)[_0x2b9083('0x43')]();_0x38b457['on'](_0x2b9083('0x4e'),function(_0x5cbe1f){const _0x18c174=_0x2b9083;return logger[_0x18c174('0x4e')](JSON[_0x18c174('0x47')](_0x5cbe1f)),_0x3cddcf(_0x5cbe1f);}),_0x38b457[_0x2b9083('0xb')](0x232c,_0x2b9083('0x2f'),function(){const _0x560114=_0x2b9083;return console[_0x560114('0x3a')]('Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!',0x232c),_0x514de5('RPC\x20listening\x20on\x20port:'+0x232c);});});};
\ No newline at end of file
+const a1217_0x3692=['matchPath','faxQueuesWaitingInteractions','./applications/','No\x20applications\x20to\x20execute','emit','waiting','UserId','length','../rpc/whatsappQueueReport','error\x20update\x20queue\x20report','openchannelQueues','condition','mailQueues','applications','Intervals','available','mailQueuesWaitingInteractions','loggedIn','execute','complete','slice','CurrentCapacity','intervals','agent\x20not\x20found','util','faxQueues','openchannelQueuesWaitingInteractions','dialogflow','interval','split','RPC\x20listening\x20on\x20port:','../../../config/logger','smsQueuesWaitingInteractions','../rpc/faxQueueReport','stringify','isArray','./interval','whatsappQueuesWaitingInteractions','\x20|\x20','%s:%s:%s','message\x20is\x20empty','error','routing','Please\x20create\x20a\x20new\x20file\x20under','chatQueues','log','agent','info','IntervalId','agents','map','capacity','%s.%s.%s','tag','name','join','interaction','catch','lodash','message','QueueReport','channel','priority','routing\x20is\x20empty','busyQueue','smsQueues','appdata','app','../rpc/mailQueueReport','existsSync','listen','format','paused','undefined','amazonlex','rules','on\x20interval','../rpc/chatQueueReport','path','chatQueuesWaitingInteractions','push','whatsappQueues','Push\x20new\x20rule','end','update','stack','values','TagId','isNil'];(function(_0x39340d,_0x3692db){const _0x1bf918=function(_0x3aa48d){while(--_0x3aa48d){_0x39340d['push'](_0x39340d['shift']());}};_0x1bf918(++_0x3692db);}(a1217_0x3692,0x15a));const a1217_0x1bf9=function(_0x39340d,_0x3692db){_0x39340d=_0x39340d-0x0;let _0x1bf918=a1217_0x3692[_0x39340d];return _0x1bf918;};const _0x2116d2=a1217_0x1bf9;'use strict';const _=require(_0x2116d2('0x44')),util=require(_0x2116d2('0x22')),path=require(_0x2116d2('0x58')),fs=require('fs'),jayson=require('jayson/promise'),logger=require(_0x2116d2('0x29'))(_0x2116d2('0x34')),rpc={'openchannelQueueReport':require('../rpc/openchannelQueueReport'),'mailQueueReport':require(_0x2116d2('0x4e')),'chatQueueReport':require(_0x2116d2('0x57')),'smsQueueReport':require('../rpc/smsQueueReport'),'faxQueueReport':require(_0x2116d2('0x2b')),'whatsappQueueReport':require(_0x2116d2('0x12'))},RuleEngine=require('../lib/rule-engine');function getId(_0x3aa48d,_0x38af7b,_0x2bf139){const _0xa796ea=_0x2116d2;return util[_0xa796ea('0x51')](_0xa796ea('0x3e'),_0x3aa48d,_0x38af7b||0x0,_0x2bf139||0x0);}function getIntervals(_0x445f4c,_0xbfbd79){const _0x299805=_0x2116d2;let _0x37e3ba=[];if(!_[_0x299805('0x9')](_0xbfbd79[_0x299805('0x3a')])&&!_[_0x299805('0x9')](_0x445f4c[_0xbfbd79[_0x299805('0x3a')]])&&!_[_0x299805('0x9')](_0x445f4c[_0xbfbd79[_0x299805('0x3a')]]['Intervals']))_0x37e3ba=_[_0x299805('0x3c')](_0x445f4c[_0xbfbd79[_0x299805('0x3a')]][_0x299805('0x18')],_0x299805('0x26'));else!_[_0x299805('0x9')](_0xbfbd79['interval'])&&(_0x37e3ba=[_0xbfbd79['interval']]);return _0x37e3ba;}exports[_0x2116d2('0x50')]=function(_0x17a592){const _0xf5c1ed=_0x2116d2;return _0x17a592[_0xf5c1ed('0x55')]={},new Promise(function(_0x2da213,_0x20b457){const _0x3c3a5f=_0xf5c1ed,_0x5ea3e8={'Start':function(_0x12d763){const _0x48ff9e=this;return new Promise(function(_0x12e6fb,_0x17dafd){const _0x27a5c5=a1217_0x1bf9;if(_0x12d763)try{const _0x36dab8=[],_0x2b2ef7=getId(_0x12d763[_0x27a5c5('0x47')],_0x12d763[_0x27a5c5('0x45')]?_0x12d763[_0x27a5c5('0x45')]['id']:0x0,_0x12d763[_0x27a5c5('0x42')]?_0x12d763[_0x27a5c5('0x42')]['id']:0x0);if(_0x12d763[_0x27a5c5('0x17')]&&_[_0x27a5c5('0x2d')](_0x12d763[_0x27a5c5('0x17')])&&_0x12d763['applications'][_0x27a5c5('0x11')]){for(let _0x55cfbf=0x0;_0x55cfbf<_0x12d763[_0x27a5c5('0x17')][_0x27a5c5('0x11')];_0x55cfbf+=0x1){const _0x3299e2=_0x12d763[_0x27a5c5('0x17')][_0x55cfbf];if(fs[_0x27a5c5('0x4f')](path[_0x27a5c5('0x41')](__dirname,_0x27a5c5('0x17'),_0x3299e2[_0x27a5c5('0x4d')]+'.js'))){let _0x4abb9d=[];switch(_0x3299e2['app']['toLowerCase']()){case'autoreply':{const _0x5502fd=_0x3299e2[_0x27a5c5('0x4c')][_0x27a5c5('0x27')](',');_0x4abb9d[_0x27a5c5('0x1')](_0x5502fd[0x0]),_0x4abb9d[_0x27a5c5('0x1')](_0x5502fd[_0x27a5c5('0x1e')](0x1,_0x5502fd['length'])[_0x27a5c5('0x41')](','));}break;case _0x27a5c5('0x25'):{const _0x23bf26=_0x3299e2[_0x27a5c5('0x4c')][_0x27a5c5('0x27')](',');_0x4abb9d[_0x27a5c5('0x1')](_0x23bf26[0x0]),_0x4abb9d['push'](_0x23bf26[0x1]),_0x4abb9d[_0x27a5c5('0x1')](_0x23bf26[_0x27a5c5('0x1e')](0x2,_0x23bf26[_0x27a5c5('0x11')])[_0x27a5c5('0x41')](','));}break;case _0x27a5c5('0x54'):{const _0x1a76eb=_0x3299e2[_0x27a5c5('0x4c')]['split'](',');_0x4abb9d[_0x27a5c5('0x1')](_0x1a76eb[0x0]),_0x4abb9d[_0x27a5c5('0x1')](_0x1a76eb[0x1]),_0x4abb9d[_0x27a5c5('0x1')](_0x1a76eb[0x2]),_0x4abb9d[_0x27a5c5('0x1')](_0x1a76eb[0x3]),_0x4abb9d['push'](_0x1a76eb[_0x27a5c5('0x1e')](0x4,_0x1a76eb['length'])[_0x27a5c5('0x41')](','));}break;case _0x27a5c5('0x45'):_0x4abb9d[_0x27a5c5('0x1')](_0x3299e2[_0x27a5c5('0x4c')]);break;case _0x27a5c5('0x3f'):_0x4abb9d['push'](_0x3299e2[_0x27a5c5('0x8')]),_0x4abb9d[_0x27a5c5('0x1')](_0x3299e2[_0x27a5c5('0x4c')]);break;default:_0x4abb9d=_[_0x27a5c5('0x9')](_0x3299e2[_0x27a5c5('0x4c')])?[]:_0x3299e2[_0x27a5c5('0x4c')]['split'](',');}const _0x359073={'id':util[_0x27a5c5('0x51')](_0x27a5c5('0x31'),_0x2b2ef7,_0x3299e2['id'],_0x3299e2[_0x27a5c5('0x4d')]),'condition':require(_0x27a5c5('0x2e'))[_0x27a5c5('0x15')](_0x2b2ef7,getIntervals(_0x17a592['intervals'],_0x3299e2),_0x17a592),'consequence':require(_0x27a5c5('0xc')+_0x3299e2[_0x27a5c5('0x4d')])['consequence'](_0x2b2ef7,_0x4abb9d,_0x17a592,_0x12d763),'p':_0x3299e2[_0x27a5c5('0x48')]||0x0};logger[_0x27a5c5('0x39')](_0x27a5c5('0x3'),_0x359073['id'],_0x27a5c5('0x56'),getIntervals(_0x17a592[_0x27a5c5('0x20')],_0x3299e2)[_0x27a5c5('0x41')](_0x27a5c5('0x30'))),_0x36dab8[_0x27a5c5('0x1')](_0x359073);}else logger[_0x27a5c5('0x33')](_0x27a5c5('0x35'),path['join'](__dirname,_0x27a5c5('0x17'),_0x3299e2[_0x27a5c5('0x4d')]+'.js'));}return _0x17a592[_0x27a5c5('0x55')][_0x2b2ef7]=new RuleEngine(_0x36dab8),_0x17a592[_0x27a5c5('0x55')][_0x2b2ef7][_0x27a5c5('0x1c')](_0x12d763,function(_0x468c58){const _0x58587d=_0x27a5c5;logger[_0x58587d('0x39')]('Applications\x20executed',JSON['stringify'](_0x468c58[_0x58587d('0xa')])),_0x17a592[_0x58587d('0x55')][_0x2b2ef7]&&_0x17a592[_0x58587d('0x55')][_0x2b2ef7][_0x58587d('0xe')](_0x58587d('0x1d'));}),_0x12e6fb({'code':0xc8,'message':_0x12d763});}else return logger[_0x27a5c5('0x39')](_0x27a5c5('0xd')),_0x12e6fb({'code':0xc8,'message':_0x12d763});}catch(_0x576b35){return logger[_0x27a5c5('0x33')](_0x576b35['stack']),_0x17dafd(_0x48ff9e['error'](0x1f4,_0x576b35));}return _0x17dafd(_0x27a5c5('0x49'));});},'AcceptMessage':function(_0x57417c){const _0x4eb861=this;return new Promise(function(_0x30e9a8,_0x423acb){const _0x58b1ff=a1217_0x1bf9;if(_0x57417c[_0x58b1ff('0x45')]&&_0x57417c[_0x58b1ff('0x45')]['id'])try{const _0x125be9=getId(_0x57417c[_0x58b1ff('0x47')],_0x57417c[_0x58b1ff('0x45')]?_0x57417c['message']['id']:0x0,_0x57417c['interaction']?_0x57417c['interaction']['id']:0x0);return _0x17a592[_0x58b1ff('0x55')][_0x125be9]&&(_0x17a592[_0x58b1ff('0x55')][_0x125be9][_0x58b1ff('0xe')](_0x58b1ff('0x4')),rpc[_0x57417c['channel']+_0x58b1ff('0x46')]&&rpc[_0x57417c[_0x58b1ff('0x47')]+_0x58b1ff('0x46')][_0x58b1ff('0x5')](_0x125be9,{'UserId':_0x57417c[_0x58b1ff('0x45')][_0x58b1ff('0x10')]})[_0x58b1ff('0x43')](function(){const _0x2a6017=_0x58b1ff;logger['error'](_0x2a6017('0x13'));})),_0x30e9a8({'code':0xc8,'message':_0x57417c});}catch(_0x2b7c24){return logger[_0x58b1ff('0x33')](_0x2b7c24[_0x58b1ff('0x6')]),_0x423acb(_0x4eb861[_0x58b1ff('0x33')](0x1f4,_0x2b7c24));}return logger[_0x58b1ff('0x33')](_0x58b1ff('0x32')),_0x423acb(_0x4eb861[_0x58b1ff('0x33')](0x1f4,_0x58b1ff('0x32')));});},'RejectMessage':function(_0x45a513){const _0x5c2a0e=this;return new Promise(function(_0x2390e9,_0x155dcb){const _0x158628=a1217_0x1bf9;if(_0x45a513[_0x158628('0x38')]&&_0x45a513[_0x158628('0x38')]['id'])try{return _0x17a592[_0x158628('0x3b')][_0x45a513['agent']['id']]&&(_0x17a592[_0x158628('0x3b')][_0x45a513[_0x158628('0x38')]['id']]['busy']=![],_0x17a592['agents'][_0x45a513['agent']['id']][_0x158628('0x4a')]=undefined),_0x2390e9({'code':0xc8,'message':_0x45a513});}catch(_0x315c22){return logger[_0x158628('0x33')](_0x315c22['stack']),_0x155dcb(_0x5c2a0e[_0x158628('0x33')](0x1f4,_0x315c22));}return logger[_0x158628('0x33')](_0x158628('0x32')),_0x155dcb(_0x5c2a0e[_0x158628('0x33')](0x1f4,_0x158628('0x32')));});},'AbandonInteraction':function(_0x38404c){const _0x48a2ce=this;return new Promise(function(_0x29a34f,_0x2da99d){const _0x55ee0c=a1217_0x1bf9;if(_0x38404c[_0x55ee0c('0x47')]&&_0x38404c[_0x55ee0c('0x42')]&&_0x38404c[_0x55ee0c('0x42')]['id'])try{const _0x480a5d=getId(_0x38404c[_0x55ee0c('0x47')],_0x38404c['message']?_0x38404c[_0x55ee0c('0x45')]['id']:0x0,_0x38404c[_0x55ee0c('0x42')]?_0x38404c[_0x55ee0c('0x42')]['id']:0x0);return _0x17a592[_0x55ee0c('0x55')][_0x480a5d]&&_0x17a592[_0x55ee0c('0x55')][_0x480a5d][_0x55ee0c('0xe')](_0x55ee0c('0x4')),_0x29a34f({'code':0xc8,'message':_0x38404c});}catch(_0x8ef9d1){return logger[_0x55ee0c('0x33')](_0x8ef9d1[_0x55ee0c('0x6')]),_0x2da99d(_0x48a2ce[_0x55ee0c('0x33')](0x1f4,_0x8ef9d1));}return logger['error'](_0x55ee0c('0x32')),_0x2da99d(_0x48a2ce['error'](0x1f4,_0x55ee0c('0x32')));});},'AgentCapacity':function(_0x4f1b9b){const _0x5556e1=this;return new Promise(function(_0x58ad56,_0x527891){const _0x3823b8=a1217_0x1bf9;if(typeof _0x17a592[_0x3823b8('0x3b')][_0x4f1b9b['id']]!=='undefined'){for(const _0x572148 in _0x4f1b9b[_0x3823b8('0x3d')]){typeof _0x4f1b9b[_0x3823b8('0x3d')][_0x572148]!==_0x3823b8('0x53')&&(typeof _0x17a592['agents'][_0x4f1b9b['id']][_0x572148+_0x3823b8('0x1f')]!==_0x3823b8('0x53')&&(_0x17a592[_0x3823b8('0x3b')][_0x4f1b9b['id']][_0x572148+_0x3823b8('0x1f')]=parseInt(_0x4f1b9b['capacity'][_0x572148],0xa)));}return _0x17a592[_0x3823b8('0x3b')][_0x4f1b9b['id']]['updateRealtime'](),_0x58ad56({'code':0xc8,'message':_0x17a592[_0x3823b8('0x3b')][_0x4f1b9b['id']]});}else return _0x527891(_0x5556e1['error'](0x1f4,_0x3823b8('0x21')));});},'Agents':function(){return new Promise(function(_0x549f0c){const _0x2f07f4=a1217_0x1bf9,_0x49fe0c=_[_0x2f07f4('0x7')](_0x17a592[_0x2f07f4('0x3b')]);_0x549f0c({'count':_0x49fe0c[_0x2f07f4('0x11')],'rows':_0x49fe0c});});},'ChatQueues':function(){return new Promise(function(_0x2bf6a9){const _0x5967ad=a1217_0x1bf9,_0xf1f9d6=[];for(const _0x57875d in _0x17a592[_0x5967ad('0x36')]){if(typeof _0x17a592[_0x5967ad('0x36')][_0x57875d]!==_0x5967ad('0x53')){const _0x2d7c8d=_0x17a592['chatQueues'][_0x57875d],_0x2f4119={'id':_0x2d7c8d['id'],'available':_0x2d7c8d['available'],'loggedIn':_0x2d7c8d[_0x5967ad('0x1b')],'name':_0x2d7c8d[_0x5967ad('0x40')],'paused':_0x2d7c8d[_0x5967ad('0x52')],'waiting':_0x2d7c8d[_0x5967ad('0xf')]};_0xf1f9d6[_0x5967ad('0x1')](_0x2f4119);}}_0x2bf6a9({'count':_0xf1f9d6[_0x5967ad('0x11')],'rows':_0xf1f9d6});});},'MailQueues':function(){return new Promise(function(_0x1be743){const _0x3708c0=a1217_0x1bf9,_0x380627=[];for(const _0x577d0f in _0x17a592[_0x3708c0('0x16')]){if(typeof _0x17a592[_0x3708c0('0x16')][_0x577d0f]!=='undefined'){const _0x25291b=_0x17a592[_0x3708c0('0x16')][_0x577d0f],_0x5dd722={'id':_0x25291b['id'],'available':_0x25291b['available'],'loggedIn':_0x25291b[_0x3708c0('0x1b')],'name':_0x25291b[_0x3708c0('0x40')],'paused':_0x25291b[_0x3708c0('0x52')],'waiting':_0x25291b[_0x3708c0('0xf')]};_0x380627[_0x3708c0('0x1')](_0x5dd722);}}_0x1be743({'count':_0x380627[_0x3708c0('0x11')],'rows':_0x380627});});},'OpenchannelQueues':function(){return new Promise(function(_0x3b83ac){const _0x374f26=a1217_0x1bf9,_0x28313e=[];for(const _0x1d9c69 in _0x17a592[_0x374f26('0x14')]){if(typeof _0x17a592[_0x374f26('0x14')][_0x1d9c69]!==_0x374f26('0x53')){const _0x323dc5=_0x17a592['openchannelQueues'][_0x1d9c69],_0x21eaad={'id':_0x323dc5['id'],'available':_0x323dc5[_0x374f26('0x19')],'loggedIn':_0x323dc5[_0x374f26('0x1b')],'name':_0x323dc5[_0x374f26('0x40')],'paused':_0x323dc5[_0x374f26('0x52')],'waiting':_0x323dc5[_0x374f26('0xf')]};_0x28313e[_0x374f26('0x1')](_0x21eaad);}}_0x3b83ac({'count':_0x28313e[_0x374f26('0x11')],'rows':_0x28313e});});},'SmsQueues':function(){return new Promise(function(_0x4294c7){const _0x12c9c2=a1217_0x1bf9,_0x204c11=[];for(const _0x1fcc31 in _0x17a592[_0x12c9c2('0x4b')]){if(typeof _0x17a592[_0x12c9c2('0x4b')][_0x1fcc31]!==_0x12c9c2('0x53')){const _0x4352f1=_0x17a592['smsQueues'][_0x1fcc31],_0x3ac858={'id':_0x4352f1['id'],'available':_0x4352f1['available'],'loggedIn':_0x4352f1[_0x12c9c2('0x1b')],'name':_0x4352f1[_0x12c9c2('0x40')],'paused':_0x4352f1[_0x12c9c2('0x52')],'waiting':_0x4352f1['waiting']};_0x204c11[_0x12c9c2('0x1')](_0x3ac858);}}_0x4294c7({'count':_0x204c11[_0x12c9c2('0x11')],'rows':_0x204c11});});},'FaxQueues':function(){return new Promise(function(_0x4092c3){const _0x48dc6a=a1217_0x1bf9,_0x56f34a=[];for(const _0x3a33b2 in _0x17a592[_0x48dc6a('0x23')]){if(typeof _0x17a592['faxQueues'][_0x3a33b2]!==_0x48dc6a('0x53')){const _0x219ad9=_0x17a592[_0x48dc6a('0x23')][_0x3a33b2],_0x1bf6a1={'id':_0x219ad9['id'],'available':_0x219ad9['available'],'loggedIn':_0x219ad9[_0x48dc6a('0x1b')],'name':_0x219ad9[_0x48dc6a('0x40')],'paused':_0x219ad9['paused'],'waiting':_0x219ad9[_0x48dc6a('0xf')]};_0x56f34a['push'](_0x1bf6a1);}}_0x4092c3({'count':_0x56f34a[_0x48dc6a('0x11')],'rows':_0x56f34a});});},'WhatsappQueues':function(){return new Promise(function(_0x280685){const _0x3fab70=a1217_0x1bf9,_0x4e925e=[];for(const _0x37d8de in _0x17a592[_0x3fab70('0x2')]){if(typeof _0x17a592[_0x3fab70('0x2')][_0x37d8de]!==_0x3fab70('0x53')){const _0x5dbd56=_0x17a592['whatsappQueues'][_0x37d8de],_0x15974b={'id':_0x5dbd56['id'],'available':_0x5dbd56[_0x3fab70('0x19')],'loggedIn':_0x5dbd56[_0x3fab70('0x1b')],'name':_0x5dbd56['name'],'paused':_0x5dbd56[_0x3fab70('0x52')],'waiting':_0x5dbd56[_0x3fab70('0xf')]};_0x4e925e['push'](_0x15974b);}}_0x280685({'count':_0x4e925e[_0x3fab70('0x11')],'rows':_0x4e925e});});},'ChatQueuesWaitingInteractions':function(){return new Promise(function(_0x55a5c2){const _0x357078=a1217_0x1bf9,_0x3d03e9=_['values'](_0x17a592[_0x357078('0x0')]);_0x55a5c2({'count':_0x3d03e9[_0x357078('0x11')],'rows':_0x3d03e9});});},'MailQueuesWaitingInteractions':function(){return new Promise(function(_0x5e2982){const _0x33fb3c=a1217_0x1bf9,_0x250ca8=_[_0x33fb3c('0x7')](_0x17a592[_0x33fb3c('0x1a')]);_0x5e2982({'count':_0x250ca8['length'],'rows':_0x250ca8});});},'OpenchannelQueuesWaitingInteractions':function(){return new Promise(function(_0x18c58c){const _0x55004b=a1217_0x1bf9,_0x4b9665=_['values'](_0x17a592[_0x55004b('0x24')]);_0x18c58c({'count':_0x4b9665[_0x55004b('0x11')],'rows':_0x4b9665});});},'SmsQueuesWaitingInteractions':function(){return new Promise(function(_0x4b511c){const _0x138d70=a1217_0x1bf9,_0x5059eb=_['values'](_0x17a592[_0x138d70('0x2a')]);_0x4b511c({'count':_0x5059eb[_0x138d70('0x11')],'rows':_0x5059eb});});},'FaxQueuesWaitingInteractions':function(){return new Promise(function(_0x3b08f5){const _0x190db1=a1217_0x1bf9,_0x22fa6c=_[_0x190db1('0x7')](_0x17a592[_0x190db1('0xb')]);_0x3b08f5({'count':_0x22fa6c['length'],'rows':_0x22fa6c});});},'WhatsappQueuesWaitingInteractions':function(){return new Promise(function(_0x57663b){const _0x5b18e5=a1217_0x1bf9,_0x479dea=_[_0x5b18e5('0x7')](_0x17a592[_0x5b18e5('0x2f')]);_0x57663b({'count':_0x479dea[_0x5b18e5('0x11')],'rows':_0x479dea});});}},_0x2684ee=jayson['server'](_0x5ea3e8)['http']();_0x2684ee['on'](_0x3c3a5f('0x33'),function(_0x48cc3a){const _0x21ed13=_0x3c3a5f;return logger['error'](JSON[_0x21ed13('0x2c')](_0x48cc3a)),_0x20b457(_0x48cc3a);}),_0x2684ee[_0x3c3a5f('0x50')](0x232c,'127.0.0.1',function(){const _0x45d826=_0x3c3a5f;return console[_0x45d826('0x37')]('Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!',0x232c),_0x2da213(_0x45d826('0x28')+0x232c);});});};
\ No newline at end of file