Built motion from commit f651e4b0a7312c0adceb5e57d6684a801a3aaf0d. Version 3.0.0...
[motion-next.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 35e3f9e..5058acb 100644 (file)
@@ -1 +1 @@
-const a808_0x3af3=['fields','filters','query','model','create','WhatsappQueue','push','includes','destroy','emit','UserId','removeTeams','type','../../rediscache','compact','map','tq.TeamId','merge','filter','SIP','UserProfileSection','params','createdAt','count','whatsappPause','join','updatedAt','flatMap','order','rows','update','userWhatsappQueue:remove','userProfileId','keys','where','toString','userWhatsappQueue:save','findAll','addAgents','get','value','key','sendStatus','online','like','UserProfileResource','every','TeamId','Unable\x20to\x20retrieve\x20the\x20current\x20user','sequelize','findAndCountAll','getTeams','interface','fieldName','show','name','ut.UserId\x20=\x20?','forEach','error','length','VIRTUAL','findOne','Agents','WhatsappQueueId','util','UserWhatsappQueue','removeAgents','../../config/logger','attributes','ids','clone','then','rawAttributes','describe','Team','sort','ut.TeamId\x20=\x20tq.TeamId','role','end','../../mysqldb','user_has_teams','transaction','nolimit','select','addTeams','pick','index','getAgents','autoAssociation','catch','body','stack','limit','each','WhatsappQueueId\x20=\x20?','json','user','includeAll','all','status','offset','undefined','WhatsappQueues','options','User','intersection','isEmpty','union','set'];(function(_0x30a34c,_0x3af380){const _0x51e706=function(_0x1ae9a0){while(--_0x1ae9a0){_0x30a34c['push'](_0x30a34c['shift']());}};_0x51e706(++_0x3af380);}(a808_0x3af3,0x1e9));const a808_0x51e7=function(_0x30a34c,_0x3af380){_0x30a34c=_0x30a34c-0x0;let _0x51e706=a808_0x3af3[_0x30a34c];return _0x51e706;};const _0x36ee15=a808_0x51e7;'use strict';const util=require(_0x36ee15('0xb')),_=require('lodash'),squel=require('squel'),qs=require('../../components/parsers/qs'),logger=require(_0x36ee15('0xe'))('api'),{getSocket}=require(_0x36ee15('0x45')),socket=getSocket(),db=require(_0x36ee15('0x1a'))['db'],{Op,QueryTypes}=require('sequelize');require('./whatsappQueue.socket')['register'](socket);function respondWithStatusCode(_0x1ae9a0,_0x5e8e5d){return _0x5e8e5d=_0x5e8e5d||0xcc,function(_0x107267){const _0x1be7a2=a808_0x51e7;if(_0x107267)return _0x1ae9a0[_0x1be7a2('0x62')](_0x5e8e5d);return _0x1ae9a0[_0x1be7a2('0x2e')](_0x5e8e5d)[_0x1be7a2('0x19')]();};}function respondWithResult(_0x3027b9,_0x3f8c26){return _0x3f8c26=_0x3f8c26||0xc8,function(_0x941584){const _0x1898ee=a808_0x51e7;if(_0x941584)return _0x3027b9[_0x1898ee('0x2e')](_0x3f8c26)[_0x1898ee('0x2a')](_0x941584);};}function respondWithFilteredResult(_0x52a95e,_0x31fbe8){return function(_0x2ac629){const _0x6be954=a808_0x51e7;if(_0x2ac629){const _0x5db05d=_0x2ac629[_0x6be954('0x4f')],_0xa9c697=_0x31fbe8[_0x6be954('0x2f')];let _0x19c203=_0x31fbe8[_0x6be954('0x2f')]+_0x31fbe8['limit'],_0x145fe1;return _0x19c203>=_0x5db05d?(_0x19c203=_0x5db05d,_0x145fe1=0xc8):_0x145fe1=0xce,_0x52a95e[_0x6be954('0x2e')](_0x145fe1),_0x52a95e[_0x6be954('0x37')]('Content-Range',_0xa9c697+'-'+_0x19c203+'/'+_0x5db05d)[_0x6be954('0x2a')](_0x2ac629);}return null;};}function saveUpdates(_0x371c18){return function(_0x4a9aaf){const _0x36b314=a808_0x51e7;if(_0x4a9aaf)return _0x4a9aaf[_0x36b314('0x56')](_0x371c18)['then'](function(_0x4f0c98){return _0x4f0c98;});return null;};}function removeEntity(_0x4e3a68){return function(_0x1e5378){const _0x1fe798=a808_0x51e7;if(_0x1e5378)return _0x1e5378[_0x1fe798('0x40')]()['then'](function(){const _0x266c22=_0x1fe798,_0x1b691c=_0x1e5378[_0x266c22('0x5f')]({'plain':!![]}),_0x34cbf7=_0x266c22('0x31');return db[_0x266c22('0x65')]['destroy']({'where':{'type':_0x34cbf7,'resourceId':_0x1b691c['id']}})[_0x266c22('0x12')](function(){return _0x1e5378;});})['then'](function(){const _0x1f817f=_0x1fe798;_0x4e3a68[_0x1f817f('0x2e')](0xcc)[_0x1f817f('0x19')]();});};}function handleEntityNotFound(_0x1b55fc){return function(_0x3f837d){const _0x4a3db3=a808_0x51e7;return!_0x3f837d&&_0x1b55fc[_0x4a3db3('0x62')](0x194),_0x3f837d;};}function handleError(_0x19a680,_0x38c859){return _0x38c859=_0x38c859||0x1f4,function(_0x405af6){const _0x50df80=a808_0x51e7;logger[_0x50df80('0x5')](_0x405af6[_0x50df80('0x26')]),_0x405af6['name']&&delete _0x405af6[_0x50df80('0x2')],_0x19a680[_0x50df80('0x2e')](_0x38c859)['send'](_0x405af6);};}exports[_0x36ee15('0x21')]=function(_0x1e57df,_0x4836f7){const _0x34fa6e=_0x36ee15;let _0x10a619={};const _0x153e50={},_0x306b29={'count':0x0,'rows':[]},_0x305053=_[_0x34fa6e('0x47')](db['WhatsappQueue'][_0x34fa6e('0x13')],function(_0x24fd2b){const _0x4c7cd0=_0x34fa6e;return{'name':_0x24fd2b[_0x4c7cd0('0x0')],'type':_0x24fd2b[_0x4c7cd0('0x44')][_0x4c7cd0('0x61')]};});_0x153e50[_0x34fa6e('0x3b')]=_[_0x34fa6e('0x47')](_0x305053,_0x34fa6e('0x2')),_0x153e50[_0x34fa6e('0x3a')]=_[_0x34fa6e('0x59')](_0x1e57df[_0x34fa6e('0x3a')]),_0x153e50[_0x34fa6e('0x39')]=_[_0x34fa6e('0x34')](_0x153e50[_0x34fa6e('0x3b')],_0x153e50[_0x34fa6e('0x3a')]),_0x10a619[_0x34fa6e('0xf')]=_[_0x34fa6e('0x34')](_0x153e50[_0x34fa6e('0x3b')],qs['fields'](_0x1e57df[_0x34fa6e('0x3a')][_0x34fa6e('0x38')])),_0x10a619[_0x34fa6e('0xf')]=_0x10a619[_0x34fa6e('0xf')][_0x34fa6e('0x6')]?_0x10a619[_0x34fa6e('0xf')]:_0x153e50[_0x34fa6e('0x3b')];typeof _0x1e57df['query']['nolimit']===_0x34fa6e('0x30')&&(_0x10a619[_0x34fa6e('0x27')]=qs[_0x34fa6e('0x27')](_0x1e57df[_0x34fa6e('0x3a')][_0x34fa6e('0x27')]),_0x10a619['offset']=qs[_0x34fa6e('0x2f')](_0x1e57df[_0x34fa6e('0x3a')][_0x34fa6e('0x2f')]));_0x10a619[_0x34fa6e('0x54')]=qs['sort'](_0x1e57df[_0x34fa6e('0x3a')]['sort']),_0x10a619[_0x34fa6e('0x5a')]=qs[_0x34fa6e('0x39')](_[_0x34fa6e('0x20')](_0x1e57df[_0x34fa6e('0x3a')],_0x153e50['filters']),_0x305053);_0x1e57df[_0x34fa6e('0x3a')][_0x34fa6e('0x4a')]&&(_0x10a619[_0x34fa6e('0x5a')]=_['merge'](_0x10a619[_0x34fa6e('0x5a')],{[Op['or']]:_[_0x34fa6e('0x47')](_0x305053,function(_0x445c7d){const _0x1df53c=_0x34fa6e;if(_0x445c7d[_0x1df53c('0x44')]!==_0x1df53c('0x7')){const _0x44afc5={};return _0x44afc5[_0x445c7d[_0x1df53c('0x2')]]={[Op[_0x1df53c('0x64')]]:'%'+_0x1e57df[_0x1df53c('0x3a')][_0x1df53c('0x4a')]+'%'},_0x44afc5;}})}));_0x10a619=_['merge']({},_0x10a619,_0x1e57df[_0x34fa6e('0x32')]);const _0x3581c0={'where':_0x10a619[_0x34fa6e('0x5a')]};return db['WhatsappQueue'][_0x34fa6e('0x4f')](_0x3581c0)[_0x34fa6e('0x12')](function(_0x4c3dae){const _0x2cd25d=_0x34fa6e;return _0x306b29[_0x2cd25d('0x4f')]=_0x4c3dae,_0x1e57df['query'][_0x2cd25d('0x2c')]&&(_0x10a619['include']=[{'all':!![]}]),db[_0x2cd25d('0x3d')][_0x2cd25d('0x5d')](_0x10a619);})[_0x34fa6e('0x12')](function(_0x43ef6d){const _0x28e280=_0x34fa6e;return _0x306b29[_0x28e280('0x55')]=_0x43ef6d,_0x306b29;})[_0x34fa6e('0x12')](respondWithFilteredResult(_0x4836f7,_0x10a619))['catch'](handleError(_0x4836f7,null));},exports[_0x36ee15('0x1')]=function(_0xec46c5,_0x89ffd){const _0x307a1a=_0x36ee15;let _0x21f6a5={'raw':!![],'where':{'id':_0xec46c5['params']['id']}};const _0x446f9a={};return _0x446f9a['model']=_['keys'](db[_0x307a1a('0x3d')][_0x307a1a('0x13')]),_0x446f9a['query']=_['keys'](_0xec46c5['query']),_0x446f9a[_0x307a1a('0x39')]=_[_0x307a1a('0x34')](_0x446f9a[_0x307a1a('0x3b')],_0x446f9a[_0x307a1a('0x3a')]),_0x21f6a5[_0x307a1a('0xf')]=_['intersection'](_0x446f9a[_0x307a1a('0x3b')],qs[_0x307a1a('0x38')](_0xec46c5[_0x307a1a('0x3a')][_0x307a1a('0x38')])),_0x21f6a5['attributes']=_0x21f6a5['attributes']['length']?_0x21f6a5[_0x307a1a('0xf')]:_0x446f9a[_0x307a1a('0x3b')],_0xec46c5[_0x307a1a('0x3a')][_0x307a1a('0x2c')]&&(_0x21f6a5['include']=[{'all':!![]}]),_0x21f6a5=_['merge']({},_0x21f6a5,_0xec46c5['options']),db[_0x307a1a('0x3d')][_0x307a1a('0x8')](_0x21f6a5)[_0x307a1a('0x12')](handleEntityNotFound(_0x89ffd,null))['then'](respondWithResult(_0x89ffd,null))[_0x307a1a('0x24')](handleError(_0x89ffd,null));},exports['create']=function(_0x598036,_0x1a0c3d){const _0x2ce6b6=_0x36ee15;return db[_0x2ce6b6('0x3d')][_0x2ce6b6('0x3c')](_0x598036[_0x2ce6b6('0x25')],{})[_0x2ce6b6('0x12')](function(_0x4087a9){const _0x2bcf33=_0x2ce6b6,_0x321285=_0x598036[_0x2bcf33('0x2b')][_0x2bcf33('0x5f')]({'plain':!![]});if(!_0x321285)throw new Error(_0x2bcf33('0x68'));if(_0x321285[_0x2bcf33('0x18')]==='user'){const _0x1c0a62=_0x4087a9[_0x2bcf33('0x5f')]({'plain':!![]}),_0x5215ff=_0x2bcf33('0x31');return db[_0x2bcf33('0x4c')][_0x2bcf33('0x8')]({'where':{'name':_0x5215ff,'userProfileId':_0x321285[_0x2bcf33('0x58')]},'raw':!![]})[_0x2bcf33('0x12')](function(_0x32b9fa){const _0x38bc92=_0x2bcf33;return _0x32b9fa&&_0x32b9fa[_0x38bc92('0x23')]===0x0?db[_0x38bc92('0x65')]['create']({'name':_0x1c0a62[_0x38bc92('0x2')],'resourceId':_0x1c0a62['id'],'type':_0x32b9fa[_0x38bc92('0x2')],'sectionId':_0x32b9fa['id']},{})[_0x38bc92('0x12')](function(){return _0x4087a9;}):_0x4087a9;})[_0x2bcf33('0x24')](function(_0x545728){const _0x3d7c4e=_0x2bcf33;logger[_0x3d7c4e('0x5')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x545728);throw _0x545728;});}return _0x4087a9;})[_0x2ce6b6('0x12')](respondWithResult(_0x1a0c3d,0xc9))[_0x2ce6b6('0x24')](handleError(_0x1a0c3d,null));},exports['update']=function(_0x5c6c56,_0x2eba4e){const _0x3fb593=_0x36ee15;return _0x5c6c56['body']['id']&&delete _0x5c6c56[_0x3fb593('0x25')]['id'],db[_0x3fb593('0x3d')][_0x3fb593('0x8')]({'where':{'id':_0x5c6c56[_0x3fb593('0x4d')]['id']}})[_0x3fb593('0x12')](handleEntityNotFound(_0x2eba4e,null))[_0x3fb593('0x12')](saveUpdates(_0x5c6c56[_0x3fb593('0x25')],null))['then'](respondWithResult(_0x2eba4e,null))[_0x3fb593('0x24')](handleError(_0x2eba4e,null));},exports[_0x36ee15('0x40')]=function(_0x3fbd82,_0x1afd08){const _0x310cb6=_0x36ee15;return db['WhatsappQueue']['findOne']({'where':{'id':_0x3fbd82['params']['id']}})[_0x310cb6('0x12')](handleEntityNotFound(_0x1afd08,null))[_0x310cb6('0x12')](removeEntity(_0x1afd08,null))[_0x310cb6('0x24')](handleError(_0x1afd08,null));},exports[_0x36ee15('0x14')]=function(_0x48574d,_0x210a53){const _0x3736e0=_0x36ee15;return db[_0x3736e0('0x3d')]['describe']()[_0x3736e0('0x12')](respondWithResult(_0x210a53,null))[_0x3736e0('0x24')](handleError(_0x210a53,null));},exports['getMembers']=function(_0x4d6a53,_0x2a8dc8){const _0x41a38d=_0x36ee15;let _0x41d49f={'raw':!![],'where':{}};const _0x211dc3={};let _0x2af13d;return db[_0x41a38d('0x3d')][_0x41a38d('0x8')]({'where':{'id':_0x4d6a53[_0x41a38d('0x4d')]['id']}})['then'](handleEntityNotFound(_0x2a8dc8,null))['then'](function(_0x304c68){const _0x42e556=_0x41a38d;if(_0x304c68)return _0x2af13d=_0x304c68[_0x42e556('0x5f')]({'plain':!![]}),_0x211dc3['model']=_['keys'](db[_0x42e556('0xc')][_0x42e556('0x13')]),_0x211dc3[_0x42e556('0x3a')]=_[_0x42e556('0x59')](_0x4d6a53[_0x42e556('0x3a')]),_0x211dc3['filters']=_[_0x42e556('0x34')](_0x211dc3[_0x42e556('0x3b')],_0x211dc3[_0x42e556('0x3a')]),_0x41d49f['attributes']=_[_0x42e556('0x34')](_0x211dc3[_0x42e556('0x3b')],qs[_0x42e556('0x38')](_0x4d6a53[_0x42e556('0x3a')]['fields'])),_0x41d49f['attributes']=_0x41d49f['attributes'][_0x42e556('0x6')]?_0x41d49f['attributes']:_0x211dc3[_0x42e556('0x3b')],typeof _0x4d6a53[_0x42e556('0x3a')][_0x42e556('0x1d')]==='undefined'&&(_0x41d49f[_0x42e556('0x27')]=qs['limit'](_0x4d6a53['query'][_0x42e556('0x27')]),_0x41d49f['offset']=qs[_0x42e556('0x2f')](_0x4d6a53[_0x42e556('0x3a')][_0x42e556('0x2f')])),_0x41d49f[_0x42e556('0x54')]=qs[_0x42e556('0x16')](_0x4d6a53[_0x42e556('0x3a')][_0x42e556('0x16')]),_0x41d49f[_0x42e556('0x5a')]=qs[_0x42e556('0x39')](_[_0x42e556('0x20')](_0x4d6a53['query'],_0x211dc3[_0x42e556('0x39')])),_0x41d49f[_0x42e556('0x5a')][_0x42e556('0xa')]=_0x304c68['id'],_0x4d6a53['query'][_0x42e556('0x4a')]&&(_0x41d49f[_0x42e556('0x5a')]=_[_0x42e556('0x49')](_0x41d49f[_0x42e556('0x5a')],{[Op['or']]:_[_0x42e556('0x47')](_0x41d49f[_0x42e556('0xf')],function(_0x56e507){const _0x2408d7=_0x42e556,_0x101749={};return _0x101749[_0x56e507]={[Op['like']]:'%'+_0x4d6a53['query'][_0x2408d7('0x4a')]+'%'},_0x101749;})})),_0x41d49f=_[_0x42e556('0x49')]({},_0x41d49f,_0x4d6a53['options']),db['UserWhatsappQueue']['findAll'](_0x41d49f);})[_0x41a38d('0x12')](function(_0x5b449e){const _0x18fae2=_0x41a38d;if(_0x5b449e)return db[_0x18fae2('0x33')][_0x18fae2('0x6a')]({'where':{'id':_[_0x18fae2('0x47')](_0x5b449e,_0x18fae2('0x42')),'role':'agent'},'attributes':['id',_0x18fae2('0x2'),_0x18fae2('0x50'),'updatedAt',_0x18fae2('0x4e')]});})['then'](function(_0xa898b5){const _0x129dc4=_0x41a38d;return _0xa898b5?{'count':_0xa898b5[_0x129dc4('0x4f')],'rows':_[_0x129dc4('0x47')](_0xa898b5[_0x129dc4('0x55')],function(_0x58b299){const _0x585df3=_0x129dc4;return{'membername':_0x58b299[_0x585df3('0x2')],'UserId':_0x58b299['id'],'queue_name':_0x2af13d[_0x585df3('0x2')],'WhatsappQueueId':_0x2af13d['id'],'interface':util['format']('%s/%s',_0x585df3('0x4b'),_0x58b299['name']),'penalty':0x0,'paused':_0x58b299[_0x585df3('0x50')],'createdAt':_0x58b299[_0x585df3('0x4e')],'updatedAt':_0x58b299[_0x585df3('0x52')]};})}:{'count':0x0,'rows':[]};})[_0x41a38d('0x12')](respondWithFilteredResult(_0x2a8dc8,_0x41d49f))[_0x41a38d('0x24')](handleError(_0x2a8dc8,null));},exports[_0x36ee15('0x6b')]=function(_0x9f63b6,_0x23fadf){const _0x219e35=_0x36ee15;let _0x45fc13={};const _0x304b68={};let _0xc00a79,_0x17d855;return db[_0x219e35('0x3d')]['findOne']({'where':{'id':_0x9f63b6[_0x219e35('0x4d')]['id']}})['then'](handleEntityNotFound(_0x23fadf,null))[_0x219e35('0x12')](function(_0x4a2623){const _0x512b20=_0x219e35;if(_0x4a2623)return _0xc00a79=_0x4a2623,_0x304b68['model']=_[_0x512b20('0x59')](db[_0x512b20('0x15')][_0x512b20('0x13')]),_0x304b68[_0x512b20('0x3a')]=_[_0x512b20('0x59')](_0x9f63b6[_0x512b20('0x3a')]),_0x304b68[_0x512b20('0x39')]=_[_0x512b20('0x34')](_0x304b68[_0x512b20('0x3b')],_0x304b68[_0x512b20('0x3a')]),_0x45fc13[_0x512b20('0xf')]=_[_0x512b20('0x34')](_0x304b68['model'],qs['fields'](_0x9f63b6['query'][_0x512b20('0x38')])),_0x45fc13[_0x512b20('0xf')]=_0x45fc13[_0x512b20('0xf')][_0x512b20('0x6')]?_0x45fc13[_0x512b20('0xf')]:_0x304b68['model'],_0x45fc13[_0x512b20('0x54')]=qs[_0x512b20('0x16')](_0x9f63b6[_0x512b20('0x3a')][_0x512b20('0x16')]),_0x45fc13['where']=qs['filters'](_[_0x512b20('0x20')](_0x9f63b6['query'],_0x304b68[_0x512b20('0x39')])),_0x9f63b6[_0x512b20('0x3a')]['filter']&&(_0x45fc13[_0x512b20('0x5a')]=_[_0x512b20('0x49')](_0x45fc13['where'],{[Op['or']]:_[_0x512b20('0x47')](_0x45fc13['attributes'],function(_0x22be4e){const _0x2d7d23=_0x512b20,_0x7f8ea1={};return _0x7f8ea1[_0x22be4e]={[Op[_0x2d7d23('0x64')]]:'%'+_0x9f63b6['query'][_0x2d7d23('0x4a')]+'%'},_0x7f8ea1;})})),_0x45fc13=_[_0x512b20('0x49')]({},_0x45fc13,_0x9f63b6[_0x512b20('0x32')]),_0xc00a79['getTeams'](_0x45fc13);})['then'](function(_0x130c6e){const _0x54163d=_0x219e35;if(_0x130c6e)return _0x17d855=_0x130c6e[_0x54163d('0x6')],typeof _0x9f63b6[_0x54163d('0x3a')]['nolimit']==='undefined'&&(_0x45fc13[_0x54163d('0x27')]=qs[_0x54163d('0x27')](_0x9f63b6[_0x54163d('0x3a')][_0x54163d('0x27')]),_0x45fc13[_0x54163d('0x2f')]=qs[_0x54163d('0x2f')](_0x9f63b6[_0x54163d('0x3a')][_0x54163d('0x2f')])),_0xc00a79['getTeams'](_0x45fc13);})[_0x219e35('0x12')](function(_0x497911){if(_0x497911)return _0x497911?{'count':_0x17d855,'rows':_0x497911}:null;})['then'](respondWithResult(_0x23fadf,null))['catch'](handleError(_0x23fadf,null));},exports[_0x36ee15('0x1f')]=function(_0x5edd01,_0x5ba52c){const _0x47f985=_0x36ee15,_0x3cfde8=_0x5edd01[_0x47f985('0x25')][_0x47f985('0x10')];return db[_0x47f985('0x15')][_0x47f985('0x5d')]({'where':{'id':_0x3cfde8},'attributes':['id'],'include':[{'model':db['User'],'as':_0x47f985('0x9'),'attributes':['id',_0x47f985('0x2'),_0x47f985('0x63'),'voicePause',_0x47f985('0x6c')],'raw':!![]}]})['then'](function(_0x3a8e48){const _0x2c2cd5=_0x47f985;if(_0x3a8e48){const _0x5f0bd3=_[_0x2c2cd5('0x53')](_0x3a8e48,function(_0x3bbfb9){const _0x2309c8=_0x2c2cd5,_0x48b756=_0x3bbfb9[_0x2309c8('0x5f')]({'plain':!![]});return _0x48b756[_0x2309c8('0x9')];});return db['WhatsappQueue']['findOne']({'where':{'id':_0x5edd01[_0x2c2cd5('0x4d')]['id']}})[_0x2c2cd5('0x12')](function(_0x2cef40){const _0x23a142=_0x2c2cd5;return db[_0x23a142('0x69')]['transaction'](function(_0xb7c7cb){const _0x490977=_0x23a142;return _0x2cef40[_0x490977('0x1f')](_0x3cfde8,{'transaction':_0xb7c7cb})['then'](function(){const _0x3b5e70=_0x490977;return Promise[_0x3b5e70('0x28')](_0x5f0bd3,function(_0x17bc35){const _0x57815d=_0x3b5e70;return db[_0x57815d('0xc')]['findOrCreate']({'where':{'UserId':_0x17bc35['id'],'WhatsappQueueId':_0x5edd01[_0x57815d('0x4d')]['id']},'transaction':_0xb7c7cb});});})[_0x490977('0x12')](function(){_0x5f0bd3['forEach'](function(_0x3e24d7){const _0x59e681=a808_0x51e7;socket[_0x59e681('0x41')](_0x59e681('0x5c'),{'UserId':_0x3e24d7['id'],'WhatsappQueueId':_0x2cef40['id']});});});});});}})[_0x47f985('0x12')](respondWithStatusCode(_0x5ba52c,null))[_0x47f985('0x24')](handleError(_0x5ba52c,null));},exports['removeTeams']=function(_0x4466fd,_0x194650){const _0x21fbd0=_0x36ee15;return db['Team'][_0x21fbd0('0x5d')]({'where':{'id':_0x4466fd[_0x21fbd0('0x3a')]['ids']},'attributes':['id'],'include':[{'model':db[_0x21fbd0('0x33')],'as':_0x21fbd0('0x9'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x194650,null))[_0x21fbd0('0x12')](function(_0x4ae4a8){const _0x211746=_0x21fbd0,_0x1a9753=_[_0x211746('0x47')](_0x4ae4a8,'id');let _0x2ca35d=[];const _0x26074c=[],_0x1b5592=squel[_0x211746('0x1e')]();_0x1b5592['field'](_0x211746('0x48'))['from']('team_has_whatsapp_queues','tq')[_0x211746('0x51')](_0x211746('0x1b'),'ut',_0x211746('0x17'))[_0x211746('0x5a')](_0x211746('0x29'),_0x4466fd['params']['id']);for(let _0x2e13cc=0x0;_0x2e13cc<_0x4ae4a8['length'];_0x2e13cc+=0x1){const _0x392076=_0x4ae4a8[_0x2e13cc];for(let _0x20152b=0x0;_0x20152b<_0x392076[_0x211746('0x9')]['length'];_0x20152b+=0x1){const _0x1ab174=_0x392076['Agents'][_0x20152b],_0x2e218d=_0x1b5592[_0x211746('0x11')]();_0x2e218d[_0x211746('0x5a')](_0x211746('0x3'),_0x1ab174['id']),_0x26074c[_0x211746('0x3e')](db['sequelize'][_0x211746('0x3a')](_0x2e218d[_0x211746('0x5b')](),{'type':QueryTypes['SELECT']})[_0x211746('0x12')](function(_0x3047b3){const _0x54a720=_0x211746;if(_0x3047b3[_0x54a720('0x6')]===0x1)return _0x1ab174['id'];else{const _0x3f40ec=_[_0x54a720('0x66')](_['map'](_0x3047b3,_0x54a720('0x67')),function(_0x4898b7){const _0x65e8e8=_0x54a720;return _[_0x65e8e8('0x3f')](_0x1a9753,_0x4898b7);});if(_0x3f40ec)return _0x1ab174['id'];}}));}}return Promise[_0x211746('0x2d')](_0x26074c)[_0x211746('0x12')](function(_0x334847){const _0x48b5d5=_0x211746;return _0x2ca35d=_(_0x2ca35d)[_0x48b5d5('0x36')](_0x334847)[_0x48b5d5('0x46')]()[_0x48b5d5('0x60')](),db[_0x48b5d5('0x3d')]['findOne']({'where':{'id':_0x4466fd[_0x48b5d5('0x4d')]['id']}})[_0x48b5d5('0x12')](function(_0x2288f0){const _0x40b93c=_0x48b5d5;return db['sequelize'][_0x40b93c('0x1c')](function(_0x4fada8){const _0x969dcd=_0x40b93c;return _0x2288f0[_0x969dcd('0x43')](_0x4466fd[_0x969dcd('0x3a')][_0x969dcd('0x10')],{'transaction':_0x4fada8})[_0x969dcd('0x12')](function(){const _0x546bda=_0x969dcd;if(!_[_0x546bda('0x35')](_0x2ca35d))return _0x2288f0[_0x546bda('0xd')](_0x2ca35d,{'transaction':_0x4fada8});})[_0x969dcd('0x12')](function(){const _0x437db2=_0x969dcd;_0x2ca35d[_0x437db2('0x4')](function(_0xfbada6){const _0x2d658d=_0x437db2;socket['emit'](_0x2d658d('0x57'),{'UserId':_0xfbada6,'WhatsappQueueId':_0x2288f0['id']});});});});});});})[_0x21fbd0('0x12')](respondWithStatusCode(_0x194650,null))[_0x21fbd0('0x24')](handleError(_0x194650,null));},exports['addAgents']=function(_0x211449,_0x331986){const _0x249ca4=_0x36ee15;return db[_0x249ca4('0x3d')][_0x249ca4('0x8')]({'where':{'id':_0x211449['params']['id']}})[_0x249ca4('0x12')](function(_0x97a255){const _0x20af6b=_0x249ca4;if(_0x97a255)return _0x97a255[_0x20af6b('0x5e')](_0x211449[_0x20af6b('0x25')]['ids'],{'through':_['omit'](_0x211449[_0x20af6b('0x25')],[_0x20af6b('0x10'),'id'])})[_0x20af6b('0x12')](function(_0x1d9e49){const _0x30d317=_0x20af6b;for(let _0x37b2bb=0x0;_0x37b2bb<_0x211449[_0x30d317('0x25')][_0x30d317('0x10')]['length'];_0x37b2bb+=0x1){socket[_0x30d317('0x41')](_0x30d317('0x5c'),{'UserId':_0x211449[_0x30d317('0x25')][_0x30d317('0x10')][_0x37b2bb],'WhatsappQueueId':_0x211449[_0x30d317('0x4d')]['id']});}return _0x1d9e49;});})[_0x249ca4('0x12')](respondWithResult(_0x331986,null))[_0x249ca4('0x24')](handleError(_0x331986,null));},exports[_0x36ee15('0xd')]=function(_0x2c5ab4,_0x324a47){const _0x30f665=_0x36ee15;return db['WhatsappQueue'][_0x30f665('0x8')]({'where':{'id':_0x2c5ab4[_0x30f665('0x4d')]['id']}})[_0x30f665('0x12')](handleEntityNotFound(_0x324a47,null))[_0x30f665('0x12')](function(_0x2fb955){const _0x4520fb=_0x30f665;if(_0x2fb955)return _0x2fb955[_0x4520fb('0xd')](_0x2c5ab4['query'][_0x4520fb('0x10')])[_0x4520fb('0x12')](function(){const _0x138755=_0x4520fb;if(_['isArray'](_0x2c5ab4['query'][_0x138755('0x10')]))for(let _0x2291d0=0x0;_0x2291d0<_0x2c5ab4[_0x138755('0x3a')][_0x138755('0x10')][_0x138755('0x6')];_0x2291d0+=0x1){socket[_0x138755('0x41')](_0x138755('0x57'),{'UserId':Number(_0x2c5ab4[_0x138755('0x3a')]['ids'][_0x2291d0]),'WhatsappQueueId':Number(_0x2c5ab4[_0x138755('0x4d')]['id'])});}else socket[_0x138755('0x41')]('userWhatsappQueue:remove',{'UserId':Number(_0x2c5ab4['query']['ids']),'WhatsappQueueId':Number(_0x2c5ab4['params']['id'])});});})[_0x30f665('0x12')](respondWithStatusCode(_0x324a47,null))[_0x30f665('0x24')](handleError(_0x324a47,null));},exports['getAgents']=function(_0x445d48,_0x3c876a){const _0x422ec6=_0x36ee15;let _0x221913={};const _0x40b752={};let _0x19a7bf,_0x10f58e;return db['WhatsappQueue'][_0x422ec6('0x8')]({'where':{'id':_0x445d48['params']['id']}})[_0x422ec6('0x12')](handleEntityNotFound(_0x3c876a,null))[_0x422ec6('0x12')](function(_0xc76194){const _0x5a8768=_0x422ec6;if(_0xc76194)return _0x19a7bf=_0xc76194,_0x40b752[_0x5a8768('0x3b')]=_['keys'](db[_0x5a8768('0x33')][_0x5a8768('0x13')]),_0x40b752['query']=_[_0x5a8768('0x59')](_0x445d48[_0x5a8768('0x3a')]),_0x40b752['filters']=_['intersection'](_0x40b752[_0x5a8768('0x3b')],_0x40b752['query']),_0x221913[_0x5a8768('0xf')]=_[_0x5a8768('0x34')](_0x40b752[_0x5a8768('0x3b')],qs[_0x5a8768('0x38')](_0x445d48[_0x5a8768('0x3a')][_0x5a8768('0x38')])),_0x221913['attributes']=_0x221913['attributes']['length']?_0x221913[_0x5a8768('0xf')]:_0x40b752[_0x5a8768('0x3b')],_0x221913[_0x5a8768('0x54')]=qs[_0x5a8768('0x16')](_0x445d48[_0x5a8768('0x3a')][_0x5a8768('0x16')]),_0x221913['where']=qs[_0x5a8768('0x39')](_[_0x5a8768('0x20')](_0x445d48[_0x5a8768('0x3a')],_0x40b752[_0x5a8768('0x39')])),_0x445d48['query'][_0x5a8768('0x4a')]&&(_0x221913[_0x5a8768('0x5a')]=_[_0x5a8768('0x49')](_0x221913[_0x5a8768('0x5a')],{[Op['or']]:_[_0x5a8768('0x47')](_0x221913[_0x5a8768('0xf')],function(_0x1c630e){const _0x5a4d0f=_0x5a8768,_0x4b3ef0={};return _0x4b3ef0[_0x1c630e]={[Op[_0x5a4d0f('0x64')]]:'%'+_0x445d48[_0x5a4d0f('0x3a')]['filter']+'%'},_0x4b3ef0;})})),_0x221913=_['merge']({},_0x221913,_0x445d48[_0x5a8768('0x32')]),_0x19a7bf['getAgents'](_0x221913);})['then'](function(_0x5baaca){const _0x545a3e=_0x422ec6;if(_0x5baaca)return _0x10f58e=_0x5baaca[_0x545a3e('0x6')],typeof _0x445d48['query']['nolimit']===_0x545a3e('0x30')&&(_0x221913['limit']=qs['limit'](_0x445d48[_0x545a3e('0x3a')][_0x545a3e('0x27')]),_0x221913[_0x545a3e('0x2f')]=qs['offset'](_0x445d48[_0x545a3e('0x3a')][_0x545a3e('0x2f')])),_0x19a7bf[_0x545a3e('0x22')](_0x221913);})['then'](function(_0x941063){if(_0x941063)return _0x941063?{'count':_0x10f58e,'rows':_0x941063}:null;})[_0x422ec6('0x12')](respondWithResult(_0x3c876a,null))[_0x422ec6('0x24')](handleError(_0x3c876a,null));};
\ No newline at end of file
+const a808_0xf1da=['UserWhatsappQueue','compact','findOne','userWhatsappQueue:save','WhatsappQueueId','addAgents','Team','describe','team_has_whatsapp_queues','TeamId','error','body','../../mysqldb','UserProfileSection','send','intersection','lodash','autoAssociation','Content-Range','../../components/parsers/qs','Agents','count','updatedAt','findAll','tq.TeamId','Unable\x20to\x20retrieve\x20the\x20current\x20user','push','set','end','transaction','where','userProfileId','map','stack','undefined','SIP','value','util','key','offset','api','order','online','removeAgents','index','omit','userWhatsappQueue:remove','removeTeams','includeAll','WhatsappQueues','rows','%s/%s','destroy','format','options','sort','params','join','model','register','sendStatus','User','getTeams','then','filter','status','catch','create','include','createdAt','ut.UserId\x20=\x20?','fieldName','update','role','nolimit','like','includes','get','query','UserId','fields','./whatsappQueue.socket','WhatsappQueue','isArray','whatsappPause','name','agent','ids','each','getAgents','type','clone','pick','findAndCountAll','findOrCreate','sequelize','emit','attributes','limit','user','squel','filters','merge','keys','all','length','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','rawAttributes'];(function(_0x1b602f,_0xf1dadf){const _0x3d3cff=function(_0x157fe5){while(--_0x157fe5){_0x1b602f['push'](_0x1b602f['shift']());}};_0x3d3cff(++_0xf1dadf);}(a808_0xf1da,0x1a8));const a808_0x3d3c=function(_0x1b602f,_0xf1dadf){_0x1b602f=_0x1b602f-0x0;let _0x3d3cff=a808_0xf1da[_0x1b602f];return _0x3d3cff;};const _0x295ae9=a808_0x3d3c;'use strict';const util=require(_0x295ae9('0x31')),_=require(_0x295ae9('0x1c')),squel=require(_0x295ae9('0x3')),qs=require(_0x295ae9('0x1f')),logger=require('../../config/logger')(_0x295ae9('0x34')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require(_0x295ae9('0x18'))['db'],{Op,QueryTypes}=require(_0x295ae9('0x6b'));require(_0x295ae9('0x5d'))[_0x295ae9('0x47')](socket);function respondWithStatusCode(_0x157fe5,_0x33a33f){return _0x33a33f=_0x33a33f||0xcc,function(_0xf0b592){const _0x41449a=a808_0x3d3c;if(_0xf0b592)return _0x157fe5[_0x41449a('0x48')](_0x33a33f);return _0x157fe5['status'](_0x33a33f)[_0x41449a('0x28')]();};}function respondWithResult(_0x1427f7,_0x39ae93){return _0x39ae93=_0x39ae93||0xc8,function(_0x26372e){const _0x552768=a808_0x3d3c;if(_0x26372e)return _0x1427f7[_0x552768('0x4d')](_0x39ae93)['json'](_0x26372e);};}function respondWithFilteredResult(_0x36dd1d,_0x49b777){return function(_0x29164a){const _0x27cbae=a808_0x3d3c;if(_0x29164a){const _0x358efe=_0x29164a[_0x27cbae('0x21')],_0x31aba2=_0x49b777[_0x27cbae('0x33')];let _0x26ea7c=_0x49b777[_0x27cbae('0x33')]+_0x49b777[_0x27cbae('0x1')],_0x478a10;return _0x26ea7c>=_0x358efe?(_0x26ea7c=_0x358efe,_0x478a10=0xc8):_0x478a10=0xce,_0x36dd1d[_0x27cbae('0x4d')](_0x478a10),_0x36dd1d[_0x27cbae('0x27')](_0x27cbae('0x1e'),_0x31aba2+'-'+_0x26ea7c+'/'+_0x358efe)['json'](_0x29164a);}return null;};}function saveUpdates(_0x457111){return function(_0x5c598f){const _0x4049fc=a808_0x3d3c;if(_0x5c598f)return _0x5c598f[_0x4049fc('0x54')](_0x457111)[_0x4049fc('0x4b')](function(_0x367f6f){return _0x367f6f;});return null;};}function removeEntity(_0x3efb23){return function(_0x5f0b17){if(_0x5f0b17)return _0x5f0b17['destroy']()['then'](function(){const _0x570a95=a808_0x3d3c,_0x5894b7=_0x5f0b17[_0x570a95('0x59')]({'plain':!![]}),_0x760e75=_0x570a95('0x3d');return db['UserProfileResource'][_0x570a95('0x40')]({'where':{'type':_0x760e75,'resourceId':_0x5894b7['id']}})[_0x570a95('0x4b')](function(){return _0x5f0b17;});})['then'](function(){const _0x1c6af2=a808_0x3d3c;_0x3efb23[_0x1c6af2('0x4d')](0xcc)[_0x1c6af2('0x28')]();});};}function handleEntityNotFound(_0x1b3e80){return function(_0x438880){const _0x477533=a808_0x3d3c;return!_0x438880&&_0x1b3e80[_0x477533('0x48')](0x194),_0x438880;};}function handleError(_0x14c142,_0x3a1ee4){return _0x3a1ee4=_0x3a1ee4||0x1f4,function(_0x136d90){const _0x147234=a808_0x3d3c;logger[_0x147234('0x16')](_0x136d90[_0x147234('0x2d')]),_0x136d90['name']&&delete _0x136d90['name'],_0x14c142[_0x147234('0x4d')](_0x3a1ee4)[_0x147234('0x1a')](_0x136d90);};}exports[_0x295ae9('0x38')]=function(_0x4ea368,_0x351f9a){const _0xff9ece=_0x295ae9;let _0x421856={};const _0x3ed641={},_0x547dd7={'count':0x0,'rows':[]},_0x49558f=_['map'](db[_0xff9ece('0x5e')]['rawAttributes'],function(_0x5a1a56){const _0x33f542=_0xff9ece;return{'name':_0x5a1a56[_0x33f542('0x53')],'type':_0x5a1a56[_0x33f542('0x66')][_0x33f542('0x32')]};});_0x3ed641[_0xff9ece('0x46')]=_[_0xff9ece('0x2c')](_0x49558f,'name'),_0x3ed641['query']=_['keys'](_0x4ea368[_0xff9ece('0x5a')]),_0x3ed641['filters']=_['intersection'](_0x3ed641[_0xff9ece('0x46')],_0x3ed641[_0xff9ece('0x5a')]),_0x421856[_0xff9ece('0x0')]=_[_0xff9ece('0x1b')](_0x3ed641[_0xff9ece('0x46')],qs['fields'](_0x4ea368[_0xff9ece('0x5a')][_0xff9ece('0x5c')])),_0x421856[_0xff9ece('0x0')]=_0x421856[_0xff9ece('0x0')][_0xff9ece('0x8')]?_0x421856['attributes']:_0x3ed641['model'];typeof _0x4ea368[_0xff9ece('0x5a')][_0xff9ece('0x56')]==='undefined'&&(_0x421856[_0xff9ece('0x1')]=qs[_0xff9ece('0x1')](_0x4ea368['query'][_0xff9ece('0x1')]),_0x421856['offset']=qs[_0xff9ece('0x33')](_0x4ea368[_0xff9ece('0x5a')][_0xff9ece('0x33')]));_0x421856[_0xff9ece('0x35')]=qs[_0xff9ece('0x43')](_0x4ea368[_0xff9ece('0x5a')][_0xff9ece('0x43')]),_0x421856['where']=qs[_0xff9ece('0x4')](_['pick'](_0x4ea368[_0xff9ece('0x5a')],_0x3ed641[_0xff9ece('0x4')]),_0x49558f);_0x4ea368[_0xff9ece('0x5a')][_0xff9ece('0x4c')]&&(_0x421856[_0xff9ece('0x2a')]=_[_0xff9ece('0x5')](_0x421856[_0xff9ece('0x2a')],{[Op['or']]:_[_0xff9ece('0x2c')](_0x49558f,function(_0x5afaae){const _0x2f48d6=_0xff9ece;if(_0x5afaae['type']!=='VIRTUAL'){const _0x429076={};return _0x429076[_0x5afaae[_0x2f48d6('0x61')]]={[Op[_0x2f48d6('0x57')]]:'%'+_0x4ea368[_0x2f48d6('0x5a')]['filter']+'%'},_0x429076;}})}));_0x421856=_['merge']({},_0x421856,_0x4ea368[_0xff9ece('0x42')]);const _0x5501bb={'where':_0x421856[_0xff9ece('0x2a')]};return db[_0xff9ece('0x5e')][_0xff9ece('0x21')](_0x5501bb)[_0xff9ece('0x4b')](function(_0x1f8282){const _0x25482a=_0xff9ece;return _0x547dd7['count']=_0x1f8282,_0x4ea368[_0x25482a('0x5a')][_0x25482a('0x3c')]&&(_0x421856[_0x25482a('0x50')]=[{'all':!![]}]),db[_0x25482a('0x5e')][_0x25482a('0x23')](_0x421856);})[_0xff9ece('0x4b')](function(_0x5f5406){const _0x126174=_0xff9ece;return _0x547dd7[_0x126174('0x3e')]=_0x5f5406,_0x547dd7;})['then'](respondWithFilteredResult(_0x351f9a,_0x421856))[_0xff9ece('0x4e')](handleError(_0x351f9a,null));},exports['show']=function(_0x2a2de8,_0x5e861d){const _0x1b7edc=_0x295ae9;let _0x1fcccc={'raw':!![],'where':{'id':_0x2a2de8[_0x1b7edc('0x44')]['id']}};const _0x160c65={};return _0x160c65[_0x1b7edc('0x46')]=_[_0x1b7edc('0x6')](db[_0x1b7edc('0x5e')]['rawAttributes']),_0x160c65[_0x1b7edc('0x5a')]=_[_0x1b7edc('0x6')](_0x2a2de8[_0x1b7edc('0x5a')]),_0x160c65['filters']=_['intersection'](_0x160c65[_0x1b7edc('0x46')],_0x160c65[_0x1b7edc('0x5a')]),_0x1fcccc[_0x1b7edc('0x0')]=_[_0x1b7edc('0x1b')](_0x160c65[_0x1b7edc('0x46')],qs[_0x1b7edc('0x5c')](_0x2a2de8[_0x1b7edc('0x5a')][_0x1b7edc('0x5c')])),_0x1fcccc[_0x1b7edc('0x0')]=_0x1fcccc[_0x1b7edc('0x0')]['length']?_0x1fcccc[_0x1b7edc('0x0')]:_0x160c65[_0x1b7edc('0x46')],_0x2a2de8[_0x1b7edc('0x5a')][_0x1b7edc('0x3c')]&&(_0x1fcccc['include']=[{'all':!![]}]),_0x1fcccc=_[_0x1b7edc('0x5')]({},_0x1fcccc,_0x2a2de8[_0x1b7edc('0x42')]),db[_0x1b7edc('0x5e')]['findOne'](_0x1fcccc)[_0x1b7edc('0x4b')](handleEntityNotFound(_0x5e861d,null))['then'](respondWithResult(_0x5e861d,null))[_0x1b7edc('0x4e')](handleError(_0x5e861d,null));},exports[_0x295ae9('0x4f')]=function(_0x388452,_0x258a9f){const _0x38f31d=_0x295ae9;return db['WhatsappQueue'][_0x38f31d('0x4f')](_0x388452[_0x38f31d('0x17')],{})['then'](function(_0x495db0){const _0x540344=_0x38f31d,_0x2e0f35=_0x388452[_0x540344('0x2')]['get']({'plain':!![]});if(!_0x2e0f35)throw new Error(_0x540344('0x25'));if(_0x2e0f35[_0x540344('0x55')]===_0x540344('0x2')){const _0x33f68a=_0x495db0['get']({'plain':!![]}),_0x52a852='WhatsappQueues';return db[_0x540344('0x19')][_0x540344('0xe')]({'where':{'name':_0x52a852,'userProfileId':_0x2e0f35[_0x540344('0x2b')]},'raw':!![]})['then'](function(_0x379760){const _0x1f5957=_0x540344;return _0x379760&&_0x379760[_0x1f5957('0x1d')]===0x0?db['UserProfileResource'][_0x1f5957('0x4f')]({'name':_0x33f68a[_0x1f5957('0x61')],'resourceId':_0x33f68a['id'],'type':_0x379760[_0x1f5957('0x61')],'sectionId':_0x379760['id']},{})[_0x1f5957('0x4b')](function(){return _0x495db0;}):_0x495db0;})[_0x540344('0x4e')](function(_0x4d1fd2){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4d1fd2);throw _0x4d1fd2;});}return _0x495db0;})[_0x38f31d('0x4b')](respondWithResult(_0x258a9f,0xc9))[_0x38f31d('0x4e')](handleError(_0x258a9f,null));},exports[_0x295ae9('0x54')]=function(_0x4ae29b,_0x3db89f){const _0x2b5287=_0x295ae9;return _0x4ae29b['body']['id']&&delete _0x4ae29b[_0x2b5287('0x17')]['id'],db[_0x2b5287('0x5e')][_0x2b5287('0xe')]({'where':{'id':_0x4ae29b[_0x2b5287('0x44')]['id']}})[_0x2b5287('0x4b')](handleEntityNotFound(_0x3db89f,null))[_0x2b5287('0x4b')](saveUpdates(_0x4ae29b[_0x2b5287('0x17')],null))[_0x2b5287('0x4b')](respondWithResult(_0x3db89f,null))[_0x2b5287('0x4e')](handleError(_0x3db89f,null));},exports[_0x295ae9('0x40')]=function(_0x4ed01a,_0x537ce3){const _0x3dba9d=_0x295ae9;return db[_0x3dba9d('0x5e')][_0x3dba9d('0xe')]({'where':{'id':_0x4ed01a[_0x3dba9d('0x44')]['id']}})['then'](handleEntityNotFound(_0x537ce3,null))[_0x3dba9d('0x4b')](removeEntity(_0x537ce3,null))[_0x3dba9d('0x4e')](handleError(_0x537ce3,null));},exports[_0x295ae9('0x13')]=function(_0x594a46,_0x5f18f4){const _0x43b800=_0x295ae9;return db[_0x43b800('0x5e')]['describe']()[_0x43b800('0x4b')](respondWithResult(_0x5f18f4,null))[_0x43b800('0x4e')](handleError(_0x5f18f4,null));},exports['getMembers']=function(_0x21e5bf,_0x2dd573){const _0x58b814=_0x295ae9;let _0x4ca95c={'raw':!![],'where':{}};const _0x529602={};let _0xd54120;return db[_0x58b814('0x5e')]['findOne']({'where':{'id':_0x21e5bf[_0x58b814('0x44')]['id']}})[_0x58b814('0x4b')](handleEntityNotFound(_0x2dd573,null))[_0x58b814('0x4b')](function(_0x639bea){const _0x2dc2e7=_0x58b814;if(_0x639bea)return _0xd54120=_0x639bea['get']({'plain':!![]}),_0x529602['model']=_[_0x2dc2e7('0x6')](db[_0x2dc2e7('0xc')][_0x2dc2e7('0xb')]),_0x529602[_0x2dc2e7('0x5a')]=_['keys'](_0x21e5bf[_0x2dc2e7('0x5a')]),_0x529602['filters']=_[_0x2dc2e7('0x1b')](_0x529602[_0x2dc2e7('0x46')],_0x529602[_0x2dc2e7('0x5a')]),_0x4ca95c['attributes']=_[_0x2dc2e7('0x1b')](_0x529602['model'],qs[_0x2dc2e7('0x5c')](_0x21e5bf[_0x2dc2e7('0x5a')]['fields'])),_0x4ca95c[_0x2dc2e7('0x0')]=_0x4ca95c[_0x2dc2e7('0x0')][_0x2dc2e7('0x8')]?_0x4ca95c[_0x2dc2e7('0x0')]:_0x529602[_0x2dc2e7('0x46')],typeof _0x21e5bf[_0x2dc2e7('0x5a')][_0x2dc2e7('0x56')]===_0x2dc2e7('0x2e')&&(_0x4ca95c[_0x2dc2e7('0x1')]=qs[_0x2dc2e7('0x1')](_0x21e5bf[_0x2dc2e7('0x5a')]['limit']),_0x4ca95c[_0x2dc2e7('0x33')]=qs[_0x2dc2e7('0x33')](_0x21e5bf[_0x2dc2e7('0x5a')][_0x2dc2e7('0x33')])),_0x4ca95c[_0x2dc2e7('0x35')]=qs[_0x2dc2e7('0x43')](_0x21e5bf[_0x2dc2e7('0x5a')][_0x2dc2e7('0x43')]),_0x4ca95c[_0x2dc2e7('0x2a')]=qs['filters'](_[_0x2dc2e7('0x68')](_0x21e5bf[_0x2dc2e7('0x5a')],_0x529602[_0x2dc2e7('0x4')])),_0x4ca95c[_0x2dc2e7('0x2a')][_0x2dc2e7('0x10')]=_0x639bea['id'],_0x21e5bf[_0x2dc2e7('0x5a')][_0x2dc2e7('0x4c')]&&(_0x4ca95c[_0x2dc2e7('0x2a')]=_[_0x2dc2e7('0x5')](_0x4ca95c[_0x2dc2e7('0x2a')],{[Op['or']]:_[_0x2dc2e7('0x2c')](_0x4ca95c[_0x2dc2e7('0x0')],function(_0x349fae){const _0xf1d972=_0x2dc2e7,_0x4c2eba={};return _0x4c2eba[_0x349fae]={[Op[_0xf1d972('0x57')]]:'%'+_0x21e5bf[_0xf1d972('0x5a')]['filter']+'%'},_0x4c2eba;})})),_0x4ca95c=_[_0x2dc2e7('0x5')]({},_0x4ca95c,_0x21e5bf[_0x2dc2e7('0x42')]),db['UserWhatsappQueue']['findAll'](_0x4ca95c);})[_0x58b814('0x4b')](function(_0x4aa0f6){const _0x5b5289=_0x58b814;if(_0x4aa0f6)return db['User'][_0x5b5289('0x69')]({'where':{'id':_[_0x5b5289('0x2c')](_0x4aa0f6,_0x5b5289('0x5b')),'role':_0x5b5289('0x62')},'attributes':['id',_0x5b5289('0x61'),_0x5b5289('0x60'),_0x5b5289('0x22'),_0x5b5289('0x51')]});})[_0x58b814('0x4b')](function(_0x299afe){const _0x5f20a4=_0x58b814;return _0x299afe?{'count':_0x299afe['count'],'rows':_[_0x5f20a4('0x2c')](_0x299afe[_0x5f20a4('0x3e')],function(_0x2ee4e4){const _0x3327d3=_0x5f20a4;return{'membername':_0x2ee4e4[_0x3327d3('0x61')],'UserId':_0x2ee4e4['id'],'queue_name':_0xd54120[_0x3327d3('0x61')],'WhatsappQueueId':_0xd54120['id'],'interface':util[_0x3327d3('0x41')](_0x3327d3('0x3f'),_0x3327d3('0x2f'),_0x2ee4e4['name']),'penalty':0x0,'paused':_0x2ee4e4[_0x3327d3('0x60')],'createdAt':_0x2ee4e4[_0x3327d3('0x51')],'updatedAt':_0x2ee4e4[_0x3327d3('0x22')]};})}:{'count':0x0,'rows':[]};})['then'](respondWithFilteredResult(_0x2dd573,_0x4ca95c))[_0x58b814('0x4e')](handleError(_0x2dd573,null));},exports[_0x295ae9('0x4a')]=function(_0x36a4af,_0x34d7dc){const _0x1c8892=_0x295ae9;let _0x48bbe3={};const _0x5add42={};let _0xc0f337,_0x59a8f9;return db['WhatsappQueue']['findOne']({'where':{'id':_0x36a4af['params']['id']}})[_0x1c8892('0x4b')](handleEntityNotFound(_0x34d7dc,null))[_0x1c8892('0x4b')](function(_0xa80ea){const _0x51c508=_0x1c8892;if(_0xa80ea)return _0xc0f337=_0xa80ea,_0x5add42[_0x51c508('0x46')]=_[_0x51c508('0x6')](db['Team'][_0x51c508('0xb')]),_0x5add42['query']=_[_0x51c508('0x6')](_0x36a4af[_0x51c508('0x5a')]),_0x5add42[_0x51c508('0x4')]=_[_0x51c508('0x1b')](_0x5add42[_0x51c508('0x46')],_0x5add42['query']),_0x48bbe3[_0x51c508('0x0')]=_[_0x51c508('0x1b')](_0x5add42[_0x51c508('0x46')],qs[_0x51c508('0x5c')](_0x36a4af['query']['fields'])),_0x48bbe3[_0x51c508('0x0')]=_0x48bbe3[_0x51c508('0x0')][_0x51c508('0x8')]?_0x48bbe3[_0x51c508('0x0')]:_0x5add42[_0x51c508('0x46')],_0x48bbe3[_0x51c508('0x35')]=qs['sort'](_0x36a4af[_0x51c508('0x5a')][_0x51c508('0x43')]),_0x48bbe3['where']=qs[_0x51c508('0x4')](_[_0x51c508('0x68')](_0x36a4af[_0x51c508('0x5a')],_0x5add42[_0x51c508('0x4')])),_0x36a4af['query'][_0x51c508('0x4c')]&&(_0x48bbe3['where']=_[_0x51c508('0x5')](_0x48bbe3[_0x51c508('0x2a')],{[Op['or']]:_[_0x51c508('0x2c')](_0x48bbe3['attributes'],function(_0xc6252){const _0x113e67=_0x51c508,_0x216b0b={};return _0x216b0b[_0xc6252]={[Op[_0x113e67('0x57')]]:'%'+_0x36a4af[_0x113e67('0x5a')][_0x113e67('0x4c')]+'%'},_0x216b0b;})})),_0x48bbe3=_['merge']({},_0x48bbe3,_0x36a4af['options']),_0xc0f337[_0x51c508('0x4a')](_0x48bbe3);})[_0x1c8892('0x4b')](function(_0x2355b8){const _0x35f927=_0x1c8892;if(_0x2355b8)return _0x59a8f9=_0x2355b8[_0x35f927('0x8')],typeof _0x36a4af['query'][_0x35f927('0x56')]===_0x35f927('0x2e')&&(_0x48bbe3[_0x35f927('0x1')]=qs[_0x35f927('0x1')](_0x36a4af[_0x35f927('0x5a')]['limit']),_0x48bbe3[_0x35f927('0x33')]=qs[_0x35f927('0x33')](_0x36a4af[_0x35f927('0x5a')][_0x35f927('0x33')])),_0xc0f337[_0x35f927('0x4a')](_0x48bbe3);})[_0x1c8892('0x4b')](function(_0x2b16f6){if(_0x2b16f6)return _0x2b16f6?{'count':_0x59a8f9,'rows':_0x2b16f6}:null;})['then'](respondWithResult(_0x34d7dc,null))[_0x1c8892('0x4e')](handleError(_0x34d7dc,null));},exports['addTeams']=function(_0x3f105c,_0x2ec4f0){const _0x45568f=_0x295ae9,_0x40c5a6=_0x3f105c[_0x45568f('0x17')][_0x45568f('0x63')];return db[_0x45568f('0x12')][_0x45568f('0x23')]({'where':{'id':_0x40c5a6},'attributes':['id'],'include':[{'model':db[_0x45568f('0x49')],'as':_0x45568f('0x20'),'attributes':['id',_0x45568f('0x61'),_0x45568f('0x36'),'voicePause','interface'],'raw':!![]}]})[_0x45568f('0x4b')](function(_0x2065b5){const _0x5949c3=_0x45568f;if(_0x2065b5){const _0x2d68ab=_['flatMap'](_0x2065b5,function(_0x49eee7){const _0x391376=a808_0x3d3c,_0x5e4fb8=_0x49eee7['get']({'plain':!![]});return _0x5e4fb8[_0x391376('0x20')];});return db[_0x5949c3('0x5e')][_0x5949c3('0xe')]({'where':{'id':_0x3f105c[_0x5949c3('0x44')]['id']}})[_0x5949c3('0x4b')](function(_0x3e40de){const _0xd4ff91=_0x5949c3;return db[_0xd4ff91('0x6b')][_0xd4ff91('0x29')](function(_0x14dbbd){const _0x504979=_0xd4ff91;return _0x3e40de['addTeams'](_0x40c5a6,{'transaction':_0x14dbbd})[_0x504979('0x4b')](function(){const _0x199b5f=_0x504979;return Promise[_0x199b5f('0x64')](_0x2d68ab,function(_0x1ac07b){const _0x5ed44d=_0x199b5f;return db[_0x5ed44d('0xc')][_0x5ed44d('0x6a')]({'where':{'UserId':_0x1ac07b['id'],'WhatsappQueueId':_0x3f105c[_0x5ed44d('0x44')]['id']},'transaction':_0x14dbbd});});})['then'](function(){_0x2d68ab['forEach'](function(_0x5235c0){const _0xc52b89=a808_0x3d3c;socket[_0xc52b89('0x6c')](_0xc52b89('0xf'),{'UserId':_0x5235c0['id'],'WhatsappQueueId':_0x3e40de['id']});});});});});}})[_0x45568f('0x4b')](respondWithStatusCode(_0x2ec4f0,null))[_0x45568f('0x4e')](handleError(_0x2ec4f0,null));},exports[_0x295ae9('0x3b')]=function(_0x3039d3,_0x5c4be5){const _0x3ffd59=_0x295ae9;return db[_0x3ffd59('0x12')][_0x3ffd59('0x23')]({'where':{'id':_0x3039d3[_0x3ffd59('0x5a')]['ids']},'attributes':['id'],'include':[{'model':db[_0x3ffd59('0x49')],'as':_0x3ffd59('0x20'),'attributes':['id'],'raw':!![]}]})[_0x3ffd59('0x4b')](handleEntityNotFound(_0x5c4be5,null))['then'](function(_0x5e5cef){const _0x146154=_0x3ffd59,_0x561610=_[_0x146154('0x2c')](_0x5e5cef,'id');let _0x1ee421=[];const _0x153a3e=[],_0x4bf986=squel['select']();_0x4bf986['field'](_0x146154('0x24'))['from'](_0x146154('0x14'),'tq')[_0x146154('0x45')]('user_has_teams','ut',_0x146154('0x9'))[_0x146154('0x2a')](_0x146154('0xa'),_0x3039d3[_0x146154('0x44')]['id']);for(let _0x3262d4=0x0;_0x3262d4<_0x5e5cef[_0x146154('0x8')];_0x3262d4+=0x1){const _0x398abe=_0x5e5cef[_0x3262d4];for(let _0x5939d6=0x0;_0x5939d6<_0x398abe[_0x146154('0x20')][_0x146154('0x8')];_0x5939d6+=0x1){const _0x25e302=_0x398abe['Agents'][_0x5939d6],_0x51c41a=_0x4bf986[_0x146154('0x67')]();_0x51c41a[_0x146154('0x2a')](_0x146154('0x52'),_0x25e302['id']),_0x153a3e[_0x146154('0x26')](db['sequelize'][_0x146154('0x5a')](_0x51c41a['toString'](),{'type':QueryTypes['SELECT']})[_0x146154('0x4b')](function(_0x5dea43){const _0x38a64d=_0x146154;if(_0x5dea43['length']===0x1)return _0x25e302['id'];else{const _0xfd4532=_['every'](_[_0x38a64d('0x2c')](_0x5dea43,_0x38a64d('0x15')),function(_0x3edb12){const _0x1664da=_0x38a64d;return _[_0x1664da('0x58')](_0x561610,_0x3edb12);});if(_0xfd4532)return _0x25e302['id'];}}));}}return Promise[_0x146154('0x7')](_0x153a3e)[_0x146154('0x4b')](function(_0x1fefb8){const _0x1e92de=_0x146154;return _0x1ee421=_(_0x1ee421)['union'](_0x1fefb8)[_0x1e92de('0xd')]()[_0x1e92de('0x30')](),db[_0x1e92de('0x5e')][_0x1e92de('0xe')]({'where':{'id':_0x3039d3['params']['id']}})[_0x1e92de('0x4b')](function(_0x4aebc2){return db['sequelize']['transaction'](function(_0x2e5c7b){const _0x2267e7=a808_0x3d3c;return _0x4aebc2[_0x2267e7('0x3b')](_0x3039d3[_0x2267e7('0x5a')]['ids'],{'transaction':_0x2e5c7b})[_0x2267e7('0x4b')](function(){if(!_['isEmpty'](_0x1ee421))return _0x4aebc2['removeAgents'](_0x1ee421,{'transaction':_0x2e5c7b});})[_0x2267e7('0x4b')](function(){_0x1ee421['forEach'](function(_0x18f2fa){const _0x504448=a808_0x3d3c;socket[_0x504448('0x6c')]('userWhatsappQueue:remove',{'UserId':_0x18f2fa,'WhatsappQueueId':_0x4aebc2['id']});});});});});});})[_0x3ffd59('0x4b')](respondWithStatusCode(_0x5c4be5,null))[_0x3ffd59('0x4e')](handleError(_0x5c4be5,null));},exports['addAgents']=function(_0x462859,_0x385449){const _0x5096f3=_0x295ae9;return db[_0x5096f3('0x5e')][_0x5096f3('0xe')]({'where':{'id':_0x462859[_0x5096f3('0x44')]['id']}})[_0x5096f3('0x4b')](function(_0x35c928){const _0x12937b=_0x5096f3;if(_0x35c928)return _0x35c928[_0x12937b('0x11')](_0x462859[_0x12937b('0x17')][_0x12937b('0x63')],{'through':_[_0x12937b('0x39')](_0x462859[_0x12937b('0x17')],['ids','id'])})[_0x12937b('0x4b')](function(_0x3e4cff){const _0x5929a4=_0x12937b;for(let _0xb68099=0x0;_0xb68099<_0x462859[_0x5929a4('0x17')]['ids']['length'];_0xb68099+=0x1){socket[_0x5929a4('0x6c')](_0x5929a4('0xf'),{'UserId':_0x462859[_0x5929a4('0x17')][_0x5929a4('0x63')][_0xb68099],'WhatsappQueueId':_0x462859[_0x5929a4('0x44')]['id']});}return _0x3e4cff;});})[_0x5096f3('0x4b')](respondWithResult(_0x385449,null))[_0x5096f3('0x4e')](handleError(_0x385449,null));},exports[_0x295ae9('0x37')]=function(_0x14270a,_0x43886c){const _0x474c22=_0x295ae9;return db[_0x474c22('0x5e')]['findOne']({'where':{'id':_0x14270a[_0x474c22('0x44')]['id']}})[_0x474c22('0x4b')](handleEntityNotFound(_0x43886c,null))['then'](function(_0x3559ad){const _0x15e4e1=_0x474c22;if(_0x3559ad)return _0x3559ad['removeAgents'](_0x14270a[_0x15e4e1('0x5a')][_0x15e4e1('0x63')])[_0x15e4e1('0x4b')](function(){const _0x24f1f5=_0x15e4e1;if(_[_0x24f1f5('0x5f')](_0x14270a[_0x24f1f5('0x5a')][_0x24f1f5('0x63')]))for(let _0x491553=0x0;_0x491553<_0x14270a[_0x24f1f5('0x5a')]['ids'][_0x24f1f5('0x8')];_0x491553+=0x1){socket[_0x24f1f5('0x6c')](_0x24f1f5('0x3a'),{'UserId':Number(_0x14270a[_0x24f1f5('0x5a')][_0x24f1f5('0x63')][_0x491553]),'WhatsappQueueId':Number(_0x14270a[_0x24f1f5('0x44')]['id'])});}else socket[_0x24f1f5('0x6c')](_0x24f1f5('0x3a'),{'UserId':Number(_0x14270a['query'][_0x24f1f5('0x63')]),'WhatsappQueueId':Number(_0x14270a[_0x24f1f5('0x44')]['id'])});});})[_0x474c22('0x4b')](respondWithStatusCode(_0x43886c,null))[_0x474c22('0x4e')](handleError(_0x43886c,null));},exports[_0x295ae9('0x65')]=function(_0x4c30f3,_0x3c8545){const _0x47bf39=_0x295ae9;let _0x1f374f={};const _0x4567bc={};let _0x137d05,_0x3bb2fa;return db[_0x47bf39('0x5e')][_0x47bf39('0xe')]({'where':{'id':_0x4c30f3[_0x47bf39('0x44')]['id']}})[_0x47bf39('0x4b')](handleEntityNotFound(_0x3c8545,null))[_0x47bf39('0x4b')](function(_0x28af2f){const _0x3b7177=_0x47bf39;if(_0x28af2f)return _0x137d05=_0x28af2f,_0x4567bc[_0x3b7177('0x46')]=_[_0x3b7177('0x6')](db[_0x3b7177('0x49')][_0x3b7177('0xb')]),_0x4567bc[_0x3b7177('0x5a')]=_['keys'](_0x4c30f3['query']),_0x4567bc[_0x3b7177('0x4')]=_[_0x3b7177('0x1b')](_0x4567bc[_0x3b7177('0x46')],_0x4567bc[_0x3b7177('0x5a')]),_0x1f374f[_0x3b7177('0x0')]=_[_0x3b7177('0x1b')](_0x4567bc[_0x3b7177('0x46')],qs[_0x3b7177('0x5c')](_0x4c30f3[_0x3b7177('0x5a')][_0x3b7177('0x5c')])),_0x1f374f['attributes']=_0x1f374f[_0x3b7177('0x0')][_0x3b7177('0x8')]?_0x1f374f[_0x3b7177('0x0')]:_0x4567bc['model'],_0x1f374f[_0x3b7177('0x35')]=qs[_0x3b7177('0x43')](_0x4c30f3['query'][_0x3b7177('0x43')]),_0x1f374f[_0x3b7177('0x2a')]=qs[_0x3b7177('0x4')](_[_0x3b7177('0x68')](_0x4c30f3[_0x3b7177('0x5a')],_0x4567bc[_0x3b7177('0x4')])),_0x4c30f3[_0x3b7177('0x5a')][_0x3b7177('0x4c')]&&(_0x1f374f[_0x3b7177('0x2a')]=_[_0x3b7177('0x5')](_0x1f374f[_0x3b7177('0x2a')],{[Op['or']]:_[_0x3b7177('0x2c')](_0x1f374f['attributes'],function(_0x521ced){const _0x56ba20=_0x3b7177,_0x272571={};return _0x272571[_0x521ced]={[Op['like']]:'%'+_0x4c30f3[_0x56ba20('0x5a')][_0x56ba20('0x4c')]+'%'},_0x272571;})})),_0x1f374f=_[_0x3b7177('0x5')]({},_0x1f374f,_0x4c30f3['options']),_0x137d05[_0x3b7177('0x65')](_0x1f374f);})[_0x47bf39('0x4b')](function(_0x21b627){const _0x5b4f5b=_0x47bf39;if(_0x21b627)return _0x3bb2fa=_0x21b627[_0x5b4f5b('0x8')],typeof _0x4c30f3[_0x5b4f5b('0x5a')]['nolimit']==='undefined'&&(_0x1f374f['limit']=qs['limit'](_0x4c30f3[_0x5b4f5b('0x5a')]['limit']),_0x1f374f[_0x5b4f5b('0x33')]=qs[_0x5b4f5b('0x33')](_0x4c30f3[_0x5b4f5b('0x5a')][_0x5b4f5b('0x33')])),_0x137d05[_0x5b4f5b('0x65')](_0x1f374f);})[_0x47bf39('0x4b')](function(_0xa1a5d6){if(_0xa1a5d6)return _0xa1a5d6?{'count':_0x3bb2fa,'rows':_0xa1a5d6}:null;})[_0x47bf39('0x4b')](respondWithResult(_0x3c8545,null))[_0x47bf39('0x4e')](handleError(_0x3c8545,null));};
\ No newline at end of file