Built motion from commit 4a18b36e645f5fa4a517d36f9783bde259878164. Version 3.0.0...
[motion-next.git] / server / api / chatQueue / chatQueue.controller.js
1 const a95_0x33c4=['addTeams','ChatQueue','describe','voicePause','like','UserChatQueue','User','addAgents','userChatQueue:save','ChatQueueId\x20=\x20?','createdAt','SELECT','then','select','Content-Range','ut.TeamId\x20=\x20tq.TeamId','role','field','removeAgents','omit','findOrCreate','getAgents','from','autoAssociation','nolimit','interface','UserProfileSection','destroy','clone','transaction','agent','ChatQueues','params','%s/%s','sequelize','query','union','model','Agents','merge','includes','filters','util','updatedAt','index','limit','compact','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','SIP','value','forEach','ChatQueueId','toString','user_has_teams','count','../../mysqldb','get','getTeams','send','all','userProfileId','VIRTUAL','catch','include','json','userChatQueue:remove','rows','getMembers','intersection','offset','every','squel','chatPause','update','pick','push','Unable\x20to\x20retrieve\x20the\x20current\x20user','status','body','length','create','ids','join','format','rawAttributes','Team','emit','fieldName','sort','isEmpty','findOne','name','stack','attributes','sendStatus','findAll','where','team_has_chat_queues','keys','includeAll','map','options','filter','fields','api','flatMap','lodash','undefined','removeTeams','type','show','order','error','UserProfileResource','user'];(function(_0x468eec,_0x33c4c5){const _0x18cfe9=function(_0x2291b9){while(--_0x2291b9){_0x468eec['push'](_0x468eec['shift']());}};_0x18cfe9(++_0x33c4c5);}(a95_0x33c4,0xcc));const a95_0x18cf=function(_0x468eec,_0x33c4c5){_0x468eec=_0x468eec-0x0;let _0x18cfe9=a95_0x33c4[_0x468eec];return _0x18cfe9;};const _0x357213=a95_0x18cf;'use strict';const util=require(_0x357213('0x44')),_=require(_0x357213('0x11')),squel=require(_0x357213('0x61')),qs=require('../../components/parsers/qs'),logger=require('../../config/logger')(_0x357213('0xf')),{getSocket}=require('../../rediscache'),db=require(_0x357213('0x51'))['db'],{Op,QueryTypes}=require(_0x357213('0x3c')),socket=getSocket();require('./chatQueue.socket')['register'](socket);function respondWithStatusCode(_0x2291b9,_0x3a90db){return _0x3a90db=_0x3a90db||0xcc,function(_0x41bb54){const _0x4af7d9=a95_0x18cf;if(_0x41bb54)return _0x2291b9[_0x4af7d9('0x5')](_0x3a90db);return _0x2291b9['status'](_0x3a90db)['end']();};}function respondWithResult(_0x496174,_0x2340c4){return _0x2340c4=_0x2340c4||0xc8,function(_0x2c4dc2){const _0x575a1b=a95_0x18cf;if(_0x2c4dc2)return _0x496174['status'](_0x2340c4)[_0x575a1b('0x5a')](_0x2c4dc2);};}function respondWithFilteredResult(_0x2f3d7d,_0x4b90ff){return function(_0x2d8495){const _0x42b1c5=a95_0x18cf;if(_0x2d8495){const _0x2a6819=_0x2d8495[_0x42b1c5('0x50')],_0x4b16a4=_0x4b90ff[_0x42b1c5('0x5f')];let _0x1c67ca=_0x4b90ff[_0x42b1c5('0x5f')]+_0x4b90ff[_0x42b1c5('0x47')],_0x618457;return _0x1c67ca>=_0x2a6819?(_0x1c67ca=_0x2a6819,_0x618457=0xc8):_0x618457=0xce,_0x2f3d7d['status'](_0x618457),_0x2f3d7d['set'](_0x42b1c5('0x28'),_0x4b16a4+'-'+_0x1c67ca+'/'+_0x2a6819)[_0x42b1c5('0x5a')](_0x2d8495);}return null;};}function saveUpdates(_0x59b319){return function(_0x1a9737){const _0x4ccdf4=a95_0x18cf;if(_0x1a9737)return _0x1a9737[_0x4ccdf4('0x63')](_0x59b319)[_0x4ccdf4('0x26')](function(_0x412aed){return _0x412aed;});return null;};}function removeEntity(_0x21ba23){return function(_0x215707){const _0xab5fe1=a95_0x18cf;if(_0x215707)return _0x215707[_0xab5fe1('0x35')]()[_0xab5fe1('0x26')](function(){const _0xfcc77d=_0xab5fe1,_0x926e35=_0x215707[_0xfcc77d('0x52')]({'plain':!![]}),_0x3b9c75=_0xfcc77d('0x39');return db[_0xfcc77d('0x18')]['destroy']({'where':{'type':_0x3b9c75,'resourceId':_0x926e35['id']}})[_0xfcc77d('0x26')](function(){return _0x215707;});})[_0xab5fe1('0x26')](function(){const _0xdb66b8=_0xab5fe1;_0x21ba23[_0xdb66b8('0x67')](0xcc)['end']();});};}function handleEntityNotFound(_0x22655e){return function(_0x571df0){const _0x28a64f=a95_0x18cf;return!_0x571df0&&_0x22655e[_0x28a64f('0x5')](0x194),_0x571df0;};}function handleError(_0x1245b9,_0x49e6b2){return _0x49e6b2=_0x49e6b2||0x1f4,function(_0x3cac6e){const _0x13fb1d=a95_0x18cf;logger[_0x13fb1d('0x17')](_0x3cac6e[_0x13fb1d('0x3')]),_0x3cac6e[_0x13fb1d('0x2')]&&delete _0x3cac6e['name'],_0x1245b9[_0x13fb1d('0x67')](_0x49e6b2)[_0x13fb1d('0x54')](_0x3cac6e);};}exports[_0x357213('0x46')]=function(_0xeb8d28,_0x597de0){const _0x40ba40=_0x357213;let _0x45e6f={};const _0x24b02d={},_0x47d071={'count':0x0,'rows':[]},_0x1b9f04=_[_0x40ba40('0xb')](db[_0x40ba40('0x1b')][_0x40ba40('0x6e')],function(_0x7a1238){const _0x45698c=_0x40ba40;return{'name':_0x7a1238[_0x45698c('0x71')],'type':_0x7a1238[_0x45698c('0x14')]['key']};});_0x24b02d[_0x40ba40('0x3f')]=_['map'](_0x1b9f04,_0x40ba40('0x2')),_0x24b02d[_0x40ba40('0x3d')]=_[_0x40ba40('0x9')](_0xeb8d28[_0x40ba40('0x3d')]),_0x24b02d[_0x40ba40('0x43')]=_[_0x40ba40('0x5e')](_0x24b02d[_0x40ba40('0x3f')],_0x24b02d['query']),_0x45e6f['attributes']=_[_0x40ba40('0x5e')](_0x24b02d[_0x40ba40('0x3f')],qs[_0x40ba40('0xe')](_0xeb8d28['query']['fields'])),_0x45e6f[_0x40ba40('0x4')]=_0x45e6f[_0x40ba40('0x4')][_0x40ba40('0x69')]?_0x45e6f[_0x40ba40('0x4')]:_0x24b02d[_0x40ba40('0x3f')];typeof _0xeb8d28[_0x40ba40('0x3d')][_0x40ba40('0x32')]==='undefined'&&(_0x45e6f[_0x40ba40('0x47')]=qs[_0x40ba40('0x47')](_0xeb8d28[_0x40ba40('0x3d')][_0x40ba40('0x47')]),_0x45e6f[_0x40ba40('0x5f')]=qs[_0x40ba40('0x5f')](_0xeb8d28[_0x40ba40('0x3d')]['offset']));_0x45e6f[_0x40ba40('0x16')]=qs[_0x40ba40('0x72')](_0xeb8d28[_0x40ba40('0x3d')][_0x40ba40('0x72')]),_0x45e6f[_0x40ba40('0x7')]=qs[_0x40ba40('0x43')](_[_0x40ba40('0x64')](_0xeb8d28['query'],_0x24b02d[_0x40ba40('0x43')]),_0x1b9f04);_0xeb8d28['query'][_0x40ba40('0xd')]&&(_0x45e6f[_0x40ba40('0x7')]=_[_0x40ba40('0x41')](_0x45e6f[_0x40ba40('0x7')],{[Op['or']]:_[_0x40ba40('0xb')](_0x1b9f04,function(_0xbdb38){const _0x1aa3a9=_0x40ba40;if(_0xbdb38['type']!==_0x1aa3a9('0x57')){const _0x886b20={};return _0x886b20[_0xbdb38[_0x1aa3a9('0x2')]]={[Op[_0x1aa3a9('0x1e')]]:'%'+_0xeb8d28[_0x1aa3a9('0x3d')][_0x1aa3a9('0xd')]+'%'},_0x886b20;}})}));_0x45e6f=_[_0x40ba40('0x41')]({},_0x45e6f,_0xeb8d28[_0x40ba40('0xc')]);const _0x5e0a18={'where':_0x45e6f[_0x40ba40('0x7')]};return db[_0x40ba40('0x1b')][_0x40ba40('0x50')](_0x5e0a18)[_0x40ba40('0x26')](function(_0xbcb53e){const _0x8bfac8=_0x40ba40;return _0x47d071[_0x8bfac8('0x50')]=_0xbcb53e,_0xeb8d28[_0x8bfac8('0x3d')][_0x8bfac8('0xa')]&&(_0x45e6f[_0x8bfac8('0x59')]=[{'all':!![]}]),db[_0x8bfac8('0x1b')][_0x8bfac8('0x6')](_0x45e6f);})[_0x40ba40('0x26')](function(_0xd17e64){const _0x406b21=_0x40ba40;return _0x47d071[_0x406b21('0x5c')]=_0xd17e64,_0x47d071;})[_0x40ba40('0x26')](respondWithFilteredResult(_0x597de0,_0x45e6f))[_0x40ba40('0x58')](handleError(_0x597de0,null));},exports[_0x357213('0x15')]=function(_0x57870f,_0x32cfae){const _0xb5e8c2=_0x357213;let _0x448e6f={'raw':!![],'where':{'id':_0x57870f[_0xb5e8c2('0x3a')]['id']}};const _0x29a8c4={};return _0x29a8c4['model']=_[_0xb5e8c2('0x9')](db[_0xb5e8c2('0x1b')][_0xb5e8c2('0x6e')]),_0x29a8c4['query']=_[_0xb5e8c2('0x9')](_0x57870f[_0xb5e8c2('0x3d')]),_0x29a8c4['filters']=_[_0xb5e8c2('0x5e')](_0x29a8c4[_0xb5e8c2('0x3f')],_0x29a8c4['query']),_0x448e6f[_0xb5e8c2('0x4')]=_[_0xb5e8c2('0x5e')](_0x29a8c4[_0xb5e8c2('0x3f')],qs[_0xb5e8c2('0xe')](_0x57870f[_0xb5e8c2('0x3d')][_0xb5e8c2('0xe')])),_0x448e6f['attributes']=_0x448e6f[_0xb5e8c2('0x4')]['length']?_0x448e6f[_0xb5e8c2('0x4')]:_0x29a8c4['model'],_0x57870f['query'][_0xb5e8c2('0xa')]&&(_0x448e6f['include']=[{'all':!![]}]),_0x448e6f=_[_0xb5e8c2('0x41')]({},_0x448e6f,_0x57870f[_0xb5e8c2('0xc')]),db['ChatQueue'][_0xb5e8c2('0x1')](_0x448e6f)[_0xb5e8c2('0x26')](handleEntityNotFound(_0x32cfae,null))['then'](respondWithResult(_0x32cfae,null))['catch'](handleError(_0x32cfae,null));},exports[_0x357213('0x6a')]=function(_0x16609d,_0x244662){const _0x378889=_0x357213;return db[_0x378889('0x1b')][_0x378889('0x6a')](_0x16609d[_0x378889('0x68')],{})[_0x378889('0x26')](function(_0x2ba909){const _0x2b111e=_0x378889,_0x2731ee=_0x16609d[_0x2b111e('0x19')]['get']({'plain':!![]});if(!_0x2731ee)throw new Error(_0x2b111e('0x66'));if(_0x2731ee[_0x2b111e('0x2a')]===_0x2b111e('0x19')){const _0xf00607=_0x2ba909[_0x2b111e('0x52')]({'plain':!![]}),_0x39df8d=_0x2b111e('0x39');return db[_0x2b111e('0x34')][_0x2b111e('0x1')]({'where':{'name':_0x39df8d,'userProfileId':_0x2731ee[_0x2b111e('0x56')]},'raw':!![]})[_0x2b111e('0x26')](function(_0x192e4d){const _0x1d5c77=_0x2b111e;return _0x192e4d&&_0x192e4d[_0x1d5c77('0x31')]===0x0?db[_0x1d5c77('0x18')][_0x1d5c77('0x6a')]({'name':_0xf00607['name'],'resourceId':_0xf00607['id'],'type':_0x192e4d[_0x1d5c77('0x2')],'sectionId':_0x192e4d['id']},{})['then'](function(){return _0x2ba909;}):_0x2ba909;})[_0x2b111e('0x58')](function(_0x1ca148){const _0x61efc6=_0x2b111e;logger['error'](_0x61efc6('0x49'),_0x1ca148);throw _0x1ca148;});}return _0x2ba909;})[_0x378889('0x26')](respondWithResult(_0x244662,0xc9))[_0x378889('0x58')](handleError(_0x244662,null));},exports['update']=function(_0x58ffa3,_0x1ddc12){const _0x460d50=_0x357213;return _0x58ffa3[_0x460d50('0x68')]['id']&&delete _0x58ffa3[_0x460d50('0x68')]['id'],db[_0x460d50('0x1b')][_0x460d50('0x1')]({'where':{'id':_0x58ffa3[_0x460d50('0x3a')]['id']}})['then'](handleEntityNotFound(_0x1ddc12,null))['then'](saveUpdates(_0x58ffa3[_0x460d50('0x68')],null))[_0x460d50('0x26')](respondWithResult(_0x1ddc12,null))['catch'](handleError(_0x1ddc12,null));},exports[_0x357213('0x35')]=function(_0x39a026,_0x3a573f){const _0x5c60c8=_0x357213;return db[_0x5c60c8('0x1b')][_0x5c60c8('0x1')]({'where':{'id':_0x39a026[_0x5c60c8('0x3a')]['id']}})['then'](handleEntityNotFound(_0x3a573f,null))[_0x5c60c8('0x26')](removeEntity(_0x3a573f,null))[_0x5c60c8('0x58')](handleError(_0x3a573f,null));},exports[_0x357213('0x1c')]=function(_0x1eff01,_0x355ed2){const _0x111271=_0x357213;return db[_0x111271('0x1b')][_0x111271('0x1c')]()['then'](respondWithResult(_0x355ed2,null))['catch'](handleError(_0x355ed2,null));},exports[_0x357213('0x5d')]=function(_0x3715d3,_0x399483){const _0x5e72a2=_0x357213;let _0x15aff3={'raw':!![],'where':{}};const _0x24166f={};let _0x43b213;return db['ChatQueue'][_0x5e72a2('0x1')]({'where':{'id':_0x3715d3[_0x5e72a2('0x3a')]['id']}})[_0x5e72a2('0x26')](handleEntityNotFound(_0x399483,null))[_0x5e72a2('0x26')](function(_0xf16c98){const _0xc757c0=_0x5e72a2;if(_0xf16c98)return _0x43b213=_0xf16c98[_0xc757c0('0x52')]({'plain':!![]}),_0x24166f[_0xc757c0('0x3f')]=_[_0xc757c0('0x9')](db[_0xc757c0('0x1f')][_0xc757c0('0x6e')]),_0x24166f[_0xc757c0('0x3d')]=_[_0xc757c0('0x9')](_0x3715d3[_0xc757c0('0x3d')]),_0x24166f[_0xc757c0('0x43')]=_[_0xc757c0('0x5e')](_0x24166f['model'],_0x24166f[_0xc757c0('0x3d')]),_0x15aff3[_0xc757c0('0x4')]=_[_0xc757c0('0x5e')](_0x24166f[_0xc757c0('0x3f')],qs['fields'](_0x3715d3[_0xc757c0('0x3d')][_0xc757c0('0xe')])),_0x15aff3[_0xc757c0('0x4')]=_0x15aff3[_0xc757c0('0x4')][_0xc757c0('0x69')]?_0x15aff3[_0xc757c0('0x4')]:_0x24166f[_0xc757c0('0x3f')],typeof _0x3715d3[_0xc757c0('0x3d')][_0xc757c0('0x32')]===_0xc757c0('0x12')&&(_0x15aff3[_0xc757c0('0x47')]=qs[_0xc757c0('0x47')](_0x3715d3[_0xc757c0('0x3d')][_0xc757c0('0x47')]),_0x15aff3[_0xc757c0('0x5f')]=qs[_0xc757c0('0x5f')](_0x3715d3[_0xc757c0('0x3d')]['offset'])),_0x15aff3[_0xc757c0('0x16')]=qs[_0xc757c0('0x72')](_0x3715d3['query'][_0xc757c0('0x72')]),_0x15aff3[_0xc757c0('0x7')]=qs[_0xc757c0('0x43')](_[_0xc757c0('0x64')](_0x3715d3['query'],_0x24166f['filters'])),_0x15aff3[_0xc757c0('0x7')][_0xc757c0('0x4d')]=_0xf16c98['id'],_0x3715d3[_0xc757c0('0x3d')][_0xc757c0('0xd')]&&(_0x15aff3[_0xc757c0('0x7')]=_[_0xc757c0('0x41')](_0x15aff3['where'],{[Op['or']]:_[_0xc757c0('0xb')](_0x15aff3[_0xc757c0('0x4')],function(_0x4e226d){const _0x1bfb4b=_0xc757c0,_0x5cc17a={};return _0x5cc17a[_0x4e226d]={[Op[_0x1bfb4b('0x1e')]]:'%'+_0x3715d3[_0x1bfb4b('0x3d')]['filter']+'%'},_0x5cc17a;})})),_0x15aff3=_['merge']({},_0x15aff3,_0x3715d3['options']),db[_0xc757c0('0x1f')][_0xc757c0('0x6')](_0x15aff3);})['then'](function(_0x3110a6){const _0x1edddd=_0x5e72a2;if(_0x3110a6)return db[_0x1edddd('0x20')]['findAndCountAll']({'where':{'id':_[_0x1edddd('0xb')](_0x3110a6,'UserId'),'role':_0x1edddd('0x38')},'attributes':['id',_0x1edddd('0x2'),_0x1edddd('0x62'),_0x1edddd('0x45'),_0x1edddd('0x24')]});})[_0x5e72a2('0x26')](function(_0x29d521){const _0x5649df=_0x5e72a2;return _0x29d521?{'count':_0x29d521[_0x5649df('0x50')],'rows':_['map'](_0x29d521[_0x5649df('0x5c')],function(_0x2486cc){const _0x43bc23=_0x5649df;return{'membername':_0x2486cc[_0x43bc23('0x2')],'UserId':_0x2486cc['id'],'queue_name':_0x43b213[_0x43bc23('0x2')],'ChatQueueId':_0x43b213['id'],'interface':util[_0x43bc23('0x6d')](_0x43bc23('0x3b'),_0x43bc23('0x4a'),_0x2486cc[_0x43bc23('0x2')]),'penalty':0x0,'paused':_0x2486cc[_0x43bc23('0x62')],'createdAt':_0x2486cc['createdAt'],'updatedAt':_0x2486cc[_0x43bc23('0x45')]};})}:{'count':0x0,'rows':[]};})[_0x5e72a2('0x26')](respondWithFilteredResult(_0x399483,_0x15aff3))[_0x5e72a2('0x58')](handleError(_0x399483,null));},exports[_0x357213('0x53')]=function(_0x365b5f,_0x141edd){const _0x26a8cf=_0x357213;let _0x50211d={};const _0x4fb069={};let _0x4b040d,_0x345c5c;return db[_0x26a8cf('0x1b')][_0x26a8cf('0x1')]({'where':{'id':_0x365b5f[_0x26a8cf('0x3a')]['id']}})[_0x26a8cf('0x26')](handleEntityNotFound(_0x141edd,null))[_0x26a8cf('0x26')](function(_0x18f634){const _0x53ccdb=_0x26a8cf;if(_0x18f634)return _0x4b040d=_0x18f634,_0x4fb069[_0x53ccdb('0x3f')]=_['keys'](db[_0x53ccdb('0x6f')][_0x53ccdb('0x6e')]),_0x4fb069[_0x53ccdb('0x3d')]=_[_0x53ccdb('0x9')](_0x365b5f['query']),_0x4fb069['filters']=_[_0x53ccdb('0x5e')](_0x4fb069[_0x53ccdb('0x3f')],_0x4fb069[_0x53ccdb('0x3d')]),_0x50211d[_0x53ccdb('0x4')]=_['intersection'](_0x4fb069[_0x53ccdb('0x3f')],qs[_0x53ccdb('0xe')](_0x365b5f[_0x53ccdb('0x3d')][_0x53ccdb('0xe')])),_0x50211d[_0x53ccdb('0x4')]=_0x50211d[_0x53ccdb('0x4')][_0x53ccdb('0x69')]?_0x50211d[_0x53ccdb('0x4')]:_0x4fb069[_0x53ccdb('0x3f')],_0x50211d[_0x53ccdb('0x16')]=qs[_0x53ccdb('0x72')](_0x365b5f['query'][_0x53ccdb('0x72')]),_0x50211d[_0x53ccdb('0x7')]=qs['filters'](_[_0x53ccdb('0x64')](_0x365b5f[_0x53ccdb('0x3d')],_0x4fb069[_0x53ccdb('0x43')])),_0x365b5f['query']['filter']&&(_0x50211d[_0x53ccdb('0x7')]=_[_0x53ccdb('0x41')](_0x50211d[_0x53ccdb('0x7')],{[Op['or']]:_[_0x53ccdb('0xb')](_0x50211d[_0x53ccdb('0x4')],function(_0x12224e){const _0xecb4c7=_0x53ccdb,_0x1fa083={};return _0x1fa083[_0x12224e]={[Op[_0xecb4c7('0x1e')]]:'%'+_0x365b5f[_0xecb4c7('0x3d')]['filter']+'%'},_0x1fa083;})})),_0x50211d=_[_0x53ccdb('0x41')]({},_0x50211d,_0x365b5f[_0x53ccdb('0xc')]),_0x4b040d['getTeams'](_0x50211d);})['then'](function(_0x1eb98c){const _0x83a167=_0x26a8cf;if(_0x1eb98c)return _0x345c5c=_0x1eb98c[_0x83a167('0x69')],typeof _0x365b5f[_0x83a167('0x3d')][_0x83a167('0x32')]===_0x83a167('0x12')&&(_0x50211d['limit']=qs['limit'](_0x365b5f['query'][_0x83a167('0x47')]),_0x50211d['offset']=qs[_0x83a167('0x5f')](_0x365b5f['query'][_0x83a167('0x5f')])),_0x4b040d['getTeams'](_0x50211d);})[_0x26a8cf('0x26')](function(_0x466a80){if(_0x466a80)return _0x466a80?{'count':_0x345c5c,'rows':_0x466a80}:null;})['then'](respondWithResult(_0x141edd,null))[_0x26a8cf('0x58')](handleError(_0x141edd,null));},exports[_0x357213('0x1a')]=function(_0x109917,_0xb9c9e9){const _0x2251be=_0x357213,_0x5aa865=_0x109917[_0x2251be('0x68')][_0x2251be('0x6b')];return db['Team'][_0x2251be('0x6')]({'where':{'id':_0x5aa865},'attributes':['id'],'include':[{'model':db[_0x2251be('0x20')],'as':_0x2251be('0x40'),'attributes':['id',_0x2251be('0x2'),'online',_0x2251be('0x1d'),_0x2251be('0x33')],'raw':!![]}]})[_0x2251be('0x26')](function(_0x7f1b7e){const _0x2d5252=_0x2251be;if(_0x7f1b7e){const _0x114cc4=_[_0x2d5252('0x10')](_0x7f1b7e,function(_0x389a1d){const _0x44cd4d=_0x2d5252,_0x585a3a=_0x389a1d[_0x44cd4d('0x52')]({'plain':!![]});return _0x585a3a['Agents'];});return db[_0x2d5252('0x1b')][_0x2d5252('0x1')]({'where':{'id':_0x109917[_0x2d5252('0x3a')]['id']}})[_0x2d5252('0x26')](function(_0x30612b){const _0x24dd6f=_0x2d5252;return db[_0x24dd6f('0x3c')][_0x24dd6f('0x37')](function(_0x58cbcc){const _0xd90d6b=_0x24dd6f;return _0x30612b[_0xd90d6b('0x1a')](_0x5aa865,{'transaction':_0x58cbcc})[_0xd90d6b('0x26')](function(){const _0x5a59c9=_0xd90d6b;return Promise[_0x5a59c9('0x55')](_0x114cc4[_0x5a59c9('0xb')](_0x11b939=>{const _0x13bea8=_0x5a59c9;return db[_0x13bea8('0x1f')][_0x13bea8('0x2e')]({'where':{'UserId':_0x11b939['id'],'ChatQueueId':_0x109917[_0x13bea8('0x3a')]['id']},'transaction':_0x58cbcc});}));})[_0xd90d6b('0x26')](function(){_0x114cc4['forEach'](function(_0x331145){const _0x5aebd5=a95_0x18cf;socket[_0x5aebd5('0x70')](_0x5aebd5('0x22'),{'UserId':_0x331145['id'],'ChatQueueId':_0x30612b['id']});});});});});}})[_0x2251be('0x26')](respondWithStatusCode(_0xb9c9e9,null))['catch'](handleError(_0xb9c9e9,null));},exports[_0x357213('0x13')]=function(_0x29131e,_0x57a98f){const _0x28df0b=_0x357213;return db[_0x28df0b('0x6f')][_0x28df0b('0x6')]({'where':{'id':_0x29131e['query'][_0x28df0b('0x6b')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x28df0b('0x40'),'attributes':['id'],'raw':!![]}]})[_0x28df0b('0x26')](handleEntityNotFound(_0x57a98f,null))[_0x28df0b('0x26')](function(_0x50bd1d){const _0x376a73=_0x28df0b,_0x527a47=_['map'](_0x50bd1d,'id');let _0x396ea6=[];const _0x166b7a=[],_0xc9f01e=squel[_0x376a73('0x27')]();_0xc9f01e[_0x376a73('0x2b')]('tq.TeamId')[_0x376a73('0x30')](_0x376a73('0x8'),'tq')[_0x376a73('0x6c')](_0x376a73('0x4f'),'ut',_0x376a73('0x29'))[_0x376a73('0x7')](_0x376a73('0x23'),_0x29131e['params']['id']);for(let _0x17eb17=0x0;_0x17eb17<_0x50bd1d['length'];_0x17eb17+=0x1){const _0x1cc001=_0x50bd1d[_0x17eb17];for(let _0x2e24d9=0x0;_0x2e24d9<_0x1cc001[_0x376a73('0x40')]['length'];_0x2e24d9+=0x1){const _0x5b7be2=_0x1cc001[_0x376a73('0x40')][_0x2e24d9],_0x416809=_0xc9f01e[_0x376a73('0x36')]();_0x416809[_0x376a73('0x7')]('ut.UserId\x20=\x20?',_0x5b7be2['id']),_0x166b7a[_0x376a73('0x65')](db[_0x376a73('0x3c')][_0x376a73('0x3d')](_0x416809[_0x376a73('0x4e')](),{'type':QueryTypes[_0x376a73('0x25')]})[_0x376a73('0x26')](function(_0xb4a9ba){const _0x22cd2a=_0x376a73;if(_0xb4a9ba['length']===0x1)return _0x5b7be2['id'];else{const _0x2f9d5a=_[_0x22cd2a('0x60')](_[_0x22cd2a('0xb')](_0xb4a9ba,'TeamId'),function(_0x40c888){const _0x20638b=_0x22cd2a;return _[_0x20638b('0x42')](_0x527a47,_0x40c888);});if(_0x2f9d5a)return _0x5b7be2['id'];}}));}}return Promise[_0x376a73('0x55')](_0x166b7a)[_0x376a73('0x26')](function(_0x4cced0){const _0x1d027e=_0x376a73;return _0x396ea6=_(_0x396ea6)[_0x1d027e('0x3e')](_0x4cced0)[_0x1d027e('0x48')]()[_0x1d027e('0x4b')](),db[_0x1d027e('0x1b')][_0x1d027e('0x1')]({'where':{'id':_0x29131e['params']['id']}})[_0x1d027e('0x26')](function(_0x20dd28){return db['sequelize']['transaction'](function(_0x424223){const _0x443bed=a95_0x18cf;return _0x20dd28[_0x443bed('0x13')](_0x29131e[_0x443bed('0x3d')][_0x443bed('0x6b')],{'transaction':_0x424223})[_0x443bed('0x26')](function(){const _0x5663ad=_0x443bed;if(!_[_0x5663ad('0x0')](_0x396ea6))return _0x20dd28[_0x5663ad('0x2c')](_0x396ea6,{'transaction':_0x424223});})[_0x443bed('0x26')](function(){const _0x2a8d6f=_0x443bed;_0x396ea6[_0x2a8d6f('0x4c')](function(_0x34ba7d){const _0x4ce036=_0x2a8d6f;socket[_0x4ce036('0x70')](_0x4ce036('0x5b'),{'UserId':_0x34ba7d,'ChatQueueId':_0x20dd28['id']});});});});});});})['then'](respondWithStatusCode(_0x57a98f,null))[_0x28df0b('0x58')](handleError(_0x57a98f,null));},exports[_0x357213('0x21')]=function(_0x2b9d58,_0x2962c9){const _0x4f9e22=_0x357213;return db[_0x4f9e22('0x1b')][_0x4f9e22('0x1')]({'where':{'id':_0x2b9d58[_0x4f9e22('0x3a')]['id']}})[_0x4f9e22('0x26')](function(_0x2ba79a){const _0x2d26b2=_0x4f9e22;if(_0x2ba79a)return _0x2ba79a[_0x2d26b2('0x21')](_0x2b9d58[_0x2d26b2('0x68')][_0x2d26b2('0x6b')],{'through':_[_0x2d26b2('0x2d')](_0x2b9d58[_0x2d26b2('0x68')],[_0x2d26b2('0x6b'),'id'])})[_0x2d26b2('0x26')](function(_0x4f078d){const _0x4a6cce=_0x2d26b2;for(let _0xede1ea=0x0;_0xede1ea<_0x2b9d58[_0x4a6cce('0x68')][_0x4a6cce('0x6b')][_0x4a6cce('0x69')];_0xede1ea+=0x1){socket[_0x4a6cce('0x70')](_0x4a6cce('0x22'),{'UserId':_0x2b9d58[_0x4a6cce('0x68')][_0x4a6cce('0x6b')][_0xede1ea],'ChatQueueId':_0x2b9d58[_0x4a6cce('0x3a')]['id']});}return _0x4f078d;});})[_0x4f9e22('0x26')](respondWithResult(_0x2962c9,null))['catch'](handleError(_0x2962c9,null));},exports[_0x357213('0x2c')]=function(_0x426530,_0x4e8196){const _0x4882d6=_0x357213;return db['ChatQueue'][_0x4882d6('0x1')]({'where':{'id':_0x426530[_0x4882d6('0x3a')]['id']}})[_0x4882d6('0x26')](handleEntityNotFound(_0x4e8196,null))[_0x4882d6('0x26')](function(_0x3bb6fc){const _0x2dd2bd=_0x4882d6;if(_0x3bb6fc)return _0x3bb6fc[_0x2dd2bd('0x2c')](_0x426530[_0x2dd2bd('0x3d')]['ids'])[_0x2dd2bd('0x26')](function(){const _0x41c7e1=_0x2dd2bd;if(_['isArray'](_0x426530[_0x41c7e1('0x3d')][_0x41c7e1('0x6b')]))for(let _0x252136=0x0;_0x252136<_0x426530['query']['ids'][_0x41c7e1('0x69')];_0x252136+=0x1){socket[_0x41c7e1('0x70')]('userChatQueue:remove',{'UserId':Number(_0x426530[_0x41c7e1('0x3d')][_0x41c7e1('0x6b')][_0x252136]),'ChatQueueId':Number(_0x426530[_0x41c7e1('0x3a')]['id'])});}else socket['emit']('userChatQueue:remove',{'UserId':Number(_0x426530['query'][_0x41c7e1('0x6b')]),'ChatQueueId':Number(_0x426530[_0x41c7e1('0x3a')]['id'])});});})[_0x4882d6('0x26')](respondWithStatusCode(_0x4e8196,null))[_0x4882d6('0x58')](handleError(_0x4e8196,null));},exports['getAgents']=function(_0x3a91f4,_0x166eca){const _0x282b45=_0x357213;let _0xbbfa7={};const _0x318a0b={};let _0x3faaf3,_0xf7fb5d;return db[_0x282b45('0x1b')]['findOne']({'where':{'id':_0x3a91f4[_0x282b45('0x3a')]['id']}})[_0x282b45('0x26')](handleEntityNotFound(_0x166eca,null))['then'](function(_0x202a7e){const _0x22b917=_0x282b45;if(_0x202a7e)return _0x3faaf3=_0x202a7e,_0x318a0b[_0x22b917('0x3f')]=_[_0x22b917('0x9')](db[_0x22b917('0x20')][_0x22b917('0x6e')]),_0x318a0b[_0x22b917('0x3d')]=_[_0x22b917('0x9')](_0x3a91f4[_0x22b917('0x3d')]),_0x318a0b['filters']=_['intersection'](_0x318a0b[_0x22b917('0x3f')],_0x318a0b[_0x22b917('0x3d')]),_0xbbfa7['attributes']=_[_0x22b917('0x5e')](_0x318a0b[_0x22b917('0x3f')],qs[_0x22b917('0xe')](_0x3a91f4[_0x22b917('0x3d')]['fields'])),_0xbbfa7[_0x22b917('0x4')]=_0xbbfa7[_0x22b917('0x4')]['length']?_0xbbfa7[_0x22b917('0x4')]:_0x318a0b[_0x22b917('0x3f')],_0xbbfa7['order']=qs[_0x22b917('0x72')](_0x3a91f4[_0x22b917('0x3d')][_0x22b917('0x72')]),_0xbbfa7[_0x22b917('0x7')]=qs[_0x22b917('0x43')](_[_0x22b917('0x64')](_0x3a91f4[_0x22b917('0x3d')],_0x318a0b[_0x22b917('0x43')])),_0x3a91f4[_0x22b917('0x3d')]['filter']&&(_0xbbfa7['where']=_['merge'](_0xbbfa7[_0x22b917('0x7')],{[Op['or']]:_['map'](_0xbbfa7[_0x22b917('0x4')],function(_0x357558){const _0x3d9fd7=_0x22b917,_0x1ecf72={};return _0x1ecf72[_0x357558]={[Op[_0x3d9fd7('0x1e')]]:'%'+_0x3a91f4[_0x3d9fd7('0x3d')][_0x3d9fd7('0xd')]+'%'},_0x1ecf72;})})),_0xbbfa7=_['merge']({},_0xbbfa7,_0x3a91f4[_0x22b917('0xc')]),_0x3faaf3['getAgents'](_0xbbfa7);})[_0x282b45('0x26')](function(_0x55e16d){const _0x1b281e=_0x282b45;if(_0x55e16d)return _0xf7fb5d=_0x55e16d['length'],typeof _0x3a91f4[_0x1b281e('0x3d')][_0x1b281e('0x32')]===_0x1b281e('0x12')&&(_0xbbfa7['limit']=qs[_0x1b281e('0x47')](_0x3a91f4['query'][_0x1b281e('0x47')]),_0xbbfa7[_0x1b281e('0x5f')]=qs[_0x1b281e('0x5f')](_0x3a91f4[_0x1b281e('0x3d')][_0x1b281e('0x5f')])),_0x3faaf3[_0x1b281e('0x2f')](_0xbbfa7);})['then'](function(_0x2cad98){if(_0x2cad98)return _0x2cad98?{'count':_0xf7fb5d,'rows':_0x2cad98}:null;})['then'](respondWithResult(_0x166eca,null))[_0x282b45('0x58')](handleError(_0x166eca,null));};