Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / config / socketio.js
index 57e831f..d6f1dfd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1113=['Trunks','UserProfileResource','resourceId','where','%s:queue:%s','length','format','user:%s','handshake','query','userProfileId','ChatInteraction','ChatInteractions','MailInteraction','MailInteractions','FaxInteractions','SmsInteraction','SmsInteractions','OpenchannelInteractions','WhatsappInteraction','admin','voice:outbound','include','VoiceQueue','push','ChatQueue','FaxQueue','SmsQueue','MailQueue','OpenchannelQueue','WhatsappQueue','Trunk','Campaign','voice:inbound','WhatsappQueues','IvrCampaigns','getVoiceQueues','getChatQueues','getFaxQueues','getSmsQueues','getMailQueues','getOpenchannelQueues','all','voice','chat','fax','openchannel','whatsapp','campaign:%s:%s','map','user_has_chat_interactions:remove','leave','removeMailInteractions','emit','user_has_mail_interactions:remove','removeFaxInteractions','user_has_fax_interactions:remove','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','WhatsappInteractions','removeWhatsappInteractions','user_has_whatsapp_interactions:remove','log','join','default','connection','setMaxListeners','address','request','remotePort','connectedAt','SocketIO\x20','nsp','disconnect','DISCONNECTED','CONNECTED','util','bluebird','../mysqldb','Agents','User','name','role','agent','type','ivr','UserProfileSection','findOne','then','autoAssociation','VoiceQueues','ChatQueues','FaxQueues','SmsQueues','OpenchannelQueues','findAll','Telephones'];(function(_0x5f5b74,_0x575f37){var _0x45f1fd=function(_0x503ce0){while(--_0x503ce0){_0x5f5b74['push'](_0x5f5b74['shift']());}};_0x45f1fd(++_0x575f37);}(_0x1113,0x16f));var _0x3111=function(_0x11bd81,_0x11fa4c){_0x11bd81=_0x11bd81-0x0;var _0x158de0=_0x1113[_0x11bd81];return _0x158de0;};'use strict';var _=require('lodash');var util=require(_0x3111('0x0'));var BPromise=require(_0x3111('0x1'));var db=require(_0x3111('0x2'))['db'];var config=require('./environment');var queryQueues={'attributes':['id','name'],'include':[{'as':_0x3111('0x3'),'model':db[_0x3111('0x4')],'attributes':['id',_0x3111('0x5'),_0x3111('0x6')],'raw':!![],'where':{'role':_0x3111('0x7')},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id',_0x3111('0x5')],'where':{'role':'telephone'}};var queryTrunks={'raw':!![],'attributes':['id',_0x3111('0x5')]};var queryAgents={'raw':!![],'attributes':['id',_0x3111('0x5')],'where':{'role':_0x3111('0x7')}};var queryCampaigns={'raw':!![],'attributes':['id',_0x3111('0x5'),_0x3111('0x8')],'where':{'type':_0x3111('0x9')}};function getAssociatedResources(_0x4ad8df,_0x5639a1,_0x250ed7){return db[_0x3111('0xa')][_0x3111('0xb')]({'where':{'name':_0x4ad8df,'userProfileId':_0x5639a1},'raw':!![]})[_0x3111('0xc')](function(_0x50d909){if(_0x50d909){if(_0x50d909[_0x3111('0xd')]){switch(_0x4ad8df){case _0x3111('0xe'):case _0x3111('0xf'):case _0x3111('0x10'):case _0x3111('0x11'):case'MailQueues':case _0x3111('0x12'):case'WhatsappQueues':return db[_0x250ed7][_0x3111('0x13')](queryQueues);case _0x3111('0x14'):return db[_0x250ed7][_0x3111('0x13')](queryTelephones);case _0x3111('0x15'):return db[_0x250ed7][_0x3111('0x13')](queryTrunks);case'IvrCampaigns':return db[_0x250ed7][_0x3111('0x13')](queryCampaigns);}}else{return db[_0x3111('0x16')][_0x3111('0x13')]({'attributes':[_0x3111('0x17')],'where':{'sectionId':_0x50d909['id']},'raw':!![]})[_0x3111('0xc')](function(_0x3bab1f){if(_0x3bab1f){var _0x341fbd={'where':{'id':_['map'](_0x3bab1f,_0x3111('0x17'))},'raw':!![]};switch(_0x250ed7){case _0x3111('0x4'):_0x341fbd[_0x3111('0x18')][_0x3111('0x6')]='telephone';break;case'Campaign':_0x341fbd[_0x3111('0x18')]['type']=_0x3111('0x9');break;}return db[_0x250ed7][_0x3111('0x13')](_0x341fbd);}else{return[];}});}}else{return[];}})['then'](function(_0x453e6a){return _0x453e6a;});}function joinOrLeaveQueues(_0x3030fb,_0x3dd324,_0x43f2ac,_0x734894){_0x3030fb[_0x3dd324](util['format'](_0x3111('0x19'),_0x43f2ac,_0x734894[_0x3111('0x5')]));if(_0x734894[_0x3111('0x3')]){for(var _0x5a5177=0x0;_0x5a5177<_0x734894['Agents'][_0x3111('0x1a')];_0x5a5177+=0x1){_0x3030fb[_0x3dd324](util[_0x3111('0x1b')](_0x3111('0x1c'),_0x734894[_0x3111('0x3')][_0x5a5177][_0x3111('0x5')]));}}}function joinOrLeave(_0x33fadd,_0x1deaf3,_0x5a8f9d){var _0x5266ab;if(_0x33fadd[_0x3111('0x1d')][_0x3111('0x1e')]['id']){db[_0x3111('0x4')]['find']({'attributes':['id','name',_0x3111('0x6'),_0x3111('0x1f')],'where':{'id':_0x33fadd[_0x3111('0x1d')]['query']['id']},'include':[{'model':db[_0x3111('0x20')],'as':_0x3111('0x21'),'attributes':['id'],'raw':!![]},{'model':db[_0x3111('0x22')],'as':_0x3111('0x23'),'attributes':['id'],'raw':!![]},{'model':db['FaxInteraction'],'as':_0x3111('0x24'),'attributes':['id'],'raw':!![]},{'model':db[_0x3111('0x25')],'as':_0x3111('0x26'),'attributes':['id'],'raw':!![]},{'model':db['OpenchannelInteraction'],'as':_0x3111('0x27'),'attributes':['id'],'raw':!![]},{'model':db[_0x3111('0x28')],'as':'WhatsappInteractions','attributes':['id'],'raw':!![]}]})[_0x3111('0xc')](function(_0x1c2c25){if(_0x1c2c25){_0x5266ab=_0x1c2c25;_0x33fadd[_0x1deaf3](util['format']('user:%s',_0x1c2c25[_0x3111('0x5')]));var _0x3a92e8=[];switch(_0x1c2c25[_0x3111('0x6')]){case _0x3111('0x29'):_0x33fadd[_0x1deaf3]('voice:inbound');_0x33fadd[_0x1deaf3](_0x3111('0x2a'));if(queryQueues['hasOwnProperty'](_0x3111('0x2b'))){delete queryQueues[_0x3111('0x2b')];}_0x3a92e8['push'](db[_0x3111('0x2c')][_0x3111('0x13')](queryQueues));_0x3a92e8[_0x3111('0x2d')](db[_0x3111('0x2e')][_0x3111('0x13')](queryQueues));_0x3a92e8['push'](db[_0x3111('0x2f')][_0x3111('0x13')](queryQueues));_0x3a92e8['push'](db[_0x3111('0x30')][_0x3111('0x13')](queryQueues));_0x3a92e8['push'](db[_0x3111('0x31')][_0x3111('0x13')](queryQueues));_0x3a92e8[_0x3111('0x2d')](db[_0x3111('0x32')][_0x3111('0x13')](queryQueues));_0x3a92e8[_0x3111('0x2d')](db[_0x3111('0x33')][_0x3111('0x13')](queryQueues));_0x3a92e8[_0x3111('0x2d')](db[_0x3111('0x4')]['findAll'](queryTelephones));_0x3a92e8[_0x3111('0x2d')](db[_0x3111('0x34')]['findAll'](queryTrunks));_0x3a92e8[_0x3111('0x2d')](db[_0x3111('0x35')][_0x3111('0x13')](queryCampaigns));_0x3a92e8[_0x3111('0x2d')](db['User'][_0x3111('0x13')](queryAgents));break;case'user':_0x33fadd[_0x1deaf3](_0x3111('0x36'));_0x33fadd[_0x1deaf3](_0x3111('0x2a'));_0x3a92e8['push'](getAssociatedResources(_0x3111('0xe'),_0x1c2c25[_0x3111('0x1f')],_0x3111('0x2c')));_0x3a92e8[_0x3111('0x2d')](getAssociatedResources(_0x3111('0xf'),_0x1c2c25[_0x3111('0x1f')],_0x3111('0x2e')));_0x3a92e8[_0x3111('0x2d')](getAssociatedResources(_0x3111('0x10'),_0x1c2c25['userProfileId'],_0x3111('0x2f')));_0x3a92e8['push'](getAssociatedResources(_0x3111('0x11'),_0x1c2c25[_0x3111('0x1f')],_0x3111('0x30')));_0x3a92e8[_0x3111('0x2d')](getAssociatedResources('MailQueues',_0x1c2c25[_0x3111('0x1f')],_0x3111('0x31')));_0x3a92e8[_0x3111('0x2d')](getAssociatedResources(_0x3111('0x12'),_0x1c2c25[_0x3111('0x1f')],_0x3111('0x32')));_0x3a92e8['push'](getAssociatedResources(_0x3111('0x37'),_0x1c2c25[_0x3111('0x1f')],_0x3111('0x33')));_0x3a92e8[_0x3111('0x2d')](getAssociatedResources(_0x3111('0x14'),_0x1c2c25['userProfileId'],_0x3111('0x4')));_0x3a92e8[_0x3111('0x2d')](getAssociatedResources(_0x3111('0x15'),_0x1c2c25[_0x3111('0x1f')],'Trunk'));_0x3a92e8['push'](getAssociatedResources(_0x3111('0x38'),_0x1c2c25[_0x3111('0x1f')],'Campaign'));_0x3a92e8[_0x3111('0x2d')](db[_0x3111('0x4')][_0x3111('0x13')](queryAgents));break;case _0x3111('0x7'):_0x33fadd[_0x1deaf3](_0x3111('0x36'));_0x33fadd[_0x1deaf3](_0x3111('0x2a'));_0x3a92e8[_0x3111('0x2d')](_0x1c2c25[_0x3111('0x39')]({'attributes':['id',_0x3111('0x5')]}));_0x3a92e8[_0x3111('0x2d')](_0x1c2c25[_0x3111('0x3a')]({'attributes':['id',_0x3111('0x5')]}));_0x3a92e8[_0x3111('0x2d')](_0x1c2c25[_0x3111('0x3b')]({'attributes':['id',_0x3111('0x5')]}));_0x3a92e8[_0x3111('0x2d')](_0x1c2c25[_0x3111('0x3c')]({'attributes':['id','name']}));_0x3a92e8[_0x3111('0x2d')](_0x1c2c25[_0x3111('0x3d')]({'attributes':['id',_0x3111('0x5')]}));_0x3a92e8[_0x3111('0x2d')](_0x1c2c25[_0x3111('0x3e')]({'attributes':['id',_0x3111('0x5')]}));_0x3a92e8[_0x3111('0x2d')](_0x1c2c25['getWhatsappQueues']({'attributes':['id','name']}));break;}return BPromise[_0x3111('0x3f')](_0x3a92e8);}})[_0x3111('0xc')](function(_0x227105){if(_0x227105&&_0x227105[_0x3111('0x1a')]){for(var _0xc7fee4=0x0;_0xc7fee4<_0x227105[_0x3111('0x1a')];_0xc7fee4+=0x1){for(var _0x5306b6=0x0;_0x5306b6<_0x227105[_0xc7fee4][_0x3111('0x1a')];_0x5306b6+=0x1){switch(_0xc7fee4){case 0x0:joinOrLeaveQueues(_0x33fadd,_0x1deaf3,_0x3111('0x40'),_0x227105[_0xc7fee4][_0x5306b6]);break;case 0x1:joinOrLeaveQueues(_0x33fadd,_0x1deaf3,_0x3111('0x41'),_0x227105[_0xc7fee4][_0x5306b6]);break;case 0x2:joinOrLeaveQueues(_0x33fadd,_0x1deaf3,_0x3111('0x42'),_0x227105[_0xc7fee4][_0x5306b6]);break;case 0x3:joinOrLeaveQueues(_0x33fadd,_0x1deaf3,'sms',_0x227105[_0xc7fee4][_0x5306b6]);break;case 0x4:joinOrLeaveQueues(_0x33fadd,_0x1deaf3,'mail',_0x227105[_0xc7fee4][_0x5306b6]);break;case 0x5:joinOrLeaveQueues(_0x33fadd,_0x1deaf3,_0x3111('0x43'),_0x227105[_0xc7fee4][_0x5306b6]);break;case 0x6:joinOrLeaveQueues(_0x33fadd,_0x1deaf3,_0x3111('0x44'),_0x227105[_0xc7fee4][_0x5306b6]);break;case 0x7:_0x33fadd[_0x1deaf3](util[_0x3111('0x1b')]('telephone:%s',_0x227105[_0xc7fee4][_0x5306b6][_0x3111('0x5')]));break;case 0x8:_0x33fadd[_0x1deaf3](util[_0x3111('0x1b')]('trunk:%s',_0x227105[_0xc7fee4][_0x5306b6][_0x3111('0x5')]));break;case 0x9:_0x33fadd[_0x1deaf3](util[_0x3111('0x1b')](_0x3111('0x45'),_0x227105[_0xc7fee4][_0x5306b6]['type'],_0x227105[_0xc7fee4][_0x5306b6]['name']));break;case 0xa:_0x33fadd[_0x1deaf3](util[_0x3111('0x1b')](_0x3111('0x1c'),_0x227105[_0xc7fee4][_0x5306b6][_0x3111('0x5')]));break;}}}}})[_0x3111('0xc')](function(){if(_0x1deaf3==='leave'){var _0x1d925c=_[_0x3111('0x46')](_0x5266ab[_0x3111('0x21')],'id');return _0x5266ab['removeChatInteractions'](_0x1d925c)['then'](function(){for(var _0x53fa31=0x0;_0x53fa31<_0x1d925c[_0x3111('0x1a')];_0x53fa31+=0x1){_0x5a8f9d['emit'](_0x3111('0x47'),{'ChatInteractionId':Number(_0x1d925c[_0x53fa31]),'UserId':Number(_0x5266ab['id'])});}});}})['then'](function(){if(_0x1deaf3===_0x3111('0x48')){var _0x396394=_[_0x3111('0x46')](_0x5266ab[_0x3111('0x23')],'id');return _0x5266ab[_0x3111('0x49')](_0x396394)[_0x3111('0xc')](function(){for(var _0x1b04c1=0x0;_0x1b04c1<_0x396394[_0x3111('0x1a')];_0x1b04c1+=0x1){_0x5a8f9d[_0x3111('0x4a')](_0x3111('0x4b'),{'MailInteractionId':Number(_0x396394[_0x1b04c1]),'UserId':Number(_0x5266ab['id'])});}});}})[_0x3111('0xc')](function(){if(_0x1deaf3==='leave'){var _0x4efb9e=_[_0x3111('0x46')](_0x5266ab[_0x3111('0x24')],'id');return _0x5266ab[_0x3111('0x4c')](_0x4efb9e)[_0x3111('0xc')](function(){for(var _0x52b275=0x0;_0x52b275<_0x4efb9e['length'];_0x52b275+=0x1){_0x5a8f9d[_0x3111('0x4a')](_0x3111('0x4d'),{'FaxInteractionId':Number(_0x4efb9e[_0x52b275]),'UserId':Number(_0x5266ab['id'])});}});}})[_0x3111('0xc')](function(){if(_0x1deaf3===_0x3111('0x48')){var _0x285292=_[_0x3111('0x46')](_0x5266ab[_0x3111('0x26')],'id');return _0x5266ab['removeSmsInteractions'](_0x285292)[_0x3111('0xc')](function(){for(var _0x729e4f=0x0;_0x729e4f<_0x285292['length'];_0x729e4f+=0x1){_0x5a8f9d[_0x3111('0x4a')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x285292[_0x729e4f]),'UserId':Number(_0x5266ab['id'])});}});}})[_0x3111('0xc')](function(){if(_0x1deaf3==='leave'){var _0x29c015=_['map'](_0x5266ab['OpenchannelInteractions'],'id');return _0x5266ab[_0x3111('0x4e')](_0x29c015)[_0x3111('0xc')](function(){for(var _0x33642e=0x0;_0x33642e<_0x29c015[_0x3111('0x1a')];_0x33642e+=0x1){_0x5a8f9d['emit'](_0x3111('0x4f'),{'OpenchannelInteractionId':Number(_0x29c015[_0x33642e]),'UserId':Number(_0x5266ab['id'])});}});}})['then'](function(){if(_0x1deaf3===_0x3111('0x48')){var _0x13b322=_[_0x3111('0x46')](_0x5266ab[_0x3111('0x50')],'id');return _0x5266ab[_0x3111('0x51')](_0x13b322)[_0x3111('0xc')](function(){for(var _0x1f4e83=0x0;_0x1f4e83<_0x13b322['length'];_0x1f4e83+=0x1){_0x5a8f9d['emit'](_0x3111('0x52'),{'WhatsappInteractionId':Number(_0x13b322[_0x1f4e83]),'UserId':Number(_0x5266ab['id'])});}});}})['catch'](function(_0x3d3c14){_0x33fadd[_0x3111('0x53')](_0x3d3c14);});}}function onDisconnect(_0x353b44,_0x43d873){joinOrLeave(_0x353b44,_0x3111('0x48'),_0x43d873);}function onConnect(_0x156861){joinOrLeave(_0x156861,_0x3111('0x54'));}exports[_0x3111('0x55')]=function(_0x5de978){_0x5de978['on'](_0x3111('0x56'),function(_0x24ccb2){_0x24ccb2[_0x3111('0x57')](0x0);_0x24ccb2[_0x3111('0x58')]=_0x24ccb2[_0x3111('0x59')][_0x3111('0x56')]['remoteAddress']+':'+_0x24ccb2['request'][_0x3111('0x56')][_0x3111('0x5a')];_0x24ccb2[_0x3111('0x5b')]=new Date();_0x24ccb2['log']=function(_0x28cc81){console[_0x3111('0x53')](_0x3111('0x5c')+_0x24ccb2[_0x3111('0x5d')][_0x3111('0x5')]+'['+_0x24ccb2[_0x3111('0x58')]+']',_0x28cc81);};_0x24ccb2['on'](_0x3111('0x5e'),function(){onDisconnect(_0x24ccb2,_0x5de978);_0x24ccb2[_0x3111('0x53')](_0x3111('0x5f'));});onConnect(_0x24ccb2);_0x24ccb2[_0x3111('0x53')](_0x3111('0x60'));});};
\ No newline at end of file
+var _0x3157=['removeFaxInteractions','user_has_fax_interactions:remove','removeOpenchannelInteractions','removeWhatsappInteractions','user_has_whatsapp_interactions:remove','catch','join','default','connection','setMaxListeners','remoteAddress','request','remotePort','log','SocketIO\x20','nsp','address','disconnect','DISCONNECTED','CONNECTED','lodash','util','bluebird','../mysqldb','name','User','telephone','agent','ivr','findOne','then','autoAssociation','ChatQueues','FaxQueues','SmsQueues','MailQueues','WhatsappQueues','findAll','Telephones','Trunks','UserProfileResource','map','resourceId','where','role','%s:queue:%s','Agents','length','format','handshake','query','ChatInteraction','ChatInteractions','MailInteraction','MailInteractions','FaxInteraction','SmsInteraction','SmsInteractions','OpenchannelInteraction','OpenchannelInteractions','WhatsappInteraction','user:%s','admin','voice:outbound','hasOwnProperty','include','VoiceQueue','push','ChatQueue','FaxQueue','OpenchannelQueue','WhatsappQueue','Campaign','user','VoiceQueues','userProfileId','SmsQueue','OpenchannelQueues','IvrCampaigns','getChatQueues','getFaxQueues','getMailQueues','getOpenchannelQueues','getWhatsappQueues','voice','chat','fax','sms','openchannel','whatsapp','telephone:%s','trunk:%s','campaign:%s:%s','leave','removeChatInteractions','emit','FaxInteractions'];(function(_0x38b2d9,_0x19fd42){var _0x23a3e1=function(_0xd8192f){while(--_0xd8192f){_0x38b2d9['push'](_0x38b2d9['shift']());}};_0x23a3e1(++_0x19fd42);}(_0x3157,0x198));var _0x7315=function(_0x55054c,_0x23fcfa){_0x55054c=_0x55054c-0x0;var _0x32c2ed=_0x3157[_0x55054c];return _0x32c2ed;};'use strict';var _=require(_0x7315('0x0'));var util=require(_0x7315('0x1'));var BPromise=require(_0x7315('0x2'));var db=require(_0x7315('0x3'))['db'];var config=require('./environment');var queryQueues={'attributes':['id',_0x7315('0x4')],'include':[{'as':'Agents','model':db[_0x7315('0x5')],'attributes':['id',_0x7315('0x4'),'role'],'raw':!![],'where':{'role':'agent'},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id',_0x7315('0x4')],'where':{'role':_0x7315('0x6')}};var queryTrunks={'raw':!![],'attributes':['id',_0x7315('0x4')]};var queryAgents={'raw':!![],'attributes':['id','name'],'where':{'role':_0x7315('0x7')}};var queryCampaigns={'raw':!![],'attributes':['id',_0x7315('0x4'),'type'],'where':{'type':_0x7315('0x8')}};function getAssociatedResources(_0x2f8dda,_0x1cad8b,_0x1b6416){return db['UserProfileSection'][_0x7315('0x9')]({'where':{'name':_0x2f8dda,'userProfileId':_0x1cad8b},'raw':!![]})[_0x7315('0xa')](function(_0x22e958){if(_0x22e958){if(_0x22e958[_0x7315('0xb')]){switch(_0x2f8dda){case'VoiceQueues':case _0x7315('0xc'):case _0x7315('0xd'):case _0x7315('0xe'):case _0x7315('0xf'):case'OpenchannelQueues':case _0x7315('0x10'):return db[_0x1b6416][_0x7315('0x11')](queryQueues);case _0x7315('0x12'):return db[_0x1b6416][_0x7315('0x11')](queryTelephones);case _0x7315('0x13'):return db[_0x1b6416][_0x7315('0x11')](queryTrunks);case'IvrCampaigns':return db[_0x1b6416]['findAll'](queryCampaigns);}}else{return db[_0x7315('0x14')][_0x7315('0x11')]({'attributes':['resourceId'],'where':{'sectionId':_0x22e958['id']},'raw':!![]})[_0x7315('0xa')](function(_0x25ff8a){if(_0x25ff8a){var _0xd77567={'where':{'id':_[_0x7315('0x15')](_0x25ff8a,_0x7315('0x16'))},'raw':!![]};switch(_0x1b6416){case _0x7315('0x5'):_0xd77567[_0x7315('0x17')][_0x7315('0x18')]=_0x7315('0x6');break;case'Campaign':_0xd77567[_0x7315('0x17')]['type']=_0x7315('0x8');break;}return db[_0x1b6416]['findAll'](_0xd77567);}else{return[];}});}}else{return[];}})[_0x7315('0xa')](function(_0x2848ca){return _0x2848ca;});}function joinOrLeaveQueues(_0xa98946,_0x397f39,_0x145fb4,_0x351914){_0xa98946[_0x397f39](util['format'](_0x7315('0x19'),_0x145fb4,_0x351914['name']));if(_0x351914[_0x7315('0x1a')]){for(var _0x223002=0x0;_0x223002<_0x351914[_0x7315('0x1a')][_0x7315('0x1b')];_0x223002+=0x1){_0xa98946[_0x397f39](util[_0x7315('0x1c')]('user:%s',_0x351914[_0x7315('0x1a')][_0x223002]['name']));}}}function joinOrLeave(_0x1a7eb0,_0x77dbbc,_0x16b24f){var _0x3d1a8a;if(_0x1a7eb0[_0x7315('0x1d')][_0x7315('0x1e')]['id']){db[_0x7315('0x5')]['find']({'attributes':['id',_0x7315('0x4'),_0x7315('0x18'),'userProfileId'],'where':{'id':_0x1a7eb0[_0x7315('0x1d')]['query']['id']},'include':[{'model':db[_0x7315('0x1f')],'as':_0x7315('0x20'),'attributes':['id'],'raw':!![]},{'model':db[_0x7315('0x21')],'as':_0x7315('0x22'),'attributes':['id'],'raw':!![]},{'model':db[_0x7315('0x23')],'as':'FaxInteractions','attributes':['id'],'raw':!![]},{'model':db[_0x7315('0x24')],'as':_0x7315('0x25'),'attributes':['id'],'raw':!![]},{'model':db[_0x7315('0x26')],'as':_0x7315('0x27'),'attributes':['id'],'raw':!![]},{'model':db[_0x7315('0x28')],'as':'WhatsappInteractions','attributes':['id'],'raw':!![]}]})[_0x7315('0xa')](function(_0x537a83){if(_0x537a83){_0x3d1a8a=_0x537a83;_0x1a7eb0[_0x77dbbc](util[_0x7315('0x1c')](_0x7315('0x29'),_0x537a83[_0x7315('0x4')]));var _0x26cbba=[];switch(_0x537a83['role']){case _0x7315('0x2a'):_0x1a7eb0[_0x77dbbc]('voice:inbound');_0x1a7eb0[_0x77dbbc](_0x7315('0x2b'));if(queryQueues[_0x7315('0x2c')](_0x7315('0x2d'))){delete queryQueues[_0x7315('0x2d')];}_0x26cbba['push'](db[_0x7315('0x2e')][_0x7315('0x11')](queryQueues));_0x26cbba[_0x7315('0x2f')](db[_0x7315('0x30')][_0x7315('0x11')](queryQueues));_0x26cbba[_0x7315('0x2f')](db[_0x7315('0x31')][_0x7315('0x11')](queryQueues));_0x26cbba[_0x7315('0x2f')](db['SmsQueue'][_0x7315('0x11')](queryQueues));_0x26cbba['push'](db['MailQueue'][_0x7315('0x11')](queryQueues));_0x26cbba['push'](db[_0x7315('0x32')][_0x7315('0x11')](queryQueues));_0x26cbba[_0x7315('0x2f')](db[_0x7315('0x33')][_0x7315('0x11')](queryQueues));_0x26cbba[_0x7315('0x2f')](db[_0x7315('0x5')][_0x7315('0x11')](queryTelephones));_0x26cbba[_0x7315('0x2f')](db['Trunk']['findAll'](queryTrunks));_0x26cbba[_0x7315('0x2f')](db[_0x7315('0x34')][_0x7315('0x11')](queryCampaigns));_0x26cbba[_0x7315('0x2f')](db[_0x7315('0x5')]['findAll'](queryAgents));break;case _0x7315('0x35'):_0x1a7eb0[_0x77dbbc]('voice:inbound');_0x1a7eb0[_0x77dbbc](_0x7315('0x2b'));_0x26cbba[_0x7315('0x2f')](getAssociatedResources(_0x7315('0x36'),_0x537a83[_0x7315('0x37')],_0x7315('0x2e')));_0x26cbba[_0x7315('0x2f')](getAssociatedResources(_0x7315('0xc'),_0x537a83['userProfileId'],_0x7315('0x30')));_0x26cbba[_0x7315('0x2f')](getAssociatedResources(_0x7315('0xd'),_0x537a83[_0x7315('0x37')],_0x7315('0x31')));_0x26cbba[_0x7315('0x2f')](getAssociatedResources('SmsQueues',_0x537a83[_0x7315('0x37')],_0x7315('0x38')));_0x26cbba['push'](getAssociatedResources(_0x7315('0xf'),_0x537a83['userProfileId'],'MailQueue'));_0x26cbba[_0x7315('0x2f')](getAssociatedResources(_0x7315('0x39'),_0x537a83[_0x7315('0x37')],_0x7315('0x32')));_0x26cbba[_0x7315('0x2f')](getAssociatedResources('WhatsappQueues',_0x537a83[_0x7315('0x37')],'WhatsappQueue'));_0x26cbba[_0x7315('0x2f')](getAssociatedResources(_0x7315('0x12'),_0x537a83[_0x7315('0x37')],'User'));_0x26cbba['push'](getAssociatedResources(_0x7315('0x13'),_0x537a83[_0x7315('0x37')],'Trunk'));_0x26cbba[_0x7315('0x2f')](getAssociatedResources(_0x7315('0x3a'),_0x537a83['userProfileId'],_0x7315('0x34')));_0x26cbba[_0x7315('0x2f')](db[_0x7315('0x5')][_0x7315('0x11')](queryAgents));break;case _0x7315('0x7'):_0x1a7eb0[_0x77dbbc]('voice:inbound');_0x1a7eb0[_0x77dbbc](_0x7315('0x2b'));_0x26cbba[_0x7315('0x2f')](_0x537a83['getVoiceQueues']({'attributes':['id',_0x7315('0x4')]}));_0x26cbba['push'](_0x537a83[_0x7315('0x3b')]({'attributes':['id',_0x7315('0x4')]}));_0x26cbba['push'](_0x537a83[_0x7315('0x3c')]({'attributes':['id','name']}));_0x26cbba[_0x7315('0x2f')](_0x537a83['getSmsQueues']({'attributes':['id',_0x7315('0x4')]}));_0x26cbba[_0x7315('0x2f')](_0x537a83[_0x7315('0x3d')]({'attributes':['id',_0x7315('0x4')]}));_0x26cbba['push'](_0x537a83[_0x7315('0x3e')]({'attributes':['id',_0x7315('0x4')]}));_0x26cbba[_0x7315('0x2f')](_0x537a83[_0x7315('0x3f')]({'attributes':['id',_0x7315('0x4')]}));break;}return BPromise['all'](_0x26cbba);}})['then'](function(_0xc9ec1){if(_0xc9ec1&&_0xc9ec1[_0x7315('0x1b')]){for(var _0x135202=0x0;_0x135202<_0xc9ec1[_0x7315('0x1b')];_0x135202+=0x1){for(var _0x51310c=0x0;_0x51310c<_0xc9ec1[_0x135202][_0x7315('0x1b')];_0x51310c+=0x1){switch(_0x135202){case 0x0:joinOrLeaveQueues(_0x1a7eb0,_0x77dbbc,_0x7315('0x40'),_0xc9ec1[_0x135202][_0x51310c]);break;case 0x1:joinOrLeaveQueues(_0x1a7eb0,_0x77dbbc,_0x7315('0x41'),_0xc9ec1[_0x135202][_0x51310c]);break;case 0x2:joinOrLeaveQueues(_0x1a7eb0,_0x77dbbc,_0x7315('0x42'),_0xc9ec1[_0x135202][_0x51310c]);break;case 0x3:joinOrLeaveQueues(_0x1a7eb0,_0x77dbbc,_0x7315('0x43'),_0xc9ec1[_0x135202][_0x51310c]);break;case 0x4:joinOrLeaveQueues(_0x1a7eb0,_0x77dbbc,'mail',_0xc9ec1[_0x135202][_0x51310c]);break;case 0x5:joinOrLeaveQueues(_0x1a7eb0,_0x77dbbc,_0x7315('0x44'),_0xc9ec1[_0x135202][_0x51310c]);break;case 0x6:joinOrLeaveQueues(_0x1a7eb0,_0x77dbbc,_0x7315('0x45'),_0xc9ec1[_0x135202][_0x51310c]);break;case 0x7:if(_0x3d1a8a[_0x7315('0x18')]!=='agent')_0x1a7eb0[_0x77dbbc](util[_0x7315('0x1c')](_0x7315('0x46'),_0xc9ec1[_0x135202][_0x51310c][_0x7315('0x4')]));break;case 0x8:if(_0x3d1a8a['role']!==_0x7315('0x7'))_0x1a7eb0[_0x77dbbc](util[_0x7315('0x1c')](_0x7315('0x47'),_0xc9ec1[_0x135202][_0x51310c][_0x7315('0x4')]));break;case 0x9:if(_0x3d1a8a[_0x7315('0x18')]!=='agent')_0x1a7eb0[_0x77dbbc](util['format'](_0x7315('0x48'),_0xc9ec1[_0x135202][_0x51310c]['type'],_0xc9ec1[_0x135202][_0x51310c]['name']));break;case 0xa:_0x1a7eb0[_0x77dbbc](util[_0x7315('0x1c')]('user:%s',_0xc9ec1[_0x135202][_0x51310c][_0x7315('0x4')]));break;}}}}})[_0x7315('0xa')](function(){if(_0x77dbbc===_0x7315('0x49')){var _0x1fd54d=_[_0x7315('0x15')](_0x3d1a8a[_0x7315('0x20')],'id');return _0x3d1a8a[_0x7315('0x4a')](_0x1fd54d)[_0x7315('0xa')](function(){for(var _0x3e7eed=0x0;_0x3e7eed<_0x1fd54d['length'];_0x3e7eed+=0x1){_0x16b24f[_0x7315('0x4b')]('user_has_chat_interactions:remove',{'ChatInteractionId':Number(_0x1fd54d[_0x3e7eed]),'UserId':Number(_0x3d1a8a['id'])});}});}})[_0x7315('0xa')](function(){if(_0x77dbbc===_0x7315('0x49')){var _0x57fd73=_['map'](_0x3d1a8a[_0x7315('0x22')],'id');return _0x3d1a8a['removeMailInteractions'](_0x57fd73)[_0x7315('0xa')](function(){for(var _0x517a09=0x0;_0x517a09<_0x57fd73[_0x7315('0x1b')];_0x517a09+=0x1){_0x16b24f[_0x7315('0x4b')]('user_has_mail_interactions:remove',{'MailInteractionId':Number(_0x57fd73[_0x517a09]),'UserId':Number(_0x3d1a8a['id'])});}});}})[_0x7315('0xa')](function(){if(_0x77dbbc===_0x7315('0x49')){var _0x1bfe0f=_[_0x7315('0x15')](_0x3d1a8a[_0x7315('0x4c')],'id');return _0x3d1a8a[_0x7315('0x4d')](_0x1bfe0f)[_0x7315('0xa')](function(){for(var _0x114c92=0x0;_0x114c92<_0x1bfe0f[_0x7315('0x1b')];_0x114c92+=0x1){_0x16b24f['emit'](_0x7315('0x4e'),{'FaxInteractionId':Number(_0x1bfe0f[_0x114c92]),'UserId':Number(_0x3d1a8a['id'])});}});}})[_0x7315('0xa')](function(){if(_0x77dbbc===_0x7315('0x49')){var _0x565791=_[_0x7315('0x15')](_0x3d1a8a['SmsInteractions'],'id');return _0x3d1a8a['removeSmsInteractions'](_0x565791)[_0x7315('0xa')](function(){for(var _0x3a3e33=0x0;_0x3a3e33<_0x565791['length'];_0x3a3e33+=0x1){_0x16b24f['emit']('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x565791[_0x3a3e33]),'UserId':Number(_0x3d1a8a['id'])});}});}})[_0x7315('0xa')](function(){if(_0x77dbbc===_0x7315('0x49')){var _0x24cf56=_[_0x7315('0x15')](_0x3d1a8a['OpenchannelInteractions'],'id');return _0x3d1a8a[_0x7315('0x4f')](_0x24cf56)[_0x7315('0xa')](function(){for(var _0xdfeb03=0x0;_0xdfeb03<_0x24cf56[_0x7315('0x1b')];_0xdfeb03+=0x1){_0x16b24f[_0x7315('0x4b')]('user_has_openchannel_interactions:remove',{'OpenchannelInteractionId':Number(_0x24cf56[_0xdfeb03]),'UserId':Number(_0x3d1a8a['id'])});}});}})['then'](function(){if(_0x77dbbc===_0x7315('0x49')){var _0x1a2265=_['map'](_0x3d1a8a['WhatsappInteractions'],'id');return _0x3d1a8a[_0x7315('0x50')](_0x1a2265)[_0x7315('0xa')](function(){for(var _0x5c823f=0x0;_0x5c823f<_0x1a2265['length'];_0x5c823f+=0x1){_0x16b24f['emit'](_0x7315('0x51'),{'WhatsappInteractionId':Number(_0x1a2265[_0x5c823f]),'UserId':Number(_0x3d1a8a['id'])});}});}})[_0x7315('0x52')](function(_0x1e9a22){_0x1a7eb0['log'](_0x1e9a22);});}}function onDisconnect(_0x438d6f,_0xc40410){joinOrLeave(_0x438d6f,_0x7315('0x49'),_0xc40410);}function onConnect(_0x204503){joinOrLeave(_0x204503,_0x7315('0x53'));}exports[_0x7315('0x54')]=function(_0x1eb86b){_0x1eb86b['on'](_0x7315('0x55'),function(_0x4a5d46){_0x4a5d46[_0x7315('0x56')](0x0);_0x4a5d46['address']=_0x4a5d46['request'][_0x7315('0x55')][_0x7315('0x57')]+':'+_0x4a5d46[_0x7315('0x58')][_0x7315('0x55')][_0x7315('0x59')];_0x4a5d46['connectedAt']=new Date();_0x4a5d46[_0x7315('0x5a')]=function(_0x361730){console[_0x7315('0x5a')](_0x7315('0x5b')+_0x4a5d46[_0x7315('0x5c')][_0x7315('0x4')]+'['+_0x4a5d46[_0x7315('0x5d')]+']',_0x361730);};_0x4a5d46['on'](_0x7315('0x5e'),function(){onDisconnect(_0x4a5d46,_0x1eb86b);_0x4a5d46['log'](_0x7315('0x5f'));});onConnect(_0x4a5d46);_0x4a5d46[_0x7315('0x5a')](_0x7315('0x60'));});};
\ No newline at end of file