Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 960c2c0..d6f12b5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8b3b=['SELECT','every','includes','all','union','value','isEmpty','removeAgents','userWhatsappQueue:remove','addAgents','omit','spread','isArray','getAgents','html-pdf','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./whatsappQueue.socket','register','end','status','json','count','offset','set','apply','reject','save','update','then','destroy','get','WhatsappQueues','UserProfileResource','stack','name','send','index','map','WhatsappQueue','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','pick','filter','VIRTUAL','options','includeAll','findAll','rows','show','params','include','merge','find','catch','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','limit','sort','WhatsappQueueId','UserWhatsappQueue','findAndCountAll','UserId','agent','whatsappPause','updatedAt','format','%s/%s','createdAt','getTeams','findOne','Team','addTeams','ids','User','online','voicePause','interface','flatMap','sequelize','transaction','findOrCreate','forEach','emit','userWhatsappQueue:save','removeTeams','Agents','select','field','tq.TeamId','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','QueryTypes'];(function(_0x4051e8,_0x449184){var _0x317ad6=function(_0x4ba1f7){while(--_0x4ba1f7){_0x4051e8['push'](_0x4051e8['shift']());}};_0x317ad6(++_0x449184);}(_0x8b3b,0x12e));var _0xb8b3=function(_0x578b6c,_0x2838aa){_0x578b6c=_0x578b6c-0x0;var _0x24a715=_0x8b3b[_0x578b6c];return _0x24a715;};'use strict';var pdf=require(_0xb8b3('0x0'));var emlformat=require(_0xb8b3('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xb8b3('0x2'));var jsonpatch=require(_0xb8b3('0x3'));var rp=require('request-promise');var moment=require(_0xb8b3('0x4'));var BPromise=require(_0xb8b3('0x5'));var Mustache=require(_0xb8b3('0x6'));var util=require('util');var path=require(_0xb8b3('0x7'));var sox=require('sox');var csv=require(_0xb8b3('0x8'));var ejs=require(_0xb8b3('0x9'));var fs=require('fs');var _=require(_0xb8b3('0xa'));var squel=require(_0xb8b3('0xb'));var crypto=require(_0xb8b3('0xc'));var jsforce=require(_0xb8b3('0xd'));var deskjs=require(_0xb8b3('0xe'));var toCsv=require(_0xb8b3('0x8'));var querystring=require('querystring');var Papa=require(_0xb8b3('0xf'));var Redis=require('ioredis');var authService=require(_0xb8b3('0x10'));var qs=require(_0xb8b3('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb8b3('0x12'));var logger=require(_0xb8b3('0x13'))(_0xb8b3('0x14'));var utils=require(_0xb8b3('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xb8b3('0x16'));var db=require('../../mysqldb')['db'];config[_0xb8b3('0x17')]=_[_0xb8b3('0x18')](config[_0xb8b3('0x17')],{'host':_0xb8b3('0x19'),'port':0x18eb});var socket=require(_0xb8b3('0x1a'))(new Redis(config['redis']));require(_0xb8b3('0x1b'))[_0xb8b3('0x1c')](socket);function respondWithStatusCode(_0x30d3ff,_0x2c0047){_0x2c0047=_0x2c0047||0xcc;return function(_0x5039ac){if(_0x5039ac){return _0x30d3ff['sendStatus'](_0x2c0047);}return _0x30d3ff['status'](_0x2c0047)[_0xb8b3('0x1d')]();};}function respondWithResult(_0x2a7652,_0x4dd3da){_0x4dd3da=_0x4dd3da||0xc8;return function(_0x2e5bc7){if(_0x2e5bc7){return _0x2a7652[_0xb8b3('0x1e')](_0x4dd3da)[_0xb8b3('0x1f')](_0x2e5bc7);}};}function respondWithFilteredResult(_0x4ecb15,_0x134c5f){return function(_0x40ff35){if(_0x40ff35){var _0x1d1225=_0x40ff35[_0xb8b3('0x20')],_0x1336d8=_0x134c5f['offset'],_0x37f30f=_0x134c5f[_0xb8b3('0x21')]+_0x134c5f['limit'],_0x1787d3;if(_0x37f30f>=_0x1d1225){_0x37f30f=_0x1d1225;_0x1787d3=0xc8;}else{_0x1787d3=0xce;}_0x4ecb15['status'](_0x1787d3);return _0x4ecb15[_0xb8b3('0x22')]('Content-Range',_0x1336d8+'-'+_0x37f30f+'/'+_0x1d1225)['json'](_0x40ff35);}return null;};}function patchUpdates(_0x5b177c){return function(_0xb1214){try{jsonpatch[_0xb8b3('0x23')](_0xb1214,_0x5b177c,!![]);}catch(_0x59779e){return BPromise[_0xb8b3('0x24')](_0x59779e);}return _0xb1214[_0xb8b3('0x25')]();};}function saveUpdates(_0x20e4b9,_0xdebb9){return function(_0x4557d3){if(_0x4557d3){return _0x4557d3[_0xb8b3('0x26')](_0x20e4b9)[_0xb8b3('0x27')](function(_0x324f12){return _0x324f12;});}return null;};}function removeEntity(_0x189a20,_0x1fda27){return function(_0x4c116c){if(_0x4c116c){return _0x4c116c[_0xb8b3('0x28')]()[_0xb8b3('0x27')](function(){var _0x5b47f6=_0x4c116c[_0xb8b3('0x29')]({'plain':!![]});var _0xfe4eb4=_0xb8b3('0x2a');return db[_0xb8b3('0x2b')]['destroy']({'where':{'type':_0xfe4eb4,'resourceId':_0x5b47f6['id']}})['then'](function(){return _0x4c116c;});})[_0xb8b3('0x27')](function(){_0x189a20[_0xb8b3('0x1e')](0xcc)[_0xb8b3('0x1d')]();});}};}function handleEntityNotFound(_0x5a2225,_0x2a90e8){return function(_0x31e141){if(!_0x31e141){_0x5a2225['sendStatus'](0x194);}return _0x31e141;};}function handleError(_0x1fbd43,_0x575738){_0x575738=_0x575738||0x1f4;return function(_0x5c51f1){logger['error'](_0x5c51f1[_0xb8b3('0x2c')]);if(_0x5c51f1['name']){delete _0x5c51f1[_0xb8b3('0x2d')];}_0x1fbd43[_0xb8b3('0x1e')](_0x575738)[_0xb8b3('0x2e')](_0x5c51f1);};}exports[_0xb8b3('0x2f')]=function(_0x134374,_0x5dcc93){var _0x346b08={},_0xf0e1dd={},_0x3220fb={'count':0x0,'rows':[]};var _0x4e0876=_[_0xb8b3('0x30')](db[_0xb8b3('0x31')][_0xb8b3('0x32')],function(_0x41452c){return{'name':_0x41452c['fieldName'],'type':_0x41452c[_0xb8b3('0x33')][_0xb8b3('0x34')]};});_0xf0e1dd[_0xb8b3('0x35')]=_[_0xb8b3('0x30')](_0x4e0876,_0xb8b3('0x2d'));_0xf0e1dd[_0xb8b3('0x36')]=_[_0xb8b3('0x37')](_0x134374[_0xb8b3('0x36')]);_0xf0e1dd[_0xb8b3('0x38')]=_[_0xb8b3('0x39')](_0xf0e1dd[_0xb8b3('0x35')],_0xf0e1dd[_0xb8b3('0x36')]);_0x346b08[_0xb8b3('0x3a')]=_[_0xb8b3('0x39')](_0xf0e1dd[_0xb8b3('0x35')],qs[_0xb8b3('0x3b')](_0x134374['query'][_0xb8b3('0x3b')]));_0x346b08[_0xb8b3('0x3a')]=_0x346b08['attributes'][_0xb8b3('0x3c')]?_0x346b08[_0xb8b3('0x3a')]:_0xf0e1dd[_0xb8b3('0x35')];if(!_0x134374[_0xb8b3('0x36')][_0xb8b3('0x3d')](_0xb8b3('0x3e'))){_0x346b08['limit']=qs['limit'](_0x134374[_0xb8b3('0x36')]['limit']);_0x346b08[_0xb8b3('0x21')]=qs[_0xb8b3('0x21')](_0x134374[_0xb8b3('0x36')][_0xb8b3('0x21')]);}_0x346b08[_0xb8b3('0x3f')]=qs['sort'](_0x134374[_0xb8b3('0x36')]['sort']);_0x346b08[_0xb8b3('0x40')]=qs[_0xb8b3('0x38')](_[_0xb8b3('0x41')](_0x134374[_0xb8b3('0x36')],_0xf0e1dd[_0xb8b3('0x38')]),_0x4e0876);if(_0x134374[_0xb8b3('0x36')][_0xb8b3('0x42')]){_0x346b08[_0xb8b3('0x40')]=_['merge'](_0x346b08[_0xb8b3('0x40')],{'$or':_['map'](_0x4e0876,function(_0x5d8727){if(_0x5d8727['type']!==_0xb8b3('0x43')){var _0x4d068e={};_0x4d068e[_0x5d8727['name']]={'$like':'%'+_0x134374[_0xb8b3('0x36')][_0xb8b3('0x42')]+'%'};return _0x4d068e;}})});}_0x346b08=_['merge']({},_0x346b08,_0x134374[_0xb8b3('0x44')]);var _0x386541={'where':_0x346b08['where']};return db[_0xb8b3('0x31')][_0xb8b3('0x20')](_0x386541)['then'](function(_0x317613){_0x3220fb['count']=_0x317613;if(_0x134374[_0xb8b3('0x36')][_0xb8b3('0x45')]){_0x346b08['include']=[{'all':!![]}];}return db[_0xb8b3('0x31')][_0xb8b3('0x46')](_0x346b08);})[_0xb8b3('0x27')](function(_0x391325){_0x3220fb[_0xb8b3('0x47')]=_0x391325;return _0x3220fb;})[_0xb8b3('0x27')](respondWithFilteredResult(_0x5dcc93,_0x346b08))['catch'](handleError(_0x5dcc93,null));};exports[_0xb8b3('0x48')]=function(_0x507d15,_0x22e7b2){var _0x2d51bd={'raw':!![],'where':{'id':_0x507d15[_0xb8b3('0x49')]['id']}},_0x94998a={};_0x94998a[_0xb8b3('0x35')]=_[_0xb8b3('0x37')](db[_0xb8b3('0x31')]['rawAttributes']);_0x94998a['query']=_[_0xb8b3('0x37')](_0x507d15[_0xb8b3('0x36')]);_0x94998a['filters']=_[_0xb8b3('0x39')](_0x94998a[_0xb8b3('0x35')],_0x94998a[_0xb8b3('0x36')]);_0x2d51bd[_0xb8b3('0x3a')]=_[_0xb8b3('0x39')](_0x94998a[_0xb8b3('0x35')],qs['fields'](_0x507d15[_0xb8b3('0x36')]['fields']));_0x2d51bd[_0xb8b3('0x3a')]=_0x2d51bd[_0xb8b3('0x3a')][_0xb8b3('0x3c')]?_0x2d51bd[_0xb8b3('0x3a')]:_0x94998a[_0xb8b3('0x35')];if(_0x507d15[_0xb8b3('0x36')][_0xb8b3('0x45')]){_0x2d51bd[_0xb8b3('0x4a')]=[{'all':!![]}];}_0x2d51bd=_[_0xb8b3('0x4b')]({},_0x2d51bd,_0x507d15[_0xb8b3('0x44')]);return db['WhatsappQueue'][_0xb8b3('0x4c')](_0x2d51bd)[_0xb8b3('0x27')](handleEntityNotFound(_0x22e7b2,null))[_0xb8b3('0x27')](respondWithResult(_0x22e7b2,null))[_0xb8b3('0x4d')](handleError(_0x22e7b2,null));};exports[_0xb8b3('0x4e')]=function(_0x46b8a3,_0x11d4c3){return db[_0xb8b3('0x31')][_0xb8b3('0x4e')](_0x46b8a3[_0xb8b3('0x4f')],{})[_0xb8b3('0x27')](function(_0x147779){var _0x41a5a1=_0x46b8a3[_0xb8b3('0x50')][_0xb8b3('0x29')]({'plain':!![]});if(!_0x41a5a1)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x41a5a1[_0xb8b3('0x51')]===_0xb8b3('0x50')){var _0x7c0817=_0x147779['get']({'plain':!![]});var _0x17d911=_0xb8b3('0x2a');return db[_0xb8b3('0x52')][_0xb8b3('0x4c')]({'where':{'name':_0x17d911,'userProfileId':_0x41a5a1[_0xb8b3('0x53')]},'raw':!![]})[_0xb8b3('0x27')](function(_0x43f264){if(_0x43f264&&_0x43f264[_0xb8b3('0x54')]===0x0){return db[_0xb8b3('0x2b')][_0xb8b3('0x4e')]({'name':_0x7c0817[_0xb8b3('0x2d')],'resourceId':_0x7c0817['id'],'type':_0x43f264[_0xb8b3('0x2d')],'sectionId':_0x43f264['id']},{})[_0xb8b3('0x27')](function(){return _0x147779;});}else{return _0x147779;}})[_0xb8b3('0x4d')](function(_0x59c0ab){logger[_0xb8b3('0x55')](_0xb8b3('0x56'),_0x59c0ab);throw _0x59c0ab;});}return _0x147779;})[_0xb8b3('0x27')](respondWithResult(_0x11d4c3,0xc9))[_0xb8b3('0x4d')](handleError(_0x11d4c3,null));};exports[_0xb8b3('0x26')]=function(_0x326501,_0xc72a60){if(_0x326501[_0xb8b3('0x4f')]['id']){delete _0x326501[_0xb8b3('0x4f')]['id'];}return db[_0xb8b3('0x31')][_0xb8b3('0x4c')]({'where':{'id':_0x326501[_0xb8b3('0x49')]['id']}})[_0xb8b3('0x27')](handleEntityNotFound(_0xc72a60,null))[_0xb8b3('0x27')](saveUpdates(_0x326501[_0xb8b3('0x4f')],null))[_0xb8b3('0x27')](respondWithResult(_0xc72a60,null))[_0xb8b3('0x4d')](handleError(_0xc72a60,null));};exports[_0xb8b3('0x28')]=function(_0x200974,_0x517252){return db[_0xb8b3('0x31')][_0xb8b3('0x4c')]({'where':{'id':_0x200974[_0xb8b3('0x49')]['id']}})[_0xb8b3('0x27')](handleEntityNotFound(_0x517252,null))[_0xb8b3('0x27')](removeEntity(_0x517252,null))[_0xb8b3('0x4d')](handleError(_0x517252,null));};exports[_0xb8b3('0x57')]=function(_0x423160,_0x2c26bf){return db[_0xb8b3('0x31')][_0xb8b3('0x57')]()['then'](respondWithResult(_0x2c26bf,null))[_0xb8b3('0x4d')](handleError(_0x2c26bf,null));};exports[_0xb8b3('0x58')]=function(_0x2fb08e,_0x3191ef,_0x3a0339){var _0x235978={'raw':!![],'where':{}},_0x27640d={},_0xb6da9c;return db[_0xb8b3('0x31')]['findOne']({'where':{'id':_0x2fb08e[_0xb8b3('0x49')]['id']}})[_0xb8b3('0x27')](handleEntityNotFound(_0x3191ef,null))[_0xb8b3('0x27')](function(_0x287e8f){if(_0x287e8f){_0xb6da9c=_0x287e8f[_0xb8b3('0x29')]({'plain':!![]});_0x27640d['model']=_['keys'](db['UserWhatsappQueue']['rawAttributes']);_0x27640d[_0xb8b3('0x36')]=_[_0xb8b3('0x37')](_0x2fb08e[_0xb8b3('0x36')]);_0x27640d[_0xb8b3('0x38')]=_['intersection'](_0x27640d[_0xb8b3('0x35')],_0x27640d[_0xb8b3('0x36')]);_0x235978[_0xb8b3('0x3a')]=_[_0xb8b3('0x39')](_0x27640d[_0xb8b3('0x35')],qs[_0xb8b3('0x3b')](_0x2fb08e['query'][_0xb8b3('0x3b')]));_0x235978[_0xb8b3('0x3a')]=_0x235978[_0xb8b3('0x3a')][_0xb8b3('0x3c')]?_0x235978[_0xb8b3('0x3a')]:_0x27640d['model'];if(!_0x2fb08e[_0xb8b3('0x36')][_0xb8b3('0x3d')](_0xb8b3('0x3e'))){_0x235978['limit']=qs[_0xb8b3('0x59')](_0x2fb08e[_0xb8b3('0x36')]['limit']);_0x235978[_0xb8b3('0x21')]=qs['offset'](_0x2fb08e['query'][_0xb8b3('0x21')]);}_0x235978[_0xb8b3('0x3f')]=qs[_0xb8b3('0x5a')](_0x2fb08e[_0xb8b3('0x36')][_0xb8b3('0x5a')]);_0x235978[_0xb8b3('0x40')]=qs[_0xb8b3('0x38')](_[_0xb8b3('0x41')](_0x2fb08e[_0xb8b3('0x36')],_0x27640d['filters']));_0x235978[_0xb8b3('0x40')][_0xb8b3('0x5b')]=_0x287e8f['id'];if(_0x2fb08e[_0xb8b3('0x36')][_0xb8b3('0x42')]){_0x235978[_0xb8b3('0x40')]=_[_0xb8b3('0x4b')](_0x235978['where'],{'$or':_[_0xb8b3('0x30')](_0x235978[_0xb8b3('0x3a')],function(_0x1a93f5){var _0x120017={};_0x120017[_0x1a93f5]={'$like':'%'+_0x2fb08e[_0xb8b3('0x36')][_0xb8b3('0x42')]+'%'};return _0x120017;})});}_0x235978=_[_0xb8b3('0x4b')]({},_0x235978,_0x2fb08e['options']);return db[_0xb8b3('0x5c')]['findAll'](_0x235978);}})[_0xb8b3('0x27')](function(_0x45ff7a){if(_0x45ff7a){return db['User'][_0xb8b3('0x5d')]({'where':{'id':_[_0xb8b3('0x30')](_0x45ff7a,_0xb8b3('0x5e')),'role':_0xb8b3('0x5f')},'attributes':['id',_0xb8b3('0x2d'),_0xb8b3('0x60'),_0xb8b3('0x61'),'createdAt']});}})[_0xb8b3('0x27')](function(_0x286ce5){if(_0x286ce5){return{'count':_0x286ce5['count'],'rows':_['map'](_0x286ce5[_0xb8b3('0x47')],function(_0x3655ef){return{'membername':_0x3655ef['name'],'UserId':_0x3655ef['id'],'queue_name':_0xb6da9c[_0xb8b3('0x2d')],'WhatsappQueueId':_0xb6da9c['id'],'interface':util[_0xb8b3('0x62')](_0xb8b3('0x63'),'SIP',_0x3655ef[_0xb8b3('0x2d')]),'penalty':0x0,'paused':_0x3655ef[_0xb8b3('0x60')],'createdAt':_0x3655ef[_0xb8b3('0x64')],'updatedAt':_0x3655ef[_0xb8b3('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x3191ef,_0x235978))[_0xb8b3('0x4d')](handleError(_0x3191ef,null));};exports[_0xb8b3('0x65')]=function(_0x1c853f,_0x27f6fb,_0x1c1e53){var _0x4245b0={};var _0x40a9ee={};var _0x57c6e3;var _0x3c661c;return db[_0xb8b3('0x31')][_0xb8b3('0x66')]({'where':{'id':_0x1c853f[_0xb8b3('0x49')]['id']}})[_0xb8b3('0x27')](handleEntityNotFound(_0x27f6fb,null))[_0xb8b3('0x27')](function(_0x491424){if(_0x491424){_0x57c6e3=_0x491424;_0x40a9ee['model']=_[_0xb8b3('0x37')](db[_0xb8b3('0x67')]['rawAttributes']);_0x40a9ee[_0xb8b3('0x36')]=_[_0xb8b3('0x37')](_0x1c853f[_0xb8b3('0x36')]);_0x40a9ee[_0xb8b3('0x38')]=_['intersection'](_0x40a9ee[_0xb8b3('0x35')],_0x40a9ee[_0xb8b3('0x36')]);_0x4245b0[_0xb8b3('0x3a')]=_[_0xb8b3('0x39')](_0x40a9ee[_0xb8b3('0x35')],qs[_0xb8b3('0x3b')](_0x1c853f[_0xb8b3('0x36')][_0xb8b3('0x3b')]));_0x4245b0[_0xb8b3('0x3a')]=_0x4245b0[_0xb8b3('0x3a')]['length']?_0x4245b0[_0xb8b3('0x3a')]:_0x40a9ee[_0xb8b3('0x35')];_0x4245b0[_0xb8b3('0x3f')]=qs[_0xb8b3('0x5a')](_0x1c853f[_0xb8b3('0x36')][_0xb8b3('0x5a')]);_0x4245b0[_0xb8b3('0x40')]=qs['filters'](_[_0xb8b3('0x41')](_0x1c853f[_0xb8b3('0x36')],_0x40a9ee['filters']));if(_0x1c853f[_0xb8b3('0x36')][_0xb8b3('0x42')]){_0x4245b0[_0xb8b3('0x40')]=_[_0xb8b3('0x4b')](_0x4245b0[_0xb8b3('0x40')],{'$or':_[_0xb8b3('0x30')](_0x4245b0[_0xb8b3('0x3a')],function(_0x41d278){var _0x137900={};_0x137900[_0x41d278]={'$like':'%'+_0x1c853f['query']['filter']+'%'};return _0x137900;})});}_0x4245b0=_['merge']({},_0x4245b0,_0x1c853f[_0xb8b3('0x44')]);return _0x57c6e3[_0xb8b3('0x65')](_0x4245b0);}})[_0xb8b3('0x27')](function(_0xb263b2){if(_0xb263b2){_0x3c661c=_0xb263b2['length'];if(!_0x1c853f[_0xb8b3('0x36')][_0xb8b3('0x3d')]('nolimit')){_0x4245b0[_0xb8b3('0x59')]=qs['limit'](_0x1c853f['query'][_0xb8b3('0x59')]);_0x4245b0[_0xb8b3('0x21')]=qs['offset'](_0x1c853f['query'][_0xb8b3('0x21')]);}return _0x57c6e3[_0xb8b3('0x65')](_0x4245b0);}})['then'](function(_0x3107f3){if(_0x3107f3){return _0x3107f3?{'count':_0x3c661c,'rows':_0x3107f3}:null;}})[_0xb8b3('0x27')](respondWithResult(_0x27f6fb,null))['catch'](handleError(_0x27f6fb,null));};exports[_0xb8b3('0x68')]=function(_0x3a4e3b,_0x1fe514,_0x438c41){var _0x4465e1=_0x3a4e3b['body'][_0xb8b3('0x69')];return db[_0xb8b3('0x67')][_0xb8b3('0x46')]({'where':{'id':_0x4465e1},'attributes':['id'],'include':[{'model':db[_0xb8b3('0x6a')],'as':'Agents','attributes':['id',_0xb8b3('0x2d'),_0xb8b3('0x6b'),_0xb8b3('0x6c'),_0xb8b3('0x6d')],'raw':!![]}]})[_0xb8b3('0x27')](function(_0xada0ad){if(_0xada0ad){var _0x1d6841=_[_0xb8b3('0x6e')](_0xada0ad,function(_0x57757a){var _0x54818b=_0x57757a[_0xb8b3('0x29')]({'plain':!![]});return _0x54818b['Agents'];});return db[_0xb8b3('0x31')][_0xb8b3('0x4c')]({'where':{'id':_0x3a4e3b['params']['id']}})[_0xb8b3('0x27')](function(_0x127296){return db[_0xb8b3('0x6f')][_0xb8b3('0x70')](function(_0x6eca71){return _0x127296[_0xb8b3('0x68')](_0x4465e1,{'transaction':_0x6eca71})[_0xb8b3('0x27')](function(){return BPromise['each'](_0x1d6841,function(_0x10fb53){return db[_0xb8b3('0x5c')][_0xb8b3('0x71')]({'where':{'UserId':_0x10fb53['id'],'WhatsappQueueId':_0x3a4e3b[_0xb8b3('0x49')]['id']},'transaction':_0x6eca71});});})['then'](function(){_0x1d6841[_0xb8b3('0x72')](function(_0x5c00c6){socket[_0xb8b3('0x73')](_0xb8b3('0x74'),{'UserId':_0x5c00c6['id'],'WhatsappQueueId':_0x127296['id']});});});});});}})[_0xb8b3('0x27')](respondWithStatusCode(_0x1fe514,null))[_0xb8b3('0x4d')](handleError(_0x1fe514,null));};exports[_0xb8b3('0x75')]=function(_0xc7bfdb,_0x2e327b,_0x5795f5){return db[_0xb8b3('0x67')][_0xb8b3('0x46')]({'where':{'id':_0xc7bfdb[_0xb8b3('0x36')][_0xb8b3('0x69')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0xb8b3('0x76'),'attributes':['id'],'raw':!![]}]})[_0xb8b3('0x27')](handleEntityNotFound(_0x2e327b,null))[_0xb8b3('0x27')](function(_0x3674cb){var _0x3e3091=_['map'](_0x3674cb,'id');var _0x5a8293=[];var _0x2c3e04=[];var _0x25ef31=squel[_0xb8b3('0x77')]();_0x25ef31[_0xb8b3('0x78')](_0xb8b3('0x79'))['from']('team_has_whatsapp_queues','tq')[_0xb8b3('0x7a')](_0xb8b3('0x7b'),'ut',_0xb8b3('0x7c'))[_0xb8b3('0x40')](_0xb8b3('0x7d'),_0xc7bfdb['params']['id']);for(var _0x13a2fe=0x0;_0x13a2fe<_0x3674cb[_0xb8b3('0x3c')];_0x13a2fe+=0x1){let _0x5b61df=_0x3674cb[_0x13a2fe];for(var _0xab48c9=0x0;_0xab48c9<_0x5b61df[_0xb8b3('0x76')][_0xb8b3('0x3c')];_0xab48c9+=0x1){let _0xa623c8=_0x5b61df[_0xb8b3('0x76')][_0xab48c9];var _0x349992=_0x25ef31['clone']();_0x349992['where'](_0xb8b3('0x7e'),_0xa623c8['id']);_0x2c3e04[_0xb8b3('0x7f')](db['sequelize'][_0xb8b3('0x36')](_0x349992[_0xb8b3('0x80')](),{'type':db[_0xb8b3('0x6f')][_0xb8b3('0x81')][_0xb8b3('0x82')]})[_0xb8b3('0x27')](function(_0x3f1d52){if(_0x3f1d52['length']===0x1){return _0xa623c8['id'];}else{var _0x5ba9a2=_[_0xb8b3('0x83')](_[_0xb8b3('0x30')](_0x3f1d52,'TeamId'),function(_0x3abcdf){return _[_0xb8b3('0x84')](_0x3e3091,_0x3abcdf);});if(_0x5ba9a2){return _0xa623c8['id'];}}}));}}return BPromise[_0xb8b3('0x85')](_0x2c3e04)[_0xb8b3('0x27')](function(_0x4bbcd5){_0x5a8293=_(_0x5a8293)[_0xb8b3('0x86')](_0x4bbcd5)['compact']()[_0xb8b3('0x87')]();return db[_0xb8b3('0x31')][_0xb8b3('0x4c')]({'where':{'id':_0xc7bfdb[_0xb8b3('0x49')]['id']}})[_0xb8b3('0x27')](function(_0x5d1642){return db[_0xb8b3('0x6f')][_0xb8b3('0x70')](function(_0x2cff38){return _0x5d1642[_0xb8b3('0x75')](_0xc7bfdb[_0xb8b3('0x36')][_0xb8b3('0x69')],{'transaction':_0x2cff38})[_0xb8b3('0x27')](function(){if(!_[_0xb8b3('0x88')](_0x5a8293)){return _0x5d1642[_0xb8b3('0x89')](_0x5a8293,{'transaction':_0x2cff38});}})[_0xb8b3('0x27')](function(){_0x5a8293[_0xb8b3('0x72')](function(_0x5750e8){socket[_0xb8b3('0x73')](_0xb8b3('0x8a'),{'UserId':_0x5750e8,'WhatsappQueueId':_0x5d1642['id']});});});});});});})[_0xb8b3('0x27')](respondWithStatusCode(_0x2e327b,null))[_0xb8b3('0x4d')](handleError(_0x2e327b,null));};exports['addAgents']=function(_0x493142,_0x2639cb,_0x567843){return db[_0xb8b3('0x31')][_0xb8b3('0x4c')]({'where':{'id':_0x493142[_0xb8b3('0x49')]['id']}})[_0xb8b3('0x27')](handleEntityNotFound(_0x2639cb,null))[_0xb8b3('0x27')](function(_0x2aace3){if(_0x2aace3){return _0x2aace3[_0xb8b3('0x8b')](_0x493142[_0xb8b3('0x4f')]['ids'],_[_0xb8b3('0x8c')](_0x493142[_0xb8b3('0x4f')],['ids','id'])||{})[_0xb8b3('0x8d')](function(_0x3460e0){for(var _0x4f60c3=0x0;_0x4f60c3<_0x493142[_0xb8b3('0x4f')]['ids'][_0xb8b3('0x3c')];_0x4f60c3+=0x1){socket[_0xb8b3('0x73')](_0xb8b3('0x74'),{'UserId':_0x493142[_0xb8b3('0x4f')][_0xb8b3('0x69')][_0x4f60c3],'WhatsappQueueId':_0x493142['params']['id']});}return _0x3460e0;});}})['then'](respondWithResult(_0x2639cb,null))[_0xb8b3('0x4d')](handleError(_0x2639cb,null));};exports[_0xb8b3('0x89')]=function(_0x162aac,_0x596e6d,_0x283da3){return db['WhatsappQueue'][_0xb8b3('0x4c')]({'where':{'id':_0x162aac[_0xb8b3('0x49')]['id']}})[_0xb8b3('0x27')](handleEntityNotFound(_0x596e6d,null))['then'](function(_0x2c5f74){if(_0x2c5f74){return _0x2c5f74['removeAgents'](_0x162aac[_0xb8b3('0x36')][_0xb8b3('0x69')])[_0xb8b3('0x27')](function(){if(_[_0xb8b3('0x8e')](_0x162aac[_0xb8b3('0x36')][_0xb8b3('0x69')])){for(var _0xcd9066=0x0;_0xcd9066<_0x162aac[_0xb8b3('0x36')]['ids'][_0xb8b3('0x3c')];_0xcd9066+=0x1){socket[_0xb8b3('0x73')](_0xb8b3('0x8a'),{'UserId':Number(_0x162aac[_0xb8b3('0x36')][_0xb8b3('0x69')][_0xcd9066]),'WhatsappQueueId':Number(_0x162aac[_0xb8b3('0x49')]['id'])});}}else{socket[_0xb8b3('0x73')](_0xb8b3('0x8a'),{'UserId':Number(_0x162aac['query'][_0xb8b3('0x69')]),'WhatsappQueueId':Number(_0x162aac[_0xb8b3('0x49')]['id'])});}});}})['then'](respondWithStatusCode(_0x596e6d,null))[_0xb8b3('0x4d')](handleError(_0x596e6d,null));};exports[_0xb8b3('0x8f')]=function(_0xdb89d9,_0x20bf09,_0x128191){var _0x5715ea={};var _0x40aa78={};var _0xc17c42;var _0x553108;return db[_0xb8b3('0x31')][_0xb8b3('0x66')]({'where':{'id':_0xdb89d9[_0xb8b3('0x49')]['id']}})[_0xb8b3('0x27')](handleEntityNotFound(_0x20bf09,null))['then'](function(_0x16a1da){if(_0x16a1da){_0xc17c42=_0x16a1da;_0x40aa78['model']=_[_0xb8b3('0x37')](db[_0xb8b3('0x6a')][_0xb8b3('0x32')]);_0x40aa78[_0xb8b3('0x36')]=_['keys'](_0xdb89d9[_0xb8b3('0x36')]);_0x40aa78[_0xb8b3('0x38')]=_[_0xb8b3('0x39')](_0x40aa78[_0xb8b3('0x35')],_0x40aa78['query']);_0x5715ea[_0xb8b3('0x3a')]=_['intersection'](_0x40aa78[_0xb8b3('0x35')],qs['fields'](_0xdb89d9[_0xb8b3('0x36')][_0xb8b3('0x3b')]));_0x5715ea[_0xb8b3('0x3a')]=_0x5715ea[_0xb8b3('0x3a')][_0xb8b3('0x3c')]?_0x5715ea['attributes']:_0x40aa78[_0xb8b3('0x35')];_0x5715ea[_0xb8b3('0x3f')]=qs[_0xb8b3('0x5a')](_0xdb89d9[_0xb8b3('0x36')][_0xb8b3('0x5a')]);_0x5715ea[_0xb8b3('0x40')]=qs[_0xb8b3('0x38')](_['pick'](_0xdb89d9[_0xb8b3('0x36')],_0x40aa78[_0xb8b3('0x38')]));if(_0xdb89d9[_0xb8b3('0x36')][_0xb8b3('0x42')]){_0x5715ea[_0xb8b3('0x40')]=_['merge'](_0x5715ea[_0xb8b3('0x40')],{'$or':_['map'](_0x5715ea[_0xb8b3('0x3a')],function(_0x4ad5c3){var _0x223390={};_0x223390[_0x4ad5c3]={'$like':'%'+_0xdb89d9[_0xb8b3('0x36')][_0xb8b3('0x42')]+'%'};return _0x223390;})});}_0x5715ea=_[_0xb8b3('0x4b')]({},_0x5715ea,_0xdb89d9['options']);return _0xc17c42[_0xb8b3('0x8f')](_0x5715ea);}})[_0xb8b3('0x27')](function(_0x1ec7d3){if(_0x1ec7d3){_0x553108=_0x1ec7d3[_0xb8b3('0x3c')];if(!_0xdb89d9['query']['hasOwnProperty']('nolimit')){_0x5715ea['limit']=qs['limit'](_0xdb89d9[_0xb8b3('0x36')][_0xb8b3('0x59')]);_0x5715ea[_0xb8b3('0x21')]=qs['offset'](_0xdb89d9['query'][_0xb8b3('0x21')]);}return _0xc17c42['getAgents'](_0x5715ea);}})[_0xb8b3('0x27')](function(_0x1ea7cb){if(_0x1ea7cb){return _0x1ea7cb?{'count':_0x553108,'rows':_0x1ea7cb}:null;}})[_0xb8b3('0x27')](respondWithResult(_0x20bf09,null))['catch'](handleError(_0x20bf09,null));};
\ No newline at end of file
+var _0xf1c9=['show','params','model','keys','filters','intersection','attributes','fields','length','includeAll','merge','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','describe','getMembers','findOne','hasOwnProperty','order','sort','WhatsappQueueId','filter','UserWhatsappQueue','findAll','findAndCountAll','UserId','agent','whatsappPause','updatedAt','format','SIP','createdAt','Team','pick','options','getTeams','nolimit','addTeams','User','Agents','online','voicePause','flatMap','sequelize','each','forEach','emit','removeTeams','ids','select','tq.TeamId','from','team_has_whatsapp_queues','join','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','transaction','isEmpty','removeAgents','userWhatsappQueue:remove','addAgents','omit','spread','userWhatsappQueue:save','isArray','bluebird','util','lodash','squel','ioredis','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./whatsappQueue.socket','register','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','update','then','get','WhatsappQueues','UserProfileResource','destroy','error','stack','name','send','index','map','WhatsappQueue','rawAttributes','fieldName','type','key','where','include','query','rows','catch'];(function(_0x3db453,_0x18a04f){var _0x25e68e=function(_0x559f48){while(--_0x559f48){_0x3db453['push'](_0x3db453['shift']());}};_0x25e68e(++_0x18a04f);}(_0xf1c9,0x1c9));var _0x9f1c=function(_0x44ec36,_0x296ad2){_0x44ec36=_0x44ec36-0x0;var _0x22976e=_0xf1c9[_0x44ec36];return _0x22976e;};'use strict';var BPromise=require(_0x9f1c('0x0'));var util=require(_0x9f1c('0x1'));var _=require(_0x9f1c('0x2'));var squel=require(_0x9f1c('0x3'));var Redis=require(_0x9f1c('0x4'));var qs=require('../../components/parsers/qs');var logger=require(_0x9f1c('0x5'))(_0x9f1c('0x6'));var config=require(_0x9f1c('0x7'));var db=require(_0x9f1c('0x8'))['db'];config[_0x9f1c('0x9')]=_[_0x9f1c('0xa')](config[_0x9f1c('0x9')],{'host':_0x9f1c('0xb'),'port':0x18eb});var socket=require(_0x9f1c('0xc'))(new Redis(config[_0x9f1c('0x9')]));require(_0x9f1c('0xd'))[_0x9f1c('0xe')](socket);function respondWithStatusCode(_0x388848,_0x155a00){_0x155a00=_0x155a00||0xcc;return function(_0x3af1b1){if(_0x3af1b1){return _0x388848[_0x9f1c('0xf')](_0x155a00);}return _0x388848[_0x9f1c('0x10')](_0x155a00)[_0x9f1c('0x11')]();};}function respondWithResult(_0xf9dc3d,_0x4f24fc){_0x4f24fc=_0x4f24fc||0xc8;return function(_0x126a43){if(_0x126a43){return _0xf9dc3d[_0x9f1c('0x10')](_0x4f24fc)[_0x9f1c('0x12')](_0x126a43);}};}function respondWithFilteredResult(_0x2daf78,_0x2a9669){return function(_0x2a3ad0){if(_0x2a3ad0){var _0x5653a1=typeof _0x2a9669[_0x9f1c('0x13')]===_0x9f1c('0x14')&&typeof _0x2a9669['limit']===_0x9f1c('0x14');var _0x47aab9=_0x2a3ad0[_0x9f1c('0x15')];var _0x556662=_0x5653a1?0x0:_0x2a9669['offset'];var _0x17357b=_0x5653a1?_0x2a3ad0[_0x9f1c('0x15')]:_0x2a9669[_0x9f1c('0x13')]+_0x2a9669[_0x9f1c('0x16')];var _0x618160;if(_0x17357b>=_0x47aab9){_0x17357b=_0x47aab9;_0x618160=0xc8;}else{_0x618160=0xce;}_0x2daf78[_0x9f1c('0x10')](_0x618160);return _0x2daf78[_0x9f1c('0x17')](_0x9f1c('0x18'),_0x556662+'-'+_0x17357b+'/'+_0x47aab9)[_0x9f1c('0x12')](_0x2a3ad0);}return null;};}function saveUpdates(_0x24af19){return function(_0x4528a9){if(_0x4528a9){return _0x4528a9[_0x9f1c('0x19')](_0x24af19)[_0x9f1c('0x1a')](function(_0x383be8){return _0x383be8;});}return null;};}function removeEntity(_0x3dfc53){return function(_0x1f367c){if(_0x1f367c){return _0x1f367c['destroy']()[_0x9f1c('0x1a')](function(){var _0x695c7d=_0x1f367c[_0x9f1c('0x1b')]({'plain':!![]});var _0x2ce630=_0x9f1c('0x1c');return db[_0x9f1c('0x1d')][_0x9f1c('0x1e')]({'where':{'type':_0x2ce630,'resourceId':_0x695c7d['id']}})[_0x9f1c('0x1a')](function(){return _0x1f367c;});})[_0x9f1c('0x1a')](function(){_0x3dfc53[_0x9f1c('0x10')](0xcc)[_0x9f1c('0x11')]();});}};}function handleEntityNotFound(_0x26b871){return function(_0x74e786){if(!_0x74e786){_0x26b871[_0x9f1c('0xf')](0x194);}return _0x74e786;};}function handleError(_0x54bc51,_0x53ccf2){_0x53ccf2=_0x53ccf2||0x1f4;return function(_0x4d6759){logger[_0x9f1c('0x1f')](_0x4d6759[_0x9f1c('0x20')]);if(_0x4d6759[_0x9f1c('0x21')]){delete _0x4d6759[_0x9f1c('0x21')];}_0x54bc51[_0x9f1c('0x10')](_0x53ccf2)[_0x9f1c('0x22')](_0x4d6759);};}exports[_0x9f1c('0x23')]=function(_0x375b28,_0x46c3b2){var _0xa13bdf={};var _0xbc341b={'count':0x0,'rows':[]};var _0x49197d=_[_0x9f1c('0x24')](db[_0x9f1c('0x25')][_0x9f1c('0x26')],function(_0x3a4592){return{'name':_0x3a4592[_0x9f1c('0x27')],'type':_0x3a4592[_0x9f1c('0x28')][_0x9f1c('0x29')]};});_0xa13bdf=qs['getOptions'](_0x49197d,_0x375b28);var _0x358fe9={'where':_0xa13bdf[_0x9f1c('0x2a')]};return db['WhatsappQueue'][_0x9f1c('0x15')](_0x358fe9)[_0x9f1c('0x1a')](function(_0x2f96f5){_0xbc341b[_0x9f1c('0x15')]=_0x2f96f5;_0xa13bdf[_0x9f1c('0x2b')]=qs[_0x9f1c('0x2b')](_0x375b28[_0x9f1c('0x2c')]);return db['WhatsappQueue']['findAll'](_0xa13bdf);})[_0x9f1c('0x1a')](function(_0x194383){_0xbc341b[_0x9f1c('0x2d')]=_0x194383;return _0xbc341b;})[_0x9f1c('0x1a')](respondWithFilteredResult(_0x46c3b2,_0xa13bdf))[_0x9f1c('0x2e')](handleError(_0x46c3b2,null));};exports[_0x9f1c('0x2f')]=function(_0x51e47b,_0x299de0){var _0x525816={'raw':!![],'where':{'id':_0x51e47b[_0x9f1c('0x30')]['id']}},_0x4dec34={};_0x4dec34[_0x9f1c('0x31')]=_[_0x9f1c('0x32')](db['WhatsappQueue'][_0x9f1c('0x26')]);_0x4dec34[_0x9f1c('0x2c')]=_[_0x9f1c('0x32')](_0x51e47b[_0x9f1c('0x2c')]);_0x4dec34[_0x9f1c('0x33')]=_[_0x9f1c('0x34')](_0x4dec34[_0x9f1c('0x31')],_0x4dec34['query']);_0x525816[_0x9f1c('0x35')]=_['intersection'](_0x4dec34['model'],qs['fields'](_0x51e47b['query'][_0x9f1c('0x36')]));_0x525816['attributes']=_0x525816[_0x9f1c('0x35')][_0x9f1c('0x37')]?_0x525816['attributes']:_0x4dec34[_0x9f1c('0x31')];if(_0x51e47b['query'][_0x9f1c('0x38')]){_0x525816['include']=[{'all':!![]}];}_0x525816=_[_0x9f1c('0x39')]({},_0x525816,_0x51e47b['options']);return db[_0x9f1c('0x25')][_0x9f1c('0x3a')](_0x525816)[_0x9f1c('0x1a')](handleEntityNotFound(_0x299de0,null))[_0x9f1c('0x1a')](respondWithResult(_0x299de0,null))[_0x9f1c('0x2e')](handleError(_0x299de0,null));};exports['create']=function(_0x292dfb,_0xda3056){return db[_0x9f1c('0x25')][_0x9f1c('0x3b')](_0x292dfb[_0x9f1c('0x3c')],{})[_0x9f1c('0x1a')](function(_0x4fc81b){var _0x50ec1f=_0x292dfb[_0x9f1c('0x3d')]['get']({'plain':!![]});if(!_0x50ec1f)throw new Error(_0x9f1c('0x3e'));if(_0x50ec1f['role']===_0x9f1c('0x3d')){var _0x229eed=_0x4fc81b['get']({'plain':!![]});var _0x2b2a67=_0x9f1c('0x1c');return db[_0x9f1c('0x3f')][_0x9f1c('0x3a')]({'where':{'name':_0x2b2a67,'userProfileId':_0x50ec1f[_0x9f1c('0x40')]},'raw':!![]})[_0x9f1c('0x1a')](function(_0x181270){if(_0x181270&&_0x181270['autoAssociation']===0x0){return db['UserProfileResource'][_0x9f1c('0x3b')]({'name':_0x229eed[_0x9f1c('0x21')],'resourceId':_0x229eed['id'],'type':_0x181270[_0x9f1c('0x21')],'sectionId':_0x181270['id']},{})[_0x9f1c('0x1a')](function(){return _0x4fc81b;});}else{return _0x4fc81b;}})[_0x9f1c('0x2e')](function(_0x14b3be){logger[_0x9f1c('0x1f')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x14b3be);throw _0x14b3be;});}return _0x4fc81b;})[_0x9f1c('0x1a')](respondWithResult(_0xda3056,0xc9))['catch'](handleError(_0xda3056,null));};exports[_0x9f1c('0x19')]=function(_0x20636e,_0x4c6bf6){if(_0x20636e[_0x9f1c('0x3c')]['id']){delete _0x20636e['body']['id'];}return db[_0x9f1c('0x25')][_0x9f1c('0x3a')]({'where':{'id':_0x20636e['params']['id']}})['then'](handleEntityNotFound(_0x4c6bf6,null))['then'](saveUpdates(_0x20636e['body'],null))['then'](respondWithResult(_0x4c6bf6,null))[_0x9f1c('0x2e')](handleError(_0x4c6bf6,null));};exports['destroy']=function(_0x45260f,_0x590e0e){return db[_0x9f1c('0x25')][_0x9f1c('0x3a')]({'where':{'id':_0x45260f[_0x9f1c('0x30')]['id']}})['then'](handleEntityNotFound(_0x590e0e,null))[_0x9f1c('0x1a')](removeEntity(_0x590e0e,null))[_0x9f1c('0x2e')](handleError(_0x590e0e,null));};exports[_0x9f1c('0x41')]=function(_0x3c1b44,_0x2dafa4){return db['WhatsappQueue']['describe']()[_0x9f1c('0x1a')](respondWithResult(_0x2dafa4,null))[_0x9f1c('0x2e')](handleError(_0x2dafa4,null));};exports[_0x9f1c('0x42')]=function(_0x18bfde,_0x2354e2){var _0x473065={'raw':!![],'where':{}},_0x39b0aa={},_0x8ac4ae;return db['WhatsappQueue'][_0x9f1c('0x43')]({'where':{'id':_0x18bfde[_0x9f1c('0x30')]['id']}})[_0x9f1c('0x1a')](handleEntityNotFound(_0x2354e2,null))[_0x9f1c('0x1a')](function(_0x309bf9){if(_0x309bf9){_0x8ac4ae=_0x309bf9[_0x9f1c('0x1b')]({'plain':!![]});_0x39b0aa[_0x9f1c('0x31')]=_[_0x9f1c('0x32')](db['UserWhatsappQueue'][_0x9f1c('0x26')]);_0x39b0aa['query']=_['keys'](_0x18bfde[_0x9f1c('0x2c')]);_0x39b0aa[_0x9f1c('0x33')]=_[_0x9f1c('0x34')](_0x39b0aa[_0x9f1c('0x31')],_0x39b0aa[_0x9f1c('0x2c')]);_0x473065['attributes']=_['intersection'](_0x39b0aa[_0x9f1c('0x31')],qs['fields'](_0x18bfde['query'][_0x9f1c('0x36')]));_0x473065[_0x9f1c('0x35')]=_0x473065[_0x9f1c('0x35')][_0x9f1c('0x37')]?_0x473065[_0x9f1c('0x35')]:_0x39b0aa[_0x9f1c('0x31')];if(!_0x18bfde[_0x9f1c('0x2c')][_0x9f1c('0x44')]('nolimit')){_0x473065[_0x9f1c('0x16')]=qs[_0x9f1c('0x16')](_0x18bfde[_0x9f1c('0x2c')]['limit']);_0x473065[_0x9f1c('0x13')]=qs[_0x9f1c('0x13')](_0x18bfde[_0x9f1c('0x2c')][_0x9f1c('0x13')]);}_0x473065[_0x9f1c('0x45')]=qs['sort'](_0x18bfde[_0x9f1c('0x2c')][_0x9f1c('0x46')]);_0x473065[_0x9f1c('0x2a')]=qs['filters'](_['pick'](_0x18bfde[_0x9f1c('0x2c')],_0x39b0aa[_0x9f1c('0x33')]));_0x473065[_0x9f1c('0x2a')][_0x9f1c('0x47')]=_0x309bf9['id'];if(_0x18bfde[_0x9f1c('0x2c')]['filter']){_0x473065['where']=_[_0x9f1c('0x39')](_0x473065[_0x9f1c('0x2a')],{'$or':_[_0x9f1c('0x24')](_0x473065[_0x9f1c('0x35')],function(_0x175ec9){var _0xf9587={};_0xf9587[_0x175ec9]={'$like':'%'+_0x18bfde[_0x9f1c('0x2c')][_0x9f1c('0x48')]+'%'};return _0xf9587;})});}_0x473065=_['merge']({},_0x473065,_0x18bfde['options']);return db[_0x9f1c('0x49')][_0x9f1c('0x4a')](_0x473065);}})[_0x9f1c('0x1a')](function(_0x1d7e7e){if(_0x1d7e7e){return db['User'][_0x9f1c('0x4b')]({'where':{'id':_[_0x9f1c('0x24')](_0x1d7e7e,_0x9f1c('0x4c')),'role':_0x9f1c('0x4d')},'attributes':['id','name',_0x9f1c('0x4e'),_0x9f1c('0x4f'),'createdAt']});}})[_0x9f1c('0x1a')](function(_0x32dbc2){if(_0x32dbc2){return{'count':_0x32dbc2[_0x9f1c('0x15')],'rows':_[_0x9f1c('0x24')](_0x32dbc2[_0x9f1c('0x2d')],function(_0x3d82cf){return{'membername':_0x3d82cf[_0x9f1c('0x21')],'UserId':_0x3d82cf['id'],'queue_name':_0x8ac4ae[_0x9f1c('0x21')],'WhatsappQueueId':_0x8ac4ae['id'],'interface':util[_0x9f1c('0x50')]('%s/%s',_0x9f1c('0x51'),_0x3d82cf[_0x9f1c('0x21')]),'penalty':0x0,'paused':_0x3d82cf[_0x9f1c('0x4e')],'createdAt':_0x3d82cf[_0x9f1c('0x52')],'updatedAt':_0x3d82cf[_0x9f1c('0x4f')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x9f1c('0x1a')](respondWithFilteredResult(_0x2354e2,_0x473065))[_0x9f1c('0x2e')](handleError(_0x2354e2,null));};exports['getTeams']=function(_0x4eecca,_0x2a7ed5){var _0x51ba88={};var _0xb92ad4={};var _0x18b2f7;var _0x3d34d7;return db[_0x9f1c('0x25')][_0x9f1c('0x43')]({'where':{'id':_0x4eecca[_0x9f1c('0x30')]['id']}})[_0x9f1c('0x1a')](handleEntityNotFound(_0x2a7ed5,null))[_0x9f1c('0x1a')](function(_0x312615){if(_0x312615){_0x18b2f7=_0x312615;_0xb92ad4['model']=_['keys'](db[_0x9f1c('0x53')][_0x9f1c('0x26')]);_0xb92ad4['query']=_['keys'](_0x4eecca['query']);_0xb92ad4[_0x9f1c('0x33')]=_[_0x9f1c('0x34')](_0xb92ad4['model'],_0xb92ad4['query']);_0x51ba88[_0x9f1c('0x35')]=_[_0x9f1c('0x34')](_0xb92ad4['model'],qs['fields'](_0x4eecca[_0x9f1c('0x2c')][_0x9f1c('0x36')]));_0x51ba88['attributes']=_0x51ba88[_0x9f1c('0x35')][_0x9f1c('0x37')]?_0x51ba88[_0x9f1c('0x35')]:_0xb92ad4[_0x9f1c('0x31')];_0x51ba88[_0x9f1c('0x45')]=qs[_0x9f1c('0x46')](_0x4eecca['query'][_0x9f1c('0x46')]);_0x51ba88[_0x9f1c('0x2a')]=qs[_0x9f1c('0x33')](_[_0x9f1c('0x54')](_0x4eecca[_0x9f1c('0x2c')],_0xb92ad4['filters']));if(_0x4eecca[_0x9f1c('0x2c')][_0x9f1c('0x48')]){_0x51ba88[_0x9f1c('0x2a')]=_['merge'](_0x51ba88[_0x9f1c('0x2a')],{'$or':_[_0x9f1c('0x24')](_0x51ba88[_0x9f1c('0x35')],function(_0x25cdc0){var _0xeef153={};_0xeef153[_0x25cdc0]={'$like':'%'+_0x4eecca[_0x9f1c('0x2c')]['filter']+'%'};return _0xeef153;})});}_0x51ba88=_[_0x9f1c('0x39')]({},_0x51ba88,_0x4eecca[_0x9f1c('0x55')]);return _0x18b2f7[_0x9f1c('0x56')](_0x51ba88);}})[_0x9f1c('0x1a')](function(_0xe5b409){if(_0xe5b409){_0x3d34d7=_0xe5b409[_0x9f1c('0x37')];if(!_0x4eecca[_0x9f1c('0x2c')]['hasOwnProperty'](_0x9f1c('0x57'))){_0x51ba88[_0x9f1c('0x16')]=qs[_0x9f1c('0x16')](_0x4eecca[_0x9f1c('0x2c')][_0x9f1c('0x16')]);_0x51ba88[_0x9f1c('0x13')]=qs[_0x9f1c('0x13')](_0x4eecca['query'][_0x9f1c('0x13')]);}return _0x18b2f7[_0x9f1c('0x56')](_0x51ba88);}})[_0x9f1c('0x1a')](function(_0x4cb04a){if(_0x4cb04a){return _0x4cb04a?{'count':_0x3d34d7,'rows':_0x4cb04a}:null;}})['then'](respondWithResult(_0x2a7ed5,null))[_0x9f1c('0x2e')](handleError(_0x2a7ed5,null));};exports[_0x9f1c('0x58')]=function(_0x4f6fca,_0x35a0bd){var _0x3062d3=_0x4f6fca[_0x9f1c('0x3c')]['ids'];return db[_0x9f1c('0x53')]['findAll']({'where':{'id':_0x3062d3},'attributes':['id'],'include':[{'model':db[_0x9f1c('0x59')],'as':_0x9f1c('0x5a'),'attributes':['id',_0x9f1c('0x21'),_0x9f1c('0x5b'),_0x9f1c('0x5c'),'interface'],'raw':!![]}]})[_0x9f1c('0x1a')](function(_0x35a1f8){if(_0x35a1f8){var _0x4d2855=_[_0x9f1c('0x5d')](_0x35a1f8,function(_0xbf8e1a){var _0x28abf5=_0xbf8e1a[_0x9f1c('0x1b')]({'plain':!![]});return _0x28abf5[_0x9f1c('0x5a')];});return db[_0x9f1c('0x25')][_0x9f1c('0x3a')]({'where':{'id':_0x4f6fca[_0x9f1c('0x30')]['id']}})[_0x9f1c('0x1a')](function(_0x207692){return db[_0x9f1c('0x5e')]['transaction'](function(_0x3d3ac5){return _0x207692[_0x9f1c('0x58')](_0x3062d3,{'transaction':_0x3d3ac5})[_0x9f1c('0x1a')](function(){return BPromise[_0x9f1c('0x5f')](_0x4d2855,function(_0x44fcff){return db[_0x9f1c('0x49')]['findOrCreate']({'where':{'UserId':_0x44fcff['id'],'WhatsappQueueId':_0x4f6fca[_0x9f1c('0x30')]['id']},'transaction':_0x3d3ac5});});})[_0x9f1c('0x1a')](function(){_0x4d2855[_0x9f1c('0x60')](function(_0x59a6b8){socket[_0x9f1c('0x61')]('userWhatsappQueue:save',{'UserId':_0x59a6b8['id'],'WhatsappQueueId':_0x207692['id']});});});});});}})['then'](respondWithStatusCode(_0x35a0bd,null))['catch'](handleError(_0x35a0bd,null));};exports[_0x9f1c('0x62')]=function(_0x21885c,_0x3f75bd){return db['Team'][_0x9f1c('0x4a')]({'where':{'id':_0x21885c[_0x9f1c('0x2c')][_0x9f1c('0x63')]},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x9f1c('0x1a')](handleEntityNotFound(_0x3f75bd,null))[_0x9f1c('0x1a')](function(_0x5a98e2){var _0x4185a4=_[_0x9f1c('0x24')](_0x5a98e2,'id');var _0x37be96=[];var _0x26e75f=[];var _0x99d8f2=squel[_0x9f1c('0x64')]();_0x99d8f2['field'](_0x9f1c('0x65'))[_0x9f1c('0x66')](_0x9f1c('0x67'),'tq')[_0x9f1c('0x68')]('user_has_teams','ut',_0x9f1c('0x69'))[_0x9f1c('0x2a')](_0x9f1c('0x6a'),_0x21885c[_0x9f1c('0x30')]['id']);for(var _0x1d7a1b=0x0;_0x1d7a1b<_0x5a98e2[_0x9f1c('0x37')];_0x1d7a1b+=0x1){let _0x2403c4=_0x5a98e2[_0x1d7a1b];for(var _0x443734=0x0;_0x443734<_0x2403c4['Agents'][_0x9f1c('0x37')];_0x443734+=0x1){let _0x517859=_0x2403c4['Agents'][_0x443734];var _0x3739db=_0x99d8f2['clone']();_0x3739db[_0x9f1c('0x2a')]('ut.UserId\x20=\x20?',_0x517859['id']);_0x26e75f['push'](db[_0x9f1c('0x5e')][_0x9f1c('0x2c')](_0x3739db[_0x9f1c('0x6b')](),{'type':db['sequelize'][_0x9f1c('0x6c')][_0x9f1c('0x6d')]})[_0x9f1c('0x1a')](function(_0x111107){if(_0x111107[_0x9f1c('0x37')]===0x1){return _0x517859['id'];}else{var _0x113cda=_[_0x9f1c('0x6e')](_['map'](_0x111107,_0x9f1c('0x6f')),function(_0x18dcac){return _[_0x9f1c('0x70')](_0x4185a4,_0x18dcac);});if(_0x113cda){return _0x517859['id'];}}}));}}return BPromise[_0x9f1c('0x71')](_0x26e75f)['then'](function(_0x374394){_0x37be96=_(_0x37be96)[_0x9f1c('0x72')](_0x374394)[_0x9f1c('0x73')]()[_0x9f1c('0x74')]();return db[_0x9f1c('0x25')][_0x9f1c('0x3a')]({'where':{'id':_0x21885c[_0x9f1c('0x30')]['id']}})[_0x9f1c('0x1a')](function(_0x5a9e53){return db[_0x9f1c('0x5e')][_0x9f1c('0x75')](function(_0x14ce39){return _0x5a9e53[_0x9f1c('0x62')](_0x21885c[_0x9f1c('0x2c')][_0x9f1c('0x63')],{'transaction':_0x14ce39})[_0x9f1c('0x1a')](function(){if(!_[_0x9f1c('0x76')](_0x37be96)){return _0x5a9e53[_0x9f1c('0x77')](_0x37be96,{'transaction':_0x14ce39});}})[_0x9f1c('0x1a')](function(){_0x37be96[_0x9f1c('0x60')](function(_0x3063d1){socket[_0x9f1c('0x61')](_0x9f1c('0x78'),{'UserId':_0x3063d1,'WhatsappQueueId':_0x5a9e53['id']});});});});});});})['then'](respondWithStatusCode(_0x3f75bd,null))[_0x9f1c('0x2e')](handleError(_0x3f75bd,null));};exports[_0x9f1c('0x79')]=function(_0x2d0ca7,_0x527211){return db[_0x9f1c('0x25')][_0x9f1c('0x3a')]({'where':{'id':_0x2d0ca7[_0x9f1c('0x30')]['id']}})['then'](handleEntityNotFound(_0x527211,null))[_0x9f1c('0x1a')](function(_0x52563c){if(_0x52563c){return _0x52563c[_0x9f1c('0x79')](_0x2d0ca7[_0x9f1c('0x3c')][_0x9f1c('0x63')],_[_0x9f1c('0x7a')](_0x2d0ca7['body'],[_0x9f1c('0x63'),'id'])||{})[_0x9f1c('0x7b')](function(_0x2e25da){for(var _0x22b6ad=0x0;_0x22b6ad<_0x2d0ca7[_0x9f1c('0x3c')][_0x9f1c('0x63')][_0x9f1c('0x37')];_0x22b6ad+=0x1){socket[_0x9f1c('0x61')](_0x9f1c('0x7c'),{'UserId':Number(_0x2d0ca7[_0x9f1c('0x3c')][_0x9f1c('0x63')][_0x22b6ad]),'WhatsappQueueId':Number(_0x2d0ca7[_0x9f1c('0x30')]['id'])});}return _0x2e25da;});}})[_0x9f1c('0x1a')](respondWithResult(_0x527211,null))[_0x9f1c('0x2e')](handleError(_0x527211,null));};exports[_0x9f1c('0x77')]=function(_0x15aa3b,_0x50a9a1){return db[_0x9f1c('0x25')][_0x9f1c('0x3a')]({'where':{'id':_0x15aa3b[_0x9f1c('0x30')]['id']}})[_0x9f1c('0x1a')](handleEntityNotFound(_0x50a9a1,null))[_0x9f1c('0x1a')](function(_0x1ce741){if(_0x1ce741){return _0x1ce741[_0x9f1c('0x77')](_0x15aa3b[_0x9f1c('0x2c')][_0x9f1c('0x63')])['then'](function(){if(_[_0x9f1c('0x7d')](_0x15aa3b['query']['ids'])){for(var _0x43f24a=0x0;_0x43f24a<_0x15aa3b[_0x9f1c('0x2c')]['ids'][_0x9f1c('0x37')];_0x43f24a+=0x1){socket[_0x9f1c('0x61')](_0x9f1c('0x78'),{'UserId':Number(_0x15aa3b['query']['ids'][_0x43f24a]),'WhatsappQueueId':Number(_0x15aa3b[_0x9f1c('0x30')]['id'])});}}else{socket['emit']('userWhatsappQueue:remove',{'UserId':Number(_0x15aa3b[_0x9f1c('0x2c')][_0x9f1c('0x63')]),'WhatsappQueueId':Number(_0x15aa3b[_0x9f1c('0x30')]['id'])});}});}})['then'](respondWithStatusCode(_0x50a9a1,null))[_0x9f1c('0x2e')](handleError(_0x50a9a1,null));};exports['getAgents']=function(_0x2d5d69,_0x1acffb){var _0x5d29dc={};var _0x57ea09={};var _0x12e0c6;var _0x206691;return db[_0x9f1c('0x25')][_0x9f1c('0x43')]({'where':{'id':_0x2d5d69[_0x9f1c('0x30')]['id']}})[_0x9f1c('0x1a')](handleEntityNotFound(_0x1acffb,null))[_0x9f1c('0x1a')](function(_0x45b694){if(_0x45b694){_0x12e0c6=_0x45b694;_0x57ea09[_0x9f1c('0x31')]=_[_0x9f1c('0x32')](db[_0x9f1c('0x59')][_0x9f1c('0x26')]);_0x57ea09[_0x9f1c('0x2c')]=_[_0x9f1c('0x32')](_0x2d5d69[_0x9f1c('0x2c')]);_0x57ea09[_0x9f1c('0x33')]=_[_0x9f1c('0x34')](_0x57ea09[_0x9f1c('0x31')],_0x57ea09[_0x9f1c('0x2c')]);_0x5d29dc[_0x9f1c('0x35')]=_[_0x9f1c('0x34')](_0x57ea09['model'],qs[_0x9f1c('0x36')](_0x2d5d69[_0x9f1c('0x2c')][_0x9f1c('0x36')]));_0x5d29dc[_0x9f1c('0x35')]=_0x5d29dc[_0x9f1c('0x35')][_0x9f1c('0x37')]?_0x5d29dc[_0x9f1c('0x35')]:_0x57ea09[_0x9f1c('0x31')];_0x5d29dc[_0x9f1c('0x45')]=qs['sort'](_0x2d5d69[_0x9f1c('0x2c')][_0x9f1c('0x46')]);_0x5d29dc['where']=qs['filters'](_['pick'](_0x2d5d69[_0x9f1c('0x2c')],_0x57ea09[_0x9f1c('0x33')]));if(_0x2d5d69[_0x9f1c('0x2c')]['filter']){_0x5d29dc[_0x9f1c('0x2a')]=_[_0x9f1c('0x39')](_0x5d29dc[_0x9f1c('0x2a')],{'$or':_[_0x9f1c('0x24')](_0x5d29dc['attributes'],function(_0x158b19){var _0x514d5e={};_0x514d5e[_0x158b19]={'$like':'%'+_0x2d5d69[_0x9f1c('0x2c')][_0x9f1c('0x48')]+'%'};return _0x514d5e;})});}_0x5d29dc=_['merge']({},_0x5d29dc,_0x2d5d69[_0x9f1c('0x55')]);return _0x12e0c6['getAgents'](_0x5d29dc);}})[_0x9f1c('0x1a')](function(_0x4ae993){if(_0x4ae993){_0x206691=_0x4ae993[_0x9f1c('0x37')];if(!_0x2d5d69[_0x9f1c('0x2c')]['hasOwnProperty'](_0x9f1c('0x57'))){_0x5d29dc[_0x9f1c('0x16')]=qs['limit'](_0x2d5d69[_0x9f1c('0x2c')]['limit']);_0x5d29dc['offset']=qs['offset'](_0x2d5d69['query'][_0x9f1c('0x13')]);}return _0x12e0c6['getAgents'](_0x5d29dc);}})[_0x9f1c('0x1a')](function(_0x5c08af){if(_0x5c08af){return _0x5c08af?{'count':_0x206691,'rows':_0x5c08af}:null;}})['then'](respondWithResult(_0x1acffb,null))['catch'](handleError(_0x1acffb,null));};
\ No newline at end of file