Built motion from commit (unavailable).|2.5.15
[motion2.git] / server / api / team / team.controller.js
index d9ac722..3b117eb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa5dd=['request-promise','moment','bluebird','util','path','sox','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./team.socket','register','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','get','Teams','UserProfileResource','end','error','stack','name','send','index','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','hasOwnProperty','nolimit','sort','pick','filter','where','map','options','Team','includeAll','include','findAll','rows','catch','show','params','rawAttributes','length','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getQueues','findOne','channel','isValidChannel','Sequelize','Unknown\x20channel','capitalize','toLowerCase','Queue','order','merge','ValidationError','add','Queues','ids','removeQueues','remove','Voice','Chat','Mail','Sms','Fax','Openchannel','each','online','interface','UserVoiceQueueRt','upsert','isNil','format','SIP/%s','voicePause','addAgents','omit','spread','emit','userTeam:save','chat','mail','sms','openchannel','userTeam:remove','getAgents','User','html-pdf','zip-dir','fast-json-patch'];(function(_0x465a0c,_0x19d4d5){var _0x1e202e=function(_0x27bd8a){while(--_0x27bd8a){_0x465a0c['push'](_0x465a0c['shift']());}};_0x1e202e(++_0x19d4d5);}(_0xa5dd,0x101));var _0xda5d=function(_0x386109,_0x5806b2){_0x386109=_0x386109-0x0;var _0x567dbb=_0xa5dd[_0x386109];return _0x567dbb;};'use strict';var pdf=require(_0xda5d('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xda5d('0x1'));var jsonpatch=require(_0xda5d('0x2'));var rp=require(_0xda5d('0x3'));var moment=require(_0xda5d('0x4'));var BPromise=require(_0xda5d('0x5'));var Mustache=require('mustache');var util=require(_0xda5d('0x6'));var path=require(_0xda5d('0x7'));var sox=require(_0xda5d('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xda5d('0x9'));var squel=require(_0xda5d('0xa'));var crypto=require(_0xda5d('0xb'));var jsforce=require(_0xda5d('0xc'));var deskjs=require(_0xda5d('0xd'));var toCsv=require(_0xda5d('0xe'));var querystring=require(_0xda5d('0xf'));var Papa=require(_0xda5d('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xda5d('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xda5d('0x12'))(_0xda5d('0x13'));var utils=require('../../config/utils');var config=require(_0xda5d('0x14'));var db=require(_0xda5d('0x15'))['db'];config[_0xda5d('0x16')]=_['defaults'](config['redis'],{'host':_0xda5d('0x17'),'port':0x18eb});var socket=require(_0xda5d('0x18'))(new Redis(config[_0xda5d('0x16')]));require(_0xda5d('0x19'))[_0xda5d('0x1a')](socket);function respondWithStatusCode(_0x267e0b,_0x2092f8){_0x2092f8=_0x2092f8||0xcc;return function(_0x53a7ad){if(_0x53a7ad){return _0x267e0b['sendStatus'](_0x2092f8);}return _0x267e0b['status'](_0x2092f8)['end']();};}function respondWithResult(_0x54ffb1,_0x42be77){_0x42be77=_0x42be77||0xc8;return function(_0x257973){if(_0x257973){return _0x54ffb1[_0xda5d('0x1b')](_0x42be77)[_0xda5d('0x1c')](_0x257973);}};}function respondWithFilteredResult(_0x38af9e,_0x169b53){return function(_0x3ebe68){if(_0x3ebe68){var _0x3667da=_0x3ebe68[_0xda5d('0x1d')],_0x3a7e86=_0x169b53['offset'],_0x4d5179=_0x169b53[_0xda5d('0x1e')]+_0x169b53[_0xda5d('0x1f')],_0x3f5cc9;if(_0x4d5179>=_0x3667da){_0x4d5179=_0x3667da;_0x3f5cc9=0xc8;}else{_0x3f5cc9=0xce;}_0x38af9e[_0xda5d('0x1b')](_0x3f5cc9);return _0x38af9e[_0xda5d('0x20')](_0xda5d('0x21'),_0x3a7e86+'-'+_0x4d5179+'/'+_0x3667da)[_0xda5d('0x1c')](_0x3ebe68);}return null;};}function patchUpdates(_0xf07e3a){return function(_0x5c09c1){try{jsonpatch[_0xda5d('0x22')](_0x5c09c1,_0xf07e3a,!![]);}catch(_0x594993){return BPromise[_0xda5d('0x23')](_0x594993);}return _0x5c09c1[_0xda5d('0x24')]();};}function saveUpdates(_0x4a47ef,_0x3e846c){return function(_0x521d07){if(_0x521d07){return _0x521d07[_0xda5d('0x25')](_0x4a47ef)[_0xda5d('0x26')](function(_0x1e1e56){return _0x1e1e56;});}return null;};}function removeEntity(_0x761ef0,_0x4038d7){return function(_0x114a45){if(_0x114a45){return _0x114a45[_0xda5d('0x27')]()[_0xda5d('0x26')](function(){var _0x2b0396=_0x114a45[_0xda5d('0x28')]({'plain':!![]});var _0x133285=_0xda5d('0x29');return db[_0xda5d('0x2a')][_0xda5d('0x27')]({'where':{'type':_0x133285,'resourceId':_0x2b0396['id']}})[_0xda5d('0x26')](function(){return _0x114a45;});})[_0xda5d('0x26')](function(){_0x761ef0[_0xda5d('0x1b')](0xcc)[_0xda5d('0x2b')]();});}};}function handleEntityNotFound(_0x16cf1a,_0x777bf3){return function(_0x2bded9){if(!_0x2bded9){_0x16cf1a['sendStatus'](0x194);}return _0x2bded9;};}function handleError(_0x3f4f0c,_0x34fda4){_0x34fda4=_0x34fda4||0x1f4;return function(_0x435572){logger[_0xda5d('0x2c')](_0x435572[_0xda5d('0x2d')]);if(_0x435572['name']){delete _0x435572[_0xda5d('0x2e')];}_0x3f4f0c[_0xda5d('0x1b')](_0x34fda4)[_0xda5d('0x2f')](_0x435572);};}exports[_0xda5d('0x30')]=function(_0x5bd14,_0x5b5835){var _0x4a5ca1={},_0xef5b21={},_0xff93f7={'count':0x0,'rows':[]};var _0x3f94c1=_['map'](db['Team']['rawAttributes'],function(_0x342ac6){return{'name':_0x342ac6[_0xda5d('0x31')],'type':_0x342ac6[_0xda5d('0x32')][_0xda5d('0x33')]};});_0xef5b21[_0xda5d('0x34')]=_['map'](_0x3f94c1,_0xda5d('0x2e'));_0xef5b21['query']=_[_0xda5d('0x35')](_0x5bd14[_0xda5d('0x36')]);_0xef5b21[_0xda5d('0x37')]=_['intersection'](_0xef5b21[_0xda5d('0x34')],_0xef5b21['query']);_0x4a5ca1[_0xda5d('0x38')]=_[_0xda5d('0x39')](_0xef5b21[_0xda5d('0x34')],qs[_0xda5d('0x3a')](_0x5bd14[_0xda5d('0x36')]['fields']));_0x4a5ca1[_0xda5d('0x38')]=_0x4a5ca1[_0xda5d('0x38')]['length']?_0x4a5ca1[_0xda5d('0x38')]:_0xef5b21[_0xda5d('0x34')];if(!_0x5bd14[_0xda5d('0x36')][_0xda5d('0x3b')](_0xda5d('0x3c'))){_0x4a5ca1[_0xda5d('0x1f')]=qs['limit'](_0x5bd14[_0xda5d('0x36')][_0xda5d('0x1f')]);_0x4a5ca1[_0xda5d('0x1e')]=qs['offset'](_0x5bd14['query']['offset']);}_0x4a5ca1['order']=qs[_0xda5d('0x3d')](_0x5bd14[_0xda5d('0x36')]['sort']);_0x4a5ca1['where']=qs[_0xda5d('0x37')](_[_0xda5d('0x3e')](_0x5bd14['query'],_0xef5b21[_0xda5d('0x37')]));if(_0x5bd14[_0xda5d('0x36')][_0xda5d('0x3f')]){_0x4a5ca1[_0xda5d('0x40')]=_['merge'](_0x4a5ca1[_0xda5d('0x40')],{'$or':_[_0xda5d('0x41')](_0x3f94c1,function(_0x41bd66){if(_0x41bd66[_0xda5d('0x32')]!=='VIRTUAL'){var _0x107929={};_0x107929[_0x41bd66[_0xda5d('0x2e')]]={'$like':'%'+_0x5bd14[_0xda5d('0x36')]['filter']+'%'};return _0x107929;}})});}_0x4a5ca1=_['merge']({},_0x4a5ca1,_0x5bd14[_0xda5d('0x42')]);var _0x20ae2b={'where':_0x4a5ca1[_0xda5d('0x40')]};return db[_0xda5d('0x43')][_0xda5d('0x1d')](_0x20ae2b)[_0xda5d('0x26')](function(_0x2603f1){_0xff93f7['count']=_0x2603f1;if(_0x5bd14['query'][_0xda5d('0x44')]){_0x4a5ca1[_0xda5d('0x45')]=[{'all':!![]}];}return db['Team'][_0xda5d('0x46')](_0x4a5ca1);})[_0xda5d('0x26')](function(_0x51002a){_0xff93f7[_0xda5d('0x47')]=_0x51002a;return _0xff93f7;})[_0xda5d('0x26')](respondWithFilteredResult(_0x5b5835,_0x4a5ca1))[_0xda5d('0x48')](handleError(_0x5b5835,null));};exports[_0xda5d('0x49')]=function(_0x14e1b0,_0x317992){var _0x59933a={'raw':![],'where':{'id':_0x14e1b0[_0xda5d('0x4a')]['id']}},_0x411ae0={};_0x411ae0[_0xda5d('0x34')]=_[_0xda5d('0x35')](db[_0xda5d('0x43')][_0xda5d('0x4b')]);_0x411ae0[_0xda5d('0x36')]=_[_0xda5d('0x35')](_0x14e1b0[_0xda5d('0x36')]);_0x411ae0[_0xda5d('0x37')]=_['intersection'](_0x411ae0['model'],_0x411ae0[_0xda5d('0x36')]);_0x59933a[_0xda5d('0x38')]=_[_0xda5d('0x39')](_0x411ae0[_0xda5d('0x34')],qs[_0xda5d('0x3a')](_0x14e1b0[_0xda5d('0x36')][_0xda5d('0x3a')]));_0x59933a[_0xda5d('0x38')]=_0x59933a['attributes'][_0xda5d('0x4c')]?_0x59933a['attributes']:_0x411ae0[_0xda5d('0x34')];if(_0x14e1b0[_0xda5d('0x36')][_0xda5d('0x44')]){_0x59933a[_0xda5d('0x45')]=[{'all':!![]}];}_0x59933a=_['merge']({},_0x59933a,_0x14e1b0[_0xda5d('0x42')]);return db[_0xda5d('0x43')][_0xda5d('0x4d')](_0x59933a)['then'](handleEntityNotFound(_0x317992,null))['then'](respondWithResult(_0x317992,null))[_0xda5d('0x48')](handleError(_0x317992,null));};exports['create']=function(_0x44d866,_0x50e739){return db[_0xda5d('0x43')][_0xda5d('0x4e')](_0x44d866[_0xda5d('0x4f')],{})[_0xda5d('0x26')](function(_0x28572d){var _0x2dc6d9=_0x44d866['user']['get']({'plain':!![]});if(!_0x2dc6d9)throw new Error(_0xda5d('0x50'));if(_0x2dc6d9['role']===_0xda5d('0x51')){var _0x1f7655=_0x28572d[_0xda5d('0x28')]({'plain':!![]});var _0x423641='Teams';return db[_0xda5d('0x52')][_0xda5d('0x4d')]({'where':{'name':_0x423641,'userProfileId':_0x2dc6d9[_0xda5d('0x53')]},'raw':!![]})[_0xda5d('0x26')](function(_0x335c9b){if(_0x335c9b&&_0x335c9b[_0xda5d('0x54')]===0x0){return db[_0xda5d('0x2a')][_0xda5d('0x4e')]({'name':_0x1f7655[_0xda5d('0x2e')],'resourceId':_0x1f7655['id'],'type':_0x335c9b[_0xda5d('0x2e')],'sectionId':_0x335c9b['id']},{})[_0xda5d('0x26')](function(){return _0x28572d;});}else{return _0x28572d;}})[_0xda5d('0x48')](function(_0x11dded){logger[_0xda5d('0x2c')](_0xda5d('0x55'),_0x11dded);throw _0x11dded;});}return _0x28572d;})[_0xda5d('0x26')](respondWithResult(_0x50e739,0xc9))[_0xda5d('0x48')](handleError(_0x50e739,null));};exports[_0xda5d('0x25')]=function(_0x522a31,_0x548007){if(_0x522a31[_0xda5d('0x4f')]['id']){delete _0x522a31[_0xda5d('0x4f')]['id'];}return db[_0xda5d('0x43')][_0xda5d('0x4d')]({'where':{'id':_0x522a31[_0xda5d('0x4a')]['id']}})[_0xda5d('0x26')](handleEntityNotFound(_0x548007,null))[_0xda5d('0x26')](saveUpdates(_0x522a31['body'],null))['then'](respondWithResult(_0x548007,null))[_0xda5d('0x48')](handleError(_0x548007,null));};exports[_0xda5d('0x27')]=function(_0x4bcc51,_0x529607){return db[_0xda5d('0x43')][_0xda5d('0x4d')]({'where':{'id':_0x4bcc51[_0xda5d('0x4a')]['id']}})['then'](handleEntityNotFound(_0x529607,null))['then'](removeEntity(_0x529607,null))['catch'](handleError(_0x529607,null));};exports[_0xda5d('0x56')]=function(_0x459e93,_0x68e19c,_0x1b27bb){return db[_0xda5d('0x43')][_0xda5d('0x57')]({'where':{'id':_0x459e93['params']['id']}})[_0xda5d('0x26')](handleEntityNotFound(_0x68e19c,null))[_0xda5d('0x26')](function(_0x2623bb){if(!_0x459e93[_0xda5d('0x36')][_0xda5d('0x58')]||!utils[_0xda5d('0x59')](_0x459e93[_0xda5d('0x36')][_0xda5d('0x58')])){throw new db[(_0xda5d('0x5a'))]['ValidationError'](_0xda5d('0x5b'));}var _0x478fa6={};var _0x786297={};_0x786297[_0xda5d('0x34')]=_[_0xda5d('0x35')](db[_[_0xda5d('0x5c')](_0x459e93[_0xda5d('0x36')][_0xda5d('0x58')][_0xda5d('0x5d')]())+_0xda5d('0x5e')][_0xda5d('0x4b')]);_0x786297[_0xda5d('0x36')]=_['keys'](_0x459e93[_0xda5d('0x36')]);_0x786297[_0xda5d('0x37')]=_[_0xda5d('0x39')](_0x786297[_0xda5d('0x34')],_0x786297['query']);_0x478fa6[_0xda5d('0x38')]=_[_0xda5d('0x39')](_0x786297[_0xda5d('0x34')],qs[_0xda5d('0x3a')](_0x459e93[_0xda5d('0x36')][_0xda5d('0x3a')]));_0x478fa6[_0xda5d('0x38')]=_0x478fa6[_0xda5d('0x38')][_0xda5d('0x4c')]?_0x478fa6[_0xda5d('0x38')]:_0x786297[_0xda5d('0x34')];_0x478fa6[_0xda5d('0x1f')]=qs[_0xda5d('0x1f')](_0x459e93['query'][_0xda5d('0x1f')]);_0x478fa6[_0xda5d('0x1e')]=qs[_0xda5d('0x1e')](_0x459e93['query'][_0xda5d('0x1e')]);_0x478fa6[_0xda5d('0x5f')]=qs[_0xda5d('0x3d')](_0x459e93['query']['sort']);_0x478fa6[_0xda5d('0x40')]=qs[_0xda5d('0x37')](_[_0xda5d('0x3e')](_0x459e93[_0xda5d('0x36')],_0x786297[_0xda5d('0x37')]));_0x478fa6=_[_0xda5d('0x60')]({},_0x478fa6,_0x459e93['options']);return _0x2623bb[_0xda5d('0x28')+_[_0xda5d('0x5c')](_0x459e93[_0xda5d('0x36')][_0xda5d('0x58')][_0xda5d('0x5d')]())+'Queues'](_0x478fa6);})['then'](respondWithResult(_0x68e19c,null))[_0xda5d('0x48')](handleError(_0x68e19c,null));};exports['addQueues']=function(_0x259aed,_0x285449,_0xa598d4){return db[_0xda5d('0x43')][_0xda5d('0x57')]({'where':{'id':_0x259aed[_0xda5d('0x4a')]['id']}})[_0xda5d('0x26')](function(_0x4d6216){if(_0x4d6216){if(!_0x259aed[_0xda5d('0x4f')][_0xda5d('0x58')]||!utils[_0xda5d('0x59')](_0x259aed[_0xda5d('0x4f')]['channel'])){throw new db[(_0xda5d('0x5a'))][(_0xda5d('0x61'))](_0xda5d('0x5b'));}return _0x4d6216[_0xda5d('0x62')+_['capitalize'](_0x259aed['body'][_0xda5d('0x58')]['toLowerCase']())+_0xda5d('0x63')](_0x259aed[_0xda5d('0x4f')][_0xda5d('0x64')]);}return null;})[_0xda5d('0x26')](handleEntityNotFound(_0x285449,null))[_0xda5d('0x26')](respondWithStatusCode(_0x285449,null))['catch'](handleError(_0x285449,null));};exports[_0xda5d('0x65')]=function(_0x4d49c9,_0x444678,_0x368c9d){return db[_0xda5d('0x43')][_0xda5d('0x57')]({'where':{'id':_0x4d49c9[_0xda5d('0x4a')]['id']}})['then'](function(_0xca9b71){if(_0xca9b71){if(!_0x4d49c9[_0xda5d('0x36')][_0xda5d('0x58')]||!utils[_0xda5d('0x59')](_0x4d49c9[_0xda5d('0x36')][_0xda5d('0x58')])){throw new db[(_0xda5d('0x5a'))][(_0xda5d('0x61'))](_0xda5d('0x5b'));}return _0xca9b71[_0xda5d('0x66')+_[_0xda5d('0x5c')](_0x4d49c9[_0xda5d('0x36')][_0xda5d('0x58')]['toLowerCase']())+_0xda5d('0x63')](_0x4d49c9[_0xda5d('0x36')]['ids']);}return null;})[_0xda5d('0x26')](handleEntityNotFound(_0x444678,null))[_0xda5d('0x26')](respondWithStatusCode(_0x444678,null))[_0xda5d('0x48')](handleError(_0x444678,null));};exports['addAgents']=function(_0x5b5d1,_0x25dab9,_0x1b8855){return db['Team']['find']({'where':{'id':_0x5b5d1[_0xda5d('0x4a')]['id']}})[_0xda5d('0x26')](handleEntityNotFound(_0x25dab9,null))[_0xda5d('0x26')](function(_0x351e2c){if(_0x351e2c){var _0x1d3921=[_0xda5d('0x67'),_0xda5d('0x68'),_0xda5d('0x69'),_0xda5d('0x6a'),_0xda5d('0x6b'),_0xda5d('0x6c')];return BPromise[_0xda5d('0x6d')](_0x1d3921,function(_0x234f51){return _0x351e2c['get'+_0x234f51+_0xda5d('0x63')]({'attributes':['id','name']})[_0xda5d('0x26')](function(_0x3b33c3){return BPromise[_0xda5d('0x6d')](_0x3b33c3,function(_0x28647e){return _0x28647e['addAgents'](_0x5b5d1[_0xda5d('0x4f')]['ids'])[_0xda5d('0x26')](function(){if(_0x234f51===_0xda5d('0x67')){return db['User'][_0xda5d('0x46')]({'where':{'id':_0x5b5d1[_0xda5d('0x4f')][_0xda5d('0x64')]},'attributes':['id',_0xda5d('0x2e'),_0xda5d('0x6e'),'voicePause',_0xda5d('0x6f')],'raw':!![]})[_0xda5d('0x26')](function(_0x3801e6){return BPromise[_0xda5d('0x6d')](_['filter'](_0x3801e6,{'online':0x1}),function(_0x176aac){return db[_0xda5d('0x70')][_0xda5d('0x71')]({'membername':_0x176aac['name'],'UserId':_0x176aac['id'],'queue_name':_0x28647e[_0xda5d('0x2e')],'VoiceQueueId':_0x28647e['id'],'interface':_[_0xda5d('0x72')](_0x176aac[_0xda5d('0x6f')])?util[_0xda5d('0x73')](_0xda5d('0x74'),_0x176aac[_0xda5d('0x2e')]):_0x176aac[_0xda5d('0x6f')],'paused':_0x176aac[_0xda5d('0x75')]||![],'penalty':0x0});});});}});});})[_0xda5d('0x26')](function(){return _0x351e2c;});})[_0xda5d('0x26')](function(){return _0x351e2c;});}})[_0xda5d('0x26')](function(_0x2780a4){if(_0x2780a4){return _0x2780a4[_0xda5d('0x76')](_0x5b5d1[_0xda5d('0x4f')][_0xda5d('0x64')],_[_0xda5d('0x77')](_0x5b5d1[_0xda5d('0x4f')],[_0xda5d('0x64'),'id'])||{})[_0xda5d('0x78')](function(_0x1efbab){for(var _0x3ec6e5=0x0;_0x3ec6e5<_0x5b5d1[_0xda5d('0x4f')][_0xda5d('0x64')][_0xda5d('0x4c')];_0x3ec6e5+=0x1){socket[_0xda5d('0x79')](_0xda5d('0x7a'),{'UserId':_0x5b5d1[_0xda5d('0x4f')]['ids'][_0x3ec6e5],'TeamId':_0x5b5d1['params']['id']});}return _0x1efbab;});}})[_0xda5d('0x26')](respondWithResult(_0x25dab9,null))['catch'](handleError(_0x25dab9,null));};exports['removeAgents']=function(_0x100a86,_0x18ea99,_0x520c71){return db['Team'][_0xda5d('0x4d')]({'where':{'id':_0x100a86[_0xda5d('0x4a')]['id']}})[_0xda5d('0x26')](handleEntityNotFound(_0x18ea99,null))[_0xda5d('0x26')](function(_0x50937c){if(_0x50937c){return BPromise[_0xda5d('0x6d')](['voice',_0xda5d('0x7b'),_0xda5d('0x7c'),_0xda5d('0x7d'),'fax',_0xda5d('0x7e')],function(_0x3fee03){return _0x50937c[_0xda5d('0x28')+_[_0xda5d('0x5c')](_0x3fee03)+_0xda5d('0x63')]({'attributes':['id','name']})[_0xda5d('0x26')](function(_0xe50ee1){return BPromise[_0xda5d('0x6d')](_0xe50ee1,function(_0xeb8b89){return _0xeb8b89['removeAgents'](_0x100a86[_0xda5d('0x36')]['ids'])[_0xda5d('0x26')](function(){if(_0x3fee03==='voice'){return db[_0xda5d('0x70')][_0xda5d('0x27')]({'where':{'VoiceQueueId':_0xeb8b89['id'],'UserId':_0x100a86[_0xda5d('0x36')][_0xda5d('0x64')]}});}});});})[_0xda5d('0x26')](function(){return _0x50937c;});})[_0xda5d('0x26')](function(){return _0x50937c;});}})[_0xda5d('0x26')](function(_0x13f8f4){if(_0x13f8f4){return _0x13f8f4['removeAgents'](_0x100a86['query'][_0xda5d('0x64')])['then'](function(){if(_['isArray'](_0x100a86['query'][_0xda5d('0x64')])){for(var _0x602008=0x0;_0x602008<_0x100a86[_0xda5d('0x36')][_0xda5d('0x64')][_0xda5d('0x4c')];_0x602008+=0x1){socket[_0xda5d('0x79')](_0xda5d('0x7f'),{'UserId':Number(_0x100a86[_0xda5d('0x36')][_0xda5d('0x64')][_0x602008]),'TeamId':Number(_0x100a86[_0xda5d('0x4a')]['id'])});}}else{socket[_0xda5d('0x79')](_0xda5d('0x7f'),{'UserId':Number(_0x100a86[_0xda5d('0x36')][_0xda5d('0x64')]),'TeamId':Number(_0x100a86[_0xda5d('0x4a')]['id'])});}});}})[_0xda5d('0x26')](respondWithStatusCode(_0x18ea99,null))[_0xda5d('0x48')](handleError(_0x18ea99,null));};exports[_0xda5d('0x80')]=function(_0x32164d,_0x3698a0,_0x53979e){var _0x208097={};var _0x381744={};var _0x102b85;var _0x4e2046;return db[_0xda5d('0x43')][_0xda5d('0x57')]({'where':{'id':_0x32164d['params']['id']}})[_0xda5d('0x26')](handleEntityNotFound(_0x3698a0,null))[_0xda5d('0x26')](function(_0xd991ef){if(_0xd991ef){_0x102b85=_0xd991ef;_0x381744[_0xda5d('0x34')]=_[_0xda5d('0x35')](db[_0xda5d('0x81')]['rawAttributes']);_0x381744[_0xda5d('0x36')]=_['keys'](_0x32164d['query']);_0x381744['filters']=_[_0xda5d('0x39')](_0x381744['model'],_0x381744[_0xda5d('0x36')]);_0x208097[_0xda5d('0x38')]=_[_0xda5d('0x39')](_0x381744[_0xda5d('0x34')],qs[_0xda5d('0x3a')](_0x32164d[_0xda5d('0x36')][_0xda5d('0x3a')]));_0x208097['attributes']=_0x208097[_0xda5d('0x38')][_0xda5d('0x4c')]?_0x208097[_0xda5d('0x38')]:_0x381744[_0xda5d('0x34')];_0x208097['order']=qs[_0xda5d('0x3d')](_0x32164d[_0xda5d('0x36')]['sort']);_0x208097[_0xda5d('0x40')]=qs[_0xda5d('0x37')](_[_0xda5d('0x3e')](_0x32164d['query'],_0x381744[_0xda5d('0x37')]));if(_0x32164d[_0xda5d('0x36')][_0xda5d('0x3f')]){_0x208097[_0xda5d('0x40')]=_[_0xda5d('0x60')](_0x208097[_0xda5d('0x40')],{'$or':_[_0xda5d('0x41')](_0x208097['attributes'],function(_0x517935){var _0x4ea05d={};_0x4ea05d[_0x517935]={'$like':'%'+_0x32164d[_0xda5d('0x36')][_0xda5d('0x3f')]+'%'};return _0x4ea05d;})});}_0x208097=_[_0xda5d('0x60')]({},_0x208097,_0x32164d['options']);return _0x102b85['getAgents'](_0x208097);}})['then'](function(_0x500b7d){if(_0x500b7d){_0x4e2046=_0x500b7d[_0xda5d('0x4c')];if(!_0x32164d[_0xda5d('0x36')]['hasOwnProperty'](_0xda5d('0x3c'))){_0x208097['limit']=qs[_0xda5d('0x1f')](_0x32164d[_0xda5d('0x36')]['limit']);_0x208097[_0xda5d('0x1e')]=qs[_0xda5d('0x1e')](_0x32164d['query'][_0xda5d('0x1e')]);}return _0x102b85[_0xda5d('0x80')](_0x208097);}})[_0xda5d('0x26')](function(_0x14e617){if(_0x14e617){return _0x14e617?{'count':_0x4e2046,'rows':_0x14e617}:null;}})['then'](respondWithResult(_0x3698a0,null))['catch'](handleError(_0x3698a0,null));};
\ No newline at end of file
+var _0x022b=['Whatsapp','each','User','online','voicePause','interface','UserVoiceQueueRt','isNil','format','SIP/%s','spread','emit','userTeam:save','removeAgents','sms','fax','openchannel','whatsapp','voice','isArray','userTeam:remove','getAgents','html-pdf','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','update','destroy','then','Teams','UserProfileResource','error','name','send','index','map','Team','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','findAll','rows','show','params','include','options','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getQueues','findOne','isValidChannel','channel','Sequelize','ValidationError','Unknown\x20channel','Queue','capitalize','toLowerCase','Queues','addQueues','add','ids','removeQueues','addAgents','Voice','Chat','Mail','Fax'];(function(_0x1bf4ec,_0x38525a){var _0x5531ef=function(_0x113327){while(--_0x113327){_0x1bf4ec['push'](_0x1bf4ec['shift']());}};_0x5531ef(++_0x38525a);}(_0x022b,0x1a2));var _0xb022=function(_0x5ec608,_0x1214bb){_0x5ec608=_0x5ec608-0x0;var _0x7deeb8=_0x022b[_0x5ec608];return _0x7deeb8;};'use strict';var pdf=require(_0xb022('0x0'));var emlformat=require(_0xb022('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xb022('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xb022('0x3'));var moment=require(_0xb022('0x4'));var BPromise=require(_0xb022('0x5'));var Mustache=require(_0xb022('0x6'));var util=require(_0xb022('0x7'));var path=require(_0xb022('0x8'));var sox=require(_0xb022('0x9'));var csv=require(_0xb022('0xa'));var ejs=require(_0xb022('0xb'));var fs=require('fs');var _=require(_0xb022('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xb022('0xd'));var deskjs=require(_0xb022('0xe'));var toCsv=require(_0xb022('0xa'));var querystring=require(_0xb022('0xf'));var Papa=require('papaparse');var Redis=require(_0xb022('0x10'));var authService=require(_0xb022('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xb022('0x12'));var hardwareService=require(_0xb022('0x13'));var logger=require(_0xb022('0x14'))('api');var utils=require(_0xb022('0x15'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xb022('0x16'))['db'];config[_0xb022('0x17')]=_[_0xb022('0x18')](config[_0xb022('0x17')],{'host':_0xb022('0x19'),'port':0x18eb});var socket=require(_0xb022('0x1a'))(new Redis(config[_0xb022('0x17')]));require('./team.socket')[_0xb022('0x1b')](socket);function respondWithStatusCode(_0x446306,_0x341038){_0x341038=_0x341038||0xcc;return function(_0x379980){if(_0x379980){return _0x446306[_0xb022('0x1c')](_0x341038);}return _0x446306[_0xb022('0x1d')](_0x341038)[_0xb022('0x1e')]();};}function respondWithResult(_0x3bb885,_0x427306){_0x427306=_0x427306||0xc8;return function(_0x4245b3){if(_0x4245b3){return _0x3bb885[_0xb022('0x1d')](_0x427306)[_0xb022('0x1f')](_0x4245b3);}};}function respondWithFilteredResult(_0x3cfed7,_0x377c51){return function(_0x3696a8){if(_0x3696a8){var _0x4ec2a9=_0x3696a8[_0xb022('0x20')],_0x1a1ab6=_0x377c51[_0xb022('0x21')],_0x3a01fb=_0x377c51['offset']+_0x377c51[_0xb022('0x22')],_0x186823;if(_0x3a01fb>=_0x4ec2a9){_0x3a01fb=_0x4ec2a9;_0x186823=0xc8;}else{_0x186823=0xce;}_0x3cfed7[_0xb022('0x1d')](_0x186823);return _0x3cfed7[_0xb022('0x23')](_0xb022('0x24'),_0x1a1ab6+'-'+_0x3a01fb+'/'+_0x4ec2a9)[_0xb022('0x1f')](_0x3696a8);}return null;};}function patchUpdates(_0x4215dd){return function(_0x4e6ae1){try{jsonpatch[_0xb022('0x25')](_0x4e6ae1,_0x4215dd,!![]);}catch(_0x2713a3){return BPromise[_0xb022('0x26')](_0x2713a3);}return _0x4e6ae1['save']();};}function saveUpdates(_0x2669c0,_0x593059){return function(_0x50a475){if(_0x50a475){return _0x50a475[_0xb022('0x27')](_0x2669c0)['then'](function(_0x12ef99){return _0x12ef99;});}return null;};}function removeEntity(_0x49210b,_0x2fc8c7){return function(_0x17c9d4){if(_0x17c9d4){return _0x17c9d4[_0xb022('0x28')]()[_0xb022('0x29')](function(){var _0x46289e=_0x17c9d4['get']({'plain':!![]});var _0x313f2c=_0xb022('0x2a');return db[_0xb022('0x2b')][_0xb022('0x28')]({'where':{'type':_0x313f2c,'resourceId':_0x46289e['id']}})['then'](function(){return _0x17c9d4;});})['then'](function(){_0x49210b[_0xb022('0x1d')](0xcc)[_0xb022('0x1e')]();});}};}function handleEntityNotFound(_0x48afad,_0x54a854){return function(_0x2be4de){if(!_0x2be4de){_0x48afad[_0xb022('0x1c')](0x194);}return _0x2be4de;};}function handleError(_0xfb4573,_0x26ad0b){_0x26ad0b=_0x26ad0b||0x1f4;return function(_0x1d2996){logger[_0xb022('0x2c')](_0x1d2996['stack']);if(_0x1d2996['name']){delete _0x1d2996[_0xb022('0x2d')];}_0xfb4573[_0xb022('0x1d')](_0x26ad0b)[_0xb022('0x2e')](_0x1d2996);};}exports[_0xb022('0x2f')]=function(_0x300830,_0x3d55dd){var _0xcc559f={},_0x1e173b={},_0x230fde={'count':0x0,'rows':[]};var _0x5414e1=_[_0xb022('0x30')](db[_0xb022('0x31')][_0xb022('0x32')],function(_0x47f8be){return{'name':_0x47f8be[_0xb022('0x33')],'type':_0x47f8be[_0xb022('0x34')][_0xb022('0x35')]};});_0x1e173b[_0xb022('0x36')]=_[_0xb022('0x30')](_0x5414e1,_0xb022('0x2d'));_0x1e173b[_0xb022('0x37')]=_[_0xb022('0x38')](_0x300830['query']);_0x1e173b[_0xb022('0x39')]=_[_0xb022('0x3a')](_0x1e173b[_0xb022('0x36')],_0x1e173b[_0xb022('0x37')]);_0xcc559f[_0xb022('0x3b')]=_[_0xb022('0x3a')](_0x1e173b[_0xb022('0x36')],qs[_0xb022('0x3c')](_0x300830[_0xb022('0x37')][_0xb022('0x3c')]));_0xcc559f[_0xb022('0x3b')]=_0xcc559f[_0xb022('0x3b')][_0xb022('0x3d')]?_0xcc559f[_0xb022('0x3b')]:_0x1e173b['model'];if(!_0x300830['query'][_0xb022('0x3e')](_0xb022('0x3f'))){_0xcc559f[_0xb022('0x22')]=qs[_0xb022('0x22')](_0x300830[_0xb022('0x37')][_0xb022('0x22')]);_0xcc559f[_0xb022('0x21')]=qs[_0xb022('0x21')](_0x300830[_0xb022('0x37')][_0xb022('0x21')]);}_0xcc559f[_0xb022('0x40')]=qs['sort'](_0x300830[_0xb022('0x37')][_0xb022('0x41')]);_0xcc559f[_0xb022('0x42')]=qs[_0xb022('0x39')](_[_0xb022('0x43')](_0x300830['query'],_0x1e173b[_0xb022('0x39')]),_0x5414e1);if(_0x300830[_0xb022('0x37')][_0xb022('0x44')]){_0xcc559f[_0xb022('0x42')]=_[_0xb022('0x45')](_0xcc559f['where'],{'$or':_[_0xb022('0x30')](_0x5414e1,function(_0x6a779a){if(_0x6a779a[_0xb022('0x34')]!==_0xb022('0x46')){var _0x55191d={};_0x55191d[_0x6a779a['name']]={'$like':'%'+_0x300830[_0xb022('0x37')][_0xb022('0x44')]+'%'};return _0x55191d;}})});}_0xcc559f=_['merge']({},_0xcc559f,_0x300830['options']);var _0x27e787={'where':_0xcc559f[_0xb022('0x42')]};return db[_0xb022('0x31')]['count'](_0x27e787)[_0xb022('0x29')](function(_0x1b874f){_0x230fde[_0xb022('0x20')]=_0x1b874f;if(_0x300830[_0xb022('0x37')][_0xb022('0x47')]){_0xcc559f['include']=[{'all':!![]}];}return db['Team'][_0xb022('0x48')](_0xcc559f);})[_0xb022('0x29')](function(_0x3c186a){_0x230fde[_0xb022('0x49')]=_0x3c186a;return _0x230fde;})[_0xb022('0x29')](respondWithFilteredResult(_0x3d55dd,_0xcc559f))['catch'](handleError(_0x3d55dd,null));};exports[_0xb022('0x4a')]=function(_0x48cb10,_0x16a35e){var _0x409063={'raw':![],'where':{'id':_0x48cb10[_0xb022('0x4b')]['id']}},_0xb0752a={};_0xb0752a[_0xb022('0x36')]=_['keys'](db['Team'][_0xb022('0x32')]);_0xb0752a['query']=_[_0xb022('0x38')](_0x48cb10[_0xb022('0x37')]);_0xb0752a[_0xb022('0x39')]=_[_0xb022('0x3a')](_0xb0752a[_0xb022('0x36')],_0xb0752a['query']);_0x409063[_0xb022('0x3b')]=_[_0xb022('0x3a')](_0xb0752a['model'],qs[_0xb022('0x3c')](_0x48cb10[_0xb022('0x37')][_0xb022('0x3c')]));_0x409063[_0xb022('0x3b')]=_0x409063[_0xb022('0x3b')][_0xb022('0x3d')]?_0x409063[_0xb022('0x3b')]:_0xb0752a['model'];if(_0x48cb10[_0xb022('0x37')][_0xb022('0x47')]){_0x409063[_0xb022('0x4c')]=[{'all':!![]}];}_0x409063=_['merge']({},_0x409063,_0x48cb10[_0xb022('0x4d')]);return db[_0xb022('0x31')]['find'](_0x409063)[_0xb022('0x29')](handleEntityNotFound(_0x16a35e,null))[_0xb022('0x29')](respondWithResult(_0x16a35e,null))[_0xb022('0x4e')](handleError(_0x16a35e,null));};exports[_0xb022('0x4f')]=function(_0x4c20d1,_0x4f19ff){return db[_0xb022('0x31')][_0xb022('0x4f')](_0x4c20d1[_0xb022('0x50')],{})['then'](function(_0x5ad4ad){var _0x4d4db2=_0x4c20d1[_0xb022('0x51')][_0xb022('0x52')]({'plain':!![]});if(!_0x4d4db2)throw new Error(_0xb022('0x53'));if(_0x4d4db2[_0xb022('0x54')]===_0xb022('0x51')){var _0x4fe8ef=_0x5ad4ad[_0xb022('0x52')]({'plain':!![]});var _0x530bf3=_0xb022('0x2a');return db[_0xb022('0x55')][_0xb022('0x56')]({'where':{'name':_0x530bf3,'userProfileId':_0x4d4db2[_0xb022('0x57')]},'raw':!![]})['then'](function(_0x3f7c34){if(_0x3f7c34&&_0x3f7c34[_0xb022('0x58')]===0x0){return db['UserProfileResource'][_0xb022('0x4f')]({'name':_0x4fe8ef[_0xb022('0x2d')],'resourceId':_0x4fe8ef['id'],'type':_0x3f7c34[_0xb022('0x2d')],'sectionId':_0x3f7c34['id']},{})[_0xb022('0x29')](function(){return _0x5ad4ad;});}else{return _0x5ad4ad;}})[_0xb022('0x4e')](function(_0x400d8a){logger['error'](_0xb022('0x59'),_0x400d8a);throw _0x400d8a;});}return _0x5ad4ad;})[_0xb022('0x29')](respondWithResult(_0x4f19ff,0xc9))['catch'](handleError(_0x4f19ff,null));};exports[_0xb022('0x27')]=function(_0x2b646e,_0x164a03){if(_0x2b646e['body']['id']){delete _0x2b646e['body']['id'];}return db['Team'][_0xb022('0x56')]({'where':{'id':_0x2b646e[_0xb022('0x4b')]['id']}})[_0xb022('0x29')](handleEntityNotFound(_0x164a03,null))[_0xb022('0x29')](saveUpdates(_0x2b646e[_0xb022('0x50')],null))[_0xb022('0x29')](respondWithResult(_0x164a03,null))[_0xb022('0x4e')](handleError(_0x164a03,null));};exports[_0xb022('0x28')]=function(_0x29578a,_0x7f225f){return db[_0xb022('0x31')][_0xb022('0x56')]({'where':{'id':_0x29578a[_0xb022('0x4b')]['id']}})['then'](handleEntityNotFound(_0x7f225f,null))[_0xb022('0x29')](removeEntity(_0x7f225f,null))['catch'](handleError(_0x7f225f,null));};exports[_0xb022('0x5a')]=function(_0x50009a,_0x5c1d2e,_0x490c65){return db['Team'][_0xb022('0x5b')]({'where':{'id':_0x50009a['params']['id']}})[_0xb022('0x29')](handleEntityNotFound(_0x5c1d2e,null))['then'](function(_0x5d4bca){if(!_0x50009a[_0xb022('0x37')]['channel']||!utils[_0xb022('0x5c')](_0x50009a[_0xb022('0x37')][_0xb022('0x5d')])){throw new db[(_0xb022('0x5e'))][(_0xb022('0x5f'))](_0xb022('0x60'));}var _0x3d277e={};var _0x46dda2={};_0x46dda2[_0xb022('0x36')]=_['keys'](db[_['capitalize'](_0x50009a[_0xb022('0x37')][_0xb022('0x5d')]['toLowerCase']())+_0xb022('0x61')][_0xb022('0x32')]);_0x46dda2[_0xb022('0x37')]=_[_0xb022('0x38')](_0x50009a[_0xb022('0x37')]);_0x46dda2['filters']=_[_0xb022('0x3a')](_0x46dda2[_0xb022('0x36')],_0x46dda2[_0xb022('0x37')]);_0x3d277e[_0xb022('0x3b')]=_['intersection'](_0x46dda2[_0xb022('0x36')],qs['fields'](_0x50009a[_0xb022('0x37')][_0xb022('0x3c')]));_0x3d277e[_0xb022('0x3b')]=_0x3d277e[_0xb022('0x3b')][_0xb022('0x3d')]?_0x3d277e[_0xb022('0x3b')]:_0x46dda2[_0xb022('0x36')];_0x3d277e[_0xb022('0x22')]=qs['limit'](_0x50009a['query'][_0xb022('0x22')]);_0x3d277e[_0xb022('0x21')]=qs[_0xb022('0x21')](_0x50009a[_0xb022('0x37')]['offset']);_0x3d277e[_0xb022('0x40')]=qs[_0xb022('0x41')](_0x50009a['query'][_0xb022('0x41')]);_0x3d277e[_0xb022('0x42')]=qs['filters'](_[_0xb022('0x43')](_0x50009a[_0xb022('0x37')],_0x46dda2[_0xb022('0x39')]));_0x3d277e=_['merge']({},_0x3d277e,_0x50009a['options']);return _0x5d4bca[_0xb022('0x52')+_[_0xb022('0x62')](_0x50009a[_0xb022('0x37')]['channel'][_0xb022('0x63')]())+_0xb022('0x64')](_0x3d277e);})[_0xb022('0x29')](respondWithResult(_0x5c1d2e,null))[_0xb022('0x4e')](handleError(_0x5c1d2e,null));};exports[_0xb022('0x65')]=function(_0x4ec6c7,_0x436656,_0x1244ae){return db[_0xb022('0x31')]['findOne']({'where':{'id':_0x4ec6c7['params']['id']}})['then'](function(_0x2afb32){if(_0x2afb32){if(!_0x4ec6c7['body']['channel']||!utils[_0xb022('0x5c')](_0x4ec6c7[_0xb022('0x50')][_0xb022('0x5d')])){throw new db[(_0xb022('0x5e'))][(_0xb022('0x5f'))](_0xb022('0x60'));}return _0x2afb32[_0xb022('0x66')+_[_0xb022('0x62')](_0x4ec6c7['body']['channel'][_0xb022('0x63')]())+_0xb022('0x64')](_0x4ec6c7[_0xb022('0x50')][_0xb022('0x67')]);}return null;})['then'](handleEntityNotFound(_0x436656,null))[_0xb022('0x29')](respondWithStatusCode(_0x436656,null))[_0xb022('0x4e')](handleError(_0x436656,null));};exports[_0xb022('0x68')]=function(_0x351246,_0x293c80,_0x2b511a){return db[_0xb022('0x31')]['findOne']({'where':{'id':_0x351246[_0xb022('0x4b')]['id']}})[_0xb022('0x29')](function(_0x4180cd){if(_0x4180cd){if(!_0x351246['query']['channel']||!utils[_0xb022('0x5c')](_0x351246[_0xb022('0x37')][_0xb022('0x5d')])){throw new db[(_0xb022('0x5e'))]['ValidationError'](_0xb022('0x60'));}return _0x4180cd['remove'+_[_0xb022('0x62')](_0x351246[_0xb022('0x37')][_0xb022('0x5d')][_0xb022('0x63')]())+_0xb022('0x64')](_0x351246[_0xb022('0x37')][_0xb022('0x67')]);}return null;})[_0xb022('0x29')](handleEntityNotFound(_0x293c80,null))['then'](respondWithStatusCode(_0x293c80,null))[_0xb022('0x4e')](handleError(_0x293c80,null));};exports[_0xb022('0x69')]=function(_0x3644e0,_0x17c17c,_0x516420){return db[_0xb022('0x31')][_0xb022('0x56')]({'where':{'id':_0x3644e0[_0xb022('0x4b')]['id']}})[_0xb022('0x29')](handleEntityNotFound(_0x17c17c,null))[_0xb022('0x29')](function(_0xb5d587){if(_0xb5d587){var _0x4ebc2f=[_0xb022('0x6a'),_0xb022('0x6b'),_0xb022('0x6c'),'Sms',_0xb022('0x6d'),'Openchannel',_0xb022('0x6e')];return BPromise[_0xb022('0x6f')](_0x4ebc2f,function(_0x175dd8){return _0xb5d587[_0xb022('0x52')+_0x175dd8+_0xb022('0x64')]({'attributes':['id',_0xb022('0x2d')]})[_0xb022('0x29')](function(_0x1300db){return BPromise[_0xb022('0x6f')](_0x1300db,function(_0x24d41b){return _0x24d41b[_0xb022('0x69')](_0x3644e0['body'][_0xb022('0x67')])[_0xb022('0x29')](function(){if(_0x175dd8==='Voice'){return db[_0xb022('0x70')][_0xb022('0x48')]({'where':{'id':_0x3644e0[_0xb022('0x50')]['ids']},'attributes':['id',_0xb022('0x2d'),_0xb022('0x71'),_0xb022('0x72'),_0xb022('0x73')],'raw':!![]})['then'](function(_0x4ea8e0){return BPromise[_0xb022('0x6f')](_[_0xb022('0x44')](_0x4ea8e0,{'online':0x1}),function(_0x339da8){return db[_0xb022('0x74')]['upsert']({'membername':_0x339da8[_0xb022('0x2d')],'UserId':_0x339da8['id'],'queue_name':_0x24d41b[_0xb022('0x2d')],'VoiceQueueId':_0x24d41b['id'],'interface':_[_0xb022('0x75')](_0x339da8[_0xb022('0x73')])?util[_0xb022('0x76')](_0xb022('0x77'),_0x339da8['name']):_0x339da8[_0xb022('0x73')],'paused':_0x339da8['voicePause']||![],'penalty':0x0});});});}});});})['then'](function(){return _0xb5d587;});})[_0xb022('0x29')](function(){return _0xb5d587;});}})[_0xb022('0x29')](function(_0x1b20f6){if(_0x1b20f6){return _0x1b20f6[_0xb022('0x69')](_0x3644e0[_0xb022('0x50')][_0xb022('0x67')],_['omit'](_0x3644e0[_0xb022('0x50')],['ids','id'])||{})[_0xb022('0x78')](function(_0x5c1958){for(var _0x23d21e=0x0;_0x23d21e<_0x3644e0[_0xb022('0x50')]['ids']['length'];_0x23d21e+=0x1){socket[_0xb022('0x79')](_0xb022('0x7a'),{'UserId':_0x3644e0[_0xb022('0x50')]['ids'][_0x23d21e],'TeamId':_0x3644e0[_0xb022('0x4b')]['id']});}return _0x5c1958;});}})[_0xb022('0x29')](respondWithResult(_0x17c17c,null))[_0xb022('0x4e')](handleError(_0x17c17c,null));};exports[_0xb022('0x7b')]=function(_0x206e48,_0x4d94ad,_0x47d91f){return db[_0xb022('0x31')][_0xb022('0x56')]({'where':{'id':_0x206e48[_0xb022('0x4b')]['id']}})['then'](handleEntityNotFound(_0x4d94ad,null))[_0xb022('0x29')](function(_0x56c159){if(_0x56c159){return BPromise['each'](['voice','chat','mail',_0xb022('0x7c'),_0xb022('0x7d'),_0xb022('0x7e'),_0xb022('0x7f')],function(_0x486659){return _0x56c159[_0xb022('0x52')+_[_0xb022('0x62')](_0x486659)+'Queues']({'attributes':['id','name']})[_0xb022('0x29')](function(_0x38444f){return BPromise[_0xb022('0x6f')](_0x38444f,function(_0x3fc931){return _0x3fc931[_0xb022('0x7b')](_0x206e48['query']['ids'])[_0xb022('0x29')](function(){if(_0x486659===_0xb022('0x80')){return db['UserVoiceQueueRt'][_0xb022('0x28')]({'where':{'VoiceQueueId':_0x3fc931['id'],'UserId':_0x206e48[_0xb022('0x37')][_0xb022('0x67')]}});}});});})[_0xb022('0x29')](function(){return _0x56c159;});})[_0xb022('0x29')](function(){return _0x56c159;});}})['then'](function(_0x3e03b1){if(_0x3e03b1){return _0x3e03b1['removeAgents'](_0x206e48['query'][_0xb022('0x67')])[_0xb022('0x29')](function(){if(_[_0xb022('0x81')](_0x206e48[_0xb022('0x37')][_0xb022('0x67')])){for(var _0x3fb026=0x0;_0x3fb026<_0x206e48['query'][_0xb022('0x67')][_0xb022('0x3d')];_0x3fb026+=0x1){socket[_0xb022('0x79')](_0xb022('0x82'),{'UserId':Number(_0x206e48[_0xb022('0x37')][_0xb022('0x67')][_0x3fb026]),'TeamId':Number(_0x206e48[_0xb022('0x4b')]['id'])});}}else{socket[_0xb022('0x79')]('userTeam:remove',{'UserId':Number(_0x206e48[_0xb022('0x37')][_0xb022('0x67')]),'TeamId':Number(_0x206e48[_0xb022('0x4b')]['id'])});}});}})[_0xb022('0x29')](respondWithStatusCode(_0x4d94ad,null))[_0xb022('0x4e')](handleError(_0x4d94ad,null));};exports['getAgents']=function(_0x1e0474,_0x199195,_0x229a9b){var _0x4e53f3={};var _0x323474={};var _0x383731;var _0x34d5f3;return db[_0xb022('0x31')][_0xb022('0x5b')]({'where':{'id':_0x1e0474[_0xb022('0x4b')]['id']}})[_0xb022('0x29')](handleEntityNotFound(_0x199195,null))[_0xb022('0x29')](function(_0x3ea5a4){if(_0x3ea5a4){_0x383731=_0x3ea5a4;_0x323474['model']=_[_0xb022('0x38')](db[_0xb022('0x70')][_0xb022('0x32')]);_0x323474[_0xb022('0x37')]=_[_0xb022('0x38')](_0x1e0474['query']);_0x323474[_0xb022('0x39')]=_[_0xb022('0x3a')](_0x323474[_0xb022('0x36')],_0x323474[_0xb022('0x37')]);_0x4e53f3[_0xb022('0x3b')]=_[_0xb022('0x3a')](_0x323474['model'],qs['fields'](_0x1e0474[_0xb022('0x37')][_0xb022('0x3c')]));_0x4e53f3[_0xb022('0x3b')]=_0x4e53f3['attributes'][_0xb022('0x3d')]?_0x4e53f3[_0xb022('0x3b')]:_0x323474[_0xb022('0x36')];_0x4e53f3[_0xb022('0x40')]=qs[_0xb022('0x41')](_0x1e0474['query'][_0xb022('0x41')]);_0x4e53f3[_0xb022('0x42')]=qs['filters'](_['pick'](_0x1e0474[_0xb022('0x37')],_0x323474['filters']));if(_0x1e0474[_0xb022('0x37')][_0xb022('0x44')]){_0x4e53f3['where']=_[_0xb022('0x45')](_0x4e53f3[_0xb022('0x42')],{'$or':_[_0xb022('0x30')](_0x4e53f3[_0xb022('0x3b')],function(_0x39676e){var _0x5ae154={};_0x5ae154[_0x39676e]={'$like':'%'+_0x1e0474['query'][_0xb022('0x44')]+'%'};return _0x5ae154;})});}_0x4e53f3=_[_0xb022('0x45')]({},_0x4e53f3,_0x1e0474[_0xb022('0x4d')]);return _0x383731[_0xb022('0x83')](_0x4e53f3);}})['then'](function(_0x29cd89){if(_0x29cd89){_0x34d5f3=_0x29cd89[_0xb022('0x3d')];if(!_0x1e0474[_0xb022('0x37')][_0xb022('0x3e')]('nolimit')){_0x4e53f3[_0xb022('0x22')]=qs[_0xb022('0x22')](_0x1e0474['query'][_0xb022('0x22')]);_0x4e53f3[_0xb022('0x21')]=qs[_0xb022('0x21')](_0x1e0474['query']['offset']);}return _0x383731[_0xb022('0x83')](_0x4e53f3);}})[_0xb022('0x29')](function(_0x1619ec){if(_0x1619ec){return _0x1619ec?{'count':_0x34d5f3,'rows':_0x1619ec}:null;}})[_0xb022('0x29')](respondWithResult(_0x199195,null))[_0xb022('0x4e')](handleError(_0x199195,null));};
\ No newline at end of file