Built motion from commit c49361c37b5f784889c8087ac6e0e91b7e6b561a. Version 3.0.0...
[motion-next.git] / server / api / team / team.controller.js
1 const a626_0x4ac7=['each','register','Queues','catch','add','userProfileId','name','filters','rows','fields','sort','../../rediscache','model','UserProfileResource','voicePause','sms','nolimit','offset','UserVoiceQueueRt','params','format','limit','json','update','Fax','toLowerCase','autoAssociation','Teams','util','show','omit','./team.socket','removeAgents','../../config/logger','set','index','../../config/utils','body','create','destroy','where','User','online','send','ids','isArray','../../components/parsers/qs','Unable\x20to\x20retrieve\x20the\x20current\x20user','findAll','addQueues','get','include','whatsapp','key','attributes','stack','merge','error','addAgents','includeAll','rawAttributes','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Chat','Unknown\x20channel','options','Openchannel','Voice','SIP/%s','userTeam:save','isValidChannel','voice','query','count','findOne','emit','Mail','type','then','intersection','keys','user','sequelize','length','map','chat','pick','channel','filter','Team','role','undefined','interface','capitalize','Sms','sendStatus','mail','like','fieldName','userTeam:remove','fax','getAgents','removeQueues','UserProfileSection','order','status','Whatsapp','lodash','end','Content-Range','upsert','isNil'];(function(_0xa31f4c,_0x4ac72b){const _0x5f2919=function(_0x60c04c){while(--_0x60c04c){_0xa31f4c['push'](_0xa31f4c['shift']());}};_0x5f2919(++_0x4ac72b);}(a626_0x4ac7,0x189));const a626_0x5f29=function(_0xa31f4c,_0x4ac72b){_0xa31f4c=_0xa31f4c-0x0;let _0x5f2919=a626_0x4ac7[_0xa31f4c];return _0x5f2919;};const _0x4a61d4=a626_0x5f29;'use strict';const util=require(_0x4a61d4('0x4f')),_=require(_0x4a61d4('0x2e')),qs=require(_0x4a61d4('0x61')),logger=require(_0x4a61d4('0x54'))('api'),utils=require(_0x4a61d4('0x57')),{getSocket}=require(_0x4a61d4('0x3e')),socket=getSocket(),db=require('../../mysqldb')['db'],{Op,ValidationError}=require(_0x4a61d4('0x15'));require(_0x4a61d4('0x52'))[_0x4a61d4('0x34')](socket);function respondWithStatusCode(_0x60c04c,_0x3afa3e){return _0x3afa3e=_0x3afa3e||0xcc,function(_0x5c8e54){const _0x2cdd6d=a626_0x5f29;if(_0x5c8e54)return _0x60c04c[_0x2cdd6d('0x22')](_0x3afa3e);return _0x60c04c[_0x2cdd6d('0x2c')](_0x3afa3e)[_0x2cdd6d('0x2f')]();};}function respondWithResult(_0x15f2ae,_0x1a4afd){return _0x1a4afd=_0x1a4afd||0xc8,function(_0x65f0ef){const _0x1070f8=a626_0x5f29;if(_0x65f0ef)return _0x15f2ae[_0x1070f8('0x2c')](_0x1a4afd)[_0x1070f8('0x49')](_0x65f0ef);};}function respondWithFilteredResult(_0x3a368e,_0x4f0511){return function(_0x9e069){const _0x5a61c1=a626_0x5f29;if(_0x9e069){const _0x92680=_0x9e069['count'],_0xf804ae=_0x4f0511[_0x5a61c1('0x44')];let _0x175fe0=_0x4f0511[_0x5a61c1('0x44')]+_0x4f0511[_0x5a61c1('0x48')],_0x2ca22a;return _0x175fe0>=_0x92680?(_0x175fe0=_0x92680,_0x2ca22a=0xc8):_0x2ca22a=0xce,_0x3a368e[_0x5a61c1('0x2c')](_0x2ca22a),_0x3a368e[_0x5a61c1('0x55')](_0x5a61c1('0x30'),_0xf804ae+'-'+_0x175fe0+'/'+_0x92680)[_0x5a61c1('0x49')](_0x9e069);}return null;};}function saveUpdates(_0x2500b2){return function(_0x467601){const _0x44c5a3=a626_0x5f29;if(_0x467601)return _0x467601[_0x44c5a3('0x4a')](_0x2500b2)[_0x44c5a3('0x11')](function(_0x3bc752){return _0x3bc752;});return null;};}function removeEntity(_0x54b478){return function(_0x2ebbc7){const _0x896383=a626_0x5f29;if(_0x2ebbc7)return _0x2ebbc7[_0x896383('0x5a')]()[_0x896383('0x11')](function(){const _0x49379a=_0x896383,_0x408db8=_0x2ebbc7['get']({'plain':!![]}),_0x2629d7=_0x49379a('0x4e');return db['UserProfileResource'][_0x49379a('0x5a')]({'where':{'type':_0x2629d7,'resourceId':_0x408db8['id']}})[_0x49379a('0x11')](function(){return _0x2ebbc7;});})[_0x896383('0x11')](function(){const _0x34b5ea=_0x896383;_0x54b478[_0x34b5ea('0x2c')](0xcc)[_0x34b5ea('0x2f')]();});};}function handleEntityNotFound(_0x20cc07){return function(_0x5d58cd){return!_0x5d58cd&&_0x20cc07['sendStatus'](0x194),_0x5d58cd;};}function handleError(_0x52534b,_0x74d7eb){return _0x74d7eb=_0x74d7eb||0x1f4,function(_0x4a9d43){const _0x2deae0=a626_0x5f29;logger['error'](_0x4a9d43[_0x2deae0('0x6a')]),_0x4a9d43['name']&&delete _0x4a9d43[_0x2deae0('0x39')],_0x52534b[_0x2deae0('0x2c')](_0x74d7eb)[_0x2deae0('0x5e')](_0x4a9d43);};}exports[_0x4a61d4('0x56')]=function(_0x44d51e,_0x29b118){const _0x16340b=_0x4a61d4;let _0x26ea30={};const _0xb6a443={},_0x1dc749={'count':0x0,'rows':[]},_0x197fcd=_[_0x16340b('0x17')](db[_0x16340b('0x1c')][_0x16340b('0x0')],function(_0x206eb6){const _0x264463=_0x16340b;return{'name':_0x206eb6[_0x264463('0x25')],'type':_0x206eb6[_0x264463('0x10')][_0x264463('0x68')]};});_0xb6a443[_0x16340b('0x3f')]=_['map'](_0x197fcd,_0x16340b('0x39')),_0xb6a443[_0x16340b('0xb')]=_['keys'](_0x44d51e[_0x16340b('0xb')]),_0xb6a443[_0x16340b('0x3a')]=_['intersection'](_0xb6a443[_0x16340b('0x3f')],_0xb6a443[_0x16340b('0xb')]),_0x26ea30[_0x16340b('0x69')]=_['intersection'](_0xb6a443[_0x16340b('0x3f')],qs[_0x16340b('0x3c')](_0x44d51e[_0x16340b('0xb')]['fields'])),_0x26ea30['attributes']=_0x26ea30['attributes'][_0x16340b('0x16')]?_0x26ea30[_0x16340b('0x69')]:_0xb6a443['model'];typeof _0x44d51e[_0x16340b('0xb')][_0x16340b('0x43')]==='undefined'&&(_0x26ea30[_0x16340b('0x48')]=qs[_0x16340b('0x48')](_0x44d51e[_0x16340b('0xb')][_0x16340b('0x48')]),_0x26ea30[_0x16340b('0x44')]=qs[_0x16340b('0x44')](_0x44d51e[_0x16340b('0xb')][_0x16340b('0x44')]));_0x26ea30[_0x16340b('0x2b')]=qs[_0x16340b('0x3d')](_0x44d51e['query'][_0x16340b('0x3d')]),_0x26ea30[_0x16340b('0x5b')]=qs[_0x16340b('0x3a')](_['pick'](_0x44d51e[_0x16340b('0xb')],_0xb6a443['filters']),_0x197fcd);_0x44d51e[_0x16340b('0xb')][_0x16340b('0x1b')]&&(_0x26ea30[_0x16340b('0x5b')]=_[_0x16340b('0x6b')](_0x26ea30[_0x16340b('0x5b')],{[Op['or']]:_[_0x16340b('0x17')](_0x197fcd,function(_0xb26193){const _0x1188a8=_0x16340b;if(_0xb26193[_0x1188a8('0x10')]!=='VIRTUAL'){const _0x42957b={};return _0x42957b[_0xb26193[_0x1188a8('0x39')]]={[Op[_0x1188a8('0x24')]]:'%'+_0x44d51e[_0x1188a8('0xb')][_0x1188a8('0x1b')]+'%'},_0x42957b;}})}));_0x26ea30=_['merge']({},_0x26ea30,_0x44d51e[_0x16340b('0x4')]);const _0x314933={'where':_0x26ea30[_0x16340b('0x5b')]};return db[_0x16340b('0x1c')][_0x16340b('0xc')](_0x314933)['then'](function(_0x4990bd){const _0x5d36e4=_0x16340b;return _0x1dc749['count']=_0x4990bd,_0x44d51e['query'][_0x5d36e4('0x6e')]&&(_0x26ea30[_0x5d36e4('0x66')]=[{'all':!![]}]),db['Team']['findAll'](_0x26ea30);})[_0x16340b('0x11')](function(_0x4f151c){const _0x5187d9=_0x16340b;return _0x1dc749[_0x5187d9('0x3b')]=_0x4f151c,_0x1dc749;})[_0x16340b('0x11')](respondWithFilteredResult(_0x29b118,_0x26ea30))[_0x16340b('0x36')](handleError(_0x29b118,null));},exports[_0x4a61d4('0x50')]=function(_0x4973a4,_0x2c6023){const _0x209db2=_0x4a61d4;let _0x2a46ca={'raw':![],'where':{'id':_0x4973a4[_0x209db2('0x46')]['id']}};const _0x1651d1={};return _0x1651d1[_0x209db2('0x3f')]=_[_0x209db2('0x13')](db[_0x209db2('0x1c')]['rawAttributes']),_0x1651d1[_0x209db2('0xb')]=_[_0x209db2('0x13')](_0x4973a4[_0x209db2('0xb')]),_0x1651d1[_0x209db2('0x3a')]=_[_0x209db2('0x12')](_0x1651d1[_0x209db2('0x3f')],_0x1651d1[_0x209db2('0xb')]),_0x2a46ca[_0x209db2('0x69')]=_[_0x209db2('0x12')](_0x1651d1[_0x209db2('0x3f')],qs[_0x209db2('0x3c')](_0x4973a4['query']['fields'])),_0x2a46ca['attributes']=_0x2a46ca[_0x209db2('0x69')][_0x209db2('0x16')]?_0x2a46ca[_0x209db2('0x69')]:_0x1651d1[_0x209db2('0x3f')],_0x4973a4['query']['includeAll']&&(_0x2a46ca[_0x209db2('0x66')]=[{'all':!![]}]),_0x2a46ca=_[_0x209db2('0x6b')]({},_0x2a46ca,_0x4973a4[_0x209db2('0x4')]),db[_0x209db2('0x1c')][_0x209db2('0xd')](_0x2a46ca)['then'](handleEntityNotFound(_0x2c6023,null))[_0x209db2('0x11')](respondWithResult(_0x2c6023,null))[_0x209db2('0x36')](handleError(_0x2c6023,null));},exports[_0x4a61d4('0x59')]=function(_0x87d11,_0x114baf){const _0x56e702=_0x4a61d4;return db[_0x56e702('0x1c')][_0x56e702('0x59')](_0x87d11['body'],{})[_0x56e702('0x11')](function(_0x103945){const _0x59bec3=_0x56e702,_0x17354f=_0x87d11[_0x59bec3('0x14')][_0x59bec3('0x65')]({'plain':!![]});if(!_0x17354f)throw new Error(_0x59bec3('0x62'));if(_0x17354f[_0x59bec3('0x1d')]==='user'){const _0x3b6a82=_0x103945[_0x59bec3('0x65')]({'plain':!![]}),_0x12ad2a=_0x59bec3('0x4e');return db[_0x59bec3('0x2a')][_0x59bec3('0xd')]({'where':{'name':_0x12ad2a,'userProfileId':_0x17354f[_0x59bec3('0x38')]},'raw':!![]})[_0x59bec3('0x11')](function(_0x577d8e){const _0x47c9e9=_0x59bec3;return _0x577d8e&&_0x577d8e[_0x47c9e9('0x4d')]===0x0?db[_0x47c9e9('0x40')]['create']({'name':_0x3b6a82['name'],'resourceId':_0x3b6a82['id'],'type':_0x577d8e[_0x47c9e9('0x39')],'sectionId':_0x577d8e['id']},{})[_0x47c9e9('0x11')](function(){return _0x103945;}):_0x103945;})[_0x59bec3('0x36')](function(_0x5f2560){const _0x54464b=_0x59bec3;logger[_0x54464b('0x6c')](_0x54464b('0x1'),_0x5f2560);throw _0x5f2560;});}return _0x103945;})[_0x56e702('0x11')](respondWithResult(_0x114baf,0xc9))[_0x56e702('0x36')](handleError(_0x114baf,null));},exports[_0x4a61d4('0x4a')]=function(_0x2699e8,_0x362c92){const _0x58602e=_0x4a61d4;return _0x2699e8[_0x58602e('0x58')]['id']&&delete _0x2699e8[_0x58602e('0x58')]['id'],db[_0x58602e('0x1c')][_0x58602e('0xd')]({'where':{'id':_0x2699e8[_0x58602e('0x46')]['id']}})[_0x58602e('0x11')](handleEntityNotFound(_0x362c92,null))[_0x58602e('0x11')](saveUpdates(_0x2699e8[_0x58602e('0x58')],null))[_0x58602e('0x11')](respondWithResult(_0x362c92,null))[_0x58602e('0x36')](handleError(_0x362c92,null));},exports[_0x4a61d4('0x5a')]=function(_0x4439c1,_0x1bd3ec){const _0x1ddcc7=_0x4a61d4;return db[_0x1ddcc7('0x1c')]['findOne']({'where':{'id':_0x4439c1[_0x1ddcc7('0x46')]['id']}})['then'](handleEntityNotFound(_0x1bd3ec,null))[_0x1ddcc7('0x11')](removeEntity(_0x1bd3ec,null))[_0x1ddcc7('0x36')](handleError(_0x1bd3ec,null));},exports['getQueues']=function(_0x395025,_0x36e7db){const _0x1610bc=_0x4a61d4;return db[_0x1610bc('0x1c')][_0x1610bc('0xd')]({'where':{'id':_0x395025[_0x1610bc('0x46')]['id']}})[_0x1610bc('0x11')](handleEntityNotFound(_0x36e7db,null))[_0x1610bc('0x11')](function(_0x59bf2c){const _0x351346=_0x1610bc;if(!_0x395025[_0x351346('0xb')][_0x351346('0x1a')]||!utils[_0x351346('0x9')](_0x395025[_0x351346('0xb')][_0x351346('0x1a')]))throw new ValidationError(_0x351346('0x3'));let _0x2d0aca={};const _0x32492d={};return _0x32492d[_0x351346('0x3f')]=_[_0x351346('0x13')](db[_[_0x351346('0x20')](_0x395025['query'][_0x351346('0x1a')][_0x351346('0x4c')]())+'Queue']['rawAttributes']),_0x32492d['query']=_[_0x351346('0x13')](_0x395025['query']),_0x32492d[_0x351346('0x3a')]=_[_0x351346('0x12')](_0x32492d[_0x351346('0x3f')],_0x32492d[_0x351346('0xb')]),_0x2d0aca[_0x351346('0x69')]=_[_0x351346('0x12')](_0x32492d[_0x351346('0x3f')],qs[_0x351346('0x3c')](_0x395025['query'][_0x351346('0x3c')])),_0x2d0aca[_0x351346('0x69')]=_0x2d0aca[_0x351346('0x69')][_0x351346('0x16')]?_0x2d0aca[_0x351346('0x69')]:_0x32492d['model'],_0x2d0aca[_0x351346('0x48')]=qs[_0x351346('0x48')](_0x395025[_0x351346('0xb')]['limit']),_0x2d0aca[_0x351346('0x44')]=qs['offset'](_0x395025['query'][_0x351346('0x44')]),_0x2d0aca[_0x351346('0x2b')]=qs[_0x351346('0x3d')](_0x395025['query'][_0x351346('0x3d')]),_0x2d0aca[_0x351346('0x5b')]=qs[_0x351346('0x3a')](_[_0x351346('0x19')](_0x395025[_0x351346('0xb')],_0x32492d[_0x351346('0x3a')])),_0x2d0aca=_[_0x351346('0x6b')]({},_0x2d0aca,_0x395025[_0x351346('0x4')]),_0x59bf2c[_0x351346('0x65')+_[_0x351346('0x20')](_0x395025[_0x351346('0xb')][_0x351346('0x1a')]['toLowerCase']())+'Queues'](_0x2d0aca);})[_0x1610bc('0x11')](respondWithResult(_0x36e7db,null))[_0x1610bc('0x36')](handleError(_0x36e7db,null));},exports[_0x4a61d4('0x64')]=function(_0x103f5c,_0x26ffd1){const _0x481f67=_0x4a61d4;return db['Team']['findOne']({'where':{'id':_0x103f5c[_0x481f67('0x46')]['id']}})['then'](function(_0x5edfe1){const _0x5152fe=_0x481f67;if(_0x5edfe1){if(!_0x103f5c[_0x5152fe('0x58')][_0x5152fe('0x1a')]||!utils[_0x5152fe('0x9')](_0x103f5c[_0x5152fe('0x58')][_0x5152fe('0x1a')]))throw new ValidationError('Unknown\x20channel');return _0x5edfe1[_0x5152fe('0x37')+_[_0x5152fe('0x20')](_0x103f5c['body'][_0x5152fe('0x1a')][_0x5152fe('0x4c')]())+'Queues'](_0x103f5c[_0x5152fe('0x58')][_0x5152fe('0x5f')]);}return null;})['then'](handleEntityNotFound(_0x26ffd1,null))[_0x481f67('0x11')](respondWithStatusCode(_0x26ffd1,null))[_0x481f67('0x36')](handleError(_0x26ffd1,null));},exports[_0x4a61d4('0x29')]=function(_0x5f1619,_0x2c2f60){const _0x4af334=_0x4a61d4;return db[_0x4af334('0x1c')][_0x4af334('0xd')]({'where':{'id':_0x5f1619[_0x4af334('0x46')]['id']}})['then'](function(_0x469c1c){const _0x39b401=_0x4af334;if(_0x469c1c){if(!_0x5f1619['query'][_0x39b401('0x1a')]||!utils[_0x39b401('0x9')](_0x5f1619['query'][_0x39b401('0x1a')]))throw new ValidationError('Unknown\x20channel');return _0x469c1c['remove'+_[_0x39b401('0x20')](_0x5f1619[_0x39b401('0xb')][_0x39b401('0x1a')][_0x39b401('0x4c')]())+_0x39b401('0x35')](_0x5f1619[_0x39b401('0xb')][_0x39b401('0x5f')]);}return null;})[_0x4af334('0x11')](handleEntityNotFound(_0x2c2f60,null))['then'](respondWithStatusCode(_0x2c2f60,null))[_0x4af334('0x36')](handleError(_0x2c2f60,null));},exports['addAgents']=function(_0x5a31dd,_0x169209){const _0x26324e=_0x4a61d4;return db[_0x26324e('0x1c')][_0x26324e('0xd')]({'where':{'id':_0x5a31dd['params']['id']}})[_0x26324e('0x11')](function(_0x1b51f9){const _0x29d70a=_0x26324e;if(_0x1b51f9){const _0x310d22=[_0x29d70a('0x6'),_0x29d70a('0x2'),_0x29d70a('0xf'),_0x29d70a('0x21'),_0x29d70a('0x4b'),_0x29d70a('0x5'),_0x29d70a('0x2d')];return Promise[_0x29d70a('0x33')](_0x310d22,function(_0x5f5716){const _0x518a1c=_0x29d70a;return _0x1b51f9[_0x518a1c('0x65')+_0x5f5716+'Queues']({'attributes':['id',_0x518a1c('0x39')]})[_0x518a1c('0x11')](function(_0x4d6aa2){return Promise['each'](_0x4d6aa2,function(_0x2f45dc){const _0x3496c2=a626_0x5f29;return _0x2f45dc[_0x3496c2('0x6d')](_0x5a31dd['body'][_0x3496c2('0x5f')])[_0x3496c2('0x11')](function(){const _0x592e90=_0x3496c2;if(_0x5f5716===_0x592e90('0x6'))return db[_0x592e90('0x5c')][_0x592e90('0x63')]({'where':{'id':_0x5a31dd[_0x592e90('0x58')][_0x592e90('0x5f')]},'attributes':['id',_0x592e90('0x39'),_0x592e90('0x5d'),_0x592e90('0x41'),_0x592e90('0x1f')],'raw':!![]})[_0x592e90('0x11')](function(_0xe48c19){const _0x2b1b82=_0x592e90;return Promise[_0x2b1b82('0x33')](_[_0x2b1b82('0x1b')](_0xe48c19,{'online':0x1}),function(_0x312e9a){const _0x1dbbe2=_0x2b1b82;return db['UserVoiceQueueRt'][_0x1dbbe2('0x31')]({'membername':_0x312e9a[_0x1dbbe2('0x39')],'UserId':_0x312e9a['id'],'queue_name':_0x2f45dc[_0x1dbbe2('0x39')],'VoiceQueueId':_0x2f45dc['id'],'interface':_[_0x1dbbe2('0x32')](_0x312e9a[_0x1dbbe2('0x1f')])?util[_0x1dbbe2('0x47')](_0x1dbbe2('0x7'),_0x312e9a[_0x1dbbe2('0x39')]):_0x312e9a['interface'],'paused':_0x312e9a[_0x1dbbe2('0x41')]||![],'penalty':0x0});});});});});})['then'](function(){return _0x1b51f9;});})[_0x29d70a('0x11')](function(){return _0x1b51f9;});}})[_0x26324e('0x11')](function(_0x19350e){const _0x7865f1=_0x26324e;if(_0x19350e)return _0x19350e[_0x7865f1('0x6d')](_0x5a31dd[_0x7865f1('0x58')][_0x7865f1('0x5f')],{'through':_[_0x7865f1('0x51')](_0x5a31dd[_0x7865f1('0x58')],[_0x7865f1('0x5f'),'id'])})[_0x7865f1('0x11')](function(_0x29fa81){const _0x742b3c=_0x7865f1;for(let _0x5140a9=0x0;_0x5140a9<_0x5a31dd['body']['ids']['length'];_0x5140a9+=0x1){socket[_0x742b3c('0xe')](_0x742b3c('0x8'),{'UserId':_0x5a31dd[_0x742b3c('0x58')]['ids'][_0x5140a9],'TeamId':_0x5a31dd[_0x742b3c('0x46')]['id']});}return _0x29fa81;});})['then'](respondWithResult(_0x169209,null))[_0x26324e('0x36')](handleError(_0x169209,null));},exports[_0x4a61d4('0x53')]=function(_0x374fbb,_0x26648e){const _0x442a9a=_0x4a61d4;return db[_0x442a9a('0x1c')][_0x442a9a('0xd')]({'where':{'id':_0x374fbb[_0x442a9a('0x46')]['id']}})['then'](handleEntityNotFound(_0x26648e,null))[_0x442a9a('0x11')](function(_0x5f36ca){const _0x26045d=_0x442a9a;if(_0x5f36ca)return Promise[_0x26045d('0x33')]([_0x26045d('0xa'),_0x26045d('0x18'),_0x26045d('0x23'),_0x26045d('0x42'),_0x26045d('0x27'),'openchannel',_0x26045d('0x67')],function(_0xc61e99){const _0x2193af=_0x26045d;return _0x5f36ca[_0x2193af('0x65')+_[_0x2193af('0x20')](_0xc61e99)+_0x2193af('0x35')]({'attributes':['id',_0x2193af('0x39')]})[_0x2193af('0x11')](function(_0x467ebd){return Promise['each'](_0x467ebd,function(_0x511f02){const _0x55bb49=a626_0x5f29;return _0x511f02[_0x55bb49('0x53')](_0x374fbb[_0x55bb49('0xb')][_0x55bb49('0x5f')])['then'](function(){const _0x4145c7=_0x55bb49;if(_0xc61e99===_0x4145c7('0xa'))return db[_0x4145c7('0x45')][_0x4145c7('0x5a')]({'where':{'VoiceQueueId':_0x511f02['id'],'UserId':_0x374fbb[_0x4145c7('0xb')]['ids']}});});});})[_0x2193af('0x11')](function(){return _0x5f36ca;});})[_0x26045d('0x11')](function(){return _0x5f36ca;});})[_0x442a9a('0x11')](function(_0x178dcc){const _0x447e3d=_0x442a9a;if(_0x178dcc)return _0x178dcc['removeAgents'](_0x374fbb[_0x447e3d('0xb')]['ids'])['then'](function(){const _0x4a18e6=_0x447e3d;if(_[_0x4a18e6('0x60')](_0x374fbb[_0x4a18e6('0xb')]['ids']))for(let _0x3631c8=0x0;_0x3631c8<_0x374fbb[_0x4a18e6('0xb')][_0x4a18e6('0x5f')][_0x4a18e6('0x16')];_0x3631c8+=0x1){socket['emit'](_0x4a18e6('0x26'),{'UserId':Number(_0x374fbb[_0x4a18e6('0xb')][_0x4a18e6('0x5f')][_0x3631c8]),'TeamId':Number(_0x374fbb[_0x4a18e6('0x46')]['id'])});}else socket['emit'](_0x4a18e6('0x26'),{'UserId':Number(_0x374fbb['query'][_0x4a18e6('0x5f')]),'TeamId':Number(_0x374fbb[_0x4a18e6('0x46')]['id'])});});})[_0x442a9a('0x11')](respondWithStatusCode(_0x26648e,null))[_0x442a9a('0x36')](handleError(_0x26648e,null));},exports['getAgents']=function(_0x3f1697,_0x1b26a1){const _0x4bb6e5=_0x4a61d4;let _0x308e2b={};const _0x157c9f={};let _0x332b13,_0xc34853;return db[_0x4bb6e5('0x1c')]['findOne']({'where':{'id':_0x3f1697[_0x4bb6e5('0x46')]['id']}})[_0x4bb6e5('0x11')](handleEntityNotFound(_0x1b26a1,null))[_0x4bb6e5('0x11')](function(_0x55182c){const _0x22ce17=_0x4bb6e5;if(_0x55182c)return _0x332b13=_0x55182c,_0x157c9f['model']=_[_0x22ce17('0x13')](db[_0x22ce17('0x5c')][_0x22ce17('0x0')]),_0x157c9f[_0x22ce17('0xb')]=_[_0x22ce17('0x13')](_0x3f1697[_0x22ce17('0xb')]),_0x157c9f[_0x22ce17('0x3a')]=_[_0x22ce17('0x12')](_0x157c9f[_0x22ce17('0x3f')],_0x157c9f[_0x22ce17('0xb')]),_0x308e2b[_0x22ce17('0x69')]=_[_0x22ce17('0x12')](_0x157c9f['model'],qs['fields'](_0x3f1697[_0x22ce17('0xb')][_0x22ce17('0x3c')])),_0x308e2b[_0x22ce17('0x69')]=_0x308e2b[_0x22ce17('0x69')][_0x22ce17('0x16')]?_0x308e2b[_0x22ce17('0x69')]:_0x157c9f[_0x22ce17('0x3f')],_0x308e2b[_0x22ce17('0x2b')]=qs[_0x22ce17('0x3d')](_0x3f1697['query'][_0x22ce17('0x3d')]),_0x308e2b[_0x22ce17('0x5b')]=qs[_0x22ce17('0x3a')](_[_0x22ce17('0x19')](_0x3f1697[_0x22ce17('0xb')],_0x157c9f[_0x22ce17('0x3a')])),_0x3f1697[_0x22ce17('0xb')]['filter']&&(_0x308e2b[_0x22ce17('0x5b')]=_[_0x22ce17('0x6b')](_0x308e2b[_0x22ce17('0x5b')],{[Op['or']]:_[_0x22ce17('0x17')](_0x308e2b[_0x22ce17('0x69')],function(_0x459d15){const _0x58d495=_0x22ce17,_0x16217e={};return _0x16217e[_0x459d15]={[Op[_0x58d495('0x24')]]:'%'+_0x3f1697['query'][_0x58d495('0x1b')]+'%'},_0x16217e;})})),_0x308e2b=_[_0x22ce17('0x6b')]({},_0x308e2b,_0x3f1697['options']),_0x332b13['getAgents'](_0x308e2b);})[_0x4bb6e5('0x11')](function(_0x199059){const _0x1884a9=_0x4bb6e5;if(_0x199059)return _0xc34853=_0x199059[_0x1884a9('0x16')],typeof _0x3f1697[_0x1884a9('0xb')][_0x1884a9('0x43')]===_0x1884a9('0x1e')&&(_0x308e2b[_0x1884a9('0x48')]=qs[_0x1884a9('0x48')](_0x3f1697['query']['limit']),_0x308e2b['offset']=qs[_0x1884a9('0x44')](_0x3f1697[_0x1884a9('0xb')][_0x1884a9('0x44')])),_0x332b13[_0x1884a9('0x28')](_0x308e2b);})[_0x4bb6e5('0x11')](function(_0x52b8a9){if(_0x52b8a9)return _0x52b8a9?{'count':_0xc34853,'rows':_0x52b8a9}:null;})[_0x4bb6e5('0x11')](respondWithResult(_0x1b26a1,null))[_0x4bb6e5('0x36')](handleError(_0x1b26a1,null));};