Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / config / socketio.js
index c9b0b7c..e5d1382 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe8bd=['where','Campaign','format','length','user:%s','handshake','query','find','ChatInteractions','MailInteraction','MailInteractions','FaxInteraction','SmsInteraction','OpenchannelInteraction','admin','voice:outbound','hasOwnProperty','include','push','VoiceQueue','ChatQueue','FaxQueue','SmsQueue','user','voice:inbound','userProfileId','MailQueue','OpenchannelQueue','Trunk','getVoiceQueues','getChatQueues','getFaxQueues','getSmsQueues','getMailQueues','getOpenchannelQueues','all','sms','mail','openchannel','trunk:%s','campaign:%s:%s','leave','removeChatInteractions','emit','map','removeMailInteractions','removeFaxInteractions','user_has_fax_interactions:remove','SmsInteractions','user_has_sms_interactions:remove','OpenchannelInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','catch','log','join','default','connection','setMaxListeners','address','request','remotePort','connectedAt','SocketIO\x20','nsp','disconnect','DISCONNECTED','lodash','bluebird','../mysqldb','./environment','name','Agents','User','role','agent','telephone','type','ivr','findOne','then','ChatQueues','FaxQueues','SmsQueues','MailQueues','OpenchannelQueues','findAll','Telephones','Trunks','IvrCampaigns','UserProfileResource','resourceId'];(function(_0x142f78,_0x168833){var _0x338117=function(_0x1d34ab){while(--_0x1d34ab){_0x142f78['push'](_0x142f78['shift']());}};_0x338117(++_0x168833);}(_0xe8bd,0x9f));var _0xde8b=function(_0x2163d0,_0x5d3605){_0x2163d0=_0x2163d0-0x0;var _0x476c03=_0xe8bd[_0x2163d0];return _0x476c03;};'use strict';var _=require(_0xde8b('0x0'));var util=require('util');var BPromise=require(_0xde8b('0x1'));var db=require(_0xde8b('0x2'))['db'];var config=require(_0xde8b('0x3'));var queryQueues={'attributes':['id',_0xde8b('0x4')],'include':[{'as':_0xde8b('0x5'),'model':db[_0xde8b('0x6')],'attributes':['id',_0xde8b('0x4'),_0xde8b('0x7')],'raw':!![],'where':{'role':_0xde8b('0x8')},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id',_0xde8b('0x4')],'where':{'role':_0xde8b('0x9')}};var queryTrunks={'raw':!![],'attributes':['id',_0xde8b('0x4')]};var queryAgents={'raw':!![],'attributes':['id',_0xde8b('0x4')],'where':{'role':_0xde8b('0x8')}};var queryCampaigns={'raw':!![],'attributes':['id',_0xde8b('0x4'),_0xde8b('0xa')],'where':{'type':_0xde8b('0xb')}};function getAssociatedResources(_0x373c75,_0x538768,_0x49477a){return db['UserProfileSection'][_0xde8b('0xc')]({'where':{'name':_0x373c75,'userProfileId':_0x538768},'raw':!![]})[_0xde8b('0xd')](function(_0x55c227){if(_0x55c227){if(_0x55c227['autoAssociation']){switch(_0x373c75){case'VoiceQueues':case _0xde8b('0xe'):case _0xde8b('0xf'):case _0xde8b('0x10'):case _0xde8b('0x11'):case _0xde8b('0x12'):return db[_0x49477a][_0xde8b('0x13')](queryQueues);case _0xde8b('0x14'):return db[_0x49477a]['findAll'](queryTelephones);case _0xde8b('0x15'):return db[_0x49477a][_0xde8b('0x13')](queryTrunks);case _0xde8b('0x16'):return db[_0x49477a][_0xde8b('0x13')](queryCampaigns);}}else{return db[_0xde8b('0x17')][_0xde8b('0x13')]({'attributes':[_0xde8b('0x18')],'where':{'sectionId':_0x55c227['id']},'raw':!![]})[_0xde8b('0xd')](function(_0xd25a08){if(_0xd25a08){var _0x3abf38={'where':{'id':_['map'](_0xd25a08,_0xde8b('0x18'))},'raw':!![]};switch(_0x49477a){case _0xde8b('0x6'):_0x3abf38[_0xde8b('0x19')][_0xde8b('0x7')]=_0xde8b('0x9');break;case _0xde8b('0x1a'):_0x3abf38[_0xde8b('0x19')][_0xde8b('0xa')]=_0xde8b('0xb');break;}return db[_0x49477a]['findAll'](_0x3abf38);}else{return[];}});}}else{return[];}})[_0xde8b('0xd')](function(_0x318922){return _0x318922;});}function joinOrLeaveQueues(_0x222031,_0x59bb3a,_0x1e2ceb,_0x37ebc9){_0x222031[_0x59bb3a](util[_0xde8b('0x1b')]('%s:queue:%s',_0x1e2ceb,_0x37ebc9[_0xde8b('0x4')]));if(_0x37ebc9[_0xde8b('0x5')]){for(var _0x3c157f=0x0;_0x3c157f<_0x37ebc9[_0xde8b('0x5')][_0xde8b('0x1c')];_0x3c157f+=0x1){_0x222031[_0x59bb3a](util['format'](_0xde8b('0x1d'),_0x37ebc9['Agents'][_0x3c157f][_0xde8b('0x4')]));}}}function joinOrLeave(_0x1a1369,_0x187989,_0x429cc2){var _0xe67577;if(_0x1a1369[_0xde8b('0x1e')][_0xde8b('0x1f')]['id']){db[_0xde8b('0x6')][_0xde8b('0x20')]({'attributes':['id',_0xde8b('0x4'),'role','userProfileId'],'where':{'id':_0x1a1369[_0xde8b('0x1e')]['query']['id']},'include':[{'model':db['ChatInteraction'],'as':_0xde8b('0x21'),'attributes':['id'],'raw':!![]},{'model':db[_0xde8b('0x22')],'as':_0xde8b('0x23'),'attributes':['id'],'raw':!![]},{'model':db[_0xde8b('0x24')],'as':'FaxInteractions','attributes':['id'],'raw':!![]},{'model':db[_0xde8b('0x25')],'as':'SmsInteractions','attributes':['id'],'raw':!![]},{'model':db[_0xde8b('0x26')],'as':'OpenchannelInteractions','attributes':['id'],'raw':!![]}]})[_0xde8b('0xd')](function(_0x8ae7b7){if(_0x8ae7b7){_0xe67577=_0x8ae7b7;_0x1a1369[_0x187989](util[_0xde8b('0x1b')](_0xde8b('0x1d'),_0x8ae7b7[_0xde8b('0x4')]));var _0x44752e=[];switch(_0x8ae7b7['role']){case _0xde8b('0x27'):_0x1a1369[_0x187989]('voice:inbound');_0x1a1369[_0x187989](_0xde8b('0x28'));if(queryQueues[_0xde8b('0x29')](_0xde8b('0x2a'))){delete queryQueues[_0xde8b('0x2a')];}_0x44752e[_0xde8b('0x2b')](db[_0xde8b('0x2c')]['findAll'](queryQueues));_0x44752e[_0xde8b('0x2b')](db[_0xde8b('0x2d')][_0xde8b('0x13')](queryQueues));_0x44752e[_0xde8b('0x2b')](db[_0xde8b('0x2e')][_0xde8b('0x13')](queryQueues));_0x44752e[_0xde8b('0x2b')](db[_0xde8b('0x2f')][_0xde8b('0x13')](queryQueues));_0x44752e[_0xde8b('0x2b')](db['MailQueue'][_0xde8b('0x13')](queryQueues));_0x44752e[_0xde8b('0x2b')](db['OpenchannelQueue'][_0xde8b('0x13')](queryQueues));_0x44752e[_0xde8b('0x2b')](db[_0xde8b('0x6')][_0xde8b('0x13')](queryTelephones));_0x44752e[_0xde8b('0x2b')](db['Trunk'][_0xde8b('0x13')](queryTrunks));_0x44752e[_0xde8b('0x2b')](db['Campaign']['findAll'](queryCampaigns));_0x44752e[_0xde8b('0x2b')](db[_0xde8b('0x6')][_0xde8b('0x13')](queryAgents));break;case _0xde8b('0x30'):_0x1a1369[_0x187989](_0xde8b('0x31'));_0x1a1369[_0x187989](_0xde8b('0x28'));_0x44752e[_0xde8b('0x2b')](getAssociatedResources('VoiceQueues',_0x8ae7b7['userProfileId'],_0xde8b('0x2c')));_0x44752e[_0xde8b('0x2b')](getAssociatedResources(_0xde8b('0xe'),_0x8ae7b7[_0xde8b('0x32')],_0xde8b('0x2d')));_0x44752e[_0xde8b('0x2b')](getAssociatedResources('FaxQueues',_0x8ae7b7[_0xde8b('0x32')],_0xde8b('0x2e')));_0x44752e['push'](getAssociatedResources('SmsQueues',_0x8ae7b7['userProfileId'],'SmsQueue'));_0x44752e['push'](getAssociatedResources('MailQueues',_0x8ae7b7[_0xde8b('0x32')],_0xde8b('0x33')));_0x44752e[_0xde8b('0x2b')](getAssociatedResources('OpenchannelQueues',_0x8ae7b7[_0xde8b('0x32')],_0xde8b('0x34')));_0x44752e[_0xde8b('0x2b')](getAssociatedResources(_0xde8b('0x14'),_0x8ae7b7[_0xde8b('0x32')],_0xde8b('0x6')));_0x44752e['push'](getAssociatedResources(_0xde8b('0x15'),_0x8ae7b7[_0xde8b('0x32')],_0xde8b('0x35')));_0x44752e[_0xde8b('0x2b')](getAssociatedResources('IvrCampaigns',_0x8ae7b7[_0xde8b('0x32')],_0xde8b('0x1a')));_0x44752e['push'](db[_0xde8b('0x6')]['findAll'](queryAgents));break;case'agent':_0x1a1369[_0x187989](_0xde8b('0x31'));_0x1a1369[_0x187989](_0xde8b('0x28'));_0x44752e[_0xde8b('0x2b')](_0x8ae7b7[_0xde8b('0x36')]({'attributes':['id',_0xde8b('0x4')]}));_0x44752e['push'](_0x8ae7b7[_0xde8b('0x37')]({'attributes':['id',_0xde8b('0x4')]}));_0x44752e['push'](_0x8ae7b7[_0xde8b('0x38')]({'attributes':['id',_0xde8b('0x4')]}));_0x44752e['push'](_0x8ae7b7[_0xde8b('0x39')]({'attributes':['id',_0xde8b('0x4')]}));_0x44752e[_0xde8b('0x2b')](_0x8ae7b7[_0xde8b('0x3a')]({'attributes':['id',_0xde8b('0x4')]}));_0x44752e[_0xde8b('0x2b')](_0x8ae7b7[_0xde8b('0x3b')]({'attributes':['id',_0xde8b('0x4')]}));break;}return BPromise[_0xde8b('0x3c')](_0x44752e);}})['then'](function(_0x3b56fc){if(_0x3b56fc&&_0x3b56fc['length']){for(var _0x5a018d=0x0;_0x5a018d<_0x3b56fc[_0xde8b('0x1c')];_0x5a018d+=0x1){for(var _0x43776d=0x0;_0x43776d<_0x3b56fc[_0x5a018d]['length'];_0x43776d+=0x1){switch(_0x5a018d){case 0x0:joinOrLeaveQueues(_0x1a1369,_0x187989,'voice',_0x3b56fc[_0x5a018d][_0x43776d]);break;case 0x1:joinOrLeaveQueues(_0x1a1369,_0x187989,'chat',_0x3b56fc[_0x5a018d][_0x43776d]);break;case 0x2:joinOrLeaveQueues(_0x1a1369,_0x187989,'fax',_0x3b56fc[_0x5a018d][_0x43776d]);break;case 0x3:joinOrLeaveQueues(_0x1a1369,_0x187989,_0xde8b('0x3d'),_0x3b56fc[_0x5a018d][_0x43776d]);break;case 0x4:joinOrLeaveQueues(_0x1a1369,_0x187989,_0xde8b('0x3e'),_0x3b56fc[_0x5a018d][_0x43776d]);break;case 0x5:joinOrLeaveQueues(_0x1a1369,_0x187989,_0xde8b('0x3f'),_0x3b56fc[_0x5a018d][_0x43776d]);break;case 0x6:_0x1a1369[_0x187989](util[_0xde8b('0x1b')]('telephone:%s',_0x3b56fc[_0x5a018d][_0x43776d]['name']));break;case 0x7:_0x1a1369[_0x187989](util[_0xde8b('0x1b')](_0xde8b('0x40'),_0x3b56fc[_0x5a018d][_0x43776d]['name']));break;case 0x8:_0x1a1369[_0x187989](util['format'](_0xde8b('0x41'),_0x3b56fc[_0x5a018d][_0x43776d][_0xde8b('0xa')],_0x3b56fc[_0x5a018d][_0x43776d][_0xde8b('0x4')]));break;case 0x9:_0x1a1369[_0x187989](util['format']('user:%s',_0x3b56fc[_0x5a018d][_0x43776d][_0xde8b('0x4')]));break;}}}}})[_0xde8b('0xd')](function(){if(_0x187989===_0xde8b('0x42')){var _0x49dee6=_['map'](_0xe67577[_0xde8b('0x21')],'id');return _0xe67577[_0xde8b('0x43')](_0x49dee6)['then'](function(){for(var _0x305da1=0x0;_0x305da1<_0x49dee6[_0xde8b('0x1c')];_0x305da1+=0x1){_0x429cc2[_0xde8b('0x44')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x49dee6[_0x305da1]),'UserId':Number(_0xe67577['id'])});}});}})[_0xde8b('0xd')](function(){if(_0x187989==='leave'){var _0x2eccbf=_[_0xde8b('0x45')](_0xe67577['MailInteractions'],'id');return _0xe67577[_0xde8b('0x46')](_0x2eccbf)[_0xde8b('0xd')](function(){for(var _0x5bb42b=0x0;_0x5bb42b<_0x2eccbf[_0xde8b('0x1c')];_0x5bb42b+=0x1){_0x429cc2[_0xde8b('0x44')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x2eccbf[_0x5bb42b]),'UserId':Number(_0xe67577['id'])});}});}})[_0xde8b('0xd')](function(){if(_0x187989===_0xde8b('0x42')){var _0x807506=_['map'](_0xe67577['FaxInteractions'],'id');return _0xe67577[_0xde8b('0x47')](_0x807506)['then'](function(){for(var _0x8c5adb=0x0;_0x8c5adb<_0x807506['length'];_0x8c5adb+=0x1){_0x429cc2[_0xde8b('0x44')](_0xde8b('0x48'),{'FaxInteractionId':Number(_0x807506[_0x8c5adb]),'UserId':Number(_0xe67577['id'])});}});}})[_0xde8b('0xd')](function(){if(_0x187989===_0xde8b('0x42')){var _0x239fb1=_['map'](_0xe67577[_0xde8b('0x49')],'id');return _0xe67577['removeSmsInteractions'](_0x239fb1)['then'](function(){for(var _0x3b2678=0x0;_0x3b2678<_0x239fb1['length'];_0x3b2678+=0x1){_0x429cc2[_0xde8b('0x44')](_0xde8b('0x4a'),{'SmsInteractionId':Number(_0x239fb1[_0x3b2678]),'UserId':Number(_0xe67577['id'])});}});}})[_0xde8b('0xd')](function(){if(_0x187989===_0xde8b('0x42')){var _0x30d1f6=_['map'](_0xe67577[_0xde8b('0x4b')],'id');return _0xe67577[_0xde8b('0x4c')](_0x30d1f6)[_0xde8b('0xd')](function(){for(var _0x160a0f=0x0;_0x160a0f<_0x30d1f6[_0xde8b('0x1c')];_0x160a0f+=0x1){_0x429cc2[_0xde8b('0x44')](_0xde8b('0x4d'),{'OpenchannelInteractionId':Number(_0x30d1f6[_0x160a0f]),'UserId':Number(_0xe67577['id'])});}});}})[_0xde8b('0x4e')](function(_0x55cc91){_0x1a1369[_0xde8b('0x4f')](_0x55cc91);});}}function onDisconnect(_0x4322dc,_0xb51724){joinOrLeave(_0x4322dc,_0xde8b('0x42'),_0xb51724);}function onConnect(_0x3d590a){joinOrLeave(_0x3d590a,_0xde8b('0x50'));}exports[_0xde8b('0x51')]=function(_0x5d0462){_0x5d0462['on'](_0xde8b('0x52'),function(_0x122d1d){_0x122d1d[_0xde8b('0x53')](0x0);_0x122d1d[_0xde8b('0x54')]=_0x122d1d[_0xde8b('0x55')]['connection']['remoteAddress']+':'+_0x122d1d[_0xde8b('0x55')][_0xde8b('0x52')][_0xde8b('0x56')];_0x122d1d[_0xde8b('0x57')]=new Date();_0x122d1d[_0xde8b('0x4f')]=function(_0x56718a){console[_0xde8b('0x4f')](_0xde8b('0x58')+_0x122d1d[_0xde8b('0x59')]['name']+'['+_0x122d1d[_0xde8b('0x54')]+']',_0x56718a);};_0x122d1d['on'](_0xde8b('0x5a'),function(){onDisconnect(_0x122d1d,_0x5d0462);_0x122d1d[_0xde8b('0x4f')](_0xde8b('0x5b'));});onConnect(_0x122d1d);_0x122d1d[_0xde8b('0x4f')]('CONNECTED');});};
\ No newline at end of file
+var _0x5fdb=['ChatQueue','FaxQueues','MailQueue','IvrCampaigns','getVoiceQueues','getChatQueues','getSmsQueues','getMailQueues','all','chat','sms','mail','whatsapp','telephone:%s','trunk:%s','campaign:%s:%s','leave','ChatInteractions','removeChatInteractions','emit','user_has_chat_interactions:remove','removeMailInteractions','removeFaxInteractions','user_has_fax_interactions:remove','SmsInteractions','removeSmsInteractions','user_has_sms_interactions:remove','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','user_has_whatsapp_interactions:remove','log','join','default','connection','setMaxListeners','request','remoteAddress','remotePort','connectedAt','SocketIO\x20','nsp','address','disconnect','DISCONNECTED','lodash','bluebird','../mysqldb','name','Agents','User','role','agent','telephone','type','findOne','autoAssociation','VoiceQueues','ChatQueues','SmsQueues','MailQueues','OpenchannelQueues','WhatsappQueues','findAll','Telephones','Trunks','UserProfileResource','resourceId','map','where','then','format','%s:queue:%s','length','user:%s','query','find','userProfileId','MailInteractions','FaxInteraction','FaxInteractions','SmsInteraction','OpenchannelInteraction','OpenchannelInteractions','WhatsappInteractions','voice:inbound','voice:outbound','hasOwnProperty','include','push','VoiceQueue','FaxQueue','SmsQueue','OpenchannelQueue','WhatsappQueue','Trunk','Campaign','user'];(function(_0x3129fc,_0x58b191){var _0x4af3d7=function(_0x11c915){while(--_0x11c915){_0x3129fc['push'](_0x3129fc['shift']());}};_0x4af3d7(++_0x58b191);}(_0x5fdb,0x1b0));var _0xb5fd=function(_0x1283df,_0xe39897){_0x1283df=_0x1283df-0x0;var _0x3d299b=_0x5fdb[_0x1283df];return _0x3d299b;};'use strict';var _=require(_0xb5fd('0x0'));var util=require('util');var BPromise=require(_0xb5fd('0x1'));var db=require(_0xb5fd('0x2'))['db'];var config=require('./environment');var queryQueues={'attributes':['id',_0xb5fd('0x3')],'include':[{'as':_0xb5fd('0x4'),'model':db[_0xb5fd('0x5')],'attributes':['id',_0xb5fd('0x3'),_0xb5fd('0x6')],'raw':!![],'where':{'role':_0xb5fd('0x7')},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id','name'],'where':{'role':_0xb5fd('0x8')}};var queryTrunks={'raw':!![],'attributes':['id','name']};var queryAgents={'raw':!![],'attributes':['id',_0xb5fd('0x3')],'where':{'role':_0xb5fd('0x7')}};var queryCampaigns={'raw':!![],'attributes':['id',_0xb5fd('0x3'),_0xb5fd('0x9')],'where':{'type':'ivr'}};function getAssociatedResources(_0x2a352a,_0x5d9f9f,_0x47d97f){return db['UserProfileSection'][_0xb5fd('0xa')]({'where':{'name':_0x2a352a,'userProfileId':_0x5d9f9f},'raw':!![]})['then'](function(_0x3022b){if(_0x3022b){if(_0x3022b[_0xb5fd('0xb')]){switch(_0x2a352a){case _0xb5fd('0xc'):case _0xb5fd('0xd'):case'FaxQueues':case _0xb5fd('0xe'):case _0xb5fd('0xf'):case _0xb5fd('0x10'):case _0xb5fd('0x11'):return db[_0x47d97f][_0xb5fd('0x12')](queryQueues);case _0xb5fd('0x13'):return db[_0x47d97f]['findAll'](queryTelephones);case _0xb5fd('0x14'):return db[_0x47d97f][_0xb5fd('0x12')](queryTrunks);case'IvrCampaigns':return db[_0x47d97f]['findAll'](queryCampaigns);}}else{return db[_0xb5fd('0x15')][_0xb5fd('0x12')]({'attributes':[_0xb5fd('0x16')],'where':{'sectionId':_0x3022b['id']},'raw':!![]})['then'](function(_0x34d24f){if(_0x34d24f){var _0x324038={'where':{'id':_[_0xb5fd('0x17')](_0x34d24f,_0xb5fd('0x16'))},'raw':!![]};switch(_0x47d97f){case _0xb5fd('0x5'):_0x324038['where'][_0xb5fd('0x6')]='telephone';break;case'Campaign':_0x324038[_0xb5fd('0x18')][_0xb5fd('0x9')]='ivr';break;}return db[_0x47d97f][_0xb5fd('0x12')](_0x324038);}else{return[];}});}}else{return[];}})[_0xb5fd('0x19')](function(_0x1f8465){return _0x1f8465;});}function joinOrLeaveQueues(_0x32cd5c,_0x597bd7,_0xc518e4,_0x402778){_0x32cd5c[_0x597bd7](util[_0xb5fd('0x1a')](_0xb5fd('0x1b'),_0xc518e4,_0x402778[_0xb5fd('0x3')]));if(_0x402778['Agents']){for(var _0x4d4e92=0x0;_0x4d4e92<_0x402778[_0xb5fd('0x4')][_0xb5fd('0x1c')];_0x4d4e92+=0x1){_0x32cd5c[_0x597bd7](util[_0xb5fd('0x1a')](_0xb5fd('0x1d'),_0x402778[_0xb5fd('0x4')][_0x4d4e92][_0xb5fd('0x3')]));}}}function joinOrLeave(_0x56f31b,_0x229a6d,_0x32edd6){var _0x2ffd43;if(_0x56f31b['handshake'][_0xb5fd('0x1e')]['id']){db[_0xb5fd('0x5')][_0xb5fd('0x1f')]({'attributes':['id',_0xb5fd('0x3'),'role',_0xb5fd('0x20')],'where':{'id':_0x56f31b['handshake']['query']['id']},'include':[{'model':db['ChatInteraction'],'as':'ChatInteractions','attributes':['id'],'raw':!![]},{'model':db['MailInteraction'],'as':_0xb5fd('0x21'),'attributes':['id'],'raw':!![]},{'model':db[_0xb5fd('0x22')],'as':_0xb5fd('0x23'),'attributes':['id'],'raw':!![]},{'model':db[_0xb5fd('0x24')],'as':'SmsInteractions','attributes':['id'],'raw':!![]},{'model':db[_0xb5fd('0x25')],'as':_0xb5fd('0x26'),'attributes':['id'],'raw':!![]},{'model':db['WhatsappInteraction'],'as':_0xb5fd('0x27'),'attributes':['id'],'raw':!![]}]})['then'](function(_0x515ad9){if(_0x515ad9){_0x2ffd43=_0x515ad9;_0x56f31b[_0x229a6d](util[_0xb5fd('0x1a')](_0xb5fd('0x1d'),_0x515ad9[_0xb5fd('0x3')]));var _0x2d7202=[];switch(_0x515ad9[_0xb5fd('0x6')]){case'admin':_0x56f31b[_0x229a6d](_0xb5fd('0x28'));_0x56f31b[_0x229a6d](_0xb5fd('0x29'));if(queryQueues[_0xb5fd('0x2a')](_0xb5fd('0x2b'))){delete queryQueues[_0xb5fd('0x2b')];}_0x2d7202[_0xb5fd('0x2c')](db[_0xb5fd('0x2d')][_0xb5fd('0x12')](queryQueues));_0x2d7202[_0xb5fd('0x2c')](db['ChatQueue'][_0xb5fd('0x12')](queryQueues));_0x2d7202['push'](db[_0xb5fd('0x2e')]['findAll'](queryQueues));_0x2d7202['push'](db[_0xb5fd('0x2f')][_0xb5fd('0x12')](queryQueues));_0x2d7202['push'](db['MailQueue'][_0xb5fd('0x12')](queryQueues));_0x2d7202[_0xb5fd('0x2c')](db[_0xb5fd('0x30')][_0xb5fd('0x12')](queryQueues));_0x2d7202[_0xb5fd('0x2c')](db[_0xb5fd('0x31')][_0xb5fd('0x12')](queryQueues));_0x2d7202['push'](db['User']['findAll'](queryTelephones));_0x2d7202[_0xb5fd('0x2c')](db[_0xb5fd('0x32')][_0xb5fd('0x12')](queryTrunks));_0x2d7202[_0xb5fd('0x2c')](db[_0xb5fd('0x33')][_0xb5fd('0x12')](queryCampaigns));_0x2d7202[_0xb5fd('0x2c')](db[_0xb5fd('0x5')]['findAll'](queryAgents));break;case _0xb5fd('0x34'):_0x56f31b[_0x229a6d](_0xb5fd('0x28'));_0x56f31b[_0x229a6d]('voice:outbound');_0x2d7202['push'](getAssociatedResources(_0xb5fd('0xc'),_0x515ad9[_0xb5fd('0x20')],_0xb5fd('0x2d')));_0x2d7202['push'](getAssociatedResources('ChatQueues',_0x515ad9[_0xb5fd('0x20')],_0xb5fd('0x35')));_0x2d7202[_0xb5fd('0x2c')](getAssociatedResources(_0xb5fd('0x36'),_0x515ad9[_0xb5fd('0x20')],'FaxQueue'));_0x2d7202[_0xb5fd('0x2c')](getAssociatedResources('SmsQueues',_0x515ad9['userProfileId'],_0xb5fd('0x2f')));_0x2d7202[_0xb5fd('0x2c')](getAssociatedResources(_0xb5fd('0xf'),_0x515ad9[_0xb5fd('0x20')],_0xb5fd('0x37')));_0x2d7202[_0xb5fd('0x2c')](getAssociatedResources(_0xb5fd('0x10'),_0x515ad9[_0xb5fd('0x20')],_0xb5fd('0x30')));_0x2d7202[_0xb5fd('0x2c')](getAssociatedResources(_0xb5fd('0x11'),_0x515ad9[_0xb5fd('0x20')],_0xb5fd('0x31')));_0x2d7202[_0xb5fd('0x2c')](getAssociatedResources(_0xb5fd('0x13'),_0x515ad9[_0xb5fd('0x20')],_0xb5fd('0x5')));_0x2d7202[_0xb5fd('0x2c')](getAssociatedResources(_0xb5fd('0x14'),_0x515ad9[_0xb5fd('0x20')],_0xb5fd('0x32')));_0x2d7202['push'](getAssociatedResources(_0xb5fd('0x38'),_0x515ad9[_0xb5fd('0x20')],'Campaign'));_0x2d7202[_0xb5fd('0x2c')](db['User']['findAll'](queryAgents));break;case _0xb5fd('0x7'):_0x56f31b[_0x229a6d]('voice:inbound');_0x56f31b[_0x229a6d](_0xb5fd('0x29'));_0x2d7202[_0xb5fd('0x2c')](_0x515ad9[_0xb5fd('0x39')]({'attributes':['id',_0xb5fd('0x3')]}));_0x2d7202['push'](_0x515ad9[_0xb5fd('0x3a')]({'attributes':['id',_0xb5fd('0x3')]}));_0x2d7202[_0xb5fd('0x2c')](_0x515ad9['getFaxQueues']({'attributes':['id','name']}));_0x2d7202[_0xb5fd('0x2c')](_0x515ad9[_0xb5fd('0x3b')]({'attributes':['id',_0xb5fd('0x3')]}));_0x2d7202[_0xb5fd('0x2c')](_0x515ad9[_0xb5fd('0x3c')]({'attributes':['id',_0xb5fd('0x3')]}));_0x2d7202[_0xb5fd('0x2c')](_0x515ad9['getOpenchannelQueues']({'attributes':['id',_0xb5fd('0x3')]}));_0x2d7202['push'](_0x515ad9['getWhatsappQueues']({'attributes':['id','name']}));break;}return BPromise[_0xb5fd('0x3d')](_0x2d7202);}})[_0xb5fd('0x19')](function(_0x33a175){if(_0x33a175&&_0x33a175[_0xb5fd('0x1c')]){for(var _0x5bdebb=0x0;_0x5bdebb<_0x33a175[_0xb5fd('0x1c')];_0x5bdebb+=0x1){for(var _0x4ab4a1=0x0;_0x4ab4a1<_0x33a175[_0x5bdebb]['length'];_0x4ab4a1+=0x1){switch(_0x5bdebb){case 0x0:joinOrLeaveQueues(_0x56f31b,_0x229a6d,'voice',_0x33a175[_0x5bdebb][_0x4ab4a1]);break;case 0x1:joinOrLeaveQueues(_0x56f31b,_0x229a6d,_0xb5fd('0x3e'),_0x33a175[_0x5bdebb][_0x4ab4a1]);break;case 0x2:joinOrLeaveQueues(_0x56f31b,_0x229a6d,'fax',_0x33a175[_0x5bdebb][_0x4ab4a1]);break;case 0x3:joinOrLeaveQueues(_0x56f31b,_0x229a6d,_0xb5fd('0x3f'),_0x33a175[_0x5bdebb][_0x4ab4a1]);break;case 0x4:joinOrLeaveQueues(_0x56f31b,_0x229a6d,_0xb5fd('0x40'),_0x33a175[_0x5bdebb][_0x4ab4a1]);break;case 0x5:joinOrLeaveQueues(_0x56f31b,_0x229a6d,'openchannel',_0x33a175[_0x5bdebb][_0x4ab4a1]);break;case 0x6:joinOrLeaveQueues(_0x56f31b,_0x229a6d,_0xb5fd('0x41'),_0x33a175[_0x5bdebb][_0x4ab4a1]);break;case 0x7:if(_0x2ffd43[_0xb5fd('0x6')]!=='agent')_0x56f31b[_0x229a6d](util['format'](_0xb5fd('0x42'),_0x33a175[_0x5bdebb][_0x4ab4a1]['name']));break;case 0x8:if(_0x2ffd43[_0xb5fd('0x6')]!==_0xb5fd('0x7'))_0x56f31b[_0x229a6d](util['format'](_0xb5fd('0x43'),_0x33a175[_0x5bdebb][_0x4ab4a1][_0xb5fd('0x3')]));break;case 0x9:if(_0x2ffd43[_0xb5fd('0x6')]!==_0xb5fd('0x7'))_0x56f31b[_0x229a6d](util[_0xb5fd('0x1a')](_0xb5fd('0x44'),_0x33a175[_0x5bdebb][_0x4ab4a1][_0xb5fd('0x9')],_0x33a175[_0x5bdebb][_0x4ab4a1][_0xb5fd('0x3')]));break;case 0xa:_0x56f31b[_0x229a6d](util[_0xb5fd('0x1a')](_0xb5fd('0x1d'),_0x33a175[_0x5bdebb][_0x4ab4a1][_0xb5fd('0x3')]));break;}}}}})[_0xb5fd('0x19')](function(){if(_0x229a6d===_0xb5fd('0x45')){var _0x5f5064=_['map'](_0x2ffd43[_0xb5fd('0x46')],'id');return _0x2ffd43[_0xb5fd('0x47')](_0x5f5064)[_0xb5fd('0x19')](function(){for(var _0x28c8c8=0x0;_0x28c8c8<_0x5f5064[_0xb5fd('0x1c')];_0x28c8c8+=0x1){_0x32edd6[_0xb5fd('0x48')](_0xb5fd('0x49'),{'ChatInteractionId':Number(_0x5f5064[_0x28c8c8]),'UserId':Number(_0x2ffd43['id'])});}});}})['then'](function(){if(_0x229a6d==='leave'){var _0x555a96=_[_0xb5fd('0x17')](_0x2ffd43['MailInteractions'],'id');return _0x2ffd43[_0xb5fd('0x4a')](_0x555a96)[_0xb5fd('0x19')](function(){for(var _0x1f6d64=0x0;_0x1f6d64<_0x555a96[_0xb5fd('0x1c')];_0x1f6d64+=0x1){_0x32edd6[_0xb5fd('0x48')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x555a96[_0x1f6d64]),'UserId':Number(_0x2ffd43['id'])});}});}})[_0xb5fd('0x19')](function(){if(_0x229a6d===_0xb5fd('0x45')){var _0x3ade5e=_[_0xb5fd('0x17')](_0x2ffd43['FaxInteractions'],'id');return _0x2ffd43[_0xb5fd('0x4b')](_0x3ade5e)[_0xb5fd('0x19')](function(){for(var _0x3894b2=0x0;_0x3894b2<_0x3ade5e['length'];_0x3894b2+=0x1){_0x32edd6[_0xb5fd('0x48')](_0xb5fd('0x4c'),{'FaxInteractionId':Number(_0x3ade5e[_0x3894b2]),'UserId':Number(_0x2ffd43['id'])});}});}})[_0xb5fd('0x19')](function(){if(_0x229a6d==='leave'){var _0x32b85c=_[_0xb5fd('0x17')](_0x2ffd43[_0xb5fd('0x4d')],'id');return _0x2ffd43[_0xb5fd('0x4e')](_0x32b85c)['then'](function(){for(var _0x3bb214=0x0;_0x3bb214<_0x32b85c['length'];_0x3bb214+=0x1){_0x32edd6[_0xb5fd('0x48')](_0xb5fd('0x4f'),{'SmsInteractionId':Number(_0x32b85c[_0x3bb214]),'UserId':Number(_0x2ffd43['id'])});}});}})[_0xb5fd('0x19')](function(){if(_0x229a6d===_0xb5fd('0x45')){var _0xd50617=_[_0xb5fd('0x17')](_0x2ffd43[_0xb5fd('0x26')],'id');return _0x2ffd43[_0xb5fd('0x50')](_0xd50617)[_0xb5fd('0x19')](function(){for(var _0x131645=0x0;_0x131645<_0xd50617[_0xb5fd('0x1c')];_0x131645+=0x1){_0x32edd6[_0xb5fd('0x48')](_0xb5fd('0x51'),{'OpenchannelInteractionId':Number(_0xd50617[_0x131645]),'UserId':Number(_0x2ffd43['id'])});}});}})[_0xb5fd('0x19')](function(){if(_0x229a6d==='leave'){var _0x2e9869=_[_0xb5fd('0x17')](_0x2ffd43[_0xb5fd('0x27')],'id');return _0x2ffd43['removeWhatsappInteractions'](_0x2e9869)[_0xb5fd('0x19')](function(){for(var _0x4d9c11=0x0;_0x4d9c11<_0x2e9869[_0xb5fd('0x1c')];_0x4d9c11+=0x1){_0x32edd6['emit'](_0xb5fd('0x52'),{'WhatsappInteractionId':Number(_0x2e9869[_0x4d9c11]),'UserId':Number(_0x2ffd43['id'])});}});}})['catch'](function(_0x4b64c8){_0x56f31b[_0xb5fd('0x53')](_0x4b64c8);});}}function onDisconnect(_0x845f48,_0x5a28b1){joinOrLeave(_0x845f48,_0xb5fd('0x45'),_0x5a28b1);}function onConnect(_0x5b661c){joinOrLeave(_0x5b661c,_0xb5fd('0x54'));}exports[_0xb5fd('0x55')]=function(_0xe9853a){_0xe9853a['on'](_0xb5fd('0x56'),function(_0x4ff072){_0x4ff072[_0xb5fd('0x57')](0x0);_0x4ff072['address']=_0x4ff072[_0xb5fd('0x58')][_0xb5fd('0x56')][_0xb5fd('0x59')]+':'+_0x4ff072[_0xb5fd('0x58')][_0xb5fd('0x56')][_0xb5fd('0x5a')];_0x4ff072[_0xb5fd('0x5b')]=new Date();_0x4ff072[_0xb5fd('0x53')]=function(_0x5e00ab){console[_0xb5fd('0x53')](_0xb5fd('0x5c')+_0x4ff072[_0xb5fd('0x5d')][_0xb5fd('0x3')]+'['+_0x4ff072[_0xb5fd('0x5e')]+']',_0x5e00ab);};_0x4ff072['on'](_0xb5fd('0x5f'),function(){onDisconnect(_0x4ff072,_0xe9853a);_0x4ff072[_0xb5fd('0x53')](_0xb5fd('0x60'));});onConnect(_0x4ff072);_0x4ff072[_0xb5fd('0x53')]('CONNECTED');});};
\ No newline at end of file