Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / team / team.controller.js
index 05e1b6a..4d40182 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd983=['../../config/logger','api','../../config/utils','redis','defaults','localhost','./team.socket','end','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','get','Teams','UserProfileResource','destroy','sendStatus','error','stack','name','send','index','map','Team','rawAttributes','fieldName','key','model','query','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filters','pick','filter','merge','type','VIRTUAL','includeAll','findAll','rows','catch','params','keys','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','getQueues','findOne','channel','isValidChannel','Sequelize','ValidationError','Unknown\x20channel','capitalize','toLowerCase','Queue','options','remove','Queues','ids','addAgents','Chat','Mail','Fax','Openchannel','each','Voice','User','online','voicePause','interface','UserVoiceQueueRt','upsert','SIP/%s','userTeam:save','removeAgents','voice','sms','openchannel','isArray','emit','userTeam:remove','getAgents','nolimit','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware'];(function(_0x3aef2a,_0x2d1ee5){var _0xf81dd9=function(_0x5d4b7f){while(--_0x5d4b7f){_0x3aef2a['push'](_0x3aef2a['shift']());}};_0xf81dd9(++_0x2d1ee5);}(_0xd983,0x1df));var _0x3d98=function(_0x12b161,_0x18b531){_0x12b161=_0x12b161-0x0;var _0x971b9f=_0xd983[_0x12b161];return _0x971b9f;};'use strict';var pdf=require(_0x3d98('0x0'));var emlformat=require(_0x3d98('0x1'));var rimraf=require(_0x3d98('0x2'));var zipdir=require(_0x3d98('0x3'));var jsonpatch=require(_0x3d98('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x3d98('0x5'));var Mustache=require(_0x3d98('0x6'));var util=require(_0x3d98('0x7'));var path=require(_0x3d98('0x8'));var sox=require(_0x3d98('0x9'));var csv=require(_0x3d98('0xa'));var ejs=require(_0x3d98('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x3d98('0xc'));var crypto=require(_0x3d98('0xd'));var jsforce=require(_0x3d98('0xe'));var deskjs=require(_0x3d98('0xf'));var toCsv=require(_0x3d98('0xa'));var querystring=require(_0x3d98('0x10'));var Papa=require(_0x3d98('0x11'));var Redis=require(_0x3d98('0x12'));var authService=require(_0x3d98('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3d98('0x14'));var logger=require(_0x3d98('0x15'))(_0x3d98('0x16'));var utils=require(_0x3d98('0x17'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x3d98('0x18')]=_[_0x3d98('0x19')](config[_0x3d98('0x18')],{'host':_0x3d98('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3d98('0x18')]));require(_0x3d98('0x1b'))['register'](socket);function respondWithStatusCode(_0x178ca5,_0x566423){_0x566423=_0x566423||0xcc;return function(_0x2e1b11){if(_0x2e1b11){return _0x178ca5['sendStatus'](_0x566423);}return _0x178ca5['status'](_0x566423)[_0x3d98('0x1c')]();};}function respondWithResult(_0xc07e5f,_0x23867a){_0x23867a=_0x23867a||0xc8;return function(_0x57b493){if(_0x57b493){return _0xc07e5f[_0x3d98('0x1d')](_0x23867a)[_0x3d98('0x1e')](_0x57b493);}};}function respondWithFilteredResult(_0x51332a,_0x2f1843){return function(_0x245e94){if(_0x245e94){var _0x4e2a73=_0x245e94[_0x3d98('0x1f')],_0xb63af3=_0x2f1843[_0x3d98('0x20')],_0x832846=_0x2f1843['offset']+_0x2f1843[_0x3d98('0x21')],_0x1cea30;if(_0x832846>=_0x4e2a73){_0x832846=_0x4e2a73;_0x1cea30=0xc8;}else{_0x1cea30=0xce;}_0x51332a[_0x3d98('0x1d')](_0x1cea30);return _0x51332a[_0x3d98('0x22')](_0x3d98('0x23'),_0xb63af3+'-'+_0x832846+'/'+_0x4e2a73)['json'](_0x245e94);}return null;};}function patchUpdates(_0x92f4ad){return function(_0x1a368d){try{jsonpatch[_0x3d98('0x24')](_0x1a368d,_0x92f4ad,!![]);}catch(_0x49cccd){return BPromise[_0x3d98('0x25')](_0x49cccd);}return _0x1a368d[_0x3d98('0x26')]();};}function saveUpdates(_0x54177e,_0x54f448){return function(_0xf7a6cc){if(_0xf7a6cc){return _0xf7a6cc[_0x3d98('0x27')](_0x54177e)[_0x3d98('0x28')](function(_0x31db37){return _0x31db37;});}return null;};}function removeEntity(_0x403206,_0x366702){return function(_0x245ffa){if(_0x245ffa){return _0x245ffa['destroy']()['then'](function(){var _0x4ea96d=_0x245ffa[_0x3d98('0x29')]({'plain':!![]});var _0x5a2067=_0x3d98('0x2a');return db[_0x3d98('0x2b')][_0x3d98('0x2c')]({'where':{'type':_0x5a2067,'resourceId':_0x4ea96d['id']}})['then'](function(){return _0x245ffa;});})[_0x3d98('0x28')](function(){_0x403206[_0x3d98('0x1d')](0xcc)[_0x3d98('0x1c')]();});}};}function handleEntityNotFound(_0x2dca32,_0x4409ff){return function(_0x489a9a){if(!_0x489a9a){_0x2dca32[_0x3d98('0x2d')](0x194);}return _0x489a9a;};}function handleError(_0x105679,_0x4bd15a){_0x4bd15a=_0x4bd15a||0x1f4;return function(_0x27b631){logger[_0x3d98('0x2e')](_0x27b631[_0x3d98('0x2f')]);if(_0x27b631['name']){delete _0x27b631[_0x3d98('0x30')];}_0x105679['status'](_0x4bd15a)[_0x3d98('0x31')](_0x27b631);};}exports[_0x3d98('0x32')]=function(_0x26df3c,_0x2d6bf0){var _0x5390e5={},_0x2aee8a={},_0x1b393e={'count':0x0,'rows':[]};var _0x219630=_[_0x3d98('0x33')](db[_0x3d98('0x34')][_0x3d98('0x35')],function(_0x256e50){return{'name':_0x256e50[_0x3d98('0x36')],'type':_0x256e50['type'][_0x3d98('0x37')]};});_0x2aee8a[_0x3d98('0x38')]=_[_0x3d98('0x33')](_0x219630,_0x3d98('0x30'));_0x2aee8a['query']=_['keys'](_0x26df3c[_0x3d98('0x39')]);_0x2aee8a['filters']=_[_0x3d98('0x3a')](_0x2aee8a['model'],_0x2aee8a['query']);_0x5390e5[_0x3d98('0x3b')]=_[_0x3d98('0x3a')](_0x2aee8a['model'],qs[_0x3d98('0x3c')](_0x26df3c[_0x3d98('0x39')][_0x3d98('0x3c')]));_0x5390e5[_0x3d98('0x3b')]=_0x5390e5[_0x3d98('0x3b')][_0x3d98('0x3d')]?_0x5390e5[_0x3d98('0x3b')]:_0x2aee8a[_0x3d98('0x38')];if(!_0x26df3c[_0x3d98('0x39')][_0x3d98('0x3e')]('nolimit')){_0x5390e5[_0x3d98('0x21')]=qs[_0x3d98('0x21')](_0x26df3c[_0x3d98('0x39')]['limit']);_0x5390e5['offset']=qs[_0x3d98('0x20')](_0x26df3c[_0x3d98('0x39')]['offset']);}_0x5390e5[_0x3d98('0x3f')]=qs['sort'](_0x26df3c['query'][_0x3d98('0x40')]);_0x5390e5[_0x3d98('0x41')]=qs[_0x3d98('0x42')](_[_0x3d98('0x43')](_0x26df3c[_0x3d98('0x39')],_0x2aee8a[_0x3d98('0x42')]));if(_0x26df3c[_0x3d98('0x39')][_0x3d98('0x44')]){_0x5390e5[_0x3d98('0x41')]=_[_0x3d98('0x45')](_0x5390e5[_0x3d98('0x41')],{'$or':_['map'](_0x219630,function(_0x3b67a6){if(_0x3b67a6[_0x3d98('0x46')]!==_0x3d98('0x47')){var _0x8f199e={};_0x8f199e[_0x3b67a6[_0x3d98('0x30')]]={'$like':'%'+_0x26df3c['query'][_0x3d98('0x44')]+'%'};return _0x8f199e;}})});}_0x5390e5=_['merge']({},_0x5390e5,_0x26df3c['options']);var _0x34fe23={'where':_0x5390e5[_0x3d98('0x41')]};return db[_0x3d98('0x34')][_0x3d98('0x1f')](_0x34fe23)['then'](function(_0x112247){_0x1b393e[_0x3d98('0x1f')]=_0x112247;if(_0x26df3c[_0x3d98('0x39')][_0x3d98('0x48')]){_0x5390e5['include']=[{'all':!![]}];}return db['Team'][_0x3d98('0x49')](_0x5390e5);})[_0x3d98('0x28')](function(_0x170743){_0x1b393e[_0x3d98('0x4a')]=_0x170743;return _0x1b393e;})['then'](respondWithFilteredResult(_0x2d6bf0,_0x5390e5))[_0x3d98('0x4b')](handleError(_0x2d6bf0,null));};exports['show']=function(_0x18d0e3,_0x2805e6){var _0x1dc504={'raw':![],'where':{'id':_0x18d0e3[_0x3d98('0x4c')]['id']}},_0x1f6dec={};_0x1f6dec['model']=_['keys'](db[_0x3d98('0x34')][_0x3d98('0x35')]);_0x1f6dec['query']=_[_0x3d98('0x4d')](_0x18d0e3[_0x3d98('0x39')]);_0x1f6dec['filters']=_[_0x3d98('0x3a')](_0x1f6dec[_0x3d98('0x38')],_0x1f6dec[_0x3d98('0x39')]);_0x1dc504[_0x3d98('0x3b')]=_[_0x3d98('0x3a')](_0x1f6dec[_0x3d98('0x38')],qs[_0x3d98('0x3c')](_0x18d0e3[_0x3d98('0x39')][_0x3d98('0x3c')]));_0x1dc504['attributes']=_0x1dc504['attributes'][_0x3d98('0x3d')]?_0x1dc504[_0x3d98('0x3b')]:_0x1f6dec['model'];if(_0x18d0e3[_0x3d98('0x39')][_0x3d98('0x48')]){_0x1dc504[_0x3d98('0x4e')]=[{'all':!![]}];}_0x1dc504=_[_0x3d98('0x45')]({},_0x1dc504,_0x18d0e3['options']);return db[_0x3d98('0x34')][_0x3d98('0x4f')](_0x1dc504)[_0x3d98('0x28')](handleEntityNotFound(_0x2805e6,null))[_0x3d98('0x28')](respondWithResult(_0x2805e6,null))[_0x3d98('0x4b')](handleError(_0x2805e6,null));};exports[_0x3d98('0x50')]=function(_0x1798a5,_0x3f3b57){return db[_0x3d98('0x34')][_0x3d98('0x50')](_0x1798a5[_0x3d98('0x51')],{})[_0x3d98('0x28')](function(_0x5ad73a){var _0x1245ab=_0x1798a5[_0x3d98('0x52')][_0x3d98('0x29')]({'plain':!![]});if(!_0x1245ab)throw new Error(_0x3d98('0x53'));if(_0x1245ab[_0x3d98('0x54')]===_0x3d98('0x52')){var _0x551e8f=_0x5ad73a['get']({'plain':!![]});var _0x592b44=_0x3d98('0x2a');return db[_0x3d98('0x55')]['find']({'where':{'name':_0x592b44,'userProfileId':_0x1245ab[_0x3d98('0x56')]},'raw':!![]})['then'](function(_0x1181b9){if(_0x1181b9&&_0x1181b9['autoAssociation']===0x0){return db[_0x3d98('0x2b')]['create']({'name':_0x551e8f['name'],'resourceId':_0x551e8f['id'],'type':_0x1181b9[_0x3d98('0x30')],'sectionId':_0x1181b9['id']},{})[_0x3d98('0x28')](function(){return _0x5ad73a;});}else{return _0x5ad73a;}})['catch'](function(_0x5cac6b){logger[_0x3d98('0x2e')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5cac6b);throw _0x5cac6b;});}return _0x5ad73a;})[_0x3d98('0x28')](respondWithResult(_0x3f3b57,0xc9))[_0x3d98('0x4b')](handleError(_0x3f3b57,null));};exports['update']=function(_0x2e2257,_0x2e6348){if(_0x2e2257[_0x3d98('0x51')]['id']){delete _0x2e2257[_0x3d98('0x51')]['id'];}return db[_0x3d98('0x34')][_0x3d98('0x4f')]({'where':{'id':_0x2e2257[_0x3d98('0x4c')]['id']}})[_0x3d98('0x28')](handleEntityNotFound(_0x2e6348,null))[_0x3d98('0x28')](saveUpdates(_0x2e2257[_0x3d98('0x51')],null))['then'](respondWithResult(_0x2e6348,null))[_0x3d98('0x4b')](handleError(_0x2e6348,null));};exports['destroy']=function(_0x280686,_0x4fee8e){return db['Team'][_0x3d98('0x4f')]({'where':{'id':_0x280686[_0x3d98('0x4c')]['id']}})[_0x3d98('0x28')](handleEntityNotFound(_0x4fee8e,null))[_0x3d98('0x28')](removeEntity(_0x4fee8e,null))[_0x3d98('0x4b')](handleError(_0x4fee8e,null));};exports[_0x3d98('0x57')]=function(_0x3c49fe,_0x1469f6,_0x429e66){return db['Team'][_0x3d98('0x58')]({'where':{'id':_0x3c49fe[_0x3d98('0x4c')]['id']}})[_0x3d98('0x28')](handleEntityNotFound(_0x1469f6,null))[_0x3d98('0x28')](function(_0x5b74a9){if(!_0x3c49fe[_0x3d98('0x39')][_0x3d98('0x59')]||!utils[_0x3d98('0x5a')](_0x3c49fe['query']['channel'])){throw new db[(_0x3d98('0x5b'))][(_0x3d98('0x5c'))](_0x3d98('0x5d'));}var _0x4fa4df={};var _0x4459db={};_0x4459db['model']=_[_0x3d98('0x4d')](db[_[_0x3d98('0x5e')](_0x3c49fe[_0x3d98('0x39')][_0x3d98('0x59')][_0x3d98('0x5f')]())+_0x3d98('0x60')]['rawAttributes']);_0x4459db[_0x3d98('0x39')]=_[_0x3d98('0x4d')](_0x3c49fe['query']);_0x4459db[_0x3d98('0x42')]=_[_0x3d98('0x3a')](_0x4459db[_0x3d98('0x38')],_0x4459db[_0x3d98('0x39')]);_0x4fa4df[_0x3d98('0x3b')]=_[_0x3d98('0x3a')](_0x4459db[_0x3d98('0x38')],qs[_0x3d98('0x3c')](_0x3c49fe[_0x3d98('0x39')][_0x3d98('0x3c')]));_0x4fa4df[_0x3d98('0x3b')]=_0x4fa4df[_0x3d98('0x3b')][_0x3d98('0x3d')]?_0x4fa4df[_0x3d98('0x3b')]:_0x4459db[_0x3d98('0x38')];_0x4fa4df[_0x3d98('0x21')]=qs[_0x3d98('0x21')](_0x3c49fe[_0x3d98('0x39')][_0x3d98('0x21')]);_0x4fa4df[_0x3d98('0x20')]=qs[_0x3d98('0x20')](_0x3c49fe[_0x3d98('0x39')]['offset']);_0x4fa4df['order']=qs[_0x3d98('0x40')](_0x3c49fe['query'][_0x3d98('0x40')]);_0x4fa4df[_0x3d98('0x41')]=qs['filters'](_[_0x3d98('0x43')](_0x3c49fe[_0x3d98('0x39')],_0x4459db[_0x3d98('0x42')]));_0x4fa4df=_['merge']({},_0x4fa4df,_0x3c49fe[_0x3d98('0x61')]);return _0x5b74a9[_0x3d98('0x29')+_[_0x3d98('0x5e')](_0x3c49fe['query'][_0x3d98('0x59')][_0x3d98('0x5f')]())+'Queues'](_0x4fa4df);})[_0x3d98('0x28')](respondWithResult(_0x1469f6,null))[_0x3d98('0x4b')](handleError(_0x1469f6,null));};exports['addQueues']=function(_0x5a5fbe,_0x4ec95a,_0x528b51){return db['Team'][_0x3d98('0x58')]({'where':{'id':_0x5a5fbe[_0x3d98('0x4c')]['id']}})[_0x3d98('0x28')](function(_0x10dd8b){if(_0x10dd8b){if(!_0x5a5fbe[_0x3d98('0x51')][_0x3d98('0x59')]||!utils[_0x3d98('0x5a')](_0x5a5fbe[_0x3d98('0x51')][_0x3d98('0x59')])){throw new db[(_0x3d98('0x5b'))][(_0x3d98('0x5c'))](_0x3d98('0x5d'));}return _0x10dd8b['add'+_['capitalize'](_0x5a5fbe[_0x3d98('0x51')]['channel'][_0x3d98('0x5f')]())+'Queues'](_0x5a5fbe[_0x3d98('0x51')]['ids']);}return null;})[_0x3d98('0x28')](handleEntityNotFound(_0x4ec95a,null))[_0x3d98('0x28')](respondWithStatusCode(_0x4ec95a,null))[_0x3d98('0x4b')](handleError(_0x4ec95a,null));};exports['removeQueues']=function(_0x5f5b30,_0x30c08b,_0x4d8d2e){return db[_0x3d98('0x34')]['findOne']({'where':{'id':_0x5f5b30[_0x3d98('0x4c')]['id']}})[_0x3d98('0x28')](function(_0x33f7f3){if(_0x33f7f3){if(!_0x5f5b30[_0x3d98('0x39')][_0x3d98('0x59')]||!utils['isValidChannel'](_0x5f5b30[_0x3d98('0x39')][_0x3d98('0x59')])){throw new db[(_0x3d98('0x5b'))][(_0x3d98('0x5c'))](_0x3d98('0x5d'));}return _0x33f7f3[_0x3d98('0x62')+_['capitalize'](_0x5f5b30[_0x3d98('0x39')][_0x3d98('0x59')][_0x3d98('0x5f')]())+_0x3d98('0x63')](_0x5f5b30['query'][_0x3d98('0x64')]);}return null;})[_0x3d98('0x28')](handleEntityNotFound(_0x30c08b,null))[_0x3d98('0x28')](respondWithStatusCode(_0x30c08b,null))['catch'](handleError(_0x30c08b,null));};exports[_0x3d98('0x65')]=function(_0x446db9,_0x46ed00,_0x3360d8){return db[_0x3d98('0x34')][_0x3d98('0x4f')]({'where':{'id':_0x446db9['params']['id']}})[_0x3d98('0x28')](handleEntityNotFound(_0x46ed00,null))[_0x3d98('0x28')](function(_0x201734){if(_0x201734){var _0xf2de19=['Voice',_0x3d98('0x66'),_0x3d98('0x67'),'Sms',_0x3d98('0x68'),_0x3d98('0x69')];return BPromise['each'](_0xf2de19,function(_0x2ebbf9){return _0x201734[_0x3d98('0x29')+_0x2ebbf9+_0x3d98('0x63')]({'attributes':['id',_0x3d98('0x30')]})[_0x3d98('0x28')](function(_0xe9c9d9){return BPromise[_0x3d98('0x6a')](_0xe9c9d9,function(_0x395201){return _0x395201[_0x3d98('0x65')](_0x446db9['body'][_0x3d98('0x64')])[_0x3d98('0x28')](function(){if(_0x2ebbf9===_0x3d98('0x6b')){return db[_0x3d98('0x6c')][_0x3d98('0x49')]({'where':{'id':_0x446db9['body'][_0x3d98('0x64')]},'attributes':['id',_0x3d98('0x30'),_0x3d98('0x6d'),_0x3d98('0x6e'),_0x3d98('0x6f')],'raw':!![]})['then'](function(_0x20416b){return BPromise[_0x3d98('0x6a')](_[_0x3d98('0x44')](_0x20416b,{'online':0x1}),function(_0x22235b){return db[_0x3d98('0x70')][_0x3d98('0x71')]({'membername':_0x22235b[_0x3d98('0x30')],'UserId':_0x22235b['id'],'queue_name':_0x395201[_0x3d98('0x30')],'VoiceQueueId':_0x395201['id'],'interface':_['isNil'](_0x22235b['interface'])?util['format'](_0x3d98('0x72'),_0x22235b[_0x3d98('0x30')]):_0x22235b['interface'],'paused':_0x22235b['voicePause']||![],'penalty':0x0});});});}});});})[_0x3d98('0x28')](function(){return _0x201734;});})[_0x3d98('0x28')](function(){return _0x201734;});}})[_0x3d98('0x28')](function(_0x1c21e8){if(_0x1c21e8){return _0x1c21e8[_0x3d98('0x65')](_0x446db9['body'][_0x3d98('0x64')],_['omit'](_0x446db9['body'],[_0x3d98('0x64'),'id'])||{})['spread'](function(_0x12f47a){for(var _0x223973=0x0;_0x223973<_0x446db9[_0x3d98('0x51')][_0x3d98('0x64')][_0x3d98('0x3d')];_0x223973+=0x1){socket['emit'](_0x3d98('0x73'),{'UserId':_0x446db9['body']['ids'][_0x223973],'TeamId':_0x446db9['params']['id']});}return _0x12f47a;});}})['then'](respondWithResult(_0x46ed00,null))['catch'](handleError(_0x46ed00,null));};exports[_0x3d98('0x74')]=function(_0xc3dcbb,_0x412107,_0x6abcfe){return db[_0x3d98('0x34')][_0x3d98('0x4f')]({'where':{'id':_0xc3dcbb[_0x3d98('0x4c')]['id']}})['then'](handleEntityNotFound(_0x412107,null))['then'](function(_0x3c34af){if(_0x3c34af){return BPromise[_0x3d98('0x6a')]([_0x3d98('0x75'),'chat','mail',_0x3d98('0x76'),'fax',_0x3d98('0x77')],function(_0x422db7){return _0x3c34af[_0x3d98('0x29')+_['capitalize'](_0x422db7)+_0x3d98('0x63')]({'attributes':['id',_0x3d98('0x30')]})['then'](function(_0x28f7c2){return BPromise[_0x3d98('0x6a')](_0x28f7c2,function(_0x390cfa){return _0x390cfa[_0x3d98('0x74')](_0xc3dcbb[_0x3d98('0x39')]['ids'])['then'](function(){if(_0x422db7===_0x3d98('0x75')){return db[_0x3d98('0x70')][_0x3d98('0x2c')]({'where':{'VoiceQueueId':_0x390cfa['id'],'UserId':_0xc3dcbb[_0x3d98('0x39')]['ids']}});}});});})[_0x3d98('0x28')](function(){return _0x3c34af;});})['then'](function(){return _0x3c34af;});}})[_0x3d98('0x28')](function(_0x535e16){if(_0x535e16){return _0x535e16[_0x3d98('0x74')](_0xc3dcbb[_0x3d98('0x39')][_0x3d98('0x64')])[_0x3d98('0x28')](function(){if(_[_0x3d98('0x78')](_0xc3dcbb[_0x3d98('0x39')]['ids'])){for(var _0x2a16ef=0x0;_0x2a16ef<_0xc3dcbb[_0x3d98('0x39')][_0x3d98('0x64')][_0x3d98('0x3d')];_0x2a16ef+=0x1){socket[_0x3d98('0x79')]('userTeam:remove',{'UserId':Number(_0xc3dcbb[_0x3d98('0x39')][_0x3d98('0x64')][_0x2a16ef]),'TeamId':Number(_0xc3dcbb[_0x3d98('0x4c')]['id'])});}}else{socket[_0x3d98('0x79')](_0x3d98('0x7a'),{'UserId':Number(_0xc3dcbb[_0x3d98('0x39')]['ids']),'TeamId':Number(_0xc3dcbb[_0x3d98('0x4c')]['id'])});}});}})['then'](respondWithStatusCode(_0x412107,null))[_0x3d98('0x4b')](handleError(_0x412107,null));};exports[_0x3d98('0x7b')]=function(_0x1d836e,_0x4aec12,_0x5b2ba0){var _0x4a15b2={};var _0x572310={};var _0x394b65;var _0x3b3136;return db[_0x3d98('0x34')][_0x3d98('0x58')]({'where':{'id':_0x1d836e[_0x3d98('0x4c')]['id']}})[_0x3d98('0x28')](handleEntityNotFound(_0x4aec12,null))['then'](function(_0x592075){if(_0x592075){_0x394b65=_0x592075;_0x572310[_0x3d98('0x38')]=_[_0x3d98('0x4d')](db[_0x3d98('0x6c')]['rawAttributes']);_0x572310['query']=_[_0x3d98('0x4d')](_0x1d836e[_0x3d98('0x39')]);_0x572310[_0x3d98('0x42')]=_['intersection'](_0x572310['model'],_0x572310['query']);_0x4a15b2[_0x3d98('0x3b')]=_[_0x3d98('0x3a')](_0x572310['model'],qs[_0x3d98('0x3c')](_0x1d836e[_0x3d98('0x39')][_0x3d98('0x3c')]));_0x4a15b2['attributes']=_0x4a15b2[_0x3d98('0x3b')][_0x3d98('0x3d')]?_0x4a15b2[_0x3d98('0x3b')]:_0x572310[_0x3d98('0x38')];_0x4a15b2[_0x3d98('0x3f')]=qs[_0x3d98('0x40')](_0x1d836e[_0x3d98('0x39')]['sort']);_0x4a15b2['where']=qs[_0x3d98('0x42')](_['pick'](_0x1d836e[_0x3d98('0x39')],_0x572310[_0x3d98('0x42')]));if(_0x1d836e['query']['filter']){_0x4a15b2[_0x3d98('0x41')]=_[_0x3d98('0x45')](_0x4a15b2['where'],{'$or':_[_0x3d98('0x33')](_0x4a15b2[_0x3d98('0x3b')],function(_0x487c80){var _0x3254e7={};_0x3254e7[_0x487c80]={'$like':'%'+_0x1d836e[_0x3d98('0x39')][_0x3d98('0x44')]+'%'};return _0x3254e7;})});}_0x4a15b2=_[_0x3d98('0x45')]({},_0x4a15b2,_0x1d836e[_0x3d98('0x61')]);return _0x394b65[_0x3d98('0x7b')](_0x4a15b2);}})[_0x3d98('0x28')](function(_0x18180b){if(_0x18180b){_0x3b3136=_0x18180b[_0x3d98('0x3d')];if(!_0x1d836e[_0x3d98('0x39')][_0x3d98('0x3e')](_0x3d98('0x7c'))){_0x4a15b2['limit']=qs[_0x3d98('0x21')](_0x1d836e['query']['limit']);_0x4a15b2['offset']=qs[_0x3d98('0x20')](_0x1d836e[_0x3d98('0x39')]['offset']);}return _0x394b65['getAgents'](_0x4a15b2);}})[_0x3d98('0x28')](function(_0x5c15e1){if(_0x5c15e1){return _0x5c15e1?{'count':_0x3b3136,'rows':_0x5c15e1}:null;}})[_0x3d98('0x28')](respondWithResult(_0x4aec12,null))['catch'](handleError(_0x4aec12,null));};
\ No newline at end of file
+var _0xf86c=['addQueues','Sequelize','Queues','ids','removeQueues','remove','Voice','Chat','Sms','Fax','Openchannel','Whatsapp','each','addAgents','User','online','voicePause','interface','UserVoiceQueueRt','upsert','isNil','SIP/%s','spread','emit','userTeam:save','removeAgents','voice','chat','sms','fax','openchannel','whatsapp','isArray','userTeam:remove','getAgents','html-pdf','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','count','offset','limit','set','apply','then','destroy','get','Teams','UserProfileResource','name','send','index','map','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','pick','filter','merge','type','options','Team','includeAll','include','findAll','rows','show','params','rawAttributes','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','getQueues','findOne','channel','isValidChannel','ValidationError','Unknown\x20channel','toLowerCase','Queue','sort','capitalize'];(function(_0x2db735,_0x5ddb29){var _0x445d0e=function(_0x571f5a){while(--_0x571f5a){_0x2db735['push'](_0x2db735['shift']());}};_0x445d0e(++_0x5ddb29);}(_0xf86c,0x11f));var _0xcf86=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xf86c[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xcf86('0x0'));var emlformat=require(_0xcf86('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xcf86('0x2'));var rp=require(_0xcf86('0x3'));var moment=require(_0xcf86('0x4'));var BPromise=require(_0xcf86('0x5'));var Mustache=require(_0xcf86('0x6'));var util=require(_0xcf86('0x7'));var path=require(_0xcf86('0x8'));var sox=require(_0xcf86('0x9'));var csv=require(_0xcf86('0xa'));var ejs=require(_0xcf86('0xb'));var fs=require('fs');var _=require(_0xcf86('0xc'));var squel=require('squel');var crypto=require(_0xcf86('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xcf86('0xe'));var toCsv=require(_0xcf86('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xcf86('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xcf86('0x10'));var as=require(_0xcf86('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xcf86('0x12'))('api');var utils=require(_0xcf86('0x13'));var config=require(_0xcf86('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xcf86('0x15'))['db'];config[_0xcf86('0x16')]=_['defaults'](config[_0xcf86('0x16')],{'host':_0xcf86('0x17'),'port':0x18eb});var socket=require(_0xcf86('0x18'))(new Redis(config[_0xcf86('0x16')]));require('./team.socket')[_0xcf86('0x19')](socket);function respondWithStatusCode(_0x10e253,_0x211aee){_0x211aee=_0x211aee||0xcc;return function(_0x1b8384){if(_0x1b8384){return _0x10e253[_0xcf86('0x1a')](_0x211aee);}return _0x10e253[_0xcf86('0x1b')](_0x211aee)[_0xcf86('0x1c')]();};}function respondWithResult(_0x348782,_0x51bd52){_0x51bd52=_0x51bd52||0xc8;return function(_0x1ccc97){if(_0x1ccc97){return _0x348782[_0xcf86('0x1b')](_0x51bd52)[_0xcf86('0x1d')](_0x1ccc97);}};}function respondWithFilteredResult(_0x43b07c,_0x27ff8f){return function(_0xa519d4){if(_0xa519d4){var _0x2d55c0=_0xa519d4[_0xcf86('0x1e')],_0x4f76c8=_0x27ff8f[_0xcf86('0x1f')],_0x10c2cd=_0x27ff8f[_0xcf86('0x1f')]+_0x27ff8f[_0xcf86('0x20')],_0x18e3a2;if(_0x10c2cd>=_0x2d55c0){_0x10c2cd=_0x2d55c0;_0x18e3a2=0xc8;}else{_0x18e3a2=0xce;}_0x43b07c['status'](_0x18e3a2);return _0x43b07c[_0xcf86('0x21')]('Content-Range',_0x4f76c8+'-'+_0x10c2cd+'/'+_0x2d55c0)[_0xcf86('0x1d')](_0xa519d4);}return null;};}function patchUpdates(_0xdcb271){return function(_0x4ed71c){try{jsonpatch[_0xcf86('0x22')](_0x4ed71c,_0xdcb271,!![]);}catch(_0x10b709){return BPromise['reject'](_0x10b709);}return _0x4ed71c['save']();};}function saveUpdates(_0x52c93a,_0x4e8658){return function(_0x3df226){if(_0x3df226){return _0x3df226['update'](_0x52c93a)[_0xcf86('0x23')](function(_0x293a4f){return _0x293a4f;});}return null;};}function removeEntity(_0x1aa1f3,_0x409b6c){return function(_0x328bc0){if(_0x328bc0){return _0x328bc0[_0xcf86('0x24')]()[_0xcf86('0x23')](function(){var _0x1ddc7d=_0x328bc0[_0xcf86('0x25')]({'plain':!![]});var _0x26929f=_0xcf86('0x26');return db[_0xcf86('0x27')][_0xcf86('0x24')]({'where':{'type':_0x26929f,'resourceId':_0x1ddc7d['id']}})[_0xcf86('0x23')](function(){return _0x328bc0;});})[_0xcf86('0x23')](function(){_0x1aa1f3[_0xcf86('0x1b')](0xcc)[_0xcf86('0x1c')]();});}};}function handleEntityNotFound(_0x21fd0e,_0x569977){return function(_0x28aef4){if(!_0x28aef4){_0x21fd0e['sendStatus'](0x194);}return _0x28aef4;};}function handleError(_0x11e458,_0x25a632){_0x25a632=_0x25a632||0x1f4;return function(_0x47229e){logger['error'](_0x47229e['stack']);if(_0x47229e['name']){delete _0x47229e[_0xcf86('0x28')];}_0x11e458['status'](_0x25a632)[_0xcf86('0x29')](_0x47229e);};}exports[_0xcf86('0x2a')]=function(_0x2dcfb8,_0x1fe869){var _0xb5323c={},_0x437b94={},_0x3097c7={'count':0x0,'rows':[]};var _0x5c8f96=_[_0xcf86('0x2b')](db['Team']['rawAttributes'],function(_0x3f16e7){return{'name':_0x3f16e7['fieldName'],'type':_0x3f16e7['type'][_0xcf86('0x2c')]};});_0x437b94[_0xcf86('0x2d')]=_[_0xcf86('0x2b')](_0x5c8f96,_0xcf86('0x28'));_0x437b94[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x2dcfb8['query']);_0x437b94[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x437b94[_0xcf86('0x2d')],_0x437b94[_0xcf86('0x2e')]);_0xb5323c[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x437b94[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x33')]));_0xb5323c['attributes']=_0xb5323c['attributes'][_0xcf86('0x34')]?_0xb5323c[_0xcf86('0x32')]:_0x437b94['model'];if(!_0x2dcfb8['query'][_0xcf86('0x35')](_0xcf86('0x36'))){_0xb5323c[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x2dcfb8['query'][_0xcf86('0x20')]);_0xb5323c[_0xcf86('0x1f')]=qs[_0xcf86('0x1f')](_0x2dcfb8['query'][_0xcf86('0x1f')]);}_0xb5323c[_0xcf86('0x37')]=qs['sort'](_0x2dcfb8[_0xcf86('0x2e')]['sort']);_0xb5323c[_0xcf86('0x38')]=qs['filters'](_[_0xcf86('0x39')](_0x2dcfb8[_0xcf86('0x2e')],_0x437b94[_0xcf86('0x30')]),_0x5c8f96);if(_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3a')]){_0xb5323c['where']=_[_0xcf86('0x3b')](_0xb5323c[_0xcf86('0x38')],{'$or':_[_0xcf86('0x2b')](_0x5c8f96,function(_0x5eee4e){if(_0x5eee4e[_0xcf86('0x3c')]!=='VIRTUAL'){var _0x21bb42={};_0x21bb42[_0x5eee4e[_0xcf86('0x28')]]={'$like':'%'+_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3a')]+'%'};return _0x21bb42;}})});}_0xb5323c=_[_0xcf86('0x3b')]({},_0xb5323c,_0x2dcfb8[_0xcf86('0x3d')]);var _0x5029e8={'where':_0xb5323c['where']};return db[_0xcf86('0x3e')][_0xcf86('0x1e')](_0x5029e8)[_0xcf86('0x23')](function(_0x480fdb){_0x3097c7[_0xcf86('0x1e')]=_0x480fdb;if(_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3f')]){_0xb5323c[_0xcf86('0x40')]=[{'all':!![]}];}return db[_0xcf86('0x3e')][_0xcf86('0x41')](_0xb5323c);})[_0xcf86('0x23')](function(_0x5966b6){_0x3097c7[_0xcf86('0x42')]=_0x5966b6;return _0x3097c7;})[_0xcf86('0x23')](respondWithFilteredResult(_0x1fe869,_0xb5323c))['catch'](handleError(_0x1fe869,null));};exports[_0xcf86('0x43')]=function(_0x33e92a,_0x27a089){var _0x18518b={'raw':![],'where':{'id':_0x33e92a[_0xcf86('0x44')]['id']}},_0x204fd5={};_0x204fd5[_0xcf86('0x2d')]=_[_0xcf86('0x2f')](db[_0xcf86('0x3e')][_0xcf86('0x45')]);_0x204fd5[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x33e92a[_0xcf86('0x2e')]);_0x204fd5[_0xcf86('0x30')]=_['intersection'](_0x204fd5[_0xcf86('0x2d')],_0x204fd5[_0xcf86('0x2e')]);_0x18518b[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x204fd5[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x33e92a[_0xcf86('0x2e')][_0xcf86('0x33')]));_0x18518b[_0xcf86('0x32')]=_0x18518b['attributes'][_0xcf86('0x34')]?_0x18518b[_0xcf86('0x32')]:_0x204fd5[_0xcf86('0x2d')];if(_0x33e92a[_0xcf86('0x2e')][_0xcf86('0x3f')]){_0x18518b['include']=[{'all':!![]}];}_0x18518b=_[_0xcf86('0x3b')]({},_0x18518b,_0x33e92a[_0xcf86('0x3d')]);return db[_0xcf86('0x3e')][_0xcf86('0x46')](_0x18518b)['then'](handleEntityNotFound(_0x27a089,null))['then'](respondWithResult(_0x27a089,null))[_0xcf86('0x47')](handleError(_0x27a089,null));};exports[_0xcf86('0x48')]=function(_0x138ead,_0x2392bd){return db[_0xcf86('0x3e')]['create'](_0x138ead[_0xcf86('0x49')],{})[_0xcf86('0x23')](function(_0x264f26){var _0x5d3b07=_0x138ead[_0xcf86('0x4a')][_0xcf86('0x25')]({'plain':!![]});if(!_0x5d3b07)throw new Error(_0xcf86('0x4b'));if(_0x5d3b07[_0xcf86('0x4c')]===_0xcf86('0x4a')){var _0x353b4a=_0x264f26[_0xcf86('0x25')]({'plain':!![]});var _0x2ddd87='Teams';return db['UserProfileSection'][_0xcf86('0x46')]({'where':{'name':_0x2ddd87,'userProfileId':_0x5d3b07[_0xcf86('0x4d')]},'raw':!![]})[_0xcf86('0x23')](function(_0x4a4008){if(_0x4a4008&&_0x4a4008['autoAssociation']===0x0){return db[_0xcf86('0x27')][_0xcf86('0x48')]({'name':_0x353b4a[_0xcf86('0x28')],'resourceId':_0x353b4a['id'],'type':_0x4a4008[_0xcf86('0x28')],'sectionId':_0x4a4008['id']},{})[_0xcf86('0x23')](function(){return _0x264f26;});}else{return _0x264f26;}})['catch'](function(_0x4bd781){logger[_0xcf86('0x4e')](_0xcf86('0x4f'),_0x4bd781);throw _0x4bd781;});}return _0x264f26;})[_0xcf86('0x23')](respondWithResult(_0x2392bd,0xc9))[_0xcf86('0x47')](handleError(_0x2392bd,null));};exports[_0xcf86('0x50')]=function(_0x424da,_0x27af8f){if(_0x424da[_0xcf86('0x49')]['id']){delete _0x424da[_0xcf86('0x49')]['id'];}return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x424da[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x27af8f,null))[_0xcf86('0x23')](saveUpdates(_0x424da[_0xcf86('0x49')],null))['then'](respondWithResult(_0x27af8f,null))[_0xcf86('0x47')](handleError(_0x27af8f,null));};exports[_0xcf86('0x24')]=function(_0x4a4403,_0x5487ab){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x4a4403[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x5487ab,null))[_0xcf86('0x23')](removeEntity(_0x5487ab,null))[_0xcf86('0x47')](handleError(_0x5487ab,null));};exports[_0xcf86('0x51')]=function(_0x3eb775,_0x315881,_0x78c63c){return db[_0xcf86('0x3e')][_0xcf86('0x52')]({'where':{'id':_0x3eb775[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x315881,null))[_0xcf86('0x23')](function(_0x284330){if(!_0x3eb775['query'][_0xcf86('0x53')]||!utils[_0xcf86('0x54')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')])){throw new db['Sequelize'][(_0xcf86('0x55'))](_0xcf86('0x56'));}var _0x2395f7={};var _0x10a79c={};_0x10a79c[_0xcf86('0x2d')]=_[_0xcf86('0x2f')](db[_['capitalize'](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')][_0xcf86('0x57')]())+_0xcf86('0x58')][_0xcf86('0x45')]);_0x10a79c[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x3eb775[_0xcf86('0x2e')]);_0x10a79c[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x10a79c[_0xcf86('0x2d')],_0x10a79c['query']);_0x2395f7[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x10a79c[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x3eb775[_0xcf86('0x2e')]['fields']));_0x2395f7['attributes']=_0x2395f7[_0xcf86('0x32')][_0xcf86('0x34')]?_0x2395f7[_0xcf86('0x32')]:_0x10a79c[_0xcf86('0x2d')];_0x2395f7[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x20')]);_0x2395f7['offset']=qs[_0xcf86('0x1f')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x1f')]);_0x2395f7[_0xcf86('0x37')]=qs[_0xcf86('0x59')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x59')]);_0x2395f7[_0xcf86('0x38')]=qs[_0xcf86('0x30')](_[_0xcf86('0x39')](_0x3eb775[_0xcf86('0x2e')],_0x10a79c[_0xcf86('0x30')]));_0x2395f7=_['merge']({},_0x2395f7,_0x3eb775[_0xcf86('0x3d')]);return _0x284330[_0xcf86('0x25')+_[_0xcf86('0x5a')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')][_0xcf86('0x57')]())+'Queues'](_0x2395f7);})['then'](respondWithResult(_0x315881,null))['catch'](handleError(_0x315881,null));};exports[_0xcf86('0x5b')]=function(_0x550bc0,_0x2968b8,_0x57255c){return db[_0xcf86('0x3e')]['findOne']({'where':{'id':_0x550bc0['params']['id']}})[_0xcf86('0x23')](function(_0x2100f8){if(_0x2100f8){if(!_0x550bc0[_0xcf86('0x49')][_0xcf86('0x53')]||!utils['isValidChannel'](_0x550bc0[_0xcf86('0x49')][_0xcf86('0x53')])){throw new db[(_0xcf86('0x5c'))]['ValidationError'](_0xcf86('0x56'));}return _0x2100f8['add'+_[_0xcf86('0x5a')](_0x550bc0[_0xcf86('0x49')]['channel'][_0xcf86('0x57')]())+_0xcf86('0x5d')](_0x550bc0['body'][_0xcf86('0x5e')]);}return null;})[_0xcf86('0x23')](handleEntityNotFound(_0x2968b8,null))[_0xcf86('0x23')](respondWithStatusCode(_0x2968b8,null))['catch'](handleError(_0x2968b8,null));};exports[_0xcf86('0x5f')]=function(_0xf0e230,_0x450ad9,_0x559877){return db[_0xcf86('0x3e')][_0xcf86('0x52')]({'where':{'id':_0xf0e230[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](function(_0x4e2e1e){if(_0x4e2e1e){if(!_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x53')]||!utils[_0xcf86('0x54')](_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x53')])){throw new db[(_0xcf86('0x5c'))][(_0xcf86('0x55'))](_0xcf86('0x56'));}return _0x4e2e1e[_0xcf86('0x60')+_['capitalize'](_0xf0e230['query'][_0xcf86('0x53')][_0xcf86('0x57')]())+'Queues'](_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x5e')]);}return null;})[_0xcf86('0x23')](handleEntityNotFound(_0x450ad9,null))[_0xcf86('0x23')](respondWithStatusCode(_0x450ad9,null))[_0xcf86('0x47')](handleError(_0x450ad9,null));};exports['addAgents']=function(_0x18e898,_0x11b629,_0x131d61){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x18e898['params']['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x11b629,null))[_0xcf86('0x23')](function(_0x2cb634){if(_0x2cb634){var _0x1fcb82=[_0xcf86('0x61'),_0xcf86('0x62'),'Mail',_0xcf86('0x63'),_0xcf86('0x64'),_0xcf86('0x65'),_0xcf86('0x66')];return BPromise[_0xcf86('0x67')](_0x1fcb82,function(_0x45e9ec){return _0x2cb634[_0xcf86('0x25')+_0x45e9ec+_0xcf86('0x5d')]({'attributes':['id',_0xcf86('0x28')]})[_0xcf86('0x23')](function(_0x15b521){return BPromise['each'](_0x15b521,function(_0x4c4a52){return _0x4c4a52[_0xcf86('0x68')](_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')])['then'](function(){if(_0x45e9ec==='Voice'){return db[_0xcf86('0x69')][_0xcf86('0x41')]({'where':{'id':_0x18e898['body']['ids']},'attributes':['id',_0xcf86('0x28'),_0xcf86('0x6a'),_0xcf86('0x6b'),_0xcf86('0x6c')],'raw':!![]})[_0xcf86('0x23')](function(_0x265802){return BPromise[_0xcf86('0x67')](_[_0xcf86('0x3a')](_0x265802,{'online':0x1}),function(_0x8d6a51){return db[_0xcf86('0x6d')][_0xcf86('0x6e')]({'membername':_0x8d6a51[_0xcf86('0x28')],'UserId':_0x8d6a51['id'],'queue_name':_0x4c4a52[_0xcf86('0x28')],'VoiceQueueId':_0x4c4a52['id'],'interface':_[_0xcf86('0x6f')](_0x8d6a51['interface'])?util['format'](_0xcf86('0x70'),_0x8d6a51[_0xcf86('0x28')]):_0x8d6a51[_0xcf86('0x6c')],'paused':_0x8d6a51[_0xcf86('0x6b')]||![],'penalty':0x0});});});}});});})[_0xcf86('0x23')](function(){return _0x2cb634;});})[_0xcf86('0x23')](function(){return _0x2cb634;});}})[_0xcf86('0x23')](function(_0x15d468){if(_0x15d468){return _0x15d468['addAgents'](_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')],_['omit'](_0x18e898[_0xcf86('0x49')],[_0xcf86('0x5e'),'id'])||{})[_0xcf86('0x71')](function(_0x54fda8){for(var _0xd2e31e=0x0;_0xd2e31e<_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')][_0xcf86('0x34')];_0xd2e31e+=0x1){socket[_0xcf86('0x72')](_0xcf86('0x73'),{'UserId':_0x18e898['body']['ids'][_0xd2e31e],'TeamId':_0x18e898[_0xcf86('0x44')]['id']});}return _0x54fda8;});}})[_0xcf86('0x23')](respondWithResult(_0x11b629,null))[_0xcf86('0x47')](handleError(_0x11b629,null));};exports[_0xcf86('0x74')]=function(_0x40fd1a,_0x45f981,_0x319346){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x40fd1a[_0xcf86('0x44')]['id']}})['then'](handleEntityNotFound(_0x45f981,null))[_0xcf86('0x23')](function(_0x339856){if(_0x339856){return BPromise[_0xcf86('0x67')]([_0xcf86('0x75'),_0xcf86('0x76'),'mail',_0xcf86('0x77'),_0xcf86('0x78'),_0xcf86('0x79'),_0xcf86('0x7a')],function(_0x9ac1a5){return _0x339856[_0xcf86('0x25')+_[_0xcf86('0x5a')](_0x9ac1a5)+_0xcf86('0x5d')]({'attributes':['id',_0xcf86('0x28')]})[_0xcf86('0x23')](function(_0x5ffa59){return BPromise[_0xcf86('0x67')](_0x5ffa59,function(_0x467cc7){return _0x467cc7['removeAgents'](_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')])[_0xcf86('0x23')](function(){if(_0x9ac1a5===_0xcf86('0x75')){return db[_0xcf86('0x6d')][_0xcf86('0x24')]({'where':{'VoiceQueueId':_0x467cc7['id'],'UserId':_0x40fd1a[_0xcf86('0x2e')]['ids']}});}});});})['then'](function(){return _0x339856;});})[_0xcf86('0x23')](function(){return _0x339856;});}})[_0xcf86('0x23')](function(_0x2966b3){if(_0x2966b3){return _0x2966b3[_0xcf86('0x74')](_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')])[_0xcf86('0x23')](function(){if(_[_0xcf86('0x7b')](_0x40fd1a['query'][_0xcf86('0x5e')])){for(var _0xcab53a=0x0;_0xcab53a<_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')][_0xcf86('0x34')];_0xcab53a+=0x1){socket['emit'](_0xcf86('0x7c'),{'UserId':Number(_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')][_0xcab53a]),'TeamId':Number(_0x40fd1a['params']['id'])});}}else{socket['emit'](_0xcf86('0x7c'),{'UserId':Number(_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')]),'TeamId':Number(_0x40fd1a[_0xcf86('0x44')]['id'])});}});}})[_0xcf86('0x23')](respondWithStatusCode(_0x45f981,null))['catch'](handleError(_0x45f981,null));};exports[_0xcf86('0x7d')]=function(_0x319ada,_0x457e08,_0x4cf4bf){var _0x31f519={};var _0x32b1e7={};var _0x3fc4ff;var _0x1b41f7;return db[_0xcf86('0x3e')]['findOne']({'where':{'id':_0x319ada[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x457e08,null))[_0xcf86('0x23')](function(_0x11a059){if(_0x11a059){_0x3fc4ff=_0x11a059;_0x32b1e7['model']=_[_0xcf86('0x2f')](db[_0xcf86('0x69')][_0xcf86('0x45')]);_0x32b1e7[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x319ada[_0xcf86('0x2e')]);_0x32b1e7[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x32b1e7[_0xcf86('0x2d')],_0x32b1e7[_0xcf86('0x2e')]);_0x31f519[_0xcf86('0x32')]=_['intersection'](_0x32b1e7[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x319ada[_0xcf86('0x2e')]['fields']));_0x31f519[_0xcf86('0x32')]=_0x31f519[_0xcf86('0x32')][_0xcf86('0x34')]?_0x31f519[_0xcf86('0x32')]:_0x32b1e7['model'];_0x31f519['order']=qs[_0xcf86('0x59')](_0x319ada[_0xcf86('0x2e')]['sort']);_0x31f519['where']=qs[_0xcf86('0x30')](_[_0xcf86('0x39')](_0x319ada['query'],_0x32b1e7['filters']));if(_0x319ada['query']['filter']){_0x31f519[_0xcf86('0x38')]=_['merge'](_0x31f519[_0xcf86('0x38')],{'$or':_[_0xcf86('0x2b')](_0x31f519['attributes'],function(_0x32b0b5){var _0x99972a={};_0x99972a[_0x32b0b5]={'$like':'%'+_0x319ada[_0xcf86('0x2e')][_0xcf86('0x3a')]+'%'};return _0x99972a;})});}_0x31f519=_[_0xcf86('0x3b')]({},_0x31f519,_0x319ada['options']);return _0x3fc4ff[_0xcf86('0x7d')](_0x31f519);}})[_0xcf86('0x23')](function(_0xbe67a8){if(_0xbe67a8){_0x1b41f7=_0xbe67a8[_0xcf86('0x34')];if(!_0x319ada[_0xcf86('0x2e')][_0xcf86('0x35')]('nolimit')){_0x31f519[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x319ada[_0xcf86('0x2e')][_0xcf86('0x20')]);_0x31f519[_0xcf86('0x1f')]=qs['offset'](_0x319ada[_0xcf86('0x2e')][_0xcf86('0x1f')]);}return _0x3fc4ff[_0xcf86('0x7d')](_0x31f519);}})[_0xcf86('0x23')](function(_0x38aff2){if(_0x38aff2){return _0x38aff2?{'count':_0x1b41f7,'rows':_0x38aff2}:null;}})['then'](respondWithResult(_0x457e08,null))[_0xcf86('0x47')](handleError(_0x457e08,null));};
\ No newline at end of file