Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / config / socketio.js
index 3b2501a..133803d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x23bb=['removeSmsInteractions','user_has_sms_interactions:remove','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','WhatsappInteractions','removeWhatsappInteractions','user_has_whatsapp_interactions:remove','catch','log','join','default','connection','setMaxListeners','request','remoteAddress','remotePort','connectedAt','nsp','disconnect','CONNECTED','lodash','../mysqldb','./environment','name','User','role','type','UserProfileSection','then','VoiceQueues','ChatQueues','FaxQueues','MailQueues','OpenchannelQueues','WhatsappQueues','findAll','Telephones','Trunks','IvrCampaigns','UserProfileResource','resourceId','map','where','telephone','Campaign','format','%s:queue:%s','Agents','length','user:%s','query','find','userProfileId','handshake','ChatInteraction','ChatInteractions','MailInteractions','FaxInteraction','FaxInteractions','SmsInteraction','SmsInteractions','OpenchannelInteraction','OpenchannelInteractions','WhatsappInteraction','admin','voice:inbound','hasOwnProperty','include','push','VoiceQueue','ChatQueue','FaxQueue','SmsQueue','MailQueue','OpenchannelQueue','WhatsappQueue','Trunk','voice:outbound','SmsQueues','agent','getVoiceQueues','getChatQueues','getFaxQueues','getSmsQueues','getOpenchannelQueues','getWhatsappQueues','all','voice','chat','sms','mail','openchannel','whatsapp','telephone:%s','trunk:%s','leave','emit','user_has_chat_interactions:remove','removeMailInteractions','user_has_mail_interactions:remove','removeFaxInteractions'];(function(_0x58a840,_0x165547){var _0x712328=function(_0x4c7a2b){while(--_0x4c7a2b){_0x58a840['push'](_0x58a840['shift']());}};_0x712328(++_0x165547);}(_0x23bb,0x79));var _0xb23b=function(_0x5a585b,_0x3e0674){_0x5a585b=_0x5a585b-0x0;var _0x4cd398=_0x23bb[_0x5a585b];return _0x4cd398;};'use strict';var _=require(_0xb23b('0x0'));var util=require('util');var BPromise=require('bluebird');var db=require(_0xb23b('0x1'))['db'];var config=require(_0xb23b('0x2'));var queryQueues={'attributes':['id',_0xb23b('0x3')],'include':[{'as':'Agents','model':db[_0xb23b('0x4')],'attributes':['id',_0xb23b('0x3'),_0xb23b('0x5')],'raw':!![],'where':{'role':'agent'},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id','name'],'where':{'role':'telephone'}};var queryTrunks={'raw':!![],'attributes':['id',_0xb23b('0x3')]};var queryAgents={'raw':!![],'attributes':['id','name'],'where':{'role':'agent'}};var queryCampaigns={'raw':!![],'attributes':['id','name',_0xb23b('0x6')],'where':{'type':'ivr'}};function getAssociatedResources(_0x117bd5,_0x5360a1,_0x23270c){return db[_0xb23b('0x7')]['findOne']({'where':{'name':_0x117bd5,'userProfileId':_0x5360a1},'raw':!![]})[_0xb23b('0x8')](function(_0x2fe30e){if(_0x2fe30e){if(_0x2fe30e['autoAssociation']){switch(_0x117bd5){case _0xb23b('0x9'):case _0xb23b('0xa'):case _0xb23b('0xb'):case'SmsQueues':case _0xb23b('0xc'):case _0xb23b('0xd'):case _0xb23b('0xe'):return db[_0x23270c][_0xb23b('0xf')](queryQueues);case _0xb23b('0x10'):return db[_0x23270c][_0xb23b('0xf')](queryTelephones);case _0xb23b('0x11'):return db[_0x23270c][_0xb23b('0xf')](queryTrunks);case _0xb23b('0x12'):return db[_0x23270c][_0xb23b('0xf')](queryCampaigns);}}else{return db[_0xb23b('0x13')][_0xb23b('0xf')]({'attributes':[_0xb23b('0x14')],'where':{'sectionId':_0x2fe30e['id']},'raw':!![]})[_0xb23b('0x8')](function(_0x338275){if(_0x338275){var _0x1a03a6={'where':{'id':_[_0xb23b('0x15')](_0x338275,'resourceId')},'raw':!![]};switch(_0x23270c){case _0xb23b('0x4'):_0x1a03a6[_0xb23b('0x16')][_0xb23b('0x5')]=_0xb23b('0x17');break;case _0xb23b('0x18'):_0x1a03a6['where'][_0xb23b('0x6')]='ivr';break;}return db[_0x23270c][_0xb23b('0xf')](_0x1a03a6);}else{return[];}});}}else{return[];}})[_0xb23b('0x8')](function(_0x2941ea){return _0x2941ea;});}function joinOrLeaveQueues(_0x5ddf16,_0x57c0df,_0x12a658,_0x354e9d){_0x5ddf16[_0x57c0df](util[_0xb23b('0x19')](_0xb23b('0x1a'),_0x12a658,_0x354e9d[_0xb23b('0x3')]));if(_0x354e9d[_0xb23b('0x1b')]){for(var _0x65c746=0x0;_0x65c746<_0x354e9d['Agents'][_0xb23b('0x1c')];_0x65c746+=0x1){_0x5ddf16[_0x57c0df](util[_0xb23b('0x19')](_0xb23b('0x1d'),_0x354e9d[_0xb23b('0x1b')][_0x65c746]['name']));}}}function joinOrLeave(_0x14c99c,_0x3bec93,_0x4c2d1d){var _0x11aaac;if(_0x14c99c['handshake'][_0xb23b('0x1e')]['id']){db['User'][_0xb23b('0x1f')]({'attributes':['id',_0xb23b('0x3'),'role',_0xb23b('0x20')],'where':{'id':_0x14c99c[_0xb23b('0x21')][_0xb23b('0x1e')]['id']},'include':[{'model':db[_0xb23b('0x22')],'as':_0xb23b('0x23'),'attributes':['id'],'raw':!![]},{'model':db['MailInteraction'],'as':_0xb23b('0x24'),'attributes':['id'],'raw':!![]},{'model':db[_0xb23b('0x25')],'as':_0xb23b('0x26'),'attributes':['id'],'raw':!![]},{'model':db[_0xb23b('0x27')],'as':_0xb23b('0x28'),'attributes':['id'],'raw':!![]},{'model':db[_0xb23b('0x29')],'as':_0xb23b('0x2a'),'attributes':['id'],'raw':!![]},{'model':db[_0xb23b('0x2b')],'as':'WhatsappInteractions','attributes':['id'],'raw':!![]}]})[_0xb23b('0x8')](function(_0x2758d7){if(_0x2758d7){_0x11aaac=_0x2758d7;_0x14c99c[_0x3bec93](util[_0xb23b('0x19')]('user:%s',_0x2758d7[_0xb23b('0x3')]));var _0x57c1ef=[];switch(_0x2758d7[_0xb23b('0x5')]){case _0xb23b('0x2c'):_0x14c99c[_0x3bec93](_0xb23b('0x2d'));_0x14c99c[_0x3bec93]('voice:outbound');if(queryQueues[_0xb23b('0x2e')](_0xb23b('0x2f'))){delete queryQueues[_0xb23b('0x2f')];}_0x57c1ef[_0xb23b('0x30')](db[_0xb23b('0x31')][_0xb23b('0xf')](queryQueues));_0x57c1ef[_0xb23b('0x30')](db[_0xb23b('0x32')][_0xb23b('0xf')](queryQueues));_0x57c1ef[_0xb23b('0x30')](db[_0xb23b('0x33')][_0xb23b('0xf')](queryQueues));_0x57c1ef['push'](db[_0xb23b('0x34')][_0xb23b('0xf')](queryQueues));_0x57c1ef[_0xb23b('0x30')](db[_0xb23b('0x35')]['findAll'](queryQueues));_0x57c1ef[_0xb23b('0x30')](db[_0xb23b('0x36')][_0xb23b('0xf')](queryQueues));_0x57c1ef[_0xb23b('0x30')](db[_0xb23b('0x37')]['findAll'](queryQueues));_0x57c1ef[_0xb23b('0x30')](db['User'][_0xb23b('0xf')](queryTelephones));_0x57c1ef['push'](db[_0xb23b('0x38')]['findAll'](queryTrunks));_0x57c1ef[_0xb23b('0x30')](db['Campaign']['findAll'](queryCampaigns));_0x57c1ef[_0xb23b('0x30')](db[_0xb23b('0x4')][_0xb23b('0xf')](queryAgents));break;case'user':_0x14c99c[_0x3bec93](_0xb23b('0x2d'));_0x14c99c[_0x3bec93](_0xb23b('0x39'));_0x57c1ef[_0xb23b('0x30')](getAssociatedResources(_0xb23b('0x9'),_0x2758d7[_0xb23b('0x20')],_0xb23b('0x31')));_0x57c1ef[_0xb23b('0x30')](getAssociatedResources(_0xb23b('0xa'),_0x2758d7[_0xb23b('0x20')],_0xb23b('0x32')));_0x57c1ef['push'](getAssociatedResources(_0xb23b('0xb'),_0x2758d7[_0xb23b('0x20')],_0xb23b('0x33')));_0x57c1ef[_0xb23b('0x30')](getAssociatedResources(_0xb23b('0x3a'),_0x2758d7[_0xb23b('0x20')],_0xb23b('0x34')));_0x57c1ef[_0xb23b('0x30')](getAssociatedResources(_0xb23b('0xc'),_0x2758d7[_0xb23b('0x20')],_0xb23b('0x35')));_0x57c1ef[_0xb23b('0x30')](getAssociatedResources(_0xb23b('0xd'),_0x2758d7[_0xb23b('0x20')],_0xb23b('0x36')));_0x57c1ef['push'](getAssociatedResources(_0xb23b('0xe'),_0x2758d7['userProfileId'],_0xb23b('0x37')));_0x57c1ef[_0xb23b('0x30')](getAssociatedResources(_0xb23b('0x10'),_0x2758d7[_0xb23b('0x20')],_0xb23b('0x4')));_0x57c1ef[_0xb23b('0x30')](getAssociatedResources('Trunks',_0x2758d7[_0xb23b('0x20')],_0xb23b('0x38')));_0x57c1ef[_0xb23b('0x30')](getAssociatedResources(_0xb23b('0x12'),_0x2758d7[_0xb23b('0x20')],_0xb23b('0x18')));_0x57c1ef[_0xb23b('0x30')](db[_0xb23b('0x4')][_0xb23b('0xf')](queryAgents));break;case _0xb23b('0x3b'):_0x14c99c[_0x3bec93](_0xb23b('0x2d'));_0x14c99c[_0x3bec93]('voice:outbound');_0x57c1ef[_0xb23b('0x30')](_0x2758d7[_0xb23b('0x3c')]({'attributes':['id','name']}));_0x57c1ef[_0xb23b('0x30')](_0x2758d7[_0xb23b('0x3d')]({'attributes':['id','name']}));_0x57c1ef[_0xb23b('0x30')](_0x2758d7[_0xb23b('0x3e')]({'attributes':['id',_0xb23b('0x3')]}));_0x57c1ef[_0xb23b('0x30')](_0x2758d7[_0xb23b('0x3f')]({'attributes':['id',_0xb23b('0x3')]}));_0x57c1ef[_0xb23b('0x30')](_0x2758d7['getMailQueues']({'attributes':['id',_0xb23b('0x3')]}));_0x57c1ef[_0xb23b('0x30')](_0x2758d7[_0xb23b('0x40')]({'attributes':['id','name']}));_0x57c1ef['push'](_0x2758d7[_0xb23b('0x41')]({'attributes':['id','name']}));break;}return BPromise[_0xb23b('0x42')](_0x57c1ef);}})[_0xb23b('0x8')](function(_0x50703c){if(_0x50703c&&_0x50703c[_0xb23b('0x1c')]){for(var _0x32b0bc=0x0;_0x32b0bc<_0x50703c[_0xb23b('0x1c')];_0x32b0bc+=0x1){for(var _0x4d5d85=0x0;_0x4d5d85<_0x50703c[_0x32b0bc][_0xb23b('0x1c')];_0x4d5d85+=0x1){switch(_0x32b0bc){case 0x0:joinOrLeaveQueues(_0x14c99c,_0x3bec93,_0xb23b('0x43'),_0x50703c[_0x32b0bc][_0x4d5d85]);break;case 0x1:joinOrLeaveQueues(_0x14c99c,_0x3bec93,_0xb23b('0x44'),_0x50703c[_0x32b0bc][_0x4d5d85]);break;case 0x2:joinOrLeaveQueues(_0x14c99c,_0x3bec93,'fax',_0x50703c[_0x32b0bc][_0x4d5d85]);break;case 0x3:joinOrLeaveQueues(_0x14c99c,_0x3bec93,_0xb23b('0x45'),_0x50703c[_0x32b0bc][_0x4d5d85]);break;case 0x4:joinOrLeaveQueues(_0x14c99c,_0x3bec93,_0xb23b('0x46'),_0x50703c[_0x32b0bc][_0x4d5d85]);break;case 0x5:joinOrLeaveQueues(_0x14c99c,_0x3bec93,_0xb23b('0x47'),_0x50703c[_0x32b0bc][_0x4d5d85]);break;case 0x6:joinOrLeaveQueues(_0x14c99c,_0x3bec93,_0xb23b('0x48'),_0x50703c[_0x32b0bc][_0x4d5d85]);break;case 0x7:if(_0x11aaac[_0xb23b('0x5')]!==_0xb23b('0x3b'))_0x14c99c[_0x3bec93](util[_0xb23b('0x19')](_0xb23b('0x49'),_0x50703c[_0x32b0bc][_0x4d5d85][_0xb23b('0x3')]));break;case 0x8:if(_0x11aaac[_0xb23b('0x5')]!==_0xb23b('0x3b'))_0x14c99c[_0x3bec93](util[_0xb23b('0x19')](_0xb23b('0x4a'),_0x50703c[_0x32b0bc][_0x4d5d85][_0xb23b('0x3')]));break;case 0x9:if(_0x11aaac[_0xb23b('0x5')]!=='agent')_0x14c99c[_0x3bec93](util[_0xb23b('0x19')]('campaign:%s:%s',_0x50703c[_0x32b0bc][_0x4d5d85][_0xb23b('0x6')],_0x50703c[_0x32b0bc][_0x4d5d85]['name']));break;case 0xa:_0x14c99c[_0x3bec93](util['format'](_0xb23b('0x1d'),_0x50703c[_0x32b0bc][_0x4d5d85]['name']));break;}}}}})[_0xb23b('0x8')](function(){if(_0x3bec93===_0xb23b('0x4b')){var _0x5f2ec5=_[_0xb23b('0x15')](_0x11aaac['ChatInteractions'],'id');return _0x11aaac['removeChatInteractions'](_0x5f2ec5)['then'](function(){for(var _0x24d44b=0x0;_0x24d44b<_0x5f2ec5[_0xb23b('0x1c')];_0x24d44b+=0x1){_0x4c2d1d[_0xb23b('0x4c')](_0xb23b('0x4d'),{'ChatInteractionId':Number(_0x5f2ec5[_0x24d44b]),'UserId':Number(_0x11aaac['id'])});}});}})['then'](function(){if(_0x3bec93==='leave'){var _0x40fab4=_['map'](_0x11aaac[_0xb23b('0x24')],'id');return _0x11aaac[_0xb23b('0x4e')](_0x40fab4)[_0xb23b('0x8')](function(){for(var _0x125077=0x0;_0x125077<_0x40fab4[_0xb23b('0x1c')];_0x125077+=0x1){_0x4c2d1d[_0xb23b('0x4c')](_0xb23b('0x4f'),{'MailInteractionId':Number(_0x40fab4[_0x125077]),'UserId':Number(_0x11aaac['id'])});}});}})[_0xb23b('0x8')](function(){if(_0x3bec93==='leave'){var _0x1b7ac3=_[_0xb23b('0x15')](_0x11aaac[_0xb23b('0x26')],'id');return _0x11aaac[_0xb23b('0x50')](_0x1b7ac3)[_0xb23b('0x8')](function(){for(var _0x18f1ee=0x0;_0x18f1ee<_0x1b7ac3['length'];_0x18f1ee+=0x1){_0x4c2d1d['emit']('user_has_fax_interactions:remove',{'FaxInteractionId':Number(_0x1b7ac3[_0x18f1ee]),'UserId':Number(_0x11aaac['id'])});}});}})[_0xb23b('0x8')](function(){if(_0x3bec93===_0xb23b('0x4b')){var _0x4d158e=_[_0xb23b('0x15')](_0x11aaac['SmsInteractions'],'id');return _0x11aaac[_0xb23b('0x51')](_0x4d158e)[_0xb23b('0x8')](function(){for(var _0x630faf=0x0;_0x630faf<_0x4d158e[_0xb23b('0x1c')];_0x630faf+=0x1){_0x4c2d1d[_0xb23b('0x4c')](_0xb23b('0x52'),{'SmsInteractionId':Number(_0x4d158e[_0x630faf]),'UserId':Number(_0x11aaac['id'])});}});}})[_0xb23b('0x8')](function(){if(_0x3bec93===_0xb23b('0x4b')){var _0x3bd4d7=_[_0xb23b('0x15')](_0x11aaac['OpenchannelInteractions'],'id');return _0x11aaac[_0xb23b('0x53')](_0x3bd4d7)[_0xb23b('0x8')](function(){for(var _0x24e44a=0x0;_0x24e44a<_0x3bd4d7[_0xb23b('0x1c')];_0x24e44a+=0x1){_0x4c2d1d[_0xb23b('0x4c')](_0xb23b('0x54'),{'OpenchannelInteractionId':Number(_0x3bd4d7[_0x24e44a]),'UserId':Number(_0x11aaac['id'])});}});}})['then'](function(){if(_0x3bec93===_0xb23b('0x4b')){var _0x1aa2b6=_[_0xb23b('0x15')](_0x11aaac[_0xb23b('0x55')],'id');return _0x11aaac[_0xb23b('0x56')](_0x1aa2b6)['then'](function(){for(var _0x2cd985=0x0;_0x2cd985<_0x1aa2b6['length'];_0x2cd985+=0x1){_0x4c2d1d[_0xb23b('0x4c')](_0xb23b('0x57'),{'WhatsappInteractionId':Number(_0x1aa2b6[_0x2cd985]),'UserId':Number(_0x11aaac['id'])});}});}})[_0xb23b('0x58')](function(_0xc3d1f2){_0x14c99c[_0xb23b('0x59')](_0xc3d1f2);});}}function onDisconnect(_0x43f397,_0x1c0e0b){joinOrLeave(_0x43f397,_0xb23b('0x4b'),_0x1c0e0b);}function onConnect(_0x42b30f){joinOrLeave(_0x42b30f,_0xb23b('0x5a'));}exports[_0xb23b('0x5b')]=function(_0xd08a7d){_0xd08a7d['on'](_0xb23b('0x5c'),function(_0x39289f){_0x39289f[_0xb23b('0x5d')](0x0);_0x39289f['address']=_0x39289f[_0xb23b('0x5e')][_0xb23b('0x5c')][_0xb23b('0x5f')]+':'+_0x39289f[_0xb23b('0x5e')][_0xb23b('0x5c')][_0xb23b('0x60')];_0x39289f[_0xb23b('0x61')]=new Date();_0x39289f[_0xb23b('0x59')]=function(_0x5117b6){console[_0xb23b('0x59')]('SocketIO\x20'+_0x39289f[_0xb23b('0x62')]['name']+'['+_0x39289f['address']+']',_0x5117b6);};_0x39289f['on'](_0xb23b('0x63'),function(){onDisconnect(_0x39289f,_0xd08a7d);_0x39289f[_0xb23b('0x59')]('DISCONNECTED');});onConnect(_0x39289f);_0x39289f[_0xb23b('0x59')](_0xb23b('0x64'));});};
\ No newline at end of file
+var _0xd9eb=['Agents','User','role','agent','telephone','type','ivr','UserProfileSection','findOne','then','VoiceQueues','ChatQueues','SmsQueues','OpenchannelQueues','WhatsappQueues','findAll','Telephones','Trunks','IvrCampaigns','UserProfileResource','resourceId','map','where','Campaign','%s:queue:%s','length','format','handshake','query','ChatInteraction','ChatInteractions','MailInteractions','FaxInteraction','FaxInteractions','SmsInteraction','SmsInteractions','OpenchannelInteraction','OpenchannelInteractions','WhatsappInteractions','user:%s','admin','voice:outbound','hasOwnProperty','include','push','VoiceQueue','ChatQueue','SmsQueue','WhatsappQueue','user','userProfileId','FaxQueue','MailQueues','MailQueue','OpenchannelQueue','Trunk','voice:inbound','getVoiceQueues','getChatQueues','getFaxQueues','getSmsQueues','getOpenchannelQueues','getWhatsappQueues','all','voice','chat','sms','openchannel','whatsapp','telephone:%s','trunk:%s','campaign:%s:%s','removeChatInteractions','emit','user_has_chat_interactions:remove','leave','removeMailInteractions','user_has_mail_interactions:remove','removeFaxInteractions','user_has_fax_interactions:remove','removeSmsInteractions','user_has_sms_interactions:remove','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','removeWhatsappInteractions','user_has_whatsapp_interactions:remove','catch','log','join','default','remoteAddress','request','connection','remotePort','connectedAt','SocketIO\x20','address','DISCONNECTED','lodash','util','bluebird','../mysqldb','./environment','name'];(function(_0x282ccc,_0x5d66a1){var _0x27c2dd=function(_0x58431a){while(--_0x58431a){_0x282ccc['push'](_0x282ccc['shift']());}};_0x27c2dd(++_0x5d66a1);}(_0xd9eb,0xca));var _0xbd9e=function(_0x5a7282,_0xa6e195){_0x5a7282=_0x5a7282-0x0;var _0x4928ec=_0xd9eb[_0x5a7282];return _0x4928ec;};'use strict';var _=require(_0xbd9e('0x0'));var util=require(_0xbd9e('0x1'));var BPromise=require(_0xbd9e('0x2'));var db=require(_0xbd9e('0x3'))['db'];var config=require(_0xbd9e('0x4'));var queryQueues={'attributes':['id',_0xbd9e('0x5')],'include':[{'as':_0xbd9e('0x6'),'model':db[_0xbd9e('0x7')],'attributes':['id',_0xbd9e('0x5'),_0xbd9e('0x8')],'raw':!![],'where':{'role':_0xbd9e('0x9')},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id',_0xbd9e('0x5')],'where':{'role':_0xbd9e('0xa')}};var queryTrunks={'raw':!![],'attributes':['id','name']};var queryAgents={'raw':!![],'attributes':['id',_0xbd9e('0x5')],'where':{'role':_0xbd9e('0x9')}};var queryCampaigns={'raw':!![],'attributes':['id',_0xbd9e('0x5'),_0xbd9e('0xb')],'where':{'type':_0xbd9e('0xc')}};function getAssociatedResources(_0x7755b8,_0x131530,_0x82e476){return db[_0xbd9e('0xd')][_0xbd9e('0xe')]({'where':{'name':_0x7755b8,'userProfileId':_0x131530},'raw':!![]})[_0xbd9e('0xf')](function(_0x1e3c0b){if(_0x1e3c0b){if(_0x1e3c0b['autoAssociation']){switch(_0x7755b8){case _0xbd9e('0x10'):case _0xbd9e('0x11'):case'FaxQueues':case _0xbd9e('0x12'):case'MailQueues':case _0xbd9e('0x13'):case _0xbd9e('0x14'):return db[_0x82e476][_0xbd9e('0x15')](queryQueues);case _0xbd9e('0x16'):return db[_0x82e476][_0xbd9e('0x15')](queryTelephones);case _0xbd9e('0x17'):return db[_0x82e476][_0xbd9e('0x15')](queryTrunks);case _0xbd9e('0x18'):return db[_0x82e476]['findAll'](queryCampaigns);}}else{return db[_0xbd9e('0x19')][_0xbd9e('0x15')]({'attributes':[_0xbd9e('0x1a')],'where':{'sectionId':_0x1e3c0b['id']},'raw':!![]})[_0xbd9e('0xf')](function(_0x243802){if(_0x243802){var _0x339d79={'where':{'id':_[_0xbd9e('0x1b')](_0x243802,_0xbd9e('0x1a'))},'raw':!![]};switch(_0x82e476){case _0xbd9e('0x7'):_0x339d79[_0xbd9e('0x1c')][_0xbd9e('0x8')]='telephone';break;case _0xbd9e('0x1d'):_0x339d79[_0xbd9e('0x1c')][_0xbd9e('0xb')]=_0xbd9e('0xc');break;}return db[_0x82e476][_0xbd9e('0x15')](_0x339d79);}else{return[];}});}}else{return[];}})['then'](function(_0x5bf755){return _0x5bf755;});}function joinOrLeaveQueues(_0x36bdc1,_0x37e6d8,_0xb9ff26,_0x1165e0){_0x36bdc1[_0x37e6d8](util['format'](_0xbd9e('0x1e'),_0xb9ff26,_0x1165e0['name']));if(_0x1165e0['Agents']){for(var _0x30d92f=0x0;_0x30d92f<_0x1165e0[_0xbd9e('0x6')][_0xbd9e('0x1f')];_0x30d92f+=0x1){_0x36bdc1[_0x37e6d8](util[_0xbd9e('0x20')]('user:%s',_0x1165e0[_0xbd9e('0x6')][_0x30d92f][_0xbd9e('0x5')]));}}}function joinOrLeave(_0x4e53cd,_0x4efbe2,_0x2733cb){var _0x2957d1;if(_0x4e53cd[_0xbd9e('0x21')][_0xbd9e('0x22')]['id']){db['User']['find']({'attributes':['id','name',_0xbd9e('0x8'),'userProfileId'],'where':{'id':_0x4e53cd[_0xbd9e('0x21')]['query']['id']},'include':[{'model':db[_0xbd9e('0x23')],'as':_0xbd9e('0x24'),'attributes':['id'],'raw':!![]},{'model':db['MailInteraction'],'as':_0xbd9e('0x25'),'attributes':['id'],'raw':!![]},{'model':db[_0xbd9e('0x26')],'as':_0xbd9e('0x27'),'attributes':['id'],'raw':!![]},{'model':db[_0xbd9e('0x28')],'as':_0xbd9e('0x29'),'attributes':['id'],'raw':!![]},{'model':db[_0xbd9e('0x2a')],'as':_0xbd9e('0x2b'),'attributes':['id'],'raw':!![]},{'model':db['WhatsappInteraction'],'as':_0xbd9e('0x2c'),'attributes':['id'],'raw':!![]}]})['then'](function(_0x33d152){if(_0x33d152){_0x2957d1=_0x33d152;_0x4e53cd[_0x4efbe2](util['format'](_0xbd9e('0x2d'),_0x33d152[_0xbd9e('0x5')]));var _0x5485ec=[];switch(_0x33d152[_0xbd9e('0x8')]){case _0xbd9e('0x2e'):_0x4e53cd[_0x4efbe2]('voice:inbound');_0x4e53cd[_0x4efbe2](_0xbd9e('0x2f'));if(queryQueues[_0xbd9e('0x30')]('include')){delete queryQueues[_0xbd9e('0x31')];}_0x5485ec[_0xbd9e('0x32')](db[_0xbd9e('0x33')]['findAll'](queryQueues));_0x5485ec[_0xbd9e('0x32')](db[_0xbd9e('0x34')][_0xbd9e('0x15')](queryQueues));_0x5485ec[_0xbd9e('0x32')](db['FaxQueue']['findAll'](queryQueues));_0x5485ec['push'](db[_0xbd9e('0x35')]['findAll'](queryQueues));_0x5485ec[_0xbd9e('0x32')](db['MailQueue']['findAll'](queryQueues));_0x5485ec[_0xbd9e('0x32')](db['OpenchannelQueue'][_0xbd9e('0x15')](queryQueues));_0x5485ec[_0xbd9e('0x32')](db[_0xbd9e('0x36')][_0xbd9e('0x15')](queryQueues));_0x5485ec[_0xbd9e('0x32')](db[_0xbd9e('0x7')]['findAll'](queryTelephones));_0x5485ec[_0xbd9e('0x32')](db['Trunk'][_0xbd9e('0x15')](queryTrunks));_0x5485ec['push'](db['Campaign']['findAll'](queryCampaigns));_0x5485ec[_0xbd9e('0x32')](db['User']['findAll'](queryAgents));break;case _0xbd9e('0x37'):_0x4e53cd[_0x4efbe2]('voice:inbound');_0x4e53cd[_0x4efbe2](_0xbd9e('0x2f'));_0x5485ec['push'](getAssociatedResources(_0xbd9e('0x10'),_0x33d152[_0xbd9e('0x38')],_0xbd9e('0x33')));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources(_0xbd9e('0x11'),_0x33d152['userProfileId'],_0xbd9e('0x34')));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources('FaxQueues',_0x33d152[_0xbd9e('0x38')],_0xbd9e('0x39')));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources(_0xbd9e('0x12'),_0x33d152[_0xbd9e('0x38')],'SmsQueue'));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources(_0xbd9e('0x3a'),_0x33d152[_0xbd9e('0x38')],_0xbd9e('0x3b')));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources(_0xbd9e('0x13'),_0x33d152['userProfileId'],_0xbd9e('0x3c')));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources(_0xbd9e('0x14'),_0x33d152['userProfileId'],_0xbd9e('0x36')));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources('Telephones',_0x33d152['userProfileId'],'User'));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources(_0xbd9e('0x17'),_0x33d152['userProfileId'],_0xbd9e('0x3d')));_0x5485ec[_0xbd9e('0x32')](getAssociatedResources(_0xbd9e('0x18'),_0x33d152[_0xbd9e('0x38')],_0xbd9e('0x1d')));_0x5485ec[_0xbd9e('0x32')](db[_0xbd9e('0x7')][_0xbd9e('0x15')](queryAgents));break;case'agent':_0x4e53cd[_0x4efbe2](_0xbd9e('0x3e'));_0x4e53cd[_0x4efbe2](_0xbd9e('0x2f'));_0x5485ec[_0xbd9e('0x32')](_0x33d152[_0xbd9e('0x3f')]({'attributes':['id','name']}));_0x5485ec['push'](_0x33d152[_0xbd9e('0x40')]({'attributes':['id',_0xbd9e('0x5')]}));_0x5485ec['push'](_0x33d152[_0xbd9e('0x41')]({'attributes':['id','name']}));_0x5485ec[_0xbd9e('0x32')](_0x33d152[_0xbd9e('0x42')]({'attributes':['id','name']}));_0x5485ec['push'](_0x33d152['getMailQueues']({'attributes':['id',_0xbd9e('0x5')]}));_0x5485ec[_0xbd9e('0x32')](_0x33d152[_0xbd9e('0x43')]({'attributes':['id',_0xbd9e('0x5')]}));_0x5485ec[_0xbd9e('0x32')](_0x33d152[_0xbd9e('0x44')]({'attributes':['id','name']}));break;}return BPromise[_0xbd9e('0x45')](_0x5485ec);}})['then'](function(_0x53c961){if(_0x53c961&&_0x53c961[_0xbd9e('0x1f')]){for(var _0x9e55e7=0x0;_0x9e55e7<_0x53c961[_0xbd9e('0x1f')];_0x9e55e7+=0x1){for(var _0x5c8485=0x0;_0x5c8485<_0x53c961[_0x9e55e7][_0xbd9e('0x1f')];_0x5c8485+=0x1){switch(_0x9e55e7){case 0x0:joinOrLeaveQueues(_0x4e53cd,_0x4efbe2,_0xbd9e('0x46'),_0x53c961[_0x9e55e7][_0x5c8485]);break;case 0x1:joinOrLeaveQueues(_0x4e53cd,_0x4efbe2,_0xbd9e('0x47'),_0x53c961[_0x9e55e7][_0x5c8485]);break;case 0x2:joinOrLeaveQueues(_0x4e53cd,_0x4efbe2,'fax',_0x53c961[_0x9e55e7][_0x5c8485]);break;case 0x3:joinOrLeaveQueues(_0x4e53cd,_0x4efbe2,_0xbd9e('0x48'),_0x53c961[_0x9e55e7][_0x5c8485]);break;case 0x4:joinOrLeaveQueues(_0x4e53cd,_0x4efbe2,'mail',_0x53c961[_0x9e55e7][_0x5c8485]);break;case 0x5:joinOrLeaveQueues(_0x4e53cd,_0x4efbe2,_0xbd9e('0x49'),_0x53c961[_0x9e55e7][_0x5c8485]);break;case 0x6:joinOrLeaveQueues(_0x4e53cd,_0x4efbe2,_0xbd9e('0x4a'),_0x53c961[_0x9e55e7][_0x5c8485]);break;case 0x7:if(_0x2957d1[_0xbd9e('0x8')]!==_0xbd9e('0x9'))_0x4e53cd[_0x4efbe2](util[_0xbd9e('0x20')](_0xbd9e('0x4b'),_0x53c961[_0x9e55e7][_0x5c8485][_0xbd9e('0x5')]));break;case 0x8:if(_0x2957d1[_0xbd9e('0x8')]!==_0xbd9e('0x9'))_0x4e53cd[_0x4efbe2](util[_0xbd9e('0x20')](_0xbd9e('0x4c'),_0x53c961[_0x9e55e7][_0x5c8485][_0xbd9e('0x5')]));break;case 0x9:if(_0x2957d1[_0xbd9e('0x8')]!=='agent')_0x4e53cd[_0x4efbe2](util[_0xbd9e('0x20')](_0xbd9e('0x4d'),_0x53c961[_0x9e55e7][_0x5c8485][_0xbd9e('0xb')],_0x53c961[_0x9e55e7][_0x5c8485][_0xbd9e('0x5')]));break;case 0xa:_0x4e53cd[_0x4efbe2](util[_0xbd9e('0x20')](_0xbd9e('0x2d'),_0x53c961[_0x9e55e7][_0x5c8485][_0xbd9e('0x5')]));break;}}}}})[_0xbd9e('0xf')](function(){if(_0x4efbe2==='leave'){var _0x4c56e5=_[_0xbd9e('0x1b')](_0x2957d1[_0xbd9e('0x24')],'id');return _0x2957d1[_0xbd9e('0x4e')](_0x4c56e5)[_0xbd9e('0xf')](function(){for(var _0x328799=0x0;_0x328799<_0x4c56e5['length'];_0x328799+=0x1){_0x2733cb[_0xbd9e('0x4f')](_0xbd9e('0x50'),{'ChatInteractionId':Number(_0x4c56e5[_0x328799]),'UserId':Number(_0x2957d1['id'])});}});}})['then'](function(){if(_0x4efbe2===_0xbd9e('0x51')){var _0x15c9c6=_[_0xbd9e('0x1b')](_0x2957d1[_0xbd9e('0x25')],'id');return _0x2957d1[_0xbd9e('0x52')](_0x15c9c6)[_0xbd9e('0xf')](function(){for(var _0x81363f=0x0;_0x81363f<_0x15c9c6['length'];_0x81363f+=0x1){_0x2733cb['emit'](_0xbd9e('0x53'),{'MailInteractionId':Number(_0x15c9c6[_0x81363f]),'UserId':Number(_0x2957d1['id'])});}});}})[_0xbd9e('0xf')](function(){if(_0x4efbe2===_0xbd9e('0x51')){var _0x1f5fa6=_[_0xbd9e('0x1b')](_0x2957d1[_0xbd9e('0x27')],'id');return _0x2957d1[_0xbd9e('0x54')](_0x1f5fa6)[_0xbd9e('0xf')](function(){for(var _0x512ec7=0x0;_0x512ec7<_0x1f5fa6[_0xbd9e('0x1f')];_0x512ec7+=0x1){_0x2733cb[_0xbd9e('0x4f')](_0xbd9e('0x55'),{'FaxInteractionId':Number(_0x1f5fa6[_0x512ec7]),'UserId':Number(_0x2957d1['id'])});}});}})[_0xbd9e('0xf')](function(){if(_0x4efbe2===_0xbd9e('0x51')){var _0x9a6dfe=_[_0xbd9e('0x1b')](_0x2957d1[_0xbd9e('0x29')],'id');return _0x2957d1[_0xbd9e('0x56')](_0x9a6dfe)[_0xbd9e('0xf')](function(){for(var _0x530b17=0x0;_0x530b17<_0x9a6dfe[_0xbd9e('0x1f')];_0x530b17+=0x1){_0x2733cb['emit'](_0xbd9e('0x57'),{'SmsInteractionId':Number(_0x9a6dfe[_0x530b17]),'UserId':Number(_0x2957d1['id'])});}});}})['then'](function(){if(_0x4efbe2==='leave'){var _0x58bc0a=_[_0xbd9e('0x1b')](_0x2957d1['OpenchannelInteractions'],'id');return _0x2957d1[_0xbd9e('0x58')](_0x58bc0a)[_0xbd9e('0xf')](function(){for(var _0x3dcd10=0x0;_0x3dcd10<_0x58bc0a[_0xbd9e('0x1f')];_0x3dcd10+=0x1){_0x2733cb[_0xbd9e('0x4f')](_0xbd9e('0x59'),{'OpenchannelInteractionId':Number(_0x58bc0a[_0x3dcd10]),'UserId':Number(_0x2957d1['id'])});}});}})[_0xbd9e('0xf')](function(){if(_0x4efbe2===_0xbd9e('0x51')){var _0x4754d3=_['map'](_0x2957d1['WhatsappInteractions'],'id');return _0x2957d1[_0xbd9e('0x5a')](_0x4754d3)[_0xbd9e('0xf')](function(){for(var _0x2fb385=0x0;_0x2fb385<_0x4754d3[_0xbd9e('0x1f')];_0x2fb385+=0x1){_0x2733cb[_0xbd9e('0x4f')](_0xbd9e('0x5b'),{'WhatsappInteractionId':Number(_0x4754d3[_0x2fb385]),'UserId':Number(_0x2957d1['id'])});}});}})[_0xbd9e('0x5c')](function(_0x4e9056){_0x4e53cd[_0xbd9e('0x5d')](_0x4e9056);});}}function onDisconnect(_0x52e794,_0x34b792){joinOrLeave(_0x52e794,_0xbd9e('0x51'),_0x34b792);}function onConnect(_0x3b8566){joinOrLeave(_0x3b8566,_0xbd9e('0x5e'));}exports[_0xbd9e('0x5f')]=function(_0x467868){_0x467868['on']('connection',function(_0x5b0222){_0x5b0222['setMaxListeners'](0x0);_0x5b0222['address']=_0x5b0222['request']['connection'][_0xbd9e('0x60')]+':'+_0x5b0222[_0xbd9e('0x61')][_0xbd9e('0x62')][_0xbd9e('0x63')];_0x5b0222[_0xbd9e('0x64')]=new Date();_0x5b0222[_0xbd9e('0x5d')]=function(_0x508e86){console[_0xbd9e('0x5d')](_0xbd9e('0x65')+_0x5b0222['nsp'][_0xbd9e('0x5')]+'['+_0x5b0222[_0xbd9e('0x66')]+']',_0x508e86);};_0x5b0222['on']('disconnect',function(){onDisconnect(_0x5b0222,_0x467868);_0x5b0222[_0xbd9e('0x5d')](_0xbd9e('0x67'));});onConnect(_0x5b0222);_0x5b0222[_0xbd9e('0x5d')]('CONNECTED');});};
\ No newline at end of file