Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 782ffab..d6f12b5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3de4=['WhatsappQueues','UserProfileResource','destroy','error','name','send','index','map','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','WhatsappQueue','rows','catch','params','find','create','body','user','UserProfileSection','autoAssociation','describe','getMembers','WhatsappQueueId','findAll','User','findAndCountAll','UserId','agent','updatedAt','createdAt','format','%s/%s','whatsappPause','getTeams','findOne','hasOwnProperty','addTeams','ids','Agents','online','interface','flatMap','sequelize','each','findOrCreate','emit','userWhatsappQueue:save','removeTeams','select','tq.TeamId','from','team_has_whatsapp_queues','join','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','SELECT','every','TeamId','all','union','transaction','isEmpty','userWhatsappQueue:remove','addAgents','omit','removeAgents','isArray','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','./whatsappQueue.socket','register','sendStatus','status','end','json','undefined','limit','offset','count','set','Content-Range','apply','reject','save','update','then','get'];(function(_0x1f6df2,_0x22a926){var _0x3ad5cc=function(_0xcddf84){while(--_0xcddf84){_0x1f6df2['push'](_0x1f6df2['shift']());}};_0x3ad5cc(++_0x22a926);}(_0x3de4,0x1ee));var _0x43de=function(_0x2c169e,_0x554de0){_0x2c169e=_0x2c169e-0x0;var _0x1c5914=_0x3de4[_0x2c169e];return _0x1c5914;};'use strict';var emlformat=require(_0x43de('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x43de('0x1'));var jsonpatch=require(_0x43de('0x2'));var rp=require(_0x43de('0x3'));var moment=require(_0x43de('0x4'));var BPromise=require(_0x43de('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x43de('0x6'));var ejs=require(_0x43de('0x7'));var fs=require('fs');var fs_extra=require(_0x43de('0x8'));var _=require(_0x43de('0x9'));var squel=require(_0x43de('0xa'));var crypto=require(_0x43de('0xb'));var jsforce=require(_0x43de('0xc'));var deskjs=require(_0x43de('0xd'));var toCsv=require(_0x43de('0x6'));var querystring=require(_0x43de('0xe'));var Papa=require(_0x43de('0xf'));var Redis=require(_0x43de('0x10'));var authService=require(_0x43de('0x11'));var qs=require(_0x43de('0x12'));var as=require(_0x43de('0x13'));var hardwareService=require(_0x43de('0x14'));var logger=require(_0x43de('0x15'))('api');var utils=require(_0x43de('0x16'));var config=require(_0x43de('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x43de('0x18'))['db'];config[_0x43de('0x19')]=_[_0x43de('0x1a')](config[_0x43de('0x19')],{'host':_0x43de('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x43de('0x19')]));require(_0x43de('0x1c'))[_0x43de('0x1d')](socket);function respondWithStatusCode(_0x1d2676,_0xf4535b){_0xf4535b=_0xf4535b||0xcc;return function(_0x794302){if(_0x794302){return _0x1d2676[_0x43de('0x1e')](_0xf4535b);}return _0x1d2676[_0x43de('0x1f')](_0xf4535b)[_0x43de('0x20')]();};}function respondWithResult(_0xaf4365,_0x111546){_0x111546=_0x111546||0xc8;return function(_0x1d32d8){if(_0x1d32d8){return _0xaf4365['status'](_0x111546)[_0x43de('0x21')](_0x1d32d8);}};}function respondWithFilteredResult(_0x245d04,_0x53d207){return function(_0x44a26a){if(_0x44a26a){var _0x450e00=typeof _0x53d207['offset']===_0x43de('0x22')&&typeof _0x53d207[_0x43de('0x23')]==='undefined';var _0x3309bf=_0x44a26a['count'];var _0x2e49f9=_0x450e00?0x0:_0x53d207[_0x43de('0x24')];var _0x5a37d6=_0x450e00?_0x44a26a[_0x43de('0x25')]:_0x53d207[_0x43de('0x24')]+_0x53d207[_0x43de('0x23')];var _0x5a8db3;if(_0x5a37d6>=_0x3309bf){_0x5a37d6=_0x3309bf;_0x5a8db3=0xc8;}else{_0x5a8db3=0xce;}_0x245d04[_0x43de('0x1f')](_0x5a8db3);return _0x245d04[_0x43de('0x26')](_0x43de('0x27'),_0x2e49f9+'-'+_0x5a37d6+'/'+_0x3309bf)['json'](_0x44a26a);}return null;};}function patchUpdates(_0x1f1ca6){return function(_0xca050a){try{jsonpatch[_0x43de('0x28')](_0xca050a,_0x1f1ca6,!![]);}catch(_0x275716){return BPromise[_0x43de('0x29')](_0x275716);}return _0xca050a[_0x43de('0x2a')]();};}function saveUpdates(_0x17a7c3,_0x106166){return function(_0x47d597){if(_0x47d597){return _0x47d597[_0x43de('0x2b')](_0x17a7c3)[_0x43de('0x2c')](function(_0x2e9322){return _0x2e9322;});}return null;};}function removeEntity(_0x181003,_0x1ead25){return function(_0x386733){if(_0x386733){return _0x386733['destroy']()['then'](function(){var _0x2de244=_0x386733[_0x43de('0x2d')]({'plain':!![]});var _0x8468d0=_0x43de('0x2e');return db[_0x43de('0x2f')][_0x43de('0x30')]({'where':{'type':_0x8468d0,'resourceId':_0x2de244['id']}})[_0x43de('0x2c')](function(){return _0x386733;});})[_0x43de('0x2c')](function(){_0x181003[_0x43de('0x1f')](0xcc)[_0x43de('0x20')]();});}};}function handleEntityNotFound(_0x195cef,_0x2ce57b){return function(_0x1c3208){if(!_0x1c3208){_0x195cef[_0x43de('0x1e')](0x194);}return _0x1c3208;};}function handleError(_0x20a775,_0x3d342b){_0x3d342b=_0x3d342b||0x1f4;return function(_0x23e044){logger[_0x43de('0x31')](_0x23e044['stack']);if(_0x23e044[_0x43de('0x32')]){delete _0x23e044[_0x43de('0x32')];}_0x20a775[_0x43de('0x1f')](_0x3d342b)[_0x43de('0x33')](_0x23e044);};}exports[_0x43de('0x34')]=function(_0x182969,_0x55cf07){var _0x30ab6d={},_0x7bc428={},_0x468f39={'count':0x0,'rows':[]};var _0x1321fb=_[_0x43de('0x35')](db['WhatsappQueue'][_0x43de('0x36')],function(_0x3ea0a1){return{'name':_0x3ea0a1[_0x43de('0x37')],'type':_0x3ea0a1[_0x43de('0x38')]['key']};});_0x7bc428[_0x43de('0x39')]=_[_0x43de('0x35')](_0x1321fb,_0x43de('0x32'));_0x7bc428[_0x43de('0x3a')]=_[_0x43de('0x3b')](_0x182969[_0x43de('0x3a')]);_0x7bc428[_0x43de('0x3c')]=_[_0x43de('0x3d')](_0x7bc428[_0x43de('0x39')],_0x7bc428[_0x43de('0x3a')]);_0x30ab6d[_0x43de('0x3e')]=_[_0x43de('0x3d')](_0x7bc428[_0x43de('0x39')],qs[_0x43de('0x3f')](_0x182969['query']['fields']));_0x30ab6d['attributes']=_0x30ab6d[_0x43de('0x3e')][_0x43de('0x40')]?_0x30ab6d[_0x43de('0x3e')]:_0x7bc428[_0x43de('0x39')];if(!_0x182969['query']['hasOwnProperty'](_0x43de('0x41'))){_0x30ab6d[_0x43de('0x23')]=qs[_0x43de('0x23')](_0x182969[_0x43de('0x3a')][_0x43de('0x23')]);_0x30ab6d['offset']=qs['offset'](_0x182969[_0x43de('0x3a')][_0x43de('0x24')]);}_0x30ab6d[_0x43de('0x42')]=qs[_0x43de('0x43')](_0x182969[_0x43de('0x3a')][_0x43de('0x43')]);_0x30ab6d[_0x43de('0x44')]=qs[_0x43de('0x3c')](_[_0x43de('0x45')](_0x182969[_0x43de('0x3a')],_0x7bc428[_0x43de('0x3c')]),_0x1321fb);if(_0x182969['query']['filter']){_0x30ab6d[_0x43de('0x44')]=_[_0x43de('0x46')](_0x30ab6d['where'],{'$or':_[_0x43de('0x35')](_0x1321fb,function(_0x8b5013){if(_0x8b5013[_0x43de('0x38')]!==_0x43de('0x47')){var _0x2391ce={};_0x2391ce[_0x8b5013[_0x43de('0x32')]]={'$like':'%'+_0x182969[_0x43de('0x3a')][_0x43de('0x48')]+'%'};return _0x2391ce;}})});}_0x30ab6d=_[_0x43de('0x46')]({},_0x30ab6d,_0x182969[_0x43de('0x49')]);var _0x410007={'where':_0x30ab6d['where']};return db['WhatsappQueue'][_0x43de('0x25')](_0x410007)[_0x43de('0x2c')](function(_0x1d6c28){_0x468f39['count']=_0x1d6c28;if(_0x182969[_0x43de('0x3a')][_0x43de('0x4a')]){_0x30ab6d['include']=[{'all':!![]}];}return db[_0x43de('0x4b')]['findAll'](_0x30ab6d);})['then'](function(_0x26b772){_0x468f39[_0x43de('0x4c')]=_0x26b772;return _0x468f39;})[_0x43de('0x2c')](respondWithFilteredResult(_0x55cf07,_0x30ab6d))[_0x43de('0x4d')](handleError(_0x55cf07,null));};exports['show']=function(_0x158907,_0x42b8c5){var _0x56efa7={'raw':!![],'where':{'id':_0x158907[_0x43de('0x4e')]['id']}},_0x334b62={};_0x334b62[_0x43de('0x39')]=_[_0x43de('0x3b')](db[_0x43de('0x4b')][_0x43de('0x36')]);_0x334b62[_0x43de('0x3a')]=_[_0x43de('0x3b')](_0x158907[_0x43de('0x3a')]);_0x334b62[_0x43de('0x3c')]=_[_0x43de('0x3d')](_0x334b62[_0x43de('0x39')],_0x334b62[_0x43de('0x3a')]);_0x56efa7[_0x43de('0x3e')]=_[_0x43de('0x3d')](_0x334b62[_0x43de('0x39')],qs['fields'](_0x158907[_0x43de('0x3a')][_0x43de('0x3f')]));_0x56efa7[_0x43de('0x3e')]=_0x56efa7[_0x43de('0x3e')][_0x43de('0x40')]?_0x56efa7['attributes']:_0x334b62[_0x43de('0x39')];if(_0x158907[_0x43de('0x3a')][_0x43de('0x4a')]){_0x56efa7['include']=[{'all':!![]}];}_0x56efa7=_[_0x43de('0x46')]({},_0x56efa7,_0x158907[_0x43de('0x49')]);return db['WhatsappQueue'][_0x43de('0x4f')](_0x56efa7)['then'](handleEntityNotFound(_0x42b8c5,null))[_0x43de('0x2c')](respondWithResult(_0x42b8c5,null))[_0x43de('0x4d')](handleError(_0x42b8c5,null));};exports[_0x43de('0x50')]=function(_0x7dcf60,_0x47d1d5){return db['WhatsappQueue']['create'](_0x7dcf60[_0x43de('0x51')],{})['then'](function(_0x3db021){var _0x463f41=_0x7dcf60[_0x43de('0x52')][_0x43de('0x2d')]({'plain':!![]});if(!_0x463f41)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x463f41['role']===_0x43de('0x52')){var _0x132376=_0x3db021[_0x43de('0x2d')]({'plain':!![]});var _0x513437=_0x43de('0x2e');return db[_0x43de('0x53')][_0x43de('0x4f')]({'where':{'name':_0x513437,'userProfileId':_0x463f41['userProfileId']},'raw':!![]})[_0x43de('0x2c')](function(_0x4fec1e){if(_0x4fec1e&&_0x4fec1e[_0x43de('0x54')]===0x0){return db[_0x43de('0x2f')][_0x43de('0x50')]({'name':_0x132376[_0x43de('0x32')],'resourceId':_0x132376['id'],'type':_0x4fec1e[_0x43de('0x32')],'sectionId':_0x4fec1e['id']},{})[_0x43de('0x2c')](function(){return _0x3db021;});}else{return _0x3db021;}})[_0x43de('0x4d')](function(_0x41ecd7){logger[_0x43de('0x31')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x41ecd7);throw _0x41ecd7;});}return _0x3db021;})[_0x43de('0x2c')](respondWithResult(_0x47d1d5,0xc9))['catch'](handleError(_0x47d1d5,null));};exports['update']=function(_0x3dc6e0,_0x2894f4){if(_0x3dc6e0[_0x43de('0x51')]['id']){delete _0x3dc6e0[_0x43de('0x51')]['id'];}return db['WhatsappQueue'][_0x43de('0x4f')]({'where':{'id':_0x3dc6e0[_0x43de('0x4e')]['id']}})[_0x43de('0x2c')](handleEntityNotFound(_0x2894f4,null))['then'](saveUpdates(_0x3dc6e0[_0x43de('0x51')],null))[_0x43de('0x2c')](respondWithResult(_0x2894f4,null))['catch'](handleError(_0x2894f4,null));};exports[_0x43de('0x30')]=function(_0x4ef928,_0x3865ff){return db[_0x43de('0x4b')]['find']({'where':{'id':_0x4ef928[_0x43de('0x4e')]['id']}})[_0x43de('0x2c')](handleEntityNotFound(_0x3865ff,null))[_0x43de('0x2c')](removeEntity(_0x3865ff,null))['catch'](handleError(_0x3865ff,null));};exports[_0x43de('0x55')]=function(_0x4fd072,_0x2ae9f4){return db['WhatsappQueue'][_0x43de('0x55')]()['then'](respondWithResult(_0x2ae9f4,null))['catch'](handleError(_0x2ae9f4,null));};exports[_0x43de('0x56')]=function(_0xadc9ec,_0x21958e,_0x4d5f99){var _0x4e244f={'raw':!![],'where':{}},_0x205856={},_0x1ab167;return db['WhatsappQueue']['findOne']({'where':{'id':_0xadc9ec[_0x43de('0x4e')]['id']}})['then'](handleEntityNotFound(_0x21958e,null))[_0x43de('0x2c')](function(_0x31bba3){if(_0x31bba3){_0x1ab167=_0x31bba3[_0x43de('0x2d')]({'plain':!![]});_0x205856[_0x43de('0x39')]=_[_0x43de('0x3b')](db['UserWhatsappQueue'][_0x43de('0x36')]);_0x205856[_0x43de('0x3a')]=_['keys'](_0xadc9ec[_0x43de('0x3a')]);_0x205856[_0x43de('0x3c')]=_[_0x43de('0x3d')](_0x205856[_0x43de('0x39')],_0x205856['query']);_0x4e244f[_0x43de('0x3e')]=_['intersection'](_0x205856[_0x43de('0x39')],qs['fields'](_0xadc9ec[_0x43de('0x3a')][_0x43de('0x3f')]));_0x4e244f[_0x43de('0x3e')]=_0x4e244f[_0x43de('0x3e')][_0x43de('0x40')]?_0x4e244f[_0x43de('0x3e')]:_0x205856[_0x43de('0x39')];if(!_0xadc9ec['query']['hasOwnProperty'](_0x43de('0x41'))){_0x4e244f[_0x43de('0x23')]=qs[_0x43de('0x23')](_0xadc9ec[_0x43de('0x3a')]['limit']);_0x4e244f['offset']=qs[_0x43de('0x24')](_0xadc9ec[_0x43de('0x3a')][_0x43de('0x24')]);}_0x4e244f[_0x43de('0x42')]=qs[_0x43de('0x43')](_0xadc9ec['query'][_0x43de('0x43')]);_0x4e244f[_0x43de('0x44')]=qs['filters'](_['pick'](_0xadc9ec[_0x43de('0x3a')],_0x205856[_0x43de('0x3c')]));_0x4e244f[_0x43de('0x44')][_0x43de('0x57')]=_0x31bba3['id'];if(_0xadc9ec[_0x43de('0x3a')][_0x43de('0x48')]){_0x4e244f[_0x43de('0x44')]=_[_0x43de('0x46')](_0x4e244f['where'],{'$or':_[_0x43de('0x35')](_0x4e244f[_0x43de('0x3e')],function(_0x2b7161){var _0x434000={};_0x434000[_0x2b7161]={'$like':'%'+_0xadc9ec[_0x43de('0x3a')][_0x43de('0x48')]+'%'};return _0x434000;})});}_0x4e244f=_['merge']({},_0x4e244f,_0xadc9ec[_0x43de('0x49')]);return db['UserWhatsappQueue'][_0x43de('0x58')](_0x4e244f);}})['then'](function(_0x14d98e){if(_0x14d98e){return db[_0x43de('0x59')][_0x43de('0x5a')]({'where':{'id':_['map'](_0x14d98e,_0x43de('0x5b')),'role':_0x43de('0x5c')},'attributes':['id','name','whatsappPause',_0x43de('0x5d'),_0x43de('0x5e')]});}})[_0x43de('0x2c')](function(_0x630ac5){if(_0x630ac5){return{'count':_0x630ac5[_0x43de('0x25')],'rows':_[_0x43de('0x35')](_0x630ac5[_0x43de('0x4c')],function(_0x4ef6a2){return{'membername':_0x4ef6a2[_0x43de('0x32')],'UserId':_0x4ef6a2['id'],'queue_name':_0x1ab167[_0x43de('0x32')],'WhatsappQueueId':_0x1ab167['id'],'interface':util[_0x43de('0x5f')](_0x43de('0x60'),'SIP',_0x4ef6a2[_0x43de('0x32')]),'penalty':0x0,'paused':_0x4ef6a2[_0x43de('0x61')],'createdAt':_0x4ef6a2[_0x43de('0x5e')],'updatedAt':_0x4ef6a2['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x43de('0x2c')](respondWithFilteredResult(_0x21958e,_0x4e244f))[_0x43de('0x4d')](handleError(_0x21958e,null));};exports[_0x43de('0x62')]=function(_0x41f3a7,_0x42dc67,_0x37149c){var _0x150191={};var _0x57b922={};var _0xc2431e;var _0x5b4a56;return db[_0x43de('0x4b')][_0x43de('0x63')]({'where':{'id':_0x41f3a7['params']['id']}})['then'](handleEntityNotFound(_0x42dc67,null))[_0x43de('0x2c')](function(_0x359501){if(_0x359501){_0xc2431e=_0x359501;_0x57b922[_0x43de('0x39')]=_['keys'](db['Team']['rawAttributes']);_0x57b922[_0x43de('0x3a')]=_[_0x43de('0x3b')](_0x41f3a7['query']);_0x57b922[_0x43de('0x3c')]=_[_0x43de('0x3d')](_0x57b922[_0x43de('0x39')],_0x57b922[_0x43de('0x3a')]);_0x150191[_0x43de('0x3e')]=_[_0x43de('0x3d')](_0x57b922[_0x43de('0x39')],qs[_0x43de('0x3f')](_0x41f3a7[_0x43de('0x3a')][_0x43de('0x3f')]));_0x150191[_0x43de('0x3e')]=_0x150191[_0x43de('0x3e')]['length']?_0x150191['attributes']:_0x57b922[_0x43de('0x39')];_0x150191[_0x43de('0x42')]=qs[_0x43de('0x43')](_0x41f3a7[_0x43de('0x3a')][_0x43de('0x43')]);_0x150191[_0x43de('0x44')]=qs['filters'](_['pick'](_0x41f3a7[_0x43de('0x3a')],_0x57b922['filters']));if(_0x41f3a7[_0x43de('0x3a')]['filter']){_0x150191[_0x43de('0x44')]=_[_0x43de('0x46')](_0x150191[_0x43de('0x44')],{'$or':_['map'](_0x150191['attributes'],function(_0x53bf3f){var _0x2cb1f5={};_0x2cb1f5[_0x53bf3f]={'$like':'%'+_0x41f3a7[_0x43de('0x3a')][_0x43de('0x48')]+'%'};return _0x2cb1f5;})});}_0x150191=_['merge']({},_0x150191,_0x41f3a7[_0x43de('0x49')]);return _0xc2431e['getTeams'](_0x150191);}})[_0x43de('0x2c')](function(_0xdfa214){if(_0xdfa214){_0x5b4a56=_0xdfa214['length'];if(!_0x41f3a7[_0x43de('0x3a')][_0x43de('0x64')](_0x43de('0x41'))){_0x150191[_0x43de('0x23')]=qs[_0x43de('0x23')](_0x41f3a7[_0x43de('0x3a')][_0x43de('0x23')]);_0x150191[_0x43de('0x24')]=qs[_0x43de('0x24')](_0x41f3a7['query'][_0x43de('0x24')]);}return _0xc2431e[_0x43de('0x62')](_0x150191);}})[_0x43de('0x2c')](function(_0x15efae){if(_0x15efae){return _0x15efae?{'count':_0x5b4a56,'rows':_0x15efae}:null;}})[_0x43de('0x2c')](respondWithResult(_0x42dc67,null))['catch'](handleError(_0x42dc67,null));};exports[_0x43de('0x65')]=function(_0x1e3b91,_0x1dfbc2,_0x1e2219){var _0x4bdc2d=_0x1e3b91[_0x43de('0x51')][_0x43de('0x66')];return db['Team'][_0x43de('0x58')]({'where':{'id':_0x4bdc2d},'attributes':['id'],'include':[{'model':db[_0x43de('0x59')],'as':_0x43de('0x67'),'attributes':['id',_0x43de('0x32'),_0x43de('0x68'),'voicePause',_0x43de('0x69')],'raw':!![]}]})['then'](function(_0x143c98){if(_0x143c98){var _0x39a8dd=_[_0x43de('0x6a')](_0x143c98,function(_0x4f336d){var _0x4427c2=_0x4f336d[_0x43de('0x2d')]({'plain':!![]});return _0x4427c2[_0x43de('0x67')];});return db[_0x43de('0x4b')]['find']({'where':{'id':_0x1e3b91['params']['id']}})['then'](function(_0x487091){return db[_0x43de('0x6b')]['transaction'](function(_0x5224b8){return _0x487091[_0x43de('0x65')](_0x4bdc2d,{'transaction':_0x5224b8})[_0x43de('0x2c')](function(){return BPromise[_0x43de('0x6c')](_0x39a8dd,function(_0x245299){return db['UserWhatsappQueue'][_0x43de('0x6d')]({'where':{'UserId':_0x245299['id'],'WhatsappQueueId':_0x1e3b91[_0x43de('0x4e')]['id']},'transaction':_0x5224b8});});})[_0x43de('0x2c')](function(){_0x39a8dd['forEach'](function(_0x46175a){socket[_0x43de('0x6e')](_0x43de('0x6f'),{'UserId':_0x46175a['id'],'WhatsappQueueId':_0x487091['id']});});});});});}})[_0x43de('0x2c')](respondWithStatusCode(_0x1dfbc2,null))[_0x43de('0x4d')](handleError(_0x1dfbc2,null));};exports[_0x43de('0x70')]=function(_0x5e8711,_0x4e2b83,_0x1fce23){return db['Team']['findAll']({'where':{'id':_0x5e8711[_0x43de('0x3a')][_0x43de('0x66')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x43de('0x67'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x4e2b83,null))[_0x43de('0x2c')](function(_0x3837df){var _0x4ee0f9=_[_0x43de('0x35')](_0x3837df,'id');var _0x23fe93=[];var _0x1d1249=[];var _0x4593d4=squel[_0x43de('0x71')]();_0x4593d4['field'](_0x43de('0x72'))[_0x43de('0x73')](_0x43de('0x74'),'tq')[_0x43de('0x75')]('user_has_teams','ut',_0x43de('0x76'))['where'](_0x43de('0x77'),_0x5e8711[_0x43de('0x4e')]['id']);for(var _0x1ccc9a=0x0;_0x1ccc9a<_0x3837df['length'];_0x1ccc9a+=0x1){let _0x59209a=_0x3837df[_0x1ccc9a];for(var _0x1bf10c=0x0;_0x1bf10c<_0x59209a[_0x43de('0x67')][_0x43de('0x40')];_0x1bf10c+=0x1){let _0x435e40=_0x59209a[_0x43de('0x67')][_0x1bf10c];var _0x56fd99=_0x4593d4['clone']();_0x56fd99[_0x43de('0x44')](_0x43de('0x78'),_0x435e40['id']);_0x1d1249[_0x43de('0x79')](db[_0x43de('0x6b')]['query'](_0x56fd99['toString'](),{'type':db['sequelize']['QueryTypes'][_0x43de('0x7a')]})['then'](function(_0x40610c){if(_0x40610c[_0x43de('0x40')]===0x1){return _0x435e40['id'];}else{var _0x1b1c3f=_[_0x43de('0x7b')](_[_0x43de('0x35')](_0x40610c,_0x43de('0x7c')),function(_0xfa10f0){return _['includes'](_0x4ee0f9,_0xfa10f0);});if(_0x1b1c3f){return _0x435e40['id'];}}}));}}return BPromise[_0x43de('0x7d')](_0x1d1249)[_0x43de('0x2c')](function(_0x4df3a3){_0x23fe93=_(_0x23fe93)[_0x43de('0x7e')](_0x4df3a3)['compact']()['value']();return db['WhatsappQueue'][_0x43de('0x4f')]({'where':{'id':_0x5e8711['params']['id']}})['then'](function(_0x36919e){return db['sequelize'][_0x43de('0x7f')](function(_0x2b29ab){return _0x36919e['removeTeams'](_0x5e8711['query'][_0x43de('0x66')],{'transaction':_0x2b29ab})['then'](function(){if(!_[_0x43de('0x80')](_0x23fe93)){return _0x36919e['removeAgents'](_0x23fe93,{'transaction':_0x2b29ab});}})[_0x43de('0x2c')](function(){_0x23fe93['forEach'](function(_0x565253){socket[_0x43de('0x6e')](_0x43de('0x81'),{'UserId':_0x565253,'WhatsappQueueId':_0x36919e['id']});});});});});});})[_0x43de('0x2c')](respondWithStatusCode(_0x4e2b83,null))['catch'](handleError(_0x4e2b83,null));};exports[_0x43de('0x82')]=function(_0x3a25a6,_0x36aa33,_0x406095){return db[_0x43de('0x4b')][_0x43de('0x4f')]({'where':{'id':_0x3a25a6[_0x43de('0x4e')]['id']}})['then'](handleEntityNotFound(_0x36aa33,null))['then'](function(_0x585c7d){if(_0x585c7d){return _0x585c7d[_0x43de('0x82')](_0x3a25a6[_0x43de('0x51')][_0x43de('0x66')],_[_0x43de('0x83')](_0x3a25a6['body'],[_0x43de('0x66'),'id'])||{})['spread'](function(_0x27a844){for(var _0x4c2fce=0x0;_0x4c2fce<_0x3a25a6[_0x43de('0x51')][_0x43de('0x66')][_0x43de('0x40')];_0x4c2fce+=0x1){socket[_0x43de('0x6e')](_0x43de('0x6f'),{'UserId':Number(_0x3a25a6[_0x43de('0x51')][_0x43de('0x66')][_0x4c2fce]),'WhatsappQueueId':Number(_0x3a25a6[_0x43de('0x4e')]['id'])});}return _0x27a844;});}})['then'](respondWithResult(_0x36aa33,null))[_0x43de('0x4d')](handleError(_0x36aa33,null));};exports[_0x43de('0x84')]=function(_0xaa1e8b,_0x5ac2b6,_0x50fb30){return db[_0x43de('0x4b')][_0x43de('0x4f')]({'where':{'id':_0xaa1e8b[_0x43de('0x4e')]['id']}})[_0x43de('0x2c')](handleEntityNotFound(_0x5ac2b6,null))[_0x43de('0x2c')](function(_0x438e24){if(_0x438e24){return _0x438e24['removeAgents'](_0xaa1e8b[_0x43de('0x3a')]['ids'])[_0x43de('0x2c')](function(){if(_[_0x43de('0x85')](_0xaa1e8b[_0x43de('0x3a')][_0x43de('0x66')])){for(var _0x1a893b=0x0;_0x1a893b<_0xaa1e8b[_0x43de('0x3a')][_0x43de('0x66')][_0x43de('0x40')];_0x1a893b+=0x1){socket[_0x43de('0x6e')](_0x43de('0x81'),{'UserId':Number(_0xaa1e8b[_0x43de('0x3a')]['ids'][_0x1a893b]),'WhatsappQueueId':Number(_0xaa1e8b[_0x43de('0x4e')]['id'])});}}else{socket[_0x43de('0x6e')](_0x43de('0x81'),{'UserId':Number(_0xaa1e8b[_0x43de('0x3a')][_0x43de('0x66')]),'WhatsappQueueId':Number(_0xaa1e8b[_0x43de('0x4e')]['id'])});}});}})[_0x43de('0x2c')](respondWithStatusCode(_0x5ac2b6,null))[_0x43de('0x4d')](handleError(_0x5ac2b6,null));};exports['getAgents']=function(_0xe40b8d,_0x4e629b,_0xf9156d){var _0x5524e8={};var _0x1bd65b={};var _0x555340;var _0x134a6e;return db[_0x43de('0x4b')][_0x43de('0x63')]({'where':{'id':_0xe40b8d[_0x43de('0x4e')]['id']}})['then'](handleEntityNotFound(_0x4e629b,null))[_0x43de('0x2c')](function(_0x3abf20){if(_0x3abf20){_0x555340=_0x3abf20;_0x1bd65b[_0x43de('0x39')]=_[_0x43de('0x3b')](db[_0x43de('0x59')][_0x43de('0x36')]);_0x1bd65b['query']=_[_0x43de('0x3b')](_0xe40b8d['query']);_0x1bd65b['filters']=_['intersection'](_0x1bd65b[_0x43de('0x39')],_0x1bd65b[_0x43de('0x3a')]);_0x5524e8[_0x43de('0x3e')]=_[_0x43de('0x3d')](_0x1bd65b[_0x43de('0x39')],qs[_0x43de('0x3f')](_0xe40b8d['query'][_0x43de('0x3f')]));_0x5524e8['attributes']=_0x5524e8[_0x43de('0x3e')]['length']?_0x5524e8[_0x43de('0x3e')]:_0x1bd65b[_0x43de('0x39')];_0x5524e8[_0x43de('0x42')]=qs['sort'](_0xe40b8d[_0x43de('0x3a')][_0x43de('0x43')]);_0x5524e8[_0x43de('0x44')]=qs['filters'](_['pick'](_0xe40b8d[_0x43de('0x3a')],_0x1bd65b['filters']));if(_0xe40b8d[_0x43de('0x3a')]['filter']){_0x5524e8[_0x43de('0x44')]=_[_0x43de('0x46')](_0x5524e8[_0x43de('0x44')],{'$or':_[_0x43de('0x35')](_0x5524e8[_0x43de('0x3e')],function(_0x107a60){var _0x2c8f2e={};_0x2c8f2e[_0x107a60]={'$like':'%'+_0xe40b8d[_0x43de('0x3a')][_0x43de('0x48')]+'%'};return _0x2c8f2e;})});}_0x5524e8=_['merge']({},_0x5524e8,_0xe40b8d[_0x43de('0x49')]);return _0x555340[_0x43de('0x86')](_0x5524e8);}})[_0x43de('0x2c')](function(_0x4fe42a){if(_0x4fe42a){_0x134a6e=_0x4fe42a[_0x43de('0x40')];if(!_0xe40b8d[_0x43de('0x3a')][_0x43de('0x64')](_0x43de('0x41'))){_0x5524e8[_0x43de('0x23')]=qs[_0x43de('0x23')](_0xe40b8d[_0x43de('0x3a')][_0x43de('0x23')]);_0x5524e8[_0x43de('0x24')]=qs[_0x43de('0x24')](_0xe40b8d['query'][_0x43de('0x24')]);}return _0x555340[_0x43de('0x86')](_0x5524e8);}})[_0x43de('0x2c')](function(_0x14eb44){if(_0x14eb44){return _0x14eb44?{'count':_0x134a6e,'rows':_0x14eb44}:null;}})[_0x43de('0x2c')](respondWithResult(_0x4e629b,null))[_0x43de('0x4d')](handleError(_0x4e629b,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