Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / team / team.controller.js
index 41419d6..037342d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf928=['set','Content-Range','reject','save','update','then','get','Teams','UserProfileResource','destroy','stack','name','send','index','map','Team','rawAttributes','fieldName','type','key','model','query','filters','fields','attributes','length','nolimit','limit','order','sort','where','pick','filter','VIRTUAL','options','includeAll','findAll','rows','show','params','keys','intersection','include','merge','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','autoAssociation','catch','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','channel','isValidChannel','Sequelize','ValidationError','Unknown\x20channel','capitalize','toLowerCase','Queue','Queues','addQueues','findOne','add','ids','removeQueues','addAgents','Voice','Chat','Sms','Openchannel','User','interface','upsert','format','SIP/%s','voicePause','spread','emit','userTeam:save','removeAgents','voice','chat','mail','whatsapp','each','UserVoiceQueueRt','isArray','userTeam:remove','getAgents','hasOwnProperty','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','socket.io-emitter','./team.socket','register','sendStatus','end','status','json','count','offset'];(function(_0x117f4c,_0x36a9b1){var _0x2b24e9=function(_0x31761b){while(--_0x31761b){_0x117f4c['push'](_0x117f4c['shift']());}};_0x2b24e9(++_0x36a9b1);}(_0xf928,0xe0));var _0x8f92=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xf928[_0x14add3];return _0x4a174f;};'use strict';var pdf=require(_0x8f92('0x0'));var emlformat=require(_0x8f92('0x1'));var rimraf=require(_0x8f92('0x2'));var zipdir=require(_0x8f92('0x3'));var jsonpatch=require(_0x8f92('0x4'));var rp=require(_0x8f92('0x5'));var moment=require(_0x8f92('0x6'));var BPromise=require(_0x8f92('0x7'));var Mustache=require(_0x8f92('0x8'));var util=require(_0x8f92('0x9'));var path=require(_0x8f92('0xa'));var sox=require(_0x8f92('0xb'));var csv=require(_0x8f92('0xc'));var ejs=require(_0x8f92('0xd'));var fs=require('fs');var _=require('lodash');var squel=require(_0x8f92('0xe'));var crypto=require(_0x8f92('0xf'));var jsforce=require(_0x8f92('0x10'));var deskjs=require(_0x8f92('0x11'));var toCsv=require(_0x8f92('0xc'));var querystring=require(_0x8f92('0x12'));var Papa=require(_0x8f92('0x13'));var Redis=require(_0x8f92('0x14'));var authService=require(_0x8f92('0x15'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x8f92('0x16'));var logger=require(_0x8f92('0x17'))(_0x8f92('0x18'));var utils=require(_0x8f92('0x19'));var config=require('../../config/environment');var licenseUtil=require(_0x8f92('0x1a'));var db=require(_0x8f92('0x1b'))['db'];config[_0x8f92('0x1c')]=_['defaults'](config[_0x8f92('0x1c')],{'host':'localhost','port':0x18eb});var socket=require(_0x8f92('0x1d'))(new Redis(config['redis']));require(_0x8f92('0x1e'))[_0x8f92('0x1f')](socket);function respondWithStatusCode(_0xdfa620,_0x2f53cd){_0x2f53cd=_0x2f53cd||0xcc;return function(_0x18a8ae){if(_0x18a8ae){return _0xdfa620[_0x8f92('0x20')](_0x2f53cd);}return _0xdfa620['status'](_0x2f53cd)[_0x8f92('0x21')]();};}function respondWithResult(_0x348bc3,_0x187271){_0x187271=_0x187271||0xc8;return function(_0x3b34d3){if(_0x3b34d3){return _0x348bc3[_0x8f92('0x22')](_0x187271)[_0x8f92('0x23')](_0x3b34d3);}};}function respondWithFilteredResult(_0xfece0b,_0x547d04){return function(_0x4c2608){if(_0x4c2608){var _0x1f8de5=_0x4c2608[_0x8f92('0x24')],_0x1db5e1=_0x547d04['offset'],_0x58b3fb=_0x547d04[_0x8f92('0x25')]+_0x547d04['limit'],_0x3d84bc;if(_0x58b3fb>=_0x1f8de5){_0x58b3fb=_0x1f8de5;_0x3d84bc=0xc8;}else{_0x3d84bc=0xce;}_0xfece0b[_0x8f92('0x22')](_0x3d84bc);return _0xfece0b[_0x8f92('0x26')](_0x8f92('0x27'),_0x1db5e1+'-'+_0x58b3fb+'/'+_0x1f8de5)['json'](_0x4c2608);}return null;};}function patchUpdates(_0x1119b4){return function(_0x572300){try{jsonpatch['apply'](_0x572300,_0x1119b4,!![]);}catch(_0x5f0bcd){return BPromise[_0x8f92('0x28')](_0x5f0bcd);}return _0x572300[_0x8f92('0x29')]();};}function saveUpdates(_0x26c275,_0x4e6c3b){return function(_0x369936){if(_0x369936){return _0x369936[_0x8f92('0x2a')](_0x26c275)['then'](function(_0x4c2ca5){return _0x4c2ca5;});}return null;};}function removeEntity(_0x32a821,_0x2201de){return function(_0x448159){if(_0x448159){return _0x448159['destroy']()[_0x8f92('0x2b')](function(){var _0x5a9d12=_0x448159[_0x8f92('0x2c')]({'plain':!![]});var _0x4f617f=_0x8f92('0x2d');return db[_0x8f92('0x2e')][_0x8f92('0x2f')]({'where':{'type':_0x4f617f,'resourceId':_0x5a9d12['id']}})[_0x8f92('0x2b')](function(){return _0x448159;});})['then'](function(){_0x32a821[_0x8f92('0x22')](0xcc)[_0x8f92('0x21')]();});}};}function handleEntityNotFound(_0x4a8462,_0x22c7b0){return function(_0x3e85f4){if(!_0x3e85f4){_0x4a8462[_0x8f92('0x20')](0x194);}return _0x3e85f4;};}function handleError(_0x2295d7,_0x5dcac5){_0x5dcac5=_0x5dcac5||0x1f4;return function(_0x338a3c){logger['error'](_0x338a3c[_0x8f92('0x30')]);if(_0x338a3c[_0x8f92('0x31')]){delete _0x338a3c[_0x8f92('0x31')];}_0x2295d7[_0x8f92('0x22')](_0x5dcac5)[_0x8f92('0x32')](_0x338a3c);};}exports[_0x8f92('0x33')]=function(_0x1abb1c,_0x5bfdcc){var _0x47625d={},_0x60f772={},_0x364441={'count':0x0,'rows':[]};var _0x5efcc4=_[_0x8f92('0x34')](db[_0x8f92('0x35')][_0x8f92('0x36')],function(_0x2019c8){return{'name':_0x2019c8[_0x8f92('0x37')],'type':_0x2019c8[_0x8f92('0x38')][_0x8f92('0x39')]};});_0x60f772[_0x8f92('0x3a')]=_[_0x8f92('0x34')](_0x5efcc4,_0x8f92('0x31'));_0x60f772[_0x8f92('0x3b')]=_['keys'](_0x1abb1c['query']);_0x60f772[_0x8f92('0x3c')]=_['intersection'](_0x60f772[_0x8f92('0x3a')],_0x60f772[_0x8f92('0x3b')]);_0x47625d['attributes']=_['intersection'](_0x60f772[_0x8f92('0x3a')],qs[_0x8f92('0x3d')](_0x1abb1c[_0x8f92('0x3b')][_0x8f92('0x3d')]));_0x47625d[_0x8f92('0x3e')]=_0x47625d[_0x8f92('0x3e')][_0x8f92('0x3f')]?_0x47625d[_0x8f92('0x3e')]:_0x60f772[_0x8f92('0x3a')];if(!_0x1abb1c[_0x8f92('0x3b')]['hasOwnProperty'](_0x8f92('0x40'))){_0x47625d[_0x8f92('0x41')]=qs[_0x8f92('0x41')](_0x1abb1c[_0x8f92('0x3b')][_0x8f92('0x41')]);_0x47625d[_0x8f92('0x25')]=qs[_0x8f92('0x25')](_0x1abb1c[_0x8f92('0x3b')]['offset']);}_0x47625d[_0x8f92('0x42')]=qs[_0x8f92('0x43')](_0x1abb1c[_0x8f92('0x3b')]['sort']);_0x47625d[_0x8f92('0x44')]=qs[_0x8f92('0x3c')](_[_0x8f92('0x45')](_0x1abb1c[_0x8f92('0x3b')],_0x60f772[_0x8f92('0x3c')]),_0x5efcc4);if(_0x1abb1c['query'][_0x8f92('0x46')]){_0x47625d[_0x8f92('0x44')]=_['merge'](_0x47625d['where'],{'$or':_['map'](_0x5efcc4,function(_0x3154d8){if(_0x3154d8[_0x8f92('0x38')]!==_0x8f92('0x47')){var _0x7f7834={};_0x7f7834[_0x3154d8[_0x8f92('0x31')]]={'$like':'%'+_0x1abb1c[_0x8f92('0x3b')][_0x8f92('0x46')]+'%'};return _0x7f7834;}})});}_0x47625d=_['merge']({},_0x47625d,_0x1abb1c[_0x8f92('0x48')]);var _0x346683={'where':_0x47625d[_0x8f92('0x44')]};return db[_0x8f92('0x35')][_0x8f92('0x24')](_0x346683)['then'](function(_0x30607d){_0x364441[_0x8f92('0x24')]=_0x30607d;if(_0x1abb1c[_0x8f92('0x3b')][_0x8f92('0x49')]){_0x47625d['include']=[{'all':!![]}];}return db[_0x8f92('0x35')][_0x8f92('0x4a')](_0x47625d);})['then'](function(_0x53c304){_0x364441[_0x8f92('0x4b')]=_0x53c304;return _0x364441;})[_0x8f92('0x2b')](respondWithFilteredResult(_0x5bfdcc,_0x47625d))['catch'](handleError(_0x5bfdcc,null));};exports[_0x8f92('0x4c')]=function(_0x1cc1dc,_0x496710){var _0x50845a={'raw':![],'where':{'id':_0x1cc1dc[_0x8f92('0x4d')]['id']}},_0x61e935={};_0x61e935[_0x8f92('0x3a')]=_[_0x8f92('0x4e')](db[_0x8f92('0x35')][_0x8f92('0x36')]);_0x61e935[_0x8f92('0x3b')]=_['keys'](_0x1cc1dc['query']);_0x61e935[_0x8f92('0x3c')]=_[_0x8f92('0x4f')](_0x61e935[_0x8f92('0x3a')],_0x61e935['query']);_0x50845a['attributes']=_[_0x8f92('0x4f')](_0x61e935['model'],qs[_0x8f92('0x3d')](_0x1cc1dc[_0x8f92('0x3b')][_0x8f92('0x3d')]));_0x50845a[_0x8f92('0x3e')]=_0x50845a[_0x8f92('0x3e')]['length']?_0x50845a[_0x8f92('0x3e')]:_0x61e935['model'];if(_0x1cc1dc[_0x8f92('0x3b')][_0x8f92('0x49')]){_0x50845a[_0x8f92('0x50')]=[{'all':!![]}];}_0x50845a=_[_0x8f92('0x51')]({},_0x50845a,_0x1cc1dc[_0x8f92('0x48')]);return db[_0x8f92('0x35')][_0x8f92('0x52')](_0x50845a)[_0x8f92('0x2b')](handleEntityNotFound(_0x496710,null))[_0x8f92('0x2b')](respondWithResult(_0x496710,null))['catch'](handleError(_0x496710,null));};exports[_0x8f92('0x53')]=function(_0x1306ee,_0x58bcb6){return db['Team']['create'](_0x1306ee[_0x8f92('0x54')],{})[_0x8f92('0x2b')](function(_0x1150fb){var _0x2369b1=_0x1306ee[_0x8f92('0x55')][_0x8f92('0x2c')]({'plain':!![]});if(!_0x2369b1)throw new Error(_0x8f92('0x56'));if(_0x2369b1['role']===_0x8f92('0x55')){var _0x4ce106=_0x1150fb[_0x8f92('0x2c')]({'plain':!![]});var _0x1c9509=_0x8f92('0x2d');return db[_0x8f92('0x57')][_0x8f92('0x52')]({'where':{'name':_0x1c9509,'userProfileId':_0x2369b1['userProfileId']},'raw':!![]})[_0x8f92('0x2b')](function(_0x92c6ff){if(_0x92c6ff&&_0x92c6ff[_0x8f92('0x58')]===0x0){return db[_0x8f92('0x2e')]['create']({'name':_0x4ce106[_0x8f92('0x31')],'resourceId':_0x4ce106['id'],'type':_0x92c6ff[_0x8f92('0x31')],'sectionId':_0x92c6ff['id']},{})[_0x8f92('0x2b')](function(){return _0x1150fb;});}else{return _0x1150fb;}})[_0x8f92('0x59')](function(_0x216e93){logger[_0x8f92('0x5a')](_0x8f92('0x5b'),_0x216e93);throw _0x216e93;});}return _0x1150fb;})[_0x8f92('0x2b')](respondWithResult(_0x58bcb6,0xc9))[_0x8f92('0x59')](handleError(_0x58bcb6,null));};exports[_0x8f92('0x2a')]=function(_0x23d32d,_0x5a006f){if(_0x23d32d['body']['id']){delete _0x23d32d[_0x8f92('0x54')]['id'];}return db[_0x8f92('0x35')][_0x8f92('0x52')]({'where':{'id':_0x23d32d[_0x8f92('0x4d')]['id']}})[_0x8f92('0x2b')](handleEntityNotFound(_0x5a006f,null))[_0x8f92('0x2b')](saveUpdates(_0x23d32d[_0x8f92('0x54')],null))[_0x8f92('0x2b')](respondWithResult(_0x5a006f,null))[_0x8f92('0x59')](handleError(_0x5a006f,null));};exports[_0x8f92('0x2f')]=function(_0x21415e,_0x325b8f){return db['Team'][_0x8f92('0x52')]({'where':{'id':_0x21415e[_0x8f92('0x4d')]['id']}})[_0x8f92('0x2b')](handleEntityNotFound(_0x325b8f,null))['then'](removeEntity(_0x325b8f,null))[_0x8f92('0x59')](handleError(_0x325b8f,null));};exports['getQueues']=function(_0x388ff4,_0x4cf741,_0x590de8){return db[_0x8f92('0x35')]['findOne']({'where':{'id':_0x388ff4[_0x8f92('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4cf741,null))['then'](function(_0x13dea8){if(!_0x388ff4[_0x8f92('0x3b')][_0x8f92('0x5c')]||!utils[_0x8f92('0x5d')](_0x388ff4[_0x8f92('0x3b')][_0x8f92('0x5c')])){throw new db[(_0x8f92('0x5e'))][(_0x8f92('0x5f'))](_0x8f92('0x60'));}var _0x4973e0={};var _0x4ddcfc={};_0x4ddcfc['model']=_[_0x8f92('0x4e')](db[_[_0x8f92('0x61')](_0x388ff4[_0x8f92('0x3b')][_0x8f92('0x5c')][_0x8f92('0x62')]())+_0x8f92('0x63')]['rawAttributes']);_0x4ddcfc[_0x8f92('0x3b')]=_[_0x8f92('0x4e')](_0x388ff4[_0x8f92('0x3b')]);_0x4ddcfc[_0x8f92('0x3c')]=_[_0x8f92('0x4f')](_0x4ddcfc[_0x8f92('0x3a')],_0x4ddcfc[_0x8f92('0x3b')]);_0x4973e0[_0x8f92('0x3e')]=_[_0x8f92('0x4f')](_0x4ddcfc[_0x8f92('0x3a')],qs['fields'](_0x388ff4[_0x8f92('0x3b')][_0x8f92('0x3d')]));_0x4973e0[_0x8f92('0x3e')]=_0x4973e0[_0x8f92('0x3e')]['length']?_0x4973e0['attributes']:_0x4ddcfc['model'];_0x4973e0[_0x8f92('0x41')]=qs[_0x8f92('0x41')](_0x388ff4['query'][_0x8f92('0x41')]);_0x4973e0[_0x8f92('0x25')]=qs['offset'](_0x388ff4[_0x8f92('0x3b')]['offset']);_0x4973e0['order']=qs[_0x8f92('0x43')](_0x388ff4[_0x8f92('0x3b')]['sort']);_0x4973e0[_0x8f92('0x44')]=qs[_0x8f92('0x3c')](_[_0x8f92('0x45')](_0x388ff4[_0x8f92('0x3b')],_0x4ddcfc[_0x8f92('0x3c')]));_0x4973e0=_[_0x8f92('0x51')]({},_0x4973e0,_0x388ff4[_0x8f92('0x48')]);return _0x13dea8[_0x8f92('0x2c')+_[_0x8f92('0x61')](_0x388ff4[_0x8f92('0x3b')]['channel']['toLowerCase']())+_0x8f92('0x64')](_0x4973e0);})['then'](respondWithResult(_0x4cf741,null))[_0x8f92('0x59')](handleError(_0x4cf741,null));};exports[_0x8f92('0x65')]=function(_0x106213,_0x2b4132,_0x19c7d4){return db[_0x8f92('0x35')][_0x8f92('0x66')]({'where':{'id':_0x106213[_0x8f92('0x4d')]['id']}})['then'](function(_0x39d761){if(_0x39d761){if(!_0x106213[_0x8f92('0x54')][_0x8f92('0x5c')]||!utils[_0x8f92('0x5d')](_0x106213[_0x8f92('0x54')]['channel'])){throw new db[(_0x8f92('0x5e'))][(_0x8f92('0x5f'))]('Unknown\x20channel');}return _0x39d761[_0x8f92('0x67')+_[_0x8f92('0x61')](_0x106213['body']['channel'][_0x8f92('0x62')]())+_0x8f92('0x64')](_0x106213[_0x8f92('0x54')][_0x8f92('0x68')]);}return null;})[_0x8f92('0x2b')](handleEntityNotFound(_0x2b4132,null))[_0x8f92('0x2b')](respondWithStatusCode(_0x2b4132,null))['catch'](handleError(_0x2b4132,null));};exports[_0x8f92('0x69')]=function(_0xde781e,_0x420467,_0x2301a1){return db['Team'][_0x8f92('0x66')]({'where':{'id':_0xde781e[_0x8f92('0x4d')]['id']}})['then'](function(_0x2f78f8){if(_0x2f78f8){if(!_0xde781e[_0x8f92('0x3b')]['channel']||!utils[_0x8f92('0x5d')](_0xde781e[_0x8f92('0x3b')][_0x8f92('0x5c')])){throw new db[(_0x8f92('0x5e'))][(_0x8f92('0x5f'))](_0x8f92('0x60'));}return _0x2f78f8['remove'+_['capitalize'](_0xde781e['query'][_0x8f92('0x5c')][_0x8f92('0x62')]())+_0x8f92('0x64')](_0xde781e[_0x8f92('0x3b')][_0x8f92('0x68')]);}return null;})['then'](handleEntityNotFound(_0x420467,null))[_0x8f92('0x2b')](respondWithStatusCode(_0x420467,null))[_0x8f92('0x59')](handleError(_0x420467,null));};exports[_0x8f92('0x6a')]=function(_0x5f2a82,_0x336902,_0x8ea1ed){return db[_0x8f92('0x35')]['find']({'where':{'id':_0x5f2a82[_0x8f92('0x4d')]['id']}})['then'](handleEntityNotFound(_0x336902,null))[_0x8f92('0x2b')](function(_0x22a589){if(_0x22a589){var _0x12fad5=[_0x8f92('0x6b'),_0x8f92('0x6c'),'Mail',_0x8f92('0x6d'),'Fax',_0x8f92('0x6e'),'Whatsapp'];return BPromise['each'](_0x12fad5,function(_0x5e0703){return _0x22a589[_0x8f92('0x2c')+_0x5e0703+_0x8f92('0x64')]({'attributes':['id',_0x8f92('0x31')]})[_0x8f92('0x2b')](function(_0x48e648){return BPromise['each'](_0x48e648,function(_0x49425c){return _0x49425c[_0x8f92('0x6a')](_0x5f2a82[_0x8f92('0x54')]['ids'])[_0x8f92('0x2b')](function(){if(_0x5e0703===_0x8f92('0x6b')){return db[_0x8f92('0x6f')][_0x8f92('0x4a')]({'where':{'id':_0x5f2a82['body'][_0x8f92('0x68')]},'attributes':['id',_0x8f92('0x31'),'online','voicePause',_0x8f92('0x70')],'raw':!![]})['then'](function(_0x2fbe52){return BPromise['each'](_[_0x8f92('0x46')](_0x2fbe52,{'online':0x1}),function(_0x4704c3){return db['UserVoiceQueueRt'][_0x8f92('0x71')]({'membername':_0x4704c3[_0x8f92('0x31')],'UserId':_0x4704c3['id'],'queue_name':_0x49425c[_0x8f92('0x31')],'VoiceQueueId':_0x49425c['id'],'interface':_['isNil'](_0x4704c3['interface'])?util[_0x8f92('0x72')](_0x8f92('0x73'),_0x4704c3[_0x8f92('0x31')]):_0x4704c3['interface'],'paused':_0x4704c3[_0x8f92('0x74')]||![],'penalty':0x0});});});}});});})[_0x8f92('0x2b')](function(){return _0x22a589;});})[_0x8f92('0x2b')](function(){return _0x22a589;});}})[_0x8f92('0x2b')](function(_0x58263b){if(_0x58263b){return _0x58263b[_0x8f92('0x6a')](_0x5f2a82[_0x8f92('0x54')]['ids'],_['omit'](_0x5f2a82[_0x8f92('0x54')],[_0x8f92('0x68'),'id'])||{})[_0x8f92('0x75')](function(_0x565dfc){for(var _0x2a2540=0x0;_0x2a2540<_0x5f2a82[_0x8f92('0x54')][_0x8f92('0x68')]['length'];_0x2a2540+=0x1){socket[_0x8f92('0x76')](_0x8f92('0x77'),{'UserId':_0x5f2a82[_0x8f92('0x54')]['ids'][_0x2a2540],'TeamId':_0x5f2a82[_0x8f92('0x4d')]['id']});}return _0x565dfc;});}})[_0x8f92('0x2b')](respondWithResult(_0x336902,null))[_0x8f92('0x59')](handleError(_0x336902,null));};exports[_0x8f92('0x78')]=function(_0x587b3b,_0xc963ec,_0xb6dd22){return db[_0x8f92('0x35')][_0x8f92('0x52')]({'where':{'id':_0x587b3b[_0x8f92('0x4d')]['id']}})[_0x8f92('0x2b')](handleEntityNotFound(_0xc963ec,null))['then'](function(_0x318491){if(_0x318491){return BPromise['each']([_0x8f92('0x79'),_0x8f92('0x7a'),_0x8f92('0x7b'),'sms','fax','openchannel',_0x8f92('0x7c')],function(_0x39841a){return _0x318491['get'+_['capitalize'](_0x39841a)+_0x8f92('0x64')]({'attributes':['id',_0x8f92('0x31')]})[_0x8f92('0x2b')](function(_0x2bb0c7){return BPromise[_0x8f92('0x7d')](_0x2bb0c7,function(_0x56dc87){return _0x56dc87[_0x8f92('0x78')](_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')])[_0x8f92('0x2b')](function(){if(_0x39841a==='voice'){return db[_0x8f92('0x7e')]['destroy']({'where':{'VoiceQueueId':_0x56dc87['id'],'UserId':_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')]}});}});});})[_0x8f92('0x2b')](function(){return _0x318491;});})[_0x8f92('0x2b')](function(){return _0x318491;});}})[_0x8f92('0x2b')](function(_0x478be4){if(_0x478be4){return _0x478be4[_0x8f92('0x78')](_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')])[_0x8f92('0x2b')](function(){if(_[_0x8f92('0x7f')](_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')])){for(var _0x84328=0x0;_0x84328<_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')][_0x8f92('0x3f')];_0x84328+=0x1){socket[_0x8f92('0x76')](_0x8f92('0x80'),{'UserId':Number(_0x587b3b['query'][_0x8f92('0x68')][_0x84328]),'TeamId':Number(_0x587b3b[_0x8f92('0x4d')]['id'])});}}else{socket[_0x8f92('0x76')](_0x8f92('0x80'),{'UserId':Number(_0x587b3b['query'][_0x8f92('0x68')]),'TeamId':Number(_0x587b3b['params']['id'])});}});}})['then'](respondWithStatusCode(_0xc963ec,null))[_0x8f92('0x59')](handleError(_0xc963ec,null));};exports[_0x8f92('0x81')]=function(_0x38e8cd,_0x4d0600,_0x3cd5f1){var _0x5bf70d={};var _0x26fcbc={};var _0x53dab6;var _0x3095f6;return db[_0x8f92('0x35')]['findOne']({'where':{'id':_0x38e8cd[_0x8f92('0x4d')]['id']}})[_0x8f92('0x2b')](handleEntityNotFound(_0x4d0600,null))[_0x8f92('0x2b')](function(_0x43a939){if(_0x43a939){_0x53dab6=_0x43a939;_0x26fcbc[_0x8f92('0x3a')]=_['keys'](db[_0x8f92('0x6f')][_0x8f92('0x36')]);_0x26fcbc[_0x8f92('0x3b')]=_[_0x8f92('0x4e')](_0x38e8cd[_0x8f92('0x3b')]);_0x26fcbc['filters']=_['intersection'](_0x26fcbc[_0x8f92('0x3a')],_0x26fcbc[_0x8f92('0x3b')]);_0x5bf70d[_0x8f92('0x3e')]=_[_0x8f92('0x4f')](_0x26fcbc[_0x8f92('0x3a')],qs[_0x8f92('0x3d')](_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x3d')]));_0x5bf70d[_0x8f92('0x3e')]=_0x5bf70d[_0x8f92('0x3e')][_0x8f92('0x3f')]?_0x5bf70d[_0x8f92('0x3e')]:_0x26fcbc[_0x8f92('0x3a')];_0x5bf70d[_0x8f92('0x42')]=qs[_0x8f92('0x43')](_0x38e8cd['query']['sort']);_0x5bf70d['where']=qs['filters'](_['pick'](_0x38e8cd[_0x8f92('0x3b')],_0x26fcbc[_0x8f92('0x3c')]));if(_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x46')]){_0x5bf70d[_0x8f92('0x44')]=_[_0x8f92('0x51')](_0x5bf70d[_0x8f92('0x44')],{'$or':_[_0x8f92('0x34')](_0x5bf70d['attributes'],function(_0x1d9869){var _0x2f864f={};_0x2f864f[_0x1d9869]={'$like':'%'+_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x46')]+'%'};return _0x2f864f;})});}_0x5bf70d=_[_0x8f92('0x51')]({},_0x5bf70d,_0x38e8cd[_0x8f92('0x48')]);return _0x53dab6['getAgents'](_0x5bf70d);}})[_0x8f92('0x2b')](function(_0x4ab081){if(_0x4ab081){_0x3095f6=_0x4ab081[_0x8f92('0x3f')];if(!_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x82')]('nolimit')){_0x5bf70d[_0x8f92('0x41')]=qs[_0x8f92('0x41')](_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x41')]);_0x5bf70d[_0x8f92('0x25')]=qs['offset'](_0x38e8cd[_0x8f92('0x3b')]['offset']);}return _0x53dab6[_0x8f92('0x81')](_0x5bf70d);}})['then'](function(_0x56032d){if(_0x56032d){return _0x56032d?{'count':_0x3095f6,'rows':_0x56032d}:null;}})[_0x8f92('0x2b')](respondWithResult(_0x4d0600,null))[_0x8f92('0x59')](handleError(_0x4d0600,null));};
\ No newline at end of file
+var _0x590c=['Unknown\x20channel','capitalize','toLowerCase','Queue','get','Queues','addQueues','ValidationError','ids','remove','addAgents','isArray','Voice','Mail','Fax','Openchannel','Whatsapp','QueueId','TeamVoiceQueue','penalty','User','Queue:save','online','voicePause','upsert','format','SIP/%s','interface','all','spread','removeAgents','Queue:remove','UserVoiceQueueRt','getAgents','order','nolimit','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./team.socket','register','sendStatus','status','end','offset','limit','Content-Range','json','reject','error','stack','name','send','map','fieldName','type','key','query','intersection','model','attributes','fields','length','hasOwnProperty','sort','where','filters','pick','filter','VIRTUAL','merge','Team','count','then','includeAll','include','findAll','catch','show','keys','rawAttributes','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Teams','UserProfileSection','userProfileId','UserProfileResource','destroy','params','sequelize','transaction','SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20','Sequelize','QueryTypes','UserId','SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20','SELECT','VoiceQueueId','UserVoiceQueue','SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20','MailQueueId','UserMailQueue','SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20','SmsQueueId','UserSmsQueue','UserChatQueue','SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20','FaxQueueId','UserFaxQueue','OpenchannelQueueId','SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','WhatsappQueueId','UserWhatsappQueue','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','getQueues','findOne','channel','isValidChannel'];(function(_0x5520c7,_0xbee449){var _0x3b0590=function(_0x1bb4f9){while(--_0x1bb4f9){_0x5520c7['push'](_0x5520c7['shift']());}};_0x3b0590(++_0xbee449);}(_0x590c,0x150));var _0xc590=function(_0x5be571,_0x46766a){_0x5be571=_0x5be571-0x0;var _0x4ac06c=_0x590c[_0x5be571];return _0x4ac06c;};'use strict';var emlformat=require(_0xc590('0x0'));var rimraf=require(_0xc590('0x1'));var zipdir=require(_0xc590('0x2'));var jsonpatch=require(_0xc590('0x3'));var rp=require(_0xc590('0x4'));var moment=require(_0xc590('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xc590('0x6'));var util=require(_0xc590('0x7'));var path=require(_0xc590('0x8'));var sox=require(_0xc590('0x9'));var csv=require(_0xc590('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xc590('0xb'));var _=require(_0xc590('0xc'));var squel=require(_0xc590('0xd'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xc590('0xe'));var toCsv=require(_0xc590('0xa'));var querystring=require(_0xc590('0xf'));var Papa=require(_0xc590('0x10'));var Redis=require('ioredis');var authService=require(_0xc590('0x11'));var qs=require(_0xc590('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xc590('0x13'))(_0xc590('0x14'));var utils=require(_0xc590('0x15'));var config=require(_0xc590('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xc590('0x17'))['db'];config[_0xc590('0x18')]=_[_0xc590('0x19')](config[_0xc590('0x18')],{'host':_0xc590('0x1a'),'port':0x18eb});var socket=require(_0xc590('0x1b'))(new Redis(config[_0xc590('0x18')]));require(_0xc590('0x1c'))[_0xc590('0x1d')](socket);function respondWithStatusCode(_0x19965d,_0x59f4e7){_0x59f4e7=_0x59f4e7||0xcc;return function(_0x1fa9ca){if(_0x1fa9ca){return _0x19965d[_0xc590('0x1e')](_0x59f4e7);}return _0x19965d[_0xc590('0x1f')](_0x59f4e7)[_0xc590('0x20')]();};}function respondWithResult(_0x46544a,_0x336388){_0x336388=_0x336388||0xc8;return function(_0x50330e){if(_0x50330e){return _0x46544a['status'](_0x336388)['json'](_0x50330e);}};}function respondWithFilteredResult(_0x1d62c1,_0x3d0e04){return function(_0x7a779d){if(_0x7a779d){var _0x31daed=typeof _0x3d0e04['offset']==='undefined'&&typeof _0x3d0e04['limit']==='undefined';var _0x2381a3=_0x7a779d['count'];var _0x361d33=_0x31daed?0x0:_0x3d0e04[_0xc590('0x21')];var _0x3ce62c=_0x31daed?_0x7a779d['count']:_0x3d0e04[_0xc590('0x21')]+_0x3d0e04[_0xc590('0x22')];var _0x5516ae;if(_0x3ce62c>=_0x2381a3){_0x3ce62c=_0x2381a3;_0x5516ae=0xc8;}else{_0x5516ae=0xce;}_0x1d62c1[_0xc590('0x1f')](_0x5516ae);return _0x1d62c1['set'](_0xc590('0x23'),_0x361d33+'-'+_0x3ce62c+'/'+_0x2381a3)[_0xc590('0x24')](_0x7a779d);}return null;};}function patchUpdates(_0x5c5919){return function(_0x12c5eb){try{jsonpatch['apply'](_0x12c5eb,_0x5c5919,!![]);}catch(_0x571d5b){return BPromise[_0xc590('0x25')](_0x571d5b);}return _0x12c5eb['save']();};}function saveUpdates(_0x3fa9e8,_0x8a1124){return function(_0x1060b7){if(_0x1060b7){return _0x1060b7['update'](_0x3fa9e8)['then'](function(_0x1e3c2a){return _0x1e3c2a;});}return null;};}function handleEntityNotFound(_0x50ba8f,_0x391f42){return function(_0x27981c){if(!_0x27981c){_0x50ba8f['sendStatus'](0x194);}return _0x27981c;};}function handleError(_0x5720ee,_0x4bf73f){_0x4bf73f=_0x4bf73f||0x1f4;return function(_0x281851){logger[_0xc590('0x26')](_0x281851[_0xc590('0x27')]);if(_0x281851[_0xc590('0x28')]){delete _0x281851[_0xc590('0x28')];}_0x5720ee[_0xc590('0x1f')](_0x4bf73f)[_0xc590('0x29')](_0x281851);};}exports['index']=function(_0x557aea,_0x566f77){var _0x51dacf={},_0x7fc26c={},_0x2aee4c={'count':0x0,'rows':[]};var _0x224180=_[_0xc590('0x2a')](db['Team']['rawAttributes'],function(_0x4704ad){return{'name':_0x4704ad[_0xc590('0x2b')],'type':_0x4704ad[_0xc590('0x2c')][_0xc590('0x2d')]};});_0x7fc26c['model']=_[_0xc590('0x2a')](_0x224180,_0xc590('0x28'));_0x7fc26c[_0xc590('0x2e')]=_['keys'](_0x557aea[_0xc590('0x2e')]);_0x7fc26c['filters']=_[_0xc590('0x2f')](_0x7fc26c[_0xc590('0x30')],_0x7fc26c['query']);_0x51dacf[_0xc590('0x31')]=_[_0xc590('0x2f')](_0x7fc26c[_0xc590('0x30')],qs[_0xc590('0x32')](_0x557aea[_0xc590('0x2e')][_0xc590('0x32')]));_0x51dacf[_0xc590('0x31')]=_0x51dacf[_0xc590('0x31')][_0xc590('0x33')]?_0x51dacf['attributes']:_0x7fc26c[_0xc590('0x30')];if(!_0x557aea[_0xc590('0x2e')][_0xc590('0x34')]('nolimit')){_0x51dacf['limit']=qs[_0xc590('0x22')](_0x557aea['query'][_0xc590('0x22')]);_0x51dacf[_0xc590('0x21')]=qs['offset'](_0x557aea['query'][_0xc590('0x21')]);}_0x51dacf['order']=qs['sort'](_0x557aea['query'][_0xc590('0x35')]);_0x51dacf[_0xc590('0x36')]=qs[_0xc590('0x37')](_[_0xc590('0x38')](_0x557aea[_0xc590('0x2e')],_0x7fc26c[_0xc590('0x37')]),_0x224180);if(_0x557aea[_0xc590('0x2e')][_0xc590('0x39')]){_0x51dacf['where']=_['merge'](_0x51dacf[_0xc590('0x36')],{'$or':_[_0xc590('0x2a')](_0x224180,function(_0x31cdbd){if(_0x31cdbd[_0xc590('0x2c')]!==_0xc590('0x3a')){var _0x66ac9b={};_0x66ac9b[_0x31cdbd[_0xc590('0x28')]]={'$like':'%'+_0x557aea['query']['filter']+'%'};return _0x66ac9b;}})});}_0x51dacf=_[_0xc590('0x3b')]({},_0x51dacf,_0x557aea['options']);var _0x3c6803={'where':_0x51dacf[_0xc590('0x36')]};return db[_0xc590('0x3c')][_0xc590('0x3d')](_0x3c6803)[_0xc590('0x3e')](function(_0x5f37c3){_0x2aee4c[_0xc590('0x3d')]=_0x5f37c3;if(_0x557aea[_0xc590('0x2e')][_0xc590('0x3f')]){_0x51dacf[_0xc590('0x40')]=[{'all':!![]}];}return db[_0xc590('0x3c')][_0xc590('0x41')](_0x51dacf);})[_0xc590('0x3e')](function(_0x111014){_0x2aee4c['rows']=_0x111014;return _0x2aee4c;})[_0xc590('0x3e')](respondWithFilteredResult(_0x566f77,_0x51dacf))[_0xc590('0x42')](handleError(_0x566f77,null));};exports[_0xc590('0x43')]=function(_0x6c54b3,_0x79fa01){var _0x534389={'raw':![],'where':{'id':_0x6c54b3['params']['id']}},_0x43d32c={};_0x43d32c[_0xc590('0x30')]=_[_0xc590('0x44')](db[_0xc590('0x3c')][_0xc590('0x45')]);_0x43d32c[_0xc590('0x2e')]=_[_0xc590('0x44')](_0x6c54b3[_0xc590('0x2e')]);_0x43d32c['filters']=_['intersection'](_0x43d32c[_0xc590('0x30')],_0x43d32c[_0xc590('0x2e')]);_0x534389[_0xc590('0x31')]=_['intersection'](_0x43d32c['model'],qs['fields'](_0x6c54b3[_0xc590('0x2e')][_0xc590('0x32')]));_0x534389[_0xc590('0x31')]=_0x534389[_0xc590('0x31')]['length']?_0x534389['attributes']:_0x43d32c[_0xc590('0x30')];if(_0x6c54b3[_0xc590('0x2e')][_0xc590('0x3f')]){_0x534389[_0xc590('0x40')]=[{'all':!![]}];}_0x534389=_[_0xc590('0x3b')]({},_0x534389,_0x6c54b3[_0xc590('0x46')]);return db[_0xc590('0x3c')][_0xc590('0x47')](_0x534389)['then'](handleEntityNotFound(_0x79fa01,null))[_0xc590('0x3e')](respondWithResult(_0x79fa01,null))[_0xc590('0x42')](handleError(_0x79fa01,null));};exports['create']=function(_0x4926f7,_0x46d592){return db[_0xc590('0x3c')][_0xc590('0x48')](_0x4926f7[_0xc590('0x49')],{})['then'](function(_0x6dd652){var _0x19c644=_0x4926f7[_0xc590('0x4a')]['get']({'plain':!![]});if(!_0x19c644)throw new Error(_0xc590('0x4b'));if(_0x19c644[_0xc590('0x4c')]===_0xc590('0x4a')){var _0x46a9e5=_0x6dd652['get']({'plain':!![]});var _0x26eddb=_0xc590('0x4d');return db[_0xc590('0x4e')][_0xc590('0x47')]({'where':{'name':_0x26eddb,'userProfileId':_0x19c644[_0xc590('0x4f')]},'raw':!![]})['then'](function(_0x105868){if(_0x105868&&_0x105868['autoAssociation']===0x0){return db[_0xc590('0x50')]['create']({'name':_0x46a9e5[_0xc590('0x28')],'resourceId':_0x46a9e5['id'],'type':_0x105868[_0xc590('0x28')],'sectionId':_0x105868['id']},{})[_0xc590('0x3e')](function(){return _0x6dd652;});}else{return _0x6dd652;}})[_0xc590('0x42')](function(_0x4364bc){logger[_0xc590('0x26')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4364bc);throw _0x4364bc;});}return _0x6dd652;})[_0xc590('0x3e')](respondWithResult(_0x46d592,0xc9))['catch'](handleError(_0x46d592,null));};exports['update']=function(_0x220e3f,_0x2a11ae){if(_0x220e3f[_0xc590('0x49')]['id']){delete _0x220e3f['body']['id'];}return db[_0xc590('0x3c')][_0xc590('0x47')]({'where':{'id':_0x220e3f['params']['id']}})['then'](handleEntityNotFound(_0x2a11ae,null))['then'](saveUpdates(_0x220e3f[_0xc590('0x49')],null))[_0xc590('0x3e')](respondWithResult(_0x2a11ae,null))[_0xc590('0x42')](handleError(_0x2a11ae,null));};exports[_0xc590('0x51')]=function(_0x51713f,_0x444c87){var _0x38429d=_0x51713f[_0xc590('0x52')]['id'];var _0x1b6370=[];return db[_0xc590('0x53')][_0xc590('0x54')](function(_0x40be1f){var _0x4a0577=_0xc590('0x55')+_0x38429d;return db[_0xc590('0x53')]['query'](_0x4a0577,{'type':db[_0xc590('0x56')][_0xc590('0x57')]['SELECT'],'raw':!![],'transaction':_0x40be1f})[_0xc590('0x3e')](function(_0x5476d0){_0x1b6370=_[_0xc590('0x2a')](_0x5476d0,function(_0x22d441){return Number(_0x22d441[_0xc590('0x58')]);});})[_0xc590('0x3e')](function(){var _0x5355dc=_0xc590('0x59')+_0x38429d;return db[_0xc590('0x53')][_0xc590('0x2e')](_0x5355dc,{'type':db[_0xc590('0x56')][_0xc590('0x57')][_0xc590('0x5a')],'raw':!![],'transaction':_0x40be1f});})[_0xc590('0x3e')](function(_0x19943d){var _0x51cea7=_[_0xc590('0x2a')](_0x19943d,function(_0xb0a21b){return Number(_0xb0a21b[_0xc590('0x5b')]);});return db[_0xc590('0x5c')][_0xc590('0x51')]({'where':{'UserId':{'$in':_0x1b6370},'VoiceQueueId':{'$in':_0x51cea7}},'transaction':_0x40be1f});})['then'](function(){var _0x13e4a5=_0xc590('0x5d')+_0x38429d;return db[_0xc590('0x53')][_0xc590('0x2e')](_0x13e4a5,{'type':db[_0xc590('0x56')][_0xc590('0x57')][_0xc590('0x5a')],'raw':!![],'transaction':_0x40be1f});})[_0xc590('0x3e')](function(_0x25ccf1){var _0x978057=_[_0xc590('0x2a')](_0x25ccf1,function(_0x12bb5e){return Number(_0x12bb5e[_0xc590('0x5e')]);});return db[_0xc590('0x5f')][_0xc590('0x51')]({'where':{'UserId':{'$in':_0x1b6370},'MailQueueId':{'$in':_0x978057}},'transaction':_0x40be1f});})[_0xc590('0x3e')](function(){var _0x582097=_0xc590('0x60')+_0x38429d;return db[_0xc590('0x53')][_0xc590('0x2e')](_0x582097,{'type':db[_0xc590('0x56')][_0xc590('0x57')][_0xc590('0x5a')],'raw':!![],'transaction':_0x40be1f});})['then'](function(_0xe4369d){var _0x4ca80d=_[_0xc590('0x2a')](_0xe4369d,function(_0x4144d7){return Number(_0x4144d7[_0xc590('0x61')]);});return db[_0xc590('0x62')][_0xc590('0x51')]({'where':{'UserId':{'$in':_0x1b6370},'SmsQueueId':{'$in':_0x4ca80d}},'transaction':_0x40be1f});})[_0xc590('0x3e')](function(){var _0x3c21af='SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20'+_0x38429d;return db['sequelize']['query'](_0x3c21af,{'type':db['Sequelize'][_0xc590('0x57')][_0xc590('0x5a')],'raw':!![],'transaction':_0x40be1f});})[_0xc590('0x3e')](function(_0x1ad725){var _0x31f7c8=_[_0xc590('0x2a')](_0x1ad725,function(_0x439759){return Number(_0x439759['ChatQueueId']);});return db[_0xc590('0x63')][_0xc590('0x51')]({'where':{'UserId':{'$in':_0x1b6370},'ChatQueueId':{'$in':_0x31f7c8}},'transaction':_0x40be1f});})[_0xc590('0x3e')](function(){var _0x46fc91=_0xc590('0x64')+_0x38429d;return db[_0xc590('0x53')][_0xc590('0x2e')](_0x46fc91,{'type':db[_0xc590('0x56')]['QueryTypes'][_0xc590('0x5a')],'raw':!![],'transaction':_0x40be1f});})[_0xc590('0x3e')](function(_0x5d27c4){var _0x506dde=_[_0xc590('0x2a')](_0x5d27c4,function(_0x15868b){return Number(_0x15868b[_0xc590('0x65')]);});return db[_0xc590('0x66')][_0xc590('0x51')]({'where':{'UserId':{'$in':_0x1b6370},'FaxQueueId':{'$in':_0x506dde}},'transaction':_0x40be1f});})['then'](function(){var _0x292aae='SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20'+_0x38429d;return db[_0xc590('0x53')][_0xc590('0x2e')](_0x292aae,{'type':db['Sequelize'][_0xc590('0x57')]['SELECT'],'raw':!![],'transaction':_0x40be1f});})[_0xc590('0x3e')](function(_0x5f26b0){var _0x5bce5a=_[_0xc590('0x2a')](_0x5f26b0,function(_0x336f65){return Number(_0x336f65[_0xc590('0x67')]);});return db['UserOpenchannelQueue'][_0xc590('0x51')]({'where':{'UserId':{'$in':_0x1b6370},'OpenchannelQueueId':{'$in':_0x5bce5a}},'transaction':_0x40be1f});})[_0xc590('0x3e')](function(){var _0x1b4083=_0xc590('0x68')+_0x38429d;return db['sequelize'][_0xc590('0x2e')](_0x1b4083,{'type':db['Sequelize'][_0xc590('0x57')][_0xc590('0x5a')],'raw':!![],'transaction':_0x40be1f});})['then'](function(_0x22f2e0){var _0x2f0838=_[_0xc590('0x2a')](_0x22f2e0,function(_0x520e9b){return Number(_0x520e9b[_0xc590('0x69')]);});return db[_0xc590('0x6a')]['destroy']({'where':{'UserId':{'$in':_0x1b6370},'WhatsappQueueId':{'$in':_0x2f0838}},'transaction':_0x40be1f});})[_0xc590('0x3e')](function(){return db[_0xc590('0x6b')][_0xc590('0x47')]({'where':{'TeamId':_0x38429d}});})['then'](function(_0x4845ce){if(_0x4845ce===null){return;}return db[_0xc590('0x6c')][_0xc590('0x51')]({'where':{'UserId':{'$in':_0x1b6370},'VoicePrefixId':_0x4845ce[_0xc590('0x6d')]},'transaction':_0x40be1f});})[_0xc590('0x3e')](function(){return db[_0xc590('0x3c')][_0xc590('0x51')]({'where':{'id':_0x38429d},'cascade':!![],'transaction':_0x40be1f});})[_0xc590('0x3e')](function(_0x2e0b96){if(_0x2e0b96===0x0){_0x444c87['sendStatus'](0x194);}else{return db['UserProfileResource'][_0xc590('0x51')]({'where':{'type':'Teams','resourceId':_0x38429d},'cascade':!![],'transaction':_0x40be1f})[_0xc590('0x3e')](function(){_0x444c87['status'](0xcc)['end']();});}})[_0xc590('0x42')](function(_0x207df0){_0x444c87[_0xc590('0x1f')](0x1f4)['send'](_0x207df0);});});};exports[_0xc590('0x6e')]=function(_0x56b2fb,_0x48a20a,_0x207560){return db[_0xc590('0x3c')][_0xc590('0x6f')]({'where':{'id':_0x56b2fb[_0xc590('0x52')]['id']}})['then'](handleEntityNotFound(_0x48a20a,null))[_0xc590('0x3e')](function(_0x1d850e){if(!_0x56b2fb['query'][_0xc590('0x70')]||!utils[_0xc590('0x71')](_0x56b2fb[_0xc590('0x2e')][_0xc590('0x70')])){throw new db['Sequelize']['ValidationError'](_0xc590('0x72'));}var _0x5af2e8={};var _0x49860d={};_0x49860d[_0xc590('0x30')]=_[_0xc590('0x44')](db[_[_0xc590('0x73')](_0x56b2fb['query'][_0xc590('0x70')][_0xc590('0x74')]())+_0xc590('0x75')][_0xc590('0x45')]);_0x49860d[_0xc590('0x2e')]=_[_0xc590('0x44')](_0x56b2fb[_0xc590('0x2e')]);_0x49860d[_0xc590('0x37')]=_[_0xc590('0x2f')](_0x49860d[_0xc590('0x30')],_0x49860d['query']);_0x5af2e8[_0xc590('0x31')]=_[_0xc590('0x2f')](_0x49860d['model'],qs[_0xc590('0x32')](_0x56b2fb['query']['fields']));_0x5af2e8[_0xc590('0x31')]=_0x5af2e8[_0xc590('0x31')][_0xc590('0x33')]?_0x5af2e8[_0xc590('0x31')]:_0x49860d[_0xc590('0x30')];_0x5af2e8['limit']=qs[_0xc590('0x22')](_0x56b2fb[_0xc590('0x2e')][_0xc590('0x22')]);_0x5af2e8['offset']=qs[_0xc590('0x21')](_0x56b2fb['query']['offset']);_0x5af2e8['order']=qs[_0xc590('0x35')](_0x56b2fb[_0xc590('0x2e')][_0xc590('0x35')]);_0x5af2e8[_0xc590('0x36')]=qs['filters'](_[_0xc590('0x38')](_0x56b2fb[_0xc590('0x2e')],_0x49860d[_0xc590('0x37')]));_0x5af2e8=_['merge']({},_0x5af2e8,_0x56b2fb[_0xc590('0x46')]);return _0x1d850e[_0xc590('0x76')+_[_0xc590('0x73')](_0x56b2fb[_0xc590('0x2e')][_0xc590('0x70')][_0xc590('0x74')]())+_0xc590('0x77')](_0x5af2e8);})[_0xc590('0x3e')](respondWithResult(_0x48a20a,null))[_0xc590('0x42')](handleError(_0x48a20a,null));};exports[_0xc590('0x78')]=function(_0x2f76e3,_0xf52da4,_0x34a7fb){return db['Team'][_0xc590('0x6f')]({'where':{'id':_0x2f76e3[_0xc590('0x52')]['id']}})['then'](function(_0x2d1041){if(_0x2d1041){if(!_0x2f76e3[_0xc590('0x49')]['channel']||!utils[_0xc590('0x71')](_0x2f76e3[_0xc590('0x49')][_0xc590('0x70')])){throw new db[(_0xc590('0x56'))][(_0xc590('0x79'))](_0xc590('0x72'));}return _0x2d1041['add'+_[_0xc590('0x73')](_0x2f76e3[_0xc590('0x49')][_0xc590('0x70')][_0xc590('0x74')]())+'Queues'](_0x2f76e3[_0xc590('0x49')][_0xc590('0x7a')]);}return null;})[_0xc590('0x3e')](handleEntityNotFound(_0xf52da4,null))['then'](respondWithStatusCode(_0xf52da4,null))[_0xc590('0x42')](handleError(_0xf52da4,null));};exports['removeQueues']=function(_0x5bd4e1,_0x5c7a99,_0x54a72a){return db[_0xc590('0x3c')]['findOne']({'where':{'id':_0x5bd4e1[_0xc590('0x52')]['id']}})[_0xc590('0x3e')](function(_0x3bf800){if(_0x3bf800){if(!_0x5bd4e1['query'][_0xc590('0x70')]||!utils[_0xc590('0x71')](_0x5bd4e1[_0xc590('0x2e')][_0xc590('0x70')])){throw new db[(_0xc590('0x56'))][(_0xc590('0x79'))]('Unknown\x20channel');}return _0x3bf800[_0xc590('0x7b')+_['capitalize'](_0x5bd4e1[_0xc590('0x2e')]['channel']['toLowerCase']())+_0xc590('0x77')](_0x5bd4e1[_0xc590('0x2e')][_0xc590('0x7a')]);}return null;})['then'](handleEntityNotFound(_0x5c7a99,null))[_0xc590('0x3e')](respondWithStatusCode(_0x5c7a99,null))['catch'](handleError(_0x5c7a99,null));};exports[_0xc590('0x7c')]=function(_0x381355,_0x4d1457){var _0x18ff89=_[_0xc590('0x7d')](_0x381355[_0xc590('0x49')][_0xc590('0x7a')])?_0x381355['body'][_0xc590('0x7a')]:[_0x381355[_0xc590('0x49')]['ids']];var _0x80a9af=_0x381355[_0xc590('0x52')]['id'];return db[_0xc590('0x3c')][_0xc590('0x47')]({'where':{'id':_0x80a9af}})[_0xc590('0x3e')](handleEntityNotFound(_0x4d1457,null))['then'](function(_0x3d86d3){if(_0x3d86d3){var _0x55de1c=[_0xc590('0x7e'),'Chat',_0xc590('0x7f'),'Sms',_0xc590('0x80'),_0xc590('0x81'),_0xc590('0x82')];return db['sequelize'][_0xc590('0x54')](function(_0xa19e99){var _0x3735e5=_['map'](_0x55de1c,function(_0x498143){var _0x9669c8={'attributes':['id',_0xc590('0x28')]};if(_0x498143===_0xc590('0x7e')){_0x9669c8['through']={'attributes':['penalty']};}return _0x3d86d3[_0xc590('0x76')+_0x498143+_0xc590('0x77')](_0x9669c8)[_0xc590('0x3e')](function(_0x245d91){var _0x2b42ec=_[_0xc590('0x2a')](_0x245d91,function(_0x40ade6){var _0x4de604=_[_0xc590('0x2a')](_0x18ff89,function(_0x2611b1){var _0x2103b5={'where':{'UserId':_0x2611b1,[_0x498143+_0xc590('0x83')]:_0x40ade6['id']},'transaction':_0xa19e99};if(_0x498143===_0xc590('0x7e')){_0x2103b5[_0xc590('0x19')]={'penalty':_0x40ade6[_0xc590('0x84')][_0xc590('0x85')]};}return db[_0xc590('0x86')+_0x498143+_0xc590('0x75')]['findOrCreate'](_0x2103b5)[_0xc590('0x3e')](function(){socket['emit'](_0xc590('0x4a')+_0x498143+_0xc590('0x87'),{'UserId':_0x2611b1,[_0x498143+'QueueId']:_0x40ade6['id']});if(_0x498143!==_0xc590('0x7e')){return;}return db['User'][_0xc590('0x41')]({'where':{'id':_0x18ff89,'online':0x1},'attributes':['id','name',_0xc590('0x88'),_0xc590('0x89'),'interface'],'raw':!![]})[_0xc590('0x3e')](function(_0x3abcae){var _0x4ed753=_[_0xc590('0x2a')](_0x3abcae,function(_0x83538d){return db['UserVoiceQueueRt'][_0xc590('0x8a')]({'membername':_0x83538d[_0xc590('0x28')],'UserId':_0x83538d['id'],'queue_name':_0x40ade6[_0xc590('0x28')],'VoiceQueueId':_0x40ade6['id'],'interface':_['isNil'](_0x83538d['interface'])?util[_0xc590('0x8b')](_0xc590('0x8c'),_0x83538d['name']):_0x83538d[_0xc590('0x8d')],'paused':_0x83538d[_0xc590('0x89')]||![],'penalty':_0x40ade6[_0xc590('0x84')][_0xc590('0x85')]},{'transaction':_0xa19e99});});return Promise[_0xc590('0x8e')](_0x4ed753);});});});return Promise['all'](_0x4de604);});return Promise[_0xc590('0x8e')](_0x2b42ec);})['then'](function(){return db[_0xc590('0x6b')][_0xc590('0x6f')]({'where':{'teamId':_0x80a9af}})[_0xc590('0x3e')](function(_0x494aeb){if(_0x494aeb){var _0xfd56d3=_[_0xc590('0x2a')](_0x18ff89,function(_0x4755df){db['UserVoicePrefix'][_0xc590('0x8a')]({'UserId':_0x4755df,'VoicePrefixId':_0x494aeb[_0xc590('0x6d')]});});return Promise[_0xc590('0x8e')](_0xfd56d3);}});});});return Promise[_0xc590('0x8e')](_0x3735e5)[_0xc590('0x3e')](function(){return _0x3d86d3[_0xc590('0x7c')](_0x18ff89,{'transaction':_0xa19e99})[_0xc590('0x8f')](function(_0x2d71f1){return _0x2d71f1;});});});}})[_0xc590('0x3e')](respondWithResult(_0x4d1457,null))[_0xc590('0x42')](handleError(_0x4d1457,null));};exports[_0xc590('0x90')]=function(_0x811163,_0x112e23){var _0x3129a4=_['isArray'](_0x811163[_0xc590('0x2e')][_0xc590('0x7a')])?_0x811163['query'][_0xc590('0x7a')]:[_0x811163[_0xc590('0x2e')]['ids']];var _0x395cf2=_0x811163[_0xc590('0x52')]['id'];return db[_0xc590('0x3c')][_0xc590('0x47')]({'where':{'id':_0x395cf2}})['then'](handleEntityNotFound(_0x112e23,null))['then'](function(_0x9ecd6c){if(_0x9ecd6c){var _0x490b65=[_0xc590('0x7e'),'Chat',_0xc590('0x7f'),'Sms',_0xc590('0x80'),_0xc590('0x81'),_0xc590('0x82')];return db['sequelize']['transaction'](function(_0x2aed41){var _0x40d924=_[_0xc590('0x2a')](_0x490b65,function(_0x4f3e05){var _0x582bc7={'attributes':['id',_0xc590('0x28')]};return _0x9ecd6c['get'+_0x4f3e05+_0xc590('0x77')](_0x582bc7)[_0xc590('0x3e')](function(_0x5bed29){var _0x1e0a78=_[_0xc590('0x2a')](_0x5bed29,function(_0x40c3e3){return _0x40c3e3[_0xc590('0x90')](_0x3129a4,{'transaction':_0x2aed41})[_0xc590('0x3e')](function(){var _0x8c2de=_['map'](_0x3129a4,function(_0x506d3e){socket['emit'](_0xc590('0x4a')+_0x4f3e05+_0xc590('0x91'),{'UserId':Number(_0x506d3e),[_0x4f3e05+_0xc590('0x83')]:_0x40c3e3['id']});if(_0x4f3e05!==_0xc590('0x7e')){return;}return db[_0xc590('0x92')][_0xc590('0x51')]({'where':{'VoiceQueueId':_0x40c3e3['id'],'UserId':_0x506d3e},'transaction':_0x2aed41});});return Promise[_0xc590('0x8e')](_0x8c2de);});});return Promise[_0xc590('0x8e')](_0x1e0a78);});});return Promise['all'](_0x40d924)[_0xc590('0x3e')](function(){return _0x9ecd6c[_0xc590('0x90')](_0x3129a4,{'transaction':_0x2aed41});})[_0xc590('0x3e')](function(){return db[_0xc590('0x6b')][_0xc590('0x6f')]({'where':{'teamId':_0x395cf2}})[_0xc590('0x3e')](function(_0x51a33f){if(_0x51a33f){var _0x5b9d44=_[_0xc590('0x2a')](_0x3129a4,function(_0x4dd8d6){db[_0xc590('0x6c')][_0xc590('0x51')]({'where':{'UserId':_0x4dd8d6,'VoicePrefixId':_0x51a33f['VoicePrefixId']}});});return Promise[_0xc590('0x8e')](_0x5b9d44);}});});});}})[_0xc590('0x3e')](respondWithStatusCode(_0x112e23,null))[_0xc590('0x42')](handleError(_0x112e23,null));};exports[_0xc590('0x93')]=function(_0x534d61,_0xb13392,_0x86890e){var _0x3c19f0={};var _0xe72274={};var _0x1f0987;var _0xa47262;return db[_0xc590('0x3c')]['findOne']({'where':{'id':_0x534d61['params']['id']}})[_0xc590('0x3e')](handleEntityNotFound(_0xb13392,null))[_0xc590('0x3e')](function(_0xad7653){if(_0xad7653){_0x1f0987=_0xad7653;_0xe72274[_0xc590('0x30')]=_[_0xc590('0x44')](db[_0xc590('0x86')][_0xc590('0x45')]);_0xe72274[_0xc590('0x2e')]=_[_0xc590('0x44')](_0x534d61[_0xc590('0x2e')]);_0xe72274['filters']=_[_0xc590('0x2f')](_0xe72274[_0xc590('0x30')],_0xe72274[_0xc590('0x2e')]);_0x3c19f0[_0xc590('0x31')]=_[_0xc590('0x2f')](_0xe72274['model'],qs[_0xc590('0x32')](_0x534d61[_0xc590('0x2e')][_0xc590('0x32')]));_0x3c19f0[_0xc590('0x31')]=_0x3c19f0['attributes'][_0xc590('0x33')]?_0x3c19f0[_0xc590('0x31')]:_0xe72274[_0xc590('0x30')];_0x3c19f0[_0xc590('0x94')]=qs[_0xc590('0x35')](_0x534d61['query'][_0xc590('0x35')]);_0x3c19f0[_0xc590('0x36')]=qs[_0xc590('0x37')](_[_0xc590('0x38')](_0x534d61[_0xc590('0x2e')],_0xe72274[_0xc590('0x37')]));if(_0x534d61[_0xc590('0x2e')][_0xc590('0x39')]){_0x3c19f0[_0xc590('0x36')]=_[_0xc590('0x3b')](_0x3c19f0[_0xc590('0x36')],{'$or':_[_0xc590('0x2a')](_0x3c19f0[_0xc590('0x31')],function(_0x165629){var _0x22dde1={};_0x22dde1[_0x165629]={'$like':'%'+_0x534d61[_0xc590('0x2e')][_0xc590('0x39')]+'%'};return _0x22dde1;})});}_0x3c19f0=_['merge']({},_0x3c19f0,_0x534d61[_0xc590('0x46')]);return _0x1f0987[_0xc590('0x93')](_0x3c19f0);}})[_0xc590('0x3e')](function(_0x4f4e5a){if(_0x4f4e5a){_0xa47262=_0x4f4e5a[_0xc590('0x33')];if(!_0x534d61[_0xc590('0x2e')][_0xc590('0x34')](_0xc590('0x95'))){_0x3c19f0[_0xc590('0x22')]=qs[_0xc590('0x22')](_0x534d61[_0xc590('0x2e')][_0xc590('0x22')]);_0x3c19f0[_0xc590('0x21')]=qs[_0xc590('0x21')](_0x534d61[_0xc590('0x2e')][_0xc590('0x21')]);}return _0x1f0987[_0xc590('0x93')](_0x3c19f0);}})[_0xc590('0x3e')](function(_0x22a7ea){if(_0x22a7ea){return _0x22a7ea?{'count':_0xa47262,'rows':_0x22a7ea}:null;}})[_0xc590('0x3e')](respondWithResult(_0xb13392,null))[_0xc590('0x42')](handleError(_0xb13392,null));};
\ No newline at end of file