Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / api / team / team.controller.js
index b09b1ad..6ca4675 100644 (file)
@@ -1 +1 @@
-const a749_0x1dde=['isValidChannel','type','UserProfileSection','removeAgents','order','create','offset','sms','interface','userProfileId','User','autoAssociation','then','../../config/logger','fax','role','../../rediscache','mail','name','capitalize','status','Queues','Unknown\x20channel','isNil','merge','Teams','fields','fieldName','./team.socket','lodash','stack','openchannel','filter','map','end','rawAttributes','attributes','voicePause','includeAll','params','user','chat','addQueues','options','userTeam:save','toLowerCase','Unable\x20to\x20retrieve\x20the\x20current\x20user','pick','findAll','../../components/parsers/qs','set','nolimit','like','removeQueues','UserProfileResource','voice','Team','util','count','update','remove','../../mysqldb','all','online','intersection','getQueues','upsert','filters','body','undefined','sort','whatsapp','destroy','addAgents','emit','where','channel','error','include','sendStatus','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','get','keys','findOne','limit','userTeam:remove','length','model','Queue','VIRTUAL','json','api','UserVoiceQueueRt','catch','ids','getAgents','key','query'];(function(_0x4ed498,_0x2a8e34){const _0x1dded0=function(_0x3cb849){while(--_0x3cb849){_0x4ed498['push'](_0x4ed498['shift']());}};_0x1dded0(++_0x2a8e34);}(a749_0x1dde,0x18c));const a749_0x3cb8=function(_0x4ed498,_0x2a8e34){_0x4ed498=_0x4ed498-0x1df;let _0x1dded0=a749_0x1dde[_0x4ed498];return _0x1dded0;};const a749_0x5ea838=a749_0x3cb8;'use strict';const util=require(a749_0x5ea838(0x214)),_=require(a749_0x5ea838(0x1f8)),qs=require(a749_0x5ea838(0x20c)),logger=require(a749_0x5ea838(0x1e8))(a749_0x5ea838(0x236)),utils=require('../../config/utils'),{getSocket}=require(a749_0x5ea838(0x1eb)),socket=getSocket(),{db}=require(a749_0x5ea838(0x218)),{Op,ValidationError}=require('sequelize');require(a749_0x5ea838(0x1f7))['register'](socket);function respondWithStatusCode(_0x256d03,_0x1cbfec){return _0x1cbfec=_0x1cbfec||0xcc,function(_0x58b448){const _0x3ce885=a749_0x3cb8;if(_0x58b448)return _0x256d03[_0x3ce885(0x22a)](_0x1cbfec);return _0x256d03[_0x3ce885(0x1ef)](_0x1cbfec)[_0x3ce885(0x1fd)]();};}function respondWithResult(_0x3d2df3,_0x288e44){return _0x288e44=_0x288e44||0xc8,function(_0x385656){const _0xc121ef=a749_0x3cb8;if(_0x385656)return _0x3d2df3['status'](_0x288e44)[_0xc121ef(0x235)](_0x385656);};}function respondWithFilteredResult(_0x7aa287,_0xc0764b){return function(_0x1b761a){const _0x4aab4a=a749_0x3cb8;if(_0x1b761a){const _0xd4f03f=_0x1b761a['count'],_0x4f4d2f=_0xc0764b[_0x4aab4a(0x1e1)];let _0x3062da=_0xc0764b['offset']+_0xc0764b[_0x4aab4a(0x22f)],_0x28a883;return _0x3062da>=_0xd4f03f?(_0x3062da=_0xd4f03f,_0x28a883=0xc8):_0x28a883=0xce,_0x7aa287[_0x4aab4a(0x1ef)](_0x28a883),_0x7aa287[_0x4aab4a(0x20d)]('Content-Range',_0x4f4d2f+'-'+_0x3062da+'/'+_0xd4f03f)['json'](_0x1b761a);}return null;};}function saveUpdates(_0x153b0a){return function(_0x1bdfd5){const _0xc3cc7a=a749_0x3cb8;if(_0x1bdfd5)return _0x1bdfd5['update'](_0x153b0a)[_0xc3cc7a(0x1e7)](function(_0x58dd13){return _0x58dd13;});return null;};}function removeEntity(_0xec0584){return function(_0x2e078e){const _0x4d17a8=a749_0x3cb8;if(_0x2e078e)return _0x2e078e[_0x4d17a8(0x223)]()[_0x4d17a8(0x1e7)](function(){const _0x49f97f=_0x4d17a8,_0x1939db=_0x2e078e[_0x49f97f(0x22c)]({'plain':!![]}),_0x3bb024=_0x49f97f(0x1f4);return db[_0x49f97f(0x211)][_0x49f97f(0x223)]({'where':{'type':_0x3bb024,'resourceId':_0x1939db['id']}})[_0x49f97f(0x1e7)](function(){return _0x2e078e;});})['then'](function(){const _0x44011d=_0x4d17a8;_0xec0584[_0x44011d(0x1ef)](0xcc)['end']();});};}function handleEntityNotFound(_0x2b6954){return function(_0xbaacb7){const _0xa17345=a749_0x3cb8;return!_0xbaacb7&&_0x2b6954[_0xa17345(0x22a)](0x194),_0xbaacb7;};}function handleError(_0x220256,_0x1752b4){return _0x1752b4=_0x1752b4||0x1f4,function(_0xd0bf29){const _0x57aef8=a749_0x3cb8;logger['error'](_0xd0bf29[_0x57aef8(0x1f9)]),_0xd0bf29['name']&&delete _0xd0bf29['name'],_0x220256[_0x57aef8(0x1ef)](_0x1752b4)['send'](_0xd0bf29);};}exports['index']=function(_0x4fd1f6,_0x5f5d96){const _0x46ff35=a749_0x5ea838;let _0x1e2912={};const _0x5e56c0={},_0x24353a={'count':0x0,'rows':[]},_0x447efe=_[_0x46ff35(0x1fc)](db[_0x46ff35(0x213)][_0x46ff35(0x1fe)],function(_0x5ed9b6){const _0x59c8be=_0x46ff35;return{'name':_0x5ed9b6[_0x59c8be(0x1f6)],'type':_0x5ed9b6[_0x59c8be(0x23e)][_0x59c8be(0x23b)]};});_0x5e56c0[_0x46ff35(0x232)]=_['map'](_0x447efe,_0x46ff35(0x1ed)),_0x5e56c0[_0x46ff35(0x23c)]=_[_0x46ff35(0x22d)](_0x4fd1f6[_0x46ff35(0x23c)]),_0x5e56c0[_0x46ff35(0x21e)]=_[_0x46ff35(0x21b)](_0x5e56c0[_0x46ff35(0x232)],_0x5e56c0[_0x46ff35(0x23c)]),_0x1e2912[_0x46ff35(0x1ff)]=_[_0x46ff35(0x21b)](_0x5e56c0['model'],qs[_0x46ff35(0x1f5)](_0x4fd1f6[_0x46ff35(0x23c)][_0x46ff35(0x1f5)])),_0x1e2912[_0x46ff35(0x1ff)]=_0x1e2912['attributes'][_0x46ff35(0x231)]?_0x1e2912[_0x46ff35(0x1ff)]:_0x5e56c0[_0x46ff35(0x232)];typeof _0x4fd1f6[_0x46ff35(0x23c)][_0x46ff35(0x20e)]===_0x46ff35(0x220)&&(_0x1e2912[_0x46ff35(0x22f)]=qs[_0x46ff35(0x22f)](_0x4fd1f6['query'][_0x46ff35(0x22f)]),_0x1e2912['offset']=qs[_0x46ff35(0x1e1)](_0x4fd1f6[_0x46ff35(0x23c)]['offset']));_0x1e2912[_0x46ff35(0x1df)]=qs[_0x46ff35(0x221)](_0x4fd1f6[_0x46ff35(0x23c)][_0x46ff35(0x221)]),_0x1e2912[_0x46ff35(0x226)]=qs[_0x46ff35(0x21e)](_['pick'](_0x4fd1f6[_0x46ff35(0x23c)],_0x5e56c0[_0x46ff35(0x21e)]),_0x447efe);_0x4fd1f6[_0x46ff35(0x23c)]['filter']&&(_0x1e2912['where']=_[_0x46ff35(0x1f3)](_0x1e2912[_0x46ff35(0x226)],{[Op['or']]:_[_0x46ff35(0x1fc)](_0x447efe,function(_0xb5e67a){const _0x3f9ce9=_0x46ff35;if(_0xb5e67a[_0x3f9ce9(0x23e)]!==_0x3f9ce9(0x234)){const _0x4513c0={};return _0x4513c0[_0xb5e67a['name']]={[Op[_0x3f9ce9(0x20f)]]:'%'+_0x4fd1f6[_0x3f9ce9(0x23c)][_0x3f9ce9(0x1fb)]+'%'},_0x4513c0;}})}));_0x1e2912=_['merge']({},_0x1e2912,_0x4fd1f6[_0x46ff35(0x206)]);const _0x18180f={'where':_0x1e2912[_0x46ff35(0x226)]};return db[_0x46ff35(0x213)][_0x46ff35(0x215)](_0x18180f)['then'](function(_0x46b975){const _0x1abff7=_0x46ff35;return _0x24353a[_0x1abff7(0x215)]=_0x46b975,_0x4fd1f6[_0x1abff7(0x23c)][_0x1abff7(0x201)]&&(_0x1e2912['include']=[{'all':!![]}]),db['Team'][_0x1abff7(0x20b)](_0x1e2912);})[_0x46ff35(0x1e7)](function(_0x21ffce){return _0x24353a['rows']=_0x21ffce,_0x24353a;})['then'](respondWithFilteredResult(_0x5f5d96,_0x1e2912))[_0x46ff35(0x238)](handleError(_0x5f5d96,null));},exports['show']=function(_0x1d0d7c,_0x4ae4f6){const _0x5ea5fe=a749_0x5ea838;let _0x464995={'raw':![],'where':{'id':_0x1d0d7c[_0x5ea5fe(0x202)]['id']}};const _0x4350e1={};return _0x4350e1[_0x5ea5fe(0x232)]=_['keys'](db[_0x5ea5fe(0x213)][_0x5ea5fe(0x1fe)]),_0x4350e1[_0x5ea5fe(0x23c)]=_[_0x5ea5fe(0x22d)](_0x1d0d7c[_0x5ea5fe(0x23c)]),_0x4350e1[_0x5ea5fe(0x21e)]=_[_0x5ea5fe(0x21b)](_0x4350e1['model'],_0x4350e1['query']),_0x464995[_0x5ea5fe(0x1ff)]=_['intersection'](_0x4350e1[_0x5ea5fe(0x232)],qs[_0x5ea5fe(0x1f5)](_0x1d0d7c['query'][_0x5ea5fe(0x1f5)])),_0x464995[_0x5ea5fe(0x1ff)]=_0x464995['attributes'][_0x5ea5fe(0x231)]?_0x464995[_0x5ea5fe(0x1ff)]:_0x4350e1[_0x5ea5fe(0x232)],_0x1d0d7c[_0x5ea5fe(0x23c)][_0x5ea5fe(0x201)]&&(_0x464995[_0x5ea5fe(0x229)]=[{'all':!![]}]),_0x464995=_[_0x5ea5fe(0x1f3)]({},_0x464995,_0x1d0d7c[_0x5ea5fe(0x206)]),db[_0x5ea5fe(0x213)][_0x5ea5fe(0x22e)](_0x464995)[_0x5ea5fe(0x1e7)](handleEntityNotFound(_0x4ae4f6,null))['then'](respondWithResult(_0x4ae4f6,null))[_0x5ea5fe(0x238)](handleError(_0x4ae4f6,null));},exports[a749_0x5ea838(0x1e0)]=function(_0x2ad389,_0x122ada){const _0x178529=a749_0x5ea838;return db[_0x178529(0x213)]['create'](_0x2ad389['body'],{})[_0x178529(0x1e7)](function(_0x4d1492){const _0x5649aa=_0x178529,_0x2287af=_0x2ad389['user']['get']({'plain':!![]});if(!_0x2287af)throw new Error(_0x5649aa(0x209));if(_0x2287af[_0x5649aa(0x1ea)]===_0x5649aa(0x203)){const _0x33a4c4=_0x4d1492['get']({'plain':!![]}),_0x520fff=_0x5649aa(0x1f4);return db[_0x5649aa(0x23f)][_0x5649aa(0x22e)]({'where':{'name':_0x520fff,'userProfileId':_0x2287af[_0x5649aa(0x1e4)]},'raw':!![]})['then'](function(_0x3c09d4){const _0x362555=_0x5649aa;return _0x3c09d4&&_0x3c09d4[_0x362555(0x1e6)]===0x0?db[_0x362555(0x211)][_0x362555(0x1e0)]({'name':_0x33a4c4[_0x362555(0x1ed)],'resourceId':_0x33a4c4['id'],'type':_0x3c09d4['name'],'sectionId':_0x3c09d4['id']},{})['then'](function(){return _0x4d1492;}):_0x4d1492;})[_0x5649aa(0x238)](function(_0x22e082){const _0x2e6b71=_0x5649aa;logger[_0x2e6b71(0x228)](_0x2e6b71(0x22b),_0x22e082);throw _0x22e082;});}return _0x4d1492;})[_0x178529(0x1e7)](respondWithResult(_0x122ada,0xc9))['catch'](handleError(_0x122ada,null));},exports[a749_0x5ea838(0x216)]=function(_0xa163f6,_0x126e79){const _0x5207ba=a749_0x5ea838;return _0xa163f6[_0x5207ba(0x21f)]['id']&&delete _0xa163f6[_0x5207ba(0x21f)]['id'],db[_0x5207ba(0x213)]['findOne']({'where':{'id':_0xa163f6[_0x5207ba(0x202)]['id']}})[_0x5207ba(0x1e7)](handleEntityNotFound(_0x126e79,null))[_0x5207ba(0x1e7)](saveUpdates(_0xa163f6[_0x5207ba(0x21f)],null))[_0x5207ba(0x1e7)](respondWithResult(_0x126e79,null))[_0x5207ba(0x238)](handleError(_0x126e79,null));},exports[a749_0x5ea838(0x223)]=function(_0x50b648,_0x32f6d7){const _0x16ec77=a749_0x5ea838;return db[_0x16ec77(0x213)][_0x16ec77(0x22e)]({'where':{'id':_0x50b648[_0x16ec77(0x202)]['id']}})[_0x16ec77(0x1e7)](handleEntityNotFound(_0x32f6d7,null))[_0x16ec77(0x1e7)](removeEntity(_0x32f6d7,null))[_0x16ec77(0x238)](handleError(_0x32f6d7,null));},exports[a749_0x5ea838(0x21c)]=function(_0x23b1bd,_0x19930a){const _0x50a344=a749_0x5ea838;return db[_0x50a344(0x213)][_0x50a344(0x22e)]({'where':{'id':_0x23b1bd['params']['id']}})['then'](handleEntityNotFound(_0x19930a,null))[_0x50a344(0x1e7)](function(_0x938e9d){const _0x54c05c=_0x50a344;if(!_0x23b1bd[_0x54c05c(0x23c)][_0x54c05c(0x227)]||!utils[_0x54c05c(0x23d)](_0x23b1bd['query'][_0x54c05c(0x227)]))throw new ValidationError(_0x54c05c(0x1f1));let _0x11e70d={};const _0x5156a2={};return _0x5156a2[_0x54c05c(0x232)]=_[_0x54c05c(0x22d)](db[_[_0x54c05c(0x1ee)](_0x23b1bd[_0x54c05c(0x23c)][_0x54c05c(0x227)]['toLowerCase']())+_0x54c05c(0x233)]['rawAttributes']),_0x5156a2[_0x54c05c(0x23c)]=_[_0x54c05c(0x22d)](_0x23b1bd['query']),_0x5156a2[_0x54c05c(0x21e)]=_[_0x54c05c(0x21b)](_0x5156a2[_0x54c05c(0x232)],_0x5156a2[_0x54c05c(0x23c)]),_0x11e70d['attributes']=_[_0x54c05c(0x21b)](_0x5156a2[_0x54c05c(0x232)],qs[_0x54c05c(0x1f5)](_0x23b1bd['query'][_0x54c05c(0x1f5)])),_0x11e70d[_0x54c05c(0x1ff)]=_0x11e70d[_0x54c05c(0x1ff)][_0x54c05c(0x231)]?_0x11e70d['attributes']:_0x5156a2['model'],_0x11e70d[_0x54c05c(0x22f)]=qs[_0x54c05c(0x22f)](_0x23b1bd[_0x54c05c(0x23c)][_0x54c05c(0x22f)]),_0x11e70d[_0x54c05c(0x1e1)]=qs[_0x54c05c(0x1e1)](_0x23b1bd[_0x54c05c(0x23c)][_0x54c05c(0x1e1)]),_0x11e70d[_0x54c05c(0x1df)]=qs[_0x54c05c(0x221)](_0x23b1bd[_0x54c05c(0x23c)]['sort']),_0x11e70d[_0x54c05c(0x226)]=qs['filters'](_[_0x54c05c(0x20a)](_0x23b1bd[_0x54c05c(0x23c)],_0x5156a2[_0x54c05c(0x21e)])),_0x11e70d=_[_0x54c05c(0x1f3)]({},_0x11e70d,_0x23b1bd['options']),_0x938e9d[_0x54c05c(0x22c)+_['capitalize'](_0x23b1bd[_0x54c05c(0x23c)][_0x54c05c(0x227)][_0x54c05c(0x208)]())+_0x54c05c(0x1f0)](_0x11e70d);})[_0x50a344(0x1e7)](respondWithResult(_0x19930a,null))[_0x50a344(0x238)](handleError(_0x19930a,null));},exports[a749_0x5ea838(0x205)]=function(_0x3c9e53,_0x341360){const _0x1190f8=a749_0x5ea838;return db[_0x1190f8(0x213)][_0x1190f8(0x22e)]({'where':{'id':_0x3c9e53[_0x1190f8(0x202)]['id']}})[_0x1190f8(0x1e7)](function(_0x113b9d){const _0x2fa440=_0x1190f8;if(_0x113b9d){if(!_0x3c9e53[_0x2fa440(0x21f)]['channel']||!utils[_0x2fa440(0x23d)](_0x3c9e53[_0x2fa440(0x21f)][_0x2fa440(0x227)]))throw new ValidationError(_0x2fa440(0x1f1));return _0x113b9d['add'+_[_0x2fa440(0x1ee)](_0x3c9e53[_0x2fa440(0x21f)][_0x2fa440(0x227)][_0x2fa440(0x208)]())+'Queues'](_0x3c9e53[_0x2fa440(0x21f)][_0x2fa440(0x239)]);}return null;})['then'](handleEntityNotFound(_0x341360,null))[_0x1190f8(0x1e7)](respondWithStatusCode(_0x341360,null))[_0x1190f8(0x238)](handleError(_0x341360,null));},exports[a749_0x5ea838(0x210)]=function(_0x458a18,_0x1ce97b){const _0x4297ad=a749_0x5ea838;return db[_0x4297ad(0x213)][_0x4297ad(0x22e)]({'where':{'id':_0x458a18['params']['id']}})[_0x4297ad(0x1e7)](function(_0x170173){const _0x5ad462=_0x4297ad;if(_0x170173){if(!_0x458a18[_0x5ad462(0x23c)][_0x5ad462(0x227)]||!utils[_0x5ad462(0x23d)](_0x458a18[_0x5ad462(0x23c)][_0x5ad462(0x227)]))throw new ValidationError(_0x5ad462(0x1f1));return _0x170173[_0x5ad462(0x217)+_[_0x5ad462(0x1ee)](_0x458a18['query'][_0x5ad462(0x227)]['toLowerCase']())+_0x5ad462(0x1f0)](_0x458a18['query']['ids']);}return null;})[_0x4297ad(0x1e7)](handleEntityNotFound(_0x1ce97b,null))['then'](respondWithStatusCode(_0x1ce97b,null))[_0x4297ad(0x238)](handleError(_0x1ce97b,null));},exports['addAgents']=function(_0x4d6291,_0x55c7c9){const _0x560d94=a749_0x5ea838;return db[_0x560d94(0x213)][_0x560d94(0x22e)]({'where':{'id':_0x4d6291[_0x560d94(0x202)]['id']}})[_0x560d94(0x1e7)](function(_0x56749c){const _0x59d224=_0x560d94;if(_0x56749c){const _0x756c2=[_0x59d224(0x212),'chat',_0x59d224(0x1ec),_0x59d224(0x1e2),'fax',_0x59d224(0x1fa),_0x59d224(0x222)];return Promise['all'](_0x756c2[_0x59d224(0x1fc)](async _0x298b67=>{const _0x5bb8a1=_0x59d224,_0x1c50bc=await _0x56749c[_0x5bb8a1(0x22c)+_[_0x5bb8a1(0x1ee)](_0x298b67)+_0x5bb8a1(0x1f0)]({'attributes':['id',_0x5bb8a1(0x1ed)]});return _0x1c50bc[_0x5bb8a1(0x1fc)](async _0x46c564=>{const _0x1c7536=_0x5bb8a1;await _0x46c564[_0x1c7536(0x224)](_0x4d6291[_0x1c7536(0x21f)]['ids']);if(_0x298b67===_0x1c7536(0x212)){const _0x255dd2=await db[_0x1c7536(0x1e5)]['findAll']({'where':{'id':_0x4d6291[_0x1c7536(0x21f)][_0x1c7536(0x239)]},'attributes':['id','name',_0x1c7536(0x21a),'voicePause',_0x1c7536(0x1e3)],'raw':!![]}),_0xb44579=_[_0x1c7536(0x1fb)](_0x255dd2,{'online':0x1}),_0x137f9b=_0xb44579['map'](_0x46419e=>{const _0x41a173=_0x1c7536;return db[_0x41a173(0x237)][_0x41a173(0x21d)]({'membername':_0x46419e[_0x41a173(0x1ed)],'UserId':_0x46419e['id'],'queue_name':_0x46c564[_0x41a173(0x1ed)],'VoiceQueueId':_0x46c564['id'],'interface':_[_0x41a173(0x1f2)](_0x46419e[_0x41a173(0x1e3)])?util['format']('SIP/%s',_0x46419e[_0x41a173(0x1ed)]):_0x46419e[_0x41a173(0x1e3)],'paused':_0x46419e[_0x41a173(0x200)]||![],'penalty':0x0});});return Promise[_0x1c7536(0x219)](_0x137f9b);}}),_0x56749c;}))['then'](function(){return _0x56749c;});}})[_0x560d94(0x1e7)](function(_0x88f9c9){const _0xf8f8a4=_0x560d94;if(_0x88f9c9)return _0x88f9c9[_0xf8f8a4(0x224)](_0x4d6291[_0xf8f8a4(0x21f)][_0xf8f8a4(0x239)],{'through':_['omit'](_0x4d6291[_0xf8f8a4(0x21f)],['ids','id'])})['then'](function(_0x551341){const _0x100562=_0xf8f8a4;for(let _0x240fc1=0x0;_0x240fc1<_0x4d6291['body'][_0x100562(0x239)][_0x100562(0x231)];_0x240fc1+=0x1){socket[_0x100562(0x225)](_0x100562(0x207),{'UserId':_0x4d6291[_0x100562(0x21f)][_0x100562(0x239)][_0x240fc1],'TeamId':_0x4d6291['params']['id']});}return _0x551341;});})[_0x560d94(0x1e7)](respondWithResult(_0x55c7c9,null))['catch'](handleError(_0x55c7c9,null));},exports[a749_0x5ea838(0x240)]=function(_0x390aef,_0x178bbe){const _0x2f0677=a749_0x5ea838;return db['Team'][_0x2f0677(0x22e)]({'where':{'id':_0x390aef['params']['id']}})[_0x2f0677(0x1e7)](handleEntityNotFound(_0x178bbe,null))[_0x2f0677(0x1e7)](function(_0x1d227c){const _0x494dec=_0x2f0677;if(_0x1d227c){const _0x13dab2=[_0x494dec(0x212),_0x494dec(0x204),_0x494dec(0x1ec),'sms',_0x494dec(0x1e9),_0x494dec(0x1fa),_0x494dec(0x222)];return Promise['all'](_0x13dab2[_0x494dec(0x1fc)](async _0x3298d4=>{const _0x160103=_0x494dec,_0x3eb9d5=await _0x1d227c['get'+_[_0x160103(0x1ee)](_0x3298d4)+_0x160103(0x1f0)]({'attributes':['id',_0x160103(0x1ed)]});return _0x3eb9d5[_0x160103(0x1fc)](async _0x5948dd=>{const _0x5e5dd2=_0x160103;await _0x5948dd[_0x5e5dd2(0x240)](_0x390aef[_0x5e5dd2(0x23c)][_0x5e5dd2(0x239)]),_0x3298d4===_0x5e5dd2(0x212)&&await db[_0x5e5dd2(0x237)][_0x5e5dd2(0x223)]({'where':{'VoiceQueueId':_0x5948dd['id'],'UserId':_0x390aef[_0x5e5dd2(0x23c)][_0x5e5dd2(0x239)]}});}),_0x1d227c;}))['then'](function(){return _0x1d227c;});}})[_0x2f0677(0x1e7)](function(_0x213ffa){const _0x3f8ee8=_0x2f0677;if(_0x213ffa)return _0x213ffa[_0x3f8ee8(0x240)](_0x390aef[_0x3f8ee8(0x23c)]['ids'])['then'](function(){const _0x62b71=_0x3f8ee8;if(_['isArray'](_0x390aef[_0x62b71(0x23c)]['ids']))for(let _0x413eb3=0x0;_0x413eb3<_0x390aef[_0x62b71(0x23c)]['ids'][_0x62b71(0x231)];_0x413eb3+=0x1){socket[_0x62b71(0x225)](_0x62b71(0x230),{'UserId':Number(_0x390aef[_0x62b71(0x23c)][_0x62b71(0x239)][_0x413eb3]),'TeamId':Number(_0x390aef[_0x62b71(0x202)]['id'])});}else socket[_0x62b71(0x225)](_0x62b71(0x230),{'UserId':Number(_0x390aef[_0x62b71(0x23c)][_0x62b71(0x239)]),'TeamId':Number(_0x390aef[_0x62b71(0x202)]['id'])});});})[_0x2f0677(0x1e7)](respondWithStatusCode(_0x178bbe,null))['catch'](handleError(_0x178bbe,null));},exports[a749_0x5ea838(0x23a)]=function(_0x1303a5,_0x133290){const _0x58337e=a749_0x5ea838;let _0x465372={};const _0x208f0f={};let _0x34f460,_0x252458;return db['Team']['findOne']({'where':{'id':_0x1303a5[_0x58337e(0x202)]['id']}})['then'](handleEntityNotFound(_0x133290,null))['then'](function(_0x32aba4){const _0x397432=_0x58337e;if(_0x32aba4)return _0x34f460=_0x32aba4,_0x208f0f[_0x397432(0x232)]=_['keys'](db[_0x397432(0x1e5)][_0x397432(0x1fe)]),_0x208f0f[_0x397432(0x23c)]=_[_0x397432(0x22d)](_0x1303a5[_0x397432(0x23c)]),_0x208f0f[_0x397432(0x21e)]=_[_0x397432(0x21b)](_0x208f0f[_0x397432(0x232)],_0x208f0f[_0x397432(0x23c)]),_0x465372[_0x397432(0x1ff)]=_[_0x397432(0x21b)](_0x208f0f[_0x397432(0x232)],qs[_0x397432(0x1f5)](_0x1303a5[_0x397432(0x23c)][_0x397432(0x1f5)])),_0x465372[_0x397432(0x1ff)]=_0x465372[_0x397432(0x1ff)][_0x397432(0x231)]?_0x465372[_0x397432(0x1ff)]:_0x208f0f['model'],_0x465372[_0x397432(0x1df)]=qs[_0x397432(0x221)](_0x1303a5['query'][_0x397432(0x221)]),_0x465372[_0x397432(0x226)]=qs[_0x397432(0x21e)](_[_0x397432(0x20a)](_0x1303a5[_0x397432(0x23c)],_0x208f0f['filters'])),_0x1303a5[_0x397432(0x23c)][_0x397432(0x1fb)]&&(_0x465372[_0x397432(0x226)]=_[_0x397432(0x1f3)](_0x465372['where'],{[Op['or']]:_['map'](_0x465372['attributes'],function(_0x27ce93){const _0x528abf=_0x397432,_0x36681d={};return _0x36681d[_0x27ce93]={[Op[_0x528abf(0x20f)]]:'%'+_0x1303a5[_0x528abf(0x23c)][_0x528abf(0x1fb)]+'%'},_0x36681d;})})),_0x465372=_['merge']({},_0x465372,_0x1303a5[_0x397432(0x206)]),_0x34f460['getAgents'](_0x465372);})[_0x58337e(0x1e7)](function(_0x1b7af1){const _0x503924=_0x58337e;if(_0x1b7af1)return _0x252458=_0x1b7af1[_0x503924(0x231)],typeof _0x1303a5[_0x503924(0x23c)][_0x503924(0x20e)]==='undefined'&&(_0x465372[_0x503924(0x22f)]=qs[_0x503924(0x22f)](_0x1303a5[_0x503924(0x23c)][_0x503924(0x22f)]),_0x465372['offset']=qs[_0x503924(0x1e1)](_0x1303a5[_0x503924(0x23c)][_0x503924(0x1e1)])),_0x34f460['getAgents'](_0x465372);})[_0x58337e(0x1e7)](function(_0x275918){if(_0x275918)return _0x275918?{'count':_0x252458,'rows':_0x275918}:null;})[_0x58337e(0x1e7)](respondWithResult(_0x133290,null))['catch'](handleError(_0x133290,null));};
\ No newline at end of file
+const a749_0x1f77=['Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','create','name','interface','length','map','status','nolimit','userTeam:save','undefined','findAll','sort','mail','query','merge','UserProfileSection','toLowerCase','filter','sendStatus','json','format','removeAgents','send','api','online','like','where','UserProfileResource','fields','VIRTUAL','Queue','error','sms','../../config/utils','includeAll','Content-Range','voice','Queues','whatsapp','addQueues','addAgents','autoAssociation','model','keys','isValidChannel','destroy','getQueues','rawAttributes','emit','./team.socket','pick','offset','intersection','userTeam:remove','attributes','lodash','openchannel','User','show','util','removeQueues','all','Unable\x20to\x20retrieve\x20the\x20current\x20user','order','update','../../mysqldb','include','index','Team','then','role','ids','params','user','filters','get','type','body','capitalize','Unknown\x20channel','UserVoiceQueueRt','../../components/parsers/qs','isArray','set','findOne','chat','remove','rows','../../rediscache','isNil','options','channel','count','catch','fax','register','../../config/logger','key','end','limit','getAgents','voicePause'];(function(_0x12e7ce,_0x4d2572){const _0x1f7770=function(_0x57d2fb){while(--_0x57d2fb){_0x12e7ce['push'](_0x12e7ce['shift']());}};_0x1f7770(++_0x4d2572);}(a749_0x1f77,0x1ae));const a749_0x57d2=function(_0x12e7ce,_0x4d2572){_0x12e7ce=_0x12e7ce-0x1df;let _0x1f7770=a749_0x1f77[_0x12e7ce];return _0x1f7770;};const a749_0x5dd6ab=a749_0x57d2;'use strict';const util=require(a749_0x5dd6ab(0x204)),_=require(a749_0x5dd6ab(0x200)),qs=require(a749_0x5dd6ab(0x21a)),logger=require(a749_0x5dd6ab(0x229))(a749_0x5dd6ab(0x1e0)),utils=require(a749_0x5dd6ab(0x1ea)),{getSocket}=require(a749_0x5dd6ab(0x221)),socket=getSocket(),{db}=require(a749_0x5dd6ab(0x20a)),{Op,ValidationError}=require('sequelize');require(a749_0x5dd6ab(0x1fa))[a749_0x5dd6ab(0x228)](socket);function respondWithStatusCode(_0x31fc41,_0x37a762){return _0x37a762=_0x37a762||0xcc,function(_0x1f353a){const _0xd96e25=a749_0x57d2;if(_0x1f353a)return _0x31fc41[_0xd96e25(0x241)](_0x37a762);return _0x31fc41[_0xd96e25(0x235)](_0x37a762)[_0xd96e25(0x22b)]();};}function respondWithResult(_0x223c56,_0x42520d){return _0x42520d=_0x42520d||0xc8,function(_0x474bd1){const _0x3fc3b0=a749_0x57d2;if(_0x474bd1)return _0x223c56['status'](_0x42520d)[_0x3fc3b0(0x242)](_0x474bd1);};}function respondWithFilteredResult(_0x1514f0,_0x1ad327){return function(_0x4658be){const _0x540501=a749_0x57d2;if(_0x4658be){const _0x80dc24=_0x4658be[_0x540501(0x225)],_0x1d4f10=_0x1ad327['offset'];let _0x29c304=_0x1ad327['offset']+_0x1ad327[_0x540501(0x22c)],_0x341850;return _0x29c304>=_0x80dc24?(_0x29c304=_0x80dc24,_0x341850=0xc8):_0x341850=0xce,_0x1514f0['status'](_0x341850),_0x1514f0[_0x540501(0x21c)](_0x540501(0x1ec),_0x1d4f10+'-'+_0x29c304+'/'+_0x80dc24)[_0x540501(0x242)](_0x4658be);}return null;};}function saveUpdates(_0xf15efd){return function(_0x12bff9){const _0x4d77d8=a749_0x57d2;if(_0x12bff9)return _0x12bff9[_0x4d77d8(0x209)](_0xf15efd)[_0x4d77d8(0x20e)](function(_0x29a142){return _0x29a142;});return null;};}function removeEntity(_0x1d20f3){return function(_0x59cf29){const _0x2ad2d7=a749_0x57d2;if(_0x59cf29)return _0x59cf29[_0x2ad2d7(0x1f6)]()[_0x2ad2d7(0x20e)](function(){const _0x8478e8=_0x2ad2d7,_0x164dff=_0x59cf29[_0x8478e8(0x214)]({'plain':!![]}),_0x168087='Teams';return db[_0x8478e8(0x1e4)]['destroy']({'where':{'type':_0x168087,'resourceId':_0x164dff['id']}})[_0x8478e8(0x20e)](function(){return _0x59cf29;});})[_0x2ad2d7(0x20e)](function(){const _0x39d3ae=_0x2ad2d7;_0x1d20f3[_0x39d3ae(0x235)](0xcc)[_0x39d3ae(0x22b)]();});};}function handleEntityNotFound(_0x3e299a){return function(_0x4d3411){const _0x5a94bb=a749_0x57d2;return!_0x4d3411&&_0x3e299a[_0x5a94bb(0x241)](0x194),_0x4d3411;};}function handleError(_0x113810,_0x224735){return _0x224735=_0x224735||0x1f4,function(_0x114f1a){const _0x3c0419=a749_0x57d2;logger[_0x3c0419(0x1e8)](_0x114f1a['stack']),_0x114f1a[_0x3c0419(0x231)]&&delete _0x114f1a[_0x3c0419(0x231)],_0x113810[_0x3c0419(0x235)](_0x224735)[_0x3c0419(0x1df)](_0x114f1a);};}exports[a749_0x5dd6ab(0x20c)]=function(_0x148d83,_0x8a892b){const _0x1a1900=a749_0x5dd6ab;let _0x58eaa3={};const _0x4f2887={},_0x58c88a={'count':0x0,'rows':[]},_0x54d6e8=_[_0x1a1900(0x234)](db[_0x1a1900(0x20d)][_0x1a1900(0x1f8)],function(_0x24f7dd){const _0x35aa63=_0x1a1900;return{'name':_0x24f7dd['fieldName'],'type':_0x24f7dd[_0x35aa63(0x215)][_0x35aa63(0x22a)]};});_0x4f2887[_0x1a1900(0x1f3)]=_[_0x1a1900(0x234)](_0x54d6e8,_0x1a1900(0x231)),_0x4f2887['query']=_[_0x1a1900(0x1f4)](_0x148d83['query']),_0x4f2887[_0x1a1900(0x213)]=_['intersection'](_0x4f2887['model'],_0x4f2887[_0x1a1900(0x23c)]),_0x58eaa3[_0x1a1900(0x1ff)]=_[_0x1a1900(0x1fd)](_0x4f2887[_0x1a1900(0x1f3)],qs[_0x1a1900(0x1e5)](_0x148d83['query'][_0x1a1900(0x1e5)])),_0x58eaa3[_0x1a1900(0x1ff)]=_0x58eaa3['attributes'][_0x1a1900(0x233)]?_0x58eaa3['attributes']:_0x4f2887[_0x1a1900(0x1f3)];typeof _0x148d83[_0x1a1900(0x23c)][_0x1a1900(0x236)]===_0x1a1900(0x238)&&(_0x58eaa3['limit']=qs[_0x1a1900(0x22c)](_0x148d83['query'][_0x1a1900(0x22c)]),_0x58eaa3[_0x1a1900(0x1fc)]=qs[_0x1a1900(0x1fc)](_0x148d83[_0x1a1900(0x23c)][_0x1a1900(0x1fc)]));_0x58eaa3[_0x1a1900(0x208)]=qs[_0x1a1900(0x23a)](_0x148d83['query'][_0x1a1900(0x23a)]),_0x58eaa3['where']=qs[_0x1a1900(0x213)](_[_0x1a1900(0x1fb)](_0x148d83[_0x1a1900(0x23c)],_0x4f2887[_0x1a1900(0x213)]),_0x54d6e8);_0x148d83['query'][_0x1a1900(0x240)]&&(_0x58eaa3['where']=_['merge'](_0x58eaa3[_0x1a1900(0x1e3)],{[Op['or']]:_['map'](_0x54d6e8,function(_0xed007c){const _0x2d2e27=_0x1a1900;if(_0xed007c[_0x2d2e27(0x215)]!==_0x2d2e27(0x1e6)){const _0xeb057c={};return _0xeb057c[_0xed007c[_0x2d2e27(0x231)]]={[Op[_0x2d2e27(0x1e2)]]:'%'+_0x148d83[_0x2d2e27(0x23c)][_0x2d2e27(0x240)]+'%'},_0xeb057c;}})}));_0x58eaa3=_[_0x1a1900(0x23d)]({},_0x58eaa3,_0x148d83[_0x1a1900(0x223)]);const _0x2e2a76={'where':_0x58eaa3['where']};return db['Team'][_0x1a1900(0x225)](_0x2e2a76)['then'](function(_0x5b6c75){const _0x1f76e2=_0x1a1900;return _0x58c88a[_0x1f76e2(0x225)]=_0x5b6c75,_0x148d83['query'][_0x1f76e2(0x1eb)]&&(_0x58eaa3[_0x1f76e2(0x20b)]=[{'all':!![]}]),db[_0x1f76e2(0x20d)][_0x1f76e2(0x239)](_0x58eaa3);})[_0x1a1900(0x20e)](function(_0x42a262){const _0x519d23=_0x1a1900;return _0x58c88a[_0x519d23(0x220)]=_0x42a262,_0x58c88a;})['then'](respondWithFilteredResult(_0x8a892b,_0x58eaa3))[_0x1a1900(0x226)](handleError(_0x8a892b,null));},exports[a749_0x5dd6ab(0x203)]=function(_0x5dca01,_0x3ec98e){const _0xacd784=a749_0x5dd6ab;let _0x5a6922={'raw':![],'where':{'id':_0x5dca01['params']['id']}};const _0x2e3bf1={};return _0x2e3bf1[_0xacd784(0x1f3)]=_['keys'](db[_0xacd784(0x20d)][_0xacd784(0x1f8)]),_0x2e3bf1[_0xacd784(0x23c)]=_['keys'](_0x5dca01[_0xacd784(0x23c)]),_0x2e3bf1[_0xacd784(0x213)]=_[_0xacd784(0x1fd)](_0x2e3bf1[_0xacd784(0x1f3)],_0x2e3bf1[_0xacd784(0x23c)]),_0x5a6922[_0xacd784(0x1ff)]=_['intersection'](_0x2e3bf1[_0xacd784(0x1f3)],qs['fields'](_0x5dca01['query']['fields'])),_0x5a6922[_0xacd784(0x1ff)]=_0x5a6922['attributes'][_0xacd784(0x233)]?_0x5a6922['attributes']:_0x2e3bf1[_0xacd784(0x1f3)],_0x5dca01[_0xacd784(0x23c)][_0xacd784(0x1eb)]&&(_0x5a6922['include']=[{'all':!![]}]),_0x5a6922=_['merge']({},_0x5a6922,_0x5dca01['options']),db[_0xacd784(0x20d)][_0xacd784(0x21d)](_0x5a6922)[_0xacd784(0x20e)](handleEntityNotFound(_0x3ec98e,null))[_0xacd784(0x20e)](respondWithResult(_0x3ec98e,null))[_0xacd784(0x226)](handleError(_0x3ec98e,null));},exports[a749_0x5dd6ab(0x230)]=function(_0x47d523,_0x2d93f9){const _0x346c2b=a749_0x5dd6ab;return db['Team'][_0x346c2b(0x230)](_0x47d523[_0x346c2b(0x216)],{})[_0x346c2b(0x20e)](function(_0x1f201a){const _0x900416=_0x346c2b,_0x47b9b0=_0x47d523['user'][_0x900416(0x214)]({'plain':!![]});if(!_0x47b9b0)throw new Error(_0x900416(0x207));if(_0x47b9b0[_0x900416(0x20f)]===_0x900416(0x212)){const _0x51af0d=_0x1f201a[_0x900416(0x214)]({'plain':!![]}),_0x47a314='Teams';return db[_0x900416(0x23e)]['findOne']({'where':{'name':_0x47a314,'userProfileId':_0x47b9b0['userProfileId']},'raw':!![]})['then'](function(_0x19340a){const _0x1b2341=_0x900416;return _0x19340a&&_0x19340a[_0x1b2341(0x1f2)]===0x0?db[_0x1b2341(0x1e4)][_0x1b2341(0x230)]({'name':_0x51af0d['name'],'resourceId':_0x51af0d['id'],'type':_0x19340a['name'],'sectionId':_0x19340a['id']},{})[_0x1b2341(0x20e)](function(){return _0x1f201a;}):_0x1f201a;})[_0x900416(0x226)](function(_0x501761){const _0x460c47=_0x900416;logger['error'](_0x460c47(0x22f),_0x501761);throw _0x501761;});}return _0x1f201a;})[_0x346c2b(0x20e)](respondWithResult(_0x2d93f9,0xc9))[_0x346c2b(0x226)](handleError(_0x2d93f9,null));},exports['update']=function(_0x4d9378,_0x396ece){const _0x3ee1d4=a749_0x5dd6ab;return _0x4d9378['body']['id']&&delete _0x4d9378[_0x3ee1d4(0x216)]['id'],db[_0x3ee1d4(0x20d)][_0x3ee1d4(0x21d)]({'where':{'id':_0x4d9378['params']['id']}})['then'](handleEntityNotFound(_0x396ece,null))[_0x3ee1d4(0x20e)](saveUpdates(_0x4d9378[_0x3ee1d4(0x216)],null))['then'](respondWithResult(_0x396ece,null))[_0x3ee1d4(0x226)](handleError(_0x396ece,null));},exports['destroy']=function(_0x471330,_0x144b31){const _0x303584=a749_0x5dd6ab;return db[_0x303584(0x20d)]['findOne']({'where':{'id':_0x471330[_0x303584(0x211)]['id']}})['then'](handleEntityNotFound(_0x144b31,null))[_0x303584(0x20e)](removeEntity(_0x144b31,null))['catch'](handleError(_0x144b31,null));},exports[a749_0x5dd6ab(0x1f7)]=function(_0x1b3d5a,_0x5be261){const _0x17ab54=a749_0x5dd6ab;return db['Team'][_0x17ab54(0x21d)]({'where':{'id':_0x1b3d5a['params']['id']}})[_0x17ab54(0x20e)](handleEntityNotFound(_0x5be261,null))['then'](function(_0x2064b4){const _0x49aa9b=_0x17ab54;if(!_0x1b3d5a['query'][_0x49aa9b(0x224)]||!utils[_0x49aa9b(0x1f5)](_0x1b3d5a[_0x49aa9b(0x23c)][_0x49aa9b(0x224)]))throw new ValidationError(_0x49aa9b(0x218));let _0x23bc92={};const _0x2326ea={};return _0x2326ea[_0x49aa9b(0x1f3)]=_[_0x49aa9b(0x1f4)](db[_[_0x49aa9b(0x217)](_0x1b3d5a[_0x49aa9b(0x23c)]['channel']['toLowerCase']())+_0x49aa9b(0x1e7)]['rawAttributes']),_0x2326ea[_0x49aa9b(0x23c)]=_['keys'](_0x1b3d5a[_0x49aa9b(0x23c)]),_0x2326ea[_0x49aa9b(0x213)]=_[_0x49aa9b(0x1fd)](_0x2326ea[_0x49aa9b(0x1f3)],_0x2326ea[_0x49aa9b(0x23c)]),_0x23bc92[_0x49aa9b(0x1ff)]=_[_0x49aa9b(0x1fd)](_0x2326ea[_0x49aa9b(0x1f3)],qs[_0x49aa9b(0x1e5)](_0x1b3d5a['query'][_0x49aa9b(0x1e5)])),_0x23bc92['attributes']=_0x23bc92[_0x49aa9b(0x1ff)][_0x49aa9b(0x233)]?_0x23bc92[_0x49aa9b(0x1ff)]:_0x2326ea['model'],_0x23bc92[_0x49aa9b(0x22c)]=qs['limit'](_0x1b3d5a[_0x49aa9b(0x23c)][_0x49aa9b(0x22c)]),_0x23bc92['offset']=qs['offset'](_0x1b3d5a['query'][_0x49aa9b(0x1fc)]),_0x23bc92[_0x49aa9b(0x208)]=qs[_0x49aa9b(0x23a)](_0x1b3d5a[_0x49aa9b(0x23c)][_0x49aa9b(0x23a)]),_0x23bc92[_0x49aa9b(0x1e3)]=qs[_0x49aa9b(0x213)](_[_0x49aa9b(0x1fb)](_0x1b3d5a['query'],_0x2326ea[_0x49aa9b(0x213)])),_0x23bc92=_[_0x49aa9b(0x23d)]({},_0x23bc92,_0x1b3d5a[_0x49aa9b(0x223)]),_0x2064b4[_0x49aa9b(0x214)+_[_0x49aa9b(0x217)](_0x1b3d5a[_0x49aa9b(0x23c)][_0x49aa9b(0x224)][_0x49aa9b(0x23f)]())+'Queues'](_0x23bc92);})[_0x17ab54(0x20e)](respondWithResult(_0x5be261,null))[_0x17ab54(0x226)](handleError(_0x5be261,null));},exports[a749_0x5dd6ab(0x1f0)]=function(_0x581195,_0x689172){const _0x31b7c0=a749_0x5dd6ab;return db[_0x31b7c0(0x20d)][_0x31b7c0(0x21d)]({'where':{'id':_0x581195[_0x31b7c0(0x211)]['id']}})[_0x31b7c0(0x20e)](function(_0x4bbd15){const _0x274d1d=_0x31b7c0;if(_0x4bbd15){if(!_0x581195[_0x274d1d(0x216)][_0x274d1d(0x224)]||!utils['isValidChannel'](_0x581195[_0x274d1d(0x216)][_0x274d1d(0x224)]))throw new ValidationError(_0x274d1d(0x218));return _0x4bbd15['add'+_[_0x274d1d(0x217)](_0x581195[_0x274d1d(0x216)]['channel']['toLowerCase']())+'Queues'](_0x581195[_0x274d1d(0x216)][_0x274d1d(0x210)]);}return null;})[_0x31b7c0(0x20e)](handleEntityNotFound(_0x689172,null))[_0x31b7c0(0x20e)](respondWithStatusCode(_0x689172,null))[_0x31b7c0(0x226)](handleError(_0x689172,null));},exports[a749_0x5dd6ab(0x205)]=function(_0x15250c,_0x2efe3d){const _0x1d0890=a749_0x5dd6ab;return db['Team'][_0x1d0890(0x21d)]({'where':{'id':_0x15250c[_0x1d0890(0x211)]['id']}})[_0x1d0890(0x20e)](function(_0x1e8e02){const _0x582da2=_0x1d0890;if(_0x1e8e02){if(!_0x15250c['query'][_0x582da2(0x224)]||!utils[_0x582da2(0x1f5)](_0x15250c[_0x582da2(0x23c)][_0x582da2(0x224)]))throw new ValidationError('Unknown\x20channel');return _0x1e8e02[_0x582da2(0x21f)+_[_0x582da2(0x217)](_0x15250c[_0x582da2(0x23c)][_0x582da2(0x224)]['toLowerCase']())+_0x582da2(0x1ee)](_0x15250c['query'][_0x582da2(0x210)]);}return null;})['then'](handleEntityNotFound(_0x2efe3d,null))[_0x1d0890(0x20e)](respondWithStatusCode(_0x2efe3d,null))[_0x1d0890(0x226)](handleError(_0x2efe3d,null));},exports['addAgents']=function(_0x1395b9,_0x40f53d){const _0xc9dca4=a749_0x5dd6ab;return db[_0xc9dca4(0x20d)]['findOne']({'where':{'id':_0x1395b9[_0xc9dca4(0x211)]['id']}})['then'](function(_0x344b70){const _0x561a67=_0xc9dca4;if(_0x344b70){const _0x3af186=[_0x561a67(0x1ed),_0x561a67(0x21e),'mail',_0x561a67(0x1e9),_0x561a67(0x227),_0x561a67(0x201),_0x561a67(0x1ef)];return Promise[_0x561a67(0x206)](_0x3af186[_0x561a67(0x234)](async _0x3bb01f=>{const _0x216f47=_0x561a67,_0x3cb25e=await _0x344b70['get'+_[_0x216f47(0x217)](_0x3bb01f)+_0x216f47(0x1ee)]({'attributes':['id',_0x216f47(0x231)]});return _0x3cb25e[_0x216f47(0x234)](async _0x382e8f=>{const _0x71e6e6=_0x216f47;await _0x382e8f['addAgents'](_0x1395b9[_0x71e6e6(0x216)][_0x71e6e6(0x210)]);if(_0x3bb01f==='voice'){const _0x343146=await db[_0x71e6e6(0x202)]['findAll']({'where':{'id':_0x1395b9[_0x71e6e6(0x216)][_0x71e6e6(0x210)]},'attributes':['id','name',_0x71e6e6(0x1e1),'voicePause',_0x71e6e6(0x232)],'raw':!![]}),_0x4873d6=_[_0x71e6e6(0x240)](_0x343146,{'online':0x1}),_0x10281c=_0x4873d6[_0x71e6e6(0x234)](_0x1ae194=>{const _0x2c81a3=_0x71e6e6;return db[_0x2c81a3(0x219)]['upsert']({'membername':_0x1ae194[_0x2c81a3(0x231)],'UserId':_0x1ae194['id'],'queue_name':_0x382e8f[_0x2c81a3(0x231)],'VoiceQueueId':_0x382e8f['id'],'interface':_[_0x2c81a3(0x222)](_0x1ae194[_0x2c81a3(0x232)])?util[_0x2c81a3(0x243)]('SIP/%s',_0x1ae194[_0x2c81a3(0x231)]):_0x1ae194[_0x2c81a3(0x232)],'paused':_0x1ae194[_0x2c81a3(0x22e)]||![],'penalty':0x0});});return Promise[_0x71e6e6(0x206)](_0x10281c);}}),_0x344b70;}))['then'](function(){return _0x344b70;});}})['then'](function(_0x1f19d6){const _0x59900f=_0xc9dca4;if(_0x1f19d6)return _0x1f19d6[_0x59900f(0x1f1)](_0x1395b9[_0x59900f(0x216)][_0x59900f(0x210)],{'through':_['omit'](_0x1395b9[_0x59900f(0x216)],['ids','id'])})[_0x59900f(0x20e)](function(_0x54d418){const _0x111ef9=_0x59900f;for(let _0x42d7fb=0x0;_0x42d7fb<_0x1395b9[_0x111ef9(0x216)][_0x111ef9(0x210)][_0x111ef9(0x233)];_0x42d7fb+=0x1){socket[_0x111ef9(0x1f9)](_0x111ef9(0x237),{'UserId':_0x1395b9[_0x111ef9(0x216)][_0x111ef9(0x210)][_0x42d7fb],'TeamId':_0x1395b9[_0x111ef9(0x211)]['id']});}return _0x54d418;});})[_0xc9dca4(0x20e)](respondWithResult(_0x40f53d,null))[_0xc9dca4(0x226)](handleError(_0x40f53d,null));},exports[a749_0x5dd6ab(0x244)]=function(_0x24ebbd,_0x226163){const _0x134f33=a749_0x5dd6ab;return db['Team']['findOne']({'where':{'id':_0x24ebbd[_0x134f33(0x211)]['id']}})[_0x134f33(0x20e)](handleEntityNotFound(_0x226163,null))[_0x134f33(0x20e)](function(_0x218d98){const _0x59a9ea=_0x134f33;if(_0x218d98){const _0x56d463=['voice',_0x59a9ea(0x21e),_0x59a9ea(0x23b),_0x59a9ea(0x1e9),'fax',_0x59a9ea(0x201),'whatsapp'];return Promise[_0x59a9ea(0x206)](_0x56d463[_0x59a9ea(0x234)](async _0x5adc7d=>{const _0x10c878=_0x59a9ea,_0x7a12ef=await _0x218d98['get'+_[_0x10c878(0x217)](_0x5adc7d)+'Queues']({'attributes':['id',_0x10c878(0x231)]});return _0x7a12ef[_0x10c878(0x234)](async _0x1b26b2=>{const _0x4553d3=_0x10c878;await _0x1b26b2[_0x4553d3(0x244)](_0x24ebbd[_0x4553d3(0x23c)][_0x4553d3(0x210)]),_0x5adc7d===_0x4553d3(0x1ed)&&await db[_0x4553d3(0x219)]['destroy']({'where':{'VoiceQueueId':_0x1b26b2['id'],'UserId':_0x24ebbd[_0x4553d3(0x23c)][_0x4553d3(0x210)]}});}),_0x218d98;}))[_0x59a9ea(0x20e)](function(){return _0x218d98;});}})[_0x134f33(0x20e)](function(_0x29ac29){const _0x3af03e=_0x134f33;if(_0x29ac29)return _0x29ac29['removeAgents'](_0x24ebbd[_0x3af03e(0x23c)][_0x3af03e(0x210)])[_0x3af03e(0x20e)](function(){const _0x4585ac=_0x3af03e;if(_[_0x4585ac(0x21b)](_0x24ebbd[_0x4585ac(0x23c)][_0x4585ac(0x210)]))for(let _0x14f63c=0x0;_0x14f63c<_0x24ebbd['query']['ids'][_0x4585ac(0x233)];_0x14f63c+=0x1){socket['emit'](_0x4585ac(0x1fe),{'UserId':Number(_0x24ebbd[_0x4585ac(0x23c)][_0x4585ac(0x210)][_0x14f63c]),'TeamId':Number(_0x24ebbd[_0x4585ac(0x211)]['id'])});}else socket[_0x4585ac(0x1f9)]('userTeam:remove',{'UserId':Number(_0x24ebbd['query'][_0x4585ac(0x210)]),'TeamId':Number(_0x24ebbd[_0x4585ac(0x211)]['id'])});});})[_0x134f33(0x20e)](respondWithStatusCode(_0x226163,null))[_0x134f33(0x226)](handleError(_0x226163,null));},exports[a749_0x5dd6ab(0x22d)]=function(_0x52fac9,_0x211a60){const _0x4e054f=a749_0x5dd6ab;let _0x37b6bb={};const _0x3436e0={};let _0xd685b7,_0x102d8f;return db['Team'][_0x4e054f(0x21d)]({'where':{'id':_0x52fac9[_0x4e054f(0x211)]['id']}})[_0x4e054f(0x20e)](handleEntityNotFound(_0x211a60,null))[_0x4e054f(0x20e)](function(_0xc0355f){const _0x29a1eb=_0x4e054f;if(_0xc0355f)return _0xd685b7=_0xc0355f,_0x3436e0[_0x29a1eb(0x1f3)]=_[_0x29a1eb(0x1f4)](db['User'][_0x29a1eb(0x1f8)]),_0x3436e0[_0x29a1eb(0x23c)]=_[_0x29a1eb(0x1f4)](_0x52fac9[_0x29a1eb(0x23c)]),_0x3436e0[_0x29a1eb(0x213)]=_[_0x29a1eb(0x1fd)](_0x3436e0[_0x29a1eb(0x1f3)],_0x3436e0['query']),_0x37b6bb[_0x29a1eb(0x1ff)]=_[_0x29a1eb(0x1fd)](_0x3436e0['model'],qs[_0x29a1eb(0x1e5)](_0x52fac9[_0x29a1eb(0x23c)][_0x29a1eb(0x1e5)])),_0x37b6bb[_0x29a1eb(0x1ff)]=_0x37b6bb[_0x29a1eb(0x1ff)]['length']?_0x37b6bb['attributes']:_0x3436e0['model'],_0x37b6bb[_0x29a1eb(0x208)]=qs[_0x29a1eb(0x23a)](_0x52fac9[_0x29a1eb(0x23c)]['sort']),_0x37b6bb[_0x29a1eb(0x1e3)]=qs['filters'](_[_0x29a1eb(0x1fb)](_0x52fac9[_0x29a1eb(0x23c)],_0x3436e0['filters'])),_0x52fac9['query']['filter']&&(_0x37b6bb['where']=_[_0x29a1eb(0x23d)](_0x37b6bb[_0x29a1eb(0x1e3)],{[Op['or']]:_[_0x29a1eb(0x234)](_0x37b6bb['attributes'],function(_0x1e0b39){const _0x46911d=_0x29a1eb,_0x234b44={};return _0x234b44[_0x1e0b39]={[Op['like']]:'%'+_0x52fac9[_0x46911d(0x23c)][_0x46911d(0x240)]+'%'},_0x234b44;})})),_0x37b6bb=_[_0x29a1eb(0x23d)]({},_0x37b6bb,_0x52fac9[_0x29a1eb(0x223)]),_0xd685b7['getAgents'](_0x37b6bb);})[_0x4e054f(0x20e)](function(_0x311d49){const _0x5de499=_0x4e054f;if(_0x311d49)return _0x102d8f=_0x311d49[_0x5de499(0x233)],typeof _0x52fac9[_0x5de499(0x23c)][_0x5de499(0x236)]===_0x5de499(0x238)&&(_0x37b6bb[_0x5de499(0x22c)]=qs['limit'](_0x52fac9[_0x5de499(0x23c)][_0x5de499(0x22c)]),_0x37b6bb[_0x5de499(0x1fc)]=qs['offset'](_0x52fac9['query']['offset'])),_0xd685b7['getAgents'](_0x37b6bb);})['then'](function(_0x2230e5){if(_0x2230e5)return _0x2230e5?{'count':_0x102d8f,'rows':_0x2230e5}:null;})['then'](respondWithResult(_0x211a60,null))[_0x4e054f(0x226)](handleError(_0x211a60,null));};
\ No newline at end of file