Built motion from commit (unavailable).|2.2.0
[motion2.git] / server / api / team / team.controller.js
index 45ea341..37b34b2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x955f=['findAll','loginInPause','voicePause','interface','UserVoiceQueueRt','upsert','format','omit','spread','emit','userTeam:save','removeAgents','userTeam:remove','getAgents','findOne','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','util','sox','to-csv','ejs','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/logger','../../config/utils','../../mysqldb','redis','defaults','localhost','register','sendStatus','status','end','json','count','offset','set','Content-Range','apply','reject','update','then','destroy','get','Teams','error','stack','name','index','Team','rawAttributes','model','keys','query','dateStart','dateEnd','filters','intersection','fields','attributes','hasOwnProperty','nolimit','limit','order','sort','where','add','day','filter','merge','map','options','includeAll','rows','show','params','length','create','user','role','UserProfileSection','find','userProfileId','autoAssociation','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','getQueues','channel','Sequelize','ValidationError','capitalize','Queue','pick','toLowerCase','Queues','addQueues','isValidChannel','Unknown\x20channel','ids','removeQueues','remove','addAgents','each','voice','chat','sms','fax','openchannel','User'];(function(_0x561e66,_0x2c061d){var _0x374c72=function(_0x32c041){while(--_0x32c041){_0x561e66['push'](_0x561e66['shift']());}};_0x374c72(++_0x2c061d);}(_0x955f,0x1eb));var _0xf955=function(_0x3f9680,_0x18c75e){_0x3f9680=_0x3f9680-0x0;var _0x336528=_0x955f[_0x3f9680];return _0x336528;};'use strict';var pdf=require(_0xf955('0x0'));var emlformat=require(_0xf955('0x1'));var rimraf=require(_0xf955('0x2'));var zipdir=require(_0xf955('0x3'));var jsonpatch=require(_0xf955('0x4'));var rp=require('request-promise');var moment=require(_0xf955('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xf955('0x6'));var path=require('path');var sox=require(_0xf955('0x7'));var csv=require(_0xf955('0x8'));var ejs=require(_0xf955('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0xf955('0xa'));var crypto=require(_0xf955('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xf955('0xc'));var toCsv=require(_0xf955('0x8'));var querystring=require(_0xf955('0xd'));var Papa=require(_0xf955('0xe'));var Redis=require(_0xf955('0xf'));var qs=require(_0xf955('0x10'));var logger=require(_0xf955('0x11'))('api');var utils=require(_0xf955('0x12'));var config=require('../../config/environment');var db=require(_0xf955('0x13'))['db'];config[_0xf955('0x14')]=_[_0xf955('0x15')](config['redis'],{'host':_0xf955('0x16'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf955('0x14')]));require('./team.socket')[_0xf955('0x17')](socket);function respondWithStatusCode(_0x2ff7e5,_0x22507a){_0x22507a=_0x22507a||0xcc;return function(_0x109bc5){if(_0x109bc5){return _0x2ff7e5[_0xf955('0x18')](_0x22507a);}return _0x2ff7e5[_0xf955('0x19')](_0x22507a)[_0xf955('0x1a')]();};}function respondWithResult(_0x2783f2,_0x3c6af7){_0x3c6af7=_0x3c6af7||0xc8;return function(_0x24e75c){if(_0x24e75c){return _0x2783f2['status'](_0x3c6af7)[_0xf955('0x1b')](_0x24e75c);}};}function respondWithFilteredResult(_0x54e60b,_0x3139d5){return function(_0x3a814f){if(_0x3a814f){var _0x2f881b=_0x3a814f[_0xf955('0x1c')],_0x15c07c=_0x3139d5[_0xf955('0x1d')],_0x50930d=_0x3139d5[_0xf955('0x1d')]+_0x3139d5['limit'],_0x5ac6cb;if(_0x50930d>=_0x2f881b){_0x50930d=_0x2f881b;_0x5ac6cb=0xc8;}else{_0x5ac6cb=0xce;}_0x54e60b[_0xf955('0x19')](_0x5ac6cb);return _0x54e60b[_0xf955('0x1e')](_0xf955('0x1f'),_0x15c07c+'-'+_0x50930d+'/'+_0x2f881b)[_0xf955('0x1b')](_0x3a814f);}return null;};}function patchUpdates(_0x3ae4fb){return function(_0x5f4d9a){try{jsonpatch[_0xf955('0x20')](_0x5f4d9a,_0x3ae4fb,!![]);}catch(_0x3dbbe8){return BPromise[_0xf955('0x21')](_0x3dbbe8);}return _0x5f4d9a['save']();};}function saveUpdates(_0x43a5f2,_0x5daa73){return function(_0x21ae24){if(_0x21ae24){return _0x21ae24[_0xf955('0x22')](_0x43a5f2)[_0xf955('0x23')](function(_0xa4ebb4){return _0xa4ebb4;});}return null;};}function removeEntity(_0x160071,_0x565641){return function(_0x25f4f2){if(_0x25f4f2){return _0x25f4f2[_0xf955('0x24')]()[_0xf955('0x23')](function(){var _0x13a1a7=_0x25f4f2[_0xf955('0x25')]({'plain':!![]});var _0x102e36=_0xf955('0x26');return db['UserProfileResource'][_0xf955('0x24')]({'where':{'type':_0x102e36,'resourceId':_0x13a1a7['id']}})[_0xf955('0x23')](function(){return _0x25f4f2;});})[_0xf955('0x23')](function(){_0x160071[_0xf955('0x19')](0xcc)[_0xf955('0x1a')]();});}};}function handleEntityNotFound(_0x13a86d,_0x3796f7){return function(_0x51f3ab){if(!_0x51f3ab){_0x13a86d[_0xf955('0x18')](0x194);}return _0x51f3ab;};}function handleError(_0x145098,_0x41c9f6){_0x41c9f6=_0x41c9f6||0x1f4;return function(_0xbd0b74){logger[_0xf955('0x27')](_0xbd0b74[_0xf955('0x28')]);if(_0xbd0b74['name']){delete _0xbd0b74[_0xf955('0x29')];}_0x145098[_0xf955('0x19')](_0x41c9f6)['send'](_0xbd0b74);};}exports[_0xf955('0x2a')]=function(_0x2c8df1,_0xf3c870){var _0x1ef794={},_0x59bfb5={},_0x3a951c={'count':0x0,'rows':[]};var _0x518fb3=db[_0xf955('0x2b')][_0xf955('0x2c')];_0x59bfb5[_0xf955('0x2d')]=_[_0xf955('0x2e')](_0x518fb3);var _0x1e8024={'dateStart':_0x2c8df1[_0xf955('0x2f')][_0xf955('0x30')],'dateEnd':_0x2c8df1[_0xf955('0x2f')]['dateEnd']};delete _0x2c8df1[_0xf955('0x2f')][_0xf955('0x30')];delete _0x2c8df1[_0xf955('0x2f')][_0xf955('0x31')];_0x59bfb5['query']=_[_0xf955('0x2e')](_0x2c8df1[_0xf955('0x2f')]);_0x59bfb5[_0xf955('0x32')]=_[_0xf955('0x33')](_0x59bfb5[_0xf955('0x2d')],_0x59bfb5['query']);_0x1ef794['attributes']=_['intersection'](_0x59bfb5[_0xf955('0x2d')],qs[_0xf955('0x34')](_0x2c8df1[_0xf955('0x2f')][_0xf955('0x34')]));_0x1ef794[_0xf955('0x35')]=_0x1ef794[_0xf955('0x35')]['length']?_0x1ef794[_0xf955('0x35')]:_0x59bfb5['model'];if(!_0x2c8df1[_0xf955('0x2f')][_0xf955('0x36')](_0xf955('0x37'))){_0x1ef794['limit']=qs[_0xf955('0x38')](_0x2c8df1['query'][_0xf955('0x38')]);_0x1ef794[_0xf955('0x1d')]=qs[_0xf955('0x1d')](_0x2c8df1[_0xf955('0x2f')]['offset']);}_0x1ef794[_0xf955('0x39')]=qs[_0xf955('0x3a')](_0x2c8df1['query'][_0xf955('0x3a')]);_0x1ef794[_0xf955('0x3b')]=qs[_0xf955('0x32')](_['pick'](_0x2c8df1[_0xf955('0x2f')],_0x59bfb5[_0xf955('0x32')]));if(_0x1e8024[_0xf955('0x30')]){if(_0x1e8024['dateEnd']){_0x1e8024[_0xf955('0x31')]=moment(_0x1e8024[_0xf955('0x31')])[_0xf955('0x3c')](0x1,_0xf955('0x3d'));}else{_0x1e8024[_0xf955('0x31')]=moment(_0x1e8024[_0xf955('0x30')])[_0xf955('0x3c')](0x1,_0xf955('0x3d'));}_['merge'](_0x1ef794[_0xf955('0x3b')],{'createdAt':{'$gte':_0x1e8024[_0xf955('0x30')],'$lte':_0x1e8024[_0xf955('0x31')]}});}if(_0x2c8df1[_0xf955('0x2f')][_0xf955('0x3e')]){_0x1ef794[_0xf955('0x3b')]=_[_0xf955('0x3f')](_0x1ef794[_0xf955('0x3b')],{'$or':_[_0xf955('0x40')](_0x1ef794[_0xf955('0x35')],function(_0x713954){var _0x1c72b8={};_0x1c72b8[_0x713954]={'$like':'%'+_0x2c8df1[_0xf955('0x2f')][_0xf955('0x3e')]+'%'};return _0x1c72b8;})});}_0x1ef794=_[_0xf955('0x3f')]({},_0x1ef794,_0x2c8df1[_0xf955('0x41')]);var _0x356ec2={'where':_0x1ef794[_0xf955('0x3b')]};return db[_0xf955('0x2b')]['count'](_0x356ec2)[_0xf955('0x23')](function(_0x25d809){_0x3a951c[_0xf955('0x1c')]=_0x25d809;if(_0x2c8df1['query'][_0xf955('0x42')]){_0x1ef794['include']=[{'all':!![]}];}return db[_0xf955('0x2b')]['findAll'](_0x1ef794);})[_0xf955('0x23')](function(_0x24cb74){_0x3a951c[_0xf955('0x43')]=_0x24cb74;return _0x3a951c;})[_0xf955('0x23')](respondWithFilteredResult(_0xf3c870,_0x1ef794))['catch'](handleError(_0xf3c870,null));};exports[_0xf955('0x44')]=function(_0xdb1cc,_0x12321e){var _0x4f2d55={'raw':![],'where':{'id':_0xdb1cc[_0xf955('0x45')]['id']}},_0x5e98ae={};_0x5e98ae[_0xf955('0x2d')]=_[_0xf955('0x2e')](db[_0xf955('0x2b')]['rawAttributes']);_0x5e98ae[_0xf955('0x2f')]=_[_0xf955('0x2e')](_0xdb1cc[_0xf955('0x2f')]);_0x5e98ae['filters']=_[_0xf955('0x33')](_0x5e98ae['model'],_0x5e98ae[_0xf955('0x2f')]);_0x4f2d55[_0xf955('0x35')]=_[_0xf955('0x33')](_0x5e98ae['model'],qs[_0xf955('0x34')](_0xdb1cc[_0xf955('0x2f')][_0xf955('0x34')]));_0x4f2d55[_0xf955('0x35')]=_0x4f2d55['attributes'][_0xf955('0x46')]?_0x4f2d55[_0xf955('0x35')]:_0x5e98ae[_0xf955('0x2d')];if(_0xdb1cc[_0xf955('0x2f')][_0xf955('0x42')]){_0x4f2d55['include']=[{'all':!![]}];}_0x4f2d55=_[_0xf955('0x3f')]({},_0x4f2d55,_0xdb1cc['options']);return db[_0xf955('0x2b')]['find'](_0x4f2d55)[_0xf955('0x23')](handleEntityNotFound(_0x12321e,null))['then'](respondWithResult(_0x12321e,null))['catch'](handleError(_0x12321e,null));};exports[_0xf955('0x47')]=function(_0x45c7fe,_0x4961cc){return db[_0xf955('0x2b')]['create'](_0x45c7fe['body'],{})['then'](function(_0x5c427c){var _0x3c37e2=_0x45c7fe[_0xf955('0x48')]['get']({'plain':!![]});if(!_0x3c37e2)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3c37e2[_0xf955('0x49')]===_0xf955('0x48')){var _0x460052=_0x5c427c[_0xf955('0x25')]({'plain':!![]});var _0x1b7b21=_0xf955('0x26');return db[_0xf955('0x4a')][_0xf955('0x4b')]({'where':{'name':_0x1b7b21,'userProfileId':_0x3c37e2[_0xf955('0x4c')]},'raw':!![]})[_0xf955('0x23')](function(_0x1b7b73){if(_0x1b7b73&&_0x1b7b73[_0xf955('0x4d')]===0x0){return db['UserProfileResource'][_0xf955('0x47')]({'name':_0x460052[_0xf955('0x29')],'resourceId':_0x460052['id'],'type':_0x1b7b73[_0xf955('0x29')],'sectionId':_0x1b7b73['id']},{})[_0xf955('0x23')](function(){return _0x5c427c;});}else{return _0x5c427c;}})[_0xf955('0x4e')](function(_0x4dc34b){logger[_0xf955('0x27')](_0xf955('0x4f'),_0x4dc34b);throw _0x4dc34b;});}return _0x5c427c;})[_0xf955('0x23')](respondWithResult(_0x4961cc,0xc9))[_0xf955('0x4e')](handleError(_0x4961cc,null));};exports[_0xf955('0x22')]=function(_0x9057df,_0x228d59){if(_0x9057df[_0xf955('0x50')]['id']){delete _0x9057df[_0xf955('0x50')]['id'];}return db[_0xf955('0x2b')]['find']({'where':{'id':_0x9057df[_0xf955('0x45')]['id']}})[_0xf955('0x23')](handleEntityNotFound(_0x228d59,null))[_0xf955('0x23')](saveUpdates(_0x9057df[_0xf955('0x50')],null))[_0xf955('0x23')](respondWithResult(_0x228d59,null))[_0xf955('0x4e')](handleError(_0x228d59,null));};exports[_0xf955('0x24')]=function(_0x30b673,_0x948963){return db[_0xf955('0x2b')][_0xf955('0x4b')]({'where':{'id':_0x30b673[_0xf955('0x45')]['id']}})['then'](handleEntityNotFound(_0x948963,null))[_0xf955('0x23')](removeEntity(_0x948963,null))[_0xf955('0x4e')](handleError(_0x948963,null));};exports[_0xf955('0x51')]=function(_0x3eb727,_0x3c2cfd,_0x3171ba){return db[_0xf955('0x2b')]['findOne']({'where':{'id':_0x3eb727['params']['id']}})['then'](handleEntityNotFound(_0x3c2cfd,null))[_0xf955('0x23')](function(_0x530ec7){if(!_0x3eb727['query'][_0xf955('0x52')]||!utils['isValidChannel'](_0x3eb727[_0xf955('0x2f')][_0xf955('0x52')])){throw new db[(_0xf955('0x53'))][(_0xf955('0x54'))]('Unknown\x20channel');}var _0x349d76={};var _0x9e3437={};_0x9e3437[_0xf955('0x2d')]=_[_0xf955('0x2e')](db[_[_0xf955('0x55')](_0x3eb727['query'][_0xf955('0x52')]['toLowerCase']())+_0xf955('0x56')][_0xf955('0x2c')]);_0x9e3437[_0xf955('0x2f')]=_['keys'](_0x3eb727[_0xf955('0x2f')]);_0x9e3437[_0xf955('0x32')]=_[_0xf955('0x33')](_0x9e3437[_0xf955('0x2d')],_0x9e3437[_0xf955('0x2f')]);_0x349d76[_0xf955('0x35')]=_[_0xf955('0x33')](_0x9e3437['model'],qs['fields'](_0x3eb727[_0xf955('0x2f')][_0xf955('0x34')]));_0x349d76[_0xf955('0x35')]=_0x349d76[_0xf955('0x35')][_0xf955('0x46')]?_0x349d76[_0xf955('0x35')]:_0x9e3437[_0xf955('0x2d')];_0x349d76[_0xf955('0x38')]=qs[_0xf955('0x38')](_0x3eb727[_0xf955('0x2f')][_0xf955('0x38')]);_0x349d76['offset']=qs[_0xf955('0x1d')](_0x3eb727['query'][_0xf955('0x1d')]);_0x349d76['order']=qs['sort'](_0x3eb727[_0xf955('0x2f')][_0xf955('0x3a')]);_0x349d76['where']=qs[_0xf955('0x32')](_[_0xf955('0x57')](_0x3eb727['query'],_0x9e3437['filters']));_0x349d76=_[_0xf955('0x3f')]({},_0x349d76,_0x3eb727[_0xf955('0x41')]);return _0x530ec7[_0xf955('0x25')+_['capitalize'](_0x3eb727[_0xf955('0x2f')][_0xf955('0x52')][_0xf955('0x58')]())+_0xf955('0x59')](_0x349d76);})[_0xf955('0x23')](respondWithResult(_0x3c2cfd,null))[_0xf955('0x4e')](handleError(_0x3c2cfd,null));};exports[_0xf955('0x5a')]=function(_0xf1e40b,_0x5a45da,_0x3960ec){return db[_0xf955('0x2b')]['findOne']({'where':{'id':_0xf1e40b[_0xf955('0x45')]['id']}})[_0xf955('0x23')](function(_0x54dac){if(_0x54dac){if(!_0xf1e40b[_0xf955('0x50')]['channel']||!utils[_0xf955('0x5b')](_0xf1e40b[_0xf955('0x50')]['channel'])){throw new db['Sequelize'][(_0xf955('0x54'))](_0xf955('0x5c'));}return _0x54dac[_0xf955('0x3c')+_[_0xf955('0x55')](_0xf1e40b['body'][_0xf955('0x52')][_0xf955('0x58')]())+_0xf955('0x59')](_0xf1e40b[_0xf955('0x50')][_0xf955('0x5d')]);}return null;})[_0xf955('0x23')](handleEntityNotFound(_0x5a45da,null))[_0xf955('0x23')](respondWithStatusCode(_0x5a45da,null))[_0xf955('0x4e')](handleError(_0x5a45da,null));};exports[_0xf955('0x5e')]=function(_0x12d8d1,_0x2c7ba5,_0x102ef0){return db[_0xf955('0x2b')]['findOne']({'where':{'id':_0x12d8d1[_0xf955('0x45')]['id']}})[_0xf955('0x23')](function(_0x1d9469){if(_0x1d9469){if(!_0x12d8d1[_0xf955('0x2f')]['channel']||!utils[_0xf955('0x5b')](_0x12d8d1[_0xf955('0x2f')][_0xf955('0x52')])){throw new db[(_0xf955('0x53'))][(_0xf955('0x54'))](_0xf955('0x5c'));}return _0x1d9469[_0xf955('0x5f')+_[_0xf955('0x55')](_0x12d8d1[_0xf955('0x2f')][_0xf955('0x52')][_0xf955('0x58')]())+'Queues'](_0x12d8d1[_0xf955('0x2f')][_0xf955('0x5d')]);}return null;})[_0xf955('0x23')](handleEntityNotFound(_0x2c7ba5,null))[_0xf955('0x23')](respondWithStatusCode(_0x2c7ba5,null))[_0xf955('0x4e')](handleError(_0x2c7ba5,null));};exports[_0xf955('0x60')]=function(_0x1cd55b,_0x57f27f,_0xa83204){return db['Team'][_0xf955('0x4b')]({'where':{'id':_0x1cd55b['params']['id']}})[_0xf955('0x23')](handleEntityNotFound(_0x57f27f,null))[_0xf955('0x23')](function(_0x3f76ce){if(_0x3f76ce){return BPromise[_0xf955('0x61')]([_0xf955('0x62'),_0xf955('0x63'),'mail',_0xf955('0x64'),_0xf955('0x65'),_0xf955('0x66')],function(_0x4e2410){return _0x3f76ce['get'+_[_0xf955('0x55')](_0x4e2410)+_0xf955('0x59')]({'attributes':['id',_0xf955('0x29')]})['then'](function(_0x3ee844){return BPromise['each'](_0x3ee844,function(_0x36c23e){return _0x36c23e['addAgents'](_0x1cd55b[_0xf955('0x50')][_0xf955('0x5d')])[_0xf955('0x23')](function(){if(_0x4e2410==='voice'){return db[_0xf955('0x67')][_0xf955('0x68')]({'where':{'id':_0x1cd55b[_0xf955('0x50')]['ids']},'attributes':['id',_0xf955('0x29'),_0xf955('0x69'),_0xf955('0x6a'),_0xf955('0x6b')],'raw':!![]});}})[_0xf955('0x23')](function(_0x130e1a){if(_0x4e2410===_0xf955('0x62')){return BPromise['each'](_0x130e1a,function(_0x308c9e){return db[_0xf955('0x6c')][_0xf955('0x6d')]({'membername':_0x308c9e[_0xf955('0x29')],'UserId':_0x308c9e['id'],'queue_name':_0x36c23e[_0xf955('0x29')],'VoiceQueueId':_0x36c23e['id'],'interface':_['isNil'](_0x308c9e[_0xf955('0x6b')])?util[_0xf955('0x6e')]('SIP/%s',_0x308c9e['name']):_0x308c9e[_0xf955('0x6b')],'paused':_0x308c9e[_0xf955('0x6a')]||![],'penalty':0x0});});}});});})[_0xf955('0x23')](function(){return _0x3f76ce;});})[_0xf955('0x23')](function(){return _0x3f76ce;});}})['then'](function(_0x39f7ab){if(_0x39f7ab){return _0x39f7ab['addAgents'](_0x1cd55b['body'][_0xf955('0x5d')],_[_0xf955('0x6f')](_0x1cd55b['body'],['ids','id'])||{})[_0xf955('0x70')](function(_0x10f8b6){for(var _0x13e548=0x0;_0x13e548<_0x1cd55b['body']['ids'][_0xf955('0x46')];_0x13e548+=0x1){socket[_0xf955('0x71')](_0xf955('0x72'),{'UserId':_0x1cd55b['body']['ids'][_0x13e548],'TeamId':_0x1cd55b['params']['id']});}return _0x10f8b6;});}})['then'](respondWithResult(_0x57f27f,null))[_0xf955('0x4e')](handleError(_0x57f27f,null));};exports['removeAgents']=function(_0x44efad,_0x452091,_0x3b04da){var _0x3fa45e;return db[_0xf955('0x2b')]['find']({'where':{'id':_0x44efad[_0xf955('0x45')]['id']}})[_0xf955('0x23')](handleEntityNotFound(_0x452091,null))[_0xf955('0x23')](function(_0x39b7b4){if(_0x39b7b4){return BPromise['each']([_0xf955('0x62'),_0xf955('0x63'),'mail',_0xf955('0x64'),_0xf955('0x65'),_0xf955('0x66')],function(_0x25d7d6){return _0x39b7b4[_0xf955('0x25')+_[_0xf955('0x55')](_0x25d7d6)+'Queues']({'attributes':['id','name']})[_0xf955('0x23')](function(_0x545275){return BPromise[_0xf955('0x61')](_0x545275,function(_0x146bfc){return _0x146bfc[_0xf955('0x73')](_0x44efad[_0xf955('0x2f')]['ids'])['then'](function(){if(_0x25d7d6===_0xf955('0x62')){return db[_0xf955('0x6c')][_0xf955('0x24')]({'where':{'VoiceQueueId':_0x146bfc['id'],'UserId':_0x44efad[_0xf955('0x2f')][_0xf955('0x5d')]}});}});});})['then'](function(){return _0x39b7b4;});})[_0xf955('0x23')](function(){return _0x39b7b4;});}})[_0xf955('0x23')](function(_0x1ba6b1){if(_0x1ba6b1){return _0x1ba6b1[_0xf955('0x73')](_0x44efad['query']['ids'])[_0xf955('0x23')](function(_0x14123e){if(_['isArray'](_0x44efad[_0xf955('0x2f')][_0xf955('0x5d')])){for(var _0x395e56=0x0;_0x395e56<_0x44efad[_0xf955('0x2f')]['ids'][_0xf955('0x46')];_0x395e56+=0x1){socket[_0xf955('0x71')](_0xf955('0x74'),{'UserId':_0x44efad[_0xf955('0x2f')][_0xf955('0x5d')][_0x395e56],'TeamId':_0x44efad[_0xf955('0x45')]['id']});}}else{socket[_0xf955('0x71')]('userTeam:remove',{'UserId':_0x44efad['query']['ids'],'TeamId':_0x44efad[_0xf955('0x45')]['id']});}});}})[_0xf955('0x23')](respondWithStatusCode(_0x452091,null))[_0xf955('0x4e')](handleError(_0x452091,null));};exports[_0xf955('0x75')]=function(_0x1a672b,_0x35aa70,_0x17e25c){var _0x4d4ede={};var _0x513218={};var _0x1bce14;var _0x56eb0c;return db[_0xf955('0x2b')][_0xf955('0x76')]({'where':{'id':_0x1a672b[_0xf955('0x45')]['id']}})[_0xf955('0x23')](handleEntityNotFound(_0x35aa70,null))[_0xf955('0x23')](function(_0x1eb23){if(_0x1eb23){_0x1bce14=_0x1eb23;_0x513218[_0xf955('0x2d')]=_[_0xf955('0x2e')](db['User']['rawAttributes']);_0x513218['query']=_[_0xf955('0x2e')](_0x1a672b[_0xf955('0x2f')]);_0x513218[_0xf955('0x32')]=_[_0xf955('0x33')](_0x513218[_0xf955('0x2d')],_0x513218['query']);_0x4d4ede[_0xf955('0x35')]=_[_0xf955('0x33')](_0x513218[_0xf955('0x2d')],qs[_0xf955('0x34')](_0x1a672b[_0xf955('0x2f')][_0xf955('0x34')]));_0x4d4ede[_0xf955('0x35')]=_0x4d4ede[_0xf955('0x35')][_0xf955('0x46')]?_0x4d4ede['attributes']:_0x513218[_0xf955('0x2d')];_0x4d4ede['order']=qs[_0xf955('0x3a')](_0x1a672b[_0xf955('0x2f')][_0xf955('0x3a')]);_0x4d4ede[_0xf955('0x3b')]=qs[_0xf955('0x32')](_[_0xf955('0x57')](_0x1a672b[_0xf955('0x2f')],_0x513218['filters']));if(_0x1a672b[_0xf955('0x2f')]['filter']){_0x4d4ede[_0xf955('0x3b')]=_[_0xf955('0x3f')](_0x4d4ede['where'],{'$or':_[_0xf955('0x40')](_0x4d4ede[_0xf955('0x35')],function(_0x1d3aa1){var _0x11cc35={};_0x11cc35[_0x1d3aa1]={'$like':'%'+_0x1a672b[_0xf955('0x2f')][_0xf955('0x3e')]+'%'};return _0x11cc35;})});}_0x4d4ede=_[_0xf955('0x3f')]({},_0x4d4ede,_0x1a672b['options']);return _0x1bce14[_0xf955('0x75')](_0x4d4ede);}})[_0xf955('0x23')](function(_0x5cb03a){if(_0x5cb03a){_0x56eb0c=_0x5cb03a[_0xf955('0x46')];if(!_0x1a672b[_0xf955('0x2f')]['hasOwnProperty']('nolimit')){_0x4d4ede[_0xf955('0x38')]=qs[_0xf955('0x38')](_0x1a672b[_0xf955('0x2f')]['limit']);_0x4d4ede[_0xf955('0x1d')]=qs[_0xf955('0x1d')](_0x1a672b[_0xf955('0x2f')][_0xf955('0x1d')]);}return _0x1bce14[_0xf955('0x75')](_0x4d4ede);}})[_0xf955('0x23')](function(_0x1a2ecc){if(_0x1a2ecc){return _0x1a2ecc?{'count':_0x56eb0c,'rows':_0x1a2ecc}:null;}})[_0xf955('0x23')](respondWithResult(_0x35aa70,null))[_0xf955('0x4e')](handleError(_0x35aa70,null));};
\ No newline at end of file
+var _0xb10b=['role','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getQueues','findOne','channel','isValidChannel','ValidationError','Unknown\x20channel','capitalize','Queue','sort','toLowerCase','Queues','addQueues','Sequelize','ids','remove','each','voice','chat','mail','fax','openchannel','addAgents','voicePause','interface','upsert','isNil','format','SIP/%s','omit','spread','emit','userTeam:save','removeAgents','sms','userTeam:remove','getAgents','nolimit','html-pdf','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/utils','../../config/environment','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./team.socket','register','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','save','update','then','destroy','get','Teams','error','name','send','index','Team','rawAttributes','model','query','dateStart','dateEnd','keys','filters','intersection','attributes','fields','length','order','where','pick','add','day','filter','map','type','VIRTUAL','field','merge','options','includeAll','include','findAll','rows','catch','show','params','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0xb10b,0x12a));var _0xbb10=function(_0x188926,_0x1b2429){_0x188926=_0x188926-0x0;var _0x17f4bf=_0xb10b[_0x188926];return _0x17f4bf;};'use strict';var pdf=require(_0xbb10('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xbb10('0x1'));var zipdir=require(_0xbb10('0x2'));var jsonpatch=require(_0xbb10('0x3'));var rp=require('request-promise');var moment=require(_0xbb10('0x4'));var BPromise=require(_0xbb10('0x5'));var Mustache=require(_0xbb10('0x6'));var util=require(_0xbb10('0x7'));var path=require(_0xbb10('0x8'));var sox=require(_0xbb10('0x9'));var csv=require('to-csv');var ejs=require(_0xbb10('0xa'));var fs=require('fs');var _=require(_0xbb10('0xb'));var squel=require('squel');var crypto=require(_0xbb10('0xc'));var jsforce=require(_0xbb10('0xd'));var deskjs=require(_0xbb10('0xe'));var toCsv=require(_0xbb10('0xf'));var querystring=require(_0xbb10('0x10'));var Papa=require(_0xbb10('0x11'));var Redis=require(_0xbb10('0x12'));var qs=require(_0xbb10('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0xbb10('0x14'));var config=require(_0xbb10('0x15'));var db=require(_0xbb10('0x16'))['db'];config['redis']=_[_0xbb10('0x17')](config['redis'],{'host':_0xbb10('0x18'),'port':0x18eb});var socket=require(_0xbb10('0x19'))(new Redis(config[_0xbb10('0x1a')]));require(_0xbb10('0x1b'))[_0xbb10('0x1c')](socket);function respondWithStatusCode(_0x147230,_0x58a612){_0x58a612=_0x58a612||0xcc;return function(_0x26e021){if(_0x26e021){return _0x147230[_0xbb10('0x1d')](_0x58a612);}return _0x147230[_0xbb10('0x1e')](_0x58a612)[_0xbb10('0x1f')]();};}function respondWithResult(_0x3df17b,_0x2f2ebf){_0x2f2ebf=_0x2f2ebf||0xc8;return function(_0x24a57b){if(_0x24a57b){return _0x3df17b[_0xbb10('0x1e')](_0x2f2ebf)[_0xbb10('0x20')](_0x24a57b);}};}function respondWithFilteredResult(_0x2b184e,_0x4a2bfc){return function(_0x2eca0f){if(_0x2eca0f){var _0x1145f1=_0x2eca0f[_0xbb10('0x21')],_0x133ac2=_0x4a2bfc[_0xbb10('0x22')],_0x42db98=_0x4a2bfc[_0xbb10('0x22')]+_0x4a2bfc[_0xbb10('0x23')],_0x378da8;if(_0x42db98>=_0x1145f1){_0x42db98=_0x1145f1;_0x378da8=0xc8;}else{_0x378da8=0xce;}_0x2b184e[_0xbb10('0x1e')](_0x378da8);return _0x2b184e['set'](_0xbb10('0x24'),_0x133ac2+'-'+_0x42db98+'/'+_0x1145f1)[_0xbb10('0x20')](_0x2eca0f);}return null;};}function patchUpdates(_0x388fab){return function(_0x109908){try{jsonpatch[_0xbb10('0x25')](_0x109908,_0x388fab,!![]);}catch(_0x44e563){return BPromise['reject'](_0x44e563);}return _0x109908[_0xbb10('0x26')]();};}function saveUpdates(_0x12ef77,_0x50aea1){return function(_0x4c4b0d){if(_0x4c4b0d){return _0x4c4b0d[_0xbb10('0x27')](_0x12ef77)[_0xbb10('0x28')](function(_0x2e911d){return _0x2e911d;});}return null;};}function removeEntity(_0x317da4,_0x445761){return function(_0x1824b7){if(_0x1824b7){return _0x1824b7[_0xbb10('0x29')]()[_0xbb10('0x28')](function(){var _0x7f2377=_0x1824b7[_0xbb10('0x2a')]({'plain':!![]});var _0x3ba6cd=_0xbb10('0x2b');return db['UserProfileResource']['destroy']({'where':{'type':_0x3ba6cd,'resourceId':_0x7f2377['id']}})['then'](function(){return _0x1824b7;});})[_0xbb10('0x28')](function(){_0x317da4[_0xbb10('0x1e')](0xcc)[_0xbb10('0x1f')]();});}};}function handleEntityNotFound(_0x4e25ff,_0x2fdde9){return function(_0x24d586){if(!_0x24d586){_0x4e25ff[_0xbb10('0x1d')](0x194);}return _0x24d586;};}function handleError(_0x1d5e95,_0x1acce9){_0x1acce9=_0x1acce9||0x1f4;return function(_0x20d946){logger[_0xbb10('0x2c')](_0x20d946['stack']);if(_0x20d946[_0xbb10('0x2d')]){delete _0x20d946[_0xbb10('0x2d')];}_0x1d5e95[_0xbb10('0x1e')](_0x1acce9)[_0xbb10('0x2e')](_0x20d946);};}exports[_0xbb10('0x2f')]=function(_0x2ff4c1,_0x5d5c80){var _0x221624={},_0x4ee02e={},_0x448d5c={'count':0x0,'rows':[]};var _0x56f2da=db[_0xbb10('0x30')][_0xbb10('0x31')];_0x4ee02e[_0xbb10('0x32')]=_['keys'](_0x56f2da);var _0x518d47={'dateStart':_0x2ff4c1[_0xbb10('0x33')][_0xbb10('0x34')],'dateEnd':_0x2ff4c1['query'][_0xbb10('0x35')]};delete _0x2ff4c1[_0xbb10('0x33')][_0xbb10('0x34')];delete _0x2ff4c1[_0xbb10('0x33')][_0xbb10('0x35')];_0x4ee02e[_0xbb10('0x33')]=_[_0xbb10('0x36')](_0x2ff4c1['query']);_0x4ee02e[_0xbb10('0x37')]=_[_0xbb10('0x38')](_0x4ee02e[_0xbb10('0x32')],_0x4ee02e[_0xbb10('0x33')]);_0x221624[_0xbb10('0x39')]=_[_0xbb10('0x38')](_0x4ee02e[_0xbb10('0x32')],qs[_0xbb10('0x3a')](_0x2ff4c1[_0xbb10('0x33')]['fields']));_0x221624[_0xbb10('0x39')]=_0x221624[_0xbb10('0x39')][_0xbb10('0x3b')]?_0x221624[_0xbb10('0x39')]:_0x4ee02e['model'];if(!_0x2ff4c1[_0xbb10('0x33')]['hasOwnProperty']('nolimit')){_0x221624[_0xbb10('0x23')]=qs[_0xbb10('0x23')](_0x2ff4c1[_0xbb10('0x33')][_0xbb10('0x23')]);_0x221624[_0xbb10('0x22')]=qs[_0xbb10('0x22')](_0x2ff4c1['query'][_0xbb10('0x22')]);}_0x221624[_0xbb10('0x3c')]=qs['sort'](_0x2ff4c1['query']['sort']);_0x221624[_0xbb10('0x3d')]=qs[_0xbb10('0x37')](_[_0xbb10('0x3e')](_0x2ff4c1['query'],_0x4ee02e[_0xbb10('0x37')]));if(_0x518d47[_0xbb10('0x34')]){if(_0x518d47[_0xbb10('0x35')]){_0x518d47['dateEnd']=moment(_0x518d47[_0xbb10('0x35')])[_0xbb10('0x3f')](0x1,_0xbb10('0x40'));}else{_0x518d47[_0xbb10('0x35')]=moment(_0x518d47['dateStart'])[_0xbb10('0x3f')](0x1,_0xbb10('0x40'));}_['merge'](_0x221624[_0xbb10('0x3d')],{'createdAt':{'$gte':_0x518d47[_0xbb10('0x34')],'$lte':_0x518d47[_0xbb10('0x35')]}});}if(_0x2ff4c1[_0xbb10('0x33')][_0xbb10('0x41')]){_0x221624[_0xbb10('0x3d')]=_['merge'](_0x221624[_0xbb10('0x3d')],{'$or':_[_0xbb10('0x42')](_0x56f2da,function(_0x3e7b4c){if(_0x3e7b4c[_0xbb10('0x43')]['key']!==_0xbb10('0x44')){var _0x331751={};_0x331751[_0x3e7b4c[_0xbb10('0x45')]]={'$like':'%'+_0x2ff4c1[_0xbb10('0x33')]['filter']+'%'};return _0x331751;}})});}_0x221624=_[_0xbb10('0x46')]({},_0x221624,_0x2ff4c1[_0xbb10('0x47')]);var _0x54ac18={'where':_0x221624['where']};return db[_0xbb10('0x30')]['count'](_0x54ac18)[_0xbb10('0x28')](function(_0x180933){_0x448d5c['count']=_0x180933;if(_0x2ff4c1[_0xbb10('0x33')][_0xbb10('0x48')]){_0x221624[_0xbb10('0x49')]=[{'all':!![]}];}return db['Team'][_0xbb10('0x4a')](_0x221624);})[_0xbb10('0x28')](function(_0x3b9fdf){_0x448d5c[_0xbb10('0x4b')]=_0x3b9fdf;return _0x448d5c;})[_0xbb10('0x28')](respondWithFilteredResult(_0x5d5c80,_0x221624))[_0xbb10('0x4c')](handleError(_0x5d5c80,null));};exports[_0xbb10('0x4d')]=function(_0x3efa96,_0x205bb4){var _0x43b948={'raw':![],'where':{'id':_0x3efa96[_0xbb10('0x4e')]['id']}},_0x197871={};_0x197871['model']=_[_0xbb10('0x36')](db[_0xbb10('0x30')]['rawAttributes']);_0x197871[_0xbb10('0x33')]=_[_0xbb10('0x36')](_0x3efa96[_0xbb10('0x33')]);_0x197871[_0xbb10('0x37')]=_[_0xbb10('0x38')](_0x197871[_0xbb10('0x32')],_0x197871[_0xbb10('0x33')]);_0x43b948['attributes']=_['intersection'](_0x197871[_0xbb10('0x32')],qs[_0xbb10('0x3a')](_0x3efa96[_0xbb10('0x33')]['fields']));_0x43b948['attributes']=_0x43b948[_0xbb10('0x39')][_0xbb10('0x3b')]?_0x43b948[_0xbb10('0x39')]:_0x197871[_0xbb10('0x32')];if(_0x3efa96[_0xbb10('0x33')][_0xbb10('0x48')]){_0x43b948[_0xbb10('0x49')]=[{'all':!![]}];}_0x43b948=_[_0xbb10('0x46')]({},_0x43b948,_0x3efa96[_0xbb10('0x47')]);return db[_0xbb10('0x30')]['find'](_0x43b948)['then'](handleEntityNotFound(_0x205bb4,null))[_0xbb10('0x28')](respondWithResult(_0x205bb4,null))[_0xbb10('0x4c')](handleError(_0x205bb4,null));};exports[_0xbb10('0x4f')]=function(_0xb014b0,_0x36aa7d){return db[_0xbb10('0x30')][_0xbb10('0x4f')](_0xb014b0[_0xbb10('0x50')],{})[_0xbb10('0x28')](function(_0x1214f7){var _0x19ca3e=_0xb014b0[_0xbb10('0x51')][_0xbb10('0x2a')]({'plain':!![]});if(!_0x19ca3e)throw new Error(_0xbb10('0x52'));if(_0x19ca3e[_0xbb10('0x53')]==='user'){var _0x124052=_0x1214f7['get']({'plain':!![]});var _0x33d60a=_0xbb10('0x2b');return db[_0xbb10('0x54')][_0xbb10('0x55')]({'where':{'name':_0x33d60a,'userProfileId':_0x19ca3e[_0xbb10('0x56')]},'raw':!![]})[_0xbb10('0x28')](function(_0x2e3326){if(_0x2e3326&&_0x2e3326[_0xbb10('0x57')]===0x0){return db[_0xbb10('0x58')][_0xbb10('0x4f')]({'name':_0x124052[_0xbb10('0x2d')],'resourceId':_0x124052['id'],'type':_0x2e3326[_0xbb10('0x2d')],'sectionId':_0x2e3326['id']},{})[_0xbb10('0x28')](function(){return _0x1214f7;});}else{return _0x1214f7;}})[_0xbb10('0x4c')](function(_0x4475e1){logger['error'](_0xbb10('0x59'),_0x4475e1);throw _0x4475e1;});}return _0x1214f7;})[_0xbb10('0x28')](respondWithResult(_0x36aa7d,0xc9))[_0xbb10('0x4c')](handleError(_0x36aa7d,null));};exports[_0xbb10('0x27')]=function(_0xbffa3c,_0x379d8c){if(_0xbffa3c['body']['id']){delete _0xbffa3c[_0xbb10('0x50')]['id'];}return db[_0xbb10('0x30')][_0xbb10('0x55')]({'where':{'id':_0xbffa3c[_0xbb10('0x4e')]['id']}})[_0xbb10('0x28')](handleEntityNotFound(_0x379d8c,null))[_0xbb10('0x28')](saveUpdates(_0xbffa3c[_0xbb10('0x50')],null))[_0xbb10('0x28')](respondWithResult(_0x379d8c,null))[_0xbb10('0x4c')](handleError(_0x379d8c,null));};exports[_0xbb10('0x29')]=function(_0x2eb05a,_0x2a1ce1){return db[_0xbb10('0x30')]['find']({'where':{'id':_0x2eb05a['params']['id']}})[_0xbb10('0x28')](handleEntityNotFound(_0x2a1ce1,null))[_0xbb10('0x28')](removeEntity(_0x2a1ce1,null))[_0xbb10('0x4c')](handleError(_0x2a1ce1,null));};exports[_0xbb10('0x5a')]=function(_0x5573bb,_0x506498,_0x79411e){return db[_0xbb10('0x30')][_0xbb10('0x5b')]({'where':{'id':_0x5573bb[_0xbb10('0x4e')]['id']}})[_0xbb10('0x28')](handleEntityNotFound(_0x506498,null))[_0xbb10('0x28')](function(_0x45c0dc){if(!_0x5573bb['query'][_0xbb10('0x5c')]||!utils[_0xbb10('0x5d')](_0x5573bb['query']['channel'])){throw new db['Sequelize'][(_0xbb10('0x5e'))](_0xbb10('0x5f'));}var _0x155dc5={};var _0x5bd1c0={};_0x5bd1c0['model']=_['keys'](db[_[_0xbb10('0x60')](_0x5573bb[_0xbb10('0x33')][_0xbb10('0x5c')]['toLowerCase']())+_0xbb10('0x61')][_0xbb10('0x31')]);_0x5bd1c0['query']=_['keys'](_0x5573bb[_0xbb10('0x33')]);_0x5bd1c0[_0xbb10('0x37')]=_[_0xbb10('0x38')](_0x5bd1c0[_0xbb10('0x32')],_0x5bd1c0['query']);_0x155dc5[_0xbb10('0x39')]=_[_0xbb10('0x38')](_0x5bd1c0[_0xbb10('0x32')],qs['fields'](_0x5573bb[_0xbb10('0x33')][_0xbb10('0x3a')]));_0x155dc5[_0xbb10('0x39')]=_0x155dc5['attributes'][_0xbb10('0x3b')]?_0x155dc5[_0xbb10('0x39')]:_0x5bd1c0[_0xbb10('0x32')];_0x155dc5[_0xbb10('0x23')]=qs['limit'](_0x5573bb[_0xbb10('0x33')][_0xbb10('0x23')]);_0x155dc5[_0xbb10('0x22')]=qs[_0xbb10('0x22')](_0x5573bb['query'][_0xbb10('0x22')]);_0x155dc5[_0xbb10('0x3c')]=qs[_0xbb10('0x62')](_0x5573bb[_0xbb10('0x33')][_0xbb10('0x62')]);_0x155dc5[_0xbb10('0x3d')]=qs[_0xbb10('0x37')](_['pick'](_0x5573bb['query'],_0x5bd1c0['filters']));_0x155dc5=_[_0xbb10('0x46')]({},_0x155dc5,_0x5573bb[_0xbb10('0x47')]);return _0x45c0dc[_0xbb10('0x2a')+_['capitalize'](_0x5573bb['query'][_0xbb10('0x5c')][_0xbb10('0x63')]())+_0xbb10('0x64')](_0x155dc5);})[_0xbb10('0x28')](respondWithResult(_0x506498,null))[_0xbb10('0x4c')](handleError(_0x506498,null));};exports[_0xbb10('0x65')]=function(_0x4cf2f3,_0x1a5ca5,_0x15fae2){return db[_0xbb10('0x30')][_0xbb10('0x5b')]({'where':{'id':_0x4cf2f3[_0xbb10('0x4e')]['id']}})['then'](function(_0x56094a){if(_0x56094a){if(!_0x4cf2f3['body'][_0xbb10('0x5c')]||!utils[_0xbb10('0x5d')](_0x4cf2f3[_0xbb10('0x50')][_0xbb10('0x5c')])){throw new db[(_0xbb10('0x66'))][(_0xbb10('0x5e'))]('Unknown\x20channel');}return _0x56094a[_0xbb10('0x3f')+_['capitalize'](_0x4cf2f3['body']['channel'][_0xbb10('0x63')]())+_0xbb10('0x64')](_0x4cf2f3[_0xbb10('0x50')][_0xbb10('0x67')]);}return null;})['then'](handleEntityNotFound(_0x1a5ca5,null))[_0xbb10('0x28')](respondWithStatusCode(_0x1a5ca5,null))['catch'](handleError(_0x1a5ca5,null));};exports['removeQueues']=function(_0x165fe9,_0xfe3db0,_0x29529c){return db[_0xbb10('0x30')][_0xbb10('0x5b')]({'where':{'id':_0x165fe9['params']['id']}})[_0xbb10('0x28')](function(_0x19fcec){if(_0x19fcec){if(!_0x165fe9[_0xbb10('0x33')][_0xbb10('0x5c')]||!utils[_0xbb10('0x5d')](_0x165fe9[_0xbb10('0x33')][_0xbb10('0x5c')])){throw new db['Sequelize'][(_0xbb10('0x5e'))](_0xbb10('0x5f'));}return _0x19fcec[_0xbb10('0x68')+_[_0xbb10('0x60')](_0x165fe9[_0xbb10('0x33')][_0xbb10('0x5c')][_0xbb10('0x63')]())+_0xbb10('0x64')](_0x165fe9['query'][_0xbb10('0x67')]);}return null;})[_0xbb10('0x28')](handleEntityNotFound(_0xfe3db0,null))[_0xbb10('0x28')](respondWithStatusCode(_0xfe3db0,null))['catch'](handleError(_0xfe3db0,null));};exports['addAgents']=function(_0x4b923a,_0x23286d,_0x5a3c44){return db['Team'][_0xbb10('0x55')]({'where':{'id':_0x4b923a[_0xbb10('0x4e')]['id']}})[_0xbb10('0x28')](handleEntityNotFound(_0x23286d,null))[_0xbb10('0x28')](function(_0x32ec27){if(_0x32ec27){return BPromise[_0xbb10('0x69')]([_0xbb10('0x6a'),_0xbb10('0x6b'),_0xbb10('0x6c'),'sms',_0xbb10('0x6d'),_0xbb10('0x6e')],function(_0x46b6d2){return _0x32ec27[_0xbb10('0x2a')+_['capitalize'](_0x46b6d2)+'Queues']({'attributes':['id',_0xbb10('0x2d')]})[_0xbb10('0x28')](function(_0x30f0a4){return BPromise[_0xbb10('0x69')](_0x30f0a4,function(_0x5ee705){return _0x5ee705[_0xbb10('0x6f')](_0x4b923a[_0xbb10('0x50')][_0xbb10('0x67')])[_0xbb10('0x28')](function(){if(_0x46b6d2===_0xbb10('0x6a')){return db['User']['findAll']({'where':{'id':_0x4b923a[_0xbb10('0x50')][_0xbb10('0x67')]},'attributes':['id',_0xbb10('0x2d'),'loginInPause',_0xbb10('0x70'),_0xbb10('0x71')],'raw':!![]});}})['then'](function(_0x5caa06){if(_0x46b6d2===_0xbb10('0x6a')){return BPromise[_0xbb10('0x69')](_0x5caa06,function(_0x177f77){return db['UserVoiceQueueRt'][_0xbb10('0x72')]({'membername':_0x177f77[_0xbb10('0x2d')],'UserId':_0x177f77['id'],'queue_name':_0x5ee705[_0xbb10('0x2d')],'VoiceQueueId':_0x5ee705['id'],'interface':_[_0xbb10('0x73')](_0x177f77[_0xbb10('0x71')])?util[_0xbb10('0x74')](_0xbb10('0x75'),_0x177f77[_0xbb10('0x2d')]):_0x177f77[_0xbb10('0x71')],'paused':_0x177f77['voicePause']||![],'penalty':0x0});});}});});})[_0xbb10('0x28')](function(){return _0x32ec27;});})[_0xbb10('0x28')](function(){return _0x32ec27;});}})[_0xbb10('0x28')](function(_0xdb7d3e){if(_0xdb7d3e){return _0xdb7d3e[_0xbb10('0x6f')](_0x4b923a[_0xbb10('0x50')][_0xbb10('0x67')],_[_0xbb10('0x76')](_0x4b923a[_0xbb10('0x50')],[_0xbb10('0x67'),'id'])||{})[_0xbb10('0x77')](function(_0x2a4278){for(var _0x59e985=0x0;_0x59e985<_0x4b923a['body'][_0xbb10('0x67')][_0xbb10('0x3b')];_0x59e985+=0x1){socket[_0xbb10('0x78')](_0xbb10('0x79'),{'UserId':_0x4b923a[_0xbb10('0x50')]['ids'][_0x59e985],'TeamId':_0x4b923a[_0xbb10('0x4e')]['id']});}return _0x2a4278;});}})[_0xbb10('0x28')](respondWithResult(_0x23286d,null))[_0xbb10('0x4c')](handleError(_0x23286d,null));};exports[_0xbb10('0x7a')]=function(_0x19694d,_0x379d49,_0x546db5){var _0xb25e71;return db[_0xbb10('0x30')]['find']({'where':{'id':_0x19694d[_0xbb10('0x4e')]['id']}})['then'](handleEntityNotFound(_0x379d49,null))[_0xbb10('0x28')](function(_0x28bd76){if(_0x28bd76){return BPromise[_0xbb10('0x69')]([_0xbb10('0x6a'),_0xbb10('0x6b'),'mail',_0xbb10('0x7b'),'fax',_0xbb10('0x6e')],function(_0x37ec93){return _0x28bd76['get'+_['capitalize'](_0x37ec93)+_0xbb10('0x64')]({'attributes':['id',_0xbb10('0x2d')]})[_0xbb10('0x28')](function(_0x283bab){return BPromise[_0xbb10('0x69')](_0x283bab,function(_0x1cb22f){return _0x1cb22f[_0xbb10('0x7a')](_0x19694d[_0xbb10('0x33')][_0xbb10('0x67')])[_0xbb10('0x28')](function(){if(_0x37ec93===_0xbb10('0x6a')){return db['UserVoiceQueueRt'][_0xbb10('0x29')]({'where':{'VoiceQueueId':_0x1cb22f['id'],'UserId':_0x19694d[_0xbb10('0x33')][_0xbb10('0x67')]}});}});});})[_0xbb10('0x28')](function(){return _0x28bd76;});})[_0xbb10('0x28')](function(){return _0x28bd76;});}})[_0xbb10('0x28')](function(_0xfefa17){if(_0xfefa17){return _0xfefa17[_0xbb10('0x7a')](_0x19694d[_0xbb10('0x33')][_0xbb10('0x67')])[_0xbb10('0x28')](function(_0x2d3e98){if(_['isArray'](_0x19694d[_0xbb10('0x33')]['ids'])){for(var _0x1b6d7d=0x0;_0x1b6d7d<_0x19694d[_0xbb10('0x33')][_0xbb10('0x67')][_0xbb10('0x3b')];_0x1b6d7d+=0x1){socket[_0xbb10('0x78')]('userTeam:remove',{'UserId':_0x19694d[_0xbb10('0x33')][_0xbb10('0x67')][_0x1b6d7d],'TeamId':_0x19694d[_0xbb10('0x4e')]['id']});}}else{socket[_0xbb10('0x78')](_0xbb10('0x7c'),{'UserId':_0x19694d[_0xbb10('0x33')]['ids'],'TeamId':_0x19694d['params']['id']});}});}})[_0xbb10('0x28')](respondWithStatusCode(_0x379d49,null))[_0xbb10('0x4c')](handleError(_0x379d49,null));};exports[_0xbb10('0x7d')]=function(_0x57d5a1,_0x124b32,_0x3d6a91){var _0x514fdf={};var _0x2831de={};var _0xaede56;var _0x5642c3;return db[_0xbb10('0x30')]['findOne']({'where':{'id':_0x57d5a1[_0xbb10('0x4e')]['id']}})[_0xbb10('0x28')](handleEntityNotFound(_0x124b32,null))['then'](function(_0x34a5a3){if(_0x34a5a3){_0xaede56=_0x34a5a3;_0x2831de[_0xbb10('0x32')]=_['keys'](db['User'][_0xbb10('0x31')]);_0x2831de[_0xbb10('0x33')]=_[_0xbb10('0x36')](_0x57d5a1[_0xbb10('0x33')]);_0x2831de[_0xbb10('0x37')]=_['intersection'](_0x2831de[_0xbb10('0x32')],_0x2831de[_0xbb10('0x33')]);_0x514fdf[_0xbb10('0x39')]=_['intersection'](_0x2831de[_0xbb10('0x32')],qs[_0xbb10('0x3a')](_0x57d5a1[_0xbb10('0x33')][_0xbb10('0x3a')]));_0x514fdf[_0xbb10('0x39')]=_0x514fdf[_0xbb10('0x39')][_0xbb10('0x3b')]?_0x514fdf[_0xbb10('0x39')]:_0x2831de[_0xbb10('0x32')];_0x514fdf['order']=qs['sort'](_0x57d5a1[_0xbb10('0x33')][_0xbb10('0x62')]);_0x514fdf[_0xbb10('0x3d')]=qs[_0xbb10('0x37')](_[_0xbb10('0x3e')](_0x57d5a1[_0xbb10('0x33')],_0x2831de[_0xbb10('0x37')]));if(_0x57d5a1[_0xbb10('0x33')][_0xbb10('0x41')]){_0x514fdf[_0xbb10('0x3d')]=_[_0xbb10('0x46')](_0x514fdf[_0xbb10('0x3d')],{'$or':_[_0xbb10('0x42')](_0x514fdf['attributes'],function(_0x1e022d){var _0x123587={};_0x123587[_0x1e022d]={'$like':'%'+_0x57d5a1[_0xbb10('0x33')][_0xbb10('0x41')]+'%'};return _0x123587;})});}_0x514fdf=_[_0xbb10('0x46')]({},_0x514fdf,_0x57d5a1[_0xbb10('0x47')]);return _0xaede56[_0xbb10('0x7d')](_0x514fdf);}})[_0xbb10('0x28')](function(_0x3c6c45){if(_0x3c6c45){_0x5642c3=_0x3c6c45[_0xbb10('0x3b')];if(!_0x57d5a1[_0xbb10('0x33')]['hasOwnProperty'](_0xbb10('0x7e'))){_0x514fdf['limit']=qs[_0xbb10('0x23')](_0x57d5a1[_0xbb10('0x33')][_0xbb10('0x23')]);_0x514fdf[_0xbb10('0x22')]=qs[_0xbb10('0x22')](_0x57d5a1[_0xbb10('0x33')]['offset']);}return _0xaede56[_0xbb10('0x7d')](_0x514fdf);}})['then'](function(_0xd82ce1){if(_0xd82ce1){return _0xd82ce1?{'count':_0x5642c3,'rows':_0xd82ce1}:null;}})[_0xbb10('0x28')](respondWithResult(_0x124b32,null))[_0xbb10('0x4c')](handleError(_0x124b32,null));};
\ No newline at end of file