Built motion from commit b517aaa2a6638133380e4d135c64a80893061362. Version 3.0.0...
[motion-next.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 9935f88..352c9f7 100644 (file)
@@ -1 +1 @@
-const a808_0x451b=['WhatsappQueues','set','like','order','count','map','WhatsappQueue','error','ut.TeamId\x20=\x20tq.TeamId','rawAttributes','Content-Range','UserProfileSection','filters','body','sort','findAll','show','online','includeAll','Agents','offset','name','merge','user_has_teams','getAgents','status','SELECT','lodash','select','userWhatsappQueue:save','userWhatsappQueue:remove','destroy','stack','union','api','flatMap','agent','limit','updatedAt','isEmpty','ut.UserId\x20=\x20?','nolimit','filter','createdAt','catch','clone','WhatsappQueueId\x20=\x20?','undefined','Team','send','from','squel','userProfileId','VIRTUAL','describe','findOne','length','%s/%s','emit','end','Unable\x20to\x20retrieve\x20the\x20current\x20user','include','push','util','pick','options','json','key','omit','removeAgents','getMembers','fields','create','autoAssociation','query','includes','UserId','removeTeams','forEach','all','get','User','../../config/logger','update','fieldName','findAndCountAll','every','rows','format','then','UserProfileResource','role','getTeams','sendStatus','model','toString','addTeams','../../components/parsers/qs','../../rediscache','compact','keys','whatsappPause','sequelize','type','interface','register','params','join','attributes','ids','intersection','where'];(function(_0x209eaa,_0x451bf7){const _0x9e15fd=function(_0x3fc675){while(--_0x3fc675){_0x209eaa['push'](_0x209eaa['shift']());}};_0x9e15fd(++_0x451bf7);}(a808_0x451b,0x1b1));const a808_0x9e15=function(_0x209eaa,_0x451bf7){_0x209eaa=_0x209eaa-0x0;let _0x9e15fd=a808_0x451b[_0x209eaa];return _0x9e15fd;};const _0x482814=a808_0x9e15;'use strict';const util=require(_0x482814('0x4e')),_=require(_0x482814('0x2a')),squel=require(_0x482814('0x42')),qs=require(_0x482814('0x0')),logger=require(_0x482814('0x61'))(_0x482814('0x31')),{getSocket}=require(_0x482814('0x1')),socket=getSocket(),db=require('../../mysqldb')['db'],{Op}=require(_0x482814('0x5'));require('./whatsappQueue.socket')[_0x482814('0x8')](socket);function respondWithStatusCode(_0x3fc675,_0x4cee91){return _0x4cee91=_0x4cee91||0xcc,function(_0x53396f){if(_0x53396f)return _0x3fc675['sendStatus'](_0x4cee91);return _0x3fc675['status'](_0x4cee91)['end']();};}function respondWithResult(_0x433d28,_0x29cd12){return _0x29cd12=_0x29cd12||0xc8,function(_0x36c63f){const _0x3446c0=a808_0x9e15;if(_0x36c63f)return _0x433d28[_0x3446c0('0x28')](_0x29cd12)[_0x3446c0('0x51')](_0x36c63f);};}function respondWithFilteredResult(_0x1753cb,_0x5d6745){return function(_0x456218){const _0x1f865c=a808_0x9e15;if(_0x456218){const _0x31aceb=_0x456218['count'],_0x1f3873=_0x5d6745[_0x1f865c('0x23')];let _0x245456=_0x5d6745[_0x1f865c('0x23')]+_0x5d6745[_0x1f865c('0x34')],_0x395908;return _0x245456>=_0x31aceb?(_0x245456=_0x31aceb,_0x395908=0xc8):_0x395908=0xce,_0x1753cb[_0x1f865c('0x28')](_0x395908),_0x1753cb[_0x1f865c('0x10')](_0x1f865c('0x19'),_0x1f3873+'-'+_0x245456+'/'+_0x31aceb)[_0x1f865c('0x51')](_0x456218);}return null;};}function saveUpdates(_0x542e98){return function(_0x4a9735){const _0xbef805=a808_0x9e15;if(_0x4a9735)return _0x4a9735[_0xbef805('0x62')](_0x542e98)[_0xbef805('0x68')](function(_0x35c5a0){return _0x35c5a0;});return null;};}function removeEntity(_0x4e00c4){return function(_0x1226ce){const _0x122b0e=a808_0x9e15;if(_0x1226ce)return _0x1226ce[_0x122b0e('0x2e')]()[_0x122b0e('0x68')](function(){const _0x3f1078=_0x122b0e,_0x5b9fec=_0x1226ce[_0x3f1078('0x5f')]({'plain':!![]}),_0x520a7d=_0x3f1078('0xf');return db[_0x3f1078('0x69')][_0x3f1078('0x2e')]({'where':{'type':_0x520a7d,'resourceId':_0x5b9fec['id']}})[_0x3f1078('0x68')](function(){return _0x1226ce;});})[_0x122b0e('0x68')](function(){const _0x222593=_0x122b0e;_0x4e00c4[_0x222593('0x28')](0xcc)[_0x222593('0x4a')]();});};}function handleEntityNotFound(_0x338af3){return function(_0x3041d7){const _0x1d0ef8=a808_0x9e15;return!_0x3041d7&&_0x338af3[_0x1d0ef8('0x6c')](0x194),_0x3041d7;};}function handleError(_0x54e15d,_0x5db4f2){return _0x5db4f2=_0x5db4f2||0x1f4,function(_0x800946){const _0x48bfff=a808_0x9e15;logger[_0x48bfff('0x16')](_0x800946[_0x48bfff('0x2f')]),_0x800946['name']&&delete _0x800946[_0x48bfff('0x24')],_0x54e15d[_0x48bfff('0x28')](_0x5db4f2)[_0x48bfff('0x40')](_0x800946);};}exports['index']=function(_0x4525a6,_0x3b9f86){const _0x315821=_0x482814;let _0x2ad105={};const _0x2265b1={},_0x9459e7={'count':0x0,'rows':[]},_0x364ef6=_[_0x315821('0x14')](db[_0x315821('0x15')][_0x315821('0x18')],function(_0x590fd0){const _0x6cbb64=_0x315821;return{'name':_0x590fd0[_0x6cbb64('0x63')],'type':_0x590fd0['type'][_0x6cbb64('0x52')]};});_0x2265b1[_0x315821('0x6d')]=_[_0x315821('0x14')](_0x364ef6,'name'),_0x2265b1[_0x315821('0x59')]=_[_0x315821('0x3')](_0x4525a6[_0x315821('0x59')]),_0x2265b1[_0x315821('0x1b')]=_[_0x315821('0xd')](_0x2265b1['model'],_0x2265b1['query']),_0x2ad105['attributes']=_[_0x315821('0xd')](_0x2265b1['model'],qs[_0x315821('0x56')](_0x4525a6['query'][_0x315821('0x56')])),_0x2ad105[_0x315821('0xb')]=_0x2ad105[_0x315821('0xb')][_0x315821('0x47')]?_0x2ad105[_0x315821('0xb')]:_0x2265b1[_0x315821('0x6d')];typeof _0x4525a6[_0x315821('0x59')][_0x315821('0x38')]===_0x315821('0x3e')&&(_0x2ad105[_0x315821('0x34')]=qs['limit'](_0x4525a6[_0x315821('0x59')][_0x315821('0x34')]),_0x2ad105[_0x315821('0x23')]=qs['offset'](_0x4525a6[_0x315821('0x59')]['offset']));_0x2ad105[_0x315821('0x12')]=qs[_0x315821('0x1d')](_0x4525a6['query'][_0x315821('0x1d')]),_0x2ad105[_0x315821('0xe')]=qs['filters'](_[_0x315821('0x4f')](_0x4525a6[_0x315821('0x59')],_0x2265b1[_0x315821('0x1b')]),_0x364ef6);_0x4525a6[_0x315821('0x59')][_0x315821('0x39')]&&(_0x2ad105[_0x315821('0xe')]=_[_0x315821('0x25')](_0x2ad105[_0x315821('0xe')],{[Op['or']]:_[_0x315821('0x14')](_0x364ef6,function(_0x2d229b){const _0x49bb2d=_0x315821;if(_0x2d229b[_0x49bb2d('0x6')]!==_0x49bb2d('0x44')){const _0x15903a={};return _0x15903a[_0x2d229b[_0x49bb2d('0x24')]]={[Op[_0x49bb2d('0x11')]]:'%'+_0x4525a6[_0x49bb2d('0x59')][_0x49bb2d('0x39')]+'%'},_0x15903a;}})}));_0x2ad105=_[_0x315821('0x25')]({},_0x2ad105,_0x4525a6['options']);const _0x3e3655={'where':_0x2ad105['where']};return db[_0x315821('0x15')][_0x315821('0x13')](_0x3e3655)[_0x315821('0x68')](function(_0x4b2e68){const _0x4a42c7=_0x315821;return _0x9459e7[_0x4a42c7('0x13')]=_0x4b2e68,_0x4525a6[_0x4a42c7('0x59')]['includeAll']&&(_0x2ad105[_0x4a42c7('0x4c')]=[{'all':!![]}]),db[_0x4a42c7('0x15')][_0x4a42c7('0x1e')](_0x2ad105);})['then'](function(_0x4fa2a3){const _0xfc054b=_0x315821;return _0x9459e7[_0xfc054b('0x66')]=_0x4fa2a3,_0x9459e7;})['then'](respondWithFilteredResult(_0x3b9f86,_0x2ad105))[_0x315821('0x3b')](handleError(_0x3b9f86,null));},exports[_0x482814('0x1f')]=function(_0x4913bb,_0x2a63df){const _0x367897=_0x482814;let _0x1b7c50={'raw':!![],'where':{'id':_0x4913bb[_0x367897('0x9')]['id']}};const _0x820f16={};return _0x820f16[_0x367897('0x6d')]=_['keys'](db[_0x367897('0x15')][_0x367897('0x18')]),_0x820f16[_0x367897('0x59')]=_[_0x367897('0x3')](_0x4913bb[_0x367897('0x59')]),_0x820f16['filters']=_[_0x367897('0xd')](_0x820f16[_0x367897('0x6d')],_0x820f16[_0x367897('0x59')]),_0x1b7c50[_0x367897('0xb')]=_[_0x367897('0xd')](_0x820f16[_0x367897('0x6d')],qs[_0x367897('0x56')](_0x4913bb[_0x367897('0x59')]['fields'])),_0x1b7c50[_0x367897('0xb')]=_0x1b7c50[_0x367897('0xb')]['length']?_0x1b7c50[_0x367897('0xb')]:_0x820f16[_0x367897('0x6d')],_0x4913bb[_0x367897('0x59')][_0x367897('0x21')]&&(_0x1b7c50['include']=[{'all':!![]}]),_0x1b7c50=_[_0x367897('0x25')]({},_0x1b7c50,_0x4913bb[_0x367897('0x50')]),db[_0x367897('0x15')][_0x367897('0x46')](_0x1b7c50)['then'](handleEntityNotFound(_0x2a63df,null))[_0x367897('0x68')](respondWithResult(_0x2a63df,null))[_0x367897('0x3b')](handleError(_0x2a63df,null));},exports[_0x482814('0x57')]=function(_0x32b13a,_0x334c7c){const _0xd16a77=_0x482814;return db[_0xd16a77('0x15')][_0xd16a77('0x57')](_0x32b13a[_0xd16a77('0x1c')],{})[_0xd16a77('0x68')](function(_0x3eab21){const _0x56c07c=_0xd16a77,_0x2b7795=_0x32b13a['user'][_0x56c07c('0x5f')]({'plain':!![]});if(!_0x2b7795)throw new Error(_0x56c07c('0x4b'));if(_0x2b7795[_0x56c07c('0x6a')]==='user'){const _0x5d1240=_0x3eab21[_0x56c07c('0x5f')]({'plain':!![]}),_0x532620=_0x56c07c('0xf');return db[_0x56c07c('0x1a')][_0x56c07c('0x46')]({'where':{'name':_0x532620,'userProfileId':_0x2b7795[_0x56c07c('0x43')]},'raw':!![]})[_0x56c07c('0x68')](function(_0x1ab94a){const _0x4244f5=_0x56c07c;return _0x1ab94a&&_0x1ab94a[_0x4244f5('0x58')]===0x0?db[_0x4244f5('0x69')][_0x4244f5('0x57')]({'name':_0x5d1240['name'],'resourceId':_0x5d1240['id'],'type':_0x1ab94a['name'],'sectionId':_0x1ab94a['id']},{})[_0x4244f5('0x68')](function(){return _0x3eab21;}):_0x3eab21;})[_0x56c07c('0x3b')](function(_0x52c0cc){const _0x10f92f=_0x56c07c;logger[_0x10f92f('0x16')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x52c0cc);throw _0x52c0cc;});}return _0x3eab21;})[_0xd16a77('0x68')](respondWithResult(_0x334c7c,0xc9))[_0xd16a77('0x3b')](handleError(_0x334c7c,null));},exports[_0x482814('0x62')]=function(_0x59d73b,_0x2ad355){const _0x1f101b=_0x482814;return _0x59d73b[_0x1f101b('0x1c')]['id']&&delete _0x59d73b[_0x1f101b('0x1c')]['id'],db[_0x1f101b('0x15')][_0x1f101b('0x46')]({'where':{'id':_0x59d73b[_0x1f101b('0x9')]['id']}})[_0x1f101b('0x68')](handleEntityNotFound(_0x2ad355,null))[_0x1f101b('0x68')](saveUpdates(_0x59d73b[_0x1f101b('0x1c')],null))[_0x1f101b('0x68')](respondWithResult(_0x2ad355,null))['catch'](handleError(_0x2ad355,null));},exports[_0x482814('0x2e')]=function(_0xb72006,_0x2c7961){const _0x689ba4=_0x482814;return db[_0x689ba4('0x15')][_0x689ba4('0x46')]({'where':{'id':_0xb72006[_0x689ba4('0x9')]['id']}})['then'](handleEntityNotFound(_0x2c7961,null))['then'](removeEntity(_0x2c7961,null))['catch'](handleError(_0x2c7961,null));},exports[_0x482814('0x45')]=function(_0x34071d,_0x1b7022){const _0x2d17ae=_0x482814;return db[_0x2d17ae('0x15')]['describe']()[_0x2d17ae('0x68')](respondWithResult(_0x1b7022,null))['catch'](handleError(_0x1b7022,null));},exports[_0x482814('0x55')]=function(_0x53aa5d,_0xccaf8e){const _0xf14adf=_0x482814;let _0x1ac509={'raw':!![],'where':{}};const _0x3249eb={};let _0x2e3445;return db[_0xf14adf('0x15')][_0xf14adf('0x46')]({'where':{'id':_0x53aa5d[_0xf14adf('0x9')]['id']}})[_0xf14adf('0x68')](handleEntityNotFound(_0xccaf8e,null))[_0xf14adf('0x68')](function(_0xce5fa){const _0x2554f6=_0xf14adf;if(_0xce5fa)return _0x2e3445=_0xce5fa[_0x2554f6('0x5f')]({'plain':!![]}),_0x3249eb[_0x2554f6('0x6d')]=_[_0x2554f6('0x3')](db['UserWhatsappQueue'][_0x2554f6('0x18')]),_0x3249eb['query']=_[_0x2554f6('0x3')](_0x53aa5d['query']),_0x3249eb['filters']=_[_0x2554f6('0xd')](_0x3249eb[_0x2554f6('0x6d')],_0x3249eb[_0x2554f6('0x59')]),_0x1ac509[_0x2554f6('0xb')]=_[_0x2554f6('0xd')](_0x3249eb['model'],qs['fields'](_0x53aa5d[_0x2554f6('0x59')][_0x2554f6('0x56')])),_0x1ac509['attributes']=_0x1ac509[_0x2554f6('0xb')][_0x2554f6('0x47')]?_0x1ac509[_0x2554f6('0xb')]:_0x3249eb[_0x2554f6('0x6d')],typeof _0x53aa5d[_0x2554f6('0x59')][_0x2554f6('0x38')]==='undefined'&&(_0x1ac509[_0x2554f6('0x34')]=qs[_0x2554f6('0x34')](_0x53aa5d['query'][_0x2554f6('0x34')]),_0x1ac509[_0x2554f6('0x23')]=qs[_0x2554f6('0x23')](_0x53aa5d[_0x2554f6('0x59')][_0x2554f6('0x23')])),_0x1ac509[_0x2554f6('0x12')]=qs[_0x2554f6('0x1d')](_0x53aa5d[_0x2554f6('0x59')][_0x2554f6('0x1d')]),_0x1ac509[_0x2554f6('0xe')]=qs[_0x2554f6('0x1b')](_['pick'](_0x53aa5d[_0x2554f6('0x59')],_0x3249eb[_0x2554f6('0x1b')])),_0x1ac509[_0x2554f6('0xe')]['WhatsappQueueId']=_0xce5fa['id'],_0x53aa5d[_0x2554f6('0x59')][_0x2554f6('0x39')]&&(_0x1ac509[_0x2554f6('0xe')]=_['merge'](_0x1ac509['where'],{[Op['or']]:_['map'](_0x1ac509[_0x2554f6('0xb')],function(_0xa0ce5){const _0x1044ec=_0x2554f6,_0x5a8b30={};return _0x5a8b30[_0xa0ce5]={[Op[_0x1044ec('0x11')]]:'%'+_0x53aa5d[_0x1044ec('0x59')][_0x1044ec('0x39')]+'%'},_0x5a8b30;})})),_0x1ac509=_['merge']({},_0x1ac509,_0x53aa5d[_0x2554f6('0x50')]),db['UserWhatsappQueue'][_0x2554f6('0x1e')](_0x1ac509);})[_0xf14adf('0x68')](function(_0x2dd91a){const _0x4b6322=_0xf14adf;if(_0x2dd91a)return db[_0x4b6322('0x60')][_0x4b6322('0x64')]({'where':{'id':_[_0x4b6322('0x14')](_0x2dd91a,_0x4b6322('0x5b')),'role':_0x4b6322('0x33')},'attributes':['id','name','whatsappPause',_0x4b6322('0x35'),'createdAt']});})[_0xf14adf('0x68')](function(_0x3d348a){const _0x575c73=_0xf14adf;return _0x3d348a?{'count':_0x3d348a[_0x575c73('0x13')],'rows':_['map'](_0x3d348a[_0x575c73('0x66')],function(_0x53b09b){const _0x2cf53d=_0x575c73;return{'membername':_0x53b09b[_0x2cf53d('0x24')],'UserId':_0x53b09b['id'],'queue_name':_0x2e3445[_0x2cf53d('0x24')],'WhatsappQueueId':_0x2e3445['id'],'interface':util[_0x2cf53d('0x67')](_0x2cf53d('0x48'),'SIP',_0x53b09b['name']),'penalty':0x0,'paused':_0x53b09b[_0x2cf53d('0x4')],'createdAt':_0x53b09b[_0x2cf53d('0x3a')],'updatedAt':_0x53b09b[_0x2cf53d('0x35')]};})}:{'count':0x0,'rows':[]};})[_0xf14adf('0x68')](respondWithFilteredResult(_0xccaf8e,_0x1ac509))[_0xf14adf('0x3b')](handleError(_0xccaf8e,null));},exports[_0x482814('0x6b')]=function(_0x25927d,_0x50b960){const _0x2d1781=_0x482814;let _0x6f6f6d={};const _0x159de8={};let _0x38a137,_0x508abc;return db[_0x2d1781('0x15')][_0x2d1781('0x46')]({'where':{'id':_0x25927d[_0x2d1781('0x9')]['id']}})[_0x2d1781('0x68')](handleEntityNotFound(_0x50b960,null))[_0x2d1781('0x68')](function(_0x35391b){const _0x1a2fcb=_0x2d1781;if(_0x35391b)return _0x38a137=_0x35391b,_0x159de8[_0x1a2fcb('0x6d')]=_['keys'](db['Team'][_0x1a2fcb('0x18')]),_0x159de8['query']=_[_0x1a2fcb('0x3')](_0x25927d[_0x1a2fcb('0x59')]),_0x159de8[_0x1a2fcb('0x1b')]=_[_0x1a2fcb('0xd')](_0x159de8['model'],_0x159de8[_0x1a2fcb('0x59')]),_0x6f6f6d[_0x1a2fcb('0xb')]=_[_0x1a2fcb('0xd')](_0x159de8[_0x1a2fcb('0x6d')],qs[_0x1a2fcb('0x56')](_0x25927d[_0x1a2fcb('0x59')][_0x1a2fcb('0x56')])),_0x6f6f6d[_0x1a2fcb('0xb')]=_0x6f6f6d[_0x1a2fcb('0xb')]['length']?_0x6f6f6d[_0x1a2fcb('0xb')]:_0x159de8[_0x1a2fcb('0x6d')],_0x6f6f6d['order']=qs['sort'](_0x25927d['query'][_0x1a2fcb('0x1d')]),_0x6f6f6d['where']=qs[_0x1a2fcb('0x1b')](_[_0x1a2fcb('0x4f')](_0x25927d[_0x1a2fcb('0x59')],_0x159de8[_0x1a2fcb('0x1b')])),_0x25927d[_0x1a2fcb('0x59')][_0x1a2fcb('0x39')]&&(_0x6f6f6d['where']=_[_0x1a2fcb('0x25')](_0x6f6f6d[_0x1a2fcb('0xe')],{[Op['or']]:_[_0x1a2fcb('0x14')](_0x6f6f6d[_0x1a2fcb('0xb')],function(_0x3ff63a){const _0xd3bf87=_0x1a2fcb,_0x19c416={};return _0x19c416[_0x3ff63a]={[Op[_0xd3bf87('0x11')]]:'%'+_0x25927d['query'][_0xd3bf87('0x39')]+'%'},_0x19c416;})})),_0x6f6f6d=_[_0x1a2fcb('0x25')]({},_0x6f6f6d,_0x25927d[_0x1a2fcb('0x50')]),_0x38a137[_0x1a2fcb('0x6b')](_0x6f6f6d);})[_0x2d1781('0x68')](function(_0xcb26ec){const _0x40b7a4=_0x2d1781;if(_0xcb26ec)return _0x508abc=_0xcb26ec[_0x40b7a4('0x47')],typeof _0x25927d['query']['nolimit']===_0x40b7a4('0x3e')&&(_0x6f6f6d[_0x40b7a4('0x34')]=qs[_0x40b7a4('0x34')](_0x25927d['query']['limit']),_0x6f6f6d[_0x40b7a4('0x23')]=qs[_0x40b7a4('0x23')](_0x25927d['query']['offset'])),_0x38a137['getTeams'](_0x6f6f6d);})['then'](function(_0x386254){if(_0x386254)return _0x386254?{'count':_0x508abc,'rows':_0x386254}:null;})['then'](respondWithResult(_0x50b960,null))[_0x2d1781('0x3b')](handleError(_0x50b960,null));},exports[_0x482814('0x6f')]=function(_0x4f382f,_0x2d8a0e){const _0x3d507e=_0x482814,_0x11f914=_0x4f382f[_0x3d507e('0x1c')]['ids'];return db[_0x3d507e('0x3f')][_0x3d507e('0x1e')]({'where':{'id':_0x11f914},'attributes':['id'],'include':[{'model':db[_0x3d507e('0x60')],'as':_0x3d507e('0x22'),'attributes':['id',_0x3d507e('0x24'),_0x3d507e('0x20'),'voicePause',_0x3d507e('0x7')],'raw':!![]}]})[_0x3d507e('0x68')](function(_0x10edb0){const _0x540c54=_0x3d507e;if(_0x10edb0){const _0x1ee012=_[_0x540c54('0x32')](_0x10edb0,function(_0x5468a1){const _0x4cbf50=_0x540c54,_0x17215d=_0x5468a1[_0x4cbf50('0x5f')]({'plain':!![]});return _0x17215d[_0x4cbf50('0x22')];});return db[_0x540c54('0x15')][_0x540c54('0x46')]({'where':{'id':_0x4f382f[_0x540c54('0x9')]['id']}})[_0x540c54('0x68')](function(_0x4351ea){const _0x35ac22=_0x540c54;return db[_0x35ac22('0x5')]['transaction'](function(_0x5402a5){const _0x5ab1b6=_0x35ac22;return _0x4351ea['addTeams'](_0x11f914,{'transaction':_0x5402a5})[_0x5ab1b6('0x68')](function(){return Promise['each'](_0x1ee012,function(_0x5a7ac5){return db['UserWhatsappQueue']['findOrCreate']({'where':{'UserId':_0x5a7ac5['id'],'WhatsappQueueId':_0x4f382f['params']['id']},'transaction':_0x5402a5});});})[_0x5ab1b6('0x68')](function(){const _0x3eeefc=_0x5ab1b6;_0x1ee012[_0x3eeefc('0x5d')](function(_0x40bde3){const _0xdcade=_0x3eeefc;socket[_0xdcade('0x49')](_0xdcade('0x2c'),{'UserId':_0x40bde3['id'],'WhatsappQueueId':_0x4351ea['id']});});});});});}})[_0x3d507e('0x68')](respondWithStatusCode(_0x2d8a0e,null))[_0x3d507e('0x3b')](handleError(_0x2d8a0e,null));},exports[_0x482814('0x5c')]=function(_0x4519c0,_0x2e903d){const _0x4f37b3=_0x482814;return db[_0x4f37b3('0x3f')][_0x4f37b3('0x1e')]({'where':{'id':_0x4519c0[_0x4f37b3('0x59')][_0x4f37b3('0xc')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x4f37b3('0x22'),'attributes':['id'],'raw':!![]}]})[_0x4f37b3('0x68')](handleEntityNotFound(_0x2e903d,null))[_0x4f37b3('0x68')](function(_0x569820){const _0x1c4ae4=_0x4f37b3,_0xd6608b=_[_0x1c4ae4('0x14')](_0x569820,'id');let _0x1e25a0=[];const _0x51e5bf=[],_0x1b0b93=squel[_0x1c4ae4('0x2b')]();_0x1b0b93['field']('tq.TeamId')[_0x1c4ae4('0x41')]('team_has_whatsapp_queues','tq')[_0x1c4ae4('0xa')](_0x1c4ae4('0x26'),'ut',_0x1c4ae4('0x17'))[_0x1c4ae4('0xe')](_0x1c4ae4('0x3d'),_0x4519c0[_0x1c4ae4('0x9')]['id']);for(let _0x2ddaae=0x0;_0x2ddaae<_0x569820[_0x1c4ae4('0x47')];_0x2ddaae+=0x1){const _0x59c3a9=_0x569820[_0x2ddaae];for(let _0x5ccd9f=0x0;_0x5ccd9f<_0x59c3a9['Agents'][_0x1c4ae4('0x47')];_0x5ccd9f+=0x1){const _0x460f17=_0x59c3a9[_0x1c4ae4('0x22')][_0x5ccd9f],_0x539e40=_0x1b0b93[_0x1c4ae4('0x3c')]();_0x539e40['where'](_0x1c4ae4('0x37'),_0x460f17['id']),_0x51e5bf[_0x1c4ae4('0x4d')](db[_0x1c4ae4('0x5')][_0x1c4ae4('0x59')](_0x539e40[_0x1c4ae4('0x6e')](),{'type':db[_0x1c4ae4('0x5')]['QueryTypes'][_0x1c4ae4('0x29')]})['then'](function(_0x4cb92c){const _0x143db5=_0x1c4ae4;if(_0x4cb92c[_0x143db5('0x47')]===0x1)return _0x460f17['id'];else{const _0x23cd42=_[_0x143db5('0x65')](_[_0x143db5('0x14')](_0x4cb92c,'TeamId'),function(_0x36d602){const _0x453ff9=_0x143db5;return _[_0x453ff9('0x5a')](_0xd6608b,_0x36d602);});if(_0x23cd42)return _0x460f17['id'];}}));}}return Promise[_0x1c4ae4('0x5e')](_0x51e5bf)['then'](function(_0x36d6cf){const _0x2168ec=_0x1c4ae4;return _0x1e25a0=_(_0x1e25a0)[_0x2168ec('0x30')](_0x36d6cf)[_0x2168ec('0x2')]()['value'](),db[_0x2168ec('0x15')]['findOne']({'where':{'id':_0x4519c0['params']['id']}})[_0x2168ec('0x68')](function(_0xdbe36a){const _0x36f80d=_0x2168ec;return db[_0x36f80d('0x5')]['transaction'](function(_0x1f6091){const _0xf71258=_0x36f80d;return _0xdbe36a[_0xf71258('0x5c')](_0x4519c0[_0xf71258('0x59')][_0xf71258('0xc')],{'transaction':_0x1f6091})[_0xf71258('0x68')](function(){const _0x246e98=_0xf71258;if(!_[_0x246e98('0x36')](_0x1e25a0))return _0xdbe36a[_0x246e98('0x54')](_0x1e25a0,{'transaction':_0x1f6091});})[_0xf71258('0x68')](function(){const _0x18e3fd=_0xf71258;_0x1e25a0[_0x18e3fd('0x5d')](function(_0xfd7d7e){const _0x2d0cd5=_0x18e3fd;socket[_0x2d0cd5('0x49')](_0x2d0cd5('0x2d'),{'UserId':_0xfd7d7e,'WhatsappQueueId':_0xdbe36a['id']});});});});});});})['then'](respondWithStatusCode(_0x2e903d,null))['catch'](handleError(_0x2e903d,null));},exports['addAgents']=function(_0x57e0b9,_0xa5fc72){const _0x499270=_0x482814;return db['WhatsappQueue'][_0x499270('0x46')]({'where':{'id':_0x57e0b9['params']['id']}})[_0x499270('0x68')](function(_0x3bf05f){const _0x440fdd=_0x499270;if(_0x3bf05f)return _0x3bf05f['addAgents'](_0x57e0b9['body'][_0x440fdd('0xc')],{'through':_[_0x440fdd('0x53')](_0x57e0b9[_0x440fdd('0x1c')],['ids','id'])})['then'](function(_0x5b49de){const _0x24e07d=_0x440fdd;for(let _0x495517=0x0;_0x495517<_0x57e0b9[_0x24e07d('0x1c')][_0x24e07d('0xc')][_0x24e07d('0x47')];_0x495517+=0x1){socket['emit']('userWhatsappQueue:save',{'UserId':_0x57e0b9['body'][_0x24e07d('0xc')][_0x495517],'WhatsappQueueId':_0x57e0b9[_0x24e07d('0x9')]['id']});}return _0x5b49de;});})[_0x499270('0x68')](respondWithResult(_0xa5fc72,null))[_0x499270('0x3b')](handleError(_0xa5fc72,null));},exports[_0x482814('0x54')]=function(_0x45b8dd,_0x10d366){const _0xbedc53=_0x482814;return db[_0xbedc53('0x15')][_0xbedc53('0x46')]({'where':{'id':_0x45b8dd[_0xbedc53('0x9')]['id']}})['then'](handleEntityNotFound(_0x10d366,null))[_0xbedc53('0x68')](function(_0x3d3641){const _0x168ec8=_0xbedc53;if(_0x3d3641)return _0x3d3641[_0x168ec8('0x54')](_0x45b8dd['query'][_0x168ec8('0xc')])[_0x168ec8('0x68')](function(){const _0x4f744d=_0x168ec8;if(_['isArray'](_0x45b8dd[_0x4f744d('0x59')]['ids']))for(let _0x20d0df=0x0;_0x20d0df<_0x45b8dd[_0x4f744d('0x59')][_0x4f744d('0xc')][_0x4f744d('0x47')];_0x20d0df+=0x1){socket[_0x4f744d('0x49')](_0x4f744d('0x2d'),{'UserId':Number(_0x45b8dd[_0x4f744d('0x59')][_0x4f744d('0xc')][_0x20d0df]),'WhatsappQueueId':Number(_0x45b8dd[_0x4f744d('0x9')]['id'])});}else socket[_0x4f744d('0x49')]('userWhatsappQueue:remove',{'UserId':Number(_0x45b8dd[_0x4f744d('0x59')][_0x4f744d('0xc')]),'WhatsappQueueId':Number(_0x45b8dd[_0x4f744d('0x9')]['id'])});});})[_0xbedc53('0x68')](respondWithStatusCode(_0x10d366,null))[_0xbedc53('0x3b')](handleError(_0x10d366,null));},exports[_0x482814('0x27')]=function(_0x21fe79,_0x571016){const _0x3e61ca=_0x482814;let _0x1bdcd2={};const _0x17c325={};let _0x4c9300,_0x397d52;return db['WhatsappQueue'][_0x3e61ca('0x46')]({'where':{'id':_0x21fe79[_0x3e61ca('0x9')]['id']}})['then'](handleEntityNotFound(_0x571016,null))[_0x3e61ca('0x68')](function(_0x152463){const _0x434faa=_0x3e61ca;if(_0x152463)return _0x4c9300=_0x152463,_0x17c325[_0x434faa('0x6d')]=_[_0x434faa('0x3')](db['User']['rawAttributes']),_0x17c325[_0x434faa('0x59')]=_[_0x434faa('0x3')](_0x21fe79['query']),_0x17c325[_0x434faa('0x1b')]=_[_0x434faa('0xd')](_0x17c325[_0x434faa('0x6d')],_0x17c325['query']),_0x1bdcd2[_0x434faa('0xb')]=_[_0x434faa('0xd')](_0x17c325['model'],qs[_0x434faa('0x56')](_0x21fe79['query'][_0x434faa('0x56')])),_0x1bdcd2[_0x434faa('0xb')]=_0x1bdcd2[_0x434faa('0xb')]['length']?_0x1bdcd2[_0x434faa('0xb')]:_0x17c325['model'],_0x1bdcd2['order']=qs['sort'](_0x21fe79['query']['sort']),_0x1bdcd2[_0x434faa('0xe')]=qs['filters'](_['pick'](_0x21fe79[_0x434faa('0x59')],_0x17c325[_0x434faa('0x1b')])),_0x21fe79[_0x434faa('0x59')][_0x434faa('0x39')]&&(_0x1bdcd2[_0x434faa('0xe')]=_[_0x434faa('0x25')](_0x1bdcd2['where'],{[Op['or']]:_[_0x434faa('0x14')](_0x1bdcd2[_0x434faa('0xb')],function(_0x3a146c){const _0x4fc808=_0x434faa,_0x5e11d3={};return _0x5e11d3[_0x3a146c]={[Op['like']]:'%'+_0x21fe79[_0x4fc808('0x59')][_0x4fc808('0x39')]+'%'},_0x5e11d3;})})),_0x1bdcd2=_['merge']({},_0x1bdcd2,_0x21fe79[_0x434faa('0x50')]),_0x4c9300['getAgents'](_0x1bdcd2);})[_0x3e61ca('0x68')](function(_0x396294){const _0x89c9bb=_0x3e61ca;if(_0x396294)return _0x397d52=_0x396294[_0x89c9bb('0x47')],typeof _0x21fe79['query']['nolimit']==='undefined'&&(_0x1bdcd2[_0x89c9bb('0x34')]=qs[_0x89c9bb('0x34')](_0x21fe79[_0x89c9bb('0x59')]['limit']),_0x1bdcd2[_0x89c9bb('0x23')]=qs['offset'](_0x21fe79[_0x89c9bb('0x59')][_0x89c9bb('0x23')])),_0x4c9300['getAgents'](_0x1bdcd2);})[_0x3e61ca('0x68')](function(_0x3bce5c){if(_0x3bce5c)return _0x3bce5c?{'count':_0x397d52,'rows':_0x3bce5c}:null;})[_0x3e61ca('0x68')](respondWithResult(_0x571016,null))[_0x3e61ca('0x3b')](handleError(_0x571016,null));};
\ No newline at end of file
+const a808_0x3c0a=['format','rawAttributes','where','sort','api','status','json','sendStatus','count','TeamId','flatMap','User','params','whatsappPause','squel','ids','length','includeAll','limit','VIRTUAL','toString','isEmpty','util','omit','offset','filters','undefined','intersection','then','forEach','compact','QueryTypes','set','tq.TeamId','from','get','UserProfileSection','../../components/parsers/qs','role','interface','push','create','like','filter','findOne','describe','field','userWhatsappQueue:remove','fieldName','WhatsappQueues','order','join','all','name','map','register','nolimit','body','clone','sequelize','transaction','getAgents','userProfileId','Team','keys','WhatsappQueue','getTeams','WhatsappQueueId\x20=\x20?','addAgents','catch','key','error','user','userWhatsappQueue:save','send','removeTeams','pick','show','rows','removeAgents','include','fields','createdAt','findAll','query','end','SIP','model','index','update','findAndCountAll','UserProfileResource','Agents','options','autoAssociation','emit','Unable\x20to\x20retrieve\x20the\x20current\x20user','../../config/logger','attributes','updatedAt','ut.TeamId\x20=\x20tq.TeamId','destroy','team_has_whatsapp_queues','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','agent','merge','each','voicePause','UserWhatsappQueue'];(function(_0x1ba06c,_0x3c0ae8){const _0x332033=function(_0xf993b4){while(--_0xf993b4){_0x1ba06c['push'](_0x1ba06c['shift']());}};_0x332033(++_0x3c0ae8);}(a808_0x3c0a,0xe5));const a808_0x3320=function(_0x1ba06c,_0x3c0ae8){_0x1ba06c=_0x1ba06c-0x0;let _0x332033=a808_0x3c0a[_0x1ba06c];return _0x332033;};const _0x1c80a0=a808_0x3320;'use strict';const util=require(_0x1c80a0('0xb')),_=require('lodash'),squel=require(_0x1c80a0('0x3')),qs=require(_0x1c80a0('0x1a')),logger=require(_0x1c80a0('0x56'))(_0x1c80a0('0x66')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require('../../mysqldb')['db'],{Op}=require('sequelize');require('./whatsappQueue.socket')[_0x1c80a0('0x2c')](socket);function respondWithStatusCode(_0xf993b4,_0xa0dc36){return _0xa0dc36=_0xa0dc36||0xcc,function(_0xcf6569){const _0x421bfc=a808_0x3320;if(_0xcf6569)return _0xf993b4[_0x421bfc('0x69')](_0xa0dc36);return _0xf993b4[_0x421bfc('0x67')](_0xa0dc36)['end']();};}function respondWithResult(_0x14ccd0,_0xa43fbf){return _0xa43fbf=_0xa43fbf||0xc8,function(_0xc3496d){const _0x10cc6b=a808_0x3320;if(_0xc3496d)return _0x14ccd0[_0x10cc6b('0x67')](_0xa43fbf)['json'](_0xc3496d);};}function respondWithFilteredResult(_0x53a000,_0x3a2330){return function(_0x4c1d70){const _0xf4be84=a808_0x3320;if(_0x4c1d70){const _0x1bb296=_0x4c1d70['count'],_0x3bae8f=_0x3a2330[_0xf4be84('0xd')];let _0x4c52ad=_0x3a2330[_0xf4be84('0xd')]+_0x3a2330[_0xf4be84('0x7')],_0x392d01;return _0x4c52ad>=_0x1bb296?(_0x4c52ad=_0x1bb296,_0x392d01=0xc8):_0x392d01=0xce,_0x53a000[_0xf4be84('0x67')](_0x392d01),_0x53a000[_0xf4be84('0x15')]('Content-Range',_0x3bae8f+'-'+_0x4c52ad+'/'+_0x1bb296)[_0xf4be84('0x68')](_0x4c1d70);}return null;};}function saveUpdates(_0x2d817d){return function(_0x3c59bf){const _0xd18fee=a808_0x3320;if(_0x3c59bf)return _0x3c59bf[_0xd18fee('0x4e')](_0x2d817d)[_0xd18fee('0x11')](function(_0x217536){return _0x217536;});return null;};}function removeEntity(_0x2f3992){return function(_0x2706e0){const _0x5c880e=a808_0x3320;if(_0x2706e0)return _0x2706e0[_0x5c880e('0x5a')]()[_0x5c880e('0x11')](function(){const _0xf32a54=_0x5c880e,_0x32114b=_0x2706e0[_0xf32a54('0x18')]({'plain':!![]}),_0x133626='WhatsappQueues';return db['UserProfileResource'][_0xf32a54('0x5a')]({'where':{'type':_0x133626,'resourceId':_0x32114b['id']}})[_0xf32a54('0x11')](function(){return _0x2706e0;});})[_0x5c880e('0x11')](function(){const _0x198af3=_0x5c880e;_0x2f3992[_0x198af3('0x67')](0xcc)[_0x198af3('0x4a')]();});};}function handleEntityNotFound(_0x20581b){return function(_0x655bcb){return!_0x655bcb&&_0x20581b['sendStatus'](0x194),_0x655bcb;};}function handleError(_0x2e99f3,_0x42d0cb){return _0x42d0cb=_0x42d0cb||0x1f4,function(_0x2482a9){const _0x2eddcb=a808_0x3320;logger[_0x2eddcb('0x3c')](_0x2482a9['stack']),_0x2482a9[_0x2eddcb('0x2a')]&&delete _0x2482a9[_0x2eddcb('0x2a')],_0x2e99f3[_0x2eddcb('0x67')](_0x42d0cb)[_0x2eddcb('0x3f')](_0x2482a9);};}exports[_0x1c80a0('0x4d')]=function(_0x11c752,_0x403167){const _0x100af3=_0x1c80a0;let _0x51404f={};const _0x55ae3e={},_0x2cbc34={'count':0x0,'rows':[]},_0x447ea7=_['map'](db['WhatsappQueue'][_0x100af3('0x63')],function(_0x519df5){const _0x3437bf=_0x100af3;return{'name':_0x519df5[_0x3437bf('0x25')],'type':_0x519df5['type'][_0x3437bf('0x3b')]};});_0x55ae3e['model']=_[_0x100af3('0x2b')](_0x447ea7,_0x100af3('0x2a')),_0x55ae3e['query']=_[_0x100af3('0x35')](_0x11c752[_0x100af3('0x49')]),_0x55ae3e[_0x100af3('0xe')]=_[_0x100af3('0x10')](_0x55ae3e[_0x100af3('0x4c')],_0x55ae3e['query']),_0x51404f['attributes']=_[_0x100af3('0x10')](_0x55ae3e['model'],qs[_0x100af3('0x46')](_0x11c752[_0x100af3('0x49')]['fields'])),_0x51404f['attributes']=_0x51404f['attributes'][_0x100af3('0x5')]?_0x51404f[_0x100af3('0x57')]:_0x55ae3e[_0x100af3('0x4c')];typeof _0x11c752[_0x100af3('0x49')][_0x100af3('0x2d')]===_0x100af3('0xf')&&(_0x51404f[_0x100af3('0x7')]=qs[_0x100af3('0x7')](_0x11c752['query'][_0x100af3('0x7')]),_0x51404f['offset']=qs['offset'](_0x11c752['query'][_0x100af3('0xd')]));_0x51404f[_0x100af3('0x27')]=qs[_0x100af3('0x65')](_0x11c752[_0x100af3('0x49')][_0x100af3('0x65')]),_0x51404f[_0x100af3('0x64')]=qs[_0x100af3('0xe')](_[_0x100af3('0x41')](_0x11c752[_0x100af3('0x49')],_0x55ae3e[_0x100af3('0xe')]),_0x447ea7);_0x11c752['query'][_0x100af3('0x20')]&&(_0x51404f[_0x100af3('0x64')]=_[_0x100af3('0x5e')](_0x51404f[_0x100af3('0x64')],{[Op['or']]:_[_0x100af3('0x2b')](_0x447ea7,function(_0x3e2d34){const _0x271a1d=_0x100af3;if(_0x3e2d34['type']!==_0x271a1d('0x8')){const _0x59418d={};return _0x59418d[_0x3e2d34['name']]={[Op['like']]:'%'+_0x11c752['query']['filter']+'%'},_0x59418d;}})}));_0x51404f=_[_0x100af3('0x5e')]({},_0x51404f,_0x11c752[_0x100af3('0x52')]);const _0x5932cd={'where':_0x51404f[_0x100af3('0x64')]};return db[_0x100af3('0x36')][_0x100af3('0x6a')](_0x5932cd)['then'](function(_0x3b543f){const _0x49ad80=_0x100af3;return _0x2cbc34[_0x49ad80('0x6a')]=_0x3b543f,_0x11c752[_0x49ad80('0x49')][_0x49ad80('0x6')]&&(_0x51404f['include']=[{'all':!![]}]),db[_0x49ad80('0x36')][_0x49ad80('0x48')](_0x51404f);})[_0x100af3('0x11')](function(_0x3370e0){const _0xb6d9f1=_0x100af3;return _0x2cbc34[_0xb6d9f1('0x43')]=_0x3370e0,_0x2cbc34;})['then'](respondWithFilteredResult(_0x403167,_0x51404f))[_0x100af3('0x3a')](handleError(_0x403167,null));},exports[_0x1c80a0('0x42')]=function(_0x22c363,_0x154a92){const _0x99fc86=_0x1c80a0;let _0x3fc22a={'raw':!![],'where':{'id':_0x22c363[_0x99fc86('0x1')]['id']}};const _0x12ba6d={};return _0x12ba6d[_0x99fc86('0x4c')]=_[_0x99fc86('0x35')](db[_0x99fc86('0x36')][_0x99fc86('0x63')]),_0x12ba6d['query']=_[_0x99fc86('0x35')](_0x22c363['query']),_0x12ba6d[_0x99fc86('0xe')]=_[_0x99fc86('0x10')](_0x12ba6d[_0x99fc86('0x4c')],_0x12ba6d[_0x99fc86('0x49')]),_0x3fc22a[_0x99fc86('0x57')]=_[_0x99fc86('0x10')](_0x12ba6d[_0x99fc86('0x4c')],qs[_0x99fc86('0x46')](_0x22c363[_0x99fc86('0x49')][_0x99fc86('0x46')])),_0x3fc22a[_0x99fc86('0x57')]=_0x3fc22a[_0x99fc86('0x57')][_0x99fc86('0x5')]?_0x3fc22a[_0x99fc86('0x57')]:_0x12ba6d[_0x99fc86('0x4c')],_0x22c363[_0x99fc86('0x49')][_0x99fc86('0x6')]&&(_0x3fc22a[_0x99fc86('0x45')]=[{'all':!![]}]),_0x3fc22a=_[_0x99fc86('0x5e')]({},_0x3fc22a,_0x22c363[_0x99fc86('0x52')]),db[_0x99fc86('0x36')][_0x99fc86('0x21')](_0x3fc22a)['then'](handleEntityNotFound(_0x154a92,null))[_0x99fc86('0x11')](respondWithResult(_0x154a92,null))['catch'](handleError(_0x154a92,null));},exports[_0x1c80a0('0x1e')]=function(_0x180ed8,_0x57c02f){const _0xdca264=_0x1c80a0;return db['WhatsappQueue'][_0xdca264('0x1e')](_0x180ed8[_0xdca264('0x2e')],{})[_0xdca264('0x11')](function(_0x1f9408){const _0x45dd8a=_0xdca264,_0x499f44=_0x180ed8[_0x45dd8a('0x3d')]['get']({'plain':!![]});if(!_0x499f44)throw new Error(_0x45dd8a('0x55'));if(_0x499f44[_0x45dd8a('0x1b')]==='user'){const _0x3da1de=_0x1f9408['get']({'plain':!![]}),_0x1a12e4=_0x45dd8a('0x26');return db[_0x45dd8a('0x19')][_0x45dd8a('0x21')]({'where':{'name':_0x1a12e4,'userProfileId':_0x499f44[_0x45dd8a('0x33')]},'raw':!![]})[_0x45dd8a('0x11')](function(_0x1690c0){const _0x1d8e62=_0x45dd8a;return _0x1690c0&&_0x1690c0[_0x1d8e62('0x53')]===0x0?db[_0x1d8e62('0x50')][_0x1d8e62('0x1e')]({'name':_0x3da1de[_0x1d8e62('0x2a')],'resourceId':_0x3da1de['id'],'type':_0x1690c0[_0x1d8e62('0x2a')],'sectionId':_0x1690c0['id']},{})[_0x1d8e62('0x11')](function(){return _0x1f9408;}):_0x1f9408;})[_0x45dd8a('0x3a')](function(_0x53ebde){const _0x11c983=_0x45dd8a;logger['error'](_0x11c983('0x5c'),_0x53ebde);throw _0x53ebde;});}return _0x1f9408;})[_0xdca264('0x11')](respondWithResult(_0x57c02f,0xc9))[_0xdca264('0x3a')](handleError(_0x57c02f,null));},exports[_0x1c80a0('0x4e')]=function(_0x31ac0d,_0x281b2c){const _0x999187=_0x1c80a0;return _0x31ac0d['body']['id']&&delete _0x31ac0d[_0x999187('0x2e')]['id'],db['WhatsappQueue']['findOne']({'where':{'id':_0x31ac0d[_0x999187('0x1')]['id']}})[_0x999187('0x11')](handleEntityNotFound(_0x281b2c,null))[_0x999187('0x11')](saveUpdates(_0x31ac0d[_0x999187('0x2e')],null))[_0x999187('0x11')](respondWithResult(_0x281b2c,null))[_0x999187('0x3a')](handleError(_0x281b2c,null));},exports['destroy']=function(_0x109bfe,_0x3ce6ea){const _0x4679d4=_0x1c80a0;return db[_0x4679d4('0x36')][_0x4679d4('0x21')]({'where':{'id':_0x109bfe[_0x4679d4('0x1')]['id']}})[_0x4679d4('0x11')](handleEntityNotFound(_0x3ce6ea,null))['then'](removeEntity(_0x3ce6ea,null))['catch'](handleError(_0x3ce6ea,null));},exports['describe']=function(_0x23a1eb,_0x379280){const _0x4909f9=_0x1c80a0;return db['WhatsappQueue'][_0x4909f9('0x22')]()['then'](respondWithResult(_0x379280,null))[_0x4909f9('0x3a')](handleError(_0x379280,null));},exports['getMembers']=function(_0xbe2416,_0xd909a8){const _0x4719b9=_0x1c80a0;let _0x2f4d22={'raw':!![],'where':{}};const _0x2628d6={};let _0x8543ea;return db[_0x4719b9('0x36')]['findOne']({'where':{'id':_0xbe2416[_0x4719b9('0x1')]['id']}})[_0x4719b9('0x11')](handleEntityNotFound(_0xd909a8,null))[_0x4719b9('0x11')](function(_0x26f042){const _0x422a00=_0x4719b9;if(_0x26f042)return _0x8543ea=_0x26f042[_0x422a00('0x18')]({'plain':!![]}),_0x2628d6[_0x422a00('0x4c')]=_['keys'](db[_0x422a00('0x61')][_0x422a00('0x63')]),_0x2628d6[_0x422a00('0x49')]=_['keys'](_0xbe2416['query']),_0x2628d6[_0x422a00('0xe')]=_[_0x422a00('0x10')](_0x2628d6[_0x422a00('0x4c')],_0x2628d6[_0x422a00('0x49')]),_0x2f4d22[_0x422a00('0x57')]=_['intersection'](_0x2628d6[_0x422a00('0x4c')],qs[_0x422a00('0x46')](_0xbe2416[_0x422a00('0x49')][_0x422a00('0x46')])),_0x2f4d22[_0x422a00('0x57')]=_0x2f4d22['attributes'][_0x422a00('0x5')]?_0x2f4d22[_0x422a00('0x57')]:_0x2628d6[_0x422a00('0x4c')],typeof _0xbe2416[_0x422a00('0x49')][_0x422a00('0x2d')]===_0x422a00('0xf')&&(_0x2f4d22[_0x422a00('0x7')]=qs[_0x422a00('0x7')](_0xbe2416[_0x422a00('0x49')][_0x422a00('0x7')]),_0x2f4d22[_0x422a00('0xd')]=qs[_0x422a00('0xd')](_0xbe2416[_0x422a00('0x49')][_0x422a00('0xd')])),_0x2f4d22[_0x422a00('0x27')]=qs[_0x422a00('0x65')](_0xbe2416[_0x422a00('0x49')]['sort']),_0x2f4d22['where']=qs['filters'](_['pick'](_0xbe2416[_0x422a00('0x49')],_0x2628d6[_0x422a00('0xe')])),_0x2f4d22['where']['WhatsappQueueId']=_0x26f042['id'],_0xbe2416['query']['filter']&&(_0x2f4d22['where']=_[_0x422a00('0x5e')](_0x2f4d22[_0x422a00('0x64')],{[Op['or']]:_[_0x422a00('0x2b')](_0x2f4d22[_0x422a00('0x57')],function(_0x3a47dd){const _0x48385d=_0x422a00,_0x1c53b6={};return _0x1c53b6[_0x3a47dd]={[Op[_0x48385d('0x1f')]]:'%'+_0xbe2416[_0x48385d('0x49')][_0x48385d('0x20')]+'%'},_0x1c53b6;})})),_0x2f4d22=_[_0x422a00('0x5e')]({},_0x2f4d22,_0xbe2416[_0x422a00('0x52')]),db['UserWhatsappQueue'][_0x422a00('0x48')](_0x2f4d22);})[_0x4719b9('0x11')](function(_0x37db7c){const _0x4a67f7=_0x4719b9;if(_0x37db7c)return db[_0x4a67f7('0x0')][_0x4a67f7('0x4f')]({'where':{'id':_[_0x4a67f7('0x2b')](_0x37db7c,'UserId'),'role':_0x4a67f7('0x5d')},'attributes':['id',_0x4a67f7('0x2a'),_0x4a67f7('0x2'),_0x4a67f7('0x58'),_0x4a67f7('0x47')]});})[_0x4719b9('0x11')](function(_0x3b9ab3){const _0x4aa9c6=_0x4719b9;return _0x3b9ab3?{'count':_0x3b9ab3['count'],'rows':_['map'](_0x3b9ab3[_0x4aa9c6('0x43')],function(_0x4ff324){const _0xa3cfa1=_0x4aa9c6;return{'membername':_0x4ff324['name'],'UserId':_0x4ff324['id'],'queue_name':_0x8543ea['name'],'WhatsappQueueId':_0x8543ea['id'],'interface':util[_0xa3cfa1('0x62')]('%s/%s',_0xa3cfa1('0x4b'),_0x4ff324[_0xa3cfa1('0x2a')]),'penalty':0x0,'paused':_0x4ff324[_0xa3cfa1('0x2')],'createdAt':_0x4ff324[_0xa3cfa1('0x47')],'updatedAt':_0x4ff324['updatedAt']};})}:{'count':0x0,'rows':[]};})[_0x4719b9('0x11')](respondWithFilteredResult(_0xd909a8,_0x2f4d22))['catch'](handleError(_0xd909a8,null));},exports[_0x1c80a0('0x37')]=function(_0x433179,_0xa40600){const _0xa7aded=_0x1c80a0;let _0x250ebe={};const _0x1d2faf={};let _0x2e5ca2,_0xd9f4a8;return db[_0xa7aded('0x36')][_0xa7aded('0x21')]({'where':{'id':_0x433179['params']['id']}})[_0xa7aded('0x11')](handleEntityNotFound(_0xa40600,null))[_0xa7aded('0x11')](function(_0x12d3e3){const _0x583368=_0xa7aded;if(_0x12d3e3)return _0x2e5ca2=_0x12d3e3,_0x1d2faf[_0x583368('0x4c')]=_['keys'](db['Team']['rawAttributes']),_0x1d2faf[_0x583368('0x49')]=_[_0x583368('0x35')](_0x433179[_0x583368('0x49')]),_0x1d2faf['filters']=_[_0x583368('0x10')](_0x1d2faf[_0x583368('0x4c')],_0x1d2faf[_0x583368('0x49')]),_0x250ebe[_0x583368('0x57')]=_[_0x583368('0x10')](_0x1d2faf[_0x583368('0x4c')],qs['fields'](_0x433179['query'][_0x583368('0x46')])),_0x250ebe[_0x583368('0x57')]=_0x250ebe[_0x583368('0x57')][_0x583368('0x5')]?_0x250ebe[_0x583368('0x57')]:_0x1d2faf[_0x583368('0x4c')],_0x250ebe[_0x583368('0x27')]=qs['sort'](_0x433179[_0x583368('0x49')][_0x583368('0x65')]),_0x250ebe[_0x583368('0x64')]=qs['filters'](_[_0x583368('0x41')](_0x433179[_0x583368('0x49')],_0x1d2faf[_0x583368('0xe')])),_0x433179[_0x583368('0x49')][_0x583368('0x20')]&&(_0x250ebe[_0x583368('0x64')]=_[_0x583368('0x5e')](_0x250ebe[_0x583368('0x64')],{[Op['or']]:_[_0x583368('0x2b')](_0x250ebe[_0x583368('0x57')],function(_0x5ce710){const _0x1412cd=_0x583368,_0x1ea113={};return _0x1ea113[_0x5ce710]={[Op[_0x1412cd('0x1f')]]:'%'+_0x433179['query'][_0x1412cd('0x20')]+'%'},_0x1ea113;})})),_0x250ebe=_[_0x583368('0x5e')]({},_0x250ebe,_0x433179[_0x583368('0x52')]),_0x2e5ca2[_0x583368('0x37')](_0x250ebe);})[_0xa7aded('0x11')](function(_0x4fe4d2){const _0x51f15b=_0xa7aded;if(_0x4fe4d2)return _0xd9f4a8=_0x4fe4d2[_0x51f15b('0x5')],typeof _0x433179[_0x51f15b('0x49')]['nolimit']===_0x51f15b('0xf')&&(_0x250ebe[_0x51f15b('0x7')]=qs[_0x51f15b('0x7')](_0x433179['query'][_0x51f15b('0x7')]),_0x250ebe[_0x51f15b('0xd')]=qs[_0x51f15b('0xd')](_0x433179['query'][_0x51f15b('0xd')])),_0x2e5ca2[_0x51f15b('0x37')](_0x250ebe);})['then'](function(_0x106760){if(_0x106760)return _0x106760?{'count':_0xd9f4a8,'rows':_0x106760}:null;})[_0xa7aded('0x11')](respondWithResult(_0xa40600,null))[_0xa7aded('0x3a')](handleError(_0xa40600,null));},exports['addTeams']=function(_0x2ceb86,_0xe8e1ff){const _0x2fe32e=_0x1c80a0,_0x532b58=_0x2ceb86['body'][_0x2fe32e('0x4')];return db['Team'][_0x2fe32e('0x48')]({'where':{'id':_0x532b58},'attributes':['id'],'include':[{'model':db[_0x2fe32e('0x0')],'as':_0x2fe32e('0x51'),'attributes':['id',_0x2fe32e('0x2a'),'online',_0x2fe32e('0x60'),_0x2fe32e('0x1c')],'raw':!![]}]})[_0x2fe32e('0x11')](function(_0xee3aeb){const _0x1a7331=_0x2fe32e;if(_0xee3aeb){const _0x276565=_[_0x1a7331('0x6c')](_0xee3aeb,function(_0x475cd9){const _0x33a2b4=_0x1a7331,_0x38c84b=_0x475cd9[_0x33a2b4('0x18')]({'plain':!![]});return _0x38c84b[_0x33a2b4('0x51')];});return db[_0x1a7331('0x36')][_0x1a7331('0x21')]({'where':{'id':_0x2ceb86['params']['id']}})[_0x1a7331('0x11')](function(_0x321bce){const _0xd80bd7=_0x1a7331;return db[_0xd80bd7('0x30')]['transaction'](function(_0x50ae3e){const _0x489f6c=_0xd80bd7;return _0x321bce['addTeams'](_0x532b58,{'transaction':_0x50ae3e})['then'](function(){const _0x4fc849=a808_0x3320;return Promise[_0x4fc849('0x5f')](_0x276565,function(_0x55ee6a){const _0x5c2fc0=_0x4fc849;return db['UserWhatsappQueue']['findOrCreate']({'where':{'UserId':_0x55ee6a['id'],'WhatsappQueueId':_0x2ceb86[_0x5c2fc0('0x1')]['id']},'transaction':_0x50ae3e});});})[_0x489f6c('0x11')](function(){const _0x47b208=_0x489f6c;_0x276565[_0x47b208('0x12')](function(_0x1bbb41){const _0x9cf060=_0x47b208;socket[_0x9cf060('0x54')](_0x9cf060('0x3e'),{'UserId':_0x1bbb41['id'],'WhatsappQueueId':_0x321bce['id']});});});});});}})[_0x2fe32e('0x11')](respondWithStatusCode(_0xe8e1ff,null))[_0x2fe32e('0x3a')](handleError(_0xe8e1ff,null));},exports[_0x1c80a0('0x40')]=function(_0x1f067b,_0x8f310d){const _0x12804b=_0x1c80a0;return db[_0x12804b('0x34')][_0x12804b('0x48')]({'where':{'id':_0x1f067b[_0x12804b('0x49')][_0x12804b('0x4')]},'attributes':['id'],'include':[{'model':db[_0x12804b('0x0')],'as':_0x12804b('0x51'),'attributes':['id'],'raw':!![]}]})[_0x12804b('0x11')](handleEntityNotFound(_0x8f310d,null))[_0x12804b('0x11')](function(_0x4fc35e){const _0xa5d9e2=_0x12804b,_0x58d655=_['map'](_0x4fc35e,'id');let _0x5608b7=[];const _0x328971=[],_0x242302=squel['select']();_0x242302[_0xa5d9e2('0x23')](_0xa5d9e2('0x16'))[_0xa5d9e2('0x17')](_0xa5d9e2('0x5b'),'tq')[_0xa5d9e2('0x28')]('user_has_teams','ut',_0xa5d9e2('0x59'))['where'](_0xa5d9e2('0x38'),_0x1f067b[_0xa5d9e2('0x1')]['id']);for(let _0x595176=0x0;_0x595176<_0x4fc35e[_0xa5d9e2('0x5')];_0x595176+=0x1){const _0x535d96=_0x4fc35e[_0x595176];for(let _0x345b8d=0x0;_0x345b8d<_0x535d96['Agents'][_0xa5d9e2('0x5')];_0x345b8d+=0x1){const _0x67aa8a=_0x535d96[_0xa5d9e2('0x51')][_0x345b8d],_0x721345=_0x242302[_0xa5d9e2('0x2f')]();_0x721345[_0xa5d9e2('0x64')]('ut.UserId\x20=\x20?',_0x67aa8a['id']),_0x328971[_0xa5d9e2('0x1d')](db[_0xa5d9e2('0x30')]['query'](_0x721345[_0xa5d9e2('0x9')](),{'type':db['sequelize'][_0xa5d9e2('0x14')]['SELECT']})[_0xa5d9e2('0x11')](function(_0x529afd){const _0x5cfe31=_0xa5d9e2;if(_0x529afd[_0x5cfe31('0x5')]===0x1)return _0x67aa8a['id'];else{const _0x162dd0=_['every'](_['map'](_0x529afd,_0x5cfe31('0x6b')),function(_0x3d8ade){return _['includes'](_0x58d655,_0x3d8ade);});if(_0x162dd0)return _0x67aa8a['id'];}}));}}return Promise[_0xa5d9e2('0x29')](_0x328971)[_0xa5d9e2('0x11')](function(_0x2cc153){const _0x4467e1=_0xa5d9e2;return _0x5608b7=_(_0x5608b7)['union'](_0x2cc153)[_0x4467e1('0x13')]()['value'](),db[_0x4467e1('0x36')]['findOne']({'where':{'id':_0x1f067b[_0x4467e1('0x1')]['id']}})['then'](function(_0x11bfaa){const _0xd99811=_0x4467e1;return db[_0xd99811('0x30')][_0xd99811('0x31')](function(_0xb99645){const _0x3855b7=_0xd99811;return _0x11bfaa[_0x3855b7('0x40')](_0x1f067b['query'][_0x3855b7('0x4')],{'transaction':_0xb99645})[_0x3855b7('0x11')](function(){const _0x1ac2c3=_0x3855b7;if(!_[_0x1ac2c3('0xa')](_0x5608b7))return _0x11bfaa[_0x1ac2c3('0x44')](_0x5608b7,{'transaction':_0xb99645});})['then'](function(){const _0x11bc06=_0x3855b7;_0x5608b7[_0x11bc06('0x12')](function(_0x1c4a77){const _0x288f82=_0x11bc06;socket[_0x288f82('0x54')](_0x288f82('0x24'),{'UserId':_0x1c4a77,'WhatsappQueueId':_0x11bfaa['id']});});});});});});})[_0x12804b('0x11')](respondWithStatusCode(_0x8f310d,null))[_0x12804b('0x3a')](handleError(_0x8f310d,null));},exports['addAgents']=function(_0xff3189,_0x3b8885){const _0x3b6bb4=_0x1c80a0;return db[_0x3b6bb4('0x36')][_0x3b6bb4('0x21')]({'where':{'id':_0xff3189[_0x3b6bb4('0x1')]['id']}})[_0x3b6bb4('0x11')](function(_0x1a29e7){const _0x361166=_0x3b6bb4;if(_0x1a29e7)return _0x1a29e7[_0x361166('0x39')](_0xff3189[_0x361166('0x2e')][_0x361166('0x4')],{'through':_[_0x361166('0xc')](_0xff3189[_0x361166('0x2e')],[_0x361166('0x4'),'id'])})[_0x361166('0x11')](function(_0x582574){const _0x5e2023=_0x361166;for(let _0x5f20f5=0x0;_0x5f20f5<_0xff3189[_0x5e2023('0x2e')]['ids']['length'];_0x5f20f5+=0x1){socket['emit'](_0x5e2023('0x3e'),{'UserId':_0xff3189[_0x5e2023('0x2e')][_0x5e2023('0x4')][_0x5f20f5],'WhatsappQueueId':_0xff3189[_0x5e2023('0x1')]['id']});}return _0x582574;});})[_0x3b6bb4('0x11')](respondWithResult(_0x3b8885,null))[_0x3b6bb4('0x3a')](handleError(_0x3b8885,null));},exports['removeAgents']=function(_0x2bf2bf,_0x18cab6){const _0x5b72c=_0x1c80a0;return db[_0x5b72c('0x36')]['findOne']({'where':{'id':_0x2bf2bf[_0x5b72c('0x1')]['id']}})[_0x5b72c('0x11')](handleEntityNotFound(_0x18cab6,null))['then'](function(_0x2764b4){const _0x1b4ddd=_0x5b72c;if(_0x2764b4)return _0x2764b4['removeAgents'](_0x2bf2bf[_0x1b4ddd('0x49')]['ids'])['then'](function(){const _0x2007f8=_0x1b4ddd;if(_['isArray'](_0x2bf2bf[_0x2007f8('0x49')][_0x2007f8('0x4')]))for(let _0x20578c=0x0;_0x20578c<_0x2bf2bf['query'][_0x2007f8('0x4')]['length'];_0x20578c+=0x1){socket[_0x2007f8('0x54')]('userWhatsappQueue:remove',{'UserId':Number(_0x2bf2bf[_0x2007f8('0x49')][_0x2007f8('0x4')][_0x20578c]),'WhatsappQueueId':Number(_0x2bf2bf['params']['id'])});}else socket[_0x2007f8('0x54')]('userWhatsappQueue:remove',{'UserId':Number(_0x2bf2bf[_0x2007f8('0x49')][_0x2007f8('0x4')]),'WhatsappQueueId':Number(_0x2bf2bf[_0x2007f8('0x1')]['id'])});});})['then'](respondWithStatusCode(_0x18cab6,null))[_0x5b72c('0x3a')](handleError(_0x18cab6,null));},exports[_0x1c80a0('0x32')]=function(_0x31d6a5,_0x4bb8ab){const _0x3411d5=_0x1c80a0;let _0x38ab8d={};const _0x1b4df1={};let _0x39d69a,_0x2f816e;return db['WhatsappQueue']['findOne']({'where':{'id':_0x31d6a5[_0x3411d5('0x1')]['id']}})['then'](handleEntityNotFound(_0x4bb8ab,null))[_0x3411d5('0x11')](function(_0x36a1c7){const _0x936735=_0x3411d5;if(_0x36a1c7)return _0x39d69a=_0x36a1c7,_0x1b4df1[_0x936735('0x4c')]=_[_0x936735('0x35')](db[_0x936735('0x0')][_0x936735('0x63')]),_0x1b4df1[_0x936735('0x49')]=_[_0x936735('0x35')](_0x31d6a5['query']),_0x1b4df1[_0x936735('0xe')]=_[_0x936735('0x10')](_0x1b4df1['model'],_0x1b4df1[_0x936735('0x49')]),_0x38ab8d['attributes']=_[_0x936735('0x10')](_0x1b4df1[_0x936735('0x4c')],qs[_0x936735('0x46')](_0x31d6a5[_0x936735('0x49')][_0x936735('0x46')])),_0x38ab8d[_0x936735('0x57')]=_0x38ab8d['attributes'][_0x936735('0x5')]?_0x38ab8d[_0x936735('0x57')]:_0x1b4df1[_0x936735('0x4c')],_0x38ab8d[_0x936735('0x27')]=qs[_0x936735('0x65')](_0x31d6a5[_0x936735('0x49')][_0x936735('0x65')]),_0x38ab8d[_0x936735('0x64')]=qs[_0x936735('0xe')](_['pick'](_0x31d6a5[_0x936735('0x49')],_0x1b4df1['filters'])),_0x31d6a5[_0x936735('0x49')][_0x936735('0x20')]&&(_0x38ab8d[_0x936735('0x64')]=_[_0x936735('0x5e')](_0x38ab8d[_0x936735('0x64')],{[Op['or']]:_[_0x936735('0x2b')](_0x38ab8d['attributes'],function(_0x33ec2b){const _0x56e4f4=_0x936735,_0x5c09a6={};return _0x5c09a6[_0x33ec2b]={[Op[_0x56e4f4('0x1f')]]:'%'+_0x31d6a5[_0x56e4f4('0x49')][_0x56e4f4('0x20')]+'%'},_0x5c09a6;})})),_0x38ab8d=_[_0x936735('0x5e')]({},_0x38ab8d,_0x31d6a5['options']),_0x39d69a['getAgents'](_0x38ab8d);})[_0x3411d5('0x11')](function(_0x15625f){const _0x1b0a5c=_0x3411d5;if(_0x15625f)return _0x2f816e=_0x15625f['length'],typeof _0x31d6a5[_0x1b0a5c('0x49')][_0x1b0a5c('0x2d')]===_0x1b0a5c('0xf')&&(_0x38ab8d[_0x1b0a5c('0x7')]=qs[_0x1b0a5c('0x7')](_0x31d6a5[_0x1b0a5c('0x49')]['limit']),_0x38ab8d[_0x1b0a5c('0xd')]=qs[_0x1b0a5c('0xd')](_0x31d6a5[_0x1b0a5c('0x49')][_0x1b0a5c('0xd')])),_0x39d69a[_0x1b0a5c('0x32')](_0x38ab8d);})[_0x3411d5('0x11')](function(_0x6cd9d5){if(_0x6cd9d5)return _0x6cd9d5?{'count':_0x2f816e,'rows':_0x6cd9d5}:null;})['then'](respondWithResult(_0x4bb8ab,null))[_0x3411d5('0x3a')](handleError(_0x4bb8ab,null));};
\ No newline at end of file