Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / config / socketio.js
index e9bb465..9a83709 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x63e9=['address','connection','remoteAddress','request','connectedAt','SocketIO\x20','nsp','bluebird','../mysqldb','name','telephone','agent','type','ivr','UserProfileSection','findOne','then','autoAssociation','VoiceQueues','ChatQueues','FaxQueues','SmsQueues','MailQueues','OpenchannelQueues','findAll','Telephones','IvrCampaigns','UserProfileResource','resourceId','User','where','role','Campaign','%s:queue:%s','Agents','format','user:%s','handshake','query','find','userProfileId','ChatInteraction','ChatInteractions','MailInteraction','MailInteractions','FaxInteractions','SmsInteraction','OpenchannelInteraction','OpenchannelInteractions','voice:outbound','hasOwnProperty','include','VoiceQueue','push','ChatQueue','FaxQueue','SmsQueue','MailQueue','OpenchannelQueue','user','voice:inbound','Trunks','Trunk','getVoiceQueues','getChatQueues','getFaxQueues','getSmsQueues','getMailQueues','getOpenchannelQueues','length','chat','fax','sms','mail','openchannel','telephone:%s','trunk:%s','campaign:%s:%s','leave','map','removeChatInteractions','emit','user_has_chat_interactions:remove','removeMailInteractions','user_has_mail_interactions:remove','removeFaxInteractions','user_has_fax_interactions:remove','SmsInteractions','removeSmsInteractions','user_has_sms_interactions:remove','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','catch','log','default'];(function(_0x5453c5,_0x344b1d){var _0x4135e4=function(_0x174cd7){while(--_0x174cd7){_0x5453c5['push'](_0x5453c5['shift']());}};_0x4135e4(++_0x344b1d);}(_0x63e9,0x66));var _0x963e=function(_0x580b15,_0x28afa4){_0x580b15=_0x580b15-0x0;var _0x1adb1b=_0x63e9[_0x580b15];return _0x1adb1b;};'use strict';var _=require('lodash');var util=require('util');var BPromise=require(_0x963e('0x0'));var db=require(_0x963e('0x1'))['db'];var config=require('./environment');var queryQueues={'attributes':['id',_0x963e('0x2')],'include':[{'as':'Agents','model':db['User'],'attributes':['id',_0x963e('0x2'),'role'],'raw':!![],'where':{'role':'agent'},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id',_0x963e('0x2')],'where':{'role':_0x963e('0x3')}};var queryTrunks={'raw':!![],'attributes':['id',_0x963e('0x2')]};var queryAgents={'raw':!![],'attributes':['id','name'],'where':{'role':_0x963e('0x4')}};var queryCampaigns={'raw':!![],'attributes':['id','name',_0x963e('0x5')],'where':{'type':_0x963e('0x6')}};function getAssociatedResources(_0x31b79c,_0x374c03,_0x5dc590){return db[_0x963e('0x7')][_0x963e('0x8')]({'where':{'name':_0x31b79c,'userProfileId':_0x374c03},'raw':!![]})[_0x963e('0x9')](function(_0x182751){if(_0x182751){if(_0x182751[_0x963e('0xa')]){switch(_0x31b79c){case _0x963e('0xb'):case _0x963e('0xc'):case _0x963e('0xd'):case _0x963e('0xe'):case _0x963e('0xf'):case _0x963e('0x10'):return db[_0x5dc590][_0x963e('0x11')](queryQueues);case _0x963e('0x12'):return db[_0x5dc590][_0x963e('0x11')](queryTelephones);case'Trunks':return db[_0x5dc590][_0x963e('0x11')](queryTrunks);case _0x963e('0x13'):return db[_0x5dc590]['findAll'](queryCampaigns);}}else{return db[_0x963e('0x14')][_0x963e('0x11')]({'attributes':[_0x963e('0x15')],'where':{'sectionId':_0x182751['id']},'raw':!![]})[_0x963e('0x9')](function(_0x561ffa){if(_0x561ffa){var _0x101f4b={'where':{'id':_['map'](_0x561ffa,_0x963e('0x15'))},'raw':!![]};switch(_0x5dc590){case _0x963e('0x16'):_0x101f4b[_0x963e('0x17')][_0x963e('0x18')]=_0x963e('0x3');break;case _0x963e('0x19'):_0x101f4b[_0x963e('0x17')][_0x963e('0x5')]=_0x963e('0x6');break;}return db[_0x5dc590][_0x963e('0x11')](_0x101f4b);}else{return[];}});}}else{return[];}})[_0x963e('0x9')](function(_0x341502){return _0x341502;});}function joinOrLeaveQueues(_0x2a53af,_0x5d168e,_0x3014ff,_0x32e74a){_0x2a53af[_0x5d168e](util['format'](_0x963e('0x1a'),_0x3014ff,_0x32e74a[_0x963e('0x2')]));if(_0x32e74a[_0x963e('0x1b')]){for(var _0x336e86=0x0;_0x336e86<_0x32e74a[_0x963e('0x1b')]['length'];_0x336e86+=0x1){_0x2a53af[_0x5d168e](util[_0x963e('0x1c')](_0x963e('0x1d'),_0x32e74a[_0x963e('0x1b')][_0x336e86][_0x963e('0x2')]));}}}function joinOrLeave(_0x5a309f,_0x59a2f4,_0x2edbc7){var _0x968c7e;if(_0x5a309f[_0x963e('0x1e')][_0x963e('0x1f')]['id']){db['User'][_0x963e('0x20')]({'attributes':['id',_0x963e('0x2'),'role',_0x963e('0x21')],'where':{'id':_0x5a309f['handshake']['query']['id']},'include':[{'model':db[_0x963e('0x22')],'as':_0x963e('0x23'),'attributes':['id'],'raw':!![]},{'model':db[_0x963e('0x24')],'as':_0x963e('0x25'),'attributes':['id'],'raw':!![]},{'model':db['FaxInteraction'],'as':_0x963e('0x26'),'attributes':['id'],'raw':!![]},{'model':db[_0x963e('0x27')],'as':'SmsInteractions','attributes':['id'],'raw':!![]},{'model':db[_0x963e('0x28')],'as':_0x963e('0x29'),'attributes':['id'],'raw':!![]}]})[_0x963e('0x9')](function(_0x92b79){if(_0x92b79){_0x968c7e=_0x92b79;_0x5a309f[_0x59a2f4](util['format'](_0x963e('0x1d'),_0x92b79['name']));var _0x4ad3dc=[];switch(_0x92b79['role']){case'admin':_0x5a309f[_0x59a2f4]('voice:inbound');_0x5a309f[_0x59a2f4](_0x963e('0x2a'));if(queryQueues[_0x963e('0x2b')](_0x963e('0x2c'))){delete queryQueues[_0x963e('0x2c')];}_0x4ad3dc['push'](db[_0x963e('0x2d')][_0x963e('0x11')](queryQueues));_0x4ad3dc[_0x963e('0x2e')](db[_0x963e('0x2f')][_0x963e('0x11')](queryQueues));_0x4ad3dc['push'](db[_0x963e('0x30')][_0x963e('0x11')](queryQueues));_0x4ad3dc[_0x963e('0x2e')](db[_0x963e('0x31')][_0x963e('0x11')](queryQueues));_0x4ad3dc['push'](db[_0x963e('0x32')][_0x963e('0x11')](queryQueues));_0x4ad3dc[_0x963e('0x2e')](db[_0x963e('0x33')][_0x963e('0x11')](queryQueues));_0x4ad3dc[_0x963e('0x2e')](db[_0x963e('0x16')][_0x963e('0x11')](queryTelephones));_0x4ad3dc[_0x963e('0x2e')](db['Trunk'][_0x963e('0x11')](queryTrunks));_0x4ad3dc[_0x963e('0x2e')](db[_0x963e('0x19')][_0x963e('0x11')](queryCampaigns));_0x4ad3dc[_0x963e('0x2e')](db[_0x963e('0x16')][_0x963e('0x11')](queryAgents));break;case _0x963e('0x34'):_0x5a309f[_0x59a2f4](_0x963e('0x35'));_0x5a309f[_0x59a2f4]('voice:outbound');_0x4ad3dc[_0x963e('0x2e')](getAssociatedResources('VoiceQueues',_0x92b79[_0x963e('0x21')],'VoiceQueue'));_0x4ad3dc[_0x963e('0x2e')](getAssociatedResources('ChatQueues',_0x92b79[_0x963e('0x21')],_0x963e('0x2f')));_0x4ad3dc[_0x963e('0x2e')](getAssociatedResources(_0x963e('0xd'),_0x92b79[_0x963e('0x21')],_0x963e('0x30')));_0x4ad3dc[_0x963e('0x2e')](getAssociatedResources(_0x963e('0xe'),_0x92b79[_0x963e('0x21')],_0x963e('0x31')));_0x4ad3dc[_0x963e('0x2e')](getAssociatedResources(_0x963e('0xf'),_0x92b79[_0x963e('0x21')],'MailQueue'));_0x4ad3dc[_0x963e('0x2e')](getAssociatedResources(_0x963e('0x10'),_0x92b79[_0x963e('0x21')],_0x963e('0x33')));_0x4ad3dc[_0x963e('0x2e')](getAssociatedResources(_0x963e('0x12'),_0x92b79[_0x963e('0x21')],_0x963e('0x16')));_0x4ad3dc[_0x963e('0x2e')](getAssociatedResources(_0x963e('0x36'),_0x92b79[_0x963e('0x21')],_0x963e('0x37')));_0x4ad3dc['push'](getAssociatedResources(_0x963e('0x13'),_0x92b79[_0x963e('0x21')],_0x963e('0x19')));_0x4ad3dc[_0x963e('0x2e')](db[_0x963e('0x16')][_0x963e('0x11')](queryAgents));break;case _0x963e('0x4'):_0x5a309f[_0x59a2f4]('voice:inbound');_0x5a309f[_0x59a2f4](_0x963e('0x2a'));_0x4ad3dc[_0x963e('0x2e')](_0x92b79[_0x963e('0x38')]({'attributes':['id','name']}));_0x4ad3dc[_0x963e('0x2e')](_0x92b79[_0x963e('0x39')]({'attributes':['id',_0x963e('0x2')]}));_0x4ad3dc[_0x963e('0x2e')](_0x92b79[_0x963e('0x3a')]({'attributes':['id',_0x963e('0x2')]}));_0x4ad3dc[_0x963e('0x2e')](_0x92b79[_0x963e('0x3b')]({'attributes':['id',_0x963e('0x2')]}));_0x4ad3dc[_0x963e('0x2e')](_0x92b79[_0x963e('0x3c')]({'attributes':['id',_0x963e('0x2')]}));_0x4ad3dc['push'](_0x92b79[_0x963e('0x3d')]({'attributes':['id',_0x963e('0x2')]}));break;}return BPromise['all'](_0x4ad3dc);}})[_0x963e('0x9')](function(_0x5e609a){if(_0x5e609a&&_0x5e609a[_0x963e('0x3e')]){for(var _0x4175be=0x0;_0x4175be<_0x5e609a[_0x963e('0x3e')];_0x4175be+=0x1){for(var _0x16d4d8=0x0;_0x16d4d8<_0x5e609a[_0x4175be][_0x963e('0x3e')];_0x16d4d8+=0x1){switch(_0x4175be){case 0x0:joinOrLeaveQueues(_0x5a309f,_0x59a2f4,'voice',_0x5e609a[_0x4175be][_0x16d4d8]);break;case 0x1:joinOrLeaveQueues(_0x5a309f,_0x59a2f4,_0x963e('0x3f'),_0x5e609a[_0x4175be][_0x16d4d8]);break;case 0x2:joinOrLeaveQueues(_0x5a309f,_0x59a2f4,_0x963e('0x40'),_0x5e609a[_0x4175be][_0x16d4d8]);break;case 0x3:joinOrLeaveQueues(_0x5a309f,_0x59a2f4,_0x963e('0x41'),_0x5e609a[_0x4175be][_0x16d4d8]);break;case 0x4:joinOrLeaveQueues(_0x5a309f,_0x59a2f4,_0x963e('0x42'),_0x5e609a[_0x4175be][_0x16d4d8]);break;case 0x5:joinOrLeaveQueues(_0x5a309f,_0x59a2f4,_0x963e('0x43'),_0x5e609a[_0x4175be][_0x16d4d8]);break;case 0x6:_0x5a309f[_0x59a2f4](util[_0x963e('0x1c')](_0x963e('0x44'),_0x5e609a[_0x4175be][_0x16d4d8][_0x963e('0x2')]));break;case 0x7:_0x5a309f[_0x59a2f4](util[_0x963e('0x1c')](_0x963e('0x45'),_0x5e609a[_0x4175be][_0x16d4d8][_0x963e('0x2')]));break;case 0x8:_0x5a309f[_0x59a2f4](util[_0x963e('0x1c')](_0x963e('0x46'),_0x5e609a[_0x4175be][_0x16d4d8][_0x963e('0x5')],_0x5e609a[_0x4175be][_0x16d4d8][_0x963e('0x2')]));break;case 0x9:_0x5a309f[_0x59a2f4](util[_0x963e('0x1c')](_0x963e('0x1d'),_0x5e609a[_0x4175be][_0x16d4d8][_0x963e('0x2')]));break;}}}}})[_0x963e('0x9')](function(){if(_0x59a2f4===_0x963e('0x47')){var _0x312ced=_[_0x963e('0x48')](_0x968c7e[_0x963e('0x23')],'id');return _0x968c7e[_0x963e('0x49')](_0x312ced)[_0x963e('0x9')](function(){for(var _0x37c182=0x0;_0x37c182<_0x312ced['length'];_0x37c182+=0x1){_0x2edbc7[_0x963e('0x4a')](_0x963e('0x4b'),{'ChatInteractionId':Number(_0x312ced[_0x37c182]),'UserId':Number(_0x968c7e['id'])});}});}})['then'](function(){if(_0x59a2f4==='leave'){var _0x1fac64=_['map'](_0x968c7e[_0x963e('0x25')],'id');return _0x968c7e[_0x963e('0x4c')](_0x1fac64)[_0x963e('0x9')](function(){for(var _0x4f1daf=0x0;_0x4f1daf<_0x1fac64[_0x963e('0x3e')];_0x4f1daf+=0x1){_0x2edbc7[_0x963e('0x4a')](_0x963e('0x4d'),{'MailInteractionId':Number(_0x1fac64[_0x4f1daf]),'UserId':Number(_0x968c7e['id'])});}});}})['then'](function(){if(_0x59a2f4===_0x963e('0x47')){var _0x43d8f2=_[_0x963e('0x48')](_0x968c7e[_0x963e('0x26')],'id');return _0x968c7e[_0x963e('0x4e')](_0x43d8f2)[_0x963e('0x9')](function(){for(var _0x10dd4d=0x0;_0x10dd4d<_0x43d8f2['length'];_0x10dd4d+=0x1){_0x2edbc7[_0x963e('0x4a')](_0x963e('0x4f'),{'FaxInteractionId':Number(_0x43d8f2[_0x10dd4d]),'UserId':Number(_0x968c7e['id'])});}});}})[_0x963e('0x9')](function(){if(_0x59a2f4===_0x963e('0x47')){var _0x362b57=_[_0x963e('0x48')](_0x968c7e[_0x963e('0x50')],'id');return _0x968c7e[_0x963e('0x51')](_0x362b57)[_0x963e('0x9')](function(){for(var _0x57c15a=0x0;_0x57c15a<_0x362b57[_0x963e('0x3e')];_0x57c15a+=0x1){_0x2edbc7[_0x963e('0x4a')](_0x963e('0x52'),{'SmsInteractionId':Number(_0x362b57[_0x57c15a]),'UserId':Number(_0x968c7e['id'])});}});}})[_0x963e('0x9')](function(){if(_0x59a2f4===_0x963e('0x47')){var _0x4871b6=_[_0x963e('0x48')](_0x968c7e[_0x963e('0x29')],'id');return _0x968c7e[_0x963e('0x53')](_0x4871b6)['then'](function(){for(var _0xfa6f1a=0x0;_0xfa6f1a<_0x4871b6['length'];_0xfa6f1a+=0x1){_0x2edbc7[_0x963e('0x4a')](_0x963e('0x54'),{'OpenchannelInteractionId':Number(_0x4871b6[_0xfa6f1a]),'UserId':Number(_0x968c7e['id'])});}});}})[_0x963e('0x55')](function(_0x2696cf){_0x5a309f[_0x963e('0x56')](_0x2696cf);});}}function onDisconnect(_0x782b6e,_0x38a05a){joinOrLeave(_0x782b6e,'leave',_0x38a05a);}function onConnect(_0x4f047e){joinOrLeave(_0x4f047e,'join');}exports[_0x963e('0x57')]=function(_0x474d55){_0x474d55['on']('connection',function(_0xb70a79){_0xb70a79['setMaxListeners'](0x0);_0xb70a79[_0x963e('0x58')]=_0xb70a79['request'][_0x963e('0x59')][_0x963e('0x5a')]+':'+_0xb70a79[_0x963e('0x5b')]['connection']['remotePort'];_0xb70a79[_0x963e('0x5c')]=new Date();_0xb70a79[_0x963e('0x56')]=function(_0x4c3237){console['log'](_0x963e('0x5d')+_0xb70a79[_0x963e('0x5e')]['name']+'['+_0xb70a79[_0x963e('0x58')]+']',_0x4c3237);};_0xb70a79['on']('disconnect',function(){onDisconnect(_0xb70a79,_0x474d55);_0xb70a79[_0x963e('0x56')]('DISCONNECTED');});onConnect(_0xb70a79);_0xb70a79[_0x963e('0x56')]('CONNECTED');});};
\ No newline at end of file
+var _0x3c8e=['getWhatsappQueues','all','length','chat','fax','mail','openchannel','telephone:%s','campaign:%s:%s','leave','removeChatInteractions','user_has_chat_interactions:remove','MailInteractions','removeMailInteractions','emit','user_has_mail_interactions:remove','FaxInteractions','removeFaxInteractions','removeSmsInteractions','user_has_sms_interactions:remove','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','removeWhatsappInteractions','catch','log','join','default','connection','setMaxListeners','address','remoteAddress','request','remotePort','SocketIO\x20','disconnect','DISCONNECTED','CONNECTED','lodash','util','./environment','name','Agents','role','agent','type','UserProfileSection','findOne','then','autoAssociation','VoiceQueues','ChatQueues','SmsQueues','OpenchannelQueues','Telephones','findAll','Trunks','IvrCampaigns','UserProfileResource','resourceId','map','User','where','Campaign','ivr','format','%s:queue:%s','user:%s','handshake','query','ChatInteractions','MailInteraction','FaxInteraction','SmsInteraction','SmsInteractions','OpenchannelInteraction','OpenchannelInteractions','WhatsappInteraction','WhatsappInteractions','admin','voice:inbound','voice:outbound','hasOwnProperty','include','VoiceQueue','push','ChatQueue','FaxQueue','SmsQueue','MailQueue','WhatsappQueue','Trunk','user','userProfileId','FaxQueues','MailQueues','OpenchannelQueue','getVoiceQueues','getFaxQueues','getMailQueues','getOpenchannelQueues'];(function(_0x24ead6,_0x1520de){var _0x28365d=function(_0x3a6d10){while(--_0x3a6d10){_0x24ead6['push'](_0x24ead6['shift']());}};_0x28365d(++_0x1520de);}(_0x3c8e,0x89));var _0xe3c8=function(_0x323473,_0x395046){_0x323473=_0x323473-0x0;var _0x28c852=_0x3c8e[_0x323473];return _0x28c852;};'use strict';var _=require(_0xe3c8('0x0'));var util=require(_0xe3c8('0x1'));var BPromise=require('bluebird');var db=require('../mysqldb')['db'];var config=require(_0xe3c8('0x2'));var queryQueues={'attributes':['id',_0xe3c8('0x3')],'include':[{'as':_0xe3c8('0x4'),'model':db['User'],'attributes':['id',_0xe3c8('0x3'),_0xe3c8('0x5')],'raw':!![],'where':{'role':_0xe3c8('0x6')},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id',_0xe3c8('0x3')],'where':{'role':'telephone'}};var queryTrunks={'raw':!![],'attributes':['id',_0xe3c8('0x3')]};var queryAgents={'raw':!![],'attributes':['id',_0xe3c8('0x3')],'where':{'role':_0xe3c8('0x6')}};var queryCampaigns={'raw':!![],'attributes':['id',_0xe3c8('0x3'),_0xe3c8('0x7')],'where':{'type':'ivr'}};function getAssociatedResources(_0x21eae5,_0x4812d5,_0x1b6e5e){return db[_0xe3c8('0x8')][_0xe3c8('0x9')]({'where':{'name':_0x21eae5,'userProfileId':_0x4812d5},'raw':!![]})[_0xe3c8('0xa')](function(_0x50e959){if(_0x50e959){if(_0x50e959[_0xe3c8('0xb')]){switch(_0x21eae5){case _0xe3c8('0xc'):case _0xe3c8('0xd'):case'FaxQueues':case _0xe3c8('0xe'):case'MailQueues':case _0xe3c8('0xf'):case'WhatsappQueues':return db[_0x1b6e5e]['findAll'](queryQueues);case _0xe3c8('0x10'):return db[_0x1b6e5e][_0xe3c8('0x11')](queryTelephones);case _0xe3c8('0x12'):return db[_0x1b6e5e]['findAll'](queryTrunks);case _0xe3c8('0x13'):return db[_0x1b6e5e][_0xe3c8('0x11')](queryCampaigns);}}else{return db[_0xe3c8('0x14')][_0xe3c8('0x11')]({'attributes':[_0xe3c8('0x15')],'where':{'sectionId':_0x50e959['id']},'raw':!![]})[_0xe3c8('0xa')](function(_0x4c9604){if(_0x4c9604){var _0x2b7c91={'where':{'id':_[_0xe3c8('0x16')](_0x4c9604,'resourceId')},'raw':!![]};switch(_0x1b6e5e){case _0xe3c8('0x17'):_0x2b7c91[_0xe3c8('0x18')][_0xe3c8('0x5')]='telephone';break;case _0xe3c8('0x19'):_0x2b7c91[_0xe3c8('0x18')][_0xe3c8('0x7')]=_0xe3c8('0x1a');break;}return db[_0x1b6e5e][_0xe3c8('0x11')](_0x2b7c91);}else{return[];}});}}else{return[];}})[_0xe3c8('0xa')](function(_0x349895){return _0x349895;});}function joinOrLeaveQueues(_0x588b6b,_0x2a073d,_0x135b0c,_0x27ee0f){_0x588b6b[_0x2a073d](util[_0xe3c8('0x1b')](_0xe3c8('0x1c'),_0x135b0c,_0x27ee0f[_0xe3c8('0x3')]));if(_0x27ee0f['Agents']){for(var _0x1010a3=0x0;_0x1010a3<_0x27ee0f[_0xe3c8('0x4')]['length'];_0x1010a3+=0x1){_0x588b6b[_0x2a073d](util[_0xe3c8('0x1b')](_0xe3c8('0x1d'),_0x27ee0f['Agents'][_0x1010a3][_0xe3c8('0x3')]));}}}function joinOrLeave(_0x22ea83,_0x5efb85,_0x3b1987){var _0x3f9460;if(_0x22ea83[_0xe3c8('0x1e')][_0xe3c8('0x1f')]['id']){db[_0xe3c8('0x17')]['find']({'attributes':['id',_0xe3c8('0x3'),'role','userProfileId'],'where':{'id':_0x22ea83['handshake'][_0xe3c8('0x1f')]['id']},'include':[{'model':db['ChatInteraction'],'as':_0xe3c8('0x20'),'attributes':['id'],'raw':!![]},{'model':db[_0xe3c8('0x21')],'as':'MailInteractions','attributes':['id'],'raw':!![]},{'model':db[_0xe3c8('0x22')],'as':'FaxInteractions','attributes':['id'],'raw':!![]},{'model':db[_0xe3c8('0x23')],'as':_0xe3c8('0x24'),'attributes':['id'],'raw':!![]},{'model':db[_0xe3c8('0x25')],'as':_0xe3c8('0x26'),'attributes':['id'],'raw':!![]},{'model':db[_0xe3c8('0x27')],'as':_0xe3c8('0x28'),'attributes':['id'],'raw':!![]}]})[_0xe3c8('0xa')](function(_0x497448){if(_0x497448){_0x3f9460=_0x497448;_0x22ea83[_0x5efb85](util['format'](_0xe3c8('0x1d'),_0x497448[_0xe3c8('0x3')]));var _0x40d365=[];switch(_0x497448['role']){case _0xe3c8('0x29'):_0x22ea83[_0x5efb85](_0xe3c8('0x2a'));_0x22ea83[_0x5efb85](_0xe3c8('0x2b'));if(queryQueues[_0xe3c8('0x2c')]('include')){delete queryQueues[_0xe3c8('0x2d')];}_0x40d365['push'](db[_0xe3c8('0x2e')][_0xe3c8('0x11')](queryQueues));_0x40d365[_0xe3c8('0x2f')](db[_0xe3c8('0x30')]['findAll'](queryQueues));_0x40d365[_0xe3c8('0x2f')](db[_0xe3c8('0x31')][_0xe3c8('0x11')](queryQueues));_0x40d365['push'](db[_0xe3c8('0x32')][_0xe3c8('0x11')](queryQueues));_0x40d365[_0xe3c8('0x2f')](db[_0xe3c8('0x33')][_0xe3c8('0x11')](queryQueues));_0x40d365[_0xe3c8('0x2f')](db['OpenchannelQueue'][_0xe3c8('0x11')](queryQueues));_0x40d365['push'](db[_0xe3c8('0x34')][_0xe3c8('0x11')](queryQueues));_0x40d365[_0xe3c8('0x2f')](db[_0xe3c8('0x17')][_0xe3c8('0x11')](queryTelephones));_0x40d365[_0xe3c8('0x2f')](db[_0xe3c8('0x35')][_0xe3c8('0x11')](queryTrunks));_0x40d365['push'](db[_0xe3c8('0x19')]['findAll'](queryCampaigns));_0x40d365['push'](db[_0xe3c8('0x17')][_0xe3c8('0x11')](queryAgents));break;case _0xe3c8('0x36'):_0x22ea83[_0x5efb85](_0xe3c8('0x2a'));_0x22ea83[_0x5efb85]('voice:outbound');_0x40d365[_0xe3c8('0x2f')](getAssociatedResources('VoiceQueues',_0x497448[_0xe3c8('0x37')],_0xe3c8('0x2e')));_0x40d365[_0xe3c8('0x2f')](getAssociatedResources(_0xe3c8('0xd'),_0x497448[_0xe3c8('0x37')],_0xe3c8('0x30')));_0x40d365[_0xe3c8('0x2f')](getAssociatedResources(_0xe3c8('0x38'),_0x497448[_0xe3c8('0x37')],_0xe3c8('0x31')));_0x40d365[_0xe3c8('0x2f')](getAssociatedResources('SmsQueues',_0x497448['userProfileId'],_0xe3c8('0x32')));_0x40d365[_0xe3c8('0x2f')](getAssociatedResources(_0xe3c8('0x39'),_0x497448[_0xe3c8('0x37')],'MailQueue'));_0x40d365[_0xe3c8('0x2f')](getAssociatedResources('OpenchannelQueues',_0x497448[_0xe3c8('0x37')],_0xe3c8('0x3a')));_0x40d365[_0xe3c8('0x2f')](getAssociatedResources('WhatsappQueues',_0x497448[_0xe3c8('0x37')],_0xe3c8('0x34')));_0x40d365[_0xe3c8('0x2f')](getAssociatedResources(_0xe3c8('0x10'),_0x497448[_0xe3c8('0x37')],_0xe3c8('0x17')));_0x40d365[_0xe3c8('0x2f')](getAssociatedResources('Trunks',_0x497448['userProfileId'],_0xe3c8('0x35')));_0x40d365['push'](getAssociatedResources(_0xe3c8('0x13'),_0x497448[_0xe3c8('0x37')],_0xe3c8('0x19')));_0x40d365[_0xe3c8('0x2f')](db[_0xe3c8('0x17')][_0xe3c8('0x11')](queryAgents));break;case'agent':_0x22ea83[_0x5efb85](_0xe3c8('0x2a'));_0x22ea83[_0x5efb85](_0xe3c8('0x2b'));_0x40d365[_0xe3c8('0x2f')](_0x497448[_0xe3c8('0x3b')]({'attributes':['id','name']}));_0x40d365['push'](_0x497448['getChatQueues']({'attributes':['id','name']}));_0x40d365[_0xe3c8('0x2f')](_0x497448[_0xe3c8('0x3c')]({'attributes':['id',_0xe3c8('0x3')]}));_0x40d365['push'](_0x497448['getSmsQueues']({'attributes':['id',_0xe3c8('0x3')]}));_0x40d365[_0xe3c8('0x2f')](_0x497448[_0xe3c8('0x3d')]({'attributes':['id',_0xe3c8('0x3')]}));_0x40d365[_0xe3c8('0x2f')](_0x497448[_0xe3c8('0x3e')]({'attributes':['id',_0xe3c8('0x3')]}));_0x40d365['push'](_0x497448[_0xe3c8('0x3f')]({'attributes':['id',_0xe3c8('0x3')]}));break;}return BPromise[_0xe3c8('0x40')](_0x40d365);}})[_0xe3c8('0xa')](function(_0x1830f8){if(_0x1830f8&&_0x1830f8[_0xe3c8('0x41')]){for(var _0x5ad475=0x0;_0x5ad475<_0x1830f8[_0xe3c8('0x41')];_0x5ad475+=0x1){for(var _0x338dc8=0x0;_0x338dc8<_0x1830f8[_0x5ad475]['length'];_0x338dc8+=0x1){switch(_0x5ad475){case 0x0:joinOrLeaveQueues(_0x22ea83,_0x5efb85,'voice',_0x1830f8[_0x5ad475][_0x338dc8]);break;case 0x1:joinOrLeaveQueues(_0x22ea83,_0x5efb85,_0xe3c8('0x42'),_0x1830f8[_0x5ad475][_0x338dc8]);break;case 0x2:joinOrLeaveQueues(_0x22ea83,_0x5efb85,_0xe3c8('0x43'),_0x1830f8[_0x5ad475][_0x338dc8]);break;case 0x3:joinOrLeaveQueues(_0x22ea83,_0x5efb85,'sms',_0x1830f8[_0x5ad475][_0x338dc8]);break;case 0x4:joinOrLeaveQueues(_0x22ea83,_0x5efb85,_0xe3c8('0x44'),_0x1830f8[_0x5ad475][_0x338dc8]);break;case 0x5:joinOrLeaveQueues(_0x22ea83,_0x5efb85,_0xe3c8('0x45'),_0x1830f8[_0x5ad475][_0x338dc8]);break;case 0x6:joinOrLeaveQueues(_0x22ea83,_0x5efb85,'whatsapp',_0x1830f8[_0x5ad475][_0x338dc8]);break;case 0x7:if(_0x3f9460[_0xe3c8('0x5')]!==_0xe3c8('0x6'))_0x22ea83[_0x5efb85](util[_0xe3c8('0x1b')](_0xe3c8('0x46'),_0x1830f8[_0x5ad475][_0x338dc8][_0xe3c8('0x3')]));break;case 0x8:if(_0x3f9460[_0xe3c8('0x5')]!==_0xe3c8('0x6'))_0x22ea83[_0x5efb85](util['format']('trunk:%s',_0x1830f8[_0x5ad475][_0x338dc8][_0xe3c8('0x3')]));break;case 0x9:if(_0x3f9460[_0xe3c8('0x5')]!==_0xe3c8('0x6'))_0x22ea83[_0x5efb85](util[_0xe3c8('0x1b')](_0xe3c8('0x47'),_0x1830f8[_0x5ad475][_0x338dc8]['type'],_0x1830f8[_0x5ad475][_0x338dc8][_0xe3c8('0x3')]));break;case 0xa:_0x22ea83[_0x5efb85](util[_0xe3c8('0x1b')](_0xe3c8('0x1d'),_0x1830f8[_0x5ad475][_0x338dc8][_0xe3c8('0x3')]));break;}}}}})[_0xe3c8('0xa')](function(){if(_0x5efb85===_0xe3c8('0x48')){var _0x5c5a99=_[_0xe3c8('0x16')](_0x3f9460[_0xe3c8('0x20')],'id');return _0x3f9460[_0xe3c8('0x49')](_0x5c5a99)[_0xe3c8('0xa')](function(){for(var _0x11fd58=0x0;_0x11fd58<_0x5c5a99['length'];_0x11fd58+=0x1){_0x3b1987['emit'](_0xe3c8('0x4a'),{'ChatInteractionId':Number(_0x5c5a99[_0x11fd58]),'UserId':Number(_0x3f9460['id'])});}});}})[_0xe3c8('0xa')](function(){if(_0x5efb85===_0xe3c8('0x48')){var _0x331833=_[_0xe3c8('0x16')](_0x3f9460[_0xe3c8('0x4b')],'id');return _0x3f9460[_0xe3c8('0x4c')](_0x331833)[_0xe3c8('0xa')](function(){for(var _0x462228=0x0;_0x462228<_0x331833['length'];_0x462228+=0x1){_0x3b1987[_0xe3c8('0x4d')](_0xe3c8('0x4e'),{'MailInteractionId':Number(_0x331833[_0x462228]),'UserId':Number(_0x3f9460['id'])});}});}})[_0xe3c8('0xa')](function(){if(_0x5efb85==='leave'){var _0x48dcd6=_['map'](_0x3f9460[_0xe3c8('0x4f')],'id');return _0x3f9460[_0xe3c8('0x50')](_0x48dcd6)['then'](function(){for(var _0xd2d519=0x0;_0xd2d519<_0x48dcd6[_0xe3c8('0x41')];_0xd2d519+=0x1){_0x3b1987['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x48dcd6[_0xd2d519]),'UserId':Number(_0x3f9460['id'])});}});}})['then'](function(){if(_0x5efb85==='leave'){var _0x4d6301=_[_0xe3c8('0x16')](_0x3f9460['SmsInteractions'],'id');return _0x3f9460[_0xe3c8('0x51')](_0x4d6301)[_0xe3c8('0xa')](function(){for(var _0xfca356=0x0;_0xfca356<_0x4d6301[_0xe3c8('0x41')];_0xfca356+=0x1){_0x3b1987[_0xe3c8('0x4d')](_0xe3c8('0x52'),{'SmsInteractionId':Number(_0x4d6301[_0xfca356]),'UserId':Number(_0x3f9460['id'])});}});}})[_0xe3c8('0xa')](function(){if(_0x5efb85==='leave'){var _0xfac7a5=_[_0xe3c8('0x16')](_0x3f9460[_0xe3c8('0x26')],'id');return _0x3f9460[_0xe3c8('0x53')](_0xfac7a5)['then'](function(){for(var _0x1a6783=0x0;_0x1a6783<_0xfac7a5[_0xe3c8('0x41')];_0x1a6783+=0x1){_0x3b1987[_0xe3c8('0x4d')](_0xe3c8('0x54'),{'OpenchannelInteractionId':Number(_0xfac7a5[_0x1a6783]),'UserId':Number(_0x3f9460['id'])});}});}})[_0xe3c8('0xa')](function(){if(_0x5efb85==='leave'){var _0x4b3289=_[_0xe3c8('0x16')](_0x3f9460[_0xe3c8('0x28')],'id');return _0x3f9460[_0xe3c8('0x55')](_0x4b3289)['then'](function(){for(var _0x904e4a=0x0;_0x904e4a<_0x4b3289[_0xe3c8('0x41')];_0x904e4a+=0x1){_0x3b1987[_0xe3c8('0x4d')]('user_has_whatsapp_interactions:remove',{'WhatsappInteractionId':Number(_0x4b3289[_0x904e4a]),'UserId':Number(_0x3f9460['id'])});}});}})[_0xe3c8('0x56')](function(_0x5f58cb){_0x22ea83[_0xe3c8('0x57')](_0x5f58cb);});}}function onDisconnect(_0x227a6e,_0x126072){joinOrLeave(_0x227a6e,_0xe3c8('0x48'),_0x126072);}function onConnect(_0x573c16){joinOrLeave(_0x573c16,_0xe3c8('0x58'));}exports[_0xe3c8('0x59')]=function(_0x476bac){_0x476bac['on'](_0xe3c8('0x5a'),function(_0x1b491e){_0x1b491e[_0xe3c8('0x5b')](0x0);_0x1b491e[_0xe3c8('0x5c')]=_0x1b491e['request'][_0xe3c8('0x5a')][_0xe3c8('0x5d')]+':'+_0x1b491e[_0xe3c8('0x5e')][_0xe3c8('0x5a')][_0xe3c8('0x5f')];_0x1b491e['connectedAt']=new Date();_0x1b491e[_0xe3c8('0x57')]=function(_0x3f5db7){console[_0xe3c8('0x57')](_0xe3c8('0x60')+_0x1b491e['nsp'][_0xe3c8('0x3')]+'['+_0x1b491e[_0xe3c8('0x5c')]+']',_0x3f5db7);};_0x1b491e['on'](_0xe3c8('0x61'),function(){onDisconnect(_0x1b491e,_0x476bac);_0x1b491e[_0xe3c8('0x57')](_0xe3c8('0x62'));});onConnect(_0x1b491e);_0x1b491e[_0xe3c8('0x57')](_0xe3c8('0x63'));});};
\ No newline at end of file