Built motion from commit 994c64e1.|2.6.1
[motion2.git] / server / api / realtime / realtime.controller.js
index 209ea6c..d4a3e5b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb7fe=['pTalking','originated','message','dialMethod','Trunk','startPredictive','startProgressive','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','map','get','agents','busy','outbound','find','filter','length','some','UserId','online','paused','voiceStatus','loggedInDb','User','Queue','Pause','findAll','QueueId','idle','unknown','unavailable','ringing','smsPause','voicePause','whatsappPause','every','pause','chatStatus','faxStatus','mailStatus','openchannelStatus','smsStatus','whatsappStatus','*pause','mail','chat','sms','openchannel','whatsapp','toLowerCase','isArray','findOne','getAgents','uniq','value','fields','includes','globalStatus','order','startsWith','ASC','sort','DESC','pauseType','lastLoginAt','lastPauseAt','internal','address','openchannelPause','mailPause','faxPause','openchannelCapacity','mailCapacity','smsCapacity','faxCapacity','openchannelCurrentCapacity','smsCurrentCapacity','chatStatusTime','openchannelStatusTime','mailStatusTime','smsStatusTime','whatsappStatusTime','faxStatusTime','voiceStatusTime','queue','destconnectedlinenum','phoneBarEnableScreenRecordingByAgent','phoneBarEnableAutomaticScreenRecording','routealias','chatPause','resolve','channel','query','join','globalQueueFilter','type','key','role','agent','getOptions','raw','isEmpty','where','user','userProfileId','nolimit','getResources','findAndCountAll','rows','omit','globalStatusFilter','pauseTypeFilter','fieldName','UserProfile','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../mysqldb','http','client','offset','limit','count','status','set','Content-Range','name','Agents','then','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','result','request','error','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','merge','catch','voice','startCase','Queues','VoiceQueuesChannels','Unable\x20to\x20retrieve\x20voice\x20queues\x20channels','loggedIn','available','waiting','talking','push'];(function(_0x258e8e,_0x1a81f4){var _0x427d2b=function(_0x3b6c82){while(--_0x3b6c82){_0x258e8e['push'](_0x258e8e['shift']());}};_0x427d2b(++_0x1a81f4);}(_0xb7fe,0x1b3));var _0xeb7f=function(_0x4195c2,_0x57e3b8){_0x4195c2=_0x4195c2-0x0;var _0x273062=_0xb7fe[_0x4195c2];return _0x273062;};'use strict';var util=require('util');var _=require('lodash');var jayson=require(_0xeb7f('0x0'));var qs=require(_0xeb7f('0x1'));var logger=require(_0xeb7f('0x2'))(_0xeb7f('0x3'));var db=require(_0xeb7f('0x4'))['db'];var amiClient=jayson['client'][_0xeb7f('0x5')]({'port':0x232a});var routingClient=jayson[_0xeb7f('0x6')][_0xeb7f('0x5')]({'port':0x232c});function respondWithFilteredResult(_0x43cc7e,_0x5d1782){return function(_0x1edc5b){if(_0x1edc5b){var _0x292ad3=typeof _0x5d1782[_0xeb7f('0x7')]==='undefined'&&typeof _0x5d1782[_0xeb7f('0x8')]==='undefined';var _0x2ea8b1=_0x1edc5b['count'];var _0x42f014=_0x292ad3?0x0:_0x5d1782[_0xeb7f('0x7')];var _0x48380f=_0x292ad3?_0x1edc5b[_0xeb7f('0x9')]:_0x5d1782['offset']+_0x5d1782[_0xeb7f('0x8')];var _0x567f0c;if(_0x48380f>=_0x2ea8b1){_0x48380f=_0x2ea8b1;_0x567f0c=0xc8;}else{_0x567f0c=0xce;}_0x43cc7e[_0xeb7f('0xa')](_0x567f0c);return _0x43cc7e[_0xeb7f('0xb')](_0xeb7f('0xc'),_0x42f014+'-'+_0x48380f+'/'+_0x2ea8b1)['json'](_0x1edc5b);}return null;};}function handleError(_0x4a6e1c,_0xaa31f8){_0xaa31f8=_0xaa31f8||0x1f4;return function(_0x335240){logger['error'](_0x335240['stack']);if(_0x335240[_0xeb7f('0xd')]){delete _0x335240[_0xeb7f('0xd')];}_0x4a6e1c[_0xeb7f('0xa')](_0xaa31f8)['send'](_0x335240);};}function getRealtimeAgents(){return new Promise(function(_0x130bd8,_0x106dd0){return amiClient['request'](_0xeb7f('0xe'),{})[_0xeb7f('0xf')](function(_0x4b2bb1){if(_0x4b2bb1['error'])throw new Error(_0xeb7f('0x10'));var _0x459c92=_0x4b2bb1[_0xeb7f('0x11')];return routingClient[_0xeb7f('0x12')](_0xeb7f('0xe'),{})[_0xeb7f('0xf')](function(_0x560527){if(_0x560527[_0xeb7f('0x13')])throw new Error(_0xeb7f('0x14'));var _0x1f6615=_0x560527[_0xeb7f('0x11')];return _0x130bd8(_[_0xeb7f('0x15')]({},_0x459c92,_0x1f6615));});})[_0xeb7f('0x16')](function(_0x37ed5d){_0x106dd0(_0x37ed5d);});});}function getRealtimeQueues(_0x3dbde3,_0x387b1a){return new Promise(function(_0x7eff63,_0x2cfe58){var _0x5afee0=_0x387b1a===_0xeb7f('0x17')?amiClient:routingClient;return _0x5afee0['request'](_[_0xeb7f('0x18')](_0x387b1a)+_0xeb7f('0x19'),_0x3dbde3)['then'](function(_0x31888f){if(_0x31888f[_0xeb7f('0x13')])throw new Error(util['format']('Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues',_0x387b1a));return _0x7eff63(_0x31888f[_0xeb7f('0x11')]);})[_0xeb7f('0x16')](function(_0x15e2b6){_0x2cfe58(_0x15e2b6);});});}function getRealtimeVoiceQueueChannels(){return new Promise(function(_0x17da39,_0x122ede){return amiClient[_0xeb7f('0x12')](_0xeb7f('0x1a'),{})[_0xeb7f('0xf')](function(_0xff4675){if(_0xff4675['error'])throw new Error(_0xeb7f('0x1b'));return _0x17da39(_0xff4675[_0xeb7f('0x11')]);})[_0xeb7f('0x16')](function(_0x10bc08){_0x122ede(_0x10bc08);});});}function initializeQueues(_0x33b773,_0xc972c2,_0x186137,_0x405cc7){var _0x205a9f=[_0xeb7f('0x1c'),_0xeb7f('0x1d'),_0xeb7f('0x1e'),_0xeb7f('0x1f'),'paused'];if(_0x186137===_0xeb7f('0x17')&&_0x405cc7==='outbound'){_0x205a9f[_0xeb7f('0x20')](_0xeb7f('0x21'),_0xeb7f('0x22'),_0xeb7f('0x23'),'dialActive',_0xeb7f('0x24'),_0xeb7f('0x25'),_0xeb7f('0x26'),_0xeb7f('0x27'),_0xeb7f('0x28'),_0xeb7f('0x29'),_0xeb7f('0x2a'),_0xeb7f('0x2b'),_0xeb7f('0x2c'),_0xeb7f('0x2d'),'dialPredictiveIntervalMinThreshold','predictiveIntervalAvailable',_0xeb7f('0x2e'),_0xeb7f('0x2f'),'predictiveIntervalDroppedCallsTimeout',_0xeb7f('0x30'),_0xeb7f('0x31'),_0xeb7f('0x32'));}return _0x33b773[_0xeb7f('0x33')](function(_0x449ef7){var _0x4cc2d=_0x449ef7[_0xeb7f('0x34')]({'plain':!![]});_0x4cc2d[_0xeb7f('0x35')]=[];_0x4cc2d['paused']=0x0;_0x4cc2d['loggedInDb']=0x0;_0x4cc2d[_0xeb7f('0x1c')]=0x0;_0x4cc2d['available']=0x0;_0x4cc2d['waiting']=0x0;if(_0x186137===_0xeb7f('0x17')){_0x4cc2d[_0xeb7f('0x1f')]=0x0;_0x4cc2d[_0xeb7f('0x36')]=0x0;if(_0x405cc7===_0xeb7f('0x37')){_0x4cc2d[_0xeb7f('0x21')]=0x0;_0x4cc2d[_0xeb7f('0x22')]=0x0;}}var _0x229674=_[_0xeb7f('0x38')](_0xc972c2,['id',_0x4cc2d['id']]);if(_0x229674)_[_0xeb7f('0x15')](_0x4cc2d,_['pick'](_0x229674,_0x205a9f));return _0x4cc2d;});}function updateAgentVoiceStatus(_0x19ae1a,_0x12fd62,_0x381a1f){var _0x538892=_[_0xeb7f('0x39')](_0x381a1f,['queue',_0x12fd62[_0xeb7f('0xd')]]);if(_0x538892[_0xeb7f('0x3a')]===0x0)return _0x19ae1a[_0xeb7f('0x36')]=!![];if(_[_0xeb7f('0x3b')](_0x538892,['connectedlinenum',_0x19ae1a['internal']['toString']()]))return _0x19ae1a['talking']=!![];if(!_0x19ae1a[_0xeb7f('0x1f')])return _0x19ae1a[_0xeb7f('0x36')]=!![];}function getVoiceQueueAgents(_0x17cdce,_0x4ae753,_0x3c2032,_0x44e69b){var _0x433cd2=_[_0xeb7f('0x38')](_0x4ae753,['id',_0x17cdce['id']]);if(!_0x433cd2)return _0x17cdce;return _0x433cd2['getMembers']({'raw':!![]})[_0xeb7f('0xf')](function(_0x12dec3){for(var _0x177a93=0x0;_0x177a93<_0x12dec3['length'];_0x177a93++){var _0x3b9bfc=_[_0xeb7f('0x38')](_0x3c2032,['id',_0x12dec3[_0x177a93]['UserId']]);if(!_0x3b9bfc){_0x3b9bfc={'id':_0x12dec3[_0x177a93][_0xeb7f('0x3c')],'name':_0x12dec3[_0x177a93][_0xeb7f('0x3c')],'accountcode':'','online':![]};}var _0x3a8a54={'id':_0x3b9bfc['id'],'name':_0x3b9bfc[_0xeb7f('0xd')],'internal':_0x3b9bfc['accountcode'],'online':Boolean(_0x3b9bfc[_0xeb7f('0x3d')]),'paused':Boolean(_0x12dec3[_0x177a93][_0xeb7f('0x3e')])};if(_0x3b9bfc[_0xeb7f('0x3f')]===_0xeb7f('0x1f'))updateAgentVoiceStatus(_0x3a8a54,_0x17cdce,_0x44e69b);if(_0x3a8a54['online'])_0x17cdce[_0xeb7f('0x40')]++;if(_0x3a8a54[_0xeb7f('0x36')])_0x17cdce[_0xeb7f('0x36')]++;if(_0x3a8a54[_0xeb7f('0x3e')]&&!_0x3a8a54[_0xeb7f('0x36')]&&!_0x3a8a54[_0xeb7f('0x1f')])_0x17cdce[_0xeb7f('0x3e')]++;_0x17cdce['agents'][_0xeb7f('0x20')](_0x3a8a54);}return _0x17cdce;});}function getQueueAgents(_0x22962d,_0x3a7a6f,_0x36fa7f){var _0x1e5106=_0xeb7f('0x41')+_[_0xeb7f('0x18')](_0x36fa7f)+_0xeb7f('0x42');var _0x597a90=_0x36fa7f+_0xeb7f('0x43');return db[_0x1e5106][_0xeb7f('0x44')]({'where':{[_['startCase'](_0x36fa7f)+_0xeb7f('0x45')]:_0x22962d['id']},'raw':!![]})['then'](function(_0x5b7e86){for(var _0x28718b=0x0;_0x28718b<_0x5b7e86[_0xeb7f('0x3a')];_0x28718b++){var _0x4f2d47=_['find'](_0x3a7a6f,['id',_0x5b7e86[_0x28718b][_0xeb7f('0x3c')]]);if(!_0x4f2d47){_0x4f2d47={'id':_0x5b7e86[_0x28718b][_0xeb7f('0x3c')],'name':_0x5b7e86[_0x28718b]['UserId'],'online':![],['pauseField']:![]};}var _0x3de6ba={'id':_0x4f2d47['id'],'name':_0x4f2d47[_0xeb7f('0xd')],'online':Boolean(_0x4f2d47[_0xeb7f('0x3d')]),'paused':Boolean(_0x4f2d47[_0x597a90])};if(_0x3de6ba[_0xeb7f('0x3d')])_0x22962d[_0xeb7f('0x40')]++;_0x22962d[_0xeb7f('0x35')][_0xeb7f('0x20')](_0x3de6ba);}return _0x22962d;});}function isIdle(_0x329cd4){return _0x329cd4===_0xeb7f('0x46')||_0x329cd4===_0xeb7f('0x47')||_0x329cd4===_0xeb7f('0x48')||_0x329cd4===_0xeb7f('0x49')||_['isNil'](_0x329cd4);}function isAgentPaused(_0x2098a2,_0x4b0fdf){var _0x23c27a=[_0x2098a2['chatPause'],_0x2098a2['faxPause'],_0x2098a2['mailPause'],_0x2098a2['openchannelPause'],_0x2098a2[_0xeb7f('0x4a')],_0x2098a2[_0xeb7f('0x4b')],_0x2098a2[_0xeb7f('0x4c')]];if(!_0x4b0fdf)return _[_0xeb7f('0x4d')](_0x23c27a);var _0x285599=_[_0xeb7f('0x39')](_0x23c27a);return _0x285599[_0xeb7f('0x3a')]>0x0&&_0x285599[_0xeb7f('0x3a')]<_0x23c27a[_0xeb7f('0x3a')]?!![]:![];}function isAgentIdle(_0x702515){if(_0x702515[_0xeb7f('0x3f')]!==_0xeb7f('0x46')&&_0x702515[_0xeb7f('0x4b')]){_0x702515[_0xeb7f('0x3f')]=_0xeb7f('0x4e');return![];}return _[_0xeb7f('0x4d')]([_0x702515[_0xeb7f('0x4f')],_0x702515[_0xeb7f('0x50')],_0x702515[_0xeb7f('0x51')],_0x702515[_0xeb7f('0x52')],_0x702515[_0xeb7f('0x53')],_0x702515[_0xeb7f('0x3f')],_0x702515[_0xeb7f('0x54')]],isIdle);}function getAgentStatus(_0x55d260){var _0x2c4188='unknown';if(isAgentPaused(_0x55d260))_0x2c4188='pause';else if(isAgentPaused(_0x55d260,!![]))_0x2c4188=_0xeb7f('0x55');else if(isAgentIdle(_0x55d260))_0x2c4188='idle';else _0x2c4188=_0xeb7f('0x36');return _0x2c4188;}function validateChannel(_0x5bce9d){var _0x163375=[_0xeb7f('0x56'),_0xeb7f('0x57'),_0xeb7f('0x58'),_0xeb7f('0x59'),'fax',_0xeb7f('0x5a'),_0xeb7f('0x17')];if(!_['includes'](_0x163375,_0x5bce9d[_0xeb7f('0x5b')]()))throw new Error('Invalid\x20channel');return _0x5bce9d[_0xeb7f('0x5b')]();}function getFilteredAgentIds(_0x163de3,_0x27945e){var _0x98033d=_[_0xeb7f('0x5c')](_0x163de3)?_0x163de3:[_0x163de3];var _0x1629ce=_[_0xeb7f('0x33')](_0x98033d,function(_0x13f7c3){return db[_0x27945e][_0xeb7f('0x5d')]({'where':{'name':_0x13f7c3}})[_0xeb7f('0xf')](function(_0x1eb5bb){if(!_0x1eb5bb)return[];return _0x1eb5bb[_0xeb7f('0x5e')]({'attributes':['id'],'raw':!![]});});});return Promise['all'](_0x1629ce)[_0xeb7f('0xf')](function(_0xd9cac9){var _0x324270=_(_0xd9cac9)['flatten']()[_0xeb7f('0x33')]('id')[_0xeb7f('0x5f')]()[_0xeb7f('0x60')]();return _0x324270;});}function getUpdatedSortOptions(_0x491540){var _0x44c245={'fields':[],'order':null};var _0x1a1866=_0x491540['split'](',');_0x44c245[_0xeb7f('0x61')]=_[_0xeb7f('0x39')](_0x1a1866,function(_0x3d6a04){if(!_0x3d6a04[_0xeb7f('0x62')](_0xeb7f('0x63')))return!![];_0x44c245[_0xeb7f('0x64')]=_[_0xeb7f('0x65')](_0x3d6a04,'-')?'DESC':_0xeb7f('0x66');return![];});return _0x44c245;}function orderAgentsByStatus(_0x333b75,_0x4e48e9){return _0x333b75[_0xeb7f('0x67')](function(_0x162ba4,_0x22444f){if(_0x162ba4['globalStatus']===_0x22444f[_0xeb7f('0x63')]&&_0x162ba4[_0xeb7f('0x63')]===_0xeb7f('0x4e')){if(_0x4e48e9===_0xeb7f('0x68'))return(_0x162ba4[_0xeb7f('0x69')]||'')<(_0x22444f[_0xeb7f('0x69')]||'')?0x1:-0x1;return _0x162ba4['pauseType']<_0x22444f[_0xeb7f('0x69')]?-0x1:0x1;}else{if(_0x4e48e9===_0xeb7f('0x68'))return _0x162ba4[_0xeb7f('0x63')]<_0x22444f[_0xeb7f('0x63')]?0x1:-0x1;return _0x162ba4[_0xeb7f('0x63')]<_0x22444f['globalStatus']?-0x1:0x1;}});}exports['getAgents']=function(_0x2ec060,_0x36c8d1){var _0x5efe47={'count':0x0,'rows':[]},_0x235433={},_0x32d411,_0x5afe1e,_0x44b4c0,_0x186a8d,_0x1c7af6=['userpic',_0xeb7f('0x3d'),_0xeb7f('0x6a'),_0xeb7f('0x6b'),_0xeb7f('0x69'),_0xeb7f('0x6b'),_0xeb7f('0x6c'),_0xeb7f('0x6d'),'chatPause',_0xeb7f('0x6e'),_0xeb7f('0x6f'),_0xeb7f('0x4a'),_0xeb7f('0x4c'),_0xeb7f('0x70'),_0xeb7f('0x4b'),'chatCapacity',_0xeb7f('0x71'),_0xeb7f('0x72'),_0xeb7f('0x73'),'whatsappCapacity',_0xeb7f('0x74'),'chatCurrentCapacity',_0xeb7f('0x75'),'mailCurrentCapacity',_0xeb7f('0x76'),'whatsappCurrentCapacity','faxCurrentCapacity',_0xeb7f('0x4f'),'openchannelStatus',_0xeb7f('0x51'),'smsStatus',_0xeb7f('0x54'),_0xeb7f('0x50'),_0xeb7f('0x3f'),_0xeb7f('0x77'),_0xeb7f('0x78'),_0xeb7f('0x79'),_0xeb7f('0x7a'),_0xeb7f('0x7b'),_0xeb7f('0x7c'),_0xeb7f('0x7d'),_0xeb7f('0x7e'),_0xeb7f('0x7f'),'screenrecording',_0xeb7f('0x80'),_0xeb7f('0x81'),_0xeb7f('0x82')],_0x38ea2c=[_0xeb7f('0x83'),_0xeb7f('0x6e'),'mailPause',_0xeb7f('0x4a'),'whatsappPause',_0xeb7f('0x70'),'voicePause','online'];Promise[_0xeb7f('0x84')]()[_0xeb7f('0xf')](function(){if(_0x2ec060['query'][_0xeb7f('0x85')])_0x32d411=validateChannel(_0x2ec060[_0xeb7f('0x86')][_0xeb7f('0x85')]);if(!_0x2ec060[_0xeb7f('0x86')][_0xeb7f('0x67')]||!_0x2ec060[_0xeb7f('0x86')]['sort'][_0xeb7f('0x62')](_0xeb7f('0x63')))return;var _0x2e5356=getUpdatedSortOptions(_0x2ec060['query'][_0xeb7f('0x67')]);_0x2ec060[_0xeb7f('0x86')]['sort']=_0x2e5356['fields'][_0xeb7f('0x87')](',');_0x5afe1e=_0x2e5356[_0xeb7f('0x64')];})[_0xeb7f('0xf')](function(){if(!_0x2ec060['query'][_0xeb7f('0x88')])return[];var _0x4b5868=_['startCase'](_0x32d411)+'Queue';return getFilteredAgentIds(_0x2ec060[_0xeb7f('0x86')][_0xeb7f('0x88')],_0x4b5868);})['then'](function(_0x11e7a2){var _0x176ca7=_['map'](db['User']['rawAttributes'],function(_0x312a44){return{'name':_0x312a44['fieldName'],'type':_0x312a44[_0xeb7f('0x89')][_0xeb7f('0x8a')]};});_0x2ec060[_0xeb7f('0x86')][_0xeb7f('0x8b')]=_0xeb7f('0x8c');_0x2ec060[_0xeb7f('0x86')]['online']=!![];_0x235433=qs[_0xeb7f('0x8d')](_0x176ca7,_0x2ec060);_0x235433[_0xeb7f('0x8e')]=!![];if(!_[_0xeb7f('0x8f')](_0x11e7a2)){_0x235433[_0xeb7f('0x90')]=_[_0xeb7f('0x15')](_0x235433['where'],{'$and':[{'id':{'$in':_0x11e7a2}}]});}else if(!_[_0xeb7f('0x8f')](_0x2ec060[_0xeb7f('0x86')][_0xeb7f('0x88')])){return _0x5efe47;}if(_0x2ec060['user'][_0xeb7f('0x8b')]===_0xeb7f('0x91')){var _0x455feb={'params':{'id':_0x2ec060[_0xeb7f('0x91')][_0xeb7f('0x92')]},'query':{'section':_0xeb7f('0xe'),'role':_0xeb7f('0x8c'),'online':!![],'nolimit':_0x2ec060[_0xeb7f('0x86')][_0xeb7f('0x93')],'sort':_0x2ec060[_0xeb7f('0x86')]['sort'],'filter':_0x2ec060[_0xeb7f('0x86')]['filter'],'raw':!![],'ids':_0x11e7a2}};return db['UserProfile'][_0xeb7f('0x94')](_0x455feb);}return db[_0xeb7f('0x41')][_0xeb7f('0x95')](_0x235433);})[_0xeb7f('0xf')](function(_0x175a42){_0x5efe47[_0xeb7f('0x9')]=_0x175a42[_0xeb7f('0x9')];_0x44b4c0=_0x175a42[_0xeb7f('0x96')];return getRealtimeAgents();})[_0xeb7f('0xf')](function(_0x3a6f81){_0x186a8d=_0x3a6f81[_0xeb7f('0x96')];return _0x44b4c0['map'](function(_0x34a400){var _0x304e10=_['find'](_0x186a8d,['id',_0x34a400['id']]);if(_0x304e10)_[_0xeb7f('0x15')](_0x34a400,_['pick'](_[_0xeb7f('0x97')](_0x304e10,_0x38ea2c),_0x1c7af6));_0x34a400[_0xeb7f('0x63')]=getAgentStatus(_0x34a400);return _0x34a400;});})['then'](function(_0x528dec){var _0x4d161d;if(_0x2ec060[_0xeb7f('0x86')][_0xeb7f('0x98')]){_0x4d161d=_[_0xeb7f('0x39')](_0x528dec,[_0xeb7f('0x63'),_0x2ec060[_0xeb7f('0x86')]['globalStatusFilter']]);if(_0x2ec060[_0xeb7f('0x86')][_0xeb7f('0x99')]){_0x4d161d=_[_0xeb7f('0x39')](_0x4d161d,[_0xeb7f('0x69'),_0x2ec060['query'][_0xeb7f('0x99')]]);}}if(_0x4d161d)_0x528dec=_0x4d161d;if(!_0x5afe1e)return _0x528dec;return orderAgentsByStatus(_0x528dec,_0x5afe1e);})[_0xeb7f('0xf')](function(_0x269da5){_0x5efe47[_0xeb7f('0x96')]=_0x269da5;return _0x5efe47;})['then'](respondWithFilteredResult(_0x36c8d1,_0x235433))[_0xeb7f('0x16')](handleError(_0x36c8d1,null));};exports['getQueues']=function(_0x53d1df,_0x3527aa){var _0x2d3ff9={'count':0x0,'rows':[]},_0x1abd66={},_0x69809f,_0x548956,_0x42de00,_0x44787c,_0xb2c8aa;Promise['resolve']()[_0xeb7f('0xf')](function(){if(_0x53d1df[_0xeb7f('0x86')][_0xeb7f('0x85')])_0x69809f=validateChannel(_0x53d1df[_0xeb7f('0x86')]['channel']);var _0x248297=_['startCase'](_0x69809f)+_0xeb7f('0x42');var _0xe244c1=_[_0xeb7f('0x33')](db[_0x248297]['rawAttributes'],function(_0x3c924d){return{'name':_0x3c924d[_0xeb7f('0x9a')],'type':_0x3c924d[_0xeb7f('0x89')][_0xeb7f('0x8a')]};});_0x1abd66=qs[_0xeb7f('0x8d')](_0xe244c1,_0x53d1df);if(_0x53d1df[_0xeb7f('0x91')][_0xeb7f('0x8b')]===_0xeb7f('0x91')){var _0x259dd6={'params':{'id':_0x53d1df[_0xeb7f('0x91')][_0xeb7f('0x92')]},'query':{'section':_0x69809f===_0xeb7f('0x17')&&_0x53d1df[_0xeb7f('0x86')]['type']===_0xeb7f('0x37')?'QueueCampaigns':_['startCase'](_0x69809f)+_0xeb7f('0x19'),'type':_0x53d1df[_0xeb7f('0x86')][_0xeb7f('0x89')],'nolimit':!![],'sort':'name','filter':_0x53d1df['query']['filter']}};return db[_0xeb7f('0x9b')][_0xeb7f('0x94')](_0x259dd6);}return db[_0x248297][_0xeb7f('0x95')](_0x1abd66);})[_0xeb7f('0xf')](function(_0x465103){_0x2d3ff9[_0xeb7f('0x9')]=_0x465103['count'];_0x548956=_0x465103[_0xeb7f('0x96')];return getRealtimeQueues(_0x53d1df,_0x69809f);})[_0xeb7f('0xf')](function(_0x80440d){_0x44787c=_0x80440d['rows'];return getRealtimeAgents();})[_0xeb7f('0xf')](function(_0x4ff9f1){_0x42de00=_0x4ff9f1[_0xeb7f('0x96')];if(_0x69809f!=_0xeb7f('0x17'))return;return getRealtimeVoiceQueueChannels();})[_0xeb7f('0xf')](function(_0x34d4b5){_0xb2c8aa=_0x34d4b5?_0x34d4b5[_0xeb7f('0x96')]:[];return initializeQueues(_0x548956,_0x44787c,_0x69809f,_0x53d1df['query']['type']);})[_0xeb7f('0xf')](function(_0x1fcc0d){var _0x381a81=_0x1fcc0d[_0xeb7f('0x33')](function(_0x41e306){if(_0x69809f==='voice')return getVoiceQueueAgents(_0x41e306,_0x548956,_0x42de00,_0xb2c8aa);else return getQueueAgents(_0x41e306,_0x42de00,_0x69809f);});return Promise['all'](_0x381a81);})[_0xeb7f('0xf')](function(_0x1a0d69){_0x2d3ff9[_0xeb7f('0x96')]=_0x1a0d69;return _0x2d3ff9;})[_0xeb7f('0xf')](respondWithFilteredResult(_0x3527aa,_0x1abd66))[_0xeb7f('0x16')](handleError(_0x3527aa,null));};
\ No newline at end of file
+var _0x3011=['dialPredictiveIntervalMinThreshold','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','map','get','agents','loggedInDb','available','busy','outbound','find','pick','filter','queue','length','some','connectedlinenum','internal','toString','getMembers','UserId','accountcode','online','paused','voiceStatus','User','startCase','Queue','findAll','idle','unknown','ringing','isNil','openchannelPause','smsPause','voicePause','whatsappPause','every','pause','chatStatus','openchannelStatus','smsStatus','whatsappStatus','*pause','chat','sms','openchannel','fax','includes','toLowerCase','findOne','getAgents','flatten','uniq','value','split','fields','globalStatus','DESC','ASC','sort','pauseType','lastLoginAt','lastPauseAt','address','chatPause','mailPause','faxPause','openchannelCapacity','mailCapacity','smsCapacity','faxCapacity','chatCurrentCapacity','mailCurrentCapacity','smsCurrentCapacity','whatsappCurrentCapacity','faxCurrentCapacity','mailStatus','faxStatus','chatStatusTime','openchannelStatusTime','mailStatusTime','smsStatusTime','faxStatusTime','voiceStatusTime','screenrecording','phoneBarEnableScreenRecordingByAgent','phoneBarEnableAutomaticScreenRecording','routealias','resolve','channel','query','join','order','globalQueueFilter','rawAttributes','fieldName','type','key','agent','raw','where','isEmpty','user','role','getResources','findAndCountAll','pauseTypeFilter','rows','getQueues','getOptions','userProfileId','QueueCampaigns','all','util','lodash','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../mysqldb','client','http','offset','limit','undefined','count','status','set','Content-Range','json','error','stack','name','send','Agents','then','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','request','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','merge','catch','voice','Queues','format','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','VoiceQueuesChannels','Unable\x20to\x20retrieve\x20voice\x20queues\x20channels','waiting','talking','push','pTalking','message','dialMethod','Trunk','startPredictive','startProgressive','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMaxThreshold'];(function(_0x3ab833,_0x578b76){var _0x4ff18a=function(_0x100be6){while(--_0x100be6){_0x3ab833['push'](_0x3ab833['shift']());}};_0x4ff18a(++_0x578b76);}(_0x3011,0x1c3));var _0x1301=function(_0x2f863f,_0x2b8c4f){_0x2f863f=_0x2f863f-0x0;var _0x148335=_0x3011[_0x2f863f];return _0x148335;};'use strict';var util=require(_0x1301('0x0'));var _=require(_0x1301('0x1'));var jayson=require(_0x1301('0x2'));var qs=require(_0x1301('0x3'));var logger=require(_0x1301('0x4'))(_0x1301('0x5'));var db=require(_0x1301('0x6'))['db'];var amiClient=jayson['client']['http']({'port':0x232a});var routingClient=jayson[_0x1301('0x7')][_0x1301('0x8')]({'port':0x232c});function respondWithFilteredResult(_0x49f97e,_0x5353c3){return function(_0x1d045d){if(_0x1d045d){var _0x2fd45d=typeof _0x5353c3[_0x1301('0x9')]==='undefined'&&typeof _0x5353c3[_0x1301('0xa')]===_0x1301('0xb');var _0x2fb1aa=_0x1d045d[_0x1301('0xc')];var _0x1c7a4a=_0x2fd45d?0x0:_0x5353c3['offset'];var _0x96613d=_0x2fd45d?_0x1d045d[_0x1301('0xc')]:_0x5353c3['offset']+_0x5353c3[_0x1301('0xa')];var _0x9c91e6;if(_0x96613d>=_0x2fb1aa){_0x96613d=_0x2fb1aa;_0x9c91e6=0xc8;}else{_0x9c91e6=0xce;}_0x49f97e[_0x1301('0xd')](_0x9c91e6);return _0x49f97e[_0x1301('0xe')](_0x1301('0xf'),_0x1c7a4a+'-'+_0x96613d+'/'+_0x2fb1aa)[_0x1301('0x10')](_0x1d045d);}return null;};}function handleError(_0x1966f8,_0x26d8e8){_0x26d8e8=_0x26d8e8||0x1f4;return function(_0x11c364){logger[_0x1301('0x11')](_0x11c364[_0x1301('0x12')]);if(_0x11c364['name']){delete _0x11c364[_0x1301('0x13')];}_0x1966f8[_0x1301('0xd')](_0x26d8e8)[_0x1301('0x14')](_0x11c364);};}function getRealtimeAgents(){return new Promise(function(_0x483edf,_0x484692){return amiClient['request'](_0x1301('0x15'),{})[_0x1301('0x16')](function(_0x5a01db){if(_0x5a01db[_0x1301('0x11')])throw new Error(_0x1301('0x17'));var _0x2de550=_0x5a01db['result'];return routingClient[_0x1301('0x18')](_0x1301('0x15'),{})[_0x1301('0x16')](function(_0x3bf3d1){if(_0x3bf3d1[_0x1301('0x11')])throw new Error(_0x1301('0x19'));var _0x26c7df=_0x3bf3d1['result'];return _0x483edf(_[_0x1301('0x1a')]({},_0x2de550,_0x26c7df));});})[_0x1301('0x1b')](function(_0x502e04){_0x484692(_0x502e04);});});}function getRealtimeQueues(_0x567e46,_0x24f584){return new Promise(function(_0x3579c5,_0x1ceb48){var _0x2af40f=_0x24f584===_0x1301('0x1c')?amiClient:routingClient;return _0x2af40f[_0x1301('0x18')](_['startCase'](_0x24f584)+_0x1301('0x1d'),_0x567e46)[_0x1301('0x16')](function(_0xa61870){if(_0xa61870[_0x1301('0x11')])throw new Error(util[_0x1301('0x1e')](_0x1301('0x1f'),_0x24f584));return _0x3579c5(_0xa61870[_0x1301('0x20')]);})[_0x1301('0x1b')](function(_0x984638){_0x1ceb48(_0x984638);});});}function getRealtimeVoiceQueueChannels(){return new Promise(function(_0x35e70f,_0x107e06){return amiClient[_0x1301('0x18')](_0x1301('0x21'),{})[_0x1301('0x16')](function(_0x5ac12a){if(_0x5ac12a['error'])throw new Error(_0x1301('0x22'));return _0x35e70f(_0x5ac12a[_0x1301('0x20')]);})['catch'](function(_0x1649f5){_0x107e06(_0x1649f5);});});}function initializeQueues(_0x2efb70,_0x577465,_0x39c090,_0x4c5db8){var _0x847f48=['loggedIn','available',_0x1301('0x23'),_0x1301('0x24'),'paused'];if(_0x39c090===_0x1301('0x1c')&&_0x4c5db8==='outbound'){_0x847f48[_0x1301('0x25')](_0x1301('0x26'),'originated',_0x1301('0x27'),'dialActive',_0x1301('0x28'),_0x1301('0x29'),_0x1301('0x2a'),_0x1301('0x2b'),_0x1301('0x2c'),_0x1301('0x2d'),_0x1301('0x2e'),_0x1301('0x2f'),_0x1301('0x30'),_0x1301('0x31'),_0x1301('0x32'),'predictiveIntervalAvailable',_0x1301('0x33'),_0x1301('0x34'),_0x1301('0x35'),'predictiveIntervalDroppedCallsCallersExit',_0x1301('0x36'),_0x1301('0x37'));}return _0x2efb70[_0x1301('0x38')](function(_0x28d76d){var _0x287c45=_0x28d76d[_0x1301('0x39')]({'plain':!![]});_0x287c45[_0x1301('0x3a')]=[];_0x287c45['paused']=0x0;_0x287c45[_0x1301('0x3b')]=0x0;_0x287c45['loggedIn']=0x0;_0x287c45[_0x1301('0x3c')]=0x0;_0x287c45[_0x1301('0x23')]=0x0;if(_0x39c090===_0x1301('0x1c')){_0x287c45[_0x1301('0x24')]=0x0;_0x287c45[_0x1301('0x3d')]=0x0;if(_0x4c5db8===_0x1301('0x3e')){_0x287c45[_0x1301('0x26')]=0x0;_0x287c45['originated']=0x0;}}var _0x3d0de1=_[_0x1301('0x3f')](_0x577465,['id',_0x287c45['id']]);if(_0x3d0de1)_[_0x1301('0x1a')](_0x287c45,_[_0x1301('0x40')](_0x3d0de1,_0x847f48));return _0x287c45;});}function updateAgentVoiceStatus(_0x7bbd2e,_0x53fe39,_0x3542c8){var _0x49b944=_[_0x1301('0x41')](_0x3542c8,[_0x1301('0x42'),_0x53fe39[_0x1301('0x13')]]);if(_0x49b944[_0x1301('0x43')]===0x0)return _0x7bbd2e['busy']=!![];if(_[_0x1301('0x44')](_0x49b944,[_0x1301('0x45'),_0x7bbd2e[_0x1301('0x46')][_0x1301('0x47')]()]))return _0x7bbd2e[_0x1301('0x24')]=!![];if(!_0x7bbd2e[_0x1301('0x24')])return _0x7bbd2e[_0x1301('0x3d')]=!![];}function getVoiceQueueAgents(_0x400d16,_0x45a483,_0x547ee3,_0x28ff00){var _0x5cd2e7=_[_0x1301('0x3f')](_0x45a483,['id',_0x400d16['id']]);if(!_0x5cd2e7)return _0x400d16;return _0x5cd2e7[_0x1301('0x48')]({'raw':!![]})[_0x1301('0x16')](function(_0x4e8e73){for(var _0x333eff=0x0;_0x333eff<_0x4e8e73['length'];_0x333eff++){var _0x21fb6f=_[_0x1301('0x3f')](_0x547ee3,['id',_0x4e8e73[_0x333eff][_0x1301('0x49')]]);if(!_0x21fb6f){_0x21fb6f={'id':_0x4e8e73[_0x333eff]['UserId'],'name':_0x4e8e73[_0x333eff][_0x1301('0x49')],'accountcode':'','online':![]};}var _0x3e3d1e={'id':_0x21fb6f['id'],'name':_0x21fb6f[_0x1301('0x13')],'internal':_0x21fb6f[_0x1301('0x4a')],'online':Boolean(_0x21fb6f[_0x1301('0x4b')]),'paused':Boolean(_0x4e8e73[_0x333eff][_0x1301('0x4c')])};if(_0x21fb6f[_0x1301('0x4d')]===_0x1301('0x24'))updateAgentVoiceStatus(_0x3e3d1e,_0x400d16,_0x28ff00);if(_0x3e3d1e['online'])_0x400d16[_0x1301('0x3b')]++;if(_0x3e3d1e['busy'])_0x400d16[_0x1301('0x3d')]++;if(_0x3e3d1e[_0x1301('0x4c')]&&!_0x3e3d1e[_0x1301('0x3d')]&&!_0x3e3d1e[_0x1301('0x24')])_0x400d16[_0x1301('0x4c')]++;_0x400d16['agents']['push'](_0x3e3d1e);}return _0x400d16;});}function getQueueAgents(_0x4a083d,_0x2fd7e0,_0x3e965c){var _0x28bdd7=_0x1301('0x4e')+_[_0x1301('0x4f')](_0x3e965c)+_0x1301('0x50');var _0xcdbfbc=_0x3e965c+'Pause';return db[_0x28bdd7][_0x1301('0x51')]({'where':{[_[_0x1301('0x4f')](_0x3e965c)+'QueueId']:_0x4a083d['id']},'raw':!![]})[_0x1301('0x16')](function(_0x468c66){for(var _0x41dfbb=0x0;_0x41dfbb<_0x468c66[_0x1301('0x43')];_0x41dfbb++){var _0xafbc4f=_[_0x1301('0x3f')](_0x2fd7e0,['id',_0x468c66[_0x41dfbb][_0x1301('0x49')]]);if(!_0xafbc4f){_0xafbc4f={'id':_0x468c66[_0x41dfbb][_0x1301('0x49')],'name':_0x468c66[_0x41dfbb][_0x1301('0x49')],'online':![],['pauseField']:![]};}var _0x27a1c3={'id':_0xafbc4f['id'],'name':_0xafbc4f[_0x1301('0x13')],'online':Boolean(_0xafbc4f[_0x1301('0x4b')]),'paused':Boolean(_0xafbc4f[_0xcdbfbc])};if(_0x27a1c3[_0x1301('0x4b')])_0x4a083d[_0x1301('0x3b')]++;_0x4a083d[_0x1301('0x3a')]['push'](_0x27a1c3);}return _0x4a083d;});}function isIdle(_0x30d138){return _0x30d138===_0x1301('0x52')||_0x30d138===_0x1301('0x53')||_0x30d138==='unavailable'||_0x30d138===_0x1301('0x54')||_[_0x1301('0x55')](_0x30d138);}function isAgentPaused(_0x37704a,_0x2a2041){var _0x22681e=[_0x37704a['chatPause'],_0x37704a['faxPause'],_0x37704a['mailPause'],_0x37704a[_0x1301('0x56')],_0x37704a[_0x1301('0x57')],_0x37704a[_0x1301('0x58')],_0x37704a[_0x1301('0x59')]];if(!_0x2a2041)return _[_0x1301('0x5a')](_0x22681e);var _0x351538=_[_0x1301('0x41')](_0x22681e);return _0x351538[_0x1301('0x43')]>0x0&&_0x351538['length']<_0x22681e[_0x1301('0x43')]?!![]:![];}function isAgentIdle(_0x266a22){if(_0x266a22['voiceStatus']!==_0x1301('0x52')&&_0x266a22[_0x1301('0x58')]){_0x266a22[_0x1301('0x4d')]=_0x1301('0x5b');return![];}return _[_0x1301('0x5a')]([_0x266a22[_0x1301('0x5c')],_0x266a22['faxStatus'],_0x266a22['mailStatus'],_0x266a22[_0x1301('0x5d')],_0x266a22[_0x1301('0x5e')],_0x266a22[_0x1301('0x4d')],_0x266a22[_0x1301('0x5f')]],isIdle);}function getAgentStatus(_0x27dd08){var _0x493303='unknown';if(isAgentPaused(_0x27dd08))_0x493303='pause';else if(isAgentPaused(_0x27dd08,!![]))_0x493303=_0x1301('0x60');else if(isAgentIdle(_0x27dd08))_0x493303=_0x1301('0x52');else _0x493303=_0x1301('0x3d');return _0x493303;}function validateChannel(_0x1fad3a){var _0x5c9c42=['mail',_0x1301('0x61'),_0x1301('0x62'),_0x1301('0x63'),_0x1301('0x64'),'whatsapp',_0x1301('0x1c')];if(!_[_0x1301('0x65')](_0x5c9c42,_0x1fad3a['toLowerCase']()))throw new Error('Invalid\x20channel');return _0x1fad3a[_0x1301('0x66')]();}function getFilteredAgentIds(_0x3d8053,_0xd0cd66){var _0x43ddb4=_['isArray'](_0x3d8053)?_0x3d8053:[_0x3d8053];var _0x605515=_[_0x1301('0x38')](_0x43ddb4,function(_0x4d2c3f){return db[_0xd0cd66][_0x1301('0x67')]({'where':{'name':_0x4d2c3f}})[_0x1301('0x16')](function(_0x25037b){if(!_0x25037b)return[];return _0x25037b[_0x1301('0x68')]({'attributes':['id'],'raw':!![]});});});return Promise['all'](_0x605515)['then'](function(_0x520d5d){var _0x309b34=_(_0x520d5d)[_0x1301('0x69')]()['map']('id')[_0x1301('0x6a')]()[_0x1301('0x6b')]();return _0x309b34;});}function getUpdatedSortOptions(_0x221abb){var _0x3909aa={'fields':[],'order':null};var _0x129195=_0x221abb[_0x1301('0x6c')](',');_0x3909aa[_0x1301('0x6d')]=_['filter'](_0x129195,function(_0x149303){if(!_0x149303[_0x1301('0x65')](_0x1301('0x6e')))return!![];_0x3909aa['order']=_['startsWith'](_0x149303,'-')?_0x1301('0x6f'):_0x1301('0x70');return![];});return _0x3909aa;}function orderAgentsByStatus(_0x3766ab,_0x144b11){return _0x3766ab[_0x1301('0x71')](function(_0x4d0700,_0xcbf03a){if(_0x4d0700[_0x1301('0x6e')]===_0xcbf03a[_0x1301('0x6e')]&&_0x4d0700[_0x1301('0x6e')]===_0x1301('0x5b')){if(_0x144b11===_0x1301('0x6f'))return(_0x4d0700[_0x1301('0x72')]||'')<(_0xcbf03a[_0x1301('0x72')]||'')?0x1:-0x1;return _0x4d0700[_0x1301('0x72')]<_0xcbf03a[_0x1301('0x72')]?-0x1:0x1;}else{if(_0x144b11==='DESC')return _0x4d0700['globalStatus']<_0xcbf03a[_0x1301('0x6e')]?0x1:-0x1;return _0x4d0700[_0x1301('0x6e')]<_0xcbf03a[_0x1301('0x6e')]?-0x1:0x1;}});}exports[_0x1301('0x68')]=function(_0x4d6b53,_0x1f6778){var _0x1e1bcb={'count':0x0,'rows':[]},_0x2a95fc={},_0x934495,_0x38f906,_0x20332b,_0x533619,_0x35eafe=['userpic','online',_0x1301('0x73'),_0x1301('0x74'),_0x1301('0x72'),'lastPauseAt',_0x1301('0x46'),_0x1301('0x75'),_0x1301('0x76'),_0x1301('0x56'),_0x1301('0x77'),_0x1301('0x57'),'whatsappPause',_0x1301('0x78'),'voicePause','chatCapacity',_0x1301('0x79'),_0x1301('0x7a'),_0x1301('0x7b'),'whatsappCapacity',_0x1301('0x7c'),_0x1301('0x7d'),'openchannelCurrentCapacity',_0x1301('0x7e'),_0x1301('0x7f'),_0x1301('0x80'),_0x1301('0x81'),_0x1301('0x5c'),_0x1301('0x5d'),_0x1301('0x82'),_0x1301('0x5e'),_0x1301('0x5f'),_0x1301('0x83'),_0x1301('0x4d'),_0x1301('0x84'),_0x1301('0x85'),_0x1301('0x86'),_0x1301('0x87'),'whatsappStatusTime',_0x1301('0x88'),_0x1301('0x89'),'queue','destconnectedlinenum',_0x1301('0x8a'),_0x1301('0x8b'),_0x1301('0x8c'),_0x1301('0x8d')],_0x1b9183=[_0x1301('0x76'),_0x1301('0x56'),_0x1301('0x77'),_0x1301('0x57'),'whatsappPause',_0x1301('0x78'),'voicePause','online'];Promise[_0x1301('0x8e')]()[_0x1301('0x16')](function(){if(_0x4d6b53['query'][_0x1301('0x8f')])_0x934495=validateChannel(_0x4d6b53[_0x1301('0x90')]['channel']);if(!_0x4d6b53[_0x1301('0x90')]['sort']||!_0x4d6b53['query'][_0x1301('0x71')][_0x1301('0x65')](_0x1301('0x6e')))return;var _0x36bfd6=getUpdatedSortOptions(_0x4d6b53[_0x1301('0x90')][_0x1301('0x71')]);_0x4d6b53[_0x1301('0x90')][_0x1301('0x71')]=_0x36bfd6[_0x1301('0x6d')][_0x1301('0x91')](',');_0x38f906=_0x36bfd6[_0x1301('0x92')];})[_0x1301('0x16')](function(){if(!_0x4d6b53[_0x1301('0x90')][_0x1301('0x93')])return[];var _0x2c434e=_['startCase'](_0x934495)+'Queue';return getFilteredAgentIds(_0x4d6b53['query'][_0x1301('0x93')],_0x2c434e);})[_0x1301('0x16')](function(_0x2325fe){var _0x39bdbb=_[_0x1301('0x38')](db[_0x1301('0x4e')][_0x1301('0x94')],function(_0x8ab343){return{'name':_0x8ab343[_0x1301('0x95')],'type':_0x8ab343[_0x1301('0x96')][_0x1301('0x97')]};});_0x4d6b53[_0x1301('0x90')]['role']=_0x1301('0x98');_0x4d6b53[_0x1301('0x90')][_0x1301('0x4b')]=!![];_0x2a95fc=qs['getOptions'](_0x39bdbb,_0x4d6b53);_0x2a95fc[_0x1301('0x99')]=!![];if(!_['isEmpty'](_0x2325fe)){_0x2a95fc['where']=_[_0x1301('0x1a')](_0x2a95fc[_0x1301('0x9a')],{'$and':[{'id':{'$in':_0x2325fe}}]});}else if(!_[_0x1301('0x9b')](_0x4d6b53[_0x1301('0x90')][_0x1301('0x93')])){return _0x1e1bcb;}if(_0x4d6b53[_0x1301('0x9c')][_0x1301('0x9d')]===_0x1301('0x9c')){var _0x446a5a={'params':{'id':_0x4d6b53[_0x1301('0x9c')]['userProfileId']},'query':{'section':_0x1301('0x15'),'role':_0x1301('0x98'),'online':!![],'nolimit':_0x4d6b53[_0x1301('0x90')]['nolimit'],'sort':_0x4d6b53[_0x1301('0x90')][_0x1301('0x71')],'filter':_0x4d6b53[_0x1301('0x90')]['filter'],'raw':!![],'ids':_0x2325fe}};return db['UserProfile'][_0x1301('0x9e')](_0x446a5a);}return db[_0x1301('0x4e')][_0x1301('0x9f')](_0x2a95fc);})[_0x1301('0x16')](function(_0x83e03d){_0x1e1bcb[_0x1301('0xc')]=_0x83e03d[_0x1301('0xc')];_0x20332b=_0x83e03d['rows'];return getRealtimeAgents();})[_0x1301('0x16')](function(_0x470650){_0x533619=_0x470650['rows'];return _0x20332b[_0x1301('0x38')](function(_0x166b4f){var _0x1d5f10=_['find'](_0x533619,['id',_0x166b4f['id']]);if(_0x1d5f10)_['merge'](_0x166b4f,_[_0x1301('0x40')](_['omit'](_0x1d5f10,_0x1b9183),_0x35eafe));_0x166b4f[_0x1301('0x6e')]=getAgentStatus(_0x166b4f);return _0x166b4f;});})[_0x1301('0x16')](function(_0x2a32bd){var _0x4ddb24;if(_0x4d6b53[_0x1301('0x90')]['globalStatusFilter']){_0x4ddb24=_[_0x1301('0x41')](_0x2a32bd,[_0x1301('0x6e'),_0x4d6b53[_0x1301('0x90')]['globalStatusFilter']]);if(_0x4d6b53[_0x1301('0x90')]['pauseTypeFilter']){_0x4ddb24=_[_0x1301('0x41')](_0x4ddb24,[_0x1301('0x72'),_0x4d6b53[_0x1301('0x90')][_0x1301('0xa0')]]);}}if(_0x4ddb24)_0x2a32bd=_0x4ddb24;if(!_0x38f906)return _0x2a32bd;return orderAgentsByStatus(_0x2a32bd,_0x38f906);})[_0x1301('0x16')](function(_0x15125b){_0x1e1bcb[_0x1301('0xa1')]=_0x15125b;return _0x1e1bcb;})[_0x1301('0x16')](respondWithFilteredResult(_0x1f6778,_0x2a95fc))[_0x1301('0x1b')](handleError(_0x1f6778,null));};exports[_0x1301('0xa2')]=function(_0x468e53,_0x19e6f9){var _0x73018a={'count':0x0,'rows':[]},_0x56adb8={},_0x1972c2,_0x3c30fc,_0x31a90e,_0x3451d9,_0x189d12;Promise['resolve']()[_0x1301('0x16')](function(){if(_0x468e53[_0x1301('0x90')][_0x1301('0x8f')])_0x1972c2=validateChannel(_0x468e53[_0x1301('0x90')][_0x1301('0x8f')]);var _0x3ff8de=_[_0x1301('0x4f')](_0x1972c2)+'Queue';var _0x31b04e=_[_0x1301('0x38')](db[_0x3ff8de][_0x1301('0x94')],function(_0x49650d){return{'name':_0x49650d[_0x1301('0x95')],'type':_0x49650d[_0x1301('0x96')][_0x1301('0x97')]};});_0x56adb8=qs[_0x1301('0xa3')](_0x31b04e,_0x468e53);if(_0x468e53[_0x1301('0x9c')]['role']===_0x1301('0x9c')){var _0x131a9a={'params':{'id':_0x468e53[_0x1301('0x9c')][_0x1301('0xa4')]},'query':{'section':_0x1972c2===_0x1301('0x1c')&&_0x468e53[_0x1301('0x90')][_0x1301('0x96')]===_0x1301('0x3e')?_0x1301('0xa5'):_[_0x1301('0x4f')](_0x1972c2)+_0x1301('0x1d'),'type':_0x468e53[_0x1301('0x90')][_0x1301('0x96')],'nolimit':!![],'sort':_0x1301('0x13'),'filter':_0x468e53[_0x1301('0x90')][_0x1301('0x41')]}};return db['UserProfile'][_0x1301('0x9e')](_0x131a9a);}return db[_0x3ff8de][_0x1301('0x9f')](_0x56adb8);})['then'](function(_0x574339){_0x73018a[_0x1301('0xc')]=_0x574339[_0x1301('0xc')];_0x3c30fc=_0x574339[_0x1301('0xa1')];return getRealtimeQueues(_0x468e53,_0x1972c2);})[_0x1301('0x16')](function(_0x2685c0){_0x3451d9=_0x2685c0[_0x1301('0xa1')];return getRealtimeAgents();})[_0x1301('0x16')](function(_0x45788a){_0x31a90e=_0x45788a[_0x1301('0xa1')];if(_0x1972c2!='voice')return;return getRealtimeVoiceQueueChannels();})[_0x1301('0x16')](function(_0x54a19a){_0x189d12=_0x54a19a?_0x54a19a[_0x1301('0xa1')]:[];return initializeQueues(_0x3c30fc,_0x3451d9,_0x1972c2,_0x468e53['query']['type']);})[_0x1301('0x16')](function(_0x44f546){var _0x44ccaf=_0x44f546[_0x1301('0x38')](function(_0x249d5b){if(_0x1972c2===_0x1301('0x1c'))return getVoiceQueueAgents(_0x249d5b,_0x3c30fc,_0x31a90e,_0x189d12);else return getQueueAgents(_0x249d5b,_0x31a90e,_0x1972c2);});return Promise[_0x1301('0xa6')](_0x44ccaf);})[_0x1301('0x16')](function(_0x50786f){_0x73018a['rows']=_0x50786f;return _0x73018a;})['then'](respondWithFilteredResult(_0x19e6f9,_0x56adb8))[_0x1301('0x1b')](handleError(_0x19e6f9,null));};
\ No newline at end of file