Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / team / team.controller.js
index 48e655b..6054dff 100644 (file)
@@ -1 +1 @@
-const a626_0x59b6=['options','update','UserProfileSection','Teams','findOne','create','omit','Voice','sms','merge','index','model','mail','userTeam:remove','voice','User','getAgents','autoAssociation','pick','Unknown\x20channel','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','chat','offset','set','sendStatus','add','stack','interface','lodash','type','../../config/logger','destroy','filter','json','count','Sms','fields','body','isArray','ids','findAll','../../components/parsers/qs','name','query','VIRTUAL','each','voicePause','fieldName','util','Whatsapp','capitalize','userTeam:save','Queues','user','catch','whatsapp','length','../../mysqldb','status','get','UserProfileResource','emit','limit','params','undefined','removeQueues','Unable\x20to\x20retrieve\x20the\x20current\x20user','include','channel','show','filters','addAgents','end','includeAll','sequelize','role','../../config/utils','addQueues','intersection','where','rawAttributes','SIP/%s','order','send','toLowerCase','api','then','online','Openchannel','keys','Content-Range','Team','attributes','removeAgents','Queue','nolimit','error','like','register','openchannel','userProfileId','isValidChannel','UserVoiceQueueRt','map','./team.socket','sort'];(function(_0x486164,_0x59b608){const _0x41406c=function(_0x306f7f){while(--_0x306f7f){_0x486164['push'](_0x486164['shift']());}};_0x41406c(++_0x59b608);}(a626_0x59b6,0x1a2));const a626_0x4140=function(_0x486164,_0x59b608){_0x486164=_0x486164-0x0;let _0x41406c=a626_0x59b6[_0x486164];return _0x41406c;};const _0x38f888=a626_0x4140;'use strict';const util=require(_0x38f888('0x36')),_=require(_0x38f888('0x22')),qs=require(_0x38f888('0x2f')),logger=require(_0x38f888('0x24'))(_0x38f888('0x5b')),utils=require(_0x38f888('0x52')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require(_0x38f888('0x3f'))['db'],{Op,ValidationError}=require(_0x38f888('0x50'));require(_0x38f888('0x4'))[_0x38f888('0x68')](socket);function respondWithStatusCode(_0x306f7f,_0x4c30c8){return _0x4c30c8=_0x4c30c8||0xcc,function(_0x186a08){const _0x5b632c=a626_0x4140;if(_0x186a08)return _0x306f7f[_0x5b632c('0x1e')](_0x4c30c8);return _0x306f7f['status'](_0x4c30c8)[_0x5b632c('0x4e')]();};}function respondWithResult(_0xf748da,_0x24826d){return _0x24826d=_0x24826d||0xc8,function(_0x3999a3){const _0x3f1745=a626_0x4140;if(_0x3999a3)return _0xf748da[_0x3f1745('0x40')](_0x24826d)[_0x3f1745('0x27')](_0x3999a3);};}function respondWithFilteredResult(_0xbb526c,_0x177cc6){return function(_0x41518f){const _0x1657b3=a626_0x4140;if(_0x41518f){const _0x7c5a2c=_0x41518f['count'],_0x12b2de=_0x177cc6['offset'];let _0xfa87e=_0x177cc6[_0x1657b3('0x1c')]+_0x177cc6[_0x1657b3('0x44')],_0x1fd349;return _0xfa87e>=_0x7c5a2c?(_0xfa87e=_0x7c5a2c,_0x1fd349=0xc8):_0x1fd349=0xce,_0xbb526c['status'](_0x1fd349),_0xbb526c[_0x1657b3('0x1d')](_0x1657b3('0x60'),_0x12b2de+'-'+_0xfa87e+'/'+_0x7c5a2c)[_0x1657b3('0x27')](_0x41518f);}return null;};}function saveUpdates(_0x30552d){return function(_0x3ec26b){const _0x550011=a626_0x4140;if(_0x3ec26b)return _0x3ec26b['update'](_0x30552d)[_0x550011('0x5c')](function(_0x240588){return _0x240588;});return null;};}function removeEntity(_0x14a505){return function(_0x3449cd){const _0x149277=a626_0x4140;if(_0x3449cd)return _0x3449cd['destroy']()[_0x149277('0x5c')](function(){const _0x2bc266=_0x149277,_0x5d860b=_0x3449cd[_0x2bc266('0x41')]({'plain':!![]}),_0x6c0bcc=_0x2bc266('0x9');return db['UserProfileResource']['destroy']({'where':{'type':_0x6c0bcc,'resourceId':_0x5d860b['id']}})['then'](function(){return _0x3449cd;});})[_0x149277('0x5c')](function(){const _0x36986c=_0x149277;_0x14a505[_0x36986c('0x40')](0xcc)['end']();});};}function handleEntityNotFound(_0x48eed9){return function(_0xf1fc3e){const _0x18e209=a626_0x4140;return!_0xf1fc3e&&_0x48eed9[_0x18e209('0x1e')](0x194),_0xf1fc3e;};}function handleError(_0xd669da,_0x13e302){return _0x13e302=_0x13e302||0x1f4,function(_0x1fcc28){const _0x558cb9=a626_0x4140;logger[_0x558cb9('0x66')](_0x1fcc28[_0x558cb9('0x20')]),_0x1fcc28[_0x558cb9('0x30')]&&delete _0x1fcc28[_0x558cb9('0x30')],_0xd669da[_0x558cb9('0x40')](_0x13e302)[_0x558cb9('0x59')](_0x1fcc28);};}exports[_0x38f888('0x10')]=function(_0xb55f1c,_0x5885a0){const _0x35d1fc=_0x38f888;let _0x3ff714={};const _0xa0cb03={},_0x160adf={'count':0x0,'rows':[]},_0x5ab965=_[_0x35d1fc('0x3')](db['Team'][_0x35d1fc('0x56')],function(_0x155f3a){const _0x4d3666=_0x35d1fc;return{'name':_0x155f3a[_0x4d3666('0x35')],'type':_0x155f3a[_0x4d3666('0x23')]['key']};});_0xa0cb03[_0x35d1fc('0x11')]=_['map'](_0x5ab965,_0x35d1fc('0x30')),_0xa0cb03[_0x35d1fc('0x31')]=_[_0x35d1fc('0x5f')](_0xb55f1c[_0x35d1fc('0x31')]),_0xa0cb03['filters']=_[_0x35d1fc('0x54')](_0xa0cb03[_0x35d1fc('0x11')],_0xa0cb03['query']),_0x3ff714[_0x35d1fc('0x62')]=_[_0x35d1fc('0x54')](_0xa0cb03[_0x35d1fc('0x11')],qs[_0x35d1fc('0x2a')](_0xb55f1c[_0x35d1fc('0x31')][_0x35d1fc('0x2a')])),_0x3ff714[_0x35d1fc('0x62')]=_0x3ff714[_0x35d1fc('0x62')][_0x35d1fc('0x3e')]?_0x3ff714[_0x35d1fc('0x62')]:_0xa0cb03[_0x35d1fc('0x11')];typeof _0xb55f1c[_0x35d1fc('0x31')][_0x35d1fc('0x65')]===_0x35d1fc('0x46')&&(_0x3ff714[_0x35d1fc('0x44')]=qs[_0x35d1fc('0x44')](_0xb55f1c['query']['limit']),_0x3ff714[_0x35d1fc('0x1c')]=qs['offset'](_0xb55f1c[_0x35d1fc('0x31')][_0x35d1fc('0x1c')]));_0x3ff714[_0x35d1fc('0x58')]=qs[_0x35d1fc('0x5')](_0xb55f1c[_0x35d1fc('0x31')][_0x35d1fc('0x5')]),_0x3ff714[_0x35d1fc('0x55')]=qs[_0x35d1fc('0x4c')](_[_0x35d1fc('0x18')](_0xb55f1c[_0x35d1fc('0x31')],_0xa0cb03[_0x35d1fc('0x4c')]),_0x5ab965);_0xb55f1c['query'][_0x35d1fc('0x26')]&&(_0x3ff714[_0x35d1fc('0x55')]=_['merge'](_0x3ff714[_0x35d1fc('0x55')],{[Op['or']]:_[_0x35d1fc('0x3')](_0x5ab965,function(_0x20c9b6){const _0xcdeb61=_0x35d1fc;if(_0x20c9b6['type']!==_0xcdeb61('0x32')){const _0x4fa9fe={};return _0x4fa9fe[_0x20c9b6[_0xcdeb61('0x30')]]={[Op[_0xcdeb61('0x67')]]:'%'+_0xb55f1c[_0xcdeb61('0x31')][_0xcdeb61('0x26')]+'%'},_0x4fa9fe;}})}));_0x3ff714=_[_0x35d1fc('0xf')]({},_0x3ff714,_0xb55f1c[_0x35d1fc('0x6')]);const _0x3c520c={'where':_0x3ff714['where']};return db[_0x35d1fc('0x61')][_0x35d1fc('0x28')](_0x3c520c)['then'](function(_0x232663){const _0x431188=_0x35d1fc;return _0x160adf[_0x431188('0x28')]=_0x232663,_0xb55f1c[_0x431188('0x31')][_0x431188('0x4f')]&&(_0x3ff714[_0x431188('0x49')]=[{'all':!![]}]),db[_0x431188('0x61')][_0x431188('0x2e')](_0x3ff714);})[_0x35d1fc('0x5c')](function(_0x2131be){return _0x160adf['rows']=_0x2131be,_0x160adf;})[_0x35d1fc('0x5c')](respondWithFilteredResult(_0x5885a0,_0x3ff714))[_0x35d1fc('0x3c')](handleError(_0x5885a0,null));},exports[_0x38f888('0x4b')]=function(_0x585698,_0x22508f){const _0x62fb47=_0x38f888;let _0x2c048e={'raw':![],'where':{'id':_0x585698[_0x62fb47('0x45')]['id']}};const _0x59385={};return _0x59385[_0x62fb47('0x11')]=_[_0x62fb47('0x5f')](db['Team']['rawAttributes']),_0x59385[_0x62fb47('0x31')]=_[_0x62fb47('0x5f')](_0x585698[_0x62fb47('0x31')]),_0x59385[_0x62fb47('0x4c')]=_[_0x62fb47('0x54')](_0x59385['model'],_0x59385[_0x62fb47('0x31')]),_0x2c048e[_0x62fb47('0x62')]=_[_0x62fb47('0x54')](_0x59385[_0x62fb47('0x11')],qs[_0x62fb47('0x2a')](_0x585698[_0x62fb47('0x31')][_0x62fb47('0x2a')])),_0x2c048e[_0x62fb47('0x62')]=_0x2c048e['attributes'][_0x62fb47('0x3e')]?_0x2c048e[_0x62fb47('0x62')]:_0x59385[_0x62fb47('0x11')],_0x585698[_0x62fb47('0x31')][_0x62fb47('0x4f')]&&(_0x2c048e[_0x62fb47('0x49')]=[{'all':!![]}]),_0x2c048e=_[_0x62fb47('0xf')]({},_0x2c048e,_0x585698[_0x62fb47('0x6')]),db[_0x62fb47('0x61')][_0x62fb47('0xa')](_0x2c048e)[_0x62fb47('0x5c')](handleEntityNotFound(_0x22508f,null))[_0x62fb47('0x5c')](respondWithResult(_0x22508f,null))[_0x62fb47('0x3c')](handleError(_0x22508f,null));},exports[_0x38f888('0xb')]=function(_0x413e4e,_0x1419b8){const _0x8d4bec=_0x38f888;return db[_0x8d4bec('0x61')][_0x8d4bec('0xb')](_0x413e4e[_0x8d4bec('0x2b')],{})['then'](function(_0x39a882){const _0x1c1b69=_0x8d4bec,_0x3b072e=_0x413e4e['user']['get']({'plain':!![]});if(!_0x3b072e)throw new Error(_0x1c1b69('0x48'));if(_0x3b072e[_0x1c1b69('0x51')]===_0x1c1b69('0x3b')){const _0x4c9165=_0x39a882[_0x1c1b69('0x41')]({'plain':!![]}),_0x25c2a8='Teams';return db[_0x1c1b69('0x8')]['findOne']({'where':{'name':_0x25c2a8,'userProfileId':_0x3b072e[_0x1c1b69('0x0')]},'raw':!![]})['then'](function(_0x10d1c3){const _0x1718a2=_0x1c1b69;return _0x10d1c3&&_0x10d1c3[_0x1718a2('0x17')]===0x0?db[_0x1718a2('0x42')][_0x1718a2('0xb')]({'name':_0x4c9165['name'],'resourceId':_0x4c9165['id'],'type':_0x10d1c3[_0x1718a2('0x30')],'sectionId':_0x10d1c3['id']},{})[_0x1718a2('0x5c')](function(){return _0x39a882;}):_0x39a882;})[_0x1c1b69('0x3c')](function(_0x288619){const _0x489f8a=_0x1c1b69;logger[_0x489f8a('0x66')](_0x489f8a('0x1a'),_0x288619);throw _0x288619;});}return _0x39a882;})['then'](respondWithResult(_0x1419b8,0xc9))['catch'](handleError(_0x1419b8,null));},exports[_0x38f888('0x7')]=function(_0x4e11d4,_0x4b1011){const _0x4dede4=_0x38f888;return _0x4e11d4['body']['id']&&delete _0x4e11d4[_0x4dede4('0x2b')]['id'],db[_0x4dede4('0x61')][_0x4dede4('0xa')]({'where':{'id':_0x4e11d4[_0x4dede4('0x45')]['id']}})[_0x4dede4('0x5c')](handleEntityNotFound(_0x4b1011,null))[_0x4dede4('0x5c')](saveUpdates(_0x4e11d4[_0x4dede4('0x2b')],null))[_0x4dede4('0x5c')](respondWithResult(_0x4b1011,null))['catch'](handleError(_0x4b1011,null));},exports[_0x38f888('0x25')]=function(_0x45c4de,_0x12056a){const _0x131921=_0x38f888;return db['Team']['findOne']({'where':{'id':_0x45c4de[_0x131921('0x45')]['id']}})[_0x131921('0x5c')](handleEntityNotFound(_0x12056a,null))[_0x131921('0x5c')](removeEntity(_0x12056a,null))['catch'](handleError(_0x12056a,null));},exports['getQueues']=function(_0x26a4b1,_0x323f83){const _0x511101=_0x38f888;return db['Team'][_0x511101('0xa')]({'where':{'id':_0x26a4b1[_0x511101('0x45')]['id']}})['then'](handleEntityNotFound(_0x323f83,null))[_0x511101('0x5c')](function(_0x4401eb){const _0x526f61=_0x511101;if(!_0x26a4b1[_0x526f61('0x31')][_0x526f61('0x4a')]||!utils[_0x526f61('0x1')](_0x26a4b1[_0x526f61('0x31')]['channel']))throw new ValidationError('Unknown\x20channel');let _0x9e10ff={};const _0x1db45b={};return _0x1db45b[_0x526f61('0x11')]=_['keys'](db[_['capitalize'](_0x26a4b1['query'][_0x526f61('0x4a')][_0x526f61('0x5a')]())+_0x526f61('0x64')][_0x526f61('0x56')]),_0x1db45b['query']=_[_0x526f61('0x5f')](_0x26a4b1[_0x526f61('0x31')]),_0x1db45b[_0x526f61('0x4c')]=_[_0x526f61('0x54')](_0x1db45b['model'],_0x1db45b[_0x526f61('0x31')]),_0x9e10ff[_0x526f61('0x62')]=_['intersection'](_0x1db45b['model'],qs['fields'](_0x26a4b1[_0x526f61('0x31')][_0x526f61('0x2a')])),_0x9e10ff[_0x526f61('0x62')]=_0x9e10ff['attributes']['length']?_0x9e10ff[_0x526f61('0x62')]:_0x1db45b[_0x526f61('0x11')],_0x9e10ff[_0x526f61('0x44')]=qs['limit'](_0x26a4b1[_0x526f61('0x31')][_0x526f61('0x44')]),_0x9e10ff[_0x526f61('0x1c')]=qs[_0x526f61('0x1c')](_0x26a4b1[_0x526f61('0x31')]['offset']),_0x9e10ff[_0x526f61('0x58')]=qs[_0x526f61('0x5')](_0x26a4b1[_0x526f61('0x31')][_0x526f61('0x5')]),_0x9e10ff[_0x526f61('0x55')]=qs[_0x526f61('0x4c')](_['pick'](_0x26a4b1[_0x526f61('0x31')],_0x1db45b[_0x526f61('0x4c')])),_0x9e10ff=_['merge']({},_0x9e10ff,_0x26a4b1[_0x526f61('0x6')]),_0x4401eb['get'+_[_0x526f61('0x38')](_0x26a4b1[_0x526f61('0x31')][_0x526f61('0x4a')]['toLowerCase']())+'Queues'](_0x9e10ff);})[_0x511101('0x5c')](respondWithResult(_0x323f83,null))[_0x511101('0x3c')](handleError(_0x323f83,null));},exports[_0x38f888('0x53')]=function(_0x54b086,_0x55fe51){const _0x371e4e=_0x38f888;return db[_0x371e4e('0x61')][_0x371e4e('0xa')]({'where':{'id':_0x54b086[_0x371e4e('0x45')]['id']}})[_0x371e4e('0x5c')](function(_0x425a8b){const _0xa6496d=_0x371e4e;if(_0x425a8b){if(!_0x54b086['body'][_0xa6496d('0x4a')]||!utils[_0xa6496d('0x1')](_0x54b086[_0xa6496d('0x2b')][_0xa6496d('0x4a')]))throw new ValidationError(_0xa6496d('0x19'));return _0x425a8b[_0xa6496d('0x1f')+_[_0xa6496d('0x38')](_0x54b086[_0xa6496d('0x2b')][_0xa6496d('0x4a')][_0xa6496d('0x5a')]())+_0xa6496d('0x3a')](_0x54b086[_0xa6496d('0x2b')]['ids']);}return null;})[_0x371e4e('0x5c')](handleEntityNotFound(_0x55fe51,null))[_0x371e4e('0x5c')](respondWithStatusCode(_0x55fe51,null))[_0x371e4e('0x3c')](handleError(_0x55fe51,null));},exports[_0x38f888('0x47')]=function(_0x397fb0,_0x42c3fe){const _0x42dd96=_0x38f888;return db['Team']['findOne']({'where':{'id':_0x397fb0[_0x42dd96('0x45')]['id']}})[_0x42dd96('0x5c')](function(_0x5879e9){const _0x3ec221=_0x42dd96;if(_0x5879e9){if(!_0x397fb0[_0x3ec221('0x31')]['channel']||!utils[_0x3ec221('0x1')](_0x397fb0[_0x3ec221('0x31')][_0x3ec221('0x4a')]))throw new ValidationError(_0x3ec221('0x19'));return _0x5879e9['remove'+_[_0x3ec221('0x38')](_0x397fb0['query'][_0x3ec221('0x4a')][_0x3ec221('0x5a')]())+'Queues'](_0x397fb0['query'][_0x3ec221('0x2d')]);}return null;})[_0x42dd96('0x5c')](handleEntityNotFound(_0x42c3fe,null))[_0x42dd96('0x5c')](respondWithStatusCode(_0x42c3fe,null))[_0x42dd96('0x3c')](handleError(_0x42c3fe,null));},exports[_0x38f888('0x4d')]=function(_0x3b5d55,_0x4ae35b){const _0x36803d=_0x38f888;return db[_0x36803d('0x61')]['findOne']({'where':{'id':_0x3b5d55[_0x36803d('0x45')]['id']}})[_0x36803d('0x5c')](function(_0x589ab7){const _0x4e566a=_0x36803d;if(_0x589ab7){const _0x58ddc8=[_0x4e566a('0xd'),'Chat','Mail',_0x4e566a('0x29'),'Fax',_0x4e566a('0x5e'),_0x4e566a('0x37')];return Promise[_0x4e566a('0x33')](_0x58ddc8,function(_0x41510b){const _0x127d3c=_0x4e566a;return _0x589ab7[_0x127d3c('0x41')+_0x41510b+_0x127d3c('0x3a')]({'attributes':['id',_0x127d3c('0x30')]})[_0x127d3c('0x5c')](function(_0x5ccb9d){const _0xb0db97=_0x127d3c;return Promise[_0xb0db97('0x33')](_0x5ccb9d,function(_0xafca9f){const _0x488ce5=_0xb0db97;return _0xafca9f['addAgents'](_0x3b5d55[_0x488ce5('0x2b')][_0x488ce5('0x2d')])[_0x488ce5('0x5c')](function(){const _0x515830=_0x488ce5;if(_0x41510b===_0x515830('0xd'))return db[_0x515830('0x15')][_0x515830('0x2e')]({'where':{'id':_0x3b5d55['body'][_0x515830('0x2d')]},'attributes':['id',_0x515830('0x30'),_0x515830('0x5d'),_0x515830('0x34'),_0x515830('0x21')],'raw':!![]})['then'](function(_0x3351f1){return Promise['each'](_['filter'](_0x3351f1,{'online':0x1}),function(_0x2d91cc){const _0x28b880=a626_0x4140;return db[_0x28b880('0x2')]['upsert']({'membername':_0x2d91cc[_0x28b880('0x30')],'UserId':_0x2d91cc['id'],'queue_name':_0xafca9f[_0x28b880('0x30')],'VoiceQueueId':_0xafca9f['id'],'interface':_['isNil'](_0x2d91cc[_0x28b880('0x21')])?util['format'](_0x28b880('0x57'),_0x2d91cc['name']):_0x2d91cc[_0x28b880('0x21')],'paused':_0x2d91cc[_0x28b880('0x34')]||![],'penalty':0x0});});});});});})['then'](function(){return _0x589ab7;});})['then'](function(){return _0x589ab7;});}})[_0x36803d('0x5c')](function(_0x464a12){const _0xebb139=_0x36803d;if(_0x464a12)return _0x464a12[_0xebb139('0x4d')](_0x3b5d55[_0xebb139('0x2b')][_0xebb139('0x2d')],{'through':_[_0xebb139('0xc')](_0x3b5d55[_0xebb139('0x2b')],[_0xebb139('0x2d'),'id'])})['then'](function(_0x1e1b0e){const _0x518927=_0xebb139;for(let _0x15e834=0x0;_0x15e834<_0x3b5d55[_0x518927('0x2b')][_0x518927('0x2d')][_0x518927('0x3e')];_0x15e834+=0x1){socket[_0x518927('0x43')](_0x518927('0x39'),{'UserId':_0x3b5d55[_0x518927('0x2b')][_0x518927('0x2d')][_0x15e834],'TeamId':_0x3b5d55[_0x518927('0x45')]['id']});}return _0x1e1b0e;});})[_0x36803d('0x5c')](respondWithResult(_0x4ae35b,null))[_0x36803d('0x3c')](handleError(_0x4ae35b,null));},exports[_0x38f888('0x63')]=function(_0xb365ce,_0x446797){const _0x2ac5a3=_0x38f888;return db['Team'][_0x2ac5a3('0xa')]({'where':{'id':_0xb365ce['params']['id']}})[_0x2ac5a3('0x5c')](handleEntityNotFound(_0x446797,null))[_0x2ac5a3('0x5c')](function(_0x1682d2){const _0x25d573=_0x2ac5a3;if(_0x1682d2)return Promise[_0x25d573('0x33')]([_0x25d573('0x14'),_0x25d573('0x1b'),_0x25d573('0x12'),_0x25d573('0xe'),'fax',_0x25d573('0x69'),_0x25d573('0x3d')],function(_0x59d366){const _0x1e8ed3=_0x25d573;return _0x1682d2[_0x1e8ed3('0x41')+_[_0x1e8ed3('0x38')](_0x59d366)+_0x1e8ed3('0x3a')]({'attributes':['id',_0x1e8ed3('0x30')]})[_0x1e8ed3('0x5c')](function(_0x17cafc){const _0x367d74=_0x1e8ed3;return Promise[_0x367d74('0x33')](_0x17cafc,function(_0x3057d4){const _0x1f4b9f=_0x367d74;return _0x3057d4[_0x1f4b9f('0x63')](_0xb365ce['query'][_0x1f4b9f('0x2d')])['then'](function(){const _0x285f68=_0x1f4b9f;if(_0x59d366===_0x285f68('0x14'))return db['UserVoiceQueueRt'][_0x285f68('0x25')]({'where':{'VoiceQueueId':_0x3057d4['id'],'UserId':_0xb365ce['query'][_0x285f68('0x2d')]}});});});})['then'](function(){return _0x1682d2;});})[_0x25d573('0x5c')](function(){return _0x1682d2;});})['then'](function(_0x53e417){const _0x591151=_0x2ac5a3;if(_0x53e417)return _0x53e417[_0x591151('0x63')](_0xb365ce[_0x591151('0x31')][_0x591151('0x2d')])[_0x591151('0x5c')](function(){const _0x52e356=_0x591151;if(_[_0x52e356('0x2c')](_0xb365ce[_0x52e356('0x31')][_0x52e356('0x2d')]))for(let _0x4a0f72=0x0;_0x4a0f72<_0xb365ce[_0x52e356('0x31')][_0x52e356('0x2d')][_0x52e356('0x3e')];_0x4a0f72+=0x1){socket[_0x52e356('0x43')](_0x52e356('0x13'),{'UserId':Number(_0xb365ce['query']['ids'][_0x4a0f72]),'TeamId':Number(_0xb365ce['params']['id'])});}else socket[_0x52e356('0x43')](_0x52e356('0x13'),{'UserId':Number(_0xb365ce[_0x52e356('0x31')][_0x52e356('0x2d')]),'TeamId':Number(_0xb365ce[_0x52e356('0x45')]['id'])});});})[_0x2ac5a3('0x5c')](respondWithStatusCode(_0x446797,null))['catch'](handleError(_0x446797,null));},exports[_0x38f888('0x16')]=function(_0x4b6cb4,_0x4b41ad){const _0x66ba1a=_0x38f888;let _0x3d2056={};const _0x30bb24={};let _0x506fa2,_0x368f8b;return db[_0x66ba1a('0x61')]['findOne']({'where':{'id':_0x4b6cb4['params']['id']}})[_0x66ba1a('0x5c')](handleEntityNotFound(_0x4b41ad,null))[_0x66ba1a('0x5c')](function(_0xc845d7){const _0x216297=_0x66ba1a;if(_0xc845d7)return _0x506fa2=_0xc845d7,_0x30bb24[_0x216297('0x11')]=_[_0x216297('0x5f')](db[_0x216297('0x15')][_0x216297('0x56')]),_0x30bb24[_0x216297('0x31')]=_['keys'](_0x4b6cb4[_0x216297('0x31')]),_0x30bb24['filters']=_['intersection'](_0x30bb24['model'],_0x30bb24['query']),_0x3d2056['attributes']=_[_0x216297('0x54')](_0x30bb24[_0x216297('0x11')],qs[_0x216297('0x2a')](_0x4b6cb4[_0x216297('0x31')][_0x216297('0x2a')])),_0x3d2056['attributes']=_0x3d2056[_0x216297('0x62')][_0x216297('0x3e')]?_0x3d2056['attributes']:_0x30bb24[_0x216297('0x11')],_0x3d2056[_0x216297('0x58')]=qs[_0x216297('0x5')](_0x4b6cb4['query'][_0x216297('0x5')]),_0x3d2056['where']=qs[_0x216297('0x4c')](_[_0x216297('0x18')](_0x4b6cb4[_0x216297('0x31')],_0x30bb24[_0x216297('0x4c')])),_0x4b6cb4[_0x216297('0x31')][_0x216297('0x26')]&&(_0x3d2056[_0x216297('0x55')]=_[_0x216297('0xf')](_0x3d2056['where'],{[Op['or']]:_['map'](_0x3d2056[_0x216297('0x62')],function(_0x3e35c4){const _0x3138b9=_0x216297,_0x47323e={};return _0x47323e[_0x3e35c4]={[Op[_0x3138b9('0x67')]]:'%'+_0x4b6cb4[_0x3138b9('0x31')][_0x3138b9('0x26')]+'%'},_0x47323e;})})),_0x3d2056=_[_0x216297('0xf')]({},_0x3d2056,_0x4b6cb4[_0x216297('0x6')]),_0x506fa2['getAgents'](_0x3d2056);})[_0x66ba1a('0x5c')](function(_0x5933b4){const _0x43385a=_0x66ba1a;if(_0x5933b4)return _0x368f8b=_0x5933b4[_0x43385a('0x3e')],typeof _0x4b6cb4[_0x43385a('0x31')][_0x43385a('0x65')]===_0x43385a('0x46')&&(_0x3d2056[_0x43385a('0x44')]=qs[_0x43385a('0x44')](_0x4b6cb4[_0x43385a('0x31')]['limit']),_0x3d2056[_0x43385a('0x1c')]=qs['offset'](_0x4b6cb4[_0x43385a('0x31')][_0x43385a('0x1c')])),_0x506fa2[_0x43385a('0x16')](_0x3d2056);})[_0x66ba1a('0x5c')](function(_0xb19624){if(_0xb19624)return _0xb19624?{'count':_0x368f8b,'rows':_0xb19624}:null;})[_0x66ba1a('0x5c')](respondWithResult(_0x4b41ad,null))[_0x66ba1a('0x3c')](handleError(_0x4b41ad,null));};
\ No newline at end of file
+const a626_0x11d6=['openchannel','addAgents','Team','type','api','get','update','omit','order','index','Openchannel','register','name','Mail','Whatsapp','chat','intersection','UserProfileResource','includeAll','UserProfileSection','set','query','count','sms','filter','json','addQueues','filters','destroy','end','voicePause','where','getAgents','../../rediscache','removeAgents','rawAttributes','key','fieldName','stack','like','Voice','whatsapp','Chat','error','emit','capitalize','params','length','map','keys','limit','fax','sort','../../config/utils','upsert','userProfileId','attributes','send','ids','SIP/%s','Unable\x20to\x20retrieve\x20the\x20current\x20user','lodash','nolimit','merge','toLowerCase','include','getQueues','model','catch','then','autoAssociation','offset','channel','findOne','util','./team.socket','UserVoiceQueueRt','user','options','Queues','undefined','create','add','isNil','fields','mail','../../mysqldb','Teams','show','findAll','Queue','removeQueues','Content-Range','userTeam:save','pick','status','interface','sendStatus','userTeam:remove','Unknown\x20channel','body','VIRTUAL','../../config/logger','User','Fax','voice','each','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','isValidChannel'];(function(_0x12b562,_0x11d61c){const _0x49e60e=function(_0x485c97){while(--_0x485c97){_0x12b562['push'](_0x12b562['shift']());}};_0x49e60e(++_0x11d61c);}(a626_0x11d6,0x75));const a626_0x49e6=function(_0x12b562,_0x11d61c){_0x12b562=_0x12b562-0x0;let _0x49e60e=a626_0x11d6[_0x12b562];return _0x49e60e;};const _0x1f4d60=a626_0x49e6;'use strict';const util=require(_0x1f4d60('0x42')),_=require(_0x1f4d60('0x35')),qs=require('../../components/parsers/qs'),logger=require(_0x1f4d60('0x5e'))(_0x1f4d60('0x69')),utils=require(_0x1f4d60('0x2d')),{getSocket}=require(_0x1f4d60('0x19')),socket=getSocket(),db=require(_0x1f4d60('0x4e'))['db'],{Op,ValidationError}=require('sequelize');require(_0x1f4d60('0x43'))[_0x1f4d60('0x3')](socket);function respondWithStatusCode(_0x485c97,_0x3f522d){return _0x3f522d=_0x3f522d||0xcc,function(_0x14d73e){const _0x26bee5=a626_0x49e6;if(_0x14d73e)return _0x485c97[_0x26bee5('0x59')](_0x3f522d);return _0x485c97[_0x26bee5('0x57')](_0x3f522d)['end']();};}function respondWithResult(_0x2e7eb2,_0x2f032a){return _0x2f032a=_0x2f032a||0xc8,function(_0x48aecf){const _0x1274da=a626_0x49e6;if(_0x48aecf)return _0x2e7eb2['status'](_0x2f032a)[_0x1274da('0x11')](_0x48aecf);};}function respondWithFilteredResult(_0x5b166b,_0x35acaa){return function(_0x1e5c93){const _0x28d311=a626_0x49e6;if(_0x1e5c93){const _0x4363f5=_0x1e5c93[_0x28d311('0xe')],_0x40f185=_0x35acaa[_0x28d311('0x3f')];let _0x3bc2e1=_0x35acaa[_0x28d311('0x3f')]+_0x35acaa[_0x28d311('0x2a')],_0x5892b9;return _0x3bc2e1>=_0x4363f5?(_0x3bc2e1=_0x4363f5,_0x5892b9=0xc8):_0x5892b9=0xce,_0x5b166b['status'](_0x5892b9),_0x5b166b[_0x28d311('0xc')](_0x28d311('0x54'),_0x40f185+'-'+_0x3bc2e1+'/'+_0x4363f5)[_0x28d311('0x11')](_0x1e5c93);}return null;};}function saveUpdates(_0x34c2f2){return function(_0x40cdbd){const _0x5e1659=a626_0x49e6;if(_0x40cdbd)return _0x40cdbd[_0x5e1659('0x6b')](_0x34c2f2)[_0x5e1659('0x3d')](function(_0x32df8e){return _0x32df8e;});return null;};}function removeEntity(_0x5d21b8){return function(_0x2d9257){const _0x165b6f=a626_0x49e6;if(_0x2d9257)return _0x2d9257[_0x165b6f('0x14')]()[_0x165b6f('0x3d')](function(){const _0x2c987d=_0x165b6f,_0x451f2a=_0x2d9257['get']({'plain':!![]}),_0x2bf9c3='Teams';return db[_0x2c987d('0x9')]['destroy']({'where':{'type':_0x2bf9c3,'resourceId':_0x451f2a['id']}})[_0x2c987d('0x3d')](function(){return _0x2d9257;});})[_0x165b6f('0x3d')](function(){const _0x1c8117=_0x165b6f;_0x5d21b8[_0x1c8117('0x57')](0xcc)[_0x1c8117('0x15')]();});};}function handleEntityNotFound(_0x5c3f33){return function(_0xacc44a){const _0xa55ee7=a626_0x49e6;return!_0xacc44a&&_0x5c3f33[_0xa55ee7('0x59')](0x194),_0xacc44a;};}function handleError(_0x1776dc,_0x20f16e){return _0x20f16e=_0x20f16e||0x1f4,function(_0x256ed4){const _0x3c6bfe=a626_0x49e6;logger[_0x3c6bfe('0x23')](_0x256ed4[_0x3c6bfe('0x1e')]),_0x256ed4[_0x3c6bfe('0x4')]&&delete _0x256ed4[_0x3c6bfe('0x4')],_0x1776dc[_0x3c6bfe('0x57')](_0x20f16e)[_0x3c6bfe('0x31')](_0x256ed4);};}exports[_0x1f4d60('0x1')]=function(_0xe618b,_0x56bc1e){const _0x1d0bae=_0x1f4d60;let _0x5dbb37={};const _0x52d86d={},_0x1650d4={'count':0x0,'rows':[]},_0x82af82=_[_0x1d0bae('0x28')](db[_0x1d0bae('0x67')]['rawAttributes'],function(_0x306be9){const _0xf1b948=_0x1d0bae;return{'name':_0x306be9[_0xf1b948('0x1d')],'type':_0x306be9[_0xf1b948('0x68')][_0xf1b948('0x1c')]};});_0x52d86d[_0x1d0bae('0x3b')]=_['map'](_0x82af82,_0x1d0bae('0x4')),_0x52d86d['query']=_[_0x1d0bae('0x29')](_0xe618b[_0x1d0bae('0xd')]),_0x52d86d[_0x1d0bae('0x13')]=_[_0x1d0bae('0x8')](_0x52d86d[_0x1d0bae('0x3b')],_0x52d86d[_0x1d0bae('0xd')]),_0x5dbb37[_0x1d0bae('0x30')]=_[_0x1d0bae('0x8')](_0x52d86d[_0x1d0bae('0x3b')],qs[_0x1d0bae('0x4c')](_0xe618b[_0x1d0bae('0xd')][_0x1d0bae('0x4c')])),_0x5dbb37[_0x1d0bae('0x30')]=_0x5dbb37['attributes']['length']?_0x5dbb37['attributes']:_0x52d86d[_0x1d0bae('0x3b')];typeof _0xe618b[_0x1d0bae('0xd')][_0x1d0bae('0x36')]===_0x1d0bae('0x48')&&(_0x5dbb37[_0x1d0bae('0x2a')]=qs[_0x1d0bae('0x2a')](_0xe618b[_0x1d0bae('0xd')][_0x1d0bae('0x2a')]),_0x5dbb37[_0x1d0bae('0x3f')]=qs[_0x1d0bae('0x3f')](_0xe618b[_0x1d0bae('0xd')][_0x1d0bae('0x3f')]));_0x5dbb37[_0x1d0bae('0x0')]=qs[_0x1d0bae('0x2c')](_0xe618b[_0x1d0bae('0xd')][_0x1d0bae('0x2c')]),_0x5dbb37['where']=qs['filters'](_['pick'](_0xe618b[_0x1d0bae('0xd')],_0x52d86d['filters']),_0x82af82);_0xe618b[_0x1d0bae('0xd')][_0x1d0bae('0x10')]&&(_0x5dbb37['where']=_[_0x1d0bae('0x37')](_0x5dbb37[_0x1d0bae('0x17')],{[Op['or']]:_[_0x1d0bae('0x28')](_0x82af82,function(_0x49a3a5){const _0x4aeecd=_0x1d0bae;if(_0x49a3a5[_0x4aeecd('0x68')]!==_0x4aeecd('0x5d')){const _0x3e93fd={};return _0x3e93fd[_0x49a3a5[_0x4aeecd('0x4')]]={[Op[_0x4aeecd('0x1f')]]:'%'+_0xe618b[_0x4aeecd('0xd')][_0x4aeecd('0x10')]+'%'},_0x3e93fd;}})}));_0x5dbb37=_[_0x1d0bae('0x37')]({},_0x5dbb37,_0xe618b[_0x1d0bae('0x46')]);const _0x5bbc1e={'where':_0x5dbb37['where']};return db[_0x1d0bae('0x67')][_0x1d0bae('0xe')](_0x5bbc1e)[_0x1d0bae('0x3d')](function(_0x2d8a55){const _0x3e9da3=_0x1d0bae;return _0x1650d4[_0x3e9da3('0xe')]=_0x2d8a55,_0xe618b[_0x3e9da3('0xd')][_0x3e9da3('0xa')]&&(_0x5dbb37[_0x3e9da3('0x39')]=[{'all':!![]}]),db[_0x3e9da3('0x67')][_0x3e9da3('0x51')](_0x5dbb37);})[_0x1d0bae('0x3d')](function(_0x78da76){return _0x1650d4['rows']=_0x78da76,_0x1650d4;})[_0x1d0bae('0x3d')](respondWithFilteredResult(_0x56bc1e,_0x5dbb37))[_0x1d0bae('0x3c')](handleError(_0x56bc1e,null));},exports[_0x1f4d60('0x50')]=function(_0x4aec16,_0x161022){const _0x1c1c69=_0x1f4d60;let _0x1401a7={'raw':![],'where':{'id':_0x4aec16[_0x1c1c69('0x26')]['id']}};const _0x11d478={};return _0x11d478[_0x1c1c69('0x3b')]=_[_0x1c1c69('0x29')](db[_0x1c1c69('0x67')]['rawAttributes']),_0x11d478[_0x1c1c69('0xd')]=_[_0x1c1c69('0x29')](_0x4aec16[_0x1c1c69('0xd')]),_0x11d478['filters']=_[_0x1c1c69('0x8')](_0x11d478[_0x1c1c69('0x3b')],_0x11d478[_0x1c1c69('0xd')]),_0x1401a7[_0x1c1c69('0x30')]=_[_0x1c1c69('0x8')](_0x11d478['model'],qs[_0x1c1c69('0x4c')](_0x4aec16[_0x1c1c69('0xd')][_0x1c1c69('0x4c')])),_0x1401a7[_0x1c1c69('0x30')]=_0x1401a7[_0x1c1c69('0x30')][_0x1c1c69('0x27')]?_0x1401a7['attributes']:_0x11d478[_0x1c1c69('0x3b')],_0x4aec16[_0x1c1c69('0xd')][_0x1c1c69('0xa')]&&(_0x1401a7[_0x1c1c69('0x39')]=[{'all':!![]}]),_0x1401a7=_['merge']({},_0x1401a7,_0x4aec16[_0x1c1c69('0x46')]),db[_0x1c1c69('0x67')][_0x1c1c69('0x41')](_0x1401a7)[_0x1c1c69('0x3d')](handleEntityNotFound(_0x161022,null))[_0x1c1c69('0x3d')](respondWithResult(_0x161022,null))[_0x1c1c69('0x3c')](handleError(_0x161022,null));},exports[_0x1f4d60('0x49')]=function(_0x56718d,_0x4de24c){const _0x5d6a2d=_0x1f4d60;return db[_0x5d6a2d('0x67')]['create'](_0x56718d['body'],{})['then'](function(_0x191597){const _0x33129d=_0x5d6a2d,_0x26e34d=_0x56718d['user'][_0x33129d('0x6a')]({'plain':!![]});if(!_0x26e34d)throw new Error(_0x33129d('0x34'));if(_0x26e34d['role']===_0x33129d('0x45')){const _0x52ddb7=_0x191597[_0x33129d('0x6a')]({'plain':!![]}),_0xd3370f=_0x33129d('0x4f');return db[_0x33129d('0xb')][_0x33129d('0x41')]({'where':{'name':_0xd3370f,'userProfileId':_0x26e34d[_0x33129d('0x2f')]},'raw':!![]})[_0x33129d('0x3d')](function(_0x4b61d4){const _0x399416=_0x33129d;return _0x4b61d4&&_0x4b61d4[_0x399416('0x3e')]===0x0?db[_0x399416('0x9')]['create']({'name':_0x52ddb7[_0x399416('0x4')],'resourceId':_0x52ddb7['id'],'type':_0x4b61d4[_0x399416('0x4')],'sectionId':_0x4b61d4['id']},{})['then'](function(){return _0x191597;}):_0x191597;})[_0x33129d('0x3c')](function(_0x21b358){const _0x622c7e=_0x33129d;logger['error'](_0x622c7e('0x63'),_0x21b358);throw _0x21b358;});}return _0x191597;})[_0x5d6a2d('0x3d')](respondWithResult(_0x4de24c,0xc9))[_0x5d6a2d('0x3c')](handleError(_0x4de24c,null));},exports[_0x1f4d60('0x6b')]=function(_0x27b9c7,_0xa1ed5b){const _0x5a9620=_0x1f4d60;return _0x27b9c7[_0x5a9620('0x5c')]['id']&&delete _0x27b9c7[_0x5a9620('0x5c')]['id'],db[_0x5a9620('0x67')]['findOne']({'where':{'id':_0x27b9c7[_0x5a9620('0x26')]['id']}})[_0x5a9620('0x3d')](handleEntityNotFound(_0xa1ed5b,null))['then'](saveUpdates(_0x27b9c7['body'],null))['then'](respondWithResult(_0xa1ed5b,null))[_0x5a9620('0x3c')](handleError(_0xa1ed5b,null));},exports[_0x1f4d60('0x14')]=function(_0x3c3a8d,_0x4044c3){const _0x230c26=_0x1f4d60;return db[_0x230c26('0x67')]['findOne']({'where':{'id':_0x3c3a8d[_0x230c26('0x26')]['id']}})[_0x230c26('0x3d')](handleEntityNotFound(_0x4044c3,null))['then'](removeEntity(_0x4044c3,null))[_0x230c26('0x3c')](handleError(_0x4044c3,null));},exports[_0x1f4d60('0x3a')]=function(_0x4d9842,_0x22cd46){const _0x1e7307=_0x1f4d60;return db[_0x1e7307('0x67')]['findOne']({'where':{'id':_0x4d9842['params']['id']}})[_0x1e7307('0x3d')](handleEntityNotFound(_0x22cd46,null))[_0x1e7307('0x3d')](function(_0x4c054e){const _0x23c76f=_0x1e7307;if(!_0x4d9842[_0x23c76f('0xd')][_0x23c76f('0x40')]||!utils[_0x23c76f('0x64')](_0x4d9842[_0x23c76f('0xd')][_0x23c76f('0x40')]))throw new ValidationError(_0x23c76f('0x5b'));let _0x5d5c59={};const _0x3f8b30={};return _0x3f8b30[_0x23c76f('0x3b')]=_[_0x23c76f('0x29')](db[_[_0x23c76f('0x25')](_0x4d9842[_0x23c76f('0xd')][_0x23c76f('0x40')][_0x23c76f('0x38')]())+_0x23c76f('0x52')][_0x23c76f('0x1b')]),_0x3f8b30[_0x23c76f('0xd')]=_[_0x23c76f('0x29')](_0x4d9842[_0x23c76f('0xd')]),_0x3f8b30[_0x23c76f('0x13')]=_['intersection'](_0x3f8b30[_0x23c76f('0x3b')],_0x3f8b30[_0x23c76f('0xd')]),_0x5d5c59[_0x23c76f('0x30')]=_[_0x23c76f('0x8')](_0x3f8b30['model'],qs[_0x23c76f('0x4c')](_0x4d9842[_0x23c76f('0xd')][_0x23c76f('0x4c')])),_0x5d5c59[_0x23c76f('0x30')]=_0x5d5c59['attributes'][_0x23c76f('0x27')]?_0x5d5c59[_0x23c76f('0x30')]:_0x3f8b30[_0x23c76f('0x3b')],_0x5d5c59[_0x23c76f('0x2a')]=qs[_0x23c76f('0x2a')](_0x4d9842[_0x23c76f('0xd')]['limit']),_0x5d5c59['offset']=qs[_0x23c76f('0x3f')](_0x4d9842[_0x23c76f('0xd')]['offset']),_0x5d5c59[_0x23c76f('0x0')]=qs[_0x23c76f('0x2c')](_0x4d9842[_0x23c76f('0xd')]['sort']),_0x5d5c59[_0x23c76f('0x17')]=qs[_0x23c76f('0x13')](_[_0x23c76f('0x56')](_0x4d9842['query'],_0x3f8b30[_0x23c76f('0x13')])),_0x5d5c59=_['merge']({},_0x5d5c59,_0x4d9842['options']),_0x4c054e[_0x23c76f('0x6a')+_[_0x23c76f('0x25')](_0x4d9842[_0x23c76f('0xd')][_0x23c76f('0x40')][_0x23c76f('0x38')]())+_0x23c76f('0x47')](_0x5d5c59);})[_0x1e7307('0x3d')](respondWithResult(_0x22cd46,null))['catch'](handleError(_0x22cd46,null));},exports[_0x1f4d60('0x12')]=function(_0x5281bd,_0x300a3e){const _0x27adc6=_0x1f4d60;return db[_0x27adc6('0x67')]['findOne']({'where':{'id':_0x5281bd[_0x27adc6('0x26')]['id']}})[_0x27adc6('0x3d')](function(_0x563ebd){const _0x5043d1=_0x27adc6;if(_0x563ebd){if(!_0x5281bd[_0x5043d1('0x5c')]['channel']||!utils['isValidChannel'](_0x5281bd[_0x5043d1('0x5c')]['channel']))throw new ValidationError('Unknown\x20channel');return _0x563ebd[_0x5043d1('0x4a')+_[_0x5043d1('0x25')](_0x5281bd[_0x5043d1('0x5c')][_0x5043d1('0x40')][_0x5043d1('0x38')]())+_0x5043d1('0x47')](_0x5281bd[_0x5043d1('0x5c')][_0x5043d1('0x32')]);}return null;})[_0x27adc6('0x3d')](handleEntityNotFound(_0x300a3e,null))['then'](respondWithStatusCode(_0x300a3e,null))[_0x27adc6('0x3c')](handleError(_0x300a3e,null));},exports[_0x1f4d60('0x53')]=function(_0x212c9d,_0x39cc23){const _0x2f7e01=_0x1f4d60;return db[_0x2f7e01('0x67')][_0x2f7e01('0x41')]({'where':{'id':_0x212c9d[_0x2f7e01('0x26')]['id']}})[_0x2f7e01('0x3d')](function(_0x1de788){const _0x5f05bc=_0x2f7e01;if(_0x1de788){if(!_0x212c9d[_0x5f05bc('0xd')][_0x5f05bc('0x40')]||!utils[_0x5f05bc('0x64')](_0x212c9d[_0x5f05bc('0xd')][_0x5f05bc('0x40')]))throw new ValidationError('Unknown\x20channel');return _0x1de788['remove'+_[_0x5f05bc('0x25')](_0x212c9d[_0x5f05bc('0xd')][_0x5f05bc('0x40')]['toLowerCase']())+_0x5f05bc('0x47')](_0x212c9d[_0x5f05bc('0xd')][_0x5f05bc('0x32')]);}return null;})[_0x2f7e01('0x3d')](handleEntityNotFound(_0x39cc23,null))[_0x2f7e01('0x3d')](respondWithStatusCode(_0x39cc23,null))[_0x2f7e01('0x3c')](handleError(_0x39cc23,null));},exports[_0x1f4d60('0x66')]=function(_0x10d8ab,_0x28d8ba){const _0x54b8a5=_0x1f4d60;return db[_0x54b8a5('0x67')][_0x54b8a5('0x41')]({'where':{'id':_0x10d8ab[_0x54b8a5('0x26')]['id']}})[_0x54b8a5('0x3d')](function(_0x25e449){const _0x5a733c=_0x54b8a5;if(_0x25e449){const _0x1ba964=['Voice',_0x5a733c('0x22'),_0x5a733c('0x5'),'Sms',_0x5a733c('0x60'),_0x5a733c('0x2'),_0x5a733c('0x6')];return Promise['each'](_0x1ba964,function(_0x1e5976){const _0x5032f8=_0x5a733c;return _0x25e449[_0x5032f8('0x6a')+_0x1e5976+_0x5032f8('0x47')]({'attributes':['id',_0x5032f8('0x4')]})[_0x5032f8('0x3d')](function(_0x56dd04){const _0x4e51ee=_0x5032f8;return Promise[_0x4e51ee('0x62')](_0x56dd04,function(_0x42368f){const _0x47a95c=_0x4e51ee;return _0x42368f[_0x47a95c('0x66')](_0x10d8ab[_0x47a95c('0x5c')]['ids'])[_0x47a95c('0x3d')](function(){const _0x320f70=_0x47a95c;if(_0x1e5976===_0x320f70('0x20'))return db[_0x320f70('0x5f')][_0x320f70('0x51')]({'where':{'id':_0x10d8ab[_0x320f70('0x5c')][_0x320f70('0x32')]},'attributes':['id',_0x320f70('0x4'),'online',_0x320f70('0x16'),_0x320f70('0x58')],'raw':!![]})[_0x320f70('0x3d')](function(_0x3540a3){const _0x210a84=_0x320f70;return Promise[_0x210a84('0x62')](_[_0x210a84('0x10')](_0x3540a3,{'online':0x1}),function(_0x2ffcc0){const _0x3f7da9=_0x210a84;return db[_0x3f7da9('0x44')][_0x3f7da9('0x2e')]({'membername':_0x2ffcc0[_0x3f7da9('0x4')],'UserId':_0x2ffcc0['id'],'queue_name':_0x42368f['name'],'VoiceQueueId':_0x42368f['id'],'interface':_[_0x3f7da9('0x4b')](_0x2ffcc0[_0x3f7da9('0x58')])?util['format'](_0x3f7da9('0x33'),_0x2ffcc0[_0x3f7da9('0x4')]):_0x2ffcc0[_0x3f7da9('0x58')],'paused':_0x2ffcc0[_0x3f7da9('0x16')]||![],'penalty':0x0});});});});});})[_0x5032f8('0x3d')](function(){return _0x25e449;});})[_0x5a733c('0x3d')](function(){return _0x25e449;});}})[_0x54b8a5('0x3d')](function(_0x37579b){const _0x4268ea=_0x54b8a5;if(_0x37579b)return _0x37579b['addAgents'](_0x10d8ab[_0x4268ea('0x5c')][_0x4268ea('0x32')],{'through':_[_0x4268ea('0x6c')](_0x10d8ab[_0x4268ea('0x5c')],[_0x4268ea('0x32'),'id'])})['then'](function(_0x5b452d){const _0xeee95c=_0x4268ea;for(let _0x125924=0x0;_0x125924<_0x10d8ab['body'][_0xeee95c('0x32')]['length'];_0x125924+=0x1){socket['emit'](_0xeee95c('0x55'),{'UserId':_0x10d8ab['body'][_0xeee95c('0x32')][_0x125924],'TeamId':_0x10d8ab[_0xeee95c('0x26')]['id']});}return _0x5b452d;});})[_0x54b8a5('0x3d')](respondWithResult(_0x28d8ba,null))[_0x54b8a5('0x3c')](handleError(_0x28d8ba,null));},exports['removeAgents']=function(_0x483585,_0x366cbc){const _0x56f41e=_0x1f4d60;return db['Team'][_0x56f41e('0x41')]({'where':{'id':_0x483585[_0x56f41e('0x26')]['id']}})[_0x56f41e('0x3d')](handleEntityNotFound(_0x366cbc,null))['then'](function(_0x1cca24){const _0x4295c8=_0x56f41e;if(_0x1cca24)return Promise['each'](['voice',_0x4295c8('0x7'),_0x4295c8('0x4d'),_0x4295c8('0xf'),_0x4295c8('0x2b'),_0x4295c8('0x65'),_0x4295c8('0x21')],function(_0x2b4271){const _0x547c6e=_0x4295c8;return _0x1cca24[_0x547c6e('0x6a')+_[_0x547c6e('0x25')](_0x2b4271)+_0x547c6e('0x47')]({'attributes':['id','name']})[_0x547c6e('0x3d')](function(_0x28c59d){const _0x82eb3d=_0x547c6e;return Promise[_0x82eb3d('0x62')](_0x28c59d,function(_0x32e723){const _0x2b44a1=_0x82eb3d;return _0x32e723[_0x2b44a1('0x1a')](_0x483585[_0x2b44a1('0xd')][_0x2b44a1('0x32')])[_0x2b44a1('0x3d')](function(){const _0xe802e1=_0x2b44a1;if(_0x2b4271===_0xe802e1('0x61'))return db[_0xe802e1('0x44')][_0xe802e1('0x14')]({'where':{'VoiceQueueId':_0x32e723['id'],'UserId':_0x483585[_0xe802e1('0xd')][_0xe802e1('0x32')]}});});});})[_0x547c6e('0x3d')](function(){return _0x1cca24;});})['then'](function(){return _0x1cca24;});})['then'](function(_0x4a7cfb){const _0xb89ddb=_0x56f41e;if(_0x4a7cfb)return _0x4a7cfb['removeAgents'](_0x483585[_0xb89ddb('0xd')][_0xb89ddb('0x32')])[_0xb89ddb('0x3d')](function(){const _0x231b66=_0xb89ddb;if(_['isArray'](_0x483585[_0x231b66('0xd')]['ids']))for(let _0x2bdd4a=0x0;_0x2bdd4a<_0x483585[_0x231b66('0xd')][_0x231b66('0x32')]['length'];_0x2bdd4a+=0x1){socket[_0x231b66('0x24')](_0x231b66('0x5a'),{'UserId':Number(_0x483585[_0x231b66('0xd')][_0x231b66('0x32')][_0x2bdd4a]),'TeamId':Number(_0x483585[_0x231b66('0x26')]['id'])});}else socket[_0x231b66('0x24')](_0x231b66('0x5a'),{'UserId':Number(_0x483585[_0x231b66('0xd')][_0x231b66('0x32')]),'TeamId':Number(_0x483585['params']['id'])});});})[_0x56f41e('0x3d')](respondWithStatusCode(_0x366cbc,null))[_0x56f41e('0x3c')](handleError(_0x366cbc,null));},exports[_0x1f4d60('0x18')]=function(_0x1f6180,_0x32b4eb){const _0x5c67f4=_0x1f4d60;let _0x6a067b={};const _0x332243={};let _0x22da9a,_0x4a0273;return db[_0x5c67f4('0x67')]['findOne']({'where':{'id':_0x1f6180[_0x5c67f4('0x26')]['id']}})['then'](handleEntityNotFound(_0x32b4eb,null))[_0x5c67f4('0x3d')](function(_0x28fc5e){const _0x4f2c5d=_0x5c67f4;if(_0x28fc5e)return _0x22da9a=_0x28fc5e,_0x332243[_0x4f2c5d('0x3b')]=_[_0x4f2c5d('0x29')](db[_0x4f2c5d('0x5f')][_0x4f2c5d('0x1b')]),_0x332243[_0x4f2c5d('0xd')]=_[_0x4f2c5d('0x29')](_0x1f6180[_0x4f2c5d('0xd')]),_0x332243[_0x4f2c5d('0x13')]=_[_0x4f2c5d('0x8')](_0x332243[_0x4f2c5d('0x3b')],_0x332243[_0x4f2c5d('0xd')]),_0x6a067b[_0x4f2c5d('0x30')]=_[_0x4f2c5d('0x8')](_0x332243[_0x4f2c5d('0x3b')],qs['fields'](_0x1f6180[_0x4f2c5d('0xd')][_0x4f2c5d('0x4c')])),_0x6a067b[_0x4f2c5d('0x30')]=_0x6a067b[_0x4f2c5d('0x30')]['length']?_0x6a067b[_0x4f2c5d('0x30')]:_0x332243['model'],_0x6a067b[_0x4f2c5d('0x0')]=qs[_0x4f2c5d('0x2c')](_0x1f6180[_0x4f2c5d('0xd')][_0x4f2c5d('0x2c')]),_0x6a067b[_0x4f2c5d('0x17')]=qs[_0x4f2c5d('0x13')](_[_0x4f2c5d('0x56')](_0x1f6180[_0x4f2c5d('0xd')],_0x332243['filters'])),_0x1f6180[_0x4f2c5d('0xd')][_0x4f2c5d('0x10')]&&(_0x6a067b[_0x4f2c5d('0x17')]=_[_0x4f2c5d('0x37')](_0x6a067b['where'],{[Op['or']]:_[_0x4f2c5d('0x28')](_0x6a067b['attributes'],function(_0xc4fa4e){const _0x12d922=_0x4f2c5d,_0x19f1af={};return _0x19f1af[_0xc4fa4e]={[Op[_0x12d922('0x1f')]]:'%'+_0x1f6180[_0x12d922('0xd')][_0x12d922('0x10')]+'%'},_0x19f1af;})})),_0x6a067b=_[_0x4f2c5d('0x37')]({},_0x6a067b,_0x1f6180[_0x4f2c5d('0x46')]),_0x22da9a[_0x4f2c5d('0x18')](_0x6a067b);})[_0x5c67f4('0x3d')](function(_0xace23a){const _0x59646f=_0x5c67f4;if(_0xace23a)return _0x4a0273=_0xace23a['length'],typeof _0x1f6180[_0x59646f('0xd')]['nolimit']===_0x59646f('0x48')&&(_0x6a067b['limit']=qs[_0x59646f('0x2a')](_0x1f6180['query']['limit']),_0x6a067b['offset']=qs[_0x59646f('0x3f')](_0x1f6180[_0x59646f('0xd')]['offset'])),_0x22da9a['getAgents'](_0x6a067b);})[_0x5c67f4('0x3d')](function(_0x483444){if(_0x483444)return _0x483444?{'count':_0x4a0273,'rows':_0x483444}:null;})[_0x5c67f4('0x3d')](respondWithResult(_0x32b4eb,null))[_0x5c67f4('0x3c')](handleError(_0x32b4eb,null));};
\ No newline at end of file