Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / team / team.controller.js
index 41419d6..4517fe1 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 _0x6a02=['upsert','spread','removeAgents','isArray','Chat','Whatsapp','Queue:remove','UserVoiceQueueRt','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','ejs','fs-extra','squel','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','redis','localhost','socket.io-emitter','./team.socket','register','sendStatus','status','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','stack','name','map','Team','rawAttributes','fieldName','type','key','model','keys','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','sort','pick','filter','where','VIRTUAL','merge','options','includeAll','include','findAll','rows','show','params','find','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Teams','UserProfileSection','userProfileId','autoAssociation','error','destroy','sequelize','transaction','SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20','Sequelize','QueryTypes','SELECT','UserVoiceQueue','UserSmsQueue','SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20','ChatQueueId','UserChatQueue','SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20','FaxQueueId','UserFaxQueue','SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20','OpenchannelQueueId','UserOpenchannelQueue','SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','UserWhatsappQueue','TeamVoicePrefix','VoicePrefixId','UserProfileResource','end','send','getQueues','findOne','channel','ValidationError','Unknown\x20channel','capitalize','toLowerCase','order','Queues','addQueues','isValidChannel','add','ids','removeQueues','remove','addAgents','Voice','Mail','Sms','Fax','Openchannel','through','QueueId','defaults','TeamVoiceQueue','penalty','User','Queue','findOrCreate','emit','Queue:save','online','interface','isNil','format','SIP/%s','voicePause','all','UserVoicePrefix'];(function(_0x3b56c0,_0xe100d8){var _0x377efe=function(_0x181589){while(--_0x181589){_0x3b56c0['push'](_0x3b56c0['shift']());}};_0x377efe(++_0xe100d8);}(_0x6a02,0x1e6));var _0x26a0=function(_0x511f6e,_0x27f388){_0x511f6e=_0x511f6e-0x0;var _0x5aaa69=_0x6a02[_0x511f6e];return _0x5aaa69;};'use strict';var emlformat=require(_0x26a0('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x26a0('0x1'));var jsonpatch=require(_0x26a0('0x2'));var rp=require(_0x26a0('0x3'));var moment=require(_0x26a0('0x4'));var BPromise=require(_0x26a0('0x5'));var Mustache=require(_0x26a0('0x6'));var util=require(_0x26a0('0x7'));var path=require('path');var sox=require(_0x26a0('0x8'));var csv=require('to-csv');var ejs=require(_0x26a0('0x9'));var fs=require('fs');var fs_extra=require(_0x26a0('0xa'));var _=require('lodash');var squel=require(_0x26a0('0xb'));var crypto=require(_0x26a0('0xc'));var jsforce=require(_0x26a0('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x26a0('0xe'));var querystring=require(_0x26a0('0xf'));var Papa=require(_0x26a0('0x10'));var Redis=require(_0x26a0('0x11'));var authService=require(_0x26a0('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x26a0('0x13'));var hardwareService=require(_0x26a0('0x14'));var logger=require(_0x26a0('0x15'))(_0x26a0('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x26a0('0x17'))['db'];config[_0x26a0('0x18')]=_['defaults'](config[_0x26a0('0x18')],{'host':_0x26a0('0x19'),'port':0x18eb});var socket=require(_0x26a0('0x1a'))(new Redis(config[_0x26a0('0x18')]));require(_0x26a0('0x1b'))[_0x26a0('0x1c')](socket);function respondWithStatusCode(_0x5aceb9,_0x321186){_0x321186=_0x321186||0xcc;return function(_0x53198f){if(_0x53198f){return _0x5aceb9[_0x26a0('0x1d')](_0x321186);}return _0x5aceb9[_0x26a0('0x1e')](_0x321186)['end']();};}function respondWithResult(_0xf8bfb6,_0xec264e){_0xec264e=_0xec264e||0xc8;return function(_0x3eb164){if(_0x3eb164){return _0xf8bfb6['status'](_0xec264e)[_0x26a0('0x1f')](_0x3eb164);}};}function respondWithFilteredResult(_0x2334dc,_0x347eaa){return function(_0x458e9d){if(_0x458e9d){var _0x5802c4=typeof _0x347eaa[_0x26a0('0x20')]===_0x26a0('0x21')&&typeof _0x347eaa[_0x26a0('0x22')]===_0x26a0('0x21');var _0x173928=_0x458e9d[_0x26a0('0x23')];var _0x10da7f=_0x5802c4?0x0:_0x347eaa[_0x26a0('0x20')];var _0x33c7b7=_0x5802c4?_0x458e9d['count']:_0x347eaa[_0x26a0('0x20')]+_0x347eaa[_0x26a0('0x22')];var _0x1889f8;if(_0x33c7b7>=_0x173928){_0x33c7b7=_0x173928;_0x1889f8=0xc8;}else{_0x1889f8=0xce;}_0x2334dc[_0x26a0('0x1e')](_0x1889f8);return _0x2334dc['set'](_0x26a0('0x24'),_0x10da7f+'-'+_0x33c7b7+'/'+_0x173928)['json'](_0x458e9d);}return null;};}function patchUpdates(_0x91cf3d){return function(_0x11155f){try{jsonpatch[_0x26a0('0x25')](_0x11155f,_0x91cf3d,!![]);}catch(_0x18d252){return BPromise[_0x26a0('0x26')](_0x18d252);}return _0x11155f[_0x26a0('0x27')]();};}function saveUpdates(_0x1d4a0b,_0x31f9e3){return function(_0x10eed7){if(_0x10eed7){return _0x10eed7[_0x26a0('0x28')](_0x1d4a0b)[_0x26a0('0x29')](function(_0x231841){return _0x231841;});}return null;};}function handleEntityNotFound(_0x225b27,_0x2705a2){return function(_0x23ccfb){if(!_0x23ccfb){_0x225b27['sendStatus'](0x194);}return _0x23ccfb;};}function handleError(_0x5e3150,_0x2f3743){_0x2f3743=_0x2f3743||0x1f4;return function(_0x588219){logger['error'](_0x588219[_0x26a0('0x2a')]);if(_0x588219[_0x26a0('0x2b')]){delete _0x588219[_0x26a0('0x2b')];}_0x5e3150[_0x26a0('0x1e')](_0x2f3743)['send'](_0x588219);};}exports['index']=function(_0x58e993,_0x5c6257){var _0x5df65c={},_0x197f50={},_0x1b996c={'count':0x0,'rows':[]};var _0x4894b5=_[_0x26a0('0x2c')](db[_0x26a0('0x2d')][_0x26a0('0x2e')],function(_0x1d91c2){return{'name':_0x1d91c2[_0x26a0('0x2f')],'type':_0x1d91c2[_0x26a0('0x30')][_0x26a0('0x31')]};});_0x197f50[_0x26a0('0x32')]=_[_0x26a0('0x2c')](_0x4894b5,'name');_0x197f50['query']=_[_0x26a0('0x33')](_0x58e993['query']);_0x197f50[_0x26a0('0x34')]=_[_0x26a0('0x35')](_0x197f50[_0x26a0('0x32')],_0x197f50[_0x26a0('0x36')]);_0x5df65c[_0x26a0('0x37')]=_['intersection'](_0x197f50[_0x26a0('0x32')],qs[_0x26a0('0x38')](_0x58e993[_0x26a0('0x36')][_0x26a0('0x38')]));_0x5df65c['attributes']=_0x5df65c[_0x26a0('0x37')][_0x26a0('0x39')]?_0x5df65c[_0x26a0('0x37')]:_0x197f50[_0x26a0('0x32')];if(!_0x58e993[_0x26a0('0x36')][_0x26a0('0x3a')](_0x26a0('0x3b'))){_0x5df65c['limit']=qs[_0x26a0('0x22')](_0x58e993['query']['limit']);_0x5df65c[_0x26a0('0x20')]=qs[_0x26a0('0x20')](_0x58e993[_0x26a0('0x36')][_0x26a0('0x20')]);}_0x5df65c['order']=qs['sort'](_0x58e993[_0x26a0('0x36')][_0x26a0('0x3c')]);_0x5df65c['where']=qs['filters'](_[_0x26a0('0x3d')](_0x58e993[_0x26a0('0x36')],_0x197f50[_0x26a0('0x34')]),_0x4894b5);if(_0x58e993['query'][_0x26a0('0x3e')]){_0x5df65c['where']=_['merge'](_0x5df65c[_0x26a0('0x3f')],{'$or':_[_0x26a0('0x2c')](_0x4894b5,function(_0x3799a3){if(_0x3799a3['type']!==_0x26a0('0x40')){var _0x357bef={};_0x357bef[_0x3799a3[_0x26a0('0x2b')]]={'$like':'%'+_0x58e993[_0x26a0('0x36')][_0x26a0('0x3e')]+'%'};return _0x357bef;}})});}_0x5df65c=_[_0x26a0('0x41')]({},_0x5df65c,_0x58e993[_0x26a0('0x42')]);var _0x59715f={'where':_0x5df65c[_0x26a0('0x3f')]};return db[_0x26a0('0x2d')][_0x26a0('0x23')](_0x59715f)[_0x26a0('0x29')](function(_0x15fb68){_0x1b996c[_0x26a0('0x23')]=_0x15fb68;if(_0x58e993[_0x26a0('0x36')][_0x26a0('0x43')]){_0x5df65c[_0x26a0('0x44')]=[{'all':!![]}];}return db['Team'][_0x26a0('0x45')](_0x5df65c);})[_0x26a0('0x29')](function(_0x5a2338){_0x1b996c[_0x26a0('0x46')]=_0x5a2338;return _0x1b996c;})[_0x26a0('0x29')](respondWithFilteredResult(_0x5c6257,_0x5df65c))['catch'](handleError(_0x5c6257,null));};exports[_0x26a0('0x47')]=function(_0xde2865,_0xa41622){var _0x2a37c7={'raw':![],'where':{'id':_0xde2865[_0x26a0('0x48')]['id']}},_0x20cd5={};_0x20cd5[_0x26a0('0x32')]=_[_0x26a0('0x33')](db['Team']['rawAttributes']);_0x20cd5[_0x26a0('0x36')]=_[_0x26a0('0x33')](_0xde2865[_0x26a0('0x36')]);_0x20cd5[_0x26a0('0x34')]=_[_0x26a0('0x35')](_0x20cd5[_0x26a0('0x32')],_0x20cd5[_0x26a0('0x36')]);_0x2a37c7[_0x26a0('0x37')]=_[_0x26a0('0x35')](_0x20cd5[_0x26a0('0x32')],qs[_0x26a0('0x38')](_0xde2865[_0x26a0('0x36')]['fields']));_0x2a37c7[_0x26a0('0x37')]=_0x2a37c7[_0x26a0('0x37')][_0x26a0('0x39')]?_0x2a37c7[_0x26a0('0x37')]:_0x20cd5[_0x26a0('0x32')];if(_0xde2865[_0x26a0('0x36')][_0x26a0('0x43')]){_0x2a37c7[_0x26a0('0x44')]=[{'all':!![]}];}_0x2a37c7=_['merge']({},_0x2a37c7,_0xde2865[_0x26a0('0x42')]);return db[_0x26a0('0x2d')][_0x26a0('0x49')](_0x2a37c7)[_0x26a0('0x29')](handleEntityNotFound(_0xa41622,null))[_0x26a0('0x29')](respondWithResult(_0xa41622,null))[_0x26a0('0x4a')](handleError(_0xa41622,null));};exports[_0x26a0('0x4b')]=function(_0x3796a1,_0x59b4ea){return db['Team'][_0x26a0('0x4b')](_0x3796a1[_0x26a0('0x4c')],{})[_0x26a0('0x29')](function(_0x28b06a){var _0x204d77=_0x3796a1[_0x26a0('0x4d')][_0x26a0('0x4e')]({'plain':!![]});if(!_0x204d77)throw new Error(_0x26a0('0x4f'));if(_0x204d77[_0x26a0('0x50')]===_0x26a0('0x4d')){var _0x5e8992=_0x28b06a['get']({'plain':!![]});var _0x2181a7=_0x26a0('0x51');return db[_0x26a0('0x52')]['find']({'where':{'name':_0x2181a7,'userProfileId':_0x204d77[_0x26a0('0x53')]},'raw':!![]})[_0x26a0('0x29')](function(_0x4d1f50){if(_0x4d1f50&&_0x4d1f50[_0x26a0('0x54')]===0x0){return db['UserProfileResource'][_0x26a0('0x4b')]({'name':_0x5e8992[_0x26a0('0x2b')],'resourceId':_0x5e8992['id'],'type':_0x4d1f50['name'],'sectionId':_0x4d1f50['id']},{})['then'](function(){return _0x28b06a;});}else{return _0x28b06a;}})['catch'](function(_0xe2e909){logger[_0x26a0('0x55')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xe2e909);throw _0xe2e909;});}return _0x28b06a;})['then'](respondWithResult(_0x59b4ea,0xc9))[_0x26a0('0x4a')](handleError(_0x59b4ea,null));};exports['update']=function(_0x38f876,_0x169d1a){if(_0x38f876['body']['id']){delete _0x38f876[_0x26a0('0x4c')]['id'];}return db[_0x26a0('0x2d')][_0x26a0('0x49')]({'where':{'id':_0x38f876[_0x26a0('0x48')]['id']}})[_0x26a0('0x29')](handleEntityNotFound(_0x169d1a,null))[_0x26a0('0x29')](saveUpdates(_0x38f876[_0x26a0('0x4c')],null))[_0x26a0('0x29')](respondWithResult(_0x169d1a,null))['catch'](handleError(_0x169d1a,null));};exports[_0x26a0('0x56')]=function(_0x112671,_0x54a9f7){var _0x420c37=_0x112671['params']['id'];var _0x1ce38d=[];return db[_0x26a0('0x57')][_0x26a0('0x58')](function(_0x2d6a49){var _0x1d232e=_0x26a0('0x59')+_0x420c37;return db[_0x26a0('0x57')][_0x26a0('0x36')](_0x1d232e,{'type':db[_0x26a0('0x5a')][_0x26a0('0x5b')][_0x26a0('0x5c')],'raw':!![],'transaction':_0x2d6a49})[_0x26a0('0x29')](function(_0x18e19e){_0x1ce38d=_[_0x26a0('0x2c')](_0x18e19e,function(_0x2cca50){return Number(_0x2cca50['UserId']);});})[_0x26a0('0x29')](function(){var _0x4ad70d='SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20'+_0x420c37;return db[_0x26a0('0x57')][_0x26a0('0x36')](_0x4ad70d,{'type':db['Sequelize'][_0x26a0('0x5b')][_0x26a0('0x5c')],'raw':!![],'transaction':_0x2d6a49});})['then'](function(_0x427a80){var _0x3a1518=_[_0x26a0('0x2c')](_0x427a80,function(_0x44ea31){return Number(_0x44ea31['VoiceQueueId']);});return db[_0x26a0('0x5d')][_0x26a0('0x56')]({'where':{'UserId':{'$in':_0x1ce38d},'VoiceQueueId':{'$in':_0x3a1518}},'transaction':_0x2d6a49});})['then'](function(){var _0x321c2a='SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20'+_0x420c37;return db['sequelize'][_0x26a0('0x36')](_0x321c2a,{'type':db[_0x26a0('0x5a')][_0x26a0('0x5b')][_0x26a0('0x5c')],'raw':!![],'transaction':_0x2d6a49});})['then'](function(_0x182b90){var _0x14f232=_['map'](_0x182b90,function(_0x49bd93){return Number(_0x49bd93['MailQueueId']);});return db['UserMailQueue'][_0x26a0('0x56')]({'where':{'UserId':{'$in':_0x1ce38d},'MailQueueId':{'$in':_0x14f232}},'transaction':_0x2d6a49});})['then'](function(){var _0x2e865c='SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20'+_0x420c37;return db['sequelize'][_0x26a0('0x36')](_0x2e865c,{'type':db['Sequelize'][_0x26a0('0x5b')]['SELECT'],'raw':!![],'transaction':_0x2d6a49});})['then'](function(_0xb2181){var _0x5471ef=_[_0x26a0('0x2c')](_0xb2181,function(_0x3a9b9c){return Number(_0x3a9b9c['SmsQueueId']);});return db[_0x26a0('0x5e')][_0x26a0('0x56')]({'where':{'UserId':{'$in':_0x1ce38d},'SmsQueueId':{'$in':_0x5471ef}},'transaction':_0x2d6a49});})['then'](function(){var _0x5b1577=_0x26a0('0x5f')+_0x420c37;return db[_0x26a0('0x57')][_0x26a0('0x36')](_0x5b1577,{'type':db['Sequelize'][_0x26a0('0x5b')][_0x26a0('0x5c')],'raw':!![],'transaction':_0x2d6a49});})['then'](function(_0x326355){var _0x360f4b=_[_0x26a0('0x2c')](_0x326355,function(_0x561996){return Number(_0x561996[_0x26a0('0x60')]);});return db[_0x26a0('0x61')][_0x26a0('0x56')]({'where':{'UserId':{'$in':_0x1ce38d},'ChatQueueId':{'$in':_0x360f4b}},'transaction':_0x2d6a49});})[_0x26a0('0x29')](function(){var _0x1a16be=_0x26a0('0x62')+_0x420c37;return db['sequelize'][_0x26a0('0x36')](_0x1a16be,{'type':db['Sequelize'][_0x26a0('0x5b')][_0x26a0('0x5c')],'raw':!![],'transaction':_0x2d6a49});})[_0x26a0('0x29')](function(_0x28d8b1){var _0x1b0006=_[_0x26a0('0x2c')](_0x28d8b1,function(_0x535ee6){return Number(_0x535ee6[_0x26a0('0x63')]);});return db[_0x26a0('0x64')]['destroy']({'where':{'UserId':{'$in':_0x1ce38d},'FaxQueueId':{'$in':_0x1b0006}},'transaction':_0x2d6a49});})[_0x26a0('0x29')](function(){var _0x53ff44=_0x26a0('0x65')+_0x420c37;return db['sequelize']['query'](_0x53ff44,{'type':db['Sequelize'][_0x26a0('0x5b')]['SELECT'],'raw':!![],'transaction':_0x2d6a49});})[_0x26a0('0x29')](function(_0x9af3cf){var _0x1555b1=_['map'](_0x9af3cf,function(_0x53693d){return Number(_0x53693d[_0x26a0('0x66')]);});return db[_0x26a0('0x67')][_0x26a0('0x56')]({'where':{'UserId':{'$in':_0x1ce38d},'OpenchannelQueueId':{'$in':_0x1555b1}},'transaction':_0x2d6a49});})['then'](function(){var _0x3e3bb6=_0x26a0('0x68')+_0x420c37;return db['sequelize']['query'](_0x3e3bb6,{'type':db['Sequelize'][_0x26a0('0x5b')]['SELECT'],'raw':!![],'transaction':_0x2d6a49});})['then'](function(_0x4c9441){var _0x200015=_[_0x26a0('0x2c')](_0x4c9441,function(_0x25fb32){return Number(_0x25fb32['WhatsappQueueId']);});return db[_0x26a0('0x69')][_0x26a0('0x56')]({'where':{'UserId':{'$in':_0x1ce38d},'WhatsappQueueId':{'$in':_0x200015}},'transaction':_0x2d6a49});})['then'](function(){return db[_0x26a0('0x6a')]['find']({'where':{'TeamId':_0x420c37}});})[_0x26a0('0x29')](function(_0x52fc18){if(_0x52fc18===null){return;}return db['UserVoicePrefix'][_0x26a0('0x56')]({'where':{'UserId':{'$in':_0x1ce38d},'VoicePrefixId':_0x52fc18[_0x26a0('0x6b')]},'transaction':_0x2d6a49});})[_0x26a0('0x29')](function(){return db[_0x26a0('0x2d')][_0x26a0('0x56')]({'where':{'id':_0x420c37},'cascade':!![],'transaction':_0x2d6a49});})[_0x26a0('0x29')](function(_0x395928){if(_0x395928===0x0){_0x54a9f7[_0x26a0('0x1d')](0x194);}else{return db[_0x26a0('0x6c')][_0x26a0('0x56')]({'where':{'type':_0x26a0('0x51'),'resourceId':_0x420c37},'cascade':!![],'transaction':_0x2d6a49})[_0x26a0('0x29')](function(){_0x54a9f7[_0x26a0('0x1e')](0xcc)[_0x26a0('0x6d')]();});}})[_0x26a0('0x4a')](function(_0x4bfdbb){_0x54a9f7[_0x26a0('0x1e')](0x1f4)[_0x26a0('0x6e')](_0x4bfdbb);});});};exports[_0x26a0('0x6f')]=function(_0x46a2c3,_0x117c8f,_0x403d1d){return db[_0x26a0('0x2d')][_0x26a0('0x70')]({'where':{'id':_0x46a2c3[_0x26a0('0x48')]['id']}})[_0x26a0('0x29')](handleEntityNotFound(_0x117c8f,null))[_0x26a0('0x29')](function(_0x445096){if(!_0x46a2c3[_0x26a0('0x36')]['channel']||!utils['isValidChannel'](_0x46a2c3['query'][_0x26a0('0x71')])){throw new db[(_0x26a0('0x5a'))][(_0x26a0('0x72'))](_0x26a0('0x73'));}var _0x64aee3={};var _0x3a914d={};_0x3a914d[_0x26a0('0x32')]=_[_0x26a0('0x33')](db[_[_0x26a0('0x74')](_0x46a2c3[_0x26a0('0x36')]['channel'][_0x26a0('0x75')]())+'Queue'][_0x26a0('0x2e')]);_0x3a914d[_0x26a0('0x36')]=_['keys'](_0x46a2c3['query']);_0x3a914d[_0x26a0('0x34')]=_[_0x26a0('0x35')](_0x3a914d[_0x26a0('0x32')],_0x3a914d[_0x26a0('0x36')]);_0x64aee3['attributes']=_['intersection'](_0x3a914d[_0x26a0('0x32')],qs[_0x26a0('0x38')](_0x46a2c3[_0x26a0('0x36')][_0x26a0('0x38')]));_0x64aee3[_0x26a0('0x37')]=_0x64aee3[_0x26a0('0x37')][_0x26a0('0x39')]?_0x64aee3[_0x26a0('0x37')]:_0x3a914d[_0x26a0('0x32')];_0x64aee3[_0x26a0('0x22')]=qs[_0x26a0('0x22')](_0x46a2c3['query'][_0x26a0('0x22')]);_0x64aee3[_0x26a0('0x20')]=qs[_0x26a0('0x20')](_0x46a2c3[_0x26a0('0x36')]['offset']);_0x64aee3[_0x26a0('0x76')]=qs['sort'](_0x46a2c3['query'][_0x26a0('0x3c')]);_0x64aee3[_0x26a0('0x3f')]=qs[_0x26a0('0x34')](_[_0x26a0('0x3d')](_0x46a2c3[_0x26a0('0x36')],_0x3a914d[_0x26a0('0x34')]));_0x64aee3=_[_0x26a0('0x41')]({},_0x64aee3,_0x46a2c3[_0x26a0('0x42')]);return _0x445096['get'+_[_0x26a0('0x74')](_0x46a2c3[_0x26a0('0x36')][_0x26a0('0x71')][_0x26a0('0x75')]())+_0x26a0('0x77')](_0x64aee3);})[_0x26a0('0x29')](respondWithResult(_0x117c8f,null))['catch'](handleError(_0x117c8f,null));};exports[_0x26a0('0x78')]=function(_0x584f2c,_0x402d5e,_0x1100ca){return db[_0x26a0('0x2d')]['findOne']({'where':{'id':_0x584f2c[_0x26a0('0x48')]['id']}})[_0x26a0('0x29')](function(_0xe8a7de){if(_0xe8a7de){if(!_0x584f2c[_0x26a0('0x4c')][_0x26a0('0x71')]||!utils[_0x26a0('0x79')](_0x584f2c[_0x26a0('0x4c')][_0x26a0('0x71')])){throw new db['Sequelize'][(_0x26a0('0x72'))](_0x26a0('0x73'));}return _0xe8a7de[_0x26a0('0x7a')+_[_0x26a0('0x74')](_0x584f2c[_0x26a0('0x4c')][_0x26a0('0x71')][_0x26a0('0x75')]())+_0x26a0('0x77')](_0x584f2c['body'][_0x26a0('0x7b')]);}return null;})['then'](handleEntityNotFound(_0x402d5e,null))['then'](respondWithStatusCode(_0x402d5e,null))['catch'](handleError(_0x402d5e,null));};exports[_0x26a0('0x7c')]=function(_0x35c393,_0xa04908,_0x121d84){return db[_0x26a0('0x2d')][_0x26a0('0x70')]({'where':{'id':_0x35c393[_0x26a0('0x48')]['id']}})[_0x26a0('0x29')](function(_0x445e7a){if(_0x445e7a){if(!_0x35c393[_0x26a0('0x36')]['channel']||!utils['isValidChannel'](_0x35c393[_0x26a0('0x36')]['channel'])){throw new db[(_0x26a0('0x5a'))][(_0x26a0('0x72'))](_0x26a0('0x73'));}return _0x445e7a[_0x26a0('0x7d')+_['capitalize'](_0x35c393[_0x26a0('0x36')][_0x26a0('0x71')][_0x26a0('0x75')]())+'Queues'](_0x35c393['query'][_0x26a0('0x7b')]);}return null;})['then'](handleEntityNotFound(_0xa04908,null))[_0x26a0('0x29')](respondWithStatusCode(_0xa04908,null))[_0x26a0('0x4a')](handleError(_0xa04908,null));};exports[_0x26a0('0x7e')]=function(_0x555d5a,_0x32a1e7){var _0x476e2d=_['isArray'](_0x555d5a[_0x26a0('0x4c')][_0x26a0('0x7b')])?_0x555d5a[_0x26a0('0x4c')]['ids']:[_0x555d5a[_0x26a0('0x4c')][_0x26a0('0x7b')]];var _0x3d081b=_0x555d5a[_0x26a0('0x48')]['id'];return db[_0x26a0('0x2d')][_0x26a0('0x49')]({'where':{'id':_0x3d081b}})[_0x26a0('0x29')](handleEntityNotFound(_0x32a1e7,null))['then'](function(_0x586dc1){if(_0x586dc1){var _0x52b6a3=[_0x26a0('0x7f'),'Chat',_0x26a0('0x80'),_0x26a0('0x81'),_0x26a0('0x82'),_0x26a0('0x83'),'Whatsapp'];return db[_0x26a0('0x57')][_0x26a0('0x58')](function(_0xb63b35){var _0x21fd47=_[_0x26a0('0x2c')](_0x52b6a3,function(_0x413249){var _0x3055f5={'attributes':['id',_0x26a0('0x2b')]};if(_0x413249===_0x26a0('0x7f')){_0x3055f5[_0x26a0('0x84')]={'attributes':['penalty']};}return _0x586dc1[_0x26a0('0x4e')+_0x413249+'Queues'](_0x3055f5)[_0x26a0('0x29')](function(_0x3f6512){var _0x25e786=_[_0x26a0('0x2c')](_0x3f6512,function(_0x2c6ad9){var _0x274438=_[_0x26a0('0x2c')](_0x476e2d,function(_0x2795f7){var _0x4fed89={'where':{'UserId':_0x2795f7,[_0x413249+_0x26a0('0x85')]:_0x2c6ad9['id']},'transaction':_0xb63b35};if(_0x413249===_0x26a0('0x7f')){_0x4fed89[_0x26a0('0x86')]={'penalty':_0x2c6ad9[_0x26a0('0x87')][_0x26a0('0x88')]};}return db[_0x26a0('0x89')+_0x413249+_0x26a0('0x8a')][_0x26a0('0x8b')](_0x4fed89)[_0x26a0('0x29')](function(){socket[_0x26a0('0x8c')](_0x26a0('0x4d')+_0x413249+_0x26a0('0x8d'),{'UserId':_0x2795f7,[_0x413249+'QueueId']:_0x2c6ad9['id']});if(_0x413249!==_0x26a0('0x7f')){return;}return db[_0x26a0('0x89')][_0x26a0('0x45')]({'where':{'id':_0x476e2d,'online':0x1},'attributes':['id','name',_0x26a0('0x8e'),'voicePause',_0x26a0('0x8f')],'raw':!![]})['then'](function(_0x521cb5){var _0x58885e=_[_0x26a0('0x2c')](_0x521cb5,function(_0xa7e6e3){return db['UserVoiceQueueRt']['upsert']({'membername':_0xa7e6e3[_0x26a0('0x2b')],'UserId':_0xa7e6e3['id'],'queue_name':_0x2c6ad9['name'],'VoiceQueueId':_0x2c6ad9['id'],'interface':_[_0x26a0('0x90')](_0xa7e6e3[_0x26a0('0x8f')])?util[_0x26a0('0x91')](_0x26a0('0x92'),_0xa7e6e3['name']):_0xa7e6e3[_0x26a0('0x8f')],'paused':_0xa7e6e3[_0x26a0('0x93')]||![],'penalty':_0x2c6ad9['TeamVoiceQueue'][_0x26a0('0x88')]},{'transaction':_0xb63b35});});return Promise[_0x26a0('0x94')](_0x58885e);});});});return Promise[_0x26a0('0x94')](_0x274438);});return Promise[_0x26a0('0x94')](_0x25e786);})[_0x26a0('0x29')](function(){return db[_0x26a0('0x6a')][_0x26a0('0x70')]({'where':{'teamId':_0x3d081b}})[_0x26a0('0x29')](function(_0xc58038){if(_0xc58038){var _0x31659a=_[_0x26a0('0x2c')](_0x476e2d,function(_0x3d1be0){db[_0x26a0('0x95')][_0x26a0('0x96')]({'UserId':_0x3d1be0,'VoicePrefixId':_0xc58038['VoicePrefixId']});});return Promise[_0x26a0('0x94')](_0x31659a);}});});});return Promise[_0x26a0('0x94')](_0x21fd47)[_0x26a0('0x29')](function(){return _0x586dc1[_0x26a0('0x7e')](_0x476e2d,{'transaction':_0xb63b35})[_0x26a0('0x97')](function(_0xc00f0f){return _0xc00f0f;});});});}})[_0x26a0('0x29')](respondWithResult(_0x32a1e7,null))[_0x26a0('0x4a')](handleError(_0x32a1e7,null));};exports[_0x26a0('0x98')]=function(_0x3ae0e6,_0x2a18e2){var _0x5b8bac=_[_0x26a0('0x99')](_0x3ae0e6[_0x26a0('0x36')][_0x26a0('0x7b')])?_0x3ae0e6[_0x26a0('0x36')][_0x26a0('0x7b')]:[_0x3ae0e6[_0x26a0('0x36')][_0x26a0('0x7b')]];var _0x26aadf=_0x3ae0e6[_0x26a0('0x48')]['id'];return db[_0x26a0('0x2d')][_0x26a0('0x49')]({'where':{'id':_0x26aadf}})[_0x26a0('0x29')](handleEntityNotFound(_0x2a18e2,null))['then'](function(_0x23fb56){if(_0x23fb56){var _0x229dae=['Voice',_0x26a0('0x9a'),_0x26a0('0x80'),_0x26a0('0x81'),'Fax','Openchannel',_0x26a0('0x9b')];return db[_0x26a0('0x57')][_0x26a0('0x58')](function(_0x57f4ce){var _0x455b78=_[_0x26a0('0x2c')](_0x229dae,function(_0x29b953){var _0x35a034={'attributes':['id','name']};return _0x23fb56[_0x26a0('0x4e')+_0x29b953+'Queues'](_0x35a034)[_0x26a0('0x29')](function(_0x9dc162){var _0x1c38be=_[_0x26a0('0x2c')](_0x9dc162,function(_0x528222){return _0x528222[_0x26a0('0x98')](_0x5b8bac,{'transaction':_0x57f4ce})['then'](function(){var _0x5c2837=_[_0x26a0('0x2c')](_0x5b8bac,function(_0x3f725e){socket[_0x26a0('0x8c')](_0x26a0('0x4d')+_0x29b953+_0x26a0('0x9c'),{'UserId':Number(_0x3f725e),[_0x29b953+_0x26a0('0x85')]:_0x528222['id']});if(_0x29b953!==_0x26a0('0x7f')){return;}return db[_0x26a0('0x9d')][_0x26a0('0x56')]({'where':{'VoiceQueueId':_0x528222['id'],'UserId':_0x3f725e},'transaction':_0x57f4ce});});return Promise['all'](_0x5c2837);});});return Promise[_0x26a0('0x94')](_0x1c38be);});});return Promise[_0x26a0('0x94')](_0x455b78)[_0x26a0('0x29')](function(){return _0x23fb56[_0x26a0('0x98')](_0x5b8bac,{'transaction':_0x57f4ce});})[_0x26a0('0x29')](function(){return db[_0x26a0('0x6a')][_0x26a0('0x70')]({'where':{'teamId':_0x26aadf}})[_0x26a0('0x29')](function(_0x508b1f){if(_0x508b1f){var _0x46fc2f=_['map'](_0x5b8bac,function(_0x38caea){db['UserVoicePrefix'][_0x26a0('0x56')]({'where':{'UserId':_0x38caea,'VoicePrefixId':_0x508b1f['VoicePrefixId']}});});return Promise['all'](_0x46fc2f);}});});});}})['then'](respondWithStatusCode(_0x2a18e2,null))[_0x26a0('0x4a')](handleError(_0x2a18e2,null));};exports[_0x26a0('0x9e')]=function(_0x43521c,_0x190278,_0x4e8475){var _0x2fe090={};var _0x3574c4={};var _0x1cbc77;var _0x117ad9;return db[_0x26a0('0x2d')][_0x26a0('0x70')]({'where':{'id':_0x43521c[_0x26a0('0x48')]['id']}})[_0x26a0('0x29')](handleEntityNotFound(_0x190278,null))[_0x26a0('0x29')](function(_0x47b579){if(_0x47b579){_0x1cbc77=_0x47b579;_0x3574c4['model']=_[_0x26a0('0x33')](db[_0x26a0('0x89')][_0x26a0('0x2e')]);_0x3574c4[_0x26a0('0x36')]=_['keys'](_0x43521c[_0x26a0('0x36')]);_0x3574c4[_0x26a0('0x34')]=_[_0x26a0('0x35')](_0x3574c4[_0x26a0('0x32')],_0x3574c4[_0x26a0('0x36')]);_0x2fe090['attributes']=_['intersection'](_0x3574c4[_0x26a0('0x32')],qs['fields'](_0x43521c[_0x26a0('0x36')][_0x26a0('0x38')]));_0x2fe090[_0x26a0('0x37')]=_0x2fe090[_0x26a0('0x37')][_0x26a0('0x39')]?_0x2fe090['attributes']:_0x3574c4[_0x26a0('0x32')];_0x2fe090[_0x26a0('0x76')]=qs[_0x26a0('0x3c')](_0x43521c['query'][_0x26a0('0x3c')]);_0x2fe090[_0x26a0('0x3f')]=qs[_0x26a0('0x34')](_[_0x26a0('0x3d')](_0x43521c['query'],_0x3574c4[_0x26a0('0x34')]));if(_0x43521c[_0x26a0('0x36')][_0x26a0('0x3e')]){_0x2fe090[_0x26a0('0x3f')]=_[_0x26a0('0x41')](_0x2fe090['where'],{'$or':_['map'](_0x2fe090[_0x26a0('0x37')],function(_0x2ce6e7){var _0x14de0d={};_0x14de0d[_0x2ce6e7]={'$like':'%'+_0x43521c['query'][_0x26a0('0x3e')]+'%'};return _0x14de0d;})});}_0x2fe090=_[_0x26a0('0x41')]({},_0x2fe090,_0x43521c['options']);return _0x1cbc77['getAgents'](_0x2fe090);}})[_0x26a0('0x29')](function(_0xbd9d4a){if(_0xbd9d4a){_0x117ad9=_0xbd9d4a['length'];if(!_0x43521c[_0x26a0('0x36')][_0x26a0('0x3a')](_0x26a0('0x3b'))){_0x2fe090[_0x26a0('0x22')]=qs['limit'](_0x43521c[_0x26a0('0x36')][_0x26a0('0x22')]);_0x2fe090[_0x26a0('0x20')]=qs['offset'](_0x43521c[_0x26a0('0x36')][_0x26a0('0x20')]);}return _0x1cbc77[_0x26a0('0x9e')](_0x2fe090);}})['then'](function(_0x30e41b){if(_0x30e41b){return _0x30e41b?{'count':_0x117ad9,'rows':_0x30e41b}:null;}})['then'](respondWithResult(_0x190278,null))[_0x26a0('0x4a')](handleError(_0x190278,null));};
\ No newline at end of file