Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / team / team.controller.js
index 8ef9538..89f9c14 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1020=['Queue','capitalize','addQueues','Sequelize','Queues','ids','removeQueues','findOne','addAgents','Mail','Sms','Fax','sequelize','transaction','Voice','penalty','QueueId','TeamVoiceQueue','User','findOrCreate','emit','online','voicePause','interface','isNil','format','SIP/%s','all','spread','removeAgents','Chat','Openchannel','Whatsapp','Queue:remove','UserVoiceQueueRt','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','offset','undefined','limit','count','set','json','apply','save','update','then','destroy','get','Teams','UserProfileResource','error','stack','name','map','Team','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','catch','show','params','find','create','body','user','UserProfileSection','autoAssociation','getQueues','channel','isValidChannel','ValidationError','Unknown\x20channel','toLowerCase'];(function(_0x581fa7,_0x9ce527){var _0x151fa1=function(_0x119702){while(--_0x119702){_0x581fa7['push'](_0x581fa7['shift']());}};_0x151fa1(++_0x9ce527);}(_0x1020,0x1a4));var _0x0102=function(_0x1c289a,_0x277fe7){_0x1c289a=_0x1c289a-0x0;var _0x28d68e=_0x1020[_0x1c289a];return _0x28d68e;};'use strict';var emlformat=require(_0x0102('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0102('0x1'));var jsonpatch=require(_0x0102('0x2'));var rp=require(_0x0102('0x3'));var moment=require(_0x0102('0x4'));var BPromise=require(_0x0102('0x5'));var Mustache=require(_0x0102('0x6'));var util=require(_0x0102('0x7'));var path=require(_0x0102('0x8'));var sox=require(_0x0102('0x9'));var csv=require(_0x0102('0xa'));var ejs=require(_0x0102('0xb'));var fs=require('fs');var fs_extra=require(_0x0102('0xc'));var _=require('lodash');var squel=require(_0x0102('0xd'));var crypto=require(_0x0102('0xe'));var jsforce=require(_0x0102('0xf'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x0102('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x0102('0x11'));var qs=require(_0x0102('0x12'));var as=require(_0x0102('0x13'));var hardwareService=require(_0x0102('0x14'));var logger=require(_0x0102('0x15'))('api');var utils=require(_0x0102('0x16'));var config=require(_0x0102('0x17'));var licenseUtil=require(_0x0102('0x18'));var db=require(_0x0102('0x19'))['db'];config[_0x0102('0x1a')]=_[_0x0102('0x1b')](config[_0x0102('0x1a')],{'host':_0x0102('0x1c'),'port':0x18eb});var socket=require(_0x0102('0x1d'))(new Redis(config['redis']));require('./team.socket')[_0x0102('0x1e')](socket);function respondWithStatusCode(_0x20f557,_0x3d0f4b){_0x3d0f4b=_0x3d0f4b||0xcc;return function(_0x21d392){if(_0x21d392){return _0x20f557[_0x0102('0x1f')](_0x3d0f4b);}return _0x20f557[_0x0102('0x20')](_0x3d0f4b)[_0x0102('0x21')]();};}function respondWithResult(_0x2e0c35,_0x3b7253){_0x3b7253=_0x3b7253||0xc8;return function(_0x2493fe){if(_0x2493fe){return _0x2e0c35[_0x0102('0x20')](_0x3b7253)['json'](_0x2493fe);}};}function respondWithFilteredResult(_0x2ca87b,_0x560b74){return function(_0x58ba05){if(_0x58ba05){var _0x4f3266=typeof _0x560b74[_0x0102('0x22')]===_0x0102('0x23')&&typeof _0x560b74[_0x0102('0x24')]===_0x0102('0x23');var _0x1da56c=_0x58ba05[_0x0102('0x25')];var _0x74533b=_0x4f3266?0x0:_0x560b74[_0x0102('0x22')];var _0x3da475=_0x4f3266?_0x58ba05[_0x0102('0x25')]:_0x560b74[_0x0102('0x22')]+_0x560b74[_0x0102('0x24')];var _0x1cc7bb;if(_0x3da475>=_0x1da56c){_0x3da475=_0x1da56c;_0x1cc7bb=0xc8;}else{_0x1cc7bb=0xce;}_0x2ca87b[_0x0102('0x20')](_0x1cc7bb);return _0x2ca87b[_0x0102('0x26')]('Content-Range',_0x74533b+'-'+_0x3da475+'/'+_0x1da56c)[_0x0102('0x27')](_0x58ba05);}return null;};}function patchUpdates(_0x2dc5f5){return function(_0x34cb74){try{jsonpatch[_0x0102('0x28')](_0x34cb74,_0x2dc5f5,!![]);}catch(_0x2787aa){return BPromise['reject'](_0x2787aa);}return _0x34cb74[_0x0102('0x29')]();};}function saveUpdates(_0x3d0fa7,_0x3d33db){return function(_0x11d9f4){if(_0x11d9f4){return _0x11d9f4[_0x0102('0x2a')](_0x3d0fa7)[_0x0102('0x2b')](function(_0x5ea683){return _0x5ea683;});}return null;};}function removeEntity(_0x6938fc,_0x42e908){return function(_0x462eb2){if(_0x462eb2){return _0x462eb2[_0x0102('0x2c')]()['then'](function(){var _0x2013c=_0x462eb2[_0x0102('0x2d')]({'plain':!![]});var _0xe613b5=_0x0102('0x2e');return db[_0x0102('0x2f')]['destroy']({'where':{'type':_0xe613b5,'resourceId':_0x2013c['id']}})[_0x0102('0x2b')](function(){return _0x462eb2;});})[_0x0102('0x2b')](function(){_0x6938fc[_0x0102('0x20')](0xcc)[_0x0102('0x21')]();});}};}function handleEntityNotFound(_0x5944de,_0x3e5d95){return function(_0x28ddb5){if(!_0x28ddb5){_0x5944de[_0x0102('0x1f')](0x194);}return _0x28ddb5;};}function handleError(_0x5116bb,_0x51ee86){_0x51ee86=_0x51ee86||0x1f4;return function(_0x4fbc76){logger[_0x0102('0x30')](_0x4fbc76[_0x0102('0x31')]);if(_0x4fbc76['name']){delete _0x4fbc76[_0x0102('0x32')];}_0x5116bb[_0x0102('0x20')](_0x51ee86)['send'](_0x4fbc76);};}exports['index']=function(_0x4ec0a1,_0xaeae20){var _0x15aba7={},_0x5c854b={},_0x3fb9df={'count':0x0,'rows':[]};var _0x37620b=_[_0x0102('0x33')](db[_0x0102('0x34')][_0x0102('0x35')],function(_0x38def2){return{'name':_0x38def2[_0x0102('0x36')],'type':_0x38def2[_0x0102('0x37')][_0x0102('0x38')]};});_0x5c854b[_0x0102('0x39')]=_[_0x0102('0x33')](_0x37620b,'name');_0x5c854b['query']=_[_0x0102('0x3a')](_0x4ec0a1[_0x0102('0x3b')]);_0x5c854b[_0x0102('0x3c')]=_[_0x0102('0x3d')](_0x5c854b[_0x0102('0x39')],_0x5c854b['query']);_0x15aba7[_0x0102('0x3e')]=_[_0x0102('0x3d')](_0x5c854b[_0x0102('0x39')],qs['fields'](_0x4ec0a1[_0x0102('0x3b')][_0x0102('0x3f')]));_0x15aba7[_0x0102('0x3e')]=_0x15aba7[_0x0102('0x3e')][_0x0102('0x40')]?_0x15aba7[_0x0102('0x3e')]:_0x5c854b[_0x0102('0x39')];if(!_0x4ec0a1[_0x0102('0x3b')][_0x0102('0x41')](_0x0102('0x42'))){_0x15aba7[_0x0102('0x24')]=qs[_0x0102('0x24')](_0x4ec0a1[_0x0102('0x3b')]['limit']);_0x15aba7[_0x0102('0x22')]=qs[_0x0102('0x22')](_0x4ec0a1[_0x0102('0x3b')][_0x0102('0x22')]);}_0x15aba7[_0x0102('0x43')]=qs['sort'](_0x4ec0a1[_0x0102('0x3b')][_0x0102('0x44')]);_0x15aba7[_0x0102('0x45')]=qs['filters'](_[_0x0102('0x46')](_0x4ec0a1[_0x0102('0x3b')],_0x5c854b[_0x0102('0x3c')]),_0x37620b);if(_0x4ec0a1[_0x0102('0x3b')][_0x0102('0x47')]){_0x15aba7[_0x0102('0x45')]=_['merge'](_0x15aba7['where'],{'$or':_[_0x0102('0x33')](_0x37620b,function(_0x39ba70){if(_0x39ba70['type']!==_0x0102('0x48')){var _0x2cf876={};_0x2cf876[_0x39ba70[_0x0102('0x32')]]={'$like':'%'+_0x4ec0a1[_0x0102('0x3b')][_0x0102('0x47')]+'%'};return _0x2cf876;}})});}_0x15aba7=_[_0x0102('0x49')]({},_0x15aba7,_0x4ec0a1[_0x0102('0x4a')]);var _0x3b0171={'where':_0x15aba7[_0x0102('0x45')]};return db[_0x0102('0x34')][_0x0102('0x25')](_0x3b0171)['then'](function(_0x2743e4){_0x3fb9df['count']=_0x2743e4;if(_0x4ec0a1[_0x0102('0x3b')][_0x0102('0x4b')]){_0x15aba7[_0x0102('0x4c')]=[{'all':!![]}];}return db[_0x0102('0x34')]['findAll'](_0x15aba7);})[_0x0102('0x2b')](function(_0x3607a6){_0x3fb9df['rows']=_0x3607a6;return _0x3fb9df;})[_0x0102('0x2b')](respondWithFilteredResult(_0xaeae20,_0x15aba7))[_0x0102('0x4d')](handleError(_0xaeae20,null));};exports[_0x0102('0x4e')]=function(_0x35040a,_0xb78550){var _0x5cbd34={'raw':![],'where':{'id':_0x35040a[_0x0102('0x4f')]['id']}},_0x230005={};_0x230005[_0x0102('0x39')]=_[_0x0102('0x3a')](db[_0x0102('0x34')]['rawAttributes']);_0x230005[_0x0102('0x3b')]=_['keys'](_0x35040a['query']);_0x230005[_0x0102('0x3c')]=_[_0x0102('0x3d')](_0x230005['model'],_0x230005[_0x0102('0x3b')]);_0x5cbd34[_0x0102('0x3e')]=_[_0x0102('0x3d')](_0x230005[_0x0102('0x39')],qs[_0x0102('0x3f')](_0x35040a['query'][_0x0102('0x3f')]));_0x5cbd34[_0x0102('0x3e')]=_0x5cbd34[_0x0102('0x3e')][_0x0102('0x40')]?_0x5cbd34['attributes']:_0x230005[_0x0102('0x39')];if(_0x35040a[_0x0102('0x3b')][_0x0102('0x4b')]){_0x5cbd34[_0x0102('0x4c')]=[{'all':!![]}];}_0x5cbd34=_[_0x0102('0x49')]({},_0x5cbd34,_0x35040a[_0x0102('0x4a')]);return db[_0x0102('0x34')][_0x0102('0x50')](_0x5cbd34)[_0x0102('0x2b')](handleEntityNotFound(_0xb78550,null))[_0x0102('0x2b')](respondWithResult(_0xb78550,null))[_0x0102('0x4d')](handleError(_0xb78550,null));};exports[_0x0102('0x51')]=function(_0x575862,_0x4ee019){return db[_0x0102('0x34')][_0x0102('0x51')](_0x575862[_0x0102('0x52')],{})['then'](function(_0x14c812){var _0x5b43f7=_0x575862['user'][_0x0102('0x2d')]({'plain':!![]});if(!_0x5b43f7)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5b43f7['role']===_0x0102('0x53')){var _0x33cf95=_0x14c812[_0x0102('0x2d')]({'plain':!![]});var _0xf3e903=_0x0102('0x2e');return db[_0x0102('0x54')][_0x0102('0x50')]({'where':{'name':_0xf3e903,'userProfileId':_0x5b43f7['userProfileId']},'raw':!![]})['then'](function(_0x17bb0b){if(_0x17bb0b&&_0x17bb0b[_0x0102('0x55')]===0x0){return db[_0x0102('0x2f')][_0x0102('0x51')]({'name':_0x33cf95[_0x0102('0x32')],'resourceId':_0x33cf95['id'],'type':_0x17bb0b[_0x0102('0x32')],'sectionId':_0x17bb0b['id']},{})[_0x0102('0x2b')](function(){return _0x14c812;});}else{return _0x14c812;}})[_0x0102('0x4d')](function(_0x393a1f){logger[_0x0102('0x30')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x393a1f);throw _0x393a1f;});}return _0x14c812;})[_0x0102('0x2b')](respondWithResult(_0x4ee019,0xc9))['catch'](handleError(_0x4ee019,null));};exports[_0x0102('0x2a')]=function(_0x8af559,_0x3c9001){if(_0x8af559['body']['id']){delete _0x8af559[_0x0102('0x52')]['id'];}return db[_0x0102('0x34')]['find']({'where':{'id':_0x8af559[_0x0102('0x4f')]['id']}})[_0x0102('0x2b')](handleEntityNotFound(_0x3c9001,null))[_0x0102('0x2b')](saveUpdates(_0x8af559[_0x0102('0x52')],null))[_0x0102('0x2b')](respondWithResult(_0x3c9001,null))[_0x0102('0x4d')](handleError(_0x3c9001,null));};exports['destroy']=function(_0x3a35b3,_0x46f204){return db[_0x0102('0x34')][_0x0102('0x50')]({'where':{'id':_0x3a35b3[_0x0102('0x4f')]['id']}})[_0x0102('0x2b')](handleEntityNotFound(_0x46f204,null))[_0x0102('0x2b')](removeEntity(_0x46f204,null))[_0x0102('0x4d')](handleError(_0x46f204,null));};exports[_0x0102('0x56')]=function(_0x4b3571,_0x4cfc09,_0x55e8c0){return db[_0x0102('0x34')]['findOne']({'where':{'id':_0x4b3571[_0x0102('0x4f')]['id']}})['then'](handleEntityNotFound(_0x4cfc09,null))[_0x0102('0x2b')](function(_0x22b2bd){if(!_0x4b3571[_0x0102('0x3b')][_0x0102('0x57')]||!utils[_0x0102('0x58')](_0x4b3571[_0x0102('0x3b')]['channel'])){throw new db['Sequelize'][(_0x0102('0x59'))](_0x0102('0x5a'));}var _0x20f068={};var _0xa60117={};_0xa60117[_0x0102('0x39')]=_[_0x0102('0x3a')](db[_['capitalize'](_0x4b3571['query']['channel'][_0x0102('0x5b')]())+_0x0102('0x5c')][_0x0102('0x35')]);_0xa60117['query']=_['keys'](_0x4b3571[_0x0102('0x3b')]);_0xa60117[_0x0102('0x3c')]=_['intersection'](_0xa60117[_0x0102('0x39')],_0xa60117[_0x0102('0x3b')]);_0x20f068[_0x0102('0x3e')]=_[_0x0102('0x3d')](_0xa60117[_0x0102('0x39')],qs['fields'](_0x4b3571[_0x0102('0x3b')][_0x0102('0x3f')]));_0x20f068[_0x0102('0x3e')]=_0x20f068['attributes'][_0x0102('0x40')]?_0x20f068[_0x0102('0x3e')]:_0xa60117[_0x0102('0x39')];_0x20f068[_0x0102('0x24')]=qs[_0x0102('0x24')](_0x4b3571['query'][_0x0102('0x24')]);_0x20f068[_0x0102('0x22')]=qs['offset'](_0x4b3571[_0x0102('0x3b')]['offset']);_0x20f068[_0x0102('0x43')]=qs['sort'](_0x4b3571['query']['sort']);_0x20f068[_0x0102('0x45')]=qs[_0x0102('0x3c')](_['pick'](_0x4b3571[_0x0102('0x3b')],_0xa60117[_0x0102('0x3c')]));_0x20f068=_[_0x0102('0x49')]({},_0x20f068,_0x4b3571[_0x0102('0x4a')]);return _0x22b2bd[_0x0102('0x2d')+_[_0x0102('0x5d')](_0x4b3571[_0x0102('0x3b')][_0x0102('0x57')][_0x0102('0x5b')]())+'Queues'](_0x20f068);})[_0x0102('0x2b')](respondWithResult(_0x4cfc09,null))[_0x0102('0x4d')](handleError(_0x4cfc09,null));};exports[_0x0102('0x5e')]=function(_0xfdb1e4,_0x20ec50,_0x24dfdb){return db[_0x0102('0x34')]['findOne']({'where':{'id':_0xfdb1e4['params']['id']}})[_0x0102('0x2b')](function(_0x29b26a){if(_0x29b26a){if(!_0xfdb1e4[_0x0102('0x52')][_0x0102('0x57')]||!utils[_0x0102('0x58')](_0xfdb1e4['body'][_0x0102('0x57')])){throw new db[(_0x0102('0x5f'))][(_0x0102('0x59'))]('Unknown\x20channel');}return _0x29b26a['add'+_['capitalize'](_0xfdb1e4[_0x0102('0x52')][_0x0102('0x57')][_0x0102('0x5b')]())+_0x0102('0x60')](_0xfdb1e4[_0x0102('0x52')][_0x0102('0x61')]);}return null;})[_0x0102('0x2b')](handleEntityNotFound(_0x20ec50,null))[_0x0102('0x2b')](respondWithStatusCode(_0x20ec50,null))[_0x0102('0x4d')](handleError(_0x20ec50,null));};exports[_0x0102('0x62')]=function(_0xd869b9,_0x5c6814,_0x48b920){return db[_0x0102('0x34')][_0x0102('0x63')]({'where':{'id':_0xd869b9['params']['id']}})[_0x0102('0x2b')](function(_0x211bf7){if(_0x211bf7){if(!_0xd869b9[_0x0102('0x3b')][_0x0102('0x57')]||!utils[_0x0102('0x58')](_0xd869b9[_0x0102('0x3b')][_0x0102('0x57')])){throw new db[(_0x0102('0x5f'))]['ValidationError']('Unknown\x20channel');}return _0x211bf7['remove'+_[_0x0102('0x5d')](_0xd869b9['query']['channel'][_0x0102('0x5b')]())+_0x0102('0x60')](_0xd869b9[_0x0102('0x3b')][_0x0102('0x61')]);}return null;})['then'](handleEntityNotFound(_0x5c6814,null))[_0x0102('0x2b')](respondWithStatusCode(_0x5c6814,null))[_0x0102('0x4d')](handleError(_0x5c6814,null));};exports[_0x0102('0x64')]=function(_0x2f68d1,_0x4fbd28){return db[_0x0102('0x34')]['find']({'where':{'id':_0x2f68d1[_0x0102('0x4f')]['id']}})['then'](handleEntityNotFound(_0x4fbd28,null))[_0x0102('0x2b')](function(_0x334f9c){if(_0x334f9c){var _0x2b27b7=['Voice','Chat',_0x0102('0x65'),_0x0102('0x66'),_0x0102('0x67'),'Openchannel','Whatsapp'];return db[_0x0102('0x68')][_0x0102('0x69')](function(_0x597743){var _0x24d969=_[_0x0102('0x33')](_0x2b27b7,function(_0xe6e097){var _0x4863c0={'attributes':['id',_0x0102('0x32')]};if(_0xe6e097===_0x0102('0x6a')){_0x4863c0['through']={'attributes':[_0x0102('0x6b')]};}return _0x334f9c[_0x0102('0x2d')+_0xe6e097+'Queues'](_0x4863c0)[_0x0102('0x2b')](function(_0x208f90){var _0x526808=_[_0x0102('0x33')](_0x208f90,function(_0x1de614){var _0x55dbba=_[_0x0102('0x33')](_0x2f68d1['body']['ids'],function(_0x1836c7){var _0x16efaf={'where':{'UserId':_0x1836c7,[_0xe6e097+_0x0102('0x6c')]:_0x1de614['id']},'transaction':_0x597743};if(_0xe6e097===_0x0102('0x6a')){_0x16efaf[_0x0102('0x1b')]={'penalty':_0x1de614[_0x0102('0x6d')]['penalty']};}return db[_0x0102('0x6e')+_0xe6e097+_0x0102('0x5c')][_0x0102('0x6f')](_0x16efaf)['then'](function(){socket[_0x0102('0x70')](_0x0102('0x53')+_0xe6e097+'Queue:save',{'UserId':_0x1836c7,[_0xe6e097+_0x0102('0x6c')]:_0x1de614['id']});if(_0xe6e097!==_0x0102('0x6a'))return;return db[_0x0102('0x6e')]['findAll']({'where':{'id':_0x2f68d1['body'][_0x0102('0x61')],'online':0x1},'attributes':['id','name',_0x0102('0x71'),_0x0102('0x72'),_0x0102('0x73')],'raw':!![]})['then'](function(_0x214ba3){var _0x11962a=_[_0x0102('0x33')](_0x214ba3,function(_0x4cbffe){return db['UserVoiceQueueRt']['upsert']({'membername':_0x4cbffe[_0x0102('0x32')],'UserId':_0x4cbffe['id'],'queue_name':_0x1de614[_0x0102('0x32')],'VoiceQueueId':_0x1de614['id'],'interface':_[_0x0102('0x74')](_0x4cbffe['interface'])?util[_0x0102('0x75')](_0x0102('0x76'),_0x4cbffe['name']):_0x4cbffe[_0x0102('0x73')],'paused':_0x4cbffe[_0x0102('0x72')]||![],'penalty':_0x1de614[_0x0102('0x6d')][_0x0102('0x6b')]},{'transaction':_0x597743});});return Promise[_0x0102('0x77')](_0x11962a);});});});return Promise[_0x0102('0x77')](_0x55dbba);});return Promise[_0x0102('0x77')](_0x526808);});});return Promise[_0x0102('0x77')](_0x24d969)['then'](function(){return _0x334f9c['addAgents'](_0x2f68d1[_0x0102('0x52')]['ids'],{'transaction':_0x597743})[_0x0102('0x78')](function(_0x2b209c){return _0x2b209c;});});});}})[_0x0102('0x2b')](respondWithResult(_0x4fbd28,null))[_0x0102('0x4d')](handleError(_0x4fbd28,null));};exports[_0x0102('0x79')]=function(_0x34ae9e,_0x4e08e7){return db[_0x0102('0x34')][_0x0102('0x50')]({'where':{'id':_0x34ae9e[_0x0102('0x4f')]['id']}})[_0x0102('0x2b')](handleEntityNotFound(_0x4e08e7,null))[_0x0102('0x2b')](function(_0x5b392c){if(_0x5b392c){var _0xc6f67f=[_0x0102('0x6a'),_0x0102('0x7a'),_0x0102('0x65'),_0x0102('0x66'),_0x0102('0x67'),_0x0102('0x7b'),_0x0102('0x7c')];return db[_0x0102('0x68')][_0x0102('0x69')](function(_0x3c1c38){var _0x595076=_[_0x0102('0x33')](_0xc6f67f,function(_0x17f78c){var _0xbf910f={'attributes':['id',_0x0102('0x32')]};return _0x5b392c[_0x0102('0x2d')+_0x17f78c+'Queues'](_0xbf910f)[_0x0102('0x2b')](function(_0x2f9ff3){var _0x28fabe=_['map'](_0x2f9ff3,function(_0x1ff669){return _0x1ff669[_0x0102('0x79')](_0x34ae9e[_0x0102('0x3b')][_0x0102('0x61')],{'transaction':_0x3c1c38})[_0x0102('0x2b')](function(){var _0x3aab78=JSON['parse']('['+_0x34ae9e[_0x0102('0x3b')][_0x0102('0x61')]+']');var _0x7abb3c=_[_0x0102('0x33')](_0x3aab78,function(_0x2bc2fd){socket[_0x0102('0x70')]('user'+_0x17f78c+_0x0102('0x7d'),{'UserId':Number(_0x2bc2fd),[_0x17f78c+'QueueId']:_0x1ff669['id']});if(_0x17f78c!==_0x0102('0x6a'))return;return db[_0x0102('0x7e')][_0x0102('0x2c')]({'where':{'VoiceQueueId':_0x1ff669['id'],'UserId':_0x2bc2fd},'transaction':_0x3c1c38});});return Promise[_0x0102('0x77')](_0x7abb3c);});});return Promise[_0x0102('0x77')](_0x28fabe);});});return Promise['all'](_0x595076)[_0x0102('0x2b')](function(){return _0x5b392c['removeAgents'](_0x34ae9e[_0x0102('0x3b')]['ids'],{'transaction':_0x3c1c38});});});}})['then'](respondWithStatusCode(_0x4e08e7,null))[_0x0102('0x4d')](handleError(_0x4e08e7,null));};exports[_0x0102('0x7f')]=function(_0x4afaa0,_0x2144f4,_0x4b8b8a){var _0x355bb8={};var _0x36bec5={};var _0xd80198;var _0x405b26;return db[_0x0102('0x34')][_0x0102('0x63')]({'where':{'id':_0x4afaa0[_0x0102('0x4f')]['id']}})[_0x0102('0x2b')](handleEntityNotFound(_0x2144f4,null))[_0x0102('0x2b')](function(_0x51a07b){if(_0x51a07b){_0xd80198=_0x51a07b;_0x36bec5[_0x0102('0x39')]=_[_0x0102('0x3a')](db['User'][_0x0102('0x35')]);_0x36bec5[_0x0102('0x3b')]=_[_0x0102('0x3a')](_0x4afaa0[_0x0102('0x3b')]);_0x36bec5[_0x0102('0x3c')]=_[_0x0102('0x3d')](_0x36bec5['model'],_0x36bec5[_0x0102('0x3b')]);_0x355bb8[_0x0102('0x3e')]=_[_0x0102('0x3d')](_0x36bec5[_0x0102('0x39')],qs['fields'](_0x4afaa0[_0x0102('0x3b')]['fields']));_0x355bb8[_0x0102('0x3e')]=_0x355bb8['attributes'][_0x0102('0x40')]?_0x355bb8[_0x0102('0x3e')]:_0x36bec5[_0x0102('0x39')];_0x355bb8['order']=qs[_0x0102('0x44')](_0x4afaa0['query']['sort']);_0x355bb8[_0x0102('0x45')]=qs['filters'](_[_0x0102('0x46')](_0x4afaa0['query'],_0x36bec5[_0x0102('0x3c')]));if(_0x4afaa0[_0x0102('0x3b')]['filter']){_0x355bb8[_0x0102('0x45')]=_[_0x0102('0x49')](_0x355bb8[_0x0102('0x45')],{'$or':_[_0x0102('0x33')](_0x355bb8[_0x0102('0x3e')],function(_0x35df7d){var _0x5ba6ee={};_0x5ba6ee[_0x35df7d]={'$like':'%'+_0x4afaa0[_0x0102('0x3b')][_0x0102('0x47')]+'%'};return _0x5ba6ee;})});}_0x355bb8=_[_0x0102('0x49')]({},_0x355bb8,_0x4afaa0[_0x0102('0x4a')]);return _0xd80198[_0x0102('0x7f')](_0x355bb8);}})[_0x0102('0x2b')](function(_0x27a0fb){if(_0x27a0fb){_0x405b26=_0x27a0fb[_0x0102('0x40')];if(!_0x4afaa0[_0x0102('0x3b')][_0x0102('0x41')](_0x0102('0x42'))){_0x355bb8[_0x0102('0x24')]=qs[_0x0102('0x24')](_0x4afaa0[_0x0102('0x3b')][_0x0102('0x24')]);_0x355bb8[_0x0102('0x22')]=qs[_0x0102('0x22')](_0x4afaa0[_0x0102('0x3b')][_0x0102('0x22')]);}return _0xd80198['getAgents'](_0x355bb8);}})[_0x0102('0x2b')](function(_0x1ad36e){if(_0x1ad36e){return _0x1ad36e?{'count':_0x405b26,'rows':_0x1ad36e}:null;}})['then'](respondWithResult(_0x2144f4,null))[_0x0102('0x4d')](handleError(_0x2144f4,null));};
\ No newline at end of file
+var _0xe6f2=['OpenchannelQueueId','SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','WhatsappQueueId','UserWhatsappQueue','UserVoicePrefix','getQueues','params','channel','isValidChannel','ValidationError','Unknown\x20channel','capitalize','toLowerCase','Queue','Queues','addQueues','findOne','add','ids','removeQueues','addAgents','isArray','Voice','Chat','Mail','Sms','Fax','Openchannel','through','penalty','findOrCreate','Queue:save','QueueId','User','findAll','online','voicePause','interface','upsert','isNil','format','SIP/%s','TeamVoiceQueue','all','TeamVoicePrefix','VoicePrefixId','spread','removeAgents','emit','Queue:remove','getAgents','nolimit','eml-format','zip-dir','request-promise','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','json','offset','undefined','limit','count','reject','save','update','error','send','index','map','Team','rawAttributes','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','name','options','then','includeAll','rows','catch','show','keys','include','find','create','get','role','user','Teams','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','sequelize','transaction','Sequelize','QueryTypes','SELECT','UserId','SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20','VoiceQueueId','UserVoiceQueue','destroy','MailQueueId','UserMailQueue','SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20','SmsQueueId','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','SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20'];(function(_0x5d4c75,_0x13deae){var _0x8410b1=function(_0x3a76f3){while(--_0x3a76f3){_0x5d4c75['push'](_0x5d4c75['shift']());}};_0x8410b1(++_0x13deae);}(_0xe6f2,0xd1));var _0x2e6f=function(_0x425008,_0x21c494){_0x425008=_0x425008-0x0;var _0x5f1001=_0xe6f2[_0x425008];return _0x5f1001;};'use strict';var emlformat=require(_0x2e6f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x2e6f('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x2e6f('0x2'));var moment=require('moment');var BPromise=require(_0x2e6f('0x3'));var Mustache=require(_0x2e6f('0x4'));var util=require(_0x2e6f('0x5'));var path=require(_0x2e6f('0x6'));var sox=require('sox');var csv=require(_0x2e6f('0x7'));var ejs=require(_0x2e6f('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x2e6f('0x9'));var squel=require(_0x2e6f('0xa'));var crypto=require(_0x2e6f('0xb'));var jsforce=require(_0x2e6f('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x2e6f('0xd'));var Papa=require(_0x2e6f('0xe'));var Redis=require(_0x2e6f('0xf'));var authService=require(_0x2e6f('0x10'));var qs=require(_0x2e6f('0x11'));var as=require(_0x2e6f('0x12'));var hardwareService=require(_0x2e6f('0x13'));var logger=require(_0x2e6f('0x14'))(_0x2e6f('0x15'));var utils=require(_0x2e6f('0x16'));var config=require(_0x2e6f('0x17'));var licenseUtil=require(_0x2e6f('0x18'));var db=require(_0x2e6f('0x19'))['db'];config[_0x2e6f('0x1a')]=_[_0x2e6f('0x1b')](config[_0x2e6f('0x1a')],{'host':_0x2e6f('0x1c'),'port':0x18eb});var socket=require(_0x2e6f('0x1d'))(new Redis(config[_0x2e6f('0x1a')]));require('./team.socket')[_0x2e6f('0x1e')](socket);function respondWithStatusCode(_0x3400b9,_0x2bb0c3){_0x2bb0c3=_0x2bb0c3||0xcc;return function(_0x2fd653){if(_0x2fd653){return _0x3400b9[_0x2e6f('0x1f')](_0x2bb0c3);}return _0x3400b9['status'](_0x2bb0c3)['end']();};}function respondWithResult(_0x25eafa,_0x51e74e){_0x51e74e=_0x51e74e||0xc8;return function(_0x24b925){if(_0x24b925){return _0x25eafa[_0x2e6f('0x20')](_0x51e74e)[_0x2e6f('0x21')](_0x24b925);}};}function respondWithFilteredResult(_0x3d04d5,_0x3973d0){return function(_0x514283){if(_0x514283){var _0x10d424=typeof _0x3973d0[_0x2e6f('0x22')]===_0x2e6f('0x23')&&typeof _0x3973d0[_0x2e6f('0x24')]===_0x2e6f('0x23');var _0x4ba1ed=_0x514283['count'];var _0xe0d2c7=_0x10d424?0x0:_0x3973d0[_0x2e6f('0x22')];var _0x1b0115=_0x10d424?_0x514283[_0x2e6f('0x25')]:_0x3973d0[_0x2e6f('0x22')]+_0x3973d0[_0x2e6f('0x24')];var _0x5f25dc;if(_0x1b0115>=_0x4ba1ed){_0x1b0115=_0x4ba1ed;_0x5f25dc=0xc8;}else{_0x5f25dc=0xce;}_0x3d04d5[_0x2e6f('0x20')](_0x5f25dc);return _0x3d04d5['set']('Content-Range',_0xe0d2c7+'-'+_0x1b0115+'/'+_0x4ba1ed)['json'](_0x514283);}return null;};}function patchUpdates(_0x2c09b2){return function(_0x3ad924){try{jsonpatch['apply'](_0x3ad924,_0x2c09b2,!![]);}catch(_0xbba393){return BPromise[_0x2e6f('0x26')](_0xbba393);}return _0x3ad924[_0x2e6f('0x27')]();};}function saveUpdates(_0xf91ba2,_0x122801){return function(_0x22ac15){if(_0x22ac15){return _0x22ac15[_0x2e6f('0x28')](_0xf91ba2)['then'](function(_0x44c26c){return _0x44c26c;});}return null;};}function handleEntityNotFound(_0x2bc517,_0x48385e){return function(_0x2ddd71){if(!_0x2ddd71){_0x2bc517['sendStatus'](0x194);}return _0x2ddd71;};}function handleError(_0xf66b89,_0x5e637f){_0x5e637f=_0x5e637f||0x1f4;return function(_0x596c04){logger[_0x2e6f('0x29')](_0x596c04['stack']);if(_0x596c04['name']){delete _0x596c04['name'];}_0xf66b89[_0x2e6f('0x20')](_0x5e637f)[_0x2e6f('0x2a')](_0x596c04);};}exports[_0x2e6f('0x2b')]=function(_0x47c2de,_0x21bd3e){var _0x45f12a={},_0x4a9cce={},_0x175e97={'count':0x0,'rows':[]};var _0x320b30=_[_0x2e6f('0x2c')](db[_0x2e6f('0x2d')][_0x2e6f('0x2e')],function(_0x26e42b){return{'name':_0x26e42b['fieldName'],'type':_0x26e42b[_0x2e6f('0x2f')][_0x2e6f('0x30')]};});_0x4a9cce[_0x2e6f('0x31')]=_[_0x2e6f('0x2c')](_0x320b30,'name');_0x4a9cce[_0x2e6f('0x32')]=_['keys'](_0x47c2de[_0x2e6f('0x32')]);_0x4a9cce[_0x2e6f('0x33')]=_[_0x2e6f('0x34')](_0x4a9cce[_0x2e6f('0x31')],_0x4a9cce['query']);_0x45f12a['attributes']=_[_0x2e6f('0x34')](_0x4a9cce[_0x2e6f('0x31')],qs[_0x2e6f('0x35')](_0x47c2de[_0x2e6f('0x32')][_0x2e6f('0x35')]));_0x45f12a['attributes']=_0x45f12a[_0x2e6f('0x36')][_0x2e6f('0x37')]?_0x45f12a['attributes']:_0x4a9cce['model'];if(!_0x47c2de[_0x2e6f('0x32')][_0x2e6f('0x38')]('nolimit')){_0x45f12a[_0x2e6f('0x24')]=qs['limit'](_0x47c2de[_0x2e6f('0x32')][_0x2e6f('0x24')]);_0x45f12a[_0x2e6f('0x22')]=qs[_0x2e6f('0x22')](_0x47c2de[_0x2e6f('0x32')][_0x2e6f('0x22')]);}_0x45f12a[_0x2e6f('0x39')]=qs[_0x2e6f('0x3a')](_0x47c2de[_0x2e6f('0x32')]['sort']);_0x45f12a[_0x2e6f('0x3b')]=qs[_0x2e6f('0x33')](_[_0x2e6f('0x3c')](_0x47c2de[_0x2e6f('0x32')],_0x4a9cce[_0x2e6f('0x33')]),_0x320b30);if(_0x47c2de[_0x2e6f('0x32')][_0x2e6f('0x3d')]){_0x45f12a[_0x2e6f('0x3b')]=_[_0x2e6f('0x3e')](_0x45f12a[_0x2e6f('0x3b')],{'$or':_['map'](_0x320b30,function(_0x550604){if(_0x550604[_0x2e6f('0x2f')]!==_0x2e6f('0x3f')){var _0x5dc99c={};_0x5dc99c[_0x550604[_0x2e6f('0x40')]]={'$like':'%'+_0x47c2de['query'][_0x2e6f('0x3d')]+'%'};return _0x5dc99c;}})});}_0x45f12a=_[_0x2e6f('0x3e')]({},_0x45f12a,_0x47c2de[_0x2e6f('0x41')]);var _0x6a911b={'where':_0x45f12a[_0x2e6f('0x3b')]};return db[_0x2e6f('0x2d')]['count'](_0x6a911b)[_0x2e6f('0x42')](function(_0x505268){_0x175e97[_0x2e6f('0x25')]=_0x505268;if(_0x47c2de[_0x2e6f('0x32')][_0x2e6f('0x43')]){_0x45f12a['include']=[{'all':!![]}];}return db[_0x2e6f('0x2d')]['findAll'](_0x45f12a);})['then'](function(_0x1334e6){_0x175e97[_0x2e6f('0x44')]=_0x1334e6;return _0x175e97;})[_0x2e6f('0x42')](respondWithFilteredResult(_0x21bd3e,_0x45f12a))[_0x2e6f('0x45')](handleError(_0x21bd3e,null));};exports[_0x2e6f('0x46')]=function(_0x437716,_0x22c396){var _0x5837b3={'raw':![],'where':{'id':_0x437716['params']['id']}},_0x1bc063={};_0x1bc063[_0x2e6f('0x31')]=_[_0x2e6f('0x47')](db[_0x2e6f('0x2d')][_0x2e6f('0x2e')]);_0x1bc063['query']=_[_0x2e6f('0x47')](_0x437716['query']);_0x1bc063['filters']=_[_0x2e6f('0x34')](_0x1bc063['model'],_0x1bc063[_0x2e6f('0x32')]);_0x5837b3[_0x2e6f('0x36')]=_[_0x2e6f('0x34')](_0x1bc063[_0x2e6f('0x31')],qs[_0x2e6f('0x35')](_0x437716[_0x2e6f('0x32')][_0x2e6f('0x35')]));_0x5837b3[_0x2e6f('0x36')]=_0x5837b3[_0x2e6f('0x36')]['length']?_0x5837b3[_0x2e6f('0x36')]:_0x1bc063[_0x2e6f('0x31')];if(_0x437716[_0x2e6f('0x32')][_0x2e6f('0x43')]){_0x5837b3[_0x2e6f('0x48')]=[{'all':!![]}];}_0x5837b3=_[_0x2e6f('0x3e')]({},_0x5837b3,_0x437716[_0x2e6f('0x41')]);return db[_0x2e6f('0x2d')][_0x2e6f('0x49')](_0x5837b3)['then'](handleEntityNotFound(_0x22c396,null))[_0x2e6f('0x42')](respondWithResult(_0x22c396,null))[_0x2e6f('0x45')](handleError(_0x22c396,null));};exports[_0x2e6f('0x4a')]=function(_0x478a6c,_0xad246){return db['Team'][_0x2e6f('0x4a')](_0x478a6c['body'],{})[_0x2e6f('0x42')](function(_0x391e58){var _0x3d9741=_0x478a6c['user'][_0x2e6f('0x4b')]({'plain':!![]});if(!_0x3d9741)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3d9741[_0x2e6f('0x4c')]===_0x2e6f('0x4d')){var _0x15c585=_0x391e58[_0x2e6f('0x4b')]({'plain':!![]});var _0x528271=_0x2e6f('0x4e');return db[_0x2e6f('0x4f')][_0x2e6f('0x49')]({'where':{'name':_0x528271,'userProfileId':_0x3d9741[_0x2e6f('0x50')]},'raw':!![]})[_0x2e6f('0x42')](function(_0x212e40){if(_0x212e40&&_0x212e40[_0x2e6f('0x51')]===0x0){return db[_0x2e6f('0x52')]['create']({'name':_0x15c585[_0x2e6f('0x40')],'resourceId':_0x15c585['id'],'type':_0x212e40[_0x2e6f('0x40')],'sectionId':_0x212e40['id']},{})[_0x2e6f('0x42')](function(){return _0x391e58;});}else{return _0x391e58;}})[_0x2e6f('0x45')](function(_0x23f9de){logger[_0x2e6f('0x29')](_0x2e6f('0x53'),_0x23f9de);throw _0x23f9de;});}return _0x391e58;})[_0x2e6f('0x42')](respondWithResult(_0xad246,0xc9))[_0x2e6f('0x45')](handleError(_0xad246,null));};exports[_0x2e6f('0x28')]=function(_0x16722c,_0x5c4172){if(_0x16722c['body']['id']){delete _0x16722c['body']['id'];}return db[_0x2e6f('0x2d')][_0x2e6f('0x49')]({'where':{'id':_0x16722c['params']['id']}})[_0x2e6f('0x42')](handleEntityNotFound(_0x5c4172,null))[_0x2e6f('0x42')](saveUpdates(_0x16722c[_0x2e6f('0x54')],null))[_0x2e6f('0x42')](respondWithResult(_0x5c4172,null))[_0x2e6f('0x45')](handleError(_0x5c4172,null));};exports['destroy']=function(_0x111239,_0x48d883){var _0x20af16=_0x111239['params']['id'];var _0x50f657=[];return db[_0x2e6f('0x55')][_0x2e6f('0x56')](function(_0x4ef695){var _0x4e1703='SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20'+_0x20af16;return db[_0x2e6f('0x55')][_0x2e6f('0x32')](_0x4e1703,{'type':db[_0x2e6f('0x57')][_0x2e6f('0x58')][_0x2e6f('0x59')],'raw':!![],'transaction':_0x4ef695})[_0x2e6f('0x42')](function(_0x55479a){_0x50f657=_['map'](_0x55479a,function(_0x9f2d20){return Number(_0x9f2d20[_0x2e6f('0x5a')]);});})[_0x2e6f('0x42')](function(){var _0x21c807=_0x2e6f('0x5b')+_0x20af16;return db[_0x2e6f('0x55')]['query'](_0x21c807,{'type':db['Sequelize'][_0x2e6f('0x58')][_0x2e6f('0x59')],'raw':!![],'transaction':_0x4ef695});})['then'](function(_0x2f70ef){var _0x9bfcb=_[_0x2e6f('0x2c')](_0x2f70ef,function(_0x2ee20a){return Number(_0x2ee20a[_0x2e6f('0x5c')]);});return db[_0x2e6f('0x5d')][_0x2e6f('0x5e')]({'where':{'UserId':{'$in':_0x50f657},'VoiceQueueId':{'$in':_0x9bfcb}},'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(){var _0x4f13a8='SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20'+_0x20af16;return db[_0x2e6f('0x55')][_0x2e6f('0x32')](_0x4f13a8,{'type':db[_0x2e6f('0x57')]['QueryTypes'][_0x2e6f('0x59')],'raw':!![],'transaction':_0x4ef695});})['then'](function(_0x51da1d){var _0x55938e=_[_0x2e6f('0x2c')](_0x51da1d,function(_0x420981){return Number(_0x420981[_0x2e6f('0x5f')]);});return db[_0x2e6f('0x60')][_0x2e6f('0x5e')]({'where':{'UserId':{'$in':_0x50f657},'MailQueueId':{'$in':_0x55938e}},'transaction':_0x4ef695});})['then'](function(){var _0x362a26=_0x2e6f('0x61')+_0x20af16;return db[_0x2e6f('0x55')][_0x2e6f('0x32')](_0x362a26,{'type':db[_0x2e6f('0x57')][_0x2e6f('0x58')]['SELECT'],'raw':!![],'transaction':_0x4ef695});})['then'](function(_0x16a420){var _0x127ebe=_[_0x2e6f('0x2c')](_0x16a420,function(_0x2d0845){return Number(_0x2d0845[_0x2e6f('0x62')]);});return db[_0x2e6f('0x63')]['destroy']({'where':{'UserId':{'$in':_0x50f657},'SmsQueueId':{'$in':_0x127ebe}},'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(){var _0x35ada3=_0x2e6f('0x64')+_0x20af16;return db[_0x2e6f('0x55')][_0x2e6f('0x32')](_0x35ada3,{'type':db[_0x2e6f('0x57')]['QueryTypes']['SELECT'],'raw':!![],'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(_0x1d41e7){var _0x4c7798=_['map'](_0x1d41e7,function(_0x5ce265){return Number(_0x5ce265[_0x2e6f('0x65')]);});return db[_0x2e6f('0x66')][_0x2e6f('0x5e')]({'where':{'UserId':{'$in':_0x50f657},'ChatQueueId':{'$in':_0x4c7798}},'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(){var _0x2b88b2=_0x2e6f('0x67')+_0x20af16;return db[_0x2e6f('0x55')][_0x2e6f('0x32')](_0x2b88b2,{'type':db[_0x2e6f('0x57')][_0x2e6f('0x58')][_0x2e6f('0x59')],'raw':!![],'transaction':_0x4ef695});})['then'](function(_0x510221){var _0x13b788=_['map'](_0x510221,function(_0x2660b8){return Number(_0x2660b8['FaxQueueId']);});return db['UserFaxQueue']['destroy']({'where':{'UserId':{'$in':_0x50f657},'FaxQueueId':{'$in':_0x13b788}},'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(){var _0x523846=_0x2e6f('0x68')+_0x20af16;return db[_0x2e6f('0x55')][_0x2e6f('0x32')](_0x523846,{'type':db['Sequelize'][_0x2e6f('0x58')]['SELECT'],'raw':!![],'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(_0x27ac86){var _0x4ebce4=_['map'](_0x27ac86,function(_0x3f719b){return Number(_0x3f719b[_0x2e6f('0x69')]);});return db['UserOpenchannelQueue']['destroy']({'where':{'UserId':{'$in':_0x50f657},'OpenchannelQueueId':{'$in':_0x4ebce4}},'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(){var _0x1ce2c1=_0x2e6f('0x6a')+_0x20af16;return db[_0x2e6f('0x55')][_0x2e6f('0x32')](_0x1ce2c1,{'type':db['Sequelize'][_0x2e6f('0x58')][_0x2e6f('0x59')],'raw':!![],'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(_0x33f6f4){var _0x2de16c=_[_0x2e6f('0x2c')](_0x33f6f4,function(_0xf75eee){return Number(_0xf75eee[_0x2e6f('0x6b')]);});return db[_0x2e6f('0x6c')][_0x2e6f('0x5e')]({'where':{'UserId':{'$in':_0x50f657},'WhatsappQueueId':{'$in':_0x2de16c}},'transaction':_0x4ef695});})['then'](function(){return db['TeamVoicePrefix'][_0x2e6f('0x49')]({'where':{'TeamId':_0x20af16}});})[_0x2e6f('0x42')](function(_0x37906a){if(_0x37906a===null){return;}return db[_0x2e6f('0x6d')][_0x2e6f('0x5e')]({'where':{'UserId':{'$in':_0x50f657},'VoicePrefixId':_0x37906a['VoicePrefixId']},'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(){return db['Team'][_0x2e6f('0x5e')]({'where':{'id':_0x20af16},'cascade':!![],'transaction':_0x4ef695});})[_0x2e6f('0x42')](function(_0x313e1a){if(_0x313e1a===0x0){_0x48d883[_0x2e6f('0x1f')](0x194);}else{return db[_0x2e6f('0x52')][_0x2e6f('0x5e')]({'where':{'type':_0x2e6f('0x4e'),'resourceId':_0x20af16},'cascade':!![],'transaction':_0x4ef695})[_0x2e6f('0x42')](function(){_0x48d883[_0x2e6f('0x20')](0xcc)['end']();});}})[_0x2e6f('0x45')](function(_0x5dd798){_0x48d883[_0x2e6f('0x20')](0x1f4)[_0x2e6f('0x2a')](_0x5dd798);});});};exports[_0x2e6f('0x6e')]=function(_0xaec12b,_0x1be033,_0x1e0a02){return db[_0x2e6f('0x2d')]['findOne']({'where':{'id':_0xaec12b[_0x2e6f('0x6f')]['id']}})[_0x2e6f('0x42')](handleEntityNotFound(_0x1be033,null))[_0x2e6f('0x42')](function(_0xa44446){if(!_0xaec12b[_0x2e6f('0x32')][_0x2e6f('0x70')]||!utils[_0x2e6f('0x71')](_0xaec12b['query']['channel'])){throw new db[(_0x2e6f('0x57'))][(_0x2e6f('0x72'))](_0x2e6f('0x73'));}var _0x2364b1={};var _0x34c8b1={};_0x34c8b1[_0x2e6f('0x31')]=_['keys'](db[_[_0x2e6f('0x74')](_0xaec12b[_0x2e6f('0x32')][_0x2e6f('0x70')][_0x2e6f('0x75')]())+_0x2e6f('0x76')][_0x2e6f('0x2e')]);_0x34c8b1['query']=_['keys'](_0xaec12b[_0x2e6f('0x32')]);_0x34c8b1[_0x2e6f('0x33')]=_[_0x2e6f('0x34')](_0x34c8b1[_0x2e6f('0x31')],_0x34c8b1[_0x2e6f('0x32')]);_0x2364b1['attributes']=_[_0x2e6f('0x34')](_0x34c8b1[_0x2e6f('0x31')],qs['fields'](_0xaec12b['query'][_0x2e6f('0x35')]));_0x2364b1[_0x2e6f('0x36')]=_0x2364b1['attributes'][_0x2e6f('0x37')]?_0x2364b1[_0x2e6f('0x36')]:_0x34c8b1['model'];_0x2364b1[_0x2e6f('0x24')]=qs[_0x2e6f('0x24')](_0xaec12b[_0x2e6f('0x32')][_0x2e6f('0x24')]);_0x2364b1[_0x2e6f('0x22')]=qs[_0x2e6f('0x22')](_0xaec12b[_0x2e6f('0x32')]['offset']);_0x2364b1['order']=qs[_0x2e6f('0x3a')](_0xaec12b['query'][_0x2e6f('0x3a')]);_0x2364b1[_0x2e6f('0x3b')]=qs[_0x2e6f('0x33')](_[_0x2e6f('0x3c')](_0xaec12b[_0x2e6f('0x32')],_0x34c8b1[_0x2e6f('0x33')]));_0x2364b1=_[_0x2e6f('0x3e')]({},_0x2364b1,_0xaec12b['options']);return _0xa44446[_0x2e6f('0x4b')+_[_0x2e6f('0x74')](_0xaec12b['query'][_0x2e6f('0x70')][_0x2e6f('0x75')]())+_0x2e6f('0x77')](_0x2364b1);})[_0x2e6f('0x42')](respondWithResult(_0x1be033,null))[_0x2e6f('0x45')](handleError(_0x1be033,null));};exports[_0x2e6f('0x78')]=function(_0x4d44ff,_0x28bcab,_0x1d87a6){return db[_0x2e6f('0x2d')][_0x2e6f('0x79')]({'where':{'id':_0x4d44ff[_0x2e6f('0x6f')]['id']}})[_0x2e6f('0x42')](function(_0x2b92ea){if(_0x2b92ea){if(!_0x4d44ff['body']['channel']||!utils[_0x2e6f('0x71')](_0x4d44ff[_0x2e6f('0x54')][_0x2e6f('0x70')])){throw new db[(_0x2e6f('0x57'))]['ValidationError'](_0x2e6f('0x73'));}return _0x2b92ea[_0x2e6f('0x7a')+_[_0x2e6f('0x74')](_0x4d44ff[_0x2e6f('0x54')][_0x2e6f('0x70')]['toLowerCase']())+'Queues'](_0x4d44ff[_0x2e6f('0x54')][_0x2e6f('0x7b')]);}return null;})[_0x2e6f('0x42')](handleEntityNotFound(_0x28bcab,null))[_0x2e6f('0x42')](respondWithStatusCode(_0x28bcab,null))['catch'](handleError(_0x28bcab,null));};exports[_0x2e6f('0x7c')]=function(_0x38b3bb,_0xff83,_0x55eff2){return db['Team'][_0x2e6f('0x79')]({'where':{'id':_0x38b3bb['params']['id']}})['then'](function(_0xbdd00c){if(_0xbdd00c){if(!_0x38b3bb[_0x2e6f('0x32')]['channel']||!utils[_0x2e6f('0x71')](_0x38b3bb[_0x2e6f('0x32')][_0x2e6f('0x70')])){throw new db[(_0x2e6f('0x57'))][(_0x2e6f('0x72'))](_0x2e6f('0x73'));}return _0xbdd00c['remove'+_['capitalize'](_0x38b3bb[_0x2e6f('0x32')]['channel'][_0x2e6f('0x75')]())+_0x2e6f('0x77')](_0x38b3bb['query']['ids']);}return null;})[_0x2e6f('0x42')](handleEntityNotFound(_0xff83,null))[_0x2e6f('0x42')](respondWithStatusCode(_0xff83,null))[_0x2e6f('0x45')](handleError(_0xff83,null));};exports[_0x2e6f('0x7d')]=function(_0xd9b351,_0x2b92f2){var _0x586bd0=_[_0x2e6f('0x7e')](_0xd9b351[_0x2e6f('0x54')][_0x2e6f('0x7b')])?_0xd9b351[_0x2e6f('0x54')][_0x2e6f('0x7b')]:[_0xd9b351[_0x2e6f('0x54')][_0x2e6f('0x7b')]];var _0x8d2f7d=_0xd9b351['params']['id'];return db[_0x2e6f('0x2d')][_0x2e6f('0x49')]({'where':{'id':_0x8d2f7d}})[_0x2e6f('0x42')](handleEntityNotFound(_0x2b92f2,null))[_0x2e6f('0x42')](function(_0x527033){if(_0x527033){var _0x5a35cf=[_0x2e6f('0x7f'),_0x2e6f('0x80'),_0x2e6f('0x81'),_0x2e6f('0x82'),_0x2e6f('0x83'),_0x2e6f('0x84'),'Whatsapp'];return db[_0x2e6f('0x55')][_0x2e6f('0x56')](function(_0x17e639){var _0x451945=_[_0x2e6f('0x2c')](_0x5a35cf,function(_0x1f7bbc){var _0x28b867={'attributes':['id',_0x2e6f('0x40')]};if(_0x1f7bbc==='Voice'){_0x28b867[_0x2e6f('0x85')]={'attributes':[_0x2e6f('0x86')]};}return _0x527033[_0x2e6f('0x4b')+_0x1f7bbc+_0x2e6f('0x77')](_0x28b867)['then'](function(_0x521ee1){var _0x1cc5c8=_['map'](_0x521ee1,function(_0x5384d8){var _0x3613c6=_[_0x2e6f('0x2c')](_0x586bd0,function(_0x59777f){var _0x40be94={'where':{'UserId':_0x59777f,[_0x1f7bbc+'QueueId']:_0x5384d8['id']},'transaction':_0x17e639};if(_0x1f7bbc===_0x2e6f('0x7f')){_0x40be94[_0x2e6f('0x1b')]={'penalty':_0x5384d8['TeamVoiceQueue']['penalty']};}return db['User'+_0x1f7bbc+_0x2e6f('0x76')][_0x2e6f('0x87')](_0x40be94)['then'](function(){socket['emit'](_0x2e6f('0x4d')+_0x1f7bbc+_0x2e6f('0x88'),{'UserId':_0x59777f,[_0x1f7bbc+_0x2e6f('0x89')]:_0x5384d8['id']});if(_0x1f7bbc!==_0x2e6f('0x7f')){return;}return db[_0x2e6f('0x8a')][_0x2e6f('0x8b')]({'where':{'id':_0x586bd0,'online':0x1},'attributes':['id',_0x2e6f('0x40'),_0x2e6f('0x8c'),_0x2e6f('0x8d'),_0x2e6f('0x8e')],'raw':!![]})[_0x2e6f('0x42')](function(_0x934108){var _0x359891=_[_0x2e6f('0x2c')](_0x934108,function(_0xddc7fe){return db['UserVoiceQueueRt'][_0x2e6f('0x8f')]({'membername':_0xddc7fe[_0x2e6f('0x40')],'UserId':_0xddc7fe['id'],'queue_name':_0x5384d8['name'],'VoiceQueueId':_0x5384d8['id'],'interface':_[_0x2e6f('0x90')](_0xddc7fe[_0x2e6f('0x8e')])?util[_0x2e6f('0x91')](_0x2e6f('0x92'),_0xddc7fe['name']):_0xddc7fe[_0x2e6f('0x8e')],'paused':_0xddc7fe[_0x2e6f('0x8d')]||![],'penalty':_0x5384d8[_0x2e6f('0x93')]['penalty']},{'transaction':_0x17e639});});return Promise[_0x2e6f('0x94')](_0x359891);});});});return Promise[_0x2e6f('0x94')](_0x3613c6);});return Promise[_0x2e6f('0x94')](_0x1cc5c8);})[_0x2e6f('0x42')](function(){return db[_0x2e6f('0x95')][_0x2e6f('0x79')]({'where':{'teamId':_0x8d2f7d}})[_0x2e6f('0x42')](function(_0x5e1def){if(_0x5e1def){var _0x3906d6=_[_0x2e6f('0x2c')](_0x586bd0,function(_0x588039){db['UserVoicePrefix'][_0x2e6f('0x8f')]({'UserId':_0x588039,'VoicePrefixId':_0x5e1def[_0x2e6f('0x96')]});});return Promise[_0x2e6f('0x94')](_0x3906d6);}});});});return Promise[_0x2e6f('0x94')](_0x451945)[_0x2e6f('0x42')](function(){return _0x527033[_0x2e6f('0x7d')](_0x586bd0,{'transaction':_0x17e639})[_0x2e6f('0x97')](function(_0x475538){return _0x475538;});});});}})[_0x2e6f('0x42')](respondWithResult(_0x2b92f2,null))[_0x2e6f('0x45')](handleError(_0x2b92f2,null));};exports[_0x2e6f('0x98')]=function(_0x436911,_0x1c5978){var _0x3ca774=_[_0x2e6f('0x7e')](_0x436911[_0x2e6f('0x32')]['ids'])?_0x436911[_0x2e6f('0x32')][_0x2e6f('0x7b')]:[_0x436911[_0x2e6f('0x32')][_0x2e6f('0x7b')]];var _0xbb7d32=_0x436911[_0x2e6f('0x6f')]['id'];return db[_0x2e6f('0x2d')][_0x2e6f('0x49')]({'where':{'id':_0xbb7d32}})[_0x2e6f('0x42')](handleEntityNotFound(_0x1c5978,null))[_0x2e6f('0x42')](function(_0x30bb2b){if(_0x30bb2b){var _0x26c06d=[_0x2e6f('0x7f'),_0x2e6f('0x80'),_0x2e6f('0x81'),_0x2e6f('0x82'),_0x2e6f('0x83'),_0x2e6f('0x84'),'Whatsapp'];return db[_0x2e6f('0x55')][_0x2e6f('0x56')](function(_0x5dde5c){var _0x2191f3=_['map'](_0x26c06d,function(_0x42496d){var _0x24d158={'attributes':['id',_0x2e6f('0x40')]};return _0x30bb2b[_0x2e6f('0x4b')+_0x42496d+'Queues'](_0x24d158)['then'](function(_0x334575){var _0x54645d=_[_0x2e6f('0x2c')](_0x334575,function(_0x445d16){return _0x445d16[_0x2e6f('0x98')](_0x3ca774,{'transaction':_0x5dde5c})['then'](function(){var _0x902beb=_[_0x2e6f('0x2c')](_0x3ca774,function(_0x1670ab){socket[_0x2e6f('0x99')](_0x2e6f('0x4d')+_0x42496d+_0x2e6f('0x9a'),{'UserId':Number(_0x1670ab),[_0x42496d+_0x2e6f('0x89')]:_0x445d16['id']});if(_0x42496d!==_0x2e6f('0x7f')){return;}return db['UserVoiceQueueRt'][_0x2e6f('0x5e')]({'where':{'VoiceQueueId':_0x445d16['id'],'UserId':_0x1670ab},'transaction':_0x5dde5c});});return Promise[_0x2e6f('0x94')](_0x902beb);});});return Promise[_0x2e6f('0x94')](_0x54645d);});});return Promise[_0x2e6f('0x94')](_0x2191f3)['then'](function(){return _0x30bb2b[_0x2e6f('0x98')](_0x3ca774,{'transaction':_0x5dde5c});})[_0x2e6f('0x42')](function(){return db[_0x2e6f('0x95')][_0x2e6f('0x79')]({'where':{'teamId':_0xbb7d32}})['then'](function(_0x24b7a3){if(_0x24b7a3){var _0x104c1b=_[_0x2e6f('0x2c')](_0x3ca774,function(_0x432a35){db[_0x2e6f('0x6d')][_0x2e6f('0x5e')]({'where':{'UserId':_0x432a35,'VoicePrefixId':_0x24b7a3['VoicePrefixId']}});});return Promise[_0x2e6f('0x94')](_0x104c1b);}});});});}})['then'](respondWithStatusCode(_0x1c5978,null))[_0x2e6f('0x45')](handleError(_0x1c5978,null));};exports[_0x2e6f('0x9b')]=function(_0x3ad053,_0x5ece8f,_0x1b8ca7){var _0x50b9af={};var _0x3dccca={};var _0x319014;var _0xef33de;return db[_0x2e6f('0x2d')]['findOne']({'where':{'id':_0x3ad053[_0x2e6f('0x6f')]['id']}})[_0x2e6f('0x42')](handleEntityNotFound(_0x5ece8f,null))[_0x2e6f('0x42')](function(_0x317523){if(_0x317523){_0x319014=_0x317523;_0x3dccca[_0x2e6f('0x31')]=_['keys'](db[_0x2e6f('0x8a')][_0x2e6f('0x2e')]);_0x3dccca[_0x2e6f('0x32')]=_[_0x2e6f('0x47')](_0x3ad053[_0x2e6f('0x32')]);_0x3dccca['filters']=_[_0x2e6f('0x34')](_0x3dccca['model'],_0x3dccca[_0x2e6f('0x32')]);_0x50b9af[_0x2e6f('0x36')]=_[_0x2e6f('0x34')](_0x3dccca['model'],qs[_0x2e6f('0x35')](_0x3ad053['query'][_0x2e6f('0x35')]));_0x50b9af['attributes']=_0x50b9af[_0x2e6f('0x36')][_0x2e6f('0x37')]?_0x50b9af[_0x2e6f('0x36')]:_0x3dccca[_0x2e6f('0x31')];_0x50b9af['order']=qs[_0x2e6f('0x3a')](_0x3ad053['query'][_0x2e6f('0x3a')]);_0x50b9af[_0x2e6f('0x3b')]=qs[_0x2e6f('0x33')](_[_0x2e6f('0x3c')](_0x3ad053['query'],_0x3dccca[_0x2e6f('0x33')]));if(_0x3ad053[_0x2e6f('0x32')][_0x2e6f('0x3d')]){_0x50b9af[_0x2e6f('0x3b')]=_[_0x2e6f('0x3e')](_0x50b9af[_0x2e6f('0x3b')],{'$or':_['map'](_0x50b9af['attributes'],function(_0x325a4c){var _0x93fdf6={};_0x93fdf6[_0x325a4c]={'$like':'%'+_0x3ad053[_0x2e6f('0x32')]['filter']+'%'};return _0x93fdf6;})});}_0x50b9af=_['merge']({},_0x50b9af,_0x3ad053['options']);return _0x319014[_0x2e6f('0x9b')](_0x50b9af);}})[_0x2e6f('0x42')](function(_0x2c1284){if(_0x2c1284){_0xef33de=_0x2c1284[_0x2e6f('0x37')];if(!_0x3ad053['query'][_0x2e6f('0x38')](_0x2e6f('0x9c'))){_0x50b9af[_0x2e6f('0x24')]=qs[_0x2e6f('0x24')](_0x3ad053['query'][_0x2e6f('0x24')]);_0x50b9af[_0x2e6f('0x22')]=qs[_0x2e6f('0x22')](_0x3ad053[_0x2e6f('0x32')]['offset']);}return _0x319014['getAgents'](_0x50b9af);}})[_0x2e6f('0x42')](function(_0x1f8273){if(_0x1f8273){return _0x1f8273?{'count':_0xef33de,'rows':_0x1f8273}:null;}})[_0x2e6f('0x42')](respondWithResult(_0x5ece8f,null))[_0x2e6f('0x45')](handleError(_0x5ece8f,null));};
\ No newline at end of file