Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 16a7974..d1b0ee9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbf89=['apply','reject','save','update','then','get','WhatsappQueues','UserProfileResource','stack','name','send','map','WhatsappQueue','rawAttributes','fieldName','type','keys','filters','model','query','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','count','findAll','catch','show','params','intersection','includeAll','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','describe','findOne','UserWhatsappQueue','User','UserId','whatsappPause','rows','format','%s/%s','SIP','updatedAt','Team','getTeams','addTeams','ids','Agents','online','voicePause','interface','flatMap','transaction','each','findOrCreate','forEach','emit','userWhatsappQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_whatsapp_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','userWhatsappQueue:remove','addAgents','omit','removeAgents','getAgents','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','querystring','papaparse','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','end','offset','limit','set','Content-Range','json'];(function(_0x150f12,_0x2db65b){var _0x43e945=function(_0x68bdd2){while(--_0x68bdd2){_0x150f12['push'](_0x150f12['shift']());}};_0x43e945(++_0x2db65b);}(_0xbf89,0x69));var _0x9bf8=function(_0x1c6551,_0x3fbc2e){_0x1c6551=_0x1c6551-0x0;var _0x3f7434=_0xbf89[_0x1c6551];return _0x3f7434;};'use strict';var pdf=require(_0x9bf8('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x9bf8('0x1'));var zipdir=require(_0x9bf8('0x2'));var jsonpatch=require(_0x9bf8('0x3'));var rp=require(_0x9bf8('0x4'));var moment=require(_0x9bf8('0x5'));var BPromise=require(_0x9bf8('0x6'));var Mustache=require(_0x9bf8('0x7'));var util=require('util');var path=require(_0x9bf8('0x8'));var sox=require(_0x9bf8('0x9'));var csv=require(_0x9bf8('0xa'));var ejs=require(_0x9bf8('0xb'));var fs=require('fs');var _=require(_0x9bf8('0xc'));var squel=require(_0x9bf8('0xd'));var crypto=require(_0x9bf8('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x9bf8('0xa'));var querystring=require(_0x9bf8('0xf'));var Papa=require(_0x9bf8('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9bf8('0x11'));var logger=require(_0x9bf8('0x12'))(_0x9bf8('0x13'));var utils=require(_0x9bf8('0x14'));var config=require(_0x9bf8('0x15'));var licenseUtil=require(_0x9bf8('0x16'));var db=require(_0x9bf8('0x17'))['db'];config[_0x9bf8('0x18')]=_['defaults'](config['redis'],{'host':_0x9bf8('0x19'),'port':0x18eb});var socket=require(_0x9bf8('0x1a'))(new Redis(config[_0x9bf8('0x18')]));require('./whatsappQueue.socket')[_0x9bf8('0x1b')](socket);function respondWithStatusCode(_0xd93bda,_0x4a19e5){_0x4a19e5=_0x4a19e5||0xcc;return function(_0x44954c){if(_0x44954c){return _0xd93bda[_0x9bf8('0x1c')](_0x4a19e5);}return _0xd93bda[_0x9bf8('0x1d')](_0x4a19e5)[_0x9bf8('0x1e')]();};}function respondWithResult(_0x3afe7f,_0x5c4086){_0x5c4086=_0x5c4086||0xc8;return function(_0x397b63){if(_0x397b63){return _0x3afe7f[_0x9bf8('0x1d')](_0x5c4086)['json'](_0x397b63);}};}function respondWithFilteredResult(_0x4605a3,_0x5bb626){return function(_0x11c9a6){if(_0x11c9a6){var _0x632877=_0x11c9a6['count'],_0x2a5972=_0x5bb626[_0x9bf8('0x1f')],_0x2369dd=_0x5bb626[_0x9bf8('0x1f')]+_0x5bb626[_0x9bf8('0x20')],_0x530545;if(_0x2369dd>=_0x632877){_0x2369dd=_0x632877;_0x530545=0xc8;}else{_0x530545=0xce;}_0x4605a3['status'](_0x530545);return _0x4605a3[_0x9bf8('0x21')](_0x9bf8('0x22'),_0x2a5972+'-'+_0x2369dd+'/'+_0x632877)[_0x9bf8('0x23')](_0x11c9a6);}return null;};}function patchUpdates(_0x4edb1f){return function(_0x1e823a){try{jsonpatch[_0x9bf8('0x24')](_0x1e823a,_0x4edb1f,!![]);}catch(_0x4142ab){return BPromise[_0x9bf8('0x25')](_0x4142ab);}return _0x1e823a[_0x9bf8('0x26')]();};}function saveUpdates(_0x33e734,_0x44c4a9){return function(_0x4f2ccd){if(_0x4f2ccd){return _0x4f2ccd[_0x9bf8('0x27')](_0x33e734)[_0x9bf8('0x28')](function(_0x21b51f){return _0x21b51f;});}return null;};}function removeEntity(_0x48ba76,_0x46860f){return function(_0x2503cc){if(_0x2503cc){return _0x2503cc['destroy']()['then'](function(){var _0x1d5cc8=_0x2503cc[_0x9bf8('0x29')]({'plain':!![]});var _0x3f1fd1=_0x9bf8('0x2a');return db[_0x9bf8('0x2b')]['destroy']({'where':{'type':_0x3f1fd1,'resourceId':_0x1d5cc8['id']}})[_0x9bf8('0x28')](function(){return _0x2503cc;});})[_0x9bf8('0x28')](function(){_0x48ba76[_0x9bf8('0x1d')](0xcc)[_0x9bf8('0x1e')]();});}};}function handleEntityNotFound(_0x47b06f,_0x1c99b){return function(_0x12d340){if(!_0x12d340){_0x47b06f[_0x9bf8('0x1c')](0x194);}return _0x12d340;};}function handleError(_0x2be3b3,_0x31d3c2){_0x31d3c2=_0x31d3c2||0x1f4;return function(_0x5771d7){logger['error'](_0x5771d7[_0x9bf8('0x2c')]);if(_0x5771d7[_0x9bf8('0x2d')]){delete _0x5771d7['name'];}_0x2be3b3['status'](_0x31d3c2)[_0x9bf8('0x2e')](_0x5771d7);};}exports['index']=function(_0x53c58e,_0xfae614){var _0x714258={},_0x6804ca={},_0x25e104={'count':0x0,'rows':[]};var _0x4af676=_[_0x9bf8('0x2f')](db[_0x9bf8('0x30')][_0x9bf8('0x31')],function(_0x30cec7){return{'name':_0x30cec7[_0x9bf8('0x32')],'type':_0x30cec7[_0x9bf8('0x33')]['key']};});_0x6804ca['model']=_[_0x9bf8('0x2f')](_0x4af676,_0x9bf8('0x2d'));_0x6804ca['query']=_[_0x9bf8('0x34')](_0x53c58e['query']);_0x6804ca[_0x9bf8('0x35')]=_['intersection'](_0x6804ca[_0x9bf8('0x36')],_0x6804ca[_0x9bf8('0x37')]);_0x714258['attributes']=_['intersection'](_0x6804ca[_0x9bf8('0x36')],qs[_0x9bf8('0x38')](_0x53c58e[_0x9bf8('0x37')][_0x9bf8('0x38')]));_0x714258[_0x9bf8('0x39')]=_0x714258[_0x9bf8('0x39')][_0x9bf8('0x3a')]?_0x714258[_0x9bf8('0x39')]:_0x6804ca[_0x9bf8('0x36')];if(!_0x53c58e[_0x9bf8('0x37')][_0x9bf8('0x3b')](_0x9bf8('0x3c'))){_0x714258[_0x9bf8('0x20')]=qs[_0x9bf8('0x20')](_0x53c58e[_0x9bf8('0x37')]['limit']);_0x714258[_0x9bf8('0x1f')]=qs[_0x9bf8('0x1f')](_0x53c58e[_0x9bf8('0x37')][_0x9bf8('0x1f')]);}_0x714258[_0x9bf8('0x3d')]=qs[_0x9bf8('0x3e')](_0x53c58e['query'][_0x9bf8('0x3e')]);_0x714258[_0x9bf8('0x3f')]=qs['filters'](_['pick'](_0x53c58e[_0x9bf8('0x37')],_0x6804ca[_0x9bf8('0x35')]),_0x4af676);if(_0x53c58e[_0x9bf8('0x37')][_0x9bf8('0x40')]){_0x714258[_0x9bf8('0x3f')]=_[_0x9bf8('0x41')](_0x714258[_0x9bf8('0x3f')],{'$or':_[_0x9bf8('0x2f')](_0x4af676,function(_0x37b5b4){if(_0x37b5b4[_0x9bf8('0x33')]!==_0x9bf8('0x42')){var _0x22fd62={};_0x22fd62[_0x37b5b4[_0x9bf8('0x2d')]]={'$like':'%'+_0x53c58e[_0x9bf8('0x37')][_0x9bf8('0x40')]+'%'};return _0x22fd62;}})});}_0x714258=_['merge']({},_0x714258,_0x53c58e[_0x9bf8('0x43')]);var _0x53288a={'where':_0x714258[_0x9bf8('0x3f')]};return db['WhatsappQueue'][_0x9bf8('0x44')](_0x53288a)[_0x9bf8('0x28')](function(_0x2fb37a){_0x25e104[_0x9bf8('0x44')]=_0x2fb37a;if(_0x53c58e[_0x9bf8('0x37')]['includeAll']){_0x714258['include']=[{'all':!![]}];}return db[_0x9bf8('0x30')][_0x9bf8('0x45')](_0x714258);})['then'](function(_0x4ec0fb){_0x25e104['rows']=_0x4ec0fb;return _0x25e104;})[_0x9bf8('0x28')](respondWithFilteredResult(_0xfae614,_0x714258))[_0x9bf8('0x46')](handleError(_0xfae614,null));};exports[_0x9bf8('0x47')]=function(_0x2e28d6,_0x5d1026){var _0x4cefda={'raw':!![],'where':{'id':_0x2e28d6[_0x9bf8('0x48')]['id']}},_0x2d9f3d={};_0x2d9f3d[_0x9bf8('0x36')]=_[_0x9bf8('0x34')](db[_0x9bf8('0x30')][_0x9bf8('0x31')]);_0x2d9f3d[_0x9bf8('0x37')]=_[_0x9bf8('0x34')](_0x2e28d6[_0x9bf8('0x37')]);_0x2d9f3d[_0x9bf8('0x35')]=_[_0x9bf8('0x49')](_0x2d9f3d['model'],_0x2d9f3d[_0x9bf8('0x37')]);_0x4cefda[_0x9bf8('0x39')]=_[_0x9bf8('0x49')](_0x2d9f3d[_0x9bf8('0x36')],qs[_0x9bf8('0x38')](_0x2e28d6['query']['fields']));_0x4cefda[_0x9bf8('0x39')]=_0x4cefda[_0x9bf8('0x39')][_0x9bf8('0x3a')]?_0x4cefda['attributes']:_0x2d9f3d[_0x9bf8('0x36')];if(_0x2e28d6[_0x9bf8('0x37')][_0x9bf8('0x4a')]){_0x4cefda[_0x9bf8('0x4b')]=[{'all':!![]}];}_0x4cefda=_[_0x9bf8('0x41')]({},_0x4cefda,_0x2e28d6[_0x9bf8('0x43')]);return db[_0x9bf8('0x30')][_0x9bf8('0x4c')](_0x4cefda)[_0x9bf8('0x28')](handleEntityNotFound(_0x5d1026,null))[_0x9bf8('0x28')](respondWithResult(_0x5d1026,null))[_0x9bf8('0x46')](handleError(_0x5d1026,null));};exports['create']=function(_0x53be26,_0x31313e){return db[_0x9bf8('0x30')][_0x9bf8('0x4d')](_0x53be26[_0x9bf8('0x4e')],{})[_0x9bf8('0x28')](function(_0x337642){var _0xa44ceb=_0x53be26[_0x9bf8('0x4f')][_0x9bf8('0x29')]({'plain':!![]});if(!_0xa44ceb)throw new Error(_0x9bf8('0x50'));if(_0xa44ceb[_0x9bf8('0x51')]==='user'){var _0x43007c=_0x337642['get']({'plain':!![]});var _0x4c41ff='WhatsappQueues';return db[_0x9bf8('0x52')][_0x9bf8('0x4c')]({'where':{'name':_0x4c41ff,'userProfileId':_0xa44ceb['userProfileId']},'raw':!![]})[_0x9bf8('0x28')](function(_0x112b95){if(_0x112b95&&_0x112b95[_0x9bf8('0x53')]===0x0){return db[_0x9bf8('0x2b')][_0x9bf8('0x4d')]({'name':_0x43007c['name'],'resourceId':_0x43007c['id'],'type':_0x112b95[_0x9bf8('0x2d')],'sectionId':_0x112b95['id']},{})[_0x9bf8('0x28')](function(){return _0x337642;});}else{return _0x337642;}})[_0x9bf8('0x46')](function(_0x3a4cec){logger[_0x9bf8('0x54')](_0x9bf8('0x55'),_0x3a4cec);throw _0x3a4cec;});}return _0x337642;})[_0x9bf8('0x28')](respondWithResult(_0x31313e,0xc9))[_0x9bf8('0x46')](handleError(_0x31313e,null));};exports[_0x9bf8('0x27')]=function(_0x88fef3,_0x5d99d2){if(_0x88fef3[_0x9bf8('0x4e')]['id']){delete _0x88fef3[_0x9bf8('0x4e')]['id'];}return db[_0x9bf8('0x30')]['find']({'where':{'id':_0x88fef3[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](handleEntityNotFound(_0x5d99d2,null))['then'](saveUpdates(_0x88fef3[_0x9bf8('0x4e')],null))['then'](respondWithResult(_0x5d99d2,null))['catch'](handleError(_0x5d99d2,null));};exports[_0x9bf8('0x56')]=function(_0x439917,_0x20767b){return db[_0x9bf8('0x30')][_0x9bf8('0x4c')]({'where':{'id':_0x439917[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](handleEntityNotFound(_0x20767b,null))[_0x9bf8('0x28')](removeEntity(_0x20767b,null))['catch'](handleError(_0x20767b,null));};exports[_0x9bf8('0x57')]=function(_0x2ba1b4,_0xc0e0be){return db[_0x9bf8('0x30')][_0x9bf8('0x57')]()[_0x9bf8('0x28')](respondWithResult(_0xc0e0be,null))[_0x9bf8('0x46')](handleError(_0xc0e0be,null));};exports['getMembers']=function(_0x3afa5a,_0x25443f,_0x30fc43){var _0x238412={'raw':!![],'where':{}},_0x8bccf6={},_0x2dad8e;return db['WhatsappQueue'][_0x9bf8('0x58')]({'where':{'id':_0x3afa5a[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](handleEntityNotFound(_0x25443f,null))['then'](function(_0x584f68){if(_0x584f68){_0x2dad8e=_0x584f68[_0x9bf8('0x29')]({'plain':!![]});_0x8bccf6['model']=_[_0x9bf8('0x34')](db[_0x9bf8('0x59')]['rawAttributes']);_0x8bccf6[_0x9bf8('0x37')]=_['keys'](_0x3afa5a[_0x9bf8('0x37')]);_0x8bccf6['filters']=_[_0x9bf8('0x49')](_0x8bccf6['model'],_0x8bccf6[_0x9bf8('0x37')]);_0x238412[_0x9bf8('0x39')]=_[_0x9bf8('0x49')](_0x8bccf6[_0x9bf8('0x36')],qs[_0x9bf8('0x38')](_0x3afa5a['query'][_0x9bf8('0x38')]));_0x238412[_0x9bf8('0x39')]=_0x238412['attributes'][_0x9bf8('0x3a')]?_0x238412[_0x9bf8('0x39')]:_0x8bccf6[_0x9bf8('0x36')];if(!_0x3afa5a[_0x9bf8('0x37')][_0x9bf8('0x3b')](_0x9bf8('0x3c'))){_0x238412[_0x9bf8('0x20')]=qs[_0x9bf8('0x20')](_0x3afa5a['query'][_0x9bf8('0x20')]);_0x238412[_0x9bf8('0x1f')]=qs['offset'](_0x3afa5a['query'][_0x9bf8('0x1f')]);}_0x238412[_0x9bf8('0x3d')]=qs[_0x9bf8('0x3e')](_0x3afa5a[_0x9bf8('0x37')]['sort']);_0x238412[_0x9bf8('0x3f')]=qs[_0x9bf8('0x35')](_['pick'](_0x3afa5a[_0x9bf8('0x37')],_0x8bccf6['filters']));_0x238412[_0x9bf8('0x3f')]['WhatsappQueueId']=_0x584f68['id'];if(_0x3afa5a[_0x9bf8('0x37')]['filter']){_0x238412[_0x9bf8('0x3f')]=_[_0x9bf8('0x41')](_0x238412[_0x9bf8('0x3f')],{'$or':_[_0x9bf8('0x2f')](_0x238412['attributes'],function(_0x553977){var _0x5c6d07={};_0x5c6d07[_0x553977]={'$like':'%'+_0x3afa5a[_0x9bf8('0x37')][_0x9bf8('0x40')]+'%'};return _0x5c6d07;})});}_0x238412=_[_0x9bf8('0x41')]({},_0x238412,_0x3afa5a[_0x9bf8('0x43')]);return db['UserWhatsappQueue']['findAll'](_0x238412);}})[_0x9bf8('0x28')](function(_0xedf9d1){if(_0xedf9d1){return db[_0x9bf8('0x5a')]['findAndCountAll']({'where':{'id':_[_0x9bf8('0x2f')](_0xedf9d1,_0x9bf8('0x5b')),'role':'agent'},'attributes':['id','name',_0x9bf8('0x5c'),'updatedAt','createdAt']});}})[_0x9bf8('0x28')](function(_0x69f85f){if(_0x69f85f){return{'count':_0x69f85f[_0x9bf8('0x44')],'rows':_[_0x9bf8('0x2f')](_0x69f85f[_0x9bf8('0x5d')],function(_0x417ff0){return{'membername':_0x417ff0[_0x9bf8('0x2d')],'UserId':_0x417ff0['id'],'queue_name':_0x2dad8e[_0x9bf8('0x2d')],'WhatsappQueueId':_0x2dad8e['id'],'interface':util[_0x9bf8('0x5e')](_0x9bf8('0x5f'),_0x9bf8('0x60'),_0x417ff0['name']),'penalty':0x0,'paused':_0x417ff0[_0x9bf8('0x5c')],'createdAt':_0x417ff0['createdAt'],'updatedAt':_0x417ff0[_0x9bf8('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x9bf8('0x28')](respondWithFilteredResult(_0x25443f,_0x238412))[_0x9bf8('0x46')](handleError(_0x25443f,null));};exports['getTeams']=function(_0x2dbaa0,_0x4131cc,_0x23d84f){var _0x157ae3={};var _0x21ac39={};var _0x436890;var _0xad6807;return db[_0x9bf8('0x30')][_0x9bf8('0x58')]({'where':{'id':_0x2dbaa0[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](handleEntityNotFound(_0x4131cc,null))['then'](function(_0x259ef8){if(_0x259ef8){_0x436890=_0x259ef8;_0x21ac39[_0x9bf8('0x36')]=_[_0x9bf8('0x34')](db[_0x9bf8('0x62')]['rawAttributes']);_0x21ac39[_0x9bf8('0x37')]=_['keys'](_0x2dbaa0[_0x9bf8('0x37')]);_0x21ac39['filters']=_[_0x9bf8('0x49')](_0x21ac39['model'],_0x21ac39['query']);_0x157ae3[_0x9bf8('0x39')]=_[_0x9bf8('0x49')](_0x21ac39[_0x9bf8('0x36')],qs[_0x9bf8('0x38')](_0x2dbaa0[_0x9bf8('0x37')][_0x9bf8('0x38')]));_0x157ae3['attributes']=_0x157ae3[_0x9bf8('0x39')][_0x9bf8('0x3a')]?_0x157ae3[_0x9bf8('0x39')]:_0x21ac39['model'];_0x157ae3['order']=qs[_0x9bf8('0x3e')](_0x2dbaa0[_0x9bf8('0x37')][_0x9bf8('0x3e')]);_0x157ae3[_0x9bf8('0x3f')]=qs[_0x9bf8('0x35')](_['pick'](_0x2dbaa0['query'],_0x21ac39[_0x9bf8('0x35')]));if(_0x2dbaa0['query'][_0x9bf8('0x40')]){_0x157ae3[_0x9bf8('0x3f')]=_[_0x9bf8('0x41')](_0x157ae3['where'],{'$or':_[_0x9bf8('0x2f')](_0x157ae3[_0x9bf8('0x39')],function(_0x474545){var _0x1ddb5e={};_0x1ddb5e[_0x474545]={'$like':'%'+_0x2dbaa0[_0x9bf8('0x37')]['filter']+'%'};return _0x1ddb5e;})});}_0x157ae3=_[_0x9bf8('0x41')]({},_0x157ae3,_0x2dbaa0[_0x9bf8('0x43')]);return _0x436890[_0x9bf8('0x63')](_0x157ae3);}})[_0x9bf8('0x28')](function(_0x4b8422){if(_0x4b8422){_0xad6807=_0x4b8422[_0x9bf8('0x3a')];if(!_0x2dbaa0[_0x9bf8('0x37')][_0x9bf8('0x3b')]('nolimit')){_0x157ae3['limit']=qs[_0x9bf8('0x20')](_0x2dbaa0['query'][_0x9bf8('0x20')]);_0x157ae3['offset']=qs['offset'](_0x2dbaa0['query']['offset']);}return _0x436890[_0x9bf8('0x63')](_0x157ae3);}})[_0x9bf8('0x28')](function(_0xb1f450){if(_0xb1f450){return _0xb1f450?{'count':_0xad6807,'rows':_0xb1f450}:null;}})['then'](respondWithResult(_0x4131cc,null))[_0x9bf8('0x46')](handleError(_0x4131cc,null));};exports[_0x9bf8('0x64')]=function(_0x4125aa,_0x22991c,_0x50d730){var _0x3fa569=_0x4125aa[_0x9bf8('0x4e')][_0x9bf8('0x65')];return db['Team'][_0x9bf8('0x45')]({'where':{'id':_0x3fa569},'attributes':['id'],'include':[{'model':db[_0x9bf8('0x5a')],'as':_0x9bf8('0x66'),'attributes':['id',_0x9bf8('0x2d'),_0x9bf8('0x67'),_0x9bf8('0x68'),_0x9bf8('0x69')],'raw':!![]}]})[_0x9bf8('0x28')](function(_0x5a8bc5){if(_0x5a8bc5){var _0x19087f=_[_0x9bf8('0x6a')](_0x5a8bc5,function(_0x4371d8){var _0x51e820=_0x4371d8[_0x9bf8('0x29')]({'plain':!![]});return _0x51e820[_0x9bf8('0x66')];});return db['WhatsappQueue']['find']({'where':{'id':_0x4125aa[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](function(_0x53b310){return db['sequelize'][_0x9bf8('0x6b')](function(_0xce67e8){return _0x53b310[_0x9bf8('0x64')](_0x3fa569,{'transaction':_0xce67e8})['then'](function(){return BPromise[_0x9bf8('0x6c')](_0x19087f,function(_0x5b59a2){return db[_0x9bf8('0x59')][_0x9bf8('0x6d')]({'where':{'UserId':_0x5b59a2['id'],'WhatsappQueueId':_0x4125aa['params']['id']},'transaction':_0xce67e8});});})['then'](function(){_0x19087f[_0x9bf8('0x6e')](function(_0x17e34e){socket[_0x9bf8('0x6f')](_0x9bf8('0x70'),{'UserId':_0x17e34e['id'],'WhatsappQueueId':_0x53b310['id']});});});});});}})[_0x9bf8('0x28')](respondWithStatusCode(_0x22991c,null))[_0x9bf8('0x46')](handleError(_0x22991c,null));};exports[_0x9bf8('0x71')]=function(_0x2aff91,_0xfc6894,_0x482192){return db['Team'][_0x9bf8('0x45')]({'where':{'id':_0x2aff91[_0x9bf8('0x37')][_0x9bf8('0x65')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x9bf8('0x66'),'attributes':['id'],'raw':!![]}]})[_0x9bf8('0x28')](handleEntityNotFound(_0xfc6894,null))[_0x9bf8('0x28')](function(_0x252f34){var _0x291107=_['map'](_0x252f34,'id');var _0x3de709=[];var _0x20f1af=[];var _0x2cc783=squel[_0x9bf8('0x72')]();_0x2cc783[_0x9bf8('0x73')](_0x9bf8('0x74'))[_0x9bf8('0x75')](_0x9bf8('0x76'),'tq')['join'](_0x9bf8('0x77'),'ut',_0x9bf8('0x78'))[_0x9bf8('0x3f')](_0x9bf8('0x79'),_0x2aff91['params']['id']);for(var _0x13cedd=0x0;_0x13cedd<_0x252f34[_0x9bf8('0x3a')];_0x13cedd+=0x1){let _0x39466d=_0x252f34[_0x13cedd];for(var _0x221da5=0x0;_0x221da5<_0x39466d['Agents'][_0x9bf8('0x3a')];_0x221da5+=0x1){let _0x7428ea=_0x39466d[_0x9bf8('0x66')][_0x221da5];var _0x1bdfb4=_0x2cc783['clone']();_0x1bdfb4[_0x9bf8('0x3f')](_0x9bf8('0x7a'),_0x7428ea['id']);_0x20f1af[_0x9bf8('0x7b')](db[_0x9bf8('0x7c')][_0x9bf8('0x37')](_0x1bdfb4[_0x9bf8('0x7d')](),{'type':db[_0x9bf8('0x7c')][_0x9bf8('0x7e')][_0x9bf8('0x7f')]})[_0x9bf8('0x28')](function(_0x5917bd){if(_0x5917bd[_0x9bf8('0x3a')]===0x1){return _0x7428ea['id'];}else{var _0x4e9b9b=_[_0x9bf8('0x80')](_[_0x9bf8('0x2f')](_0x5917bd,_0x9bf8('0x81')),function(_0xbdd470){return _[_0x9bf8('0x82')](_0x291107,_0xbdd470);});if(_0x4e9b9b){return _0x7428ea['id'];}}}));}}return BPromise[_0x9bf8('0x83')](_0x20f1af)[_0x9bf8('0x28')](function(_0x4b83f7){_0x3de709=_(_0x3de709)[_0x9bf8('0x84')](_0x4b83f7)[_0x9bf8('0x85')]()[_0x9bf8('0x86')]();return db[_0x9bf8('0x30')][_0x9bf8('0x4c')]({'where':{'id':_0x2aff91[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](function(_0x422f43){return db[_0x9bf8('0x7c')][_0x9bf8('0x6b')](function(_0x312c5b){return _0x422f43[_0x9bf8('0x71')](_0x2aff91[_0x9bf8('0x37')][_0x9bf8('0x65')],{'transaction':_0x312c5b})[_0x9bf8('0x28')](function(){if(!_[_0x9bf8('0x87')](_0x3de709)){return _0x422f43['removeAgents'](_0x3de709,{'transaction':_0x312c5b});}})[_0x9bf8('0x28')](function(){_0x3de709[_0x9bf8('0x6e')](function(_0x23956c){socket[_0x9bf8('0x6f')](_0x9bf8('0x88'),{'UserId':_0x23956c,'WhatsappQueueId':_0x422f43['id']});});});});});});})[_0x9bf8('0x28')](respondWithStatusCode(_0xfc6894,null))['catch'](handleError(_0xfc6894,null));};exports['addAgents']=function(_0x2568d6,_0xa7f231,_0x576033){return db[_0x9bf8('0x30')]['find']({'where':{'id':_0x2568d6[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](handleEntityNotFound(_0xa7f231,null))[_0x9bf8('0x28')](function(_0x35e6dd){if(_0x35e6dd){return _0x35e6dd[_0x9bf8('0x89')](_0x2568d6[_0x9bf8('0x4e')][_0x9bf8('0x65')],_[_0x9bf8('0x8a')](_0x2568d6[_0x9bf8('0x4e')],['ids','id'])||{})['spread'](function(_0x5f3908){for(var _0x5b12fa=0x0;_0x5b12fa<_0x2568d6[_0x9bf8('0x4e')]['ids'][_0x9bf8('0x3a')];_0x5b12fa+=0x1){socket[_0x9bf8('0x6f')](_0x9bf8('0x70'),{'UserId':_0x2568d6[_0x9bf8('0x4e')][_0x9bf8('0x65')][_0x5b12fa],'WhatsappQueueId':_0x2568d6[_0x9bf8('0x48')]['id']});}return _0x5f3908;});}})[_0x9bf8('0x28')](respondWithResult(_0xa7f231,null))[_0x9bf8('0x46')](handleError(_0xa7f231,null));};exports[_0x9bf8('0x8b')]=function(_0x42e718,_0x389ca0,_0x1156e7){return db[_0x9bf8('0x30')][_0x9bf8('0x4c')]({'where':{'id':_0x42e718[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](handleEntityNotFound(_0x389ca0,null))['then'](function(_0x492f74){if(_0x492f74){return _0x492f74[_0x9bf8('0x8b')](_0x42e718[_0x9bf8('0x37')]['ids'])[_0x9bf8('0x28')](function(){if(_['isArray'](_0x42e718[_0x9bf8('0x37')][_0x9bf8('0x65')])){for(var _0x406bea=0x0;_0x406bea<_0x42e718[_0x9bf8('0x37')][_0x9bf8('0x65')][_0x9bf8('0x3a')];_0x406bea+=0x1){socket[_0x9bf8('0x6f')](_0x9bf8('0x88'),{'UserId':Number(_0x42e718[_0x9bf8('0x37')][_0x9bf8('0x65')][_0x406bea]),'WhatsappQueueId':Number(_0x42e718['params']['id'])});}}else{socket[_0x9bf8('0x6f')]('userWhatsappQueue:remove',{'UserId':Number(_0x42e718[_0x9bf8('0x37')][_0x9bf8('0x65')]),'WhatsappQueueId':Number(_0x42e718[_0x9bf8('0x48')]['id'])});}});}})['then'](respondWithStatusCode(_0x389ca0,null))[_0x9bf8('0x46')](handleError(_0x389ca0,null));};exports[_0x9bf8('0x8c')]=function(_0x2d6571,_0x53cddd,_0x39a3ba){var _0x521489={};var _0x567e83={};var _0x125c50;var _0x26d38b;return db[_0x9bf8('0x30')][_0x9bf8('0x58')]({'where':{'id':_0x2d6571[_0x9bf8('0x48')]['id']}})[_0x9bf8('0x28')](handleEntityNotFound(_0x53cddd,null))['then'](function(_0x52cfed){if(_0x52cfed){_0x125c50=_0x52cfed;_0x567e83[_0x9bf8('0x36')]=_[_0x9bf8('0x34')](db[_0x9bf8('0x5a')]['rawAttributes']);_0x567e83[_0x9bf8('0x37')]=_[_0x9bf8('0x34')](_0x2d6571[_0x9bf8('0x37')]);_0x567e83['filters']=_[_0x9bf8('0x49')](_0x567e83[_0x9bf8('0x36')],_0x567e83[_0x9bf8('0x37')]);_0x521489[_0x9bf8('0x39')]=_[_0x9bf8('0x49')](_0x567e83[_0x9bf8('0x36')],qs[_0x9bf8('0x38')](_0x2d6571[_0x9bf8('0x37')][_0x9bf8('0x38')]));_0x521489[_0x9bf8('0x39')]=_0x521489[_0x9bf8('0x39')][_0x9bf8('0x3a')]?_0x521489[_0x9bf8('0x39')]:_0x567e83[_0x9bf8('0x36')];_0x521489[_0x9bf8('0x3d')]=qs[_0x9bf8('0x3e')](_0x2d6571[_0x9bf8('0x37')][_0x9bf8('0x3e')]);_0x521489[_0x9bf8('0x3f')]=qs[_0x9bf8('0x35')](_['pick'](_0x2d6571['query'],_0x567e83['filters']));if(_0x2d6571[_0x9bf8('0x37')][_0x9bf8('0x40')]){_0x521489[_0x9bf8('0x3f')]=_['merge'](_0x521489[_0x9bf8('0x3f')],{'$or':_[_0x9bf8('0x2f')](_0x521489[_0x9bf8('0x39')],function(_0x56acf7){var _0x3a46c9={};_0x3a46c9[_0x56acf7]={'$like':'%'+_0x2d6571['query'][_0x9bf8('0x40')]+'%'};return _0x3a46c9;})});}_0x521489=_[_0x9bf8('0x41')]({},_0x521489,_0x2d6571['options']);return _0x125c50[_0x9bf8('0x8c')](_0x521489);}})['then'](function(_0x27eb42){if(_0x27eb42){_0x26d38b=_0x27eb42[_0x9bf8('0x3a')];if(!_0x2d6571[_0x9bf8('0x37')][_0x9bf8('0x3b')](_0x9bf8('0x3c'))){_0x521489[_0x9bf8('0x20')]=qs[_0x9bf8('0x20')](_0x2d6571[_0x9bf8('0x37')]['limit']);_0x521489['offset']=qs[_0x9bf8('0x1f')](_0x2d6571['query'][_0x9bf8('0x1f')]);}return _0x125c50[_0x9bf8('0x8c')](_0x521489);}})[_0x9bf8('0x28')](function(_0x192400){if(_0x192400){return _0x192400?{'count':_0x26d38b,'rows':_0x192400}:null;}})['then'](respondWithResult(_0x53cddd,null))[_0x9bf8('0x46')](handleError(_0x53cddd,null));};
\ No newline at end of file
+var _0x4ba1=['ejs','fs-extra','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./whatsappQueue.socket','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','get','WhatsappQueues','UserProfileResource','destroy','stack','name','send','index','WhatsappQueue','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','map','VIRTUAL','include','findAll','rows','show','params','includeAll','options','find','catch','create','body','user','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserWhatsappQueue','nolimit','WhatsappQueueId','User','agent','whatsappPause','updatedAt','createdAt','format','%s/%s','SIP','findOne','Team','getTeams','addTeams','Agents','online','interface','flatMap','transaction','findOrCreate','forEach','emit','userWhatsappQueue:save','ids','select','field','from','team_has_whatsapp_queues','join','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','TeamId','includes','all','union','compact','removeTeams','isEmpty','removeAgents','userWhatsappQueue:remove','addAgents','omit','spread','isArray','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv'];(function(_0x13ce01,_0x576bb1){var _0x306c53=function(_0x533eb0){while(--_0x533eb0){_0x13ce01['push'](_0x13ce01['shift']());}};_0x306c53(++_0x576bb1);}(_0x4ba1,0x19e));var _0x14ba=function(_0x3bf83f,_0x181cac){_0x3bf83f=_0x3bf83f-0x0;var _0x22c4a9=_0x4ba1[_0x3bf83f];return _0x22c4a9;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x14ba('0x0'));var zipdir=require(_0x14ba('0x1'));var jsonpatch=require(_0x14ba('0x2'));var rp=require(_0x14ba('0x3'));var moment=require(_0x14ba('0x4'));var BPromise=require(_0x14ba('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x14ba('0x6'));var sox=require(_0x14ba('0x7'));var csv=require(_0x14ba('0x8'));var ejs=require(_0x14ba('0x9'));var fs=require('fs');var fs_extra=require(_0x14ba('0xa'));var _=require('lodash');var squel=require(_0x14ba('0xb'));var crypto=require('crypto');var jsforce=require(_0x14ba('0xc'));var deskjs=require(_0x14ba('0xd'));var toCsv=require(_0x14ba('0x8'));var querystring=require(_0x14ba('0xe'));var Papa=require(_0x14ba('0xf'));var Redis=require(_0x14ba('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x14ba('0x11'));var as=require(_0x14ba('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x14ba('0x13'))(_0x14ba('0x14'));var utils=require(_0x14ba('0x15'));var config=require(_0x14ba('0x16'));var licenseUtil=require(_0x14ba('0x17'));var db=require(_0x14ba('0x18'))['db'];config[_0x14ba('0x19')]=_[_0x14ba('0x1a')](config[_0x14ba('0x19')],{'host':_0x14ba('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x14ba('0x1c'))['register'](socket);function respondWithStatusCode(_0x26eaae,_0x387da1){_0x387da1=_0x387da1||0xcc;return function(_0x311e57){if(_0x311e57){return _0x26eaae[_0x14ba('0x1d')](_0x387da1);}return _0x26eaae[_0x14ba('0x1e')](_0x387da1)[_0x14ba('0x1f')]();};}function respondWithResult(_0x222075,_0x4b2a82){_0x4b2a82=_0x4b2a82||0xc8;return function(_0x1f1970){if(_0x1f1970){return _0x222075[_0x14ba('0x1e')](_0x4b2a82)[_0x14ba('0x20')](_0x1f1970);}};}function respondWithFilteredResult(_0x19f2ed,_0x259884){return function(_0x502a02){if(_0x502a02){var _0x2c858d=typeof _0x259884[_0x14ba('0x21')]===_0x14ba('0x22')&&typeof _0x259884[_0x14ba('0x23')]===_0x14ba('0x22');var _0x168d59=_0x502a02[_0x14ba('0x24')];var _0x300f48=_0x2c858d?0x0:_0x259884['offset'];var _0x33dcb8=_0x2c858d?_0x502a02[_0x14ba('0x24')]:_0x259884[_0x14ba('0x21')]+_0x259884['limit'];var _0x431620;if(_0x33dcb8>=_0x168d59){_0x33dcb8=_0x168d59;_0x431620=0xc8;}else{_0x431620=0xce;}_0x19f2ed[_0x14ba('0x1e')](_0x431620);return _0x19f2ed[_0x14ba('0x25')](_0x14ba('0x26'),_0x300f48+'-'+_0x33dcb8+'/'+_0x168d59)[_0x14ba('0x20')](_0x502a02);}return null;};}function patchUpdates(_0x422af2){return function(_0x2c2ed1){try{jsonpatch['apply'](_0x2c2ed1,_0x422af2,!![]);}catch(_0x190e29){return BPromise[_0x14ba('0x27')](_0x190e29);}return _0x2c2ed1[_0x14ba('0x28')]();};}function saveUpdates(_0x4f6e6b,_0x20e165){return function(_0x5d4e84){if(_0x5d4e84){return _0x5d4e84[_0x14ba('0x29')](_0x4f6e6b)[_0x14ba('0x2a')](function(_0x3830b8){return _0x3830b8;});}return null;};}function removeEntity(_0x17be86,_0x304840){return function(_0x5a8b5f){if(_0x5a8b5f){return _0x5a8b5f['destroy']()['then'](function(){var _0x4277d5=_0x5a8b5f[_0x14ba('0x2b')]({'plain':!![]});var _0x34d409=_0x14ba('0x2c');return db[_0x14ba('0x2d')][_0x14ba('0x2e')]({'where':{'type':_0x34d409,'resourceId':_0x4277d5['id']}})[_0x14ba('0x2a')](function(){return _0x5a8b5f;});})[_0x14ba('0x2a')](function(){_0x17be86[_0x14ba('0x1e')](0xcc)[_0x14ba('0x1f')]();});}};}function handleEntityNotFound(_0x3765ba,_0x42b30c){return function(_0x567a1b){if(!_0x567a1b){_0x3765ba['sendStatus'](0x194);}return _0x567a1b;};}function handleError(_0x24ec85,_0x4e70ca){_0x4e70ca=_0x4e70ca||0x1f4;return function(_0x34ab6a){logger['error'](_0x34ab6a[_0x14ba('0x2f')]);if(_0x34ab6a[_0x14ba('0x30')]){delete _0x34ab6a[_0x14ba('0x30')];}_0x24ec85[_0x14ba('0x1e')](_0x4e70ca)[_0x14ba('0x31')](_0x34ab6a);};}exports[_0x14ba('0x32')]=function(_0x212c73,_0x44db11){var _0x1d28fd={},_0x2f71ae={},_0x4dd916={'count':0x0,'rows':[]};var _0x569dd9=_['map'](db[_0x14ba('0x33')][_0x14ba('0x34')],function(_0x48e210){return{'name':_0x48e210[_0x14ba('0x35')],'type':_0x48e210[_0x14ba('0x36')][_0x14ba('0x37')]};});_0x2f71ae['model']=_['map'](_0x569dd9,_0x14ba('0x30'));_0x2f71ae[_0x14ba('0x38')]=_[_0x14ba('0x39')](_0x212c73[_0x14ba('0x38')]);_0x2f71ae[_0x14ba('0x3a')]=_[_0x14ba('0x3b')](_0x2f71ae[_0x14ba('0x3c')],_0x2f71ae[_0x14ba('0x38')]);_0x1d28fd[_0x14ba('0x3d')]=_[_0x14ba('0x3b')](_0x2f71ae[_0x14ba('0x3c')],qs[_0x14ba('0x3e')](_0x212c73[_0x14ba('0x38')][_0x14ba('0x3e')]));_0x1d28fd['attributes']=_0x1d28fd['attributes'][_0x14ba('0x3f')]?_0x1d28fd[_0x14ba('0x3d')]:_0x2f71ae[_0x14ba('0x3c')];if(!_0x212c73[_0x14ba('0x38')][_0x14ba('0x40')]('nolimit')){_0x1d28fd[_0x14ba('0x23')]=qs[_0x14ba('0x23')](_0x212c73['query'][_0x14ba('0x23')]);_0x1d28fd[_0x14ba('0x21')]=qs['offset'](_0x212c73[_0x14ba('0x38')]['offset']);}_0x1d28fd[_0x14ba('0x41')]=qs[_0x14ba('0x42')](_0x212c73[_0x14ba('0x38')][_0x14ba('0x42')]);_0x1d28fd[_0x14ba('0x43')]=qs[_0x14ba('0x3a')](_[_0x14ba('0x44')](_0x212c73['query'],_0x2f71ae[_0x14ba('0x3a')]),_0x569dd9);if(_0x212c73[_0x14ba('0x38')][_0x14ba('0x45')]){_0x1d28fd['where']=_[_0x14ba('0x46')](_0x1d28fd[_0x14ba('0x43')],{'$or':_[_0x14ba('0x47')](_0x569dd9,function(_0x5b2f16){if(_0x5b2f16[_0x14ba('0x36')]!==_0x14ba('0x48')){var _0x4b79f7={};_0x4b79f7[_0x5b2f16['name']]={'$like':'%'+_0x212c73['query']['filter']+'%'};return _0x4b79f7;}})});}_0x1d28fd=_[_0x14ba('0x46')]({},_0x1d28fd,_0x212c73['options']);var _0x913ff1={'where':_0x1d28fd['where']};return db[_0x14ba('0x33')][_0x14ba('0x24')](_0x913ff1)[_0x14ba('0x2a')](function(_0x2b8c47){_0x4dd916[_0x14ba('0x24')]=_0x2b8c47;if(_0x212c73[_0x14ba('0x38')]['includeAll']){_0x1d28fd[_0x14ba('0x49')]=[{'all':!![]}];}return db[_0x14ba('0x33')][_0x14ba('0x4a')](_0x1d28fd);})[_0x14ba('0x2a')](function(_0xa0e813){_0x4dd916[_0x14ba('0x4b')]=_0xa0e813;return _0x4dd916;})[_0x14ba('0x2a')](respondWithFilteredResult(_0x44db11,_0x1d28fd))['catch'](handleError(_0x44db11,null));};exports[_0x14ba('0x4c')]=function(_0xd95729,_0x1a88fa){var _0x31b20b={'raw':!![],'where':{'id':_0xd95729[_0x14ba('0x4d')]['id']}},_0x160a6d={};_0x160a6d[_0x14ba('0x3c')]=_[_0x14ba('0x39')](db[_0x14ba('0x33')]['rawAttributes']);_0x160a6d[_0x14ba('0x38')]=_[_0x14ba('0x39')](_0xd95729['query']);_0x160a6d['filters']=_[_0x14ba('0x3b')](_0x160a6d[_0x14ba('0x3c')],_0x160a6d[_0x14ba('0x38')]);_0x31b20b[_0x14ba('0x3d')]=_[_0x14ba('0x3b')](_0x160a6d[_0x14ba('0x3c')],qs[_0x14ba('0x3e')](_0xd95729[_0x14ba('0x38')]['fields']));_0x31b20b[_0x14ba('0x3d')]=_0x31b20b[_0x14ba('0x3d')][_0x14ba('0x3f')]?_0x31b20b[_0x14ba('0x3d')]:_0x160a6d[_0x14ba('0x3c')];if(_0xd95729[_0x14ba('0x38')][_0x14ba('0x4e')]){_0x31b20b[_0x14ba('0x49')]=[{'all':!![]}];}_0x31b20b=_['merge']({},_0x31b20b,_0xd95729[_0x14ba('0x4f')]);return db['WhatsappQueue'][_0x14ba('0x50')](_0x31b20b)['then'](handleEntityNotFound(_0x1a88fa,null))[_0x14ba('0x2a')](respondWithResult(_0x1a88fa,null))[_0x14ba('0x51')](handleError(_0x1a88fa,null));};exports[_0x14ba('0x52')]=function(_0x5b1a45,_0x2d3eaa){return db['WhatsappQueue']['create'](_0x5b1a45[_0x14ba('0x53')],{})[_0x14ba('0x2a')](function(_0x35d943){var _0x30cf6e=_0x5b1a45['user']['get']({'plain':!![]});if(!_0x30cf6e)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x30cf6e['role']===_0x14ba('0x54')){var _0x156e3b=_0x35d943[_0x14ba('0x2b')]({'plain':!![]});var _0x48490a=_0x14ba('0x2c');return db['UserProfileSection'][_0x14ba('0x50')]({'where':{'name':_0x48490a,'userProfileId':_0x30cf6e[_0x14ba('0x55')]},'raw':!![]})[_0x14ba('0x2a')](function(_0x34a175){if(_0x34a175&&_0x34a175['autoAssociation']===0x0){return db[_0x14ba('0x2d')]['create']({'name':_0x156e3b[_0x14ba('0x30')],'resourceId':_0x156e3b['id'],'type':_0x34a175[_0x14ba('0x30')],'sectionId':_0x34a175['id']},{})[_0x14ba('0x2a')](function(){return _0x35d943;});}else{return _0x35d943;}})[_0x14ba('0x51')](function(_0x4225c7){logger[_0x14ba('0x56')](_0x14ba('0x57'),_0x4225c7);throw _0x4225c7;});}return _0x35d943;})[_0x14ba('0x2a')](respondWithResult(_0x2d3eaa,0xc9))[_0x14ba('0x51')](handleError(_0x2d3eaa,null));};exports[_0x14ba('0x29')]=function(_0x722544,_0x41cde9){if(_0x722544[_0x14ba('0x53')]['id']){delete _0x722544['body']['id'];}return db[_0x14ba('0x33')][_0x14ba('0x50')]({'where':{'id':_0x722544[_0x14ba('0x4d')]['id']}})[_0x14ba('0x2a')](handleEntityNotFound(_0x41cde9,null))[_0x14ba('0x2a')](saveUpdates(_0x722544[_0x14ba('0x53')],null))[_0x14ba('0x2a')](respondWithResult(_0x41cde9,null))['catch'](handleError(_0x41cde9,null));};exports[_0x14ba('0x2e')]=function(_0x2a7916,_0x39c27f){return db[_0x14ba('0x33')]['find']({'where':{'id':_0x2a7916['params']['id']}})[_0x14ba('0x2a')](handleEntityNotFound(_0x39c27f,null))[_0x14ba('0x2a')](removeEntity(_0x39c27f,null))[_0x14ba('0x51')](handleError(_0x39c27f,null));};exports[_0x14ba('0x58')]=function(_0x5e95c6,_0x2ed532){return db[_0x14ba('0x33')][_0x14ba('0x58')]()[_0x14ba('0x2a')](respondWithResult(_0x2ed532,null))['catch'](handleError(_0x2ed532,null));};exports[_0x14ba('0x59')]=function(_0x46607f,_0x2283a4,_0x9e61c7){var _0x29789a={'raw':!![],'where':{}},_0x4d157a={},_0x233aff;return db[_0x14ba('0x33')]['findOne']({'where':{'id':_0x46607f['params']['id']}})[_0x14ba('0x2a')](handleEntityNotFound(_0x2283a4,null))[_0x14ba('0x2a')](function(_0x209459){if(_0x209459){_0x233aff=_0x209459[_0x14ba('0x2b')]({'plain':!![]});_0x4d157a[_0x14ba('0x3c')]=_[_0x14ba('0x39')](db[_0x14ba('0x5a')][_0x14ba('0x34')]);_0x4d157a[_0x14ba('0x38')]=_[_0x14ba('0x39')](_0x46607f['query']);_0x4d157a[_0x14ba('0x3a')]=_[_0x14ba('0x3b')](_0x4d157a[_0x14ba('0x3c')],_0x4d157a['query']);_0x29789a[_0x14ba('0x3d')]=_[_0x14ba('0x3b')](_0x4d157a['model'],qs['fields'](_0x46607f[_0x14ba('0x38')]['fields']));_0x29789a[_0x14ba('0x3d')]=_0x29789a[_0x14ba('0x3d')]['length']?_0x29789a[_0x14ba('0x3d')]:_0x4d157a[_0x14ba('0x3c')];if(!_0x46607f[_0x14ba('0x38')][_0x14ba('0x40')](_0x14ba('0x5b'))){_0x29789a['limit']=qs[_0x14ba('0x23')](_0x46607f['query'][_0x14ba('0x23')]);_0x29789a['offset']=qs[_0x14ba('0x21')](_0x46607f['query']['offset']);}_0x29789a['order']=qs[_0x14ba('0x42')](_0x46607f[_0x14ba('0x38')][_0x14ba('0x42')]);_0x29789a[_0x14ba('0x43')]=qs[_0x14ba('0x3a')](_['pick'](_0x46607f[_0x14ba('0x38')],_0x4d157a['filters']));_0x29789a[_0x14ba('0x43')][_0x14ba('0x5c')]=_0x209459['id'];if(_0x46607f[_0x14ba('0x38')]['filter']){_0x29789a['where']=_[_0x14ba('0x46')](_0x29789a['where'],{'$or':_[_0x14ba('0x47')](_0x29789a[_0x14ba('0x3d')],function(_0x21f1e2){var _0x127971={};_0x127971[_0x21f1e2]={'$like':'%'+_0x46607f[_0x14ba('0x38')]['filter']+'%'};return _0x127971;})});}_0x29789a=_[_0x14ba('0x46')]({},_0x29789a,_0x46607f['options']);return db[_0x14ba('0x5a')]['findAll'](_0x29789a);}})[_0x14ba('0x2a')](function(_0x1da495){if(_0x1da495){return db[_0x14ba('0x5d')]['findAndCountAll']({'where':{'id':_[_0x14ba('0x47')](_0x1da495,'UserId'),'role':_0x14ba('0x5e')},'attributes':['id',_0x14ba('0x30'),_0x14ba('0x5f'),_0x14ba('0x60'),_0x14ba('0x61')]});}})[_0x14ba('0x2a')](function(_0x19ea15){if(_0x19ea15){return{'count':_0x19ea15[_0x14ba('0x24')],'rows':_[_0x14ba('0x47')](_0x19ea15[_0x14ba('0x4b')],function(_0x617c57){return{'membername':_0x617c57[_0x14ba('0x30')],'UserId':_0x617c57['id'],'queue_name':_0x233aff[_0x14ba('0x30')],'WhatsappQueueId':_0x233aff['id'],'interface':util[_0x14ba('0x62')](_0x14ba('0x63'),_0x14ba('0x64'),_0x617c57['name']),'penalty':0x0,'paused':_0x617c57['whatsappPause'],'createdAt':_0x617c57[_0x14ba('0x61')],'updatedAt':_0x617c57[_0x14ba('0x60')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x2283a4,_0x29789a))['catch'](handleError(_0x2283a4,null));};exports['getTeams']=function(_0x16ad3a,_0x23bdc4,_0x164af8){var _0x158490={};var _0xb1fb8={};var _0x20b77b;var _0x1789ed;return db[_0x14ba('0x33')][_0x14ba('0x65')]({'where':{'id':_0x16ad3a[_0x14ba('0x4d')]['id']}})['then'](handleEntityNotFound(_0x23bdc4,null))[_0x14ba('0x2a')](function(_0xf8a8de){if(_0xf8a8de){_0x20b77b=_0xf8a8de;_0xb1fb8[_0x14ba('0x3c')]=_[_0x14ba('0x39')](db[_0x14ba('0x66')][_0x14ba('0x34')]);_0xb1fb8['query']=_[_0x14ba('0x39')](_0x16ad3a[_0x14ba('0x38')]);_0xb1fb8[_0x14ba('0x3a')]=_[_0x14ba('0x3b')](_0xb1fb8[_0x14ba('0x3c')],_0xb1fb8[_0x14ba('0x38')]);_0x158490[_0x14ba('0x3d')]=_['intersection'](_0xb1fb8[_0x14ba('0x3c')],qs['fields'](_0x16ad3a[_0x14ba('0x38')][_0x14ba('0x3e')]));_0x158490[_0x14ba('0x3d')]=_0x158490[_0x14ba('0x3d')]['length']?_0x158490[_0x14ba('0x3d')]:_0xb1fb8[_0x14ba('0x3c')];_0x158490[_0x14ba('0x41')]=qs[_0x14ba('0x42')](_0x16ad3a['query'][_0x14ba('0x42')]);_0x158490[_0x14ba('0x43')]=qs[_0x14ba('0x3a')](_['pick'](_0x16ad3a[_0x14ba('0x38')],_0xb1fb8[_0x14ba('0x3a')]));if(_0x16ad3a[_0x14ba('0x38')][_0x14ba('0x45')]){_0x158490[_0x14ba('0x43')]=_['merge'](_0x158490['where'],{'$or':_[_0x14ba('0x47')](_0x158490[_0x14ba('0x3d')],function(_0x404d0e){var _0x4d7e41={};_0x4d7e41[_0x404d0e]={'$like':'%'+_0x16ad3a[_0x14ba('0x38')][_0x14ba('0x45')]+'%'};return _0x4d7e41;})});}_0x158490=_[_0x14ba('0x46')]({},_0x158490,_0x16ad3a[_0x14ba('0x4f')]);return _0x20b77b['getTeams'](_0x158490);}})[_0x14ba('0x2a')](function(_0x134b66){if(_0x134b66){_0x1789ed=_0x134b66[_0x14ba('0x3f')];if(!_0x16ad3a[_0x14ba('0x38')][_0x14ba('0x40')]('nolimit')){_0x158490['limit']=qs[_0x14ba('0x23')](_0x16ad3a[_0x14ba('0x38')][_0x14ba('0x23')]);_0x158490[_0x14ba('0x21')]=qs['offset'](_0x16ad3a[_0x14ba('0x38')]['offset']);}return _0x20b77b[_0x14ba('0x67')](_0x158490);}})['then'](function(_0x475587){if(_0x475587){return _0x475587?{'count':_0x1789ed,'rows':_0x475587}:null;}})[_0x14ba('0x2a')](respondWithResult(_0x23bdc4,null))[_0x14ba('0x51')](handleError(_0x23bdc4,null));};exports[_0x14ba('0x68')]=function(_0x4bcf23,_0x9c46c5,_0x2cbb8b){var _0x15493a=_0x4bcf23[_0x14ba('0x53')]['ids'];return db[_0x14ba('0x66')]['findAll']({'where':{'id':_0x15493a},'attributes':['id'],'include':[{'model':db[_0x14ba('0x5d')],'as':_0x14ba('0x69'),'attributes':['id','name',_0x14ba('0x6a'),'voicePause',_0x14ba('0x6b')],'raw':!![]}]})[_0x14ba('0x2a')](function(_0x2296ea){if(_0x2296ea){var _0x16e0b6=_[_0x14ba('0x6c')](_0x2296ea,function(_0x2d1883){var _0x55c630=_0x2d1883['get']({'plain':!![]});return _0x55c630[_0x14ba('0x69')];});return db[_0x14ba('0x33')][_0x14ba('0x50')]({'where':{'id':_0x4bcf23[_0x14ba('0x4d')]['id']}})['then'](function(_0x1caea7){return db['sequelize'][_0x14ba('0x6d')](function(_0x5008f){return _0x1caea7[_0x14ba('0x68')](_0x15493a,{'transaction':_0x5008f})[_0x14ba('0x2a')](function(){return BPromise['each'](_0x16e0b6,function(_0x1e0dd9){return db[_0x14ba('0x5a')][_0x14ba('0x6e')]({'where':{'UserId':_0x1e0dd9['id'],'WhatsappQueueId':_0x4bcf23[_0x14ba('0x4d')]['id']},'transaction':_0x5008f});});})[_0x14ba('0x2a')](function(){_0x16e0b6[_0x14ba('0x6f')](function(_0x200f16){socket[_0x14ba('0x70')](_0x14ba('0x71'),{'UserId':_0x200f16['id'],'WhatsappQueueId':_0x1caea7['id']});});});});});}})[_0x14ba('0x2a')](respondWithStatusCode(_0x9c46c5,null))[_0x14ba('0x51')](handleError(_0x9c46c5,null));};exports['removeTeams']=function(_0x550fc9,_0xea2377,_0x34e54c){return db[_0x14ba('0x66')][_0x14ba('0x4a')]({'where':{'id':_0x550fc9[_0x14ba('0x38')][_0x14ba('0x72')]},'attributes':['id'],'include':[{'model':db[_0x14ba('0x5d')],'as':_0x14ba('0x69'),'attributes':['id'],'raw':!![]}]})[_0x14ba('0x2a')](handleEntityNotFound(_0xea2377,null))[_0x14ba('0x2a')](function(_0x562096){var _0x263002=_[_0x14ba('0x47')](_0x562096,'id');var _0x3fc07a=[];var _0x1e0be7=[];var _0x888085=squel[_0x14ba('0x73')]();_0x888085[_0x14ba('0x74')]('tq.TeamId')[_0x14ba('0x75')](_0x14ba('0x76'),'tq')[_0x14ba('0x77')]('user_has_teams','ut',_0x14ba('0x78'))['where'](_0x14ba('0x79'),_0x550fc9[_0x14ba('0x4d')]['id']);for(var _0x1ef3ce=0x0;_0x1ef3ce<_0x562096[_0x14ba('0x3f')];_0x1ef3ce+=0x1){let _0x511db6=_0x562096[_0x1ef3ce];for(var _0x278971=0x0;_0x278971<_0x511db6['Agents'][_0x14ba('0x3f')];_0x278971+=0x1){let _0x45af94=_0x511db6[_0x14ba('0x69')][_0x278971];var _0x506be1=_0x888085[_0x14ba('0x7a')]();_0x506be1[_0x14ba('0x43')](_0x14ba('0x7b'),_0x45af94['id']);_0x1e0be7[_0x14ba('0x7c')](db[_0x14ba('0x7d')][_0x14ba('0x38')](_0x506be1[_0x14ba('0x7e')](),{'type':db['sequelize']['QueryTypes']['SELECT']})[_0x14ba('0x2a')](function(_0x17d1d2){if(_0x17d1d2[_0x14ba('0x3f')]===0x1){return _0x45af94['id'];}else{var _0x316832=_['every'](_['map'](_0x17d1d2,_0x14ba('0x7f')),function(_0x38ed8a){return _[_0x14ba('0x80')](_0x263002,_0x38ed8a);});if(_0x316832){return _0x45af94['id'];}}}));}}return BPromise[_0x14ba('0x81')](_0x1e0be7)['then'](function(_0x46ded2){_0x3fc07a=_(_0x3fc07a)[_0x14ba('0x82')](_0x46ded2)[_0x14ba('0x83')]()['value']();return db[_0x14ba('0x33')][_0x14ba('0x50')]({'where':{'id':_0x550fc9['params']['id']}})[_0x14ba('0x2a')](function(_0xb91fc7){return db[_0x14ba('0x7d')][_0x14ba('0x6d')](function(_0x567d59){return _0xb91fc7[_0x14ba('0x84')](_0x550fc9[_0x14ba('0x38')]['ids'],{'transaction':_0x567d59})['then'](function(){if(!_[_0x14ba('0x85')](_0x3fc07a)){return _0xb91fc7[_0x14ba('0x86')](_0x3fc07a,{'transaction':_0x567d59});}})[_0x14ba('0x2a')](function(){_0x3fc07a[_0x14ba('0x6f')](function(_0x44e7cb){socket[_0x14ba('0x70')](_0x14ba('0x87'),{'UserId':_0x44e7cb,'WhatsappQueueId':_0xb91fc7['id']});});});});});});})[_0x14ba('0x2a')](respondWithStatusCode(_0xea2377,null))['catch'](handleError(_0xea2377,null));};exports[_0x14ba('0x88')]=function(_0x1e0136,_0x4090a8,_0x1553bd){return db[_0x14ba('0x33')][_0x14ba('0x50')]({'where':{'id':_0x1e0136[_0x14ba('0x4d')]['id']}})[_0x14ba('0x2a')](handleEntityNotFound(_0x4090a8,null))[_0x14ba('0x2a')](function(_0x48fe76){if(_0x48fe76){return _0x48fe76['addAgents'](_0x1e0136[_0x14ba('0x53')][_0x14ba('0x72')],_[_0x14ba('0x89')](_0x1e0136[_0x14ba('0x53')],[_0x14ba('0x72'),'id'])||{})[_0x14ba('0x8a')](function(_0x40f8cc){for(var _0x1c457c=0x0;_0x1c457c<_0x1e0136[_0x14ba('0x53')][_0x14ba('0x72')][_0x14ba('0x3f')];_0x1c457c+=0x1){socket[_0x14ba('0x70')](_0x14ba('0x71'),{'UserId':Number(_0x1e0136[_0x14ba('0x53')]['ids'][_0x1c457c]),'WhatsappQueueId':Number(_0x1e0136[_0x14ba('0x4d')]['id'])});}return _0x40f8cc;});}})[_0x14ba('0x2a')](respondWithResult(_0x4090a8,null))[_0x14ba('0x51')](handleError(_0x4090a8,null));};exports[_0x14ba('0x86')]=function(_0x1e4059,_0x444957,_0xb43b0b){return db[_0x14ba('0x33')][_0x14ba('0x50')]({'where':{'id':_0x1e4059[_0x14ba('0x4d')]['id']}})[_0x14ba('0x2a')](handleEntityNotFound(_0x444957,null))[_0x14ba('0x2a')](function(_0x30d085){if(_0x30d085){return _0x30d085[_0x14ba('0x86')](_0x1e4059[_0x14ba('0x38')]['ids'])['then'](function(){if(_[_0x14ba('0x8b')](_0x1e4059[_0x14ba('0x38')][_0x14ba('0x72')])){for(var _0x14aa92=0x0;_0x14aa92<_0x1e4059[_0x14ba('0x38')][_0x14ba('0x72')]['length'];_0x14aa92+=0x1){socket[_0x14ba('0x70')]('userWhatsappQueue:remove',{'UserId':Number(_0x1e4059[_0x14ba('0x38')][_0x14ba('0x72')][_0x14aa92]),'WhatsappQueueId':Number(_0x1e4059[_0x14ba('0x4d')]['id'])});}}else{socket[_0x14ba('0x70')]('userWhatsappQueue:remove',{'UserId':Number(_0x1e4059[_0x14ba('0x38')][_0x14ba('0x72')]),'WhatsappQueueId':Number(_0x1e4059[_0x14ba('0x4d')]['id'])});}});}})['then'](respondWithStatusCode(_0x444957,null))[_0x14ba('0x51')](handleError(_0x444957,null));};exports[_0x14ba('0x8c')]=function(_0x2ffd82,_0x1d56c3,_0x142467){var _0x28e65e={};var _0x2b9d9e={};var _0x40071b;var _0xba54e3;return db[_0x14ba('0x33')][_0x14ba('0x65')]({'where':{'id':_0x2ffd82['params']['id']}})[_0x14ba('0x2a')](handleEntityNotFound(_0x1d56c3,null))[_0x14ba('0x2a')](function(_0xdd84fb){if(_0xdd84fb){_0x40071b=_0xdd84fb;_0x2b9d9e['model']=_[_0x14ba('0x39')](db[_0x14ba('0x5d')]['rawAttributes']);_0x2b9d9e[_0x14ba('0x38')]=_[_0x14ba('0x39')](_0x2ffd82[_0x14ba('0x38')]);_0x2b9d9e[_0x14ba('0x3a')]=_[_0x14ba('0x3b')](_0x2b9d9e[_0x14ba('0x3c')],_0x2b9d9e[_0x14ba('0x38')]);_0x28e65e[_0x14ba('0x3d')]=_[_0x14ba('0x3b')](_0x2b9d9e[_0x14ba('0x3c')],qs[_0x14ba('0x3e')](_0x2ffd82[_0x14ba('0x38')][_0x14ba('0x3e')]));_0x28e65e[_0x14ba('0x3d')]=_0x28e65e['attributes'][_0x14ba('0x3f')]?_0x28e65e[_0x14ba('0x3d')]:_0x2b9d9e[_0x14ba('0x3c')];_0x28e65e[_0x14ba('0x41')]=qs['sort'](_0x2ffd82[_0x14ba('0x38')][_0x14ba('0x42')]);_0x28e65e['where']=qs[_0x14ba('0x3a')](_[_0x14ba('0x44')](_0x2ffd82[_0x14ba('0x38')],_0x2b9d9e[_0x14ba('0x3a')]));if(_0x2ffd82[_0x14ba('0x38')]['filter']){_0x28e65e[_0x14ba('0x43')]=_[_0x14ba('0x46')](_0x28e65e['where'],{'$or':_[_0x14ba('0x47')](_0x28e65e[_0x14ba('0x3d')],function(_0x4fbd3c){var _0x3850dc={};_0x3850dc[_0x4fbd3c]={'$like':'%'+_0x2ffd82[_0x14ba('0x38')]['filter']+'%'};return _0x3850dc;})});}_0x28e65e=_[_0x14ba('0x46')]({},_0x28e65e,_0x2ffd82[_0x14ba('0x4f')]);return _0x40071b[_0x14ba('0x8c')](_0x28e65e);}})[_0x14ba('0x2a')](function(_0x418ba5){if(_0x418ba5){_0xba54e3=_0x418ba5[_0x14ba('0x3f')];if(!_0x2ffd82[_0x14ba('0x38')][_0x14ba('0x40')](_0x14ba('0x5b'))){_0x28e65e[_0x14ba('0x23')]=qs['limit'](_0x2ffd82['query']['limit']);_0x28e65e[_0x14ba('0x21')]=qs['offset'](_0x2ffd82[_0x14ba('0x38')]['offset']);}return _0x40071b[_0x14ba('0x8c')](_0x28e65e);}})[_0x14ba('0x2a')](function(_0xf55982){if(_0xf55982){return _0xf55982?{'count':_0xba54e3,'rows':_0xf55982}:null;}})[_0x14ba('0x2a')](respondWithResult(_0x1d56c3,null))['catch'](handleError(_0x1d56c3,null));};
\ No newline at end of file