Built motion from commit c49361c37b5f784889c8087ac6e0e91b7e6b561a. Version 3.0.0...
[motion-next.git] / server / api / chatQueue / chatQueue.controller.js
index e733c40..b284fc4 100644 (file)
@@ -1 +1 @@
-const a95_0x1c8a=['push','fields','get','options','compact','then','sendStatus','intersection','order','user_has_teams','describe','findOne','addTeams','user','findAll','count','ChatQueues','attributes','api','update','fieldName','format','userChatQueue:save','index','map','status','destroy','end','keys','every','ChatQueueId','select','emit','updatedAt','register','merge','clone','error','online','Unable\x20to\x20retrieve\x20the\x20current\x20user','../../rediscache','show','params','from','sort','rows','User','UserChatQueue','userChatQueue:remove','TeamId','offset','interface','../../config/logger','include','includeAll','ids','like','chatPause','util','VIRTUAL','findOrCreate','includes','findAndCountAll','body','catch','all','userProfileId','ut.UserId\x20=\x20?','name','ChatQueueId\x20=\x20?','json','removeAgents','nolimit','forEach','isEmpty','union','lodash','sequelize','where','createdAt','pick','transaction','squel','SIP','type','stack','role','query','getTeams','send','undefined','removeTeams','key','omit','field','flatMap','Agents','rawAttributes','create','voicePause','limit','length','model','filters','getMembers','filter','getAgents','addAgents','each','ChatQueue','../../components/parsers/qs','set','UserProfileResource','Team'];(function(_0x2c3be9,_0x1c8adf){const _0x53ad4f=function(_0x1fe370){while(--_0x1fe370){_0x2c3be9['push'](_0x2c3be9['shift']());}};_0x53ad4f(++_0x1c8adf);}(a95_0x1c8a,0x92));const a95_0x53ad=function(_0x2c3be9,_0x1c8adf){_0x2c3be9=_0x2c3be9-0x0;let _0x53ad4f=a95_0x1c8a[_0x2c3be9];return _0x53ad4f;};const _0x31e260=a95_0x53ad;'use strict';const util=require(_0x31e260('0x1a')),_=require(_0x31e260('0x2c')),squel=require(_0x31e260('0x32')),qs=require(_0x31e260('0x4e')),logger=require(_0x31e260('0x14'))(_0x31e260('0x64')),{getSocket}=require(_0x31e260('0x8')),db=require('../../mysqldb')['db'],{Op,QueryTypes}=require('sequelize'),socket=getSocket();require('./chatQueue.socket')[_0x31e260('0x2')](socket);function respondWithStatusCode(_0x1fe370,_0x4440aa){return _0x4440aa=_0x4440aa||0xcc,function(_0x308ac9){const _0x13c7f4=a95_0x53ad;if(_0x308ac9)return _0x1fe370[_0x13c7f4('0x58')](_0x4440aa);return _0x1fe370[_0x13c7f4('0x6b')](_0x4440aa)[_0x13c7f4('0x6d')]();};}function respondWithResult(_0x26dbb0,_0x10b5d6){return _0x10b5d6=_0x10b5d6||0xc8,function(_0x35ff21){const _0x2516d2=a95_0x53ad;if(_0x35ff21)return _0x26dbb0['status'](_0x10b5d6)[_0x2516d2('0x26')](_0x35ff21);};}function respondWithFilteredResult(_0x73892d,_0x425ad8){return function(_0x32f415){const _0x51c89b=a95_0x53ad;if(_0x32f415){const _0x246080=_0x32f415[_0x51c89b('0x61')],_0x1bd97e=_0x425ad8['offset'];let _0x49ac1c=_0x425ad8[_0x51c89b('0x12')]+_0x425ad8['limit'],_0x1a4cc8;return _0x49ac1c>=_0x246080?(_0x49ac1c=_0x246080,_0x1a4cc8=0xc8):_0x1a4cc8=0xce,_0x73892d['status'](_0x1a4cc8),_0x73892d[_0x51c89b('0x4f')]('Content-Range',_0x1bd97e+'-'+_0x49ac1c+'/'+_0x246080)[_0x51c89b('0x26')](_0x32f415);}return null;};}function saveUpdates(_0x2a5cf8){return function(_0x4f7b80){const _0x177879=a95_0x53ad;if(_0x4f7b80)return _0x4f7b80['update'](_0x2a5cf8)[_0x177879('0x57')](function(_0x4cc3e8){return _0x4cc3e8;});return null;};}function removeEntity(_0xff1e2b){return function(_0x169a81){const _0x2dceb4=a95_0x53ad;if(_0x169a81)return _0x169a81[_0x2dceb4('0x6c')]()['then'](function(){const _0x1034a8=_0x2dceb4,_0x5a82e4=_0x169a81[_0x1034a8('0x54')]({'plain':!![]}),_0x959cdc=_0x1034a8('0x62');return db[_0x1034a8('0x50')][_0x1034a8('0x6c')]({'where':{'type':_0x959cdc,'resourceId':_0x5a82e4['id']}})[_0x1034a8('0x57')](function(){return _0x169a81;});})[_0x2dceb4('0x57')](function(){const _0xaa2826=_0x2dceb4;_0xff1e2b[_0xaa2826('0x6b')](0xcc)[_0xaa2826('0x6d')]();});};}function handleEntityNotFound(_0x4c4ea1){return function(_0x3383a3){const _0x590077=a95_0x53ad;return!_0x3383a3&&_0x4c4ea1[_0x590077('0x58')](0x194),_0x3383a3;};}function handleError(_0x2562fa,_0x44e1e4){return _0x44e1e4=_0x44e1e4||0x1f4,function(_0x5ccfdb){const _0xc7ffed=a95_0x53ad;logger[_0xc7ffed('0x5')](_0x5ccfdb[_0xc7ffed('0x35')]),_0x5ccfdb[_0xc7ffed('0x24')]&&delete _0x5ccfdb[_0xc7ffed('0x24')],_0x2562fa['status'](_0x44e1e4)[_0xc7ffed('0x39')](_0x5ccfdb);};}exports[_0x31e260('0x69')]=function(_0x3ad063,_0x373909){const _0xdeca45=_0x31e260;let _0x5d95eb={};const _0x34cf09={},_0x4cad66={'count':0x0,'rows':[]},_0xb11b56=_[_0xdeca45('0x6a')](db[_0xdeca45('0x4d')][_0xdeca45('0x41')],function(_0x1cdbaf){const _0x16b2d4=_0xdeca45;return{'name':_0x1cdbaf[_0x16b2d4('0x66')],'type':_0x1cdbaf[_0x16b2d4('0x34')][_0x16b2d4('0x3c')]};});_0x34cf09['model']=_[_0xdeca45('0x6a')](_0xb11b56,_0xdeca45('0x24')),_0x34cf09['query']=_[_0xdeca45('0x6e')](_0x3ad063[_0xdeca45('0x37')]),_0x34cf09[_0xdeca45('0x47')]=_[_0xdeca45('0x59')](_0x34cf09[_0xdeca45('0x46')],_0x34cf09['query']),_0x5d95eb[_0xdeca45('0x63')]=_[_0xdeca45('0x59')](_0x34cf09['model'],qs[_0xdeca45('0x53')](_0x3ad063[_0xdeca45('0x37')][_0xdeca45('0x53')])),_0x5d95eb['attributes']=_0x5d95eb['attributes']['length']?_0x5d95eb[_0xdeca45('0x63')]:_0x34cf09[_0xdeca45('0x46')];typeof _0x3ad063[_0xdeca45('0x37')][_0xdeca45('0x28')]===_0xdeca45('0x3a')&&(_0x5d95eb[_0xdeca45('0x44')]=qs[_0xdeca45('0x44')](_0x3ad063[_0xdeca45('0x37')]['limit']),_0x5d95eb['offset']=qs['offset'](_0x3ad063['query'][_0xdeca45('0x12')]));_0x5d95eb[_0xdeca45('0x5a')]=qs[_0xdeca45('0xc')](_0x3ad063[_0xdeca45('0x37')]['sort']),_0x5d95eb['where']=qs[_0xdeca45('0x47')](_[_0xdeca45('0x30')](_0x3ad063[_0xdeca45('0x37')],_0x34cf09[_0xdeca45('0x47')]),_0xb11b56);_0x3ad063[_0xdeca45('0x37')][_0xdeca45('0x49')]&&(_0x5d95eb[_0xdeca45('0x2e')]=_[_0xdeca45('0x3')](_0x5d95eb[_0xdeca45('0x2e')],{[Op['or']]:_[_0xdeca45('0x6a')](_0xb11b56,function(_0x3f5934){const _0x4079a2=_0xdeca45;if(_0x3f5934[_0x4079a2('0x34')]!==_0x4079a2('0x1b')){const _0x40adf5={};return _0x40adf5[_0x3f5934[_0x4079a2('0x24')]]={[Op[_0x4079a2('0x18')]]:'%'+_0x3ad063['query'][_0x4079a2('0x49')]+'%'},_0x40adf5;}})}));_0x5d95eb=_['merge']({},_0x5d95eb,_0x3ad063[_0xdeca45('0x55')]);const _0x326247={'where':_0x5d95eb[_0xdeca45('0x2e')]};return db['ChatQueue']['count'](_0x326247)[_0xdeca45('0x57')](function(_0x128b83){const _0xdfab5f=_0xdeca45;return _0x4cad66[_0xdfab5f('0x61')]=_0x128b83,_0x3ad063['query']['includeAll']&&(_0x5d95eb[_0xdfab5f('0x15')]=[{'all':!![]}]),db['ChatQueue'][_0xdfab5f('0x60')](_0x5d95eb);})[_0xdeca45('0x57')](function(_0x1430af){const _0x2161ee=_0xdeca45;return _0x4cad66[_0x2161ee('0xd')]=_0x1430af,_0x4cad66;})[_0xdeca45('0x57')](respondWithFilteredResult(_0x373909,_0x5d95eb))[_0xdeca45('0x20')](handleError(_0x373909,null));},exports[_0x31e260('0x9')]=function(_0x5be6d7,_0x33803c){const _0x3baf35=_0x31e260;let _0x571394={'raw':!![],'where':{'id':_0x5be6d7['params']['id']}};const _0x12c2e9={};return _0x12c2e9['model']=_[_0x3baf35('0x6e')](db[_0x3baf35('0x4d')][_0x3baf35('0x41')]),_0x12c2e9['query']=_[_0x3baf35('0x6e')](_0x5be6d7['query']),_0x12c2e9[_0x3baf35('0x47')]=_[_0x3baf35('0x59')](_0x12c2e9[_0x3baf35('0x46')],_0x12c2e9[_0x3baf35('0x37')]),_0x571394[_0x3baf35('0x63')]=_['intersection'](_0x12c2e9[_0x3baf35('0x46')],qs[_0x3baf35('0x53')](_0x5be6d7[_0x3baf35('0x37')][_0x3baf35('0x53')])),_0x571394[_0x3baf35('0x63')]=_0x571394[_0x3baf35('0x63')][_0x3baf35('0x45')]?_0x571394[_0x3baf35('0x63')]:_0x12c2e9[_0x3baf35('0x46')],_0x5be6d7[_0x3baf35('0x37')][_0x3baf35('0x16')]&&(_0x571394[_0x3baf35('0x15')]=[{'all':!![]}]),_0x571394=_['merge']({},_0x571394,_0x5be6d7[_0x3baf35('0x55')]),db[_0x3baf35('0x4d')][_0x3baf35('0x5d')](_0x571394)['then'](handleEntityNotFound(_0x33803c,null))[_0x3baf35('0x57')](respondWithResult(_0x33803c,null))[_0x3baf35('0x20')](handleError(_0x33803c,null));},exports[_0x31e260('0x42')]=function(_0x34c2f8,_0x3ebf50){const _0x4d784a=_0x31e260;return db[_0x4d784a('0x4d')][_0x4d784a('0x42')](_0x34c2f8[_0x4d784a('0x1f')],{})['then'](function(_0x58a96b){const _0x3da62b=_0x4d784a,_0x20e975=_0x34c2f8[_0x3da62b('0x5f')]['get']({'plain':!![]});if(!_0x20e975)throw new Error(_0x3da62b('0x7'));if(_0x20e975[_0x3da62b('0x36')]===_0x3da62b('0x5f')){const _0x2ec847=_0x58a96b[_0x3da62b('0x54')]({'plain':!![]}),_0x795042=_0x3da62b('0x62');return db['UserProfileSection'][_0x3da62b('0x5d')]({'where':{'name':_0x795042,'userProfileId':_0x20e975[_0x3da62b('0x22')]},'raw':!![]})[_0x3da62b('0x57')](function(_0x35bb86){const _0x54c022=_0x3da62b;return _0x35bb86&&_0x35bb86['autoAssociation']===0x0?db[_0x54c022('0x50')][_0x54c022('0x42')]({'name':_0x2ec847[_0x54c022('0x24')],'resourceId':_0x2ec847['id'],'type':_0x35bb86[_0x54c022('0x24')],'sectionId':_0x35bb86['id']},{})[_0x54c022('0x57')](function(){return _0x58a96b;}):_0x58a96b;})['catch'](function(_0x584364){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x584364);throw _0x584364;});}return _0x58a96b;})[_0x4d784a('0x57')](respondWithResult(_0x3ebf50,0xc9))['catch'](handleError(_0x3ebf50,null));},exports[_0x31e260('0x65')]=function(_0x337808,_0x33eb4b){const _0x4f0689=_0x31e260;return _0x337808[_0x4f0689('0x1f')]['id']&&delete _0x337808[_0x4f0689('0x1f')]['id'],db[_0x4f0689('0x4d')][_0x4f0689('0x5d')]({'where':{'id':_0x337808[_0x4f0689('0xa')]['id']}})['then'](handleEntityNotFound(_0x33eb4b,null))['then'](saveUpdates(_0x337808[_0x4f0689('0x1f')],null))['then'](respondWithResult(_0x33eb4b,null))[_0x4f0689('0x20')](handleError(_0x33eb4b,null));},exports['destroy']=function(_0x433bf9,_0x9724d1){const _0x5d3596=_0x31e260;return db[_0x5d3596('0x4d')]['findOne']({'where':{'id':_0x433bf9[_0x5d3596('0xa')]['id']}})[_0x5d3596('0x57')](handleEntityNotFound(_0x9724d1,null))[_0x5d3596('0x57')](removeEntity(_0x9724d1,null))[_0x5d3596('0x20')](handleError(_0x9724d1,null));},exports['describe']=function(_0xb49b76,_0x5d1dab){const _0x436d2a=_0x31e260;return db[_0x436d2a('0x4d')][_0x436d2a('0x5c')]()[_0x436d2a('0x57')](respondWithResult(_0x5d1dab,null))[_0x436d2a('0x20')](handleError(_0x5d1dab,null));},exports[_0x31e260('0x48')]=function(_0x3461a4,_0x88aab0){const _0x18aee6=_0x31e260;let _0x4b4b6d={'raw':!![],'where':{}};const _0x673172={};let _0x567523;return db['ChatQueue'][_0x18aee6('0x5d')]({'where':{'id':_0x3461a4[_0x18aee6('0xa')]['id']}})['then'](handleEntityNotFound(_0x88aab0,null))['then'](function(_0x16d424){const _0x100f74=_0x18aee6;if(_0x16d424)return _0x567523=_0x16d424['get']({'plain':!![]}),_0x673172[_0x100f74('0x46')]=_['keys'](db[_0x100f74('0xf')]['rawAttributes']),_0x673172[_0x100f74('0x37')]=_[_0x100f74('0x6e')](_0x3461a4['query']),_0x673172[_0x100f74('0x47')]=_[_0x100f74('0x59')](_0x673172[_0x100f74('0x46')],_0x673172[_0x100f74('0x37')]),_0x4b4b6d[_0x100f74('0x63')]=_[_0x100f74('0x59')](_0x673172[_0x100f74('0x46')],qs[_0x100f74('0x53')](_0x3461a4[_0x100f74('0x37')]['fields'])),_0x4b4b6d[_0x100f74('0x63')]=_0x4b4b6d[_0x100f74('0x63')][_0x100f74('0x45')]?_0x4b4b6d[_0x100f74('0x63')]:_0x673172[_0x100f74('0x46')],typeof _0x3461a4[_0x100f74('0x37')][_0x100f74('0x28')]===_0x100f74('0x3a')&&(_0x4b4b6d[_0x100f74('0x44')]=qs[_0x100f74('0x44')](_0x3461a4['query'][_0x100f74('0x44')]),_0x4b4b6d[_0x100f74('0x12')]=qs[_0x100f74('0x12')](_0x3461a4['query']['offset'])),_0x4b4b6d[_0x100f74('0x5a')]=qs[_0x100f74('0xc')](_0x3461a4['query'][_0x100f74('0xc')]),_0x4b4b6d['where']=qs[_0x100f74('0x47')](_[_0x100f74('0x30')](_0x3461a4['query'],_0x673172[_0x100f74('0x47')])),_0x4b4b6d[_0x100f74('0x2e')][_0x100f74('0x70')]=_0x16d424['id'],_0x3461a4[_0x100f74('0x37')][_0x100f74('0x49')]&&(_0x4b4b6d[_0x100f74('0x2e')]=_[_0x100f74('0x3')](_0x4b4b6d[_0x100f74('0x2e')],{[Op['or']]:_[_0x100f74('0x6a')](_0x4b4b6d[_0x100f74('0x63')],function(_0x5b1eff){const _0xfcfe04=_0x100f74,_0x142044={};return _0x142044[_0x5b1eff]={[Op[_0xfcfe04('0x18')]]:'%'+_0x3461a4['query'][_0xfcfe04('0x49')]+'%'},_0x142044;})})),_0x4b4b6d=_[_0x100f74('0x3')]({},_0x4b4b6d,_0x3461a4[_0x100f74('0x55')]),db[_0x100f74('0xf')]['findAll'](_0x4b4b6d);})[_0x18aee6('0x57')](function(_0x52f723){const _0x227764=_0x18aee6;if(_0x52f723)return db['User'][_0x227764('0x1e')]({'where':{'id':_[_0x227764('0x6a')](_0x52f723,'UserId'),'role':'agent'},'attributes':['id',_0x227764('0x24'),_0x227764('0x19'),_0x227764('0x1'),_0x227764('0x2f')]});})[_0x18aee6('0x57')](function(_0x1fe7bb){const _0x1ac7cd=_0x18aee6;return _0x1fe7bb?{'count':_0x1fe7bb['count'],'rows':_[_0x1ac7cd('0x6a')](_0x1fe7bb[_0x1ac7cd('0xd')],function(_0x4c4de1){const _0x1f4c79=_0x1ac7cd;return{'membername':_0x4c4de1[_0x1f4c79('0x24')],'UserId':_0x4c4de1['id'],'queue_name':_0x567523[_0x1f4c79('0x24')],'ChatQueueId':_0x567523['id'],'interface':util[_0x1f4c79('0x67')]('%s/%s',_0x1f4c79('0x33'),_0x4c4de1[_0x1f4c79('0x24')]),'penalty':0x0,'paused':_0x4c4de1['chatPause'],'createdAt':_0x4c4de1[_0x1f4c79('0x2f')],'updatedAt':_0x4c4de1[_0x1f4c79('0x1')]};})}:{'count':0x0,'rows':[]};})[_0x18aee6('0x57')](respondWithFilteredResult(_0x88aab0,_0x4b4b6d))['catch'](handleError(_0x88aab0,null));},exports['getTeams']=function(_0x5a3b6a,_0x2c92bf){const _0x27f2e9=_0x31e260;let _0x2b249a={};const _0x273d19={};let _0x3d6ad8,_0x1b62c1;return db[_0x27f2e9('0x4d')][_0x27f2e9('0x5d')]({'where':{'id':_0x5a3b6a[_0x27f2e9('0xa')]['id']}})[_0x27f2e9('0x57')](handleEntityNotFound(_0x2c92bf,null))[_0x27f2e9('0x57')](function(_0x9dcd0d){const _0x1eb77f=_0x27f2e9;if(_0x9dcd0d)return _0x3d6ad8=_0x9dcd0d,_0x273d19[_0x1eb77f('0x46')]=_[_0x1eb77f('0x6e')](db[_0x1eb77f('0x51')][_0x1eb77f('0x41')]),_0x273d19[_0x1eb77f('0x37')]=_['keys'](_0x5a3b6a[_0x1eb77f('0x37')]),_0x273d19[_0x1eb77f('0x47')]=_[_0x1eb77f('0x59')](_0x273d19['model'],_0x273d19['query']),_0x2b249a[_0x1eb77f('0x63')]=_[_0x1eb77f('0x59')](_0x273d19['model'],qs[_0x1eb77f('0x53')](_0x5a3b6a[_0x1eb77f('0x37')][_0x1eb77f('0x53')])),_0x2b249a[_0x1eb77f('0x63')]=_0x2b249a[_0x1eb77f('0x63')][_0x1eb77f('0x45')]?_0x2b249a[_0x1eb77f('0x63')]:_0x273d19[_0x1eb77f('0x46')],_0x2b249a[_0x1eb77f('0x5a')]=qs[_0x1eb77f('0xc')](_0x5a3b6a['query']['sort']),_0x2b249a[_0x1eb77f('0x2e')]=qs[_0x1eb77f('0x47')](_[_0x1eb77f('0x30')](_0x5a3b6a[_0x1eb77f('0x37')],_0x273d19['filters'])),_0x5a3b6a[_0x1eb77f('0x37')][_0x1eb77f('0x49')]&&(_0x2b249a[_0x1eb77f('0x2e')]=_[_0x1eb77f('0x3')](_0x2b249a[_0x1eb77f('0x2e')],{[Op['or']]:_[_0x1eb77f('0x6a')](_0x2b249a[_0x1eb77f('0x63')],function(_0xc51fb4){const _0x206fe8=_0x1eb77f,_0x374c5c={};return _0x374c5c[_0xc51fb4]={[Op[_0x206fe8('0x18')]]:'%'+_0x5a3b6a['query'][_0x206fe8('0x49')]+'%'},_0x374c5c;})})),_0x2b249a=_[_0x1eb77f('0x3')]({},_0x2b249a,_0x5a3b6a[_0x1eb77f('0x55')]),_0x3d6ad8[_0x1eb77f('0x38')](_0x2b249a);})['then'](function(_0x10a482){const _0x202655=_0x27f2e9;if(_0x10a482)return _0x1b62c1=_0x10a482['length'],typeof _0x5a3b6a[_0x202655('0x37')][_0x202655('0x28')]===_0x202655('0x3a')&&(_0x2b249a['limit']=qs[_0x202655('0x44')](_0x5a3b6a[_0x202655('0x37')][_0x202655('0x44')]),_0x2b249a[_0x202655('0x12')]=qs[_0x202655('0x12')](_0x5a3b6a[_0x202655('0x37')][_0x202655('0x12')])),_0x3d6ad8[_0x202655('0x38')](_0x2b249a);})[_0x27f2e9('0x57')](function(_0xf6ba6e){if(_0xf6ba6e)return _0xf6ba6e?{'count':_0x1b62c1,'rows':_0xf6ba6e}:null;})[_0x27f2e9('0x57')](respondWithResult(_0x2c92bf,null))[_0x27f2e9('0x20')](handleError(_0x2c92bf,null));},exports[_0x31e260('0x5e')]=function(_0x22935a,_0x4e43ba){const _0xac508b=_0x31e260,_0x4f3e44=_0x22935a[_0xac508b('0x1f')][_0xac508b('0x17')];return db[_0xac508b('0x51')][_0xac508b('0x60')]({'where':{'id':_0x4f3e44},'attributes':['id'],'include':[{'model':db[_0xac508b('0xe')],'as':'Agents','attributes':['id',_0xac508b('0x24'),_0xac508b('0x6'),_0xac508b('0x43'),_0xac508b('0x13')],'raw':!![]}]})[_0xac508b('0x57')](function(_0x2f53c1){const _0x199ad4=_0xac508b;if(_0x2f53c1){const _0x15a036=_[_0x199ad4('0x3f')](_0x2f53c1,function(_0x1293cf){const _0x4d074e=_0x199ad4,_0x4c51e8=_0x1293cf[_0x4d074e('0x54')]({'plain':!![]});return _0x4c51e8['Agents'];});return db[_0x199ad4('0x4d')][_0x199ad4('0x5d')]({'where':{'id':_0x22935a['params']['id']}})['then'](function(_0x2ed279){const _0x1ae1d0=_0x199ad4;return db[_0x1ae1d0('0x2d')]['transaction'](function(_0x517875){const _0x2ca9b3=_0x1ae1d0;return _0x2ed279[_0x2ca9b3('0x5e')](_0x4f3e44,{'transaction':_0x517875})[_0x2ca9b3('0x57')](function(){const _0x2a7023=_0x2ca9b3;return Promise[_0x2a7023('0x4c')](_0x15a036,function(_0x4b8c54){const _0x2d99c3=_0x2a7023;return db[_0x2d99c3('0xf')][_0x2d99c3('0x1c')]({'where':{'UserId':_0x4b8c54['id'],'ChatQueueId':_0x22935a[_0x2d99c3('0xa')]['id']},'transaction':_0x517875});});})['then'](function(){const _0x4a099f=_0x2ca9b3;_0x15a036[_0x4a099f('0x29')](function(_0x2c3e99){const _0x132ad9=_0x4a099f;socket[_0x132ad9('0x0')](_0x132ad9('0x68'),{'UserId':_0x2c3e99['id'],'ChatQueueId':_0x2ed279['id']});});});});});}})['then'](respondWithStatusCode(_0x4e43ba,null))[_0xac508b('0x20')](handleError(_0x4e43ba,null));},exports[_0x31e260('0x3b')]=function(_0x33991c,_0xc21e86){const _0x381432=_0x31e260;return db[_0x381432('0x51')][_0x381432('0x60')]({'where':{'id':_0x33991c[_0x381432('0x37')][_0x381432('0x17')]},'attributes':['id'],'include':[{'model':db[_0x381432('0xe')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x381432('0x57')](handleEntityNotFound(_0xc21e86,null))[_0x381432('0x57')](function(_0x4b07ac){const _0x341c05=_0x381432,_0x2c71ab=_[_0x341c05('0x6a')](_0x4b07ac,'id');let _0x326135=[];const _0x7425bb=[],_0x27754c=squel[_0x341c05('0x71')]();_0x27754c[_0x341c05('0x3e')]('tq.TeamId')[_0x341c05('0xb')]('team_has_chat_queues','tq')['join'](_0x341c05('0x5b'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0x341c05('0x25'),_0x33991c['params']['id']);for(let _0x5b6bdd=0x0;_0x5b6bdd<_0x4b07ac[_0x341c05('0x45')];_0x5b6bdd+=0x1){const _0x36ee4d=_0x4b07ac[_0x5b6bdd];for(let _0x3b9091=0x0;_0x3b9091<_0x36ee4d[_0x341c05('0x40')][_0x341c05('0x45')];_0x3b9091+=0x1){const _0x1cf3fe=_0x36ee4d['Agents'][_0x3b9091],_0x4f91b4=_0x27754c[_0x341c05('0x4')]();_0x4f91b4['where'](_0x341c05('0x23'),_0x1cf3fe['id']),_0x7425bb[_0x341c05('0x52')](db[_0x341c05('0x2d')][_0x341c05('0x37')](_0x4f91b4['toString'](),{'type':QueryTypes['SELECT']})[_0x341c05('0x57')](function(_0x2d97cd){const _0x28596e=_0x341c05;if(_0x2d97cd[_0x28596e('0x45')]===0x1)return _0x1cf3fe['id'];else{const _0xe50366=_[_0x28596e('0x6f')](_[_0x28596e('0x6a')](_0x2d97cd,_0x28596e('0x11')),function(_0x5955bb){const _0x1882e7=_0x28596e;return _[_0x1882e7('0x1d')](_0x2c71ab,_0x5955bb);});if(_0xe50366)return _0x1cf3fe['id'];}}));}}return Promise[_0x341c05('0x21')](_0x7425bb)[_0x341c05('0x57')](function(_0x471304){const _0x59abce=_0x341c05;return _0x326135=_(_0x326135)[_0x59abce('0x2b')](_0x471304)[_0x59abce('0x56')]()['value'](),db[_0x59abce('0x4d')][_0x59abce('0x5d')]({'where':{'id':_0x33991c['params']['id']}})['then'](function(_0x319fba){const _0x5646d9=_0x59abce;return db[_0x5646d9('0x2d')][_0x5646d9('0x31')](function(_0x3a799){const _0x5ddbb5=_0x5646d9;return _0x319fba[_0x5ddbb5('0x3b')](_0x33991c['query'][_0x5ddbb5('0x17')],{'transaction':_0x3a799})[_0x5ddbb5('0x57')](function(){const _0x40f741=_0x5ddbb5;if(!_[_0x40f741('0x2a')](_0x326135))return _0x319fba['removeAgents'](_0x326135,{'transaction':_0x3a799});})[_0x5ddbb5('0x57')](function(){const _0x445805=_0x5ddbb5;_0x326135[_0x445805('0x29')](function(_0x34fcfb){const _0x1124ea=_0x445805;socket[_0x1124ea('0x0')](_0x1124ea('0x10'),{'UserId':_0x34fcfb,'ChatQueueId':_0x319fba['id']});});});});});});})['then'](respondWithStatusCode(_0xc21e86,null))[_0x381432('0x20')](handleError(_0xc21e86,null));},exports[_0x31e260('0x4b')]=function(_0x246bec,_0x3537d8){const _0xd2d520=_0x31e260;return db['ChatQueue'][_0xd2d520('0x5d')]({'where':{'id':_0x246bec[_0xd2d520('0xa')]['id']}})[_0xd2d520('0x57')](function(_0x1eb0d8){const _0x356432=_0xd2d520;if(_0x1eb0d8)return _0x1eb0d8[_0x356432('0x4b')](_0x246bec['body'][_0x356432('0x17')],{'through':_[_0x356432('0x3d')](_0x246bec[_0x356432('0x1f')],['ids','id'])})[_0x356432('0x57')](function(_0x5bba2a){const _0x144653=_0x356432;for(let _0x1ca131=0x0;_0x1ca131<_0x246bec[_0x144653('0x1f')][_0x144653('0x17')][_0x144653('0x45')];_0x1ca131+=0x1){socket[_0x144653('0x0')]('userChatQueue:save',{'UserId':_0x246bec[_0x144653('0x1f')]['ids'][_0x1ca131],'ChatQueueId':_0x246bec[_0x144653('0xa')]['id']});}return _0x5bba2a;});})[_0xd2d520('0x57')](respondWithResult(_0x3537d8,null))[_0xd2d520('0x20')](handleError(_0x3537d8,null));},exports[_0x31e260('0x27')]=function(_0x172292,_0x145747){const _0x1ea5c8=_0x31e260;return db[_0x1ea5c8('0x4d')][_0x1ea5c8('0x5d')]({'where':{'id':_0x172292[_0x1ea5c8('0xa')]['id']}})['then'](handleEntityNotFound(_0x145747,null))[_0x1ea5c8('0x57')](function(_0x372b5a){const _0x40ae66=_0x1ea5c8;if(_0x372b5a)return _0x372b5a['removeAgents'](_0x172292['query']['ids'])[_0x40ae66('0x57')](function(){const _0x591462=_0x40ae66;if(_['isArray'](_0x172292['query']['ids']))for(let _0x53b3f0=0x0;_0x53b3f0<_0x172292[_0x591462('0x37')]['ids'][_0x591462('0x45')];_0x53b3f0+=0x1){socket[_0x591462('0x0')](_0x591462('0x10'),{'UserId':Number(_0x172292[_0x591462('0x37')][_0x591462('0x17')][_0x53b3f0]),'ChatQueueId':Number(_0x172292['params']['id'])});}else socket[_0x591462('0x0')](_0x591462('0x10'),{'UserId':Number(_0x172292[_0x591462('0x37')][_0x591462('0x17')]),'ChatQueueId':Number(_0x172292[_0x591462('0xa')]['id'])});});})[_0x1ea5c8('0x57')](respondWithStatusCode(_0x145747,null))[_0x1ea5c8('0x20')](handleError(_0x145747,null));},exports[_0x31e260('0x4a')]=function(_0x6c9c9,_0x18682e){const _0x4b5c29=_0x31e260;let _0x163a67={};const _0x59bc3b={};let _0x281099,_0x1d2f2b;return db[_0x4b5c29('0x4d')]['findOne']({'where':{'id':_0x6c9c9[_0x4b5c29('0xa')]['id']}})[_0x4b5c29('0x57')](handleEntityNotFound(_0x18682e,null))[_0x4b5c29('0x57')](function(_0x10d318){const _0x8030b5=_0x4b5c29;if(_0x10d318)return _0x281099=_0x10d318,_0x59bc3b[_0x8030b5('0x46')]=_[_0x8030b5('0x6e')](db[_0x8030b5('0xe')][_0x8030b5('0x41')]),_0x59bc3b['query']=_[_0x8030b5('0x6e')](_0x6c9c9[_0x8030b5('0x37')]),_0x59bc3b[_0x8030b5('0x47')]=_[_0x8030b5('0x59')](_0x59bc3b['model'],_0x59bc3b[_0x8030b5('0x37')]),_0x163a67[_0x8030b5('0x63')]=_[_0x8030b5('0x59')](_0x59bc3b[_0x8030b5('0x46')],qs[_0x8030b5('0x53')](_0x6c9c9[_0x8030b5('0x37')]['fields'])),_0x163a67['attributes']=_0x163a67[_0x8030b5('0x63')][_0x8030b5('0x45')]?_0x163a67[_0x8030b5('0x63')]:_0x59bc3b['model'],_0x163a67[_0x8030b5('0x5a')]=qs[_0x8030b5('0xc')](_0x6c9c9[_0x8030b5('0x37')]['sort']),_0x163a67['where']=qs[_0x8030b5('0x47')](_[_0x8030b5('0x30')](_0x6c9c9[_0x8030b5('0x37')],_0x59bc3b[_0x8030b5('0x47')])),_0x6c9c9['query'][_0x8030b5('0x49')]&&(_0x163a67[_0x8030b5('0x2e')]=_[_0x8030b5('0x3')](_0x163a67[_0x8030b5('0x2e')],{[Op['or']]:_['map'](_0x163a67['attributes'],function(_0x2360ba){const _0xa36fff=_0x8030b5,_0x6ef98d={};return _0x6ef98d[_0x2360ba]={[Op[_0xa36fff('0x18')]]:'%'+_0x6c9c9[_0xa36fff('0x37')][_0xa36fff('0x49')]+'%'},_0x6ef98d;})})),_0x163a67=_[_0x8030b5('0x3')]({},_0x163a67,_0x6c9c9[_0x8030b5('0x55')]),_0x281099['getAgents'](_0x163a67);})['then'](function(_0x633fe){const _0x11efe2=_0x4b5c29;if(_0x633fe)return _0x1d2f2b=_0x633fe[_0x11efe2('0x45')],typeof _0x6c9c9[_0x11efe2('0x37')][_0x11efe2('0x28')]===_0x11efe2('0x3a')&&(_0x163a67[_0x11efe2('0x44')]=qs[_0x11efe2('0x44')](_0x6c9c9[_0x11efe2('0x37')][_0x11efe2('0x44')]),_0x163a67['offset']=qs[_0x11efe2('0x12')](_0x6c9c9[_0x11efe2('0x37')]['offset'])),_0x281099[_0x11efe2('0x4a')](_0x163a67);})['then'](function(_0x1b3f93){if(_0x1b3f93)return _0x1b3f93?{'count':_0x1d2f2b,'rows':_0x1b3f93}:null;})[_0x4b5c29('0x57')](respondWithResult(_0x18682e,null))[_0x4b5c29('0x20')](handleError(_0x18682e,null));};
\ No newline at end of file
+const a95_0x48a4=['transaction','intersection','lodash','UserChatQueue','api','ChatQueueId\x20=\x20?','body','userChatQueue:save','options','user_has_teams','userChatQueue:remove','includes','rawAttributes','length','userProfileId','UserProfileResource','undefined','SELECT','then','getTeams','order','include','forEach','findAll','addTeams','team_has_chat_queues','register','catch','destroy','ChatQueue','online','format','addAgents','User','role','removeTeams','like','agent','ids','findOne','../../mysqldb','value','pick','query','isArray','nolimit','update','emit','json','chatPause','compact','end','ut.TeamId\x20=\x20tq.TeamId','all','get','name','../../rediscache','omit','flatMap','SIP','describe','create','key','sendStatus','includeAll','model','findAndCountAll','Team','type','index','UserProfileSection','Content-Range','status','user','VIRTUAL','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','%s/%s','ChatQueues','filter','attributes','offset','rows','fields','limit','Unable\x20to\x20retrieve\x20the\x20current\x20user','set','removeAgents','each','error','filters','keys','Agents','getAgents','voicePause','sort','merge','params','sequelize','clone','where','updatedAt','autoAssociation','../../components/parsers/qs','fieldName','ChatQueueId','map','createdAt','join','push','ut.UserId\x20=\x20?'];(function(_0x4c7e40,_0x48a487){const _0x2eb13c=function(_0x3cf006){while(--_0x3cf006){_0x4c7e40['push'](_0x4c7e40['shift']());}};_0x2eb13c(++_0x48a487);}(a95_0x48a4,0x1d0));const a95_0x2eb1=function(_0x4c7e40,_0x48a487){_0x4c7e40=_0x4c7e40-0x0;let _0x2eb13c=a95_0x48a4[_0x4c7e40];return _0x2eb13c;};const _0x1bd819=a95_0x2eb1;'use strict';const util=require('util'),_=require(_0x1bd819('0x58')),squel=require('squel'),qs=require(_0x1bd819('0x4e')),logger=require('../../config/logger')(_0x1bd819('0x5a')),{getSocket}=require(_0x1bd819('0x20')),db=require(_0x1bd819('0x10'))['db'],{Op,QueryTypes}=require(_0x1bd819('0x49')),socket=getSocket();require('./chatQueue.socket')[_0x1bd819('0x2')](socket);function respondWithStatusCode(_0x3cf006,_0x485460){return _0x485460=_0x485460||0xcc,function(_0x48f262){const _0x4da1e7=a95_0x2eb1;if(_0x48f262)return _0x3cf006[_0x4da1e7('0x27')](_0x485460);return _0x3cf006[_0x4da1e7('0x30')](_0x485460)[_0x4da1e7('0x1b')]();};}function respondWithResult(_0x4b71c8,_0x81a469){return _0x81a469=_0x81a469||0xc8,function(_0xc87eb7){const _0x167986=a95_0x2eb1;if(_0xc87eb7)return _0x4b71c8[_0x167986('0x30')](_0x81a469)[_0x167986('0x18')](_0xc87eb7);};}function respondWithFilteredResult(_0x55584f,_0x1d337c){return function(_0xac2d44){const _0x4fd7d4=a95_0x2eb1;if(_0xac2d44){const _0x1bf9e5=_0xac2d44['count'],_0x55d2c9=_0x1d337c[_0x4fd7d4('0x38')];let _0x46cbbb=_0x1d337c[_0x4fd7d4('0x38')]+_0x1d337c['limit'],_0x210c26;return _0x46cbbb>=_0x1bf9e5?(_0x46cbbb=_0x1bf9e5,_0x210c26=0xc8):_0x210c26=0xce,_0x55584f[_0x4fd7d4('0x30')](_0x210c26),_0x55584f[_0x4fd7d4('0x3d')](_0x4fd7d4('0x2f'),_0x55d2c9+'-'+_0x46cbbb+'/'+_0x1bf9e5)[_0x4fd7d4('0x18')](_0xac2d44);}return null;};}function saveUpdates(_0x3c86d1){return function(_0x29ecc9){const _0x47fb49=a95_0x2eb1;if(_0x29ecc9)return _0x29ecc9[_0x47fb49('0x16')](_0x3c86d1)[_0x47fb49('0x68')](function(_0x3bd4a0){return _0x3bd4a0;});return null;};}function removeEntity(_0x57e0fb){return function(_0x3159d0){const _0x1a19d7=a95_0x2eb1;if(_0x3159d0)return _0x3159d0[_0x1a19d7('0x4')]()[_0x1a19d7('0x68')](function(){const _0x408471=_0x1a19d7,_0x2dd479=_0x3159d0['get']({'plain':!![]}),_0x3c6a37='ChatQueues';return db[_0x408471('0x65')]['destroy']({'where':{'type':_0x3c6a37,'resourceId':_0x2dd479['id']}})[_0x408471('0x68')](function(){return _0x3159d0;});})[_0x1a19d7('0x68')](function(){const _0x2297d7=_0x1a19d7;_0x57e0fb['status'](0xcc)[_0x2297d7('0x1b')]();});};}function handleEntityNotFound(_0x506cfa){return function(_0x5b6023){return!_0x5b6023&&_0x506cfa['sendStatus'](0x194),_0x5b6023;};}function handleError(_0x234c64,_0x28093e){return _0x28093e=_0x28093e||0x1f4,function(_0x3e4053){const _0xe25dfb=a95_0x2eb1;logger['error'](_0x3e4053['stack']),_0x3e4053[_0xe25dfb('0x1f')]&&delete _0x3e4053[_0xe25dfb('0x1f')],_0x234c64[_0xe25dfb('0x30')](_0x28093e)['send'](_0x3e4053);};}exports[_0x1bd819('0x2d')]=function(_0x5267b3,_0x149fb0){const _0x51721c=_0x1bd819;let _0x5313ed={};const _0x51e39c={},_0x2a2542={'count':0x0,'rows':[]},_0x335978=_['map'](db[_0x51721c('0x5')][_0x51721c('0x62')],function(_0xce760a){const _0x39a969=_0x51721c;return{'name':_0xce760a[_0x39a969('0x4f')],'type':_0xce760a['type'][_0x39a969('0x26')]};});_0x51e39c[_0x51721c('0x29')]=_[_0x51721c('0x51')](_0x335978,_0x51721c('0x1f')),_0x51e39c[_0x51721c('0x13')]=_[_0x51721c('0x42')](_0x5267b3[_0x51721c('0x13')]),_0x51e39c[_0x51721c('0x41')]=_[_0x51721c('0x57')](_0x51e39c[_0x51721c('0x29')],_0x51e39c[_0x51721c('0x13')]),_0x5313ed[_0x51721c('0x37')]=_[_0x51721c('0x57')](_0x51e39c['model'],qs['fields'](_0x5267b3[_0x51721c('0x13')][_0x51721c('0x3a')])),_0x5313ed[_0x51721c('0x37')]=_0x5313ed[_0x51721c('0x37')][_0x51721c('0x63')]?_0x5313ed[_0x51721c('0x37')]:_0x51e39c[_0x51721c('0x29')];typeof _0x5267b3[_0x51721c('0x13')][_0x51721c('0x15')]===_0x51721c('0x66')&&(_0x5313ed['limit']=qs[_0x51721c('0x3b')](_0x5267b3['query']['limit']),_0x5313ed[_0x51721c('0x38')]=qs[_0x51721c('0x38')](_0x5267b3[_0x51721c('0x13')][_0x51721c('0x38')]));_0x5313ed[_0x51721c('0x6a')]=qs['sort'](_0x5267b3[_0x51721c('0x13')][_0x51721c('0x46')]),_0x5313ed['where']=qs[_0x51721c('0x41')](_['pick'](_0x5267b3[_0x51721c('0x13')],_0x51e39c[_0x51721c('0x41')]),_0x335978);_0x5267b3[_0x51721c('0x13')][_0x51721c('0x36')]&&(_0x5313ed['where']=_[_0x51721c('0x47')](_0x5313ed['where'],{[Op['or']]:_['map'](_0x335978,function(_0x5bee5a){const _0x2f1272=_0x51721c;if(_0x5bee5a[_0x2f1272('0x2c')]!==_0x2f1272('0x32')){const _0x12d810={};return _0x12d810[_0x5bee5a[_0x2f1272('0x1f')]]={[Op[_0x2f1272('0xc')]]:'%'+_0x5267b3[_0x2f1272('0x13')][_0x2f1272('0x36')]+'%'},_0x12d810;}})}));_0x5313ed=_['merge']({},_0x5313ed,_0x5267b3['options']);const _0x2aee2d={'where':_0x5313ed[_0x51721c('0x4b')]};return db['ChatQueue']['count'](_0x2aee2d)[_0x51721c('0x68')](function(_0x3c58c3){const _0xb4eca3=_0x51721c;return _0x2a2542['count']=_0x3c58c3,_0x5267b3['query'][_0xb4eca3('0x28')]&&(_0x5313ed[_0xb4eca3('0x6b')]=[{'all':!![]}]),db['ChatQueue'][_0xb4eca3('0x6d')](_0x5313ed);})[_0x51721c('0x68')](function(_0x574fc7){const _0x1ada27=_0x51721c;return _0x2a2542[_0x1ada27('0x39')]=_0x574fc7,_0x2a2542;})[_0x51721c('0x68')](respondWithFilteredResult(_0x149fb0,_0x5313ed))[_0x51721c('0x3')](handleError(_0x149fb0,null));},exports['show']=function(_0x43c04e,_0x5d0511){const _0x5ecc46=_0x1bd819;let _0x2fe056={'raw':!![],'where':{'id':_0x43c04e[_0x5ecc46('0x48')]['id']}};const _0x1090ca={};return _0x1090ca['model']=_[_0x5ecc46('0x42')](db['ChatQueue']['rawAttributes']),_0x1090ca[_0x5ecc46('0x13')]=_[_0x5ecc46('0x42')](_0x43c04e[_0x5ecc46('0x13')]),_0x1090ca[_0x5ecc46('0x41')]=_[_0x5ecc46('0x57')](_0x1090ca['model'],_0x1090ca[_0x5ecc46('0x13')]),_0x2fe056[_0x5ecc46('0x37')]=_[_0x5ecc46('0x57')](_0x1090ca['model'],qs[_0x5ecc46('0x3a')](_0x43c04e['query']['fields'])),_0x2fe056[_0x5ecc46('0x37')]=_0x2fe056[_0x5ecc46('0x37')][_0x5ecc46('0x63')]?_0x2fe056['attributes']:_0x1090ca['model'],_0x43c04e[_0x5ecc46('0x13')][_0x5ecc46('0x28')]&&(_0x2fe056[_0x5ecc46('0x6b')]=[{'all':!![]}]),_0x2fe056=_[_0x5ecc46('0x47')]({},_0x2fe056,_0x43c04e[_0x5ecc46('0x5e')]),db[_0x5ecc46('0x5')][_0x5ecc46('0xf')](_0x2fe056)[_0x5ecc46('0x68')](handleEntityNotFound(_0x5d0511,null))[_0x5ecc46('0x68')](respondWithResult(_0x5d0511,null))[_0x5ecc46('0x3')](handleError(_0x5d0511,null));},exports[_0x1bd819('0x25')]=function(_0x1ccc90,_0x5c6a32){const _0x2b8238=_0x1bd819;return db['ChatQueue'][_0x2b8238('0x25')](_0x1ccc90[_0x2b8238('0x5c')],{})[_0x2b8238('0x68')](function(_0x59e032){const _0x59ab5b=_0x2b8238,_0x144898=_0x1ccc90[_0x59ab5b('0x31')][_0x59ab5b('0x1e')]({'plain':!![]});if(!_0x144898)throw new Error(_0x59ab5b('0x3c'));if(_0x144898[_0x59ab5b('0xa')]===_0x59ab5b('0x31')){const _0x23d775=_0x59e032[_0x59ab5b('0x1e')]({'plain':!![]}),_0x13c625=_0x59ab5b('0x35');return db[_0x59ab5b('0x2e')][_0x59ab5b('0xf')]({'where':{'name':_0x13c625,'userProfileId':_0x144898[_0x59ab5b('0x64')]},'raw':!![]})[_0x59ab5b('0x68')](function(_0x545980){const _0x2eba1a=_0x59ab5b;return _0x545980&&_0x545980[_0x2eba1a('0x4d')]===0x0?db[_0x2eba1a('0x65')][_0x2eba1a('0x25')]({'name':_0x23d775[_0x2eba1a('0x1f')],'resourceId':_0x23d775['id'],'type':_0x545980[_0x2eba1a('0x1f')],'sectionId':_0x545980['id']},{})[_0x2eba1a('0x68')](function(){return _0x59e032;}):_0x59e032;})['catch'](function(_0x29718c){const _0x141f7a=_0x59ab5b;logger[_0x141f7a('0x40')](_0x141f7a('0x33'),_0x29718c);throw _0x29718c;});}return _0x59e032;})[_0x2b8238('0x68')](respondWithResult(_0x5c6a32,0xc9))[_0x2b8238('0x3')](handleError(_0x5c6a32,null));},exports['update']=function(_0x5d31ec,_0x33f170){const _0x25bd63=_0x1bd819;return _0x5d31ec['body']['id']&&delete _0x5d31ec[_0x25bd63('0x5c')]['id'],db[_0x25bd63('0x5')][_0x25bd63('0xf')]({'where':{'id':_0x5d31ec['params']['id']}})[_0x25bd63('0x68')](handleEntityNotFound(_0x33f170,null))['then'](saveUpdates(_0x5d31ec[_0x25bd63('0x5c')],null))[_0x25bd63('0x68')](respondWithResult(_0x33f170,null))[_0x25bd63('0x3')](handleError(_0x33f170,null));},exports[_0x1bd819('0x4')]=function(_0xfaf16e,_0x47dcdd){const _0x24380e=_0x1bd819;return db[_0x24380e('0x5')][_0x24380e('0xf')]({'where':{'id':_0xfaf16e['params']['id']}})[_0x24380e('0x68')](handleEntityNotFound(_0x47dcdd,null))['then'](removeEntity(_0x47dcdd,null))[_0x24380e('0x3')](handleError(_0x47dcdd,null));},exports['describe']=function(_0x32a018,_0x24e39e){const _0x3819e7=_0x1bd819;return db[_0x3819e7('0x5')][_0x3819e7('0x24')]()[_0x3819e7('0x68')](respondWithResult(_0x24e39e,null))['catch'](handleError(_0x24e39e,null));},exports['getMembers']=function(_0xafb8ec,_0x5bdff7){const _0x1c5cfd=_0x1bd819;let _0x31f7b7={'raw':!![],'where':{}};const _0x3f273e={};let _0x272acf;return db['ChatQueue'][_0x1c5cfd('0xf')]({'where':{'id':_0xafb8ec[_0x1c5cfd('0x48')]['id']}})[_0x1c5cfd('0x68')](handleEntityNotFound(_0x5bdff7,null))[_0x1c5cfd('0x68')](function(_0x5bf969){const _0x338b03=_0x1c5cfd;if(_0x5bf969)return _0x272acf=_0x5bf969[_0x338b03('0x1e')]({'plain':!![]}),_0x3f273e['model']=_[_0x338b03('0x42')](db['UserChatQueue'][_0x338b03('0x62')]),_0x3f273e[_0x338b03('0x13')]=_[_0x338b03('0x42')](_0xafb8ec['query']),_0x3f273e[_0x338b03('0x41')]=_[_0x338b03('0x57')](_0x3f273e[_0x338b03('0x29')],_0x3f273e[_0x338b03('0x13')]),_0x31f7b7[_0x338b03('0x37')]=_['intersection'](_0x3f273e[_0x338b03('0x29')],qs['fields'](_0xafb8ec[_0x338b03('0x13')][_0x338b03('0x3a')])),_0x31f7b7[_0x338b03('0x37')]=_0x31f7b7[_0x338b03('0x37')][_0x338b03('0x63')]?_0x31f7b7[_0x338b03('0x37')]:_0x3f273e[_0x338b03('0x29')],typeof _0xafb8ec[_0x338b03('0x13')][_0x338b03('0x15')]==='undefined'&&(_0x31f7b7[_0x338b03('0x3b')]=qs[_0x338b03('0x3b')](_0xafb8ec[_0x338b03('0x13')]['limit']),_0x31f7b7['offset']=qs[_0x338b03('0x38')](_0xafb8ec[_0x338b03('0x13')]['offset'])),_0x31f7b7[_0x338b03('0x6a')]=qs[_0x338b03('0x46')](_0xafb8ec[_0x338b03('0x13')][_0x338b03('0x46')]),_0x31f7b7[_0x338b03('0x4b')]=qs[_0x338b03('0x41')](_[_0x338b03('0x12')](_0xafb8ec[_0x338b03('0x13')],_0x3f273e[_0x338b03('0x41')])),_0x31f7b7[_0x338b03('0x4b')][_0x338b03('0x50')]=_0x5bf969['id'],_0xafb8ec['query']['filter']&&(_0x31f7b7['where']=_[_0x338b03('0x47')](_0x31f7b7['where'],{[Op['or']]:_[_0x338b03('0x51')](_0x31f7b7['attributes'],function(_0x1ef2f2){const _0x17412c=_0x338b03,_0x9f09={};return _0x9f09[_0x1ef2f2]={[Op[_0x17412c('0xc')]]:'%'+_0xafb8ec[_0x17412c('0x13')]['filter']+'%'},_0x9f09;})})),_0x31f7b7=_['merge']({},_0x31f7b7,_0xafb8ec[_0x338b03('0x5e')]),db[_0x338b03('0x59')][_0x338b03('0x6d')](_0x31f7b7);})[_0x1c5cfd('0x68')](function(_0x21723a){const _0x28453a=_0x1c5cfd;if(_0x21723a)return db[_0x28453a('0x9')][_0x28453a('0x2a')]({'where':{'id':_[_0x28453a('0x51')](_0x21723a,'UserId'),'role':_0x28453a('0xd')},'attributes':['id',_0x28453a('0x1f'),_0x28453a('0x19'),_0x28453a('0x4c'),_0x28453a('0x52')]});})[_0x1c5cfd('0x68')](function(_0x673c2b){const _0x2957ed=_0x1c5cfd;return _0x673c2b?{'count':_0x673c2b['count'],'rows':_[_0x2957ed('0x51')](_0x673c2b[_0x2957ed('0x39')],function(_0x282424){const _0x14e064=_0x2957ed;return{'membername':_0x282424[_0x14e064('0x1f')],'UserId':_0x282424['id'],'queue_name':_0x272acf['name'],'ChatQueueId':_0x272acf['id'],'interface':util[_0x14e064('0x7')](_0x14e064('0x34'),_0x14e064('0x23'),_0x282424[_0x14e064('0x1f')]),'penalty':0x0,'paused':_0x282424['chatPause'],'createdAt':_0x282424[_0x14e064('0x52')],'updatedAt':_0x282424['updatedAt']};})}:{'count':0x0,'rows':[]};})['then'](respondWithFilteredResult(_0x5bdff7,_0x31f7b7))[_0x1c5cfd('0x3')](handleError(_0x5bdff7,null));},exports['getTeams']=function(_0x3ed5d1,_0x26f03a){const _0x3cfacd=_0x1bd819;let _0x16f44d={};const _0x27cf95={};let _0x529c15,_0x469c61;return db[_0x3cfacd('0x5')][_0x3cfacd('0xf')]({'where':{'id':_0x3ed5d1['params']['id']}})[_0x3cfacd('0x68')](handleEntityNotFound(_0x26f03a,null))['then'](function(_0x535843){const _0xf2f19f=_0x3cfacd;if(_0x535843)return _0x529c15=_0x535843,_0x27cf95['model']=_[_0xf2f19f('0x42')](db['Team'][_0xf2f19f('0x62')]),_0x27cf95[_0xf2f19f('0x13')]=_[_0xf2f19f('0x42')](_0x3ed5d1[_0xf2f19f('0x13')]),_0x27cf95[_0xf2f19f('0x41')]=_['intersection'](_0x27cf95['model'],_0x27cf95[_0xf2f19f('0x13')]),_0x16f44d['attributes']=_[_0xf2f19f('0x57')](_0x27cf95[_0xf2f19f('0x29')],qs[_0xf2f19f('0x3a')](_0x3ed5d1[_0xf2f19f('0x13')][_0xf2f19f('0x3a')])),_0x16f44d['attributes']=_0x16f44d['attributes']['length']?_0x16f44d['attributes']:_0x27cf95[_0xf2f19f('0x29')],_0x16f44d['order']=qs['sort'](_0x3ed5d1['query']['sort']),_0x16f44d['where']=qs[_0xf2f19f('0x41')](_['pick'](_0x3ed5d1[_0xf2f19f('0x13')],_0x27cf95[_0xf2f19f('0x41')])),_0x3ed5d1['query'][_0xf2f19f('0x36')]&&(_0x16f44d[_0xf2f19f('0x4b')]=_[_0xf2f19f('0x47')](_0x16f44d['where'],{[Op['or']]:_[_0xf2f19f('0x51')](_0x16f44d[_0xf2f19f('0x37')],function(_0x50dd95){const _0x3c4355=_0xf2f19f,_0x2a8173={};return _0x2a8173[_0x50dd95]={[Op[_0x3c4355('0xc')]]:'%'+_0x3ed5d1[_0x3c4355('0x13')][_0x3c4355('0x36')]+'%'},_0x2a8173;})})),_0x16f44d=_['merge']({},_0x16f44d,_0x3ed5d1[_0xf2f19f('0x5e')]),_0x529c15[_0xf2f19f('0x69')](_0x16f44d);})[_0x3cfacd('0x68')](function(_0x3f9d92){const _0x451a62=_0x3cfacd;if(_0x3f9d92)return _0x469c61=_0x3f9d92[_0x451a62('0x63')],typeof _0x3ed5d1[_0x451a62('0x13')]['nolimit']===_0x451a62('0x66')&&(_0x16f44d[_0x451a62('0x3b')]=qs[_0x451a62('0x3b')](_0x3ed5d1[_0x451a62('0x13')]['limit']),_0x16f44d['offset']=qs[_0x451a62('0x38')](_0x3ed5d1[_0x451a62('0x13')]['offset'])),_0x529c15['getTeams'](_0x16f44d);})[_0x3cfacd('0x68')](function(_0x260353){if(_0x260353)return _0x260353?{'count':_0x469c61,'rows':_0x260353}:null;})[_0x3cfacd('0x68')](respondWithResult(_0x26f03a,null))[_0x3cfacd('0x3')](handleError(_0x26f03a,null));},exports[_0x1bd819('0x0')]=function(_0x1b58f3,_0x59d65e){const _0x11342c=_0x1bd819,_0x42d026=_0x1b58f3['body']['ids'];return db[_0x11342c('0x2b')][_0x11342c('0x6d')]({'where':{'id':_0x42d026},'attributes':['id'],'include':[{'model':db[_0x11342c('0x9')],'as':_0x11342c('0x43'),'attributes':['id','name',_0x11342c('0x6'),_0x11342c('0x45'),'interface'],'raw':!![]}]})[_0x11342c('0x68')](function(_0x266141){const _0x2e0892=_0x11342c;if(_0x266141){const _0x3e7ecb=_[_0x2e0892('0x22')](_0x266141,function(_0x48f961){const _0x543739=_0x2e0892,_0x4644af=_0x48f961[_0x543739('0x1e')]({'plain':!![]});return _0x4644af[_0x543739('0x43')];});return db[_0x2e0892('0x5')][_0x2e0892('0xf')]({'where':{'id':_0x1b58f3['params']['id']}})[_0x2e0892('0x68')](function(_0x1e8019){const _0x137682=_0x2e0892;return db[_0x137682('0x49')][_0x137682('0x56')](function(_0x27974c){const _0x3ccc16=_0x137682;return _0x1e8019[_0x3ccc16('0x0')](_0x42d026,{'transaction':_0x27974c})[_0x3ccc16('0x68')](function(){const _0x138f03=_0x3ccc16;return Promise[_0x138f03('0x3f')](_0x3e7ecb,function(_0x21caa4){const _0xf030f0=_0x138f03;return db[_0xf030f0('0x59')]['findOrCreate']({'where':{'UserId':_0x21caa4['id'],'ChatQueueId':_0x1b58f3[_0xf030f0('0x48')]['id']},'transaction':_0x27974c});});})[_0x3ccc16('0x68')](function(){const _0x2f21a3=_0x3ccc16;_0x3e7ecb[_0x2f21a3('0x6c')](function(_0x2b4885){const _0x15582b=_0x2f21a3;socket[_0x15582b('0x17')](_0x15582b('0x5d'),{'UserId':_0x2b4885['id'],'ChatQueueId':_0x1e8019['id']});});});});});}})['then'](respondWithStatusCode(_0x59d65e,null))[_0x11342c('0x3')](handleError(_0x59d65e,null));},exports[_0x1bd819('0xb')]=function(_0x410f4b,_0x5946bb){const _0x203663=_0x1bd819;return db[_0x203663('0x2b')]['findAll']({'where':{'id':_0x410f4b['query'][_0x203663('0xe')]},'attributes':['id'],'include':[{'model':db[_0x203663('0x9')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x203663('0x68')](handleEntityNotFound(_0x5946bb,null))[_0x203663('0x68')](function(_0x1f08f0){const _0x48f5fb=_0x203663,_0x16a956=_['map'](_0x1f08f0,'id');let _0x45f30c=[];const _0x307ab0=[],_0xa5e9df=squel['select']();_0xa5e9df['field']('tq.TeamId')['from'](_0x48f5fb('0x1'),'tq')[_0x48f5fb('0x53')](_0x48f5fb('0x5f'),'ut',_0x48f5fb('0x1c'))[_0x48f5fb('0x4b')](_0x48f5fb('0x5b'),_0x410f4b[_0x48f5fb('0x48')]['id']);for(let _0x313d5c=0x0;_0x313d5c<_0x1f08f0[_0x48f5fb('0x63')];_0x313d5c+=0x1){const _0x109ebb=_0x1f08f0[_0x313d5c];for(let _0x3f5416=0x0;_0x3f5416<_0x109ebb[_0x48f5fb('0x43')][_0x48f5fb('0x63')];_0x3f5416+=0x1){const _0x11cb81=_0x109ebb['Agents'][_0x3f5416],_0x3790da=_0xa5e9df[_0x48f5fb('0x4a')]();_0x3790da[_0x48f5fb('0x4b')](_0x48f5fb('0x55'),_0x11cb81['id']),_0x307ab0[_0x48f5fb('0x54')](db[_0x48f5fb('0x49')]['query'](_0x3790da['toString'](),{'type':QueryTypes[_0x48f5fb('0x67')]})[_0x48f5fb('0x68')](function(_0x582bfc){const _0x5cbcc5=_0x48f5fb;if(_0x582bfc['length']===0x1)return _0x11cb81['id'];else{const _0xe5e6ac=_['every'](_[_0x5cbcc5('0x51')](_0x582bfc,'TeamId'),function(_0x578a4d){const _0x1972d5=_0x5cbcc5;return _[_0x1972d5('0x61')](_0x16a956,_0x578a4d);});if(_0xe5e6ac)return _0x11cb81['id'];}}));}}return Promise[_0x48f5fb('0x1d')](_0x307ab0)[_0x48f5fb('0x68')](function(_0xa6dfaa){const _0x53ed1a=_0x48f5fb;return _0x45f30c=_(_0x45f30c)['union'](_0xa6dfaa)[_0x53ed1a('0x1a')]()[_0x53ed1a('0x11')](),db['ChatQueue']['findOne']({'where':{'id':_0x410f4b[_0x53ed1a('0x48')]['id']}})[_0x53ed1a('0x68')](function(_0x288333){const _0x379ba7=_0x53ed1a;return db[_0x379ba7('0x49')][_0x379ba7('0x56')](function(_0x129f11){const _0x2f2776=_0x379ba7;return _0x288333[_0x2f2776('0xb')](_0x410f4b[_0x2f2776('0x13')]['ids'],{'transaction':_0x129f11})['then'](function(){const _0x5576d4=_0x2f2776;if(!_['isEmpty'](_0x45f30c))return _0x288333[_0x5576d4('0x3e')](_0x45f30c,{'transaction':_0x129f11});})[_0x2f2776('0x68')](function(){const _0x7d5da3=_0x2f2776;_0x45f30c[_0x7d5da3('0x6c')](function(_0x2a645e){const _0x31ed84=_0x7d5da3;socket[_0x31ed84('0x17')](_0x31ed84('0x60'),{'UserId':_0x2a645e,'ChatQueueId':_0x288333['id']});});});});});});})[_0x203663('0x68')](respondWithStatusCode(_0x5946bb,null))[_0x203663('0x3')](handleError(_0x5946bb,null));},exports[_0x1bd819('0x8')]=function(_0x82ab91,_0x4a6203){const _0x397630=_0x1bd819;return db[_0x397630('0x5')][_0x397630('0xf')]({'where':{'id':_0x82ab91[_0x397630('0x48')]['id']}})[_0x397630('0x68')](function(_0xe60a49){const _0x4d6034=_0x397630;if(_0xe60a49)return _0xe60a49[_0x4d6034('0x8')](_0x82ab91[_0x4d6034('0x5c')][_0x4d6034('0xe')],{'through':_[_0x4d6034('0x21')](_0x82ab91[_0x4d6034('0x5c')],[_0x4d6034('0xe'),'id'])})['then'](function(_0xd72a8a){const _0x4f1701=_0x4d6034;for(let _0x1b6386=0x0;_0x1b6386<_0x82ab91['body'][_0x4f1701('0xe')][_0x4f1701('0x63')];_0x1b6386+=0x1){socket[_0x4f1701('0x17')](_0x4f1701('0x5d'),{'UserId':_0x82ab91[_0x4f1701('0x5c')]['ids'][_0x1b6386],'ChatQueueId':_0x82ab91[_0x4f1701('0x48')]['id']});}return _0xd72a8a;});})[_0x397630('0x68')](respondWithResult(_0x4a6203,null))[_0x397630('0x3')](handleError(_0x4a6203,null));},exports['removeAgents']=function(_0x28a6ec,_0x4372cd){const _0x52cdc3=_0x1bd819;return db['ChatQueue'][_0x52cdc3('0xf')]({'where':{'id':_0x28a6ec['params']['id']}})[_0x52cdc3('0x68')](handleEntityNotFound(_0x4372cd,null))[_0x52cdc3('0x68')](function(_0x536a1e){const _0x4e770c=_0x52cdc3;if(_0x536a1e)return _0x536a1e[_0x4e770c('0x3e')](_0x28a6ec['query'][_0x4e770c('0xe')])[_0x4e770c('0x68')](function(){const _0x5df0c7=_0x4e770c;if(_[_0x5df0c7('0x14')](_0x28a6ec[_0x5df0c7('0x13')][_0x5df0c7('0xe')]))for(let _0x47d8f8=0x0;_0x47d8f8<_0x28a6ec[_0x5df0c7('0x13')][_0x5df0c7('0xe')][_0x5df0c7('0x63')];_0x47d8f8+=0x1){socket['emit']('userChatQueue:remove',{'UserId':Number(_0x28a6ec['query']['ids'][_0x47d8f8]),'ChatQueueId':Number(_0x28a6ec[_0x5df0c7('0x48')]['id'])});}else socket[_0x5df0c7('0x17')]('userChatQueue:remove',{'UserId':Number(_0x28a6ec['query'][_0x5df0c7('0xe')]),'ChatQueueId':Number(_0x28a6ec[_0x5df0c7('0x48')]['id'])});});})['then'](respondWithStatusCode(_0x4372cd,null))[_0x52cdc3('0x3')](handleError(_0x4372cd,null));},exports['getAgents']=function(_0x6b46a8,_0x49c082){const _0x4c3ced=_0x1bd819;let _0xbafd6c={};const _0x540b47={};let _0x4a63c0,_0x19dcce;return db['ChatQueue'][_0x4c3ced('0xf')]({'where':{'id':_0x6b46a8[_0x4c3ced('0x48')]['id']}})[_0x4c3ced('0x68')](handleEntityNotFound(_0x49c082,null))[_0x4c3ced('0x68')](function(_0x3463f3){const _0x53efea=_0x4c3ced;if(_0x3463f3)return _0x4a63c0=_0x3463f3,_0x540b47[_0x53efea('0x29')]=_[_0x53efea('0x42')](db[_0x53efea('0x9')][_0x53efea('0x62')]),_0x540b47[_0x53efea('0x13')]=_['keys'](_0x6b46a8[_0x53efea('0x13')]),_0x540b47[_0x53efea('0x41')]=_[_0x53efea('0x57')](_0x540b47['model'],_0x540b47[_0x53efea('0x13')]),_0xbafd6c['attributes']=_['intersection'](_0x540b47[_0x53efea('0x29')],qs[_0x53efea('0x3a')](_0x6b46a8[_0x53efea('0x13')]['fields'])),_0xbafd6c[_0x53efea('0x37')]=_0xbafd6c[_0x53efea('0x37')]['length']?_0xbafd6c['attributes']:_0x540b47[_0x53efea('0x29')],_0xbafd6c[_0x53efea('0x6a')]=qs[_0x53efea('0x46')](_0x6b46a8[_0x53efea('0x13')]['sort']),_0xbafd6c[_0x53efea('0x4b')]=qs[_0x53efea('0x41')](_['pick'](_0x6b46a8[_0x53efea('0x13')],_0x540b47[_0x53efea('0x41')])),_0x6b46a8[_0x53efea('0x13')]['filter']&&(_0xbafd6c['where']=_[_0x53efea('0x47')](_0xbafd6c['where'],{[Op['or']]:_[_0x53efea('0x51')](_0xbafd6c['attributes'],function(_0x5df1de){const _0xf92ba0=_0x53efea,_0x186705={};return _0x186705[_0x5df1de]={[Op[_0xf92ba0('0xc')]]:'%'+_0x6b46a8[_0xf92ba0('0x13')][_0xf92ba0('0x36')]+'%'},_0x186705;})})),_0xbafd6c=_['merge']({},_0xbafd6c,_0x6b46a8[_0x53efea('0x5e')]),_0x4a63c0[_0x53efea('0x44')](_0xbafd6c);})[_0x4c3ced('0x68')](function(_0x147e8b){const _0x312970=_0x4c3ced;if(_0x147e8b)return _0x19dcce=_0x147e8b['length'],typeof _0x6b46a8['query'][_0x312970('0x15')]===_0x312970('0x66')&&(_0xbafd6c['limit']=qs[_0x312970('0x3b')](_0x6b46a8['query'][_0x312970('0x3b')]),_0xbafd6c[_0x312970('0x38')]=qs[_0x312970('0x38')](_0x6b46a8['query'][_0x312970('0x38')])),_0x4a63c0[_0x312970('0x44')](_0xbafd6c);})['then'](function(_0x78fae8){if(_0x78fae8)return _0x78fae8?{'count':_0x19dcce,'rows':_0x78fae8}:null;})['then'](respondWithResult(_0x49c082,null))[_0x4c3ced('0x3')](handleError(_0x49c082,null));};
\ No newline at end of file