Built motion from commit 5fcd269f5146f10cf3129722d518881dfac64576. Version 3.0.0...
[motion-next.git] / server / api / team / team.controller.js
index 6591f17..c58cd5c 100644 (file)
@@ -1 +1 @@
-const a626_0x5a95=['addAgents','includeAll','isNil','index','role','capitalize','include','pick','Sms','count','voice','error','params','emit','merge','channel','set','all','UserProfileResource','UserProfileSection','get','sms','findOne','getQueues','register','query','fax','key','../../config/utils','Queues','lodash','offset','./team.socket','VIRTUAL','getAgents','create','Teams','like','fields','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','fieldName','removeAgents','mail','sendStatus','../../components/parsers/qs','chat','interface','remove','isValidChannel','limit','whatsapp','user','util','userTeam:remove','UserVoiceQueueRt','map','filters','User','update','Mail','Openchannel','api','upsert','body','add','sequelize','each','Team','autoAssociation','intersection','findAll','online','catch','then','undefined','rawAttributes','Fax','userTeam:save','voicePause','status','stack','send','Content-Range','toLowerCase','attributes','Unknown\x20channel','type','model','keys','length','where','options','addQueues','Whatsapp','filter','order','ids','format','json','openchannel','name','destroy','sort','nolimit','end','Chat'];(function(_0xe3e36e,_0x5a95f6){const _0x54075f=function(_0x2798a2){while(--_0x2798a2){_0xe3e36e['push'](_0xe3e36e['shift']());}};_0x54075f(++_0x5a95f6);}(a626_0x5a95,0x1bd));const a626_0x5407=function(_0xe3e36e,_0x5a95f6){_0xe3e36e=_0xe3e36e-0x0;let _0x54075f=a626_0x5a95[_0xe3e36e];return _0x54075f;};const _0x5a5d28=a626_0x5407;'use strict';const util=require(_0x5a5d28('0x1f')),_=require(_0x5a5d28('0x9')),qs=require(_0x5a5d28('0x17')),logger=require('../../config/logger')(_0x5a5d28('0x28')),utils=require(_0x5a5d28('0x7')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require('../../mysqldb')['db'],{Op,ValidationError}=require(_0x5a5d28('0x2c'));require(_0x5a5d28('0xb'))[_0x5a5d28('0x3')](socket);function respondWithStatusCode(_0x2798a2,_0x8e677e){return _0x8e677e=_0x8e677e||0xcc,function(_0x1c2bf4){const _0x5ecbc6=a626_0x5407;if(_0x1c2bf4)return _0x2798a2[_0x5ecbc6('0x16')](_0x8e677e);return _0x2798a2[_0x5ecbc6('0x3a')](_0x8e677e)[_0x5ecbc6('0x53')]();};}function respondWithResult(_0x50b39e,_0x581ff6){return _0x581ff6=_0x581ff6||0xc8,function(_0x498f61){const _0x334e0e=a626_0x5407;if(_0x498f61)return _0x50b39e[_0x334e0e('0x3a')](_0x581ff6)[_0x334e0e('0x4d')](_0x498f61);};}function respondWithFilteredResult(_0x51f51e,_0x121d8c){return function(_0x513d80){const _0x449f88=a626_0x5407;if(_0x513d80){const _0x2d83ba=_0x513d80[_0x449f88('0x5e')],_0x3d1ada=_0x121d8c['offset'];let _0x25d527=_0x121d8c[_0x449f88('0xa')]+_0x121d8c[_0x449f88('0x1c')],_0x252962;return _0x25d527>=_0x2d83ba?(_0x25d527=_0x2d83ba,_0x252962=0xc8):_0x252962=0xce,_0x51f51e[_0x449f88('0x3a')](_0x252962),_0x51f51e[_0x449f88('0x65')](_0x449f88('0x3d'),_0x3d1ada+'-'+_0x25d527+'/'+_0x2d83ba)['json'](_0x513d80);}return null;};}function saveUpdates(_0x27854e){return function(_0x5d319b){const _0x32e484=a626_0x5407;if(_0x5d319b)return _0x5d319b[_0x32e484('0x25')](_0x27854e)[_0x32e484('0x34')](function(_0x49e2f6){return _0x49e2f6;});return null;};}function removeEntity(_0x2ef002){return function(_0x51d799){const _0x5373b9=a626_0x5407;if(_0x51d799)return _0x51d799[_0x5373b9('0x50')]()['then'](function(){const _0x36bf8e=_0x5373b9,_0x41f68a=_0x51d799[_0x36bf8e('0x69')]({'plain':!![]}),_0x2a0031=_0x36bf8e('0xf');return db[_0x36bf8e('0x67')][_0x36bf8e('0x50')]({'where':{'type':_0x2a0031,'resourceId':_0x41f68a['id']}})['then'](function(){return _0x51d799;});})[_0x5373b9('0x34')](function(){const _0x54c213=_0x5373b9;_0x2ef002[_0x54c213('0x3a')](0xcc)[_0x54c213('0x53')]();});};}function handleEntityNotFound(_0x576839){return function(_0x103c3a){return!_0x103c3a&&_0x576839['sendStatus'](0x194),_0x103c3a;};}function handleError(_0x3a987e,_0x346b32){return _0x346b32=_0x346b32||0x1f4,function(_0x18ed08){const _0x30569e=a626_0x5407;logger[_0x30569e('0x60')](_0x18ed08[_0x30569e('0x3b')]),_0x18ed08[_0x30569e('0x4f')]&&delete _0x18ed08[_0x30569e('0x4f')],_0x3a987e[_0x30569e('0x3a')](_0x346b32)[_0x30569e('0x3c')](_0x18ed08);};}exports[_0x5a5d28('0x58')]=function(_0x2cdd63,_0x31810b){const _0x337f55=_0x5a5d28;let _0x48bdb3={};const _0x54bed4={},_0x3bbe3d={'count':0x0,'rows':[]},_0x36065a=_[_0x337f55('0x22')](db[_0x337f55('0x2e')][_0x337f55('0x36')],function(_0x489f43){const _0x529eec=_0x337f55;return{'name':_0x489f43[_0x529eec('0x13')],'type':_0x489f43[_0x529eec('0x41')][_0x529eec('0x6')]};});_0x54bed4[_0x337f55('0x42')]=_['map'](_0x36065a,_0x337f55('0x4f')),_0x54bed4[_0x337f55('0x4')]=_['keys'](_0x2cdd63[_0x337f55('0x4')]),_0x54bed4[_0x337f55('0x23')]=_[_0x337f55('0x30')](_0x54bed4[_0x337f55('0x42')],_0x54bed4['query']),_0x48bdb3[_0x337f55('0x3f')]=_[_0x337f55('0x30')](_0x54bed4[_0x337f55('0x42')],qs[_0x337f55('0x11')](_0x2cdd63[_0x337f55('0x4')][_0x337f55('0x11')])),_0x48bdb3[_0x337f55('0x3f')]=_0x48bdb3[_0x337f55('0x3f')][_0x337f55('0x44')]?_0x48bdb3[_0x337f55('0x3f')]:_0x54bed4['model'];typeof _0x2cdd63[_0x337f55('0x4')][_0x337f55('0x52')]==='undefined'&&(_0x48bdb3[_0x337f55('0x1c')]=qs[_0x337f55('0x1c')](_0x2cdd63['query'][_0x337f55('0x1c')]),_0x48bdb3[_0x337f55('0xa')]=qs[_0x337f55('0xa')](_0x2cdd63[_0x337f55('0x4')][_0x337f55('0xa')]));_0x48bdb3[_0x337f55('0x4a')]=qs['sort'](_0x2cdd63['query'][_0x337f55('0x51')]),_0x48bdb3[_0x337f55('0x45')]=qs[_0x337f55('0x23')](_['pick'](_0x2cdd63[_0x337f55('0x4')],_0x54bed4[_0x337f55('0x23')]),_0x36065a);_0x2cdd63[_0x337f55('0x4')]['filter']&&(_0x48bdb3[_0x337f55('0x45')]=_[_0x337f55('0x63')](_0x48bdb3[_0x337f55('0x45')],{[Op['or']]:_['map'](_0x36065a,function(_0x3606c5){const _0x9d78a3=_0x337f55;if(_0x3606c5['type']!==_0x9d78a3('0xc')){const _0x12a9f7={};return _0x12a9f7[_0x3606c5['name']]={[Op[_0x9d78a3('0x10')]]:'%'+_0x2cdd63[_0x9d78a3('0x4')][_0x9d78a3('0x49')]+'%'},_0x12a9f7;}})}));_0x48bdb3=_[_0x337f55('0x63')]({},_0x48bdb3,_0x2cdd63['options']);const _0x3ac231={'where':_0x48bdb3['where']};return db[_0x337f55('0x2e')][_0x337f55('0x5e')](_0x3ac231)[_0x337f55('0x34')](function(_0x28a13b){const _0x206406=_0x337f55;return _0x3bbe3d[_0x206406('0x5e')]=_0x28a13b,_0x2cdd63['query'][_0x206406('0x56')]&&(_0x48bdb3[_0x206406('0x5b')]=[{'all':!![]}]),db[_0x206406('0x2e')]['findAll'](_0x48bdb3);})[_0x337f55('0x34')](function(_0x217a39){return _0x3bbe3d['rows']=_0x217a39,_0x3bbe3d;})['then'](respondWithFilteredResult(_0x31810b,_0x48bdb3))['catch'](handleError(_0x31810b,null));},exports['show']=function(_0x1192e7,_0x3b810f){const _0x4dc4eb=_0x5a5d28;let _0x211290={'raw':![],'where':{'id':_0x1192e7[_0x4dc4eb('0x61')]['id']}};const _0x3f9e7b={};return _0x3f9e7b[_0x4dc4eb('0x42')]=_['keys'](db[_0x4dc4eb('0x2e')][_0x4dc4eb('0x36')]),_0x3f9e7b[_0x4dc4eb('0x4')]=_[_0x4dc4eb('0x43')](_0x1192e7[_0x4dc4eb('0x4')]),_0x3f9e7b['filters']=_[_0x4dc4eb('0x30')](_0x3f9e7b[_0x4dc4eb('0x42')],_0x3f9e7b[_0x4dc4eb('0x4')]),_0x211290[_0x4dc4eb('0x3f')]=_['intersection'](_0x3f9e7b['model'],qs[_0x4dc4eb('0x11')](_0x1192e7['query'][_0x4dc4eb('0x11')])),_0x211290[_0x4dc4eb('0x3f')]=_0x211290[_0x4dc4eb('0x3f')][_0x4dc4eb('0x44')]?_0x211290[_0x4dc4eb('0x3f')]:_0x3f9e7b[_0x4dc4eb('0x42')],_0x1192e7['query'][_0x4dc4eb('0x56')]&&(_0x211290[_0x4dc4eb('0x5b')]=[{'all':!![]}]),_0x211290=_['merge']({},_0x211290,_0x1192e7[_0x4dc4eb('0x46')]),db[_0x4dc4eb('0x2e')][_0x4dc4eb('0x1')](_0x211290)[_0x4dc4eb('0x34')](handleEntityNotFound(_0x3b810f,null))[_0x4dc4eb('0x34')](respondWithResult(_0x3b810f,null))[_0x4dc4eb('0x33')](handleError(_0x3b810f,null));},exports['create']=function(_0x48d3af,_0x56c0d2){const _0xd40c20=_0x5a5d28;return db[_0xd40c20('0x2e')]['create'](_0x48d3af['body'],{})[_0xd40c20('0x34')](function(_0x52f98e){const _0x2c3ce8=_0xd40c20,_0x16dd58=_0x48d3af[_0x2c3ce8('0x1e')]['get']({'plain':!![]});if(!_0x16dd58)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x16dd58[_0x2c3ce8('0x59')]===_0x2c3ce8('0x1e')){const _0x218420=_0x52f98e[_0x2c3ce8('0x69')]({'plain':!![]}),_0x54913b=_0x2c3ce8('0xf');return db[_0x2c3ce8('0x68')][_0x2c3ce8('0x1')]({'where':{'name':_0x54913b,'userProfileId':_0x16dd58['userProfileId']},'raw':!![]})[_0x2c3ce8('0x34')](function(_0x4118a9){const _0x43bad7=_0x2c3ce8;return _0x4118a9&&_0x4118a9[_0x43bad7('0x2f')]===0x0?db['UserProfileResource'][_0x43bad7('0xe')]({'name':_0x218420[_0x43bad7('0x4f')],'resourceId':_0x218420['id'],'type':_0x4118a9[_0x43bad7('0x4f')],'sectionId':_0x4118a9['id']},{})[_0x43bad7('0x34')](function(){return _0x52f98e;}):_0x52f98e;})[_0x2c3ce8('0x33')](function(_0x49205f){const _0x4ca7c9=_0x2c3ce8;logger[_0x4ca7c9('0x60')](_0x4ca7c9('0x12'),_0x49205f);throw _0x49205f;});}return _0x52f98e;})[_0xd40c20('0x34')](respondWithResult(_0x56c0d2,0xc9))[_0xd40c20('0x33')](handleError(_0x56c0d2,null));},exports[_0x5a5d28('0x25')]=function(_0x49332e,_0x3561ce){const _0x469a9c=_0x5a5d28;return _0x49332e['body']['id']&&delete _0x49332e['body']['id'],db['Team'][_0x469a9c('0x1')]({'where':{'id':_0x49332e['params']['id']}})['then'](handleEntityNotFound(_0x3561ce,null))['then'](saveUpdates(_0x49332e[_0x469a9c('0x2a')],null))[_0x469a9c('0x34')](respondWithResult(_0x3561ce,null))[_0x469a9c('0x33')](handleError(_0x3561ce,null));},exports[_0x5a5d28('0x50')]=function(_0x164e8f,_0x271cdc){const _0x388ed2=_0x5a5d28;return db['Team'][_0x388ed2('0x1')]({'where':{'id':_0x164e8f[_0x388ed2('0x61')]['id']}})['then'](handleEntityNotFound(_0x271cdc,null))['then'](removeEntity(_0x271cdc,null))[_0x388ed2('0x33')](handleError(_0x271cdc,null));},exports[_0x5a5d28('0x2')]=function(_0x2fe4cb,_0x408fe0){const _0x21dfcc=_0x5a5d28;return db[_0x21dfcc('0x2e')][_0x21dfcc('0x1')]({'where':{'id':_0x2fe4cb[_0x21dfcc('0x61')]['id']}})[_0x21dfcc('0x34')](handleEntityNotFound(_0x408fe0,null))['then'](function(_0x7cbf09){const _0x50e4cb=_0x21dfcc;if(!_0x2fe4cb['query'][_0x50e4cb('0x64')]||!utils[_0x50e4cb('0x1b')](_0x2fe4cb[_0x50e4cb('0x4')][_0x50e4cb('0x64')]))throw new ValidationError(_0x50e4cb('0x40'));let _0x73778={};const _0xfe87ff={};return _0xfe87ff['model']=_[_0x50e4cb('0x43')](db[_[_0x50e4cb('0x5a')](_0x2fe4cb['query']['channel'][_0x50e4cb('0x3e')]())+'Queue'][_0x50e4cb('0x36')]),_0xfe87ff[_0x50e4cb('0x4')]=_[_0x50e4cb('0x43')](_0x2fe4cb['query']),_0xfe87ff[_0x50e4cb('0x23')]=_[_0x50e4cb('0x30')](_0xfe87ff[_0x50e4cb('0x42')],_0xfe87ff[_0x50e4cb('0x4')]),_0x73778[_0x50e4cb('0x3f')]=_['intersection'](_0xfe87ff[_0x50e4cb('0x42')],qs[_0x50e4cb('0x11')](_0x2fe4cb[_0x50e4cb('0x4')][_0x50e4cb('0x11')])),_0x73778['attributes']=_0x73778[_0x50e4cb('0x3f')]['length']?_0x73778[_0x50e4cb('0x3f')]:_0xfe87ff[_0x50e4cb('0x42')],_0x73778[_0x50e4cb('0x1c')]=qs[_0x50e4cb('0x1c')](_0x2fe4cb['query'][_0x50e4cb('0x1c')]),_0x73778['offset']=qs['offset'](_0x2fe4cb[_0x50e4cb('0x4')][_0x50e4cb('0xa')]),_0x73778[_0x50e4cb('0x4a')]=qs['sort'](_0x2fe4cb[_0x50e4cb('0x4')]['sort']),_0x73778['where']=qs['filters'](_[_0x50e4cb('0x5c')](_0x2fe4cb[_0x50e4cb('0x4')],_0xfe87ff[_0x50e4cb('0x23')])),_0x73778=_[_0x50e4cb('0x63')]({},_0x73778,_0x2fe4cb[_0x50e4cb('0x46')]),_0x7cbf09[_0x50e4cb('0x69')+_[_0x50e4cb('0x5a')](_0x2fe4cb['query']['channel'][_0x50e4cb('0x3e')]())+_0x50e4cb('0x8')](_0x73778);})[_0x21dfcc('0x34')](respondWithResult(_0x408fe0,null))[_0x21dfcc('0x33')](handleError(_0x408fe0,null));},exports[_0x5a5d28('0x47')]=function(_0x2bdcb5,_0x1ab86a){const _0x5e227f=_0x5a5d28;return db[_0x5e227f('0x2e')]['findOne']({'where':{'id':_0x2bdcb5[_0x5e227f('0x61')]['id']}})[_0x5e227f('0x34')](function(_0x4a677b){const _0x485f71=_0x5e227f;if(_0x4a677b){if(!_0x2bdcb5[_0x485f71('0x2a')][_0x485f71('0x64')]||!utils[_0x485f71('0x1b')](_0x2bdcb5['body'][_0x485f71('0x64')]))throw new ValidationError(_0x485f71('0x40'));return _0x4a677b[_0x485f71('0x2b')+_[_0x485f71('0x5a')](_0x2bdcb5[_0x485f71('0x2a')]['channel'][_0x485f71('0x3e')]())+_0x485f71('0x8')](_0x2bdcb5[_0x485f71('0x2a')][_0x485f71('0x4b')]);}return null;})[_0x5e227f('0x34')](handleEntityNotFound(_0x1ab86a,null))['then'](respondWithStatusCode(_0x1ab86a,null))[_0x5e227f('0x33')](handleError(_0x1ab86a,null));},exports['removeQueues']=function(_0x383ba9,_0x29e5cd){const _0x794c7c=_0x5a5d28;return db['Team'][_0x794c7c('0x1')]({'where':{'id':_0x383ba9[_0x794c7c('0x61')]['id']}})[_0x794c7c('0x34')](function(_0x15b5d9){const _0x2bccf4=_0x794c7c;if(_0x15b5d9){if(!_0x383ba9['query'][_0x2bccf4('0x64')]||!utils['isValidChannel'](_0x383ba9[_0x2bccf4('0x4')]['channel']))throw new ValidationError(_0x2bccf4('0x40'));return _0x15b5d9[_0x2bccf4('0x1a')+_[_0x2bccf4('0x5a')](_0x383ba9[_0x2bccf4('0x4')][_0x2bccf4('0x64')][_0x2bccf4('0x3e')]())+_0x2bccf4('0x8')](_0x383ba9[_0x2bccf4('0x4')][_0x2bccf4('0x4b')]);}return null;})[_0x794c7c('0x34')](handleEntityNotFound(_0x29e5cd,null))[_0x794c7c('0x34')](respondWithStatusCode(_0x29e5cd,null))['catch'](handleError(_0x29e5cd,null));},exports[_0x5a5d28('0x55')]=function(_0x4b56b1,_0x3cc869){const _0x58a18c=_0x5a5d28;return db[_0x58a18c('0x2e')][_0x58a18c('0x1')]({'where':{'id':_0x4b56b1[_0x58a18c('0x61')]['id']}})[_0x58a18c('0x34')](function(_0x518468){const _0x40e57c=_0x58a18c;if(_0x518468){const _0x3297b3=['Voice',_0x40e57c('0x54'),_0x40e57c('0x26'),_0x40e57c('0x5d'),_0x40e57c('0x37'),_0x40e57c('0x27'),_0x40e57c('0x48')];return Promise[_0x40e57c('0x2d')](_0x3297b3,function(_0x5cc781){const _0x53ad6b=_0x40e57c;return _0x518468[_0x53ad6b('0x69')+_0x5cc781+'Queues']({'attributes':['id',_0x53ad6b('0x4f')]})[_0x53ad6b('0x34')](function(_0x540de3){const _0x2bb205=_0x53ad6b;return Promise[_0x2bb205('0x2d')](_0x540de3,function(_0xb78357){const _0x5ab169=_0x2bb205;return _0xb78357['addAgents'](_0x4b56b1[_0x5ab169('0x2a')]['ids'])[_0x5ab169('0x34')](function(){const _0x821880=_0x5ab169;if(_0x5cc781==='Voice')return db[_0x821880('0x24')][_0x821880('0x31')]({'where':{'id':_0x4b56b1['body'][_0x821880('0x4b')]},'attributes':['id',_0x821880('0x4f'),_0x821880('0x32'),'voicePause',_0x821880('0x19')],'raw':!![]})[_0x821880('0x34')](function(_0x2abb9e){const _0xe28111=_0x821880;return Promise[_0xe28111('0x2d')](_['filter'](_0x2abb9e,{'online':0x1}),function(_0x305c45){const _0x1c2f83=_0xe28111;return db[_0x1c2f83('0x21')][_0x1c2f83('0x29')]({'membername':_0x305c45[_0x1c2f83('0x4f')],'UserId':_0x305c45['id'],'queue_name':_0xb78357[_0x1c2f83('0x4f')],'VoiceQueueId':_0xb78357['id'],'interface':_[_0x1c2f83('0x57')](_0x305c45[_0x1c2f83('0x19')])?util[_0x1c2f83('0x4c')]('SIP/%s',_0x305c45['name']):_0x305c45[_0x1c2f83('0x19')],'paused':_0x305c45[_0x1c2f83('0x39')]||![],'penalty':0x0});});});});});})[_0x53ad6b('0x34')](function(){return _0x518468;});})[_0x40e57c('0x34')](function(){return _0x518468;});}})[_0x58a18c('0x34')](function(_0xa8b7f2){const _0x13d2d8=_0x58a18c;if(_0xa8b7f2)return _0xa8b7f2[_0x13d2d8('0x55')](_0x4b56b1['body'][_0x13d2d8('0x4b')],{'through':_['omit'](_0x4b56b1[_0x13d2d8('0x2a')],[_0x13d2d8('0x4b'),'id'])})[_0x13d2d8('0x34')](function(_0x11e0c0){const _0x43b216=_0x13d2d8;for(let _0x50b839=0x0;_0x50b839<_0x4b56b1[_0x43b216('0x2a')]['ids'][_0x43b216('0x44')];_0x50b839+=0x1){socket[_0x43b216('0x62')](_0x43b216('0x38'),{'UserId':_0x4b56b1['body'][_0x43b216('0x4b')][_0x50b839],'TeamId':_0x4b56b1[_0x43b216('0x61')]['id']});}return _0x11e0c0;});})[_0x58a18c('0x34')](respondWithResult(_0x3cc869,null))[_0x58a18c('0x33')](handleError(_0x3cc869,null));},exports[_0x5a5d28('0x14')]=function(_0xf93187,_0x1d6740){const _0x170e8a=_0x5a5d28;return db[_0x170e8a('0x2e')][_0x170e8a('0x1')]({'where':{'id':_0xf93187[_0x170e8a('0x61')]['id']}})['then'](handleEntityNotFound(_0x1d6740,null))[_0x170e8a('0x34')](function(_0x256370){const _0x1558a0=_0x170e8a;if(_0x256370){const _0x5b73a7=['voice',_0x1558a0('0x18'),_0x1558a0('0x15'),_0x1558a0('0x0'),_0x1558a0('0x5'),_0x1558a0('0x4e'),_0x1558a0('0x1d')];return Promise[_0x1558a0('0x66')](_0x5b73a7[_0x1558a0('0x22')](async _0x1f3687=>{const _0x56cc6e=_0x1558a0,_0x4dd6cb=await _0x256370['get'+_[_0x56cc6e('0x5a')](_0x1f3687)+'Queues']({'attributes':['id',_0x56cc6e('0x4f')]});return _0x4dd6cb[_0x56cc6e('0x44')]>0x0&&(await _0x4dd6cb[_0x56cc6e('0x14')](_0xf93187[_0x56cc6e('0x4')]['ids']),_0x1f3687===_0x56cc6e('0x5f')&&await db[_0x56cc6e('0x21')]['destroy']({'where':{'VoiceQueueId':_0x4dd6cb['id'],'UserId':_0xf93187[_0x56cc6e('0x4')]['ids']}})),_0x256370;}))[_0x1558a0('0x34')](function(){return _0x256370;});}})[_0x170e8a('0x34')](function(_0x2ada7c){const _0x5d091a=_0x170e8a;if(_0x2ada7c)return _0x2ada7c[_0x5d091a('0x14')](_0xf93187[_0x5d091a('0x4')][_0x5d091a('0x4b')])['then'](function(){const _0x3e2953=_0x5d091a;if(_['isArray'](_0xf93187[_0x3e2953('0x4')][_0x3e2953('0x4b')]))for(let _0x4559e1=0x0;_0x4559e1<_0xf93187['query'][_0x3e2953('0x4b')][_0x3e2953('0x44')];_0x4559e1+=0x1){socket[_0x3e2953('0x62')](_0x3e2953('0x20'),{'UserId':Number(_0xf93187['query']['ids'][_0x4559e1]),'TeamId':Number(_0xf93187[_0x3e2953('0x61')]['id'])});}else socket[_0x3e2953('0x62')](_0x3e2953('0x20'),{'UserId':Number(_0xf93187[_0x3e2953('0x4')][_0x3e2953('0x4b')]),'TeamId':Number(_0xf93187[_0x3e2953('0x61')]['id'])});});})['then'](respondWithStatusCode(_0x1d6740,null))[_0x170e8a('0x33')](handleError(_0x1d6740,null));},exports[_0x5a5d28('0xd')]=function(_0x12f431,_0x292e03){const _0x5d305e=_0x5a5d28;let _0x7e41ea={};const _0x4b38f3={};let _0x16aa18,_0xa53f4a;return db[_0x5d305e('0x2e')][_0x5d305e('0x1')]({'where':{'id':_0x12f431['params']['id']}})['then'](handleEntityNotFound(_0x292e03,null))[_0x5d305e('0x34')](function(_0x2c354a){const _0x2f5ca0=_0x5d305e;if(_0x2c354a)return _0x16aa18=_0x2c354a,_0x4b38f3[_0x2f5ca0('0x42')]=_['keys'](db[_0x2f5ca0('0x24')]['rawAttributes']),_0x4b38f3[_0x2f5ca0('0x4')]=_[_0x2f5ca0('0x43')](_0x12f431[_0x2f5ca0('0x4')]),_0x4b38f3['filters']=_[_0x2f5ca0('0x30')](_0x4b38f3[_0x2f5ca0('0x42')],_0x4b38f3[_0x2f5ca0('0x4')]),_0x7e41ea[_0x2f5ca0('0x3f')]=_[_0x2f5ca0('0x30')](_0x4b38f3[_0x2f5ca0('0x42')],qs['fields'](_0x12f431[_0x2f5ca0('0x4')][_0x2f5ca0('0x11')])),_0x7e41ea[_0x2f5ca0('0x3f')]=_0x7e41ea['attributes']['length']?_0x7e41ea[_0x2f5ca0('0x3f')]:_0x4b38f3['model'],_0x7e41ea[_0x2f5ca0('0x4a')]=qs[_0x2f5ca0('0x51')](_0x12f431[_0x2f5ca0('0x4')][_0x2f5ca0('0x51')]),_0x7e41ea[_0x2f5ca0('0x45')]=qs['filters'](_[_0x2f5ca0('0x5c')](_0x12f431['query'],_0x4b38f3[_0x2f5ca0('0x23')])),_0x12f431[_0x2f5ca0('0x4')][_0x2f5ca0('0x49')]&&(_0x7e41ea[_0x2f5ca0('0x45')]=_[_0x2f5ca0('0x63')](_0x7e41ea[_0x2f5ca0('0x45')],{[Op['or']]:_[_0x2f5ca0('0x22')](_0x7e41ea[_0x2f5ca0('0x3f')],function(_0x8fa0c3){const _0x231552=_0x2f5ca0,_0x21ad7b={};return _0x21ad7b[_0x8fa0c3]={[Op[_0x231552('0x10')]]:'%'+_0x12f431[_0x231552('0x4')]['filter']+'%'},_0x21ad7b;})})),_0x7e41ea=_[_0x2f5ca0('0x63')]({},_0x7e41ea,_0x12f431[_0x2f5ca0('0x46')]),_0x16aa18['getAgents'](_0x7e41ea);})[_0x5d305e('0x34')](function(_0x29ba71){const _0x171ed5=_0x5d305e;if(_0x29ba71)return _0xa53f4a=_0x29ba71[_0x171ed5('0x44')],typeof _0x12f431[_0x171ed5('0x4')][_0x171ed5('0x52')]===_0x171ed5('0x35')&&(_0x7e41ea[_0x171ed5('0x1c')]=qs['limit'](_0x12f431[_0x171ed5('0x4')][_0x171ed5('0x1c')]),_0x7e41ea['offset']=qs[_0x171ed5('0xa')](_0x12f431[_0x171ed5('0x4')]['offset'])),_0x16aa18['getAgents'](_0x7e41ea);})[_0x5d305e('0x34')](function(_0x390cd7){if(_0x390cd7)return _0x390cd7?{'count':_0xa53f4a,'rows':_0x390cd7}:null;})[_0x5d305e('0x34')](respondWithResult(_0x292e03,null))[_0x5d305e('0x33')](handleError(_0x292e03,null));};
\ No newline at end of file
+const a626_0x18f5=['Queues','Fax','UserProfileResource','interface','merge','key','count','userTeam:remove','mail','format','ids','map','Voice','type','Content-Range','util','findAll','User','filter','lodash','getAgents','get','error','name','pick','toLowerCase','limit','getQueues','attributes','stack','Team','catch','all','then','each','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','fieldName','removeAgents','keys','Mail','Unable\x20to\x20retrieve\x20the\x20current\x20user','options','Whatsapp','findOne','fields','create','add','autoAssociation','nolimit','isArray','user','upsert','undefined','voicePause','VIRTUAL','set','addAgents','rows','body','userProfileId','../../mysqldb','removeQueues','where','update','index','addQueues','Queue','like','capitalize','./team.socket','channel','include','isValidChannel','length','api','filters','rawAttributes','model','isNil','UserVoiceQueueRt','emit','sort','openchannel','intersection','includeAll','params','Teams','userTeam:save','query','order','send','role','register','../../config/utils','Sms','status','destroy','json','voice','chat','offset','../../config/logger','../../components/parsers/qs','omit','Unknown\x20channel','end','sendStatus'];(function(_0x4ee6d0,_0x18f589){const _0x174319=function(_0x48d8b6){while(--_0x48d8b6){_0x4ee6d0['push'](_0x4ee6d0['shift']());}};_0x174319(++_0x18f589);}(a626_0x18f5,0x1f0));const a626_0x1743=function(_0x4ee6d0,_0x18f589){_0x4ee6d0=_0x4ee6d0-0x0;let _0x174319=a626_0x18f5[_0x4ee6d0];return _0x174319;};const _0x1814e9=a626_0x1743;'use strict';const util=require(_0x1814e9('0x36')),_=require(_0x1814e9('0x3a')),qs=require(_0x1814e9('0x22')),logger=require(_0x1814e9('0x21'))(_0x1814e9('0x6')),utils=require(_0x1814e9('0x19')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require(_0x1814e9('0x63'))['db'],{Op,ValidationError}=require('sequelize');require(_0x1814e9('0x1'))[_0x1814e9('0x18')](socket);function respondWithStatusCode(_0x48d8b6,_0x4eb5b5){return _0x4eb5b5=_0x4eb5b5||0xcc,function(_0x453cd7){const _0x29149=a626_0x1743;if(_0x453cd7)return _0x48d8b6[_0x29149('0x26')](_0x4eb5b5);return _0x48d8b6['status'](_0x4eb5b5)[_0x29149('0x25')]();};}function respondWithResult(_0x553d22,_0x39a1a9){return _0x39a1a9=_0x39a1a9||0xc8,function(_0x5e5454){const _0x26f6bf=a626_0x1743;if(_0x5e5454)return _0x553d22['status'](_0x39a1a9)[_0x26f6bf('0x1d')](_0x5e5454);};}function respondWithFilteredResult(_0x2ec401,_0x39a363){return function(_0x1b288e){const _0x1e61af=a626_0x1743;if(_0x1b288e){const _0x12c3f1=_0x1b288e[_0x1e61af('0x2d')],_0x493124=_0x39a363[_0x1e61af('0x20')];let _0x5ccd78=_0x39a363[_0x1e61af('0x20')]+_0x39a363['limit'],_0x7572d3;return _0x5ccd78>=_0x12c3f1?(_0x5ccd78=_0x12c3f1,_0x7572d3=0xc8):_0x7572d3=0xce,_0x2ec401[_0x1e61af('0x1b')](_0x7572d3),_0x2ec401[_0x1e61af('0x5e')](_0x1e61af('0x35'),_0x493124+'-'+_0x5ccd78+'/'+_0x12c3f1)[_0x1e61af('0x1d')](_0x1b288e);}return null;};}function saveUpdates(_0x46bc4a){return function(_0x29d44a){const _0xdf490d=a626_0x1743;if(_0x29d44a)return _0x29d44a[_0xdf490d('0x66')](_0x46bc4a)[_0xdf490d('0x48')](function(_0x4d18b8){return _0x4d18b8;});return null;};}function removeEntity(_0x320a06){return function(_0x5a91aa){const _0x3dd19b=a626_0x1743;if(_0x5a91aa)return _0x5a91aa['destroy']()[_0x3dd19b('0x48')](function(){const _0x24c310=_0x3dd19b,_0x38be88=_0x5a91aa['get']({'plain':!![]}),_0x2c8b3c=_0x24c310('0x12');return db[_0x24c310('0x29')][_0x24c310('0x1c')]({'where':{'type':_0x2c8b3c,'resourceId':_0x38be88['id']}})['then'](function(){return _0x5a91aa;});})[_0x3dd19b('0x48')](function(){const _0x3e1213=_0x3dd19b;_0x320a06[_0x3e1213('0x1b')](0xcc)[_0x3e1213('0x25')]();});};}function handleEntityNotFound(_0x54aa69){return function(_0x3d4d03){const _0x473883=a626_0x1743;return!_0x3d4d03&&_0x54aa69[_0x473883('0x26')](0x194),_0x3d4d03;};}function handleError(_0x40e349,_0x3ff084){return _0x3ff084=_0x3ff084||0x1f4,function(_0x992da9){const _0x37f031=a626_0x1743;logger['error'](_0x992da9[_0x37f031('0x44')]),_0x992da9[_0x37f031('0x3e')]&&delete _0x992da9[_0x37f031('0x3e')],_0x40e349[_0x37f031('0x1b')](_0x3ff084)[_0x37f031('0x16')](_0x992da9);};}exports[_0x1814e9('0x67')]=function(_0x14be79,_0xc136c8){const _0xb70cb=_0x1814e9;let _0x3c1df9={};const _0xcac169={},_0x278953={'count':0x0,'rows':[]},_0x3ef6ec=_[_0xb70cb('0x32')](db['Team'][_0xb70cb('0x8')],function(_0x2426c9){const _0x2984ff=_0xb70cb;return{'name':_0x2426c9[_0x2984ff('0x4b')],'type':_0x2426c9[_0x2984ff('0x34')][_0x2984ff('0x2c')]};});_0xcac169['model']=_['map'](_0x3ef6ec,_0xb70cb('0x3e')),_0xcac169[_0xb70cb('0x14')]=_[_0xb70cb('0x4d')](_0x14be79[_0xb70cb('0x14')]),_0xcac169[_0xb70cb('0x7')]=_['intersection'](_0xcac169[_0xb70cb('0x9')],_0xcac169[_0xb70cb('0x14')]),_0x3c1df9[_0xb70cb('0x43')]=_[_0xb70cb('0xf')](_0xcac169[_0xb70cb('0x9')],qs[_0xb70cb('0x53')](_0x14be79['query'][_0xb70cb('0x53')])),_0x3c1df9[_0xb70cb('0x43')]=_0x3c1df9[_0xb70cb('0x43')][_0xb70cb('0x5')]?_0x3c1df9[_0xb70cb('0x43')]:_0xcac169['model'];typeof _0x14be79[_0xb70cb('0x14')][_0xb70cb('0x57')]===_0xb70cb('0x5b')&&(_0x3c1df9[_0xb70cb('0x41')]=qs[_0xb70cb('0x41')](_0x14be79[_0xb70cb('0x14')][_0xb70cb('0x41')]),_0x3c1df9[_0xb70cb('0x20')]=qs[_0xb70cb('0x20')](_0x14be79['query'][_0xb70cb('0x20')]));_0x3c1df9['order']=qs[_0xb70cb('0xd')](_0x14be79[_0xb70cb('0x14')][_0xb70cb('0xd')]),_0x3c1df9[_0xb70cb('0x65')]=qs[_0xb70cb('0x7')](_[_0xb70cb('0x3f')](_0x14be79[_0xb70cb('0x14')],_0xcac169[_0xb70cb('0x7')]),_0x3ef6ec);_0x14be79[_0xb70cb('0x14')][_0xb70cb('0x39')]&&(_0x3c1df9[_0xb70cb('0x65')]=_['merge'](_0x3c1df9[_0xb70cb('0x65')],{[Op['or']]:_['map'](_0x3ef6ec,function(_0x1df89e){const _0x40708a=_0xb70cb;if(_0x1df89e[_0x40708a('0x34')]!==_0x40708a('0x5d')){const _0x46660d={};return _0x46660d[_0x1df89e[_0x40708a('0x3e')]]={[Op[_0x40708a('0x6a')]]:'%'+_0x14be79[_0x40708a('0x14')][_0x40708a('0x39')]+'%'},_0x46660d;}})}));_0x3c1df9=_[_0xb70cb('0x2b')]({},_0x3c1df9,_0x14be79[_0xb70cb('0x50')]);const _0x5032f9={'where':_0x3c1df9[_0xb70cb('0x65')]};return db[_0xb70cb('0x45')][_0xb70cb('0x2d')](_0x5032f9)[_0xb70cb('0x48')](function(_0x1dc075){const _0x1b8532=_0xb70cb;return _0x278953['count']=_0x1dc075,_0x14be79[_0x1b8532('0x14')]['includeAll']&&(_0x3c1df9[_0x1b8532('0x3')]=[{'all':!![]}]),db['Team']['findAll'](_0x3c1df9);})['then'](function(_0x3e3cfb){const _0x2c9b99=_0xb70cb;return _0x278953[_0x2c9b99('0x60')]=_0x3e3cfb,_0x278953;})[_0xb70cb('0x48')](respondWithFilteredResult(_0xc136c8,_0x3c1df9))[_0xb70cb('0x46')](handleError(_0xc136c8,null));},exports['show']=function(_0x151b52,_0x38be69){const _0x3220ce=_0x1814e9;let _0x2b1417={'raw':![],'where':{'id':_0x151b52['params']['id']}};const _0x49e109={};return _0x49e109[_0x3220ce('0x9')]=_[_0x3220ce('0x4d')](db[_0x3220ce('0x45')][_0x3220ce('0x8')]),_0x49e109[_0x3220ce('0x14')]=_[_0x3220ce('0x4d')](_0x151b52[_0x3220ce('0x14')]),_0x49e109['filters']=_['intersection'](_0x49e109[_0x3220ce('0x9')],_0x49e109[_0x3220ce('0x14')]),_0x2b1417[_0x3220ce('0x43')]=_[_0x3220ce('0xf')](_0x49e109['model'],qs['fields'](_0x151b52[_0x3220ce('0x14')][_0x3220ce('0x53')])),_0x2b1417[_0x3220ce('0x43')]=_0x2b1417[_0x3220ce('0x43')][_0x3220ce('0x5')]?_0x2b1417[_0x3220ce('0x43')]:_0x49e109['model'],_0x151b52[_0x3220ce('0x14')][_0x3220ce('0x10')]&&(_0x2b1417[_0x3220ce('0x3')]=[{'all':!![]}]),_0x2b1417=_[_0x3220ce('0x2b')]({},_0x2b1417,_0x151b52[_0x3220ce('0x50')]),db[_0x3220ce('0x45')][_0x3220ce('0x52')](_0x2b1417)[_0x3220ce('0x48')](handleEntityNotFound(_0x38be69,null))[_0x3220ce('0x48')](respondWithResult(_0x38be69,null))[_0x3220ce('0x46')](handleError(_0x38be69,null));},exports[_0x1814e9('0x54')]=function(_0x14d18f,_0x2115b7){const _0x27058a=_0x1814e9;return db['Team']['create'](_0x14d18f[_0x27058a('0x61')],{})['then'](function(_0x725899){const _0x2219c8=_0x27058a,_0x456a0c=_0x14d18f[_0x2219c8('0x59')][_0x2219c8('0x3c')]({'plain':!![]});if(!_0x456a0c)throw new Error(_0x2219c8('0x4f'));if(_0x456a0c[_0x2219c8('0x17')]==='user'){const _0x43aff8=_0x725899[_0x2219c8('0x3c')]({'plain':!![]}),_0x2a4c29='Teams';return db['UserProfileSection'][_0x2219c8('0x52')]({'where':{'name':_0x2a4c29,'userProfileId':_0x456a0c[_0x2219c8('0x62')]},'raw':!![]})[_0x2219c8('0x48')](function(_0x165df8){const _0x2ac3e7=_0x2219c8;return _0x165df8&&_0x165df8[_0x2ac3e7('0x56')]===0x0?db[_0x2ac3e7('0x29')][_0x2ac3e7('0x54')]({'name':_0x43aff8[_0x2ac3e7('0x3e')],'resourceId':_0x43aff8['id'],'type':_0x165df8[_0x2ac3e7('0x3e')],'sectionId':_0x165df8['id']},{})['then'](function(){return _0x725899;}):_0x725899;})[_0x2219c8('0x46')](function(_0x5a5d00){const _0x4f01fc=_0x2219c8;logger[_0x4f01fc('0x3d')](_0x4f01fc('0x4a'),_0x5a5d00);throw _0x5a5d00;});}return _0x725899;})[_0x27058a('0x48')](respondWithResult(_0x2115b7,0xc9))[_0x27058a('0x46')](handleError(_0x2115b7,null));},exports[_0x1814e9('0x66')]=function(_0x266037,_0x4d398c){const _0x5c56d2=_0x1814e9;return _0x266037[_0x5c56d2('0x61')]['id']&&delete _0x266037['body']['id'],db[_0x5c56d2('0x45')]['findOne']({'where':{'id':_0x266037[_0x5c56d2('0x11')]['id']}})[_0x5c56d2('0x48')](handleEntityNotFound(_0x4d398c,null))[_0x5c56d2('0x48')](saveUpdates(_0x266037[_0x5c56d2('0x61')],null))[_0x5c56d2('0x48')](respondWithResult(_0x4d398c,null))['catch'](handleError(_0x4d398c,null));},exports[_0x1814e9('0x1c')]=function(_0x345296,_0x39ada0){const _0x6a0393=_0x1814e9;return db[_0x6a0393('0x45')][_0x6a0393('0x52')]({'where':{'id':_0x345296[_0x6a0393('0x11')]['id']}})[_0x6a0393('0x48')](handleEntityNotFound(_0x39ada0,null))[_0x6a0393('0x48')](removeEntity(_0x39ada0,null))[_0x6a0393('0x46')](handleError(_0x39ada0,null));},exports[_0x1814e9('0x42')]=function(_0x522cc8,_0x7a7728){const _0x5879cf=_0x1814e9;return db[_0x5879cf('0x45')]['findOne']({'where':{'id':_0x522cc8[_0x5879cf('0x11')]['id']}})[_0x5879cf('0x48')](handleEntityNotFound(_0x7a7728,null))[_0x5879cf('0x48')](function(_0x5855b5){const _0x22776f=_0x5879cf;if(!_0x522cc8[_0x22776f('0x14')][_0x22776f('0x2')]||!utils['isValidChannel'](_0x522cc8[_0x22776f('0x14')][_0x22776f('0x2')]))throw new ValidationError('Unknown\x20channel');let _0x274d24={};const _0x2391a5={};return _0x2391a5[_0x22776f('0x9')]=_[_0x22776f('0x4d')](db[_[_0x22776f('0x0')](_0x522cc8['query']['channel'][_0x22776f('0x40')]())+_0x22776f('0x69')]['rawAttributes']),_0x2391a5[_0x22776f('0x14')]=_[_0x22776f('0x4d')](_0x522cc8[_0x22776f('0x14')]),_0x2391a5['filters']=_[_0x22776f('0xf')](_0x2391a5[_0x22776f('0x9')],_0x2391a5[_0x22776f('0x14')]),_0x274d24['attributes']=_['intersection'](_0x2391a5['model'],qs['fields'](_0x522cc8[_0x22776f('0x14')][_0x22776f('0x53')])),_0x274d24[_0x22776f('0x43')]=_0x274d24[_0x22776f('0x43')][_0x22776f('0x5')]?_0x274d24[_0x22776f('0x43')]:_0x2391a5['model'],_0x274d24[_0x22776f('0x41')]=qs[_0x22776f('0x41')](_0x522cc8[_0x22776f('0x14')][_0x22776f('0x41')]),_0x274d24[_0x22776f('0x20')]=qs['offset'](_0x522cc8[_0x22776f('0x14')]['offset']),_0x274d24[_0x22776f('0x15')]=qs['sort'](_0x522cc8[_0x22776f('0x14')][_0x22776f('0xd')]),_0x274d24[_0x22776f('0x65')]=qs[_0x22776f('0x7')](_[_0x22776f('0x3f')](_0x522cc8[_0x22776f('0x14')],_0x2391a5[_0x22776f('0x7')])),_0x274d24=_[_0x22776f('0x2b')]({},_0x274d24,_0x522cc8['options']),_0x5855b5[_0x22776f('0x3c')+_[_0x22776f('0x0')](_0x522cc8['query'][_0x22776f('0x2')][_0x22776f('0x40')]())+_0x22776f('0x27')](_0x274d24);})['then'](respondWithResult(_0x7a7728,null))[_0x5879cf('0x46')](handleError(_0x7a7728,null));},exports[_0x1814e9('0x68')]=function(_0x54abdf,_0x38e4b7){const _0x5d6955=_0x1814e9;return db[_0x5d6955('0x45')][_0x5d6955('0x52')]({'where':{'id':_0x54abdf[_0x5d6955('0x11')]['id']}})['then'](function(_0x49591f){const _0x11c8d8=_0x5d6955;if(_0x49591f){if(!_0x54abdf[_0x11c8d8('0x61')][_0x11c8d8('0x2')]||!utils[_0x11c8d8('0x4')](_0x54abdf[_0x11c8d8('0x61')]['channel']))throw new ValidationError(_0x11c8d8('0x24'));return _0x49591f[_0x11c8d8('0x55')+_[_0x11c8d8('0x0')](_0x54abdf[_0x11c8d8('0x61')][_0x11c8d8('0x2')][_0x11c8d8('0x40')]())+_0x11c8d8('0x27')](_0x54abdf[_0x11c8d8('0x61')]['ids']);}return null;})[_0x5d6955('0x48')](handleEntityNotFound(_0x38e4b7,null))['then'](respondWithStatusCode(_0x38e4b7,null))[_0x5d6955('0x46')](handleError(_0x38e4b7,null));},exports[_0x1814e9('0x64')]=function(_0xb8b98d,_0x2118e0){const _0x1b67e5=_0x1814e9;return db[_0x1b67e5('0x45')][_0x1b67e5('0x52')]({'where':{'id':_0xb8b98d[_0x1b67e5('0x11')]['id']}})[_0x1b67e5('0x48')](function(_0x36bdbc){const _0x9bc417=_0x1b67e5;if(_0x36bdbc){if(!_0xb8b98d[_0x9bc417('0x14')]['channel']||!utils[_0x9bc417('0x4')](_0xb8b98d[_0x9bc417('0x14')]['channel']))throw new ValidationError(_0x9bc417('0x24'));return _0x36bdbc['remove'+_['capitalize'](_0xb8b98d[_0x9bc417('0x14')][_0x9bc417('0x2')]['toLowerCase']())+_0x9bc417('0x27')](_0xb8b98d['query']['ids']);}return null;})[_0x1b67e5('0x48')](handleEntityNotFound(_0x2118e0,null))[_0x1b67e5('0x48')](respondWithStatusCode(_0x2118e0,null))[_0x1b67e5('0x46')](handleError(_0x2118e0,null));},exports[_0x1814e9('0x5f')]=function(_0x5eb76b,_0x27babb){const _0x41970e=_0x1814e9;return db[_0x41970e('0x45')][_0x41970e('0x52')]({'where':{'id':_0x5eb76b['params']['id']}})[_0x41970e('0x48')](function(_0x18dafc){const _0x43497f=_0x41970e;if(_0x18dafc){const _0x56211c=[_0x43497f('0x33'),'Chat',_0x43497f('0x4e'),_0x43497f('0x1a'),_0x43497f('0x28'),'Openchannel',_0x43497f('0x51')];return Promise[_0x43497f('0x49')](_0x56211c,function(_0x5d2d5c){const _0xd7c0dc=_0x43497f;return _0x18dafc['get'+_0x5d2d5c+_0xd7c0dc('0x27')]({'attributes':['id',_0xd7c0dc('0x3e')]})[_0xd7c0dc('0x48')](function(_0x65c24c){const _0x328616=_0xd7c0dc;return Promise[_0x328616('0x49')](_0x65c24c,function(_0x358bd6){const _0x16d075=_0x328616;return _0x358bd6[_0x16d075('0x5f')](_0x5eb76b[_0x16d075('0x61')]['ids'])[_0x16d075('0x48')](function(){const _0x88e057=_0x16d075;if(_0x5d2d5c===_0x88e057('0x33'))return db[_0x88e057('0x38')][_0x88e057('0x37')]({'where':{'id':_0x5eb76b['body'][_0x88e057('0x31')]},'attributes':['id',_0x88e057('0x3e'),'online',_0x88e057('0x5c'),_0x88e057('0x2a')],'raw':!![]})[_0x88e057('0x48')](function(_0x555728){return Promise['each'](_['filter'](_0x555728,{'online':0x1}),function(_0x3aad5e){const _0x47e2d4=a626_0x1743;return db[_0x47e2d4('0xb')][_0x47e2d4('0x5a')]({'membername':_0x3aad5e[_0x47e2d4('0x3e')],'UserId':_0x3aad5e['id'],'queue_name':_0x358bd6[_0x47e2d4('0x3e')],'VoiceQueueId':_0x358bd6['id'],'interface':_[_0x47e2d4('0xa')](_0x3aad5e['interface'])?util[_0x47e2d4('0x30')]('SIP/%s',_0x3aad5e['name']):_0x3aad5e[_0x47e2d4('0x2a')],'paused':_0x3aad5e['voicePause']||![],'penalty':0x0});});});});});})['then'](function(){return _0x18dafc;});})[_0x43497f('0x48')](function(){return _0x18dafc;});}})[_0x41970e('0x48')](function(_0x2704ea){const _0x3cc5dc=_0x41970e;if(_0x2704ea)return _0x2704ea['addAgents'](_0x5eb76b[_0x3cc5dc('0x61')][_0x3cc5dc('0x31')],{'through':_[_0x3cc5dc('0x23')](_0x5eb76b[_0x3cc5dc('0x61')],['ids','id'])})['then'](function(_0x5a32b5){const _0x5bc262=_0x3cc5dc;for(let _0x3eafcb=0x0;_0x3eafcb<_0x5eb76b[_0x5bc262('0x61')]['ids'][_0x5bc262('0x5')];_0x3eafcb+=0x1){socket[_0x5bc262('0xc')](_0x5bc262('0x13'),{'UserId':_0x5eb76b[_0x5bc262('0x61')][_0x5bc262('0x31')][_0x3eafcb],'TeamId':_0x5eb76b[_0x5bc262('0x11')]['id']});}return _0x5a32b5;});})[_0x41970e('0x48')](respondWithResult(_0x27babb,null))[_0x41970e('0x46')](handleError(_0x27babb,null));},exports['removeAgents']=function(_0x5ee79d,_0xf608a5){const _0x3c8260=_0x1814e9;return db[_0x3c8260('0x45')][_0x3c8260('0x52')]({'where':{'id':_0x5ee79d[_0x3c8260('0x11')]['id']}})[_0x3c8260('0x48')](handleEntityNotFound(_0xf608a5,null))[_0x3c8260('0x48')](function(_0x43ac94){const _0x3691c1=_0x3c8260;if(_0x43ac94){const _0x4ffd8d=['voice',_0x3691c1('0x1f'),_0x3691c1('0x2f'),'sms','fax',_0x3691c1('0xe'),'whatsapp'];return Promise[_0x3691c1('0x47')](_0x4ffd8d['map'](async _0x102797=>{const _0x4d2206=_0x3691c1,_0x3ad2cd=await _0x43ac94['get'+_[_0x4d2206('0x0')](_0x102797)+'Queues']({'attributes':['id',_0x4d2206('0x3e')]});return _0x3ad2cd[_0x4d2206('0x5')]>0x0&&(await _0x3ad2cd[_0x4d2206('0x4c')](_0x5ee79d[_0x4d2206('0x14')][_0x4d2206('0x31')]),_0x102797===_0x4d2206('0x1e')&&await db[_0x4d2206('0xb')]['destroy']({'where':{'VoiceQueueId':_0x3ad2cd['id'],'UserId':_0x5ee79d[_0x4d2206('0x14')][_0x4d2206('0x31')]}})),_0x43ac94;}))[_0x3691c1('0x48')](function(){return _0x43ac94;});}})[_0x3c8260('0x48')](function(_0x496cec){const _0x515327=_0x3c8260;if(_0x496cec)return _0x496cec[_0x515327('0x4c')](_0x5ee79d['query']['ids'])[_0x515327('0x48')](function(){const _0x74b34c=_0x515327;if(_[_0x74b34c('0x58')](_0x5ee79d[_0x74b34c('0x14')][_0x74b34c('0x31')]))for(let _0x330e28=0x0;_0x330e28<_0x5ee79d[_0x74b34c('0x14')][_0x74b34c('0x31')][_0x74b34c('0x5')];_0x330e28+=0x1){socket[_0x74b34c('0xc')](_0x74b34c('0x2e'),{'UserId':Number(_0x5ee79d[_0x74b34c('0x14')][_0x74b34c('0x31')][_0x330e28]),'TeamId':Number(_0x5ee79d[_0x74b34c('0x11')]['id'])});}else socket[_0x74b34c('0xc')]('userTeam:remove',{'UserId':Number(_0x5ee79d[_0x74b34c('0x14')][_0x74b34c('0x31')]),'TeamId':Number(_0x5ee79d[_0x74b34c('0x11')]['id'])});});})[_0x3c8260('0x48')](respondWithStatusCode(_0xf608a5,null))[_0x3c8260('0x46')](handleError(_0xf608a5,null));},exports[_0x1814e9('0x3b')]=function(_0x591dbc,_0x5ca0d0){const _0x481c1b=_0x1814e9;let _0x524295={};const _0x4a46c2={};let _0x43edc0,_0x5d21a6;return db[_0x481c1b('0x45')][_0x481c1b('0x52')]({'where':{'id':_0x591dbc[_0x481c1b('0x11')]['id']}})[_0x481c1b('0x48')](handleEntityNotFound(_0x5ca0d0,null))[_0x481c1b('0x48')](function(_0x3b3b8f){const _0x38e6e4=_0x481c1b;if(_0x3b3b8f)return _0x43edc0=_0x3b3b8f,_0x4a46c2[_0x38e6e4('0x9')]=_['keys'](db[_0x38e6e4('0x38')][_0x38e6e4('0x8')]),_0x4a46c2['query']=_['keys'](_0x591dbc[_0x38e6e4('0x14')]),_0x4a46c2['filters']=_[_0x38e6e4('0xf')](_0x4a46c2['model'],_0x4a46c2[_0x38e6e4('0x14')]),_0x524295[_0x38e6e4('0x43')]=_[_0x38e6e4('0xf')](_0x4a46c2[_0x38e6e4('0x9')],qs[_0x38e6e4('0x53')](_0x591dbc[_0x38e6e4('0x14')]['fields'])),_0x524295[_0x38e6e4('0x43')]=_0x524295[_0x38e6e4('0x43')][_0x38e6e4('0x5')]?_0x524295[_0x38e6e4('0x43')]:_0x4a46c2[_0x38e6e4('0x9')],_0x524295[_0x38e6e4('0x15')]=qs['sort'](_0x591dbc[_0x38e6e4('0x14')][_0x38e6e4('0xd')]),_0x524295[_0x38e6e4('0x65')]=qs[_0x38e6e4('0x7')](_['pick'](_0x591dbc[_0x38e6e4('0x14')],_0x4a46c2[_0x38e6e4('0x7')])),_0x591dbc['query']['filter']&&(_0x524295[_0x38e6e4('0x65')]=_[_0x38e6e4('0x2b')](_0x524295[_0x38e6e4('0x65')],{[Op['or']]:_[_0x38e6e4('0x32')](_0x524295[_0x38e6e4('0x43')],function(_0x1916ab){const _0x2b6aeb=_0x38e6e4,_0x4f7627={};return _0x4f7627[_0x1916ab]={[Op['like']]:'%'+_0x591dbc[_0x2b6aeb('0x14')][_0x2b6aeb('0x39')]+'%'},_0x4f7627;})})),_0x524295=_[_0x38e6e4('0x2b')]({},_0x524295,_0x591dbc['options']),_0x43edc0[_0x38e6e4('0x3b')](_0x524295);})[_0x481c1b('0x48')](function(_0xa1ebef){const _0x140fb1=_0x481c1b;if(_0xa1ebef)return _0x5d21a6=_0xa1ebef[_0x140fb1('0x5')],typeof _0x591dbc['query'][_0x140fb1('0x57')]==='undefined'&&(_0x524295['limit']=qs[_0x140fb1('0x41')](_0x591dbc[_0x140fb1('0x14')]['limit']),_0x524295['offset']=qs[_0x140fb1('0x20')](_0x591dbc[_0x140fb1('0x14')][_0x140fb1('0x20')])),_0x43edc0[_0x140fb1('0x3b')](_0x524295);})['then'](function(_0x425de8){if(_0x425de8)return _0x425de8?{'count':_0x5d21a6,'rows':_0x425de8}:null;})[_0x481c1b('0x48')](respondWithResult(_0x5ca0d0,null))[_0x481c1b('0x46')](handleError(_0x5ca0d0,null));};
\ No newline at end of file