Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / team / team.controller.js
index de5c616..b4218ba 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5853=['SIP/%s','interface','all','spread','removeAgents','Mail','Openchannel','parse','Queue:remove','length','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','./team.socket','sendStatus','status','json','count','offset','set','Content-Range','reject','save','destroy','then','get','Teams','UserProfileResource','end','error','stack','name','send','index','map','Team','rawAttributes','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','where','merge','VIRTUAL','filter','includeAll','include','rows','show','params','keys','options','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','getQueues','findOne','channel','Sequelize','capitalize','toLowerCase','pick','Queues','addQueues','isValidChannel','ValidationError','Unknown\x20channel','add','ids','remove','addAgents','Voice','Chat','Whatsapp','sequelize','transaction','penalty','TeamVoiceQueue','User','Queue','emit','Queue:save','QueueId','findAll','online','voicePause','UserVoiceQueueRt','upsert','isNil','format'];(function(_0x55e6e1,_0x284e1a){var _0x205220=function(_0xc891c9){while(--_0xc891c9){_0x55e6e1['push'](_0x55e6e1['shift']());}};_0x205220(++_0x284e1a);}(_0x5853,0x113));var _0x3585=function(_0x1f9f5f,_0x509fb7){_0x1f9f5f=_0x1f9f5f-0x0;var _0x51d649=_0x5853[_0x1f9f5f];return _0x51d649;};'use strict';var pdf=require(_0x3585('0x0'));var emlformat=require(_0x3585('0x1'));var rimraf=require(_0x3585('0x2'));var zipdir=require(_0x3585('0x3'));var jsonpatch=require(_0x3585('0x4'));var rp=require('request-promise');var moment=require(_0x3585('0x5'));var BPromise=require(_0x3585('0x6'));var Mustache=require(_0x3585('0x7'));var util=require(_0x3585('0x8'));var path=require(_0x3585('0x9'));var sox=require(_0x3585('0xa'));var csv=require('to-csv');var ejs=require(_0x3585('0xb'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x3585('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x3585('0xd'));var toCsv=require(_0x3585('0xe'));var querystring=require(_0x3585('0xf'));var Papa=require(_0x3585('0x10'));var Redis=require(_0x3585('0x11'));var authService=require(_0x3585('0x12'));var qs=require(_0x3585('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3585('0x14'));var logger=require(_0x3585('0x15'))(_0x3585('0x16'));var utils=require(_0x3585('0x17'));var config=require(_0x3585('0x18'));var licenseUtil=require(_0x3585('0x19'));var db=require(_0x3585('0x1a'))['db'];config['redis']=_[_0x3585('0x1b')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x3585('0x1c'))['register'](socket);function respondWithStatusCode(_0x16b42a,_0x1cfae3){_0x1cfae3=_0x1cfae3||0xcc;return function(_0x5434ee){if(_0x5434ee){return _0x16b42a[_0x3585('0x1d')](_0x1cfae3);}return _0x16b42a[_0x3585('0x1e')](_0x1cfae3)['end']();};}function respondWithResult(_0x366723,_0x10449b){_0x10449b=_0x10449b||0xc8;return function(_0x43c5d7){if(_0x43c5d7){return _0x366723[_0x3585('0x1e')](_0x10449b)[_0x3585('0x1f')](_0x43c5d7);}};}function respondWithFilteredResult(_0x59e340,_0x3bd298){return function(_0x48c1db){if(_0x48c1db){var _0x22cfec=_0x48c1db[_0x3585('0x20')],_0x4493e5=_0x3bd298[_0x3585('0x21')],_0x3206d6=_0x3bd298[_0x3585('0x21')]+_0x3bd298['limit'],_0xb9fa97;if(_0x3206d6>=_0x22cfec){_0x3206d6=_0x22cfec;_0xb9fa97=0xc8;}else{_0xb9fa97=0xce;}_0x59e340['status'](_0xb9fa97);return _0x59e340[_0x3585('0x22')](_0x3585('0x23'),_0x4493e5+'-'+_0x3206d6+'/'+_0x22cfec)[_0x3585('0x1f')](_0x48c1db);}return null;};}function patchUpdates(_0x1eba01){return function(_0x2b085d){try{jsonpatch['apply'](_0x2b085d,_0x1eba01,!![]);}catch(_0xa61b5a){return BPromise[_0x3585('0x24')](_0xa61b5a);}return _0x2b085d[_0x3585('0x25')]();};}function saveUpdates(_0x2de21d,_0x610d07){return function(_0x4b18b9){if(_0x4b18b9){return _0x4b18b9['update'](_0x2de21d)['then'](function(_0x5ec4c3){return _0x5ec4c3;});}return null;};}function removeEntity(_0x568937,_0x4d0cf6){return function(_0x349571){if(_0x349571){return _0x349571[_0x3585('0x26')]()[_0x3585('0x27')](function(){var _0x3a6bf0=_0x349571[_0x3585('0x28')]({'plain':!![]});var _0x504106=_0x3585('0x29');return db[_0x3585('0x2a')]['destroy']({'where':{'type':_0x504106,'resourceId':_0x3a6bf0['id']}})[_0x3585('0x27')](function(){return _0x349571;});})['then'](function(){_0x568937[_0x3585('0x1e')](0xcc)[_0x3585('0x2b')]();});}};}function handleEntityNotFound(_0xeb24a0,_0x490ab0){return function(_0x9f8a57){if(!_0x9f8a57){_0xeb24a0[_0x3585('0x1d')](0x194);}return _0x9f8a57;};}function handleError(_0x3cb377,_0x149c99){_0x149c99=_0x149c99||0x1f4;return function(_0x425057){logger[_0x3585('0x2c')](_0x425057[_0x3585('0x2d')]);if(_0x425057[_0x3585('0x2e')]){delete _0x425057['name'];}_0x3cb377[_0x3585('0x1e')](_0x149c99)[_0x3585('0x2f')](_0x425057);};}exports[_0x3585('0x30')]=function(_0x269e30,_0x2f7da9){var _0x462254={},_0x5f1fd0={},_0x404806={'count':0x0,'rows':[]};var _0x31ea79=_[_0x3585('0x31')](db[_0x3585('0x32')][_0x3585('0x33')],function(_0x209d30){return{'name':_0x209d30['fieldName'],'type':_0x209d30['type'][_0x3585('0x34')]};});_0x5f1fd0[_0x3585('0x35')]=_[_0x3585('0x31')](_0x31ea79,_0x3585('0x2e'));_0x5f1fd0['query']=_['keys'](_0x269e30[_0x3585('0x36')]);_0x5f1fd0[_0x3585('0x37')]=_[_0x3585('0x38')](_0x5f1fd0[_0x3585('0x35')],_0x5f1fd0['query']);_0x462254[_0x3585('0x39')]=_[_0x3585('0x38')](_0x5f1fd0['model'],qs[_0x3585('0x3a')](_0x269e30[_0x3585('0x36')]['fields']));_0x462254[_0x3585('0x39')]=_0x462254['attributes']['length']?_0x462254[_0x3585('0x39')]:_0x5f1fd0[_0x3585('0x35')];if(!_0x269e30['query'][_0x3585('0x3b')](_0x3585('0x3c'))){_0x462254[_0x3585('0x3d')]=qs[_0x3585('0x3d')](_0x269e30[_0x3585('0x36')]['limit']);_0x462254[_0x3585('0x21')]=qs[_0x3585('0x21')](_0x269e30[_0x3585('0x36')]['offset']);}_0x462254[_0x3585('0x3e')]=qs['sort'](_0x269e30[_0x3585('0x36')][_0x3585('0x3f')]);_0x462254[_0x3585('0x40')]=qs[_0x3585('0x37')](_['pick'](_0x269e30['query'],_0x5f1fd0[_0x3585('0x37')]),_0x31ea79);if(_0x269e30[_0x3585('0x36')]['filter']){_0x462254[_0x3585('0x40')]=_[_0x3585('0x41')](_0x462254[_0x3585('0x40')],{'$or':_[_0x3585('0x31')](_0x31ea79,function(_0x210710){if(_0x210710['type']!==_0x3585('0x42')){var _0x3ea701={};_0x3ea701[_0x210710[_0x3585('0x2e')]]={'$like':'%'+_0x269e30[_0x3585('0x36')][_0x3585('0x43')]+'%'};return _0x3ea701;}})});}_0x462254=_['merge']({},_0x462254,_0x269e30['options']);var _0x4b4879={'where':_0x462254[_0x3585('0x40')]};return db['Team'][_0x3585('0x20')](_0x4b4879)[_0x3585('0x27')](function(_0x7332b){_0x404806[_0x3585('0x20')]=_0x7332b;if(_0x269e30[_0x3585('0x36')][_0x3585('0x44')]){_0x462254[_0x3585('0x45')]=[{'all':!![]}];}return db[_0x3585('0x32')]['findAll'](_0x462254);})['then'](function(_0x3c7e6d){_0x404806[_0x3585('0x46')]=_0x3c7e6d;return _0x404806;})[_0x3585('0x27')](respondWithFilteredResult(_0x2f7da9,_0x462254))['catch'](handleError(_0x2f7da9,null));};exports[_0x3585('0x47')]=function(_0x40b5ef,_0x3bb158){var _0xc7e54d={'raw':![],'where':{'id':_0x40b5ef[_0x3585('0x48')]['id']}},_0x79bf0b={};_0x79bf0b[_0x3585('0x35')]=_[_0x3585('0x49')](db[_0x3585('0x32')][_0x3585('0x33')]);_0x79bf0b[_0x3585('0x36')]=_[_0x3585('0x49')](_0x40b5ef[_0x3585('0x36')]);_0x79bf0b[_0x3585('0x37')]=_[_0x3585('0x38')](_0x79bf0b['model'],_0x79bf0b['query']);_0xc7e54d['attributes']=_['intersection'](_0x79bf0b[_0x3585('0x35')],qs[_0x3585('0x3a')](_0x40b5ef[_0x3585('0x36')][_0x3585('0x3a')]));_0xc7e54d[_0x3585('0x39')]=_0xc7e54d['attributes']['length']?_0xc7e54d[_0x3585('0x39')]:_0x79bf0b['model'];if(_0x40b5ef['query'][_0x3585('0x44')]){_0xc7e54d['include']=[{'all':!![]}];}_0xc7e54d=_[_0x3585('0x41')]({},_0xc7e54d,_0x40b5ef[_0x3585('0x4a')]);return db[_0x3585('0x32')][_0x3585('0x4b')](_0xc7e54d)[_0x3585('0x27')](handleEntityNotFound(_0x3bb158,null))[_0x3585('0x27')](respondWithResult(_0x3bb158,null))[_0x3585('0x4c')](handleError(_0x3bb158,null));};exports[_0x3585('0x4d')]=function(_0x2b0bdb,_0x2ff832){return db[_0x3585('0x32')][_0x3585('0x4d')](_0x2b0bdb[_0x3585('0x4e')],{})[_0x3585('0x27')](function(_0x18298f){var _0x8cfb8d=_0x2b0bdb[_0x3585('0x4f')][_0x3585('0x28')]({'plain':!![]});if(!_0x8cfb8d)throw new Error(_0x3585('0x50'));if(_0x8cfb8d[_0x3585('0x51')]===_0x3585('0x4f')){var _0x187ad5=_0x18298f[_0x3585('0x28')]({'plain':!![]});var _0x4e2909=_0x3585('0x29');return db[_0x3585('0x52')][_0x3585('0x4b')]({'where':{'name':_0x4e2909,'userProfileId':_0x8cfb8d[_0x3585('0x53')]},'raw':!![]})[_0x3585('0x27')](function(_0x906522){if(_0x906522&&_0x906522['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x187ad5['name'],'resourceId':_0x187ad5['id'],'type':_0x906522[_0x3585('0x2e')],'sectionId':_0x906522['id']},{})[_0x3585('0x27')](function(){return _0x18298f;});}else{return _0x18298f;}})[_0x3585('0x4c')](function(_0x3c7916){logger['error'](_0x3585('0x54'),_0x3c7916);throw _0x3c7916;});}return _0x18298f;})[_0x3585('0x27')](respondWithResult(_0x2ff832,0xc9))[_0x3585('0x4c')](handleError(_0x2ff832,null));};exports[_0x3585('0x55')]=function(_0x23e635,_0x42b7ad){if(_0x23e635[_0x3585('0x4e')]['id']){delete _0x23e635[_0x3585('0x4e')]['id'];}return db['Team'][_0x3585('0x4b')]({'where':{'id':_0x23e635[_0x3585('0x48')]['id']}})['then'](handleEntityNotFound(_0x42b7ad,null))[_0x3585('0x27')](saveUpdates(_0x23e635[_0x3585('0x4e')],null))[_0x3585('0x27')](respondWithResult(_0x42b7ad,null))[_0x3585('0x4c')](handleError(_0x42b7ad,null));};exports['destroy']=function(_0x1c68d9,_0x4bc70d){return db[_0x3585('0x32')]['find']({'where':{'id':_0x1c68d9[_0x3585('0x48')]['id']}})['then'](handleEntityNotFound(_0x4bc70d,null))[_0x3585('0x27')](removeEntity(_0x4bc70d,null))['catch'](handleError(_0x4bc70d,null));};exports[_0x3585('0x56')]=function(_0x5ce4f1,_0x53e1f0,_0x5eb1e6){return db[_0x3585('0x32')][_0x3585('0x57')]({'where':{'id':_0x5ce4f1[_0x3585('0x48')]['id']}})[_0x3585('0x27')](handleEntityNotFound(_0x53e1f0,null))[_0x3585('0x27')](function(_0x508884){if(!_0x5ce4f1['query']['channel']||!utils['isValidChannel'](_0x5ce4f1[_0x3585('0x36')][_0x3585('0x58')])){throw new db[(_0x3585('0x59'))]['ValidationError']('Unknown\x20channel');}var _0xb28aac={};var _0x49aad8={};_0x49aad8['model']=_[_0x3585('0x49')](db[_[_0x3585('0x5a')](_0x5ce4f1[_0x3585('0x36')]['channel'][_0x3585('0x5b')]())+'Queue'][_0x3585('0x33')]);_0x49aad8[_0x3585('0x36')]=_['keys'](_0x5ce4f1[_0x3585('0x36')]);_0x49aad8[_0x3585('0x37')]=_[_0x3585('0x38')](_0x49aad8[_0x3585('0x35')],_0x49aad8[_0x3585('0x36')]);_0xb28aac[_0x3585('0x39')]=_[_0x3585('0x38')](_0x49aad8[_0x3585('0x35')],qs[_0x3585('0x3a')](_0x5ce4f1['query'][_0x3585('0x3a')]));_0xb28aac[_0x3585('0x39')]=_0xb28aac[_0x3585('0x39')]['length']?_0xb28aac['attributes']:_0x49aad8[_0x3585('0x35')];_0xb28aac[_0x3585('0x3d')]=qs[_0x3585('0x3d')](_0x5ce4f1['query'][_0x3585('0x3d')]);_0xb28aac[_0x3585('0x21')]=qs['offset'](_0x5ce4f1[_0x3585('0x36')]['offset']);_0xb28aac['order']=qs[_0x3585('0x3f')](_0x5ce4f1[_0x3585('0x36')][_0x3585('0x3f')]);_0xb28aac['where']=qs[_0x3585('0x37')](_[_0x3585('0x5c')](_0x5ce4f1['query'],_0x49aad8['filters']));_0xb28aac=_[_0x3585('0x41')]({},_0xb28aac,_0x5ce4f1[_0x3585('0x4a')]);return _0x508884[_0x3585('0x28')+_[_0x3585('0x5a')](_0x5ce4f1[_0x3585('0x36')]['channel']['toLowerCase']())+_0x3585('0x5d')](_0xb28aac);})['then'](respondWithResult(_0x53e1f0,null))['catch'](handleError(_0x53e1f0,null));};exports[_0x3585('0x5e')]=function(_0x4d783b,_0x3c4ff5,_0x668691){return db[_0x3585('0x32')]['findOne']({'where':{'id':_0x4d783b[_0x3585('0x48')]['id']}})[_0x3585('0x27')](function(_0x3c3eaa){if(_0x3c3eaa){if(!_0x4d783b[_0x3585('0x4e')]['channel']||!utils[_0x3585('0x5f')](_0x4d783b[_0x3585('0x4e')][_0x3585('0x58')])){throw new db[(_0x3585('0x59'))][(_0x3585('0x60'))](_0x3585('0x61'));}return _0x3c3eaa[_0x3585('0x62')+_[_0x3585('0x5a')](_0x4d783b['body'][_0x3585('0x58')][_0x3585('0x5b')]())+_0x3585('0x5d')](_0x4d783b[_0x3585('0x4e')][_0x3585('0x63')]);}return null;})[_0x3585('0x27')](handleEntityNotFound(_0x3c4ff5,null))[_0x3585('0x27')](respondWithStatusCode(_0x3c4ff5,null))[_0x3585('0x4c')](handleError(_0x3c4ff5,null));};exports['removeQueues']=function(_0x3c878c,_0x5ebf46,_0x472e93){return db['Team'][_0x3585('0x57')]({'where':{'id':_0x3c878c['params']['id']}})['then'](function(_0x51ca0f){if(_0x51ca0f){if(!_0x3c878c[_0x3585('0x36')][_0x3585('0x58')]||!utils[_0x3585('0x5f')](_0x3c878c[_0x3585('0x36')][_0x3585('0x58')])){throw new db['Sequelize'][(_0x3585('0x60'))](_0x3585('0x61'));}return _0x51ca0f[_0x3585('0x64')+_['capitalize'](_0x3c878c[_0x3585('0x36')][_0x3585('0x58')]['toLowerCase']())+'Queues'](_0x3c878c[_0x3585('0x36')][_0x3585('0x63')]);}return null;})[_0x3585('0x27')](handleEntityNotFound(_0x5ebf46,null))[_0x3585('0x27')](respondWithStatusCode(_0x5ebf46,null))[_0x3585('0x4c')](handleError(_0x5ebf46,null));};exports[_0x3585('0x65')]=function(_0x468456,_0x3444ac){return db[_0x3585('0x32')][_0x3585('0x4b')]({'where':{'id':_0x468456['params']['id']}})[_0x3585('0x27')](handleEntityNotFound(_0x3444ac,null))['then'](function(_0x91ae8f){if(_0x91ae8f){var _0x5ec686=[_0x3585('0x66'),_0x3585('0x67'),'Mail','Sms','Fax','Openchannel',_0x3585('0x68')];return db[_0x3585('0x69')][_0x3585('0x6a')](function(_0x10d049){var _0x3e2d21=_['map'](_0x5ec686,function(_0x4da084){var _0x9a3dc5={'attributes':['id','name']};if(_0x4da084===_0x3585('0x66')){_0x9a3dc5['through']={'attributes':[_0x3585('0x6b')]};}return _0x91ae8f[_0x3585('0x28')+_0x4da084+_0x3585('0x5d')](_0x9a3dc5)[_0x3585('0x27')](function(_0x28f1af){var _0x14b9c0=_['map'](_0x28f1af,function(_0x115787){var _0x1b8117=_[_0x3585('0x31')](_0x468456[_0x3585('0x4e')]['ids'],function(_0x5c656d){var _0x45eff9={'where':{'UserId':_0x5c656d,[_0x4da084+'QueueId']:_0x115787['id']},'transaction':_0x10d049};if(_0x4da084==='Voice'){_0x45eff9['defaults']={'penalty':_0x115787[_0x3585('0x6c')]['penalty']};}return db[_0x3585('0x6d')+_0x4da084+_0x3585('0x6e')]['findOrCreate'](_0x45eff9)[_0x3585('0x27')](function(){socket[_0x3585('0x6f')]('user'+_0x4da084+_0x3585('0x70'),{'UserId':_0x5c656d,[_0x4da084+_0x3585('0x71')]:_0x115787['id']});if(_0x4da084!=='Voice')return;return db[_0x3585('0x6d')][_0x3585('0x72')]({'where':{'id':_0x468456[_0x3585('0x4e')]['ids'],'online':0x1},'attributes':['id',_0x3585('0x2e'),_0x3585('0x73'),_0x3585('0x74'),'interface'],'raw':!![]})[_0x3585('0x27')](function(_0x4a8d82){var _0x5cc879=_['map'](_0x4a8d82,function(_0x1f9037){return db[_0x3585('0x75')][_0x3585('0x76')]({'membername':_0x1f9037[_0x3585('0x2e')],'UserId':_0x1f9037['id'],'queue_name':_0x115787['name'],'VoiceQueueId':_0x115787['id'],'interface':_[_0x3585('0x77')](_0x1f9037['interface'])?util[_0x3585('0x78')](_0x3585('0x79'),_0x1f9037[_0x3585('0x2e')]):_0x1f9037[_0x3585('0x7a')],'paused':_0x1f9037[_0x3585('0x74')]||![],'penalty':_0x115787[_0x3585('0x6c')][_0x3585('0x6b')]},{'transaction':_0x10d049});});return Promise['all'](_0x5cc879);});});});return Promise[_0x3585('0x7b')](_0x1b8117);});return Promise['all'](_0x14b9c0);});});return Promise[_0x3585('0x7b')](_0x3e2d21)[_0x3585('0x27')](function(){return _0x91ae8f[_0x3585('0x65')](_0x468456[_0x3585('0x4e')]['ids'],{'transaction':_0x10d049})[_0x3585('0x7c')](function(_0x2aa183){return _0x2aa183;});});});}})[_0x3585('0x27')](respondWithResult(_0x3444ac,null))[_0x3585('0x4c')](handleError(_0x3444ac,null));};exports[_0x3585('0x7d')]=function(_0x8c309d,_0x45339d){return db[_0x3585('0x32')][_0x3585('0x4b')]({'where':{'id':_0x8c309d[_0x3585('0x48')]['id']}})[_0x3585('0x27')](handleEntityNotFound(_0x45339d,null))[_0x3585('0x27')](function(_0x2c9788){if(_0x2c9788){var _0x3fc306=[_0x3585('0x66'),_0x3585('0x67'),_0x3585('0x7e'),'Sms','Fax',_0x3585('0x7f'),_0x3585('0x68')];return db['sequelize']['transaction'](function(_0x236076){var _0x3d6133=_[_0x3585('0x31')](_0x3fc306,function(_0x2c5c16){var _0x1d8713={'attributes':['id','name']};return _0x2c9788[_0x3585('0x28')+_0x2c5c16+_0x3585('0x5d')](_0x1d8713)[_0x3585('0x27')](function(_0x37fc05){var _0x44144f=_[_0x3585('0x31')](_0x37fc05,function(_0xacd251){return _0xacd251[_0x3585('0x7d')](_0x8c309d[_0x3585('0x36')][_0x3585('0x63')],{'transaction':_0x236076})[_0x3585('0x27')](function(){var _0x1c0369=JSON[_0x3585('0x80')]('['+_0x8c309d[_0x3585('0x36')][_0x3585('0x63')]+']');var _0x123e33=_['map'](_0x1c0369,function(_0xd3ed65){socket[_0x3585('0x6f')](_0x3585('0x4f')+_0x2c5c16+_0x3585('0x81'),{'UserId':Number(_0xd3ed65),[_0x2c5c16+'QueueId']:_0xacd251['id']});if(_0x2c5c16!=='Voice')return;return db[_0x3585('0x75')][_0x3585('0x26')]({'where':{'VoiceQueueId':_0xacd251['id'],'UserId':_0xd3ed65},'transaction':_0x236076});});return Promise['all'](_0x123e33);});});return Promise[_0x3585('0x7b')](_0x44144f);});});return Promise[_0x3585('0x7b')](_0x3d6133)[_0x3585('0x27')](function(){return _0x2c9788[_0x3585('0x7d')](_0x8c309d[_0x3585('0x36')][_0x3585('0x63')],{'transaction':_0x236076});});});}})[_0x3585('0x27')](respondWithStatusCode(_0x45339d,null))[_0x3585('0x4c')](handleError(_0x45339d,null));};exports['getAgents']=function(_0x1091c0,_0x58e22c,_0x57d275){var _0x200ba2={};var _0x24cf57={};var _0x596c58;var _0x5d0cf8;return db[_0x3585('0x32')][_0x3585('0x57')]({'where':{'id':_0x1091c0[_0x3585('0x48')]['id']}})[_0x3585('0x27')](handleEntityNotFound(_0x58e22c,null))[_0x3585('0x27')](function(_0x343cd4){if(_0x343cd4){_0x596c58=_0x343cd4;_0x24cf57['model']=_['keys'](db[_0x3585('0x6d')][_0x3585('0x33')]);_0x24cf57[_0x3585('0x36')]=_[_0x3585('0x49')](_0x1091c0[_0x3585('0x36')]);_0x24cf57['filters']=_[_0x3585('0x38')](_0x24cf57[_0x3585('0x35')],_0x24cf57['query']);_0x200ba2[_0x3585('0x39')]=_['intersection'](_0x24cf57[_0x3585('0x35')],qs[_0x3585('0x3a')](_0x1091c0[_0x3585('0x36')][_0x3585('0x3a')]));_0x200ba2[_0x3585('0x39')]=_0x200ba2[_0x3585('0x39')][_0x3585('0x82')]?_0x200ba2[_0x3585('0x39')]:_0x24cf57[_0x3585('0x35')];_0x200ba2[_0x3585('0x3e')]=qs[_0x3585('0x3f')](_0x1091c0['query'][_0x3585('0x3f')]);_0x200ba2[_0x3585('0x40')]=qs['filters'](_[_0x3585('0x5c')](_0x1091c0[_0x3585('0x36')],_0x24cf57[_0x3585('0x37')]));if(_0x1091c0[_0x3585('0x36')][_0x3585('0x43')]){_0x200ba2[_0x3585('0x40')]=_[_0x3585('0x41')](_0x200ba2[_0x3585('0x40')],{'$or':_[_0x3585('0x31')](_0x200ba2[_0x3585('0x39')],function(_0x5bc283){var _0x5789c9={};_0x5789c9[_0x5bc283]={'$like':'%'+_0x1091c0[_0x3585('0x36')][_0x3585('0x43')]+'%'};return _0x5789c9;})});}_0x200ba2=_['merge']({},_0x200ba2,_0x1091c0['options']);return _0x596c58[_0x3585('0x83')](_0x200ba2);}})[_0x3585('0x27')](function(_0x1e95c6){if(_0x1e95c6){_0x5d0cf8=_0x1e95c6[_0x3585('0x82')];if(!_0x1091c0[_0x3585('0x36')][_0x3585('0x3b')](_0x3585('0x3c'))){_0x200ba2[_0x3585('0x3d')]=qs[_0x3585('0x3d')](_0x1091c0['query'][_0x3585('0x3d')]);_0x200ba2[_0x3585('0x21')]=qs[_0x3585('0x21')](_0x1091c0[_0x3585('0x36')][_0x3585('0x21')]);}return _0x596c58[_0x3585('0x83')](_0x200ba2);}})['then'](function(_0x4702d0){if(_0x4702d0){return _0x4702d0?{'count':_0x5d0cf8,'rows':_0x4702d0}:null;}})[_0x3585('0x27')](respondWithResult(_0x58e22c,null))['catch'](handleError(_0x58e22c,null));};
\ No newline at end of file
+var _0xe0a9=['toLowerCase','Queues','add','ids','removeQueues','addAgents','isArray','Voice','Chat','Fax','Openchannel','through','penalty','QueueId','TeamVoiceQueue','User','Queue','findOrCreate','emit','Queue:save','online','voicePause','UserVoiceQueueRt','upsert','isNil','interface','format','SIP/%s','all','spread','removeAgents','Mail','Sms','Whatsapp','Queue:remove','nolimit','getAgents','zip-dir','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','./team.socket','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','update','then','error','name','map','Team','type','model','query','filters','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','keys','intersection','find','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','Teams','UserProfileSection','autoAssociation','UserProfileResource','destroy','sequelize','transaction','SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20','SELECT','Sequelize','QueryTypes','VoiceQueueId','UserVoiceQueue','SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20','MailQueueId','SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20','SmsQueueId','UserSmsQueue','SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20','ChatQueueId','UserChatQueue','FaxQueueId','UserFaxQueue','SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20','OpenchannelQueueId','UserOpenchannelQueue','SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','send','findOne','channel','isValidChannel','ValidationError','Unknown\x20channel','capitalize'];(function(_0x29e0eb,_0x9acb52){var _0x597d2d=function(_0x596ef9){while(--_0x596ef9){_0x29e0eb['push'](_0x29e0eb['shift']());}};_0x597d2d(++_0x9acb52);}(_0xe0a9,0xba));var _0x9e0a=function(_0x3a27db,_0x4dead6){_0x3a27db=_0x3a27db-0x0;var _0x283475=_0xe0a9[_0x3a27db];return _0x283475;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x9e0a('0x0'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9e0a('0x1'));var moment=require(_0x9e0a('0x2'));var BPromise=require(_0x9e0a('0x3'));var Mustache=require(_0x9e0a('0x4'));var util=require(_0x9e0a('0x5'));var path=require('path');var sox=require(_0x9e0a('0x6'));var csv=require(_0x9e0a('0x7'));var ejs=require(_0x9e0a('0x8'));var fs=require('fs');var fs_extra=require(_0x9e0a('0x9'));var _=require(_0x9e0a('0xa'));var squel=require(_0x9e0a('0xb'));var crypto=require(_0x9e0a('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x9e0a('0xd'));var toCsv=require(_0x9e0a('0x7'));var querystring=require(_0x9e0a('0xe'));var Papa=require(_0x9e0a('0xf'));var Redis=require(_0x9e0a('0x10'));var authService=require(_0x9e0a('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x9e0a('0x12'))('api');var utils=require(_0x9e0a('0x13'));var config=require(_0x9e0a('0x14'));var licenseUtil=require(_0x9e0a('0x15'));var db=require(_0x9e0a('0x16'))['db'];config[_0x9e0a('0x17')]=_['defaults'](config[_0x9e0a('0x17')],{'host':_0x9e0a('0x18'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9e0a('0x17')]));require(_0x9e0a('0x19'))['register'](socket);function respondWithStatusCode(_0x426ff8,_0x2363ba){_0x2363ba=_0x2363ba||0xcc;return function(_0x4c877b){if(_0x4c877b){return _0x426ff8['sendStatus'](_0x2363ba);}return _0x426ff8[_0x9e0a('0x1a')](_0x2363ba)[_0x9e0a('0x1b')]();};}function respondWithResult(_0xde76e3,_0x198913){_0x198913=_0x198913||0xc8;return function(_0x4cc455){if(_0x4cc455){return _0xde76e3[_0x9e0a('0x1a')](_0x198913)[_0x9e0a('0x1c')](_0x4cc455);}};}function respondWithFilteredResult(_0x48345d,_0x2eaf79){return function(_0x1769f8){if(_0x1769f8){var _0x4ef562=typeof _0x2eaf79[_0x9e0a('0x1d')]===_0x9e0a('0x1e')&&typeof _0x2eaf79[_0x9e0a('0x1f')]===_0x9e0a('0x1e');var _0x20a746=_0x1769f8[_0x9e0a('0x20')];var _0x4e73df=_0x4ef562?0x0:_0x2eaf79[_0x9e0a('0x1d')];var _0x389e70=_0x4ef562?_0x1769f8[_0x9e0a('0x20')]:_0x2eaf79[_0x9e0a('0x1d')]+_0x2eaf79['limit'];var _0x35c860;if(_0x389e70>=_0x20a746){_0x389e70=_0x20a746;_0x35c860=0xc8;}else{_0x35c860=0xce;}_0x48345d[_0x9e0a('0x1a')](_0x35c860);return _0x48345d[_0x9e0a('0x21')](_0x9e0a('0x22'),_0x4e73df+'-'+_0x389e70+'/'+_0x20a746)[_0x9e0a('0x1c')](_0x1769f8);}return null;};}function patchUpdates(_0xcc794d){return function(_0x24dace){try{jsonpatch['apply'](_0x24dace,_0xcc794d,!![]);}catch(_0x37d886){return BPromise[_0x9e0a('0x23')](_0x37d886);}return _0x24dace['save']();};}function saveUpdates(_0x53bfd6,_0x8c2d1){return function(_0x564109){if(_0x564109){return _0x564109[_0x9e0a('0x24')](_0x53bfd6)[_0x9e0a('0x25')](function(_0x2a4b2c){return _0x2a4b2c;});}return null;};}function handleEntityNotFound(_0x47e607,_0x24d886){return function(_0x4280bc){if(!_0x4280bc){_0x47e607['sendStatus'](0x194);}return _0x4280bc;};}function handleError(_0x6ef128,_0x19cfde){_0x19cfde=_0x19cfde||0x1f4;return function(_0x24feea){logger[_0x9e0a('0x26')](_0x24feea['stack']);if(_0x24feea[_0x9e0a('0x27')]){delete _0x24feea[_0x9e0a('0x27')];}_0x6ef128[_0x9e0a('0x1a')](_0x19cfde)['send'](_0x24feea);};}exports['index']=function(_0x53f6db,_0x519e9b){var _0x3cd4d6={},_0x1b2a24={},_0x54b651={'count':0x0,'rows':[]};var _0x3f20aa=_[_0x9e0a('0x28')](db[_0x9e0a('0x29')]['rawAttributes'],function(_0x1d86d){return{'name':_0x1d86d['fieldName'],'type':_0x1d86d[_0x9e0a('0x2a')]['key']};});_0x1b2a24[_0x9e0a('0x2b')]=_[_0x9e0a('0x28')](_0x3f20aa,'name');_0x1b2a24[_0x9e0a('0x2c')]=_['keys'](_0x53f6db[_0x9e0a('0x2c')]);_0x1b2a24[_0x9e0a('0x2d')]=_['intersection'](_0x1b2a24[_0x9e0a('0x2b')],_0x1b2a24['query']);_0x3cd4d6[_0x9e0a('0x2e')]=_['intersection'](_0x1b2a24[_0x9e0a('0x2b')],qs[_0x9e0a('0x2f')](_0x53f6db[_0x9e0a('0x2c')][_0x9e0a('0x2f')]));_0x3cd4d6[_0x9e0a('0x2e')]=_0x3cd4d6[_0x9e0a('0x2e')][_0x9e0a('0x30')]?_0x3cd4d6[_0x9e0a('0x2e')]:_0x1b2a24[_0x9e0a('0x2b')];if(!_0x53f6db['query'][_0x9e0a('0x31')]('nolimit')){_0x3cd4d6['limit']=qs[_0x9e0a('0x1f')](_0x53f6db[_0x9e0a('0x2c')][_0x9e0a('0x1f')]);_0x3cd4d6[_0x9e0a('0x1d')]=qs[_0x9e0a('0x1d')](_0x53f6db[_0x9e0a('0x2c')][_0x9e0a('0x1d')]);}_0x3cd4d6[_0x9e0a('0x32')]=qs[_0x9e0a('0x33')](_0x53f6db['query'][_0x9e0a('0x33')]);_0x3cd4d6[_0x9e0a('0x34')]=qs[_0x9e0a('0x2d')](_[_0x9e0a('0x35')](_0x53f6db[_0x9e0a('0x2c')],_0x1b2a24['filters']),_0x3f20aa);if(_0x53f6db['query'][_0x9e0a('0x36')]){_0x3cd4d6[_0x9e0a('0x34')]=_[_0x9e0a('0x37')](_0x3cd4d6[_0x9e0a('0x34')],{'$or':_['map'](_0x3f20aa,function(_0x55ce0f){if(_0x55ce0f['type']!==_0x9e0a('0x38')){var _0x86879={};_0x86879[_0x55ce0f[_0x9e0a('0x27')]]={'$like':'%'+_0x53f6db['query'][_0x9e0a('0x36')]+'%'};return _0x86879;}})});}_0x3cd4d6=_[_0x9e0a('0x37')]({},_0x3cd4d6,_0x53f6db[_0x9e0a('0x39')]);var _0x2d7b52={'where':_0x3cd4d6[_0x9e0a('0x34')]};return db[_0x9e0a('0x29')][_0x9e0a('0x20')](_0x2d7b52)['then'](function(_0x280265){_0x54b651[_0x9e0a('0x20')]=_0x280265;if(_0x53f6db['query'][_0x9e0a('0x3a')]){_0x3cd4d6[_0x9e0a('0x3b')]=[{'all':!![]}];}return db[_0x9e0a('0x29')][_0x9e0a('0x3c')](_0x3cd4d6);})[_0x9e0a('0x25')](function(_0x5dafcb){_0x54b651[_0x9e0a('0x3d')]=_0x5dafcb;return _0x54b651;})['then'](respondWithFilteredResult(_0x519e9b,_0x3cd4d6))[_0x9e0a('0x3e')](handleError(_0x519e9b,null));};exports[_0x9e0a('0x3f')]=function(_0x33e07c,_0x4974ea){var _0x306cbd={'raw':![],'where':{'id':_0x33e07c[_0x9e0a('0x40')]['id']}},_0x3716d1={};_0x3716d1[_0x9e0a('0x2b')]=_['keys'](db['Team'][_0x9e0a('0x41')]);_0x3716d1[_0x9e0a('0x2c')]=_[_0x9e0a('0x42')](_0x33e07c[_0x9e0a('0x2c')]);_0x3716d1[_0x9e0a('0x2d')]=_[_0x9e0a('0x43')](_0x3716d1[_0x9e0a('0x2b')],_0x3716d1[_0x9e0a('0x2c')]);_0x306cbd['attributes']=_[_0x9e0a('0x43')](_0x3716d1[_0x9e0a('0x2b')],qs[_0x9e0a('0x2f')](_0x33e07c['query'][_0x9e0a('0x2f')]));_0x306cbd[_0x9e0a('0x2e')]=_0x306cbd[_0x9e0a('0x2e')][_0x9e0a('0x30')]?_0x306cbd[_0x9e0a('0x2e')]:_0x3716d1[_0x9e0a('0x2b')];if(_0x33e07c[_0x9e0a('0x2c')]['includeAll']){_0x306cbd[_0x9e0a('0x3b')]=[{'all':!![]}];}_0x306cbd=_[_0x9e0a('0x37')]({},_0x306cbd,_0x33e07c['options']);return db[_0x9e0a('0x29')][_0x9e0a('0x44')](_0x306cbd)['then'](handleEntityNotFound(_0x4974ea,null))[_0x9e0a('0x25')](respondWithResult(_0x4974ea,null))[_0x9e0a('0x3e')](handleError(_0x4974ea,null));};exports[_0x9e0a('0x45')]=function(_0x311a3a,_0x3bebdc){return db['Team'][_0x9e0a('0x45')](_0x311a3a[_0x9e0a('0x46')],{})[_0x9e0a('0x25')](function(_0x5807ad){var _0x574935=_0x311a3a['user'][_0x9e0a('0x47')]({'plain':!![]});if(!_0x574935)throw new Error(_0x9e0a('0x48'));if(_0x574935[_0x9e0a('0x49')]===_0x9e0a('0x4a')){var _0x3bf38d=_0x5807ad[_0x9e0a('0x47')]({'plain':!![]});var _0x37dfe0=_0x9e0a('0x4b');return db[_0x9e0a('0x4c')][_0x9e0a('0x44')]({'where':{'name':_0x37dfe0,'userProfileId':_0x574935['userProfileId']},'raw':!![]})[_0x9e0a('0x25')](function(_0xf0bab0){if(_0xf0bab0&&_0xf0bab0[_0x9e0a('0x4d')]===0x0){return db[_0x9e0a('0x4e')][_0x9e0a('0x45')]({'name':_0x3bf38d['name'],'resourceId':_0x3bf38d['id'],'type':_0xf0bab0[_0x9e0a('0x27')],'sectionId':_0xf0bab0['id']},{})[_0x9e0a('0x25')](function(){return _0x5807ad;});}else{return _0x5807ad;}})['catch'](function(_0x2f0aab){logger[_0x9e0a('0x26')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2f0aab);throw _0x2f0aab;});}return _0x5807ad;})[_0x9e0a('0x25')](respondWithResult(_0x3bebdc,0xc9))[_0x9e0a('0x3e')](handleError(_0x3bebdc,null));};exports[_0x9e0a('0x24')]=function(_0x3d91c7,_0x4efc95){if(_0x3d91c7[_0x9e0a('0x46')]['id']){delete _0x3d91c7[_0x9e0a('0x46')]['id'];}return db['Team'][_0x9e0a('0x44')]({'where':{'id':_0x3d91c7[_0x9e0a('0x40')]['id']}})['then'](handleEntityNotFound(_0x4efc95,null))['then'](saveUpdates(_0x3d91c7[_0x9e0a('0x46')],null))[_0x9e0a('0x25')](respondWithResult(_0x4efc95,null))[_0x9e0a('0x3e')](handleError(_0x4efc95,null));};exports[_0x9e0a('0x4f')]=function(_0x8add5b,_0xa3992c){var _0x66c089=_0x8add5b[_0x9e0a('0x40')]['id'];var _0x5630cf=[];return db[_0x9e0a('0x50')][_0x9e0a('0x51')](function(_0x1cde8c){var _0x520634=_0x9e0a('0x52')+_0x66c089;return db[_0x9e0a('0x50')][_0x9e0a('0x2c')](_0x520634,{'type':db['Sequelize']['QueryTypes'][_0x9e0a('0x53')],'raw':!![],'transaction':_0x1cde8c})[_0x9e0a('0x25')](function(_0x2b849e){_0x5630cf=_['map'](_0x2b849e,function(_0x40a81b){return Number(_0x40a81b['UserId']);});})[_0x9e0a('0x25')](function(){var _0x469c0c='SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20'+_0x66c089;return db['sequelize'][_0x9e0a('0x2c')](_0x469c0c,{'type':db[_0x9e0a('0x54')][_0x9e0a('0x55')][_0x9e0a('0x53')],'raw':!![],'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(_0x161f4d){var _0x33b653=_[_0x9e0a('0x28')](_0x161f4d,function(_0x2362ee){return Number(_0x2362ee[_0x9e0a('0x56')]);});return db[_0x9e0a('0x57')][_0x9e0a('0x4f')]({'where':{'UserId':{'$in':_0x5630cf},'VoiceQueueId':{'$in':_0x33b653}},'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(){var _0x19897d=_0x9e0a('0x58')+_0x66c089;return db[_0x9e0a('0x50')]['query'](_0x19897d,{'type':db[_0x9e0a('0x54')][_0x9e0a('0x55')]['SELECT'],'raw':!![],'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(_0x210565){var _0x3b490c=_[_0x9e0a('0x28')](_0x210565,function(_0x1bf3f4){return Number(_0x1bf3f4[_0x9e0a('0x59')]);});return db['UserMailQueue'][_0x9e0a('0x4f')]({'where':{'UserId':{'$in':_0x5630cf},'MailQueueId':{'$in':_0x3b490c}},'transaction':_0x1cde8c});})['then'](function(){var _0x113267=_0x9e0a('0x5a')+_0x66c089;return db['sequelize'][_0x9e0a('0x2c')](_0x113267,{'type':db[_0x9e0a('0x54')][_0x9e0a('0x55')]['SELECT'],'raw':!![],'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(_0xe394bc){var _0x767d02=_[_0x9e0a('0x28')](_0xe394bc,function(_0x354834){return Number(_0x354834[_0x9e0a('0x5b')]);});return db[_0x9e0a('0x5c')][_0x9e0a('0x4f')]({'where':{'UserId':{'$in':_0x5630cf},'SmsQueueId':{'$in':_0x767d02}},'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(){var _0x4ca4c6=_0x9e0a('0x5d')+_0x66c089;return db['sequelize'][_0x9e0a('0x2c')](_0x4ca4c6,{'type':db[_0x9e0a('0x54')][_0x9e0a('0x55')][_0x9e0a('0x53')],'raw':!![],'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(_0x3936e9){var _0x56eb13=_[_0x9e0a('0x28')](_0x3936e9,function(_0x3763c5){return Number(_0x3763c5[_0x9e0a('0x5e')]);});return db[_0x9e0a('0x5f')]['destroy']({'where':{'UserId':{'$in':_0x5630cf},'ChatQueueId':{'$in':_0x56eb13}},'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(){var _0x453239='SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20'+_0x66c089;return db[_0x9e0a('0x50')][_0x9e0a('0x2c')](_0x453239,{'type':db[_0x9e0a('0x54')]['QueryTypes'][_0x9e0a('0x53')],'raw':!![],'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(_0x425679){var _0x19c620=_[_0x9e0a('0x28')](_0x425679,function(_0x14eb16){return Number(_0x14eb16[_0x9e0a('0x60')]);});return db[_0x9e0a('0x61')][_0x9e0a('0x4f')]({'where':{'UserId':{'$in':_0x5630cf},'FaxQueueId':{'$in':_0x19c620}},'transaction':_0x1cde8c});})['then'](function(){var _0x9059d7=_0x9e0a('0x62')+_0x66c089;return db[_0x9e0a('0x50')][_0x9e0a('0x2c')](_0x9059d7,{'type':db[_0x9e0a('0x54')][_0x9e0a('0x55')]['SELECT'],'raw':!![],'transaction':_0x1cde8c});})['then'](function(_0x50f9c2){var _0x237d17=_[_0x9e0a('0x28')](_0x50f9c2,function(_0x880131){return Number(_0x880131[_0x9e0a('0x63')]);});return db[_0x9e0a('0x64')][_0x9e0a('0x4f')]({'where':{'UserId':{'$in':_0x5630cf},'OpenchannelQueueId':{'$in':_0x237d17}},'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(){var _0x1182fc=_0x9e0a('0x65')+_0x66c089;return db['sequelize'][_0x9e0a('0x2c')](_0x1182fc,{'type':db[_0x9e0a('0x54')][_0x9e0a('0x55')][_0x9e0a('0x53')],'raw':!![],'transaction':_0x1cde8c});})['then'](function(_0x4ab90f){var _0x1e702e=_[_0x9e0a('0x28')](_0x4ab90f,function(_0x554235){return Number(_0x554235['WhatsappQueueId']);});return db['UserWhatsappQueue']['destroy']({'where':{'UserId':{'$in':_0x5630cf},'WhatsappQueueId':{'$in':_0x1e702e}},'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(){return db[_0x9e0a('0x66')]['find']({'where':{'TeamId':_0x66c089}});})[_0x9e0a('0x25')](function(_0xad85ab){if(_0xad85ab===null){return;}return db[_0x9e0a('0x67')][_0x9e0a('0x4f')]({'where':{'UserId':{'$in':_0x5630cf},'VoicePrefixId':_0xad85ab[_0x9e0a('0x68')]},'transaction':_0x1cde8c});})[_0x9e0a('0x25')](function(){return db['Team']['destroy']({'where':{'id':_0x66c089},'cascade':!![],'transaction':_0x1cde8c});})['then'](function(_0x4c18e7){if(_0x4c18e7===0x0){_0xa3992c['sendStatus'](0x194);}else{return db[_0x9e0a('0x4e')][_0x9e0a('0x4f')]({'where':{'type':_0x9e0a('0x4b'),'resourceId':_0x66c089},'cascade':!![],'transaction':_0x1cde8c})[_0x9e0a('0x25')](function(){_0xa3992c[_0x9e0a('0x1a')](0xcc)[_0x9e0a('0x1b')]();});}})[_0x9e0a('0x3e')](function(_0x3f84c6){_0xa3992c[_0x9e0a('0x1a')](0x1f4)[_0x9e0a('0x69')](_0x3f84c6);});});};exports['getQueues']=function(_0x411b3a,_0x1765e9,_0x24a633){return db[_0x9e0a('0x29')][_0x9e0a('0x6a')]({'where':{'id':_0x411b3a[_0x9e0a('0x40')]['id']}})[_0x9e0a('0x25')](handleEntityNotFound(_0x1765e9,null))[_0x9e0a('0x25')](function(_0x2a8d13){if(!_0x411b3a['query'][_0x9e0a('0x6b')]||!utils[_0x9e0a('0x6c')](_0x411b3a[_0x9e0a('0x2c')][_0x9e0a('0x6b')])){throw new db['Sequelize'][(_0x9e0a('0x6d'))](_0x9e0a('0x6e'));}var _0x31ae7d={};var _0x270219={};_0x270219[_0x9e0a('0x2b')]=_['keys'](db[_[_0x9e0a('0x6f')](_0x411b3a[_0x9e0a('0x2c')][_0x9e0a('0x6b')][_0x9e0a('0x70')]())+'Queue'][_0x9e0a('0x41')]);_0x270219[_0x9e0a('0x2c')]=_[_0x9e0a('0x42')](_0x411b3a[_0x9e0a('0x2c')]);_0x270219[_0x9e0a('0x2d')]=_[_0x9e0a('0x43')](_0x270219[_0x9e0a('0x2b')],_0x270219[_0x9e0a('0x2c')]);_0x31ae7d['attributes']=_[_0x9e0a('0x43')](_0x270219[_0x9e0a('0x2b')],qs['fields'](_0x411b3a[_0x9e0a('0x2c')][_0x9e0a('0x2f')]));_0x31ae7d[_0x9e0a('0x2e')]=_0x31ae7d['attributes'][_0x9e0a('0x30')]?_0x31ae7d[_0x9e0a('0x2e')]:_0x270219[_0x9e0a('0x2b')];_0x31ae7d[_0x9e0a('0x1f')]=qs[_0x9e0a('0x1f')](_0x411b3a[_0x9e0a('0x2c')]['limit']);_0x31ae7d['offset']=qs[_0x9e0a('0x1d')](_0x411b3a[_0x9e0a('0x2c')][_0x9e0a('0x1d')]);_0x31ae7d[_0x9e0a('0x32')]=qs[_0x9e0a('0x33')](_0x411b3a[_0x9e0a('0x2c')][_0x9e0a('0x33')]);_0x31ae7d[_0x9e0a('0x34')]=qs[_0x9e0a('0x2d')](_['pick'](_0x411b3a['query'],_0x270219[_0x9e0a('0x2d')]));_0x31ae7d=_['merge']({},_0x31ae7d,_0x411b3a['options']);return _0x2a8d13[_0x9e0a('0x47')+_['capitalize'](_0x411b3a['query']['channel'][_0x9e0a('0x70')]())+_0x9e0a('0x71')](_0x31ae7d);})[_0x9e0a('0x25')](respondWithResult(_0x1765e9,null))[_0x9e0a('0x3e')](handleError(_0x1765e9,null));};exports['addQueues']=function(_0x12336f,_0x553be4,_0x26aed0){return db[_0x9e0a('0x29')]['findOne']({'where':{'id':_0x12336f[_0x9e0a('0x40')]['id']}})[_0x9e0a('0x25')](function(_0x10b567){if(_0x10b567){if(!_0x12336f[_0x9e0a('0x46')]['channel']||!utils[_0x9e0a('0x6c')](_0x12336f[_0x9e0a('0x46')][_0x9e0a('0x6b')])){throw new db[(_0x9e0a('0x54'))]['ValidationError'](_0x9e0a('0x6e'));}return _0x10b567[_0x9e0a('0x72')+_[_0x9e0a('0x6f')](_0x12336f[_0x9e0a('0x46')]['channel'][_0x9e0a('0x70')]())+_0x9e0a('0x71')](_0x12336f['body'][_0x9e0a('0x73')]);}return null;})[_0x9e0a('0x25')](handleEntityNotFound(_0x553be4,null))['then'](respondWithStatusCode(_0x553be4,null))['catch'](handleError(_0x553be4,null));};exports[_0x9e0a('0x74')]=function(_0x238a36,_0x3efb16,_0x18bc10){return db['Team'][_0x9e0a('0x6a')]({'where':{'id':_0x238a36[_0x9e0a('0x40')]['id']}})[_0x9e0a('0x25')](function(_0x3124e2){if(_0x3124e2){if(!_0x238a36['query'][_0x9e0a('0x6b')]||!utils[_0x9e0a('0x6c')](_0x238a36[_0x9e0a('0x2c')][_0x9e0a('0x6b')])){throw new db[(_0x9e0a('0x54'))][(_0x9e0a('0x6d'))](_0x9e0a('0x6e'));}return _0x3124e2['remove'+_['capitalize'](_0x238a36[_0x9e0a('0x2c')][_0x9e0a('0x6b')][_0x9e0a('0x70')]())+_0x9e0a('0x71')](_0x238a36[_0x9e0a('0x2c')][_0x9e0a('0x73')]);}return null;})[_0x9e0a('0x25')](handleEntityNotFound(_0x3efb16,null))[_0x9e0a('0x25')](respondWithStatusCode(_0x3efb16,null))[_0x9e0a('0x3e')](handleError(_0x3efb16,null));};exports[_0x9e0a('0x75')]=function(_0x273ab9,_0x31a2e1){var _0x447fc2=_[_0x9e0a('0x76')](_0x273ab9[_0x9e0a('0x46')]['ids'])?_0x273ab9[_0x9e0a('0x46')][_0x9e0a('0x73')]:[_0x273ab9[_0x9e0a('0x46')]['ids']];var _0x3dcdfb=_0x273ab9[_0x9e0a('0x40')]['id'];return db[_0x9e0a('0x29')]['find']({'where':{'id':_0x3dcdfb}})[_0x9e0a('0x25')](handleEntityNotFound(_0x31a2e1,null))['then'](function(_0x406a64){if(_0x406a64){var _0x3e837f=[_0x9e0a('0x77'),_0x9e0a('0x78'),'Mail','Sms',_0x9e0a('0x79'),_0x9e0a('0x7a'),'Whatsapp'];return db[_0x9e0a('0x50')][_0x9e0a('0x51')](function(_0x4e6b2f){var _0x2d4d34=_[_0x9e0a('0x28')](_0x3e837f,function(_0x421e6c){var _0x2d00b3={'attributes':['id',_0x9e0a('0x27')]};if(_0x421e6c===_0x9e0a('0x77')){_0x2d00b3[_0x9e0a('0x7b')]={'attributes':[_0x9e0a('0x7c')]};}return _0x406a64[_0x9e0a('0x47')+_0x421e6c+_0x9e0a('0x71')](_0x2d00b3)[_0x9e0a('0x25')](function(_0x47e32a){var _0x7ea662=_[_0x9e0a('0x28')](_0x47e32a,function(_0x21a135){var _0x45ab2d=_[_0x9e0a('0x28')](_0x447fc2,function(_0x1c890f){var _0x5aee6a={'where':{'UserId':_0x1c890f,[_0x421e6c+_0x9e0a('0x7d')]:_0x21a135['id']},'transaction':_0x4e6b2f};if(_0x421e6c===_0x9e0a('0x77')){_0x5aee6a['defaults']={'penalty':_0x21a135[_0x9e0a('0x7e')][_0x9e0a('0x7c')]};}return db[_0x9e0a('0x7f')+_0x421e6c+_0x9e0a('0x80')][_0x9e0a('0x81')](_0x5aee6a)['then'](function(){socket[_0x9e0a('0x82')](_0x9e0a('0x4a')+_0x421e6c+_0x9e0a('0x83'),{'UserId':_0x1c890f,[_0x421e6c+'QueueId']:_0x21a135['id']});if(_0x421e6c!==_0x9e0a('0x77')){return;}return db['User']['findAll']({'where':{'id':_0x447fc2,'online':0x1},'attributes':['id',_0x9e0a('0x27'),_0x9e0a('0x84'),_0x9e0a('0x85'),'interface'],'raw':!![]})['then'](function(_0x4f4f19){var _0x3a27c8=_['map'](_0x4f4f19,function(_0x5b85e6){return db[_0x9e0a('0x86')][_0x9e0a('0x87')]({'membername':_0x5b85e6[_0x9e0a('0x27')],'UserId':_0x5b85e6['id'],'queue_name':_0x21a135[_0x9e0a('0x27')],'VoiceQueueId':_0x21a135['id'],'interface':_[_0x9e0a('0x88')](_0x5b85e6[_0x9e0a('0x89')])?util[_0x9e0a('0x8a')](_0x9e0a('0x8b'),_0x5b85e6[_0x9e0a('0x27')]):_0x5b85e6[_0x9e0a('0x89')],'paused':_0x5b85e6[_0x9e0a('0x85')]||![],'penalty':_0x21a135[_0x9e0a('0x7e')][_0x9e0a('0x7c')]},{'transaction':_0x4e6b2f});});return Promise['all'](_0x3a27c8);});});});return Promise[_0x9e0a('0x8c')](_0x45ab2d);});return Promise['all'](_0x7ea662);})[_0x9e0a('0x25')](function(){return db[_0x9e0a('0x66')]['findOne']({'where':{'teamId':_0x3dcdfb}})['then'](function(_0x4d2631){if(_0x4d2631){var _0x515082=_[_0x9e0a('0x28')](_0x447fc2,function(_0x484ff2){db[_0x9e0a('0x67')]['upsert']({'UserId':_0x484ff2,'VoicePrefixId':_0x4d2631[_0x9e0a('0x68')]});});return Promise['all'](_0x515082);}});});});return Promise[_0x9e0a('0x8c')](_0x2d4d34)['then'](function(){return _0x406a64[_0x9e0a('0x75')](_0x447fc2,{'transaction':_0x4e6b2f})[_0x9e0a('0x8d')](function(_0x4d6d8c){return _0x4d6d8c;});});});}})[_0x9e0a('0x25')](respondWithResult(_0x31a2e1,null))[_0x9e0a('0x3e')](handleError(_0x31a2e1,null));};exports[_0x9e0a('0x8e')]=function(_0x19d223,_0x5bd98a){var _0x166d49=_[_0x9e0a('0x76')](_0x19d223['query'][_0x9e0a('0x73')])?_0x19d223['query'][_0x9e0a('0x73')]:[_0x19d223[_0x9e0a('0x2c')][_0x9e0a('0x73')]];var _0x52d663=_0x19d223['params']['id'];return db[_0x9e0a('0x29')][_0x9e0a('0x44')]({'where':{'id':_0x52d663}})[_0x9e0a('0x25')](handleEntityNotFound(_0x5bd98a,null))[_0x9e0a('0x25')](function(_0x531d2c){if(_0x531d2c){var _0x51cf34=[_0x9e0a('0x77'),_0x9e0a('0x78'),_0x9e0a('0x8f'),_0x9e0a('0x90'),_0x9e0a('0x79'),_0x9e0a('0x7a'),_0x9e0a('0x91')];return db[_0x9e0a('0x50')][_0x9e0a('0x51')](function(_0x4c7511){var _0x18f154=_['map'](_0x51cf34,function(_0x52921e){var _0xe79a96={'attributes':['id',_0x9e0a('0x27')]};return _0x531d2c['get'+_0x52921e+_0x9e0a('0x71')](_0xe79a96)[_0x9e0a('0x25')](function(_0x21b96d){var _0xe3393f=_[_0x9e0a('0x28')](_0x21b96d,function(_0x2f35ae){return _0x2f35ae['removeAgents'](_0x166d49,{'transaction':_0x4c7511})[_0x9e0a('0x25')](function(){var _0x4c5f09=_[_0x9e0a('0x28')](_0x166d49,function(_0x49f021){socket[_0x9e0a('0x82')](_0x9e0a('0x4a')+_0x52921e+_0x9e0a('0x92'),{'UserId':Number(_0x49f021),[_0x52921e+_0x9e0a('0x7d')]:_0x2f35ae['id']});if(_0x52921e!==_0x9e0a('0x77')){return;}return db['UserVoiceQueueRt'][_0x9e0a('0x4f')]({'where':{'VoiceQueueId':_0x2f35ae['id'],'UserId':_0x49f021},'transaction':_0x4c7511});});return Promise[_0x9e0a('0x8c')](_0x4c5f09);});});return Promise[_0x9e0a('0x8c')](_0xe3393f);});});return Promise[_0x9e0a('0x8c')](_0x18f154)[_0x9e0a('0x25')](function(){return _0x531d2c[_0x9e0a('0x8e')](_0x166d49,{'transaction':_0x4c7511});})[_0x9e0a('0x25')](function(){return db[_0x9e0a('0x66')][_0x9e0a('0x6a')]({'where':{'teamId':_0x52d663}})[_0x9e0a('0x25')](function(_0x12b5c3){if(_0x12b5c3){var _0x141488=_[_0x9e0a('0x28')](_0x166d49,function(_0x2c6cac){db[_0x9e0a('0x67')][_0x9e0a('0x4f')]({'where':{'UserId':_0x2c6cac,'VoicePrefixId':_0x12b5c3[_0x9e0a('0x68')]}});});return Promise[_0x9e0a('0x8c')](_0x141488);}});});});}})['then'](respondWithStatusCode(_0x5bd98a,null))[_0x9e0a('0x3e')](handleError(_0x5bd98a,null));};exports['getAgents']=function(_0x2b194b,_0x201734,_0x29ef47){var _0x3c3b21={};var _0x392eb6={};var _0x18f4d7;var _0x150eb5;return db[_0x9e0a('0x29')][_0x9e0a('0x6a')]({'where':{'id':_0x2b194b[_0x9e0a('0x40')]['id']}})[_0x9e0a('0x25')](handleEntityNotFound(_0x201734,null))['then'](function(_0x38a963){if(_0x38a963){_0x18f4d7=_0x38a963;_0x392eb6[_0x9e0a('0x2b')]=_[_0x9e0a('0x42')](db[_0x9e0a('0x7f')][_0x9e0a('0x41')]);_0x392eb6[_0x9e0a('0x2c')]=_[_0x9e0a('0x42')](_0x2b194b[_0x9e0a('0x2c')]);_0x392eb6[_0x9e0a('0x2d')]=_[_0x9e0a('0x43')](_0x392eb6[_0x9e0a('0x2b')],_0x392eb6[_0x9e0a('0x2c')]);_0x3c3b21[_0x9e0a('0x2e')]=_[_0x9e0a('0x43')](_0x392eb6[_0x9e0a('0x2b')],qs[_0x9e0a('0x2f')](_0x2b194b[_0x9e0a('0x2c')][_0x9e0a('0x2f')]));_0x3c3b21[_0x9e0a('0x2e')]=_0x3c3b21[_0x9e0a('0x2e')][_0x9e0a('0x30')]?_0x3c3b21['attributes']:_0x392eb6[_0x9e0a('0x2b')];_0x3c3b21[_0x9e0a('0x32')]=qs[_0x9e0a('0x33')](_0x2b194b[_0x9e0a('0x2c')][_0x9e0a('0x33')]);_0x3c3b21['where']=qs[_0x9e0a('0x2d')](_[_0x9e0a('0x35')](_0x2b194b[_0x9e0a('0x2c')],_0x392eb6['filters']));if(_0x2b194b[_0x9e0a('0x2c')][_0x9e0a('0x36')]){_0x3c3b21['where']=_[_0x9e0a('0x37')](_0x3c3b21[_0x9e0a('0x34')],{'$or':_[_0x9e0a('0x28')](_0x3c3b21[_0x9e0a('0x2e')],function(_0x108323){var _0x47619d={};_0x47619d[_0x108323]={'$like':'%'+_0x2b194b[_0x9e0a('0x2c')][_0x9e0a('0x36')]+'%'};return _0x47619d;})});}_0x3c3b21=_[_0x9e0a('0x37')]({},_0x3c3b21,_0x2b194b[_0x9e0a('0x39')]);return _0x18f4d7['getAgents'](_0x3c3b21);}})['then'](function(_0x383a51){if(_0x383a51){_0x150eb5=_0x383a51[_0x9e0a('0x30')];if(!_0x2b194b[_0x9e0a('0x2c')][_0x9e0a('0x31')](_0x9e0a('0x93'))){_0x3c3b21[_0x9e0a('0x1f')]=qs[_0x9e0a('0x1f')](_0x2b194b['query'][_0x9e0a('0x1f')]);_0x3c3b21[_0x9e0a('0x1d')]=qs[_0x9e0a('0x1d')](_0x2b194b[_0x9e0a('0x2c')]['offset']);}return _0x18f4d7[_0x9e0a('0x94')](_0x3c3b21);}})[_0x9e0a('0x25')](function(_0x21123e){if(_0x21123e){return _0x21123e?{'count':_0x150eb5,'rows':_0x21123e}:null;}})['then'](respondWithResult(_0x201734,null))[_0x9e0a('0x3e')](handleError(_0x201734,null));};
\ No newline at end of file