Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / team / team.controller.js
index 0879a16..04748ee 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf555=['filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','limit','order','sort','pick','filter','merge','where','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','user','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','findOne','channel','isValidChannel','Sequelize','Unknown\x20channel','toLowerCase','Queue','get','capitalize','addQueues','ValidationError','add','Queues','ids','removeQueues','addAgents','Voice','Chat','Mail','Fax','Openchannel','Whatsapp','each','online','voicePause','interface','UserVoiceQueueRt','isNil','format','SIP/%s','spread','emit','removeAgents','voice','chat','mail','whatsapp','isArray','userTeam:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','sox','to-csv','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','register','sendStatus','status','end','json','count','offset','set','Content-Range','apply','save','update','then','destroy','Teams','UserProfileResource','error','stack','name','index','map','Team','rawAttributes','fieldName','type','key','model','query','keys'];(function(_0x37bd26,_0x5ad346){var _0xe83dc4=function(_0x1ac229){while(--_0x1ac229){_0x37bd26['push'](_0x37bd26['shift']());}};_0xe83dc4(++_0x5ad346);}(_0xf555,0xc1));var _0x5f55=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xf555[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0x5f55('0x0'));var emlformat=require(_0x5f55('0x1'));var rimraf=require(_0x5f55('0x2'));var zipdir=require(_0x5f55('0x3'));var jsonpatch=require(_0x5f55('0x4'));var rp=require('request-promise');var moment=require(_0x5f55('0x5'));var BPromise=require(_0x5f55('0x6'));var Mustache=require(_0x5f55('0x7'));var util=require('util');var path=require('path');var sox=require(_0x5f55('0x8'));var csv=require(_0x5f55('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x5f55('0xa'));var crypto=require('crypto');var jsforce=require(_0x5f55('0xb'));var deskjs=require(_0x5f55('0xc'));var toCsv=require(_0x5f55('0x9'));var querystring=require(_0x5f55('0xd'));var Papa=require('papaparse');var Redis=require(_0x5f55('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x5f55('0xf'));var as=require(_0x5f55('0x10'));var hardwareService=require(_0x5f55('0x11'));var logger=require('../../config/logger')('api');var utils=require(_0x5f55('0x12'));var config=require(_0x5f55('0x13'));var db=require(_0x5f55('0x14'))['db'];config[_0x5f55('0x15')]=_[_0x5f55('0x16')](config[_0x5f55('0x15')],{'host':'localhost','port':0x18eb});var socket=require(_0x5f55('0x17'))(new Redis(config['redis']));require('./team.socket')[_0x5f55('0x18')](socket);function respondWithStatusCode(_0x5d62e1,_0x590a5f){_0x590a5f=_0x590a5f||0xcc;return function(_0x1303e6){if(_0x1303e6){return _0x5d62e1[_0x5f55('0x19')](_0x590a5f);}return _0x5d62e1[_0x5f55('0x1a')](_0x590a5f)[_0x5f55('0x1b')]();};}function respondWithResult(_0x494c64,_0x1cbc93){_0x1cbc93=_0x1cbc93||0xc8;return function(_0x4e6487){if(_0x4e6487){return _0x494c64['status'](_0x1cbc93)[_0x5f55('0x1c')](_0x4e6487);}};}function respondWithFilteredResult(_0x16a1d2,_0xe86740){return function(_0x55220a){if(_0x55220a){var _0x45363c=_0x55220a[_0x5f55('0x1d')],_0x438a73=_0xe86740[_0x5f55('0x1e')],_0x528c7d=_0xe86740['offset']+_0xe86740['limit'],_0x3a9a64;if(_0x528c7d>=_0x45363c){_0x528c7d=_0x45363c;_0x3a9a64=0xc8;}else{_0x3a9a64=0xce;}_0x16a1d2[_0x5f55('0x1a')](_0x3a9a64);return _0x16a1d2[_0x5f55('0x1f')](_0x5f55('0x20'),_0x438a73+'-'+_0x528c7d+'/'+_0x45363c)[_0x5f55('0x1c')](_0x55220a);}return null;};}function patchUpdates(_0x58b7c3){return function(_0xde6fa9){try{jsonpatch[_0x5f55('0x21')](_0xde6fa9,_0x58b7c3,!![]);}catch(_0x324add){return BPromise['reject'](_0x324add);}return _0xde6fa9[_0x5f55('0x22')]();};}function saveUpdates(_0x2719ce,_0x53bdd1){return function(_0xeec332){if(_0xeec332){return _0xeec332[_0x5f55('0x23')](_0x2719ce)[_0x5f55('0x24')](function(_0x46446b){return _0x46446b;});}return null;};}function removeEntity(_0x2c3183,_0x29a9c1){return function(_0x2c2e4a){if(_0x2c2e4a){return _0x2c2e4a[_0x5f55('0x25')]()[_0x5f55('0x24')](function(){var _0x39180a=_0x2c2e4a['get']({'plain':!![]});var _0x2ba182=_0x5f55('0x26');return db[_0x5f55('0x27')][_0x5f55('0x25')]({'where':{'type':_0x2ba182,'resourceId':_0x39180a['id']}})[_0x5f55('0x24')](function(){return _0x2c2e4a;});})[_0x5f55('0x24')](function(){_0x2c3183[_0x5f55('0x1a')](0xcc)[_0x5f55('0x1b')]();});}};}function handleEntityNotFound(_0x2ccf53,_0x5b9887){return function(_0x100907){if(!_0x100907){_0x2ccf53['sendStatus'](0x194);}return _0x100907;};}function handleError(_0x163c31,_0x4d7831){_0x4d7831=_0x4d7831||0x1f4;return function(_0x2d3cde){logger[_0x5f55('0x28')](_0x2d3cde[_0x5f55('0x29')]);if(_0x2d3cde['name']){delete _0x2d3cde[_0x5f55('0x2a')];}_0x163c31[_0x5f55('0x1a')](_0x4d7831)['send'](_0x2d3cde);};}exports[_0x5f55('0x2b')]=function(_0x380c74,_0x280817){var _0x21b566={},_0x409ebe={},_0x2c8d48={'count':0x0,'rows':[]};var _0x16bf82=_[_0x5f55('0x2c')](db[_0x5f55('0x2d')][_0x5f55('0x2e')],function(_0x1e6507){return{'name':_0x1e6507[_0x5f55('0x2f')],'type':_0x1e6507[_0x5f55('0x30')][_0x5f55('0x31')]};});_0x409ebe[_0x5f55('0x32')]=_[_0x5f55('0x2c')](_0x16bf82,_0x5f55('0x2a'));_0x409ebe[_0x5f55('0x33')]=_[_0x5f55('0x34')](_0x380c74[_0x5f55('0x33')]);_0x409ebe[_0x5f55('0x35')]=_['intersection'](_0x409ebe['model'],_0x409ebe[_0x5f55('0x33')]);_0x21b566[_0x5f55('0x36')]=_[_0x5f55('0x37')](_0x409ebe[_0x5f55('0x32')],qs['fields'](_0x380c74[_0x5f55('0x33')][_0x5f55('0x38')]));_0x21b566[_0x5f55('0x36')]=_0x21b566[_0x5f55('0x36')][_0x5f55('0x39')]?_0x21b566[_0x5f55('0x36')]:_0x409ebe[_0x5f55('0x32')];if(!_0x380c74[_0x5f55('0x33')][_0x5f55('0x3a')](_0x5f55('0x3b'))){_0x21b566[_0x5f55('0x3c')]=qs['limit'](_0x380c74[_0x5f55('0x33')][_0x5f55('0x3c')]);_0x21b566['offset']=qs[_0x5f55('0x1e')](_0x380c74[_0x5f55('0x33')][_0x5f55('0x1e')]);}_0x21b566[_0x5f55('0x3d')]=qs[_0x5f55('0x3e')](_0x380c74[_0x5f55('0x33')][_0x5f55('0x3e')]);_0x21b566['where']=qs[_0x5f55('0x35')](_[_0x5f55('0x3f')](_0x380c74[_0x5f55('0x33')],_0x409ebe[_0x5f55('0x35')]),_0x16bf82);if(_0x380c74['query'][_0x5f55('0x40')]){_0x21b566['where']=_[_0x5f55('0x41')](_0x21b566[_0x5f55('0x42')],{'$or':_['map'](_0x16bf82,function(_0x51be37){if(_0x51be37[_0x5f55('0x30')]!==_0x5f55('0x43')){var _0x85f8a2={};_0x85f8a2[_0x51be37[_0x5f55('0x2a')]]={'$like':'%'+_0x380c74[_0x5f55('0x33')][_0x5f55('0x40')]+'%'};return _0x85f8a2;}})});}_0x21b566=_['merge']({},_0x21b566,_0x380c74[_0x5f55('0x44')]);var _0x118c5f={'where':_0x21b566[_0x5f55('0x42')]};return db['Team'][_0x5f55('0x1d')](_0x118c5f)['then'](function(_0x3e33f7){_0x2c8d48[_0x5f55('0x1d')]=_0x3e33f7;if(_0x380c74[_0x5f55('0x33')][_0x5f55('0x45')]){_0x21b566[_0x5f55('0x46')]=[{'all':!![]}];}return db[_0x5f55('0x2d')][_0x5f55('0x47')](_0x21b566);})['then'](function(_0x4e98d9){_0x2c8d48[_0x5f55('0x48')]=_0x4e98d9;return _0x2c8d48;})[_0x5f55('0x24')](respondWithFilteredResult(_0x280817,_0x21b566))[_0x5f55('0x49')](handleError(_0x280817,null));};exports[_0x5f55('0x4a')]=function(_0x57bb38,_0x6a6d78){var _0x1f5b47={'raw':![],'where':{'id':_0x57bb38[_0x5f55('0x4b')]['id']}},_0xcd16c0={};_0xcd16c0[_0x5f55('0x32')]=_[_0x5f55('0x34')](db[_0x5f55('0x2d')][_0x5f55('0x2e')]);_0xcd16c0[_0x5f55('0x33')]=_[_0x5f55('0x34')](_0x57bb38[_0x5f55('0x33')]);_0xcd16c0[_0x5f55('0x35')]=_[_0x5f55('0x37')](_0xcd16c0[_0x5f55('0x32')],_0xcd16c0[_0x5f55('0x33')]);_0x1f5b47[_0x5f55('0x36')]=_[_0x5f55('0x37')](_0xcd16c0[_0x5f55('0x32')],qs[_0x5f55('0x38')](_0x57bb38[_0x5f55('0x33')][_0x5f55('0x38')]));_0x1f5b47[_0x5f55('0x36')]=_0x1f5b47[_0x5f55('0x36')][_0x5f55('0x39')]?_0x1f5b47['attributes']:_0xcd16c0[_0x5f55('0x32')];if(_0x57bb38[_0x5f55('0x33')][_0x5f55('0x45')]){_0x1f5b47[_0x5f55('0x46')]=[{'all':!![]}];}_0x1f5b47=_[_0x5f55('0x41')]({},_0x1f5b47,_0x57bb38[_0x5f55('0x44')]);return db[_0x5f55('0x2d')][_0x5f55('0x4c')](_0x1f5b47)['then'](handleEntityNotFound(_0x6a6d78,null))['then'](respondWithResult(_0x6a6d78,null))[_0x5f55('0x49')](handleError(_0x6a6d78,null));};exports[_0x5f55('0x4d')]=function(_0x47ef58,_0x488f3d){return db[_0x5f55('0x2d')][_0x5f55('0x4d')](_0x47ef58[_0x5f55('0x4e')],{})['then'](function(_0x374011){var _0x99bee5=_0x47ef58[_0x5f55('0x4f')]['get']({'plain':!![]});if(!_0x99bee5)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x99bee5['role']===_0x5f55('0x4f')){var _0x5862ef=_0x374011['get']({'plain':!![]});var _0x5bb578=_0x5f55('0x26');return db['UserProfileSection'][_0x5f55('0x4c')]({'where':{'name':_0x5bb578,'userProfileId':_0x99bee5[_0x5f55('0x50')]},'raw':!![]})[_0x5f55('0x24')](function(_0x1285b3){if(_0x1285b3&&_0x1285b3[_0x5f55('0x51')]===0x0){return db['UserProfileResource']['create']({'name':_0x5862ef[_0x5f55('0x2a')],'resourceId':_0x5862ef['id'],'type':_0x1285b3[_0x5f55('0x2a')],'sectionId':_0x1285b3['id']},{})['then'](function(){return _0x374011;});}else{return _0x374011;}})[_0x5f55('0x49')](function(_0x29aebb){logger[_0x5f55('0x28')](_0x5f55('0x52'),_0x29aebb);throw _0x29aebb;});}return _0x374011;})[_0x5f55('0x24')](respondWithResult(_0x488f3d,0xc9))[_0x5f55('0x49')](handleError(_0x488f3d,null));};exports[_0x5f55('0x23')]=function(_0x4d76da,_0x5acfa1){if(_0x4d76da['body']['id']){delete _0x4d76da['body']['id'];}return db['Team']['find']({'where':{'id':_0x4d76da[_0x5f55('0x4b')]['id']}})[_0x5f55('0x24')](handleEntityNotFound(_0x5acfa1,null))[_0x5f55('0x24')](saveUpdates(_0x4d76da['body'],null))[_0x5f55('0x24')](respondWithResult(_0x5acfa1,null))['catch'](handleError(_0x5acfa1,null));};exports[_0x5f55('0x25')]=function(_0x6f5a43,_0x39f4f7){return db[_0x5f55('0x2d')]['find']({'where':{'id':_0x6f5a43[_0x5f55('0x4b')]['id']}})['then'](handleEntityNotFound(_0x39f4f7,null))['then'](removeEntity(_0x39f4f7,null))[_0x5f55('0x49')](handleError(_0x39f4f7,null));};exports['getQueues']=function(_0x429894,_0x40aa95,_0x11b375){return db[_0x5f55('0x2d')][_0x5f55('0x53')]({'where':{'id':_0x429894[_0x5f55('0x4b')]['id']}})['then'](handleEntityNotFound(_0x40aa95,null))[_0x5f55('0x24')](function(_0x4bcfde){if(!_0x429894['query'][_0x5f55('0x54')]||!utils[_0x5f55('0x55')](_0x429894[_0x5f55('0x33')][_0x5f55('0x54')])){throw new db[(_0x5f55('0x56'))]['ValidationError'](_0x5f55('0x57'));}var _0x5c9e87={};var _0x594a24={};_0x594a24[_0x5f55('0x32')]=_[_0x5f55('0x34')](db[_['capitalize'](_0x429894[_0x5f55('0x33')][_0x5f55('0x54')][_0x5f55('0x58')]())+_0x5f55('0x59')]['rawAttributes']);_0x594a24['query']=_[_0x5f55('0x34')](_0x429894['query']);_0x594a24[_0x5f55('0x35')]=_[_0x5f55('0x37')](_0x594a24['model'],_0x594a24['query']);_0x5c9e87[_0x5f55('0x36')]=_[_0x5f55('0x37')](_0x594a24[_0x5f55('0x32')],qs[_0x5f55('0x38')](_0x429894[_0x5f55('0x33')][_0x5f55('0x38')]));_0x5c9e87['attributes']=_0x5c9e87[_0x5f55('0x36')][_0x5f55('0x39')]?_0x5c9e87[_0x5f55('0x36')]:_0x594a24[_0x5f55('0x32')];_0x5c9e87[_0x5f55('0x3c')]=qs[_0x5f55('0x3c')](_0x429894[_0x5f55('0x33')][_0x5f55('0x3c')]);_0x5c9e87[_0x5f55('0x1e')]=qs[_0x5f55('0x1e')](_0x429894[_0x5f55('0x33')][_0x5f55('0x1e')]);_0x5c9e87[_0x5f55('0x3d')]=qs[_0x5f55('0x3e')](_0x429894[_0x5f55('0x33')][_0x5f55('0x3e')]);_0x5c9e87[_0x5f55('0x42')]=qs['filters'](_[_0x5f55('0x3f')](_0x429894[_0x5f55('0x33')],_0x594a24['filters']));_0x5c9e87=_[_0x5f55('0x41')]({},_0x5c9e87,_0x429894[_0x5f55('0x44')]);return _0x4bcfde[_0x5f55('0x5a')+_[_0x5f55('0x5b')](_0x429894[_0x5f55('0x33')]['channel'][_0x5f55('0x58')]())+'Queues'](_0x5c9e87);})['then'](respondWithResult(_0x40aa95,null))['catch'](handleError(_0x40aa95,null));};exports[_0x5f55('0x5c')]=function(_0x3419b0,_0xb3bba1,_0x54ef7c){return db[_0x5f55('0x2d')][_0x5f55('0x53')]({'where':{'id':_0x3419b0[_0x5f55('0x4b')]['id']}})[_0x5f55('0x24')](function(_0x4d054b){if(_0x4d054b){if(!_0x3419b0[_0x5f55('0x4e')]['channel']||!utils[_0x5f55('0x55')](_0x3419b0[_0x5f55('0x4e')][_0x5f55('0x54')])){throw new db[(_0x5f55('0x56'))][(_0x5f55('0x5d'))](_0x5f55('0x57'));}return _0x4d054b[_0x5f55('0x5e')+_['capitalize'](_0x3419b0[_0x5f55('0x4e')][_0x5f55('0x54')][_0x5f55('0x58')]())+_0x5f55('0x5f')](_0x3419b0['body'][_0x5f55('0x60')]);}return null;})[_0x5f55('0x24')](handleEntityNotFound(_0xb3bba1,null))[_0x5f55('0x24')](respondWithStatusCode(_0xb3bba1,null))[_0x5f55('0x49')](handleError(_0xb3bba1,null));};exports[_0x5f55('0x61')]=function(_0x24a541,_0x87b0e0,_0x3a5db3){return db[_0x5f55('0x2d')]['findOne']({'where':{'id':_0x24a541['params']['id']}})[_0x5f55('0x24')](function(_0x113997){if(_0x113997){if(!_0x24a541['query'][_0x5f55('0x54')]||!utils['isValidChannel'](_0x24a541[_0x5f55('0x33')][_0x5f55('0x54')])){throw new db[(_0x5f55('0x56'))]['ValidationError'](_0x5f55('0x57'));}return _0x113997['remove'+_[_0x5f55('0x5b')](_0x24a541[_0x5f55('0x33')][_0x5f55('0x54')][_0x5f55('0x58')]())+_0x5f55('0x5f')](_0x24a541['query'][_0x5f55('0x60')]);}return null;})['then'](handleEntityNotFound(_0x87b0e0,null))['then'](respondWithStatusCode(_0x87b0e0,null))[_0x5f55('0x49')](handleError(_0x87b0e0,null));};exports[_0x5f55('0x62')]=function(_0x30ebd4,_0x74426,_0x1196cb){return db[_0x5f55('0x2d')][_0x5f55('0x4c')]({'where':{'id':_0x30ebd4[_0x5f55('0x4b')]['id']}})[_0x5f55('0x24')](handleEntityNotFound(_0x74426,null))[_0x5f55('0x24')](function(_0x2ef3e3){if(_0x2ef3e3){var _0xf76d0=[_0x5f55('0x63'),_0x5f55('0x64'),_0x5f55('0x65'),'Sms',_0x5f55('0x66'),_0x5f55('0x67'),_0x5f55('0x68')];return BPromise[_0x5f55('0x69')](_0xf76d0,function(_0x397724){return _0x2ef3e3[_0x5f55('0x5a')+_0x397724+_0x5f55('0x5f')]({'attributes':['id',_0x5f55('0x2a')]})[_0x5f55('0x24')](function(_0x47b958){return BPromise[_0x5f55('0x69')](_0x47b958,function(_0x2d989f){return _0x2d989f[_0x5f55('0x62')](_0x30ebd4[_0x5f55('0x4e')]['ids'])[_0x5f55('0x24')](function(){if(_0x397724===_0x5f55('0x63')){return db['User'][_0x5f55('0x47')]({'where':{'id':_0x30ebd4[_0x5f55('0x4e')][_0x5f55('0x60')]},'attributes':['id',_0x5f55('0x2a'),_0x5f55('0x6a'),_0x5f55('0x6b'),_0x5f55('0x6c')],'raw':!![]})['then'](function(_0x8e48a1){return BPromise[_0x5f55('0x69')](_[_0x5f55('0x40')](_0x8e48a1,{'online':0x1}),function(_0x3c3160){return db[_0x5f55('0x6d')]['upsert']({'membername':_0x3c3160[_0x5f55('0x2a')],'UserId':_0x3c3160['id'],'queue_name':_0x2d989f['name'],'VoiceQueueId':_0x2d989f['id'],'interface':_[_0x5f55('0x6e')](_0x3c3160[_0x5f55('0x6c')])?util[_0x5f55('0x6f')](_0x5f55('0x70'),_0x3c3160[_0x5f55('0x2a')]):_0x3c3160['interface'],'paused':_0x3c3160[_0x5f55('0x6b')]||![],'penalty':0x0});});});}});});})[_0x5f55('0x24')](function(){return _0x2ef3e3;});})[_0x5f55('0x24')](function(){return _0x2ef3e3;});}})[_0x5f55('0x24')](function(_0x44ec70){if(_0x44ec70){return _0x44ec70[_0x5f55('0x62')](_0x30ebd4[_0x5f55('0x4e')][_0x5f55('0x60')],_['omit'](_0x30ebd4[_0x5f55('0x4e')],[_0x5f55('0x60'),'id'])||{})[_0x5f55('0x71')](function(_0xbc4049){for(var _0x2dcc40=0x0;_0x2dcc40<_0x30ebd4[_0x5f55('0x4e')][_0x5f55('0x60')]['length'];_0x2dcc40+=0x1){socket[_0x5f55('0x72')]('userTeam:save',{'UserId':_0x30ebd4[_0x5f55('0x4e')][_0x5f55('0x60')][_0x2dcc40],'TeamId':_0x30ebd4['params']['id']});}return _0xbc4049;});}})['then'](respondWithResult(_0x74426,null))[_0x5f55('0x49')](handleError(_0x74426,null));};exports[_0x5f55('0x73')]=function(_0x53374b,_0x3a60a1,_0x382e72){return db[_0x5f55('0x2d')][_0x5f55('0x4c')]({'where':{'id':_0x53374b[_0x5f55('0x4b')]['id']}})[_0x5f55('0x24')](handleEntityNotFound(_0x3a60a1,null))[_0x5f55('0x24')](function(_0x473feb){if(_0x473feb){return BPromise['each']([_0x5f55('0x74'),_0x5f55('0x75'),_0x5f55('0x76'),'sms','fax','openchannel',_0x5f55('0x77')],function(_0x579cbb){return _0x473feb[_0x5f55('0x5a')+_[_0x5f55('0x5b')](_0x579cbb)+_0x5f55('0x5f')]({'attributes':['id',_0x5f55('0x2a')]})['then'](function(_0x23c516){return BPromise['each'](_0x23c516,function(_0x31504a){return _0x31504a[_0x5f55('0x73')](_0x53374b[_0x5f55('0x33')]['ids'])['then'](function(){if(_0x579cbb===_0x5f55('0x74')){return db[_0x5f55('0x6d')][_0x5f55('0x25')]({'where':{'VoiceQueueId':_0x31504a['id'],'UserId':_0x53374b[_0x5f55('0x33')]['ids']}});}});});})['then'](function(){return _0x473feb;});})[_0x5f55('0x24')](function(){return _0x473feb;});}})['then'](function(_0x3eb5af){if(_0x3eb5af){return _0x3eb5af[_0x5f55('0x73')](_0x53374b[_0x5f55('0x33')]['ids'])[_0x5f55('0x24')](function(){if(_[_0x5f55('0x78')](_0x53374b[_0x5f55('0x33')][_0x5f55('0x60')])){for(var _0x486b3a=0x0;_0x486b3a<_0x53374b['query'][_0x5f55('0x60')]['length'];_0x486b3a+=0x1){socket[_0x5f55('0x72')](_0x5f55('0x79'),{'UserId':Number(_0x53374b[_0x5f55('0x33')][_0x5f55('0x60')][_0x486b3a]),'TeamId':Number(_0x53374b['params']['id'])});}}else{socket[_0x5f55('0x72')](_0x5f55('0x79'),{'UserId':Number(_0x53374b[_0x5f55('0x33')][_0x5f55('0x60')]),'TeamId':Number(_0x53374b[_0x5f55('0x4b')]['id'])});}});}})[_0x5f55('0x24')](respondWithStatusCode(_0x3a60a1,null))['catch'](handleError(_0x3a60a1,null));};exports[_0x5f55('0x7a')]=function(_0x8bde8b,_0x4228d7,_0x1da6ea){var _0x5af7bb={};var _0x4e0b15={};var _0x16f128;var _0x83bc23;return db['Team']['findOne']({'where':{'id':_0x8bde8b['params']['id']}})[_0x5f55('0x24')](handleEntityNotFound(_0x4228d7,null))['then'](function(_0x1909c5){if(_0x1909c5){_0x16f128=_0x1909c5;_0x4e0b15[_0x5f55('0x32')]=_['keys'](db['User']['rawAttributes']);_0x4e0b15[_0x5f55('0x33')]=_[_0x5f55('0x34')](_0x8bde8b['query']);_0x4e0b15[_0x5f55('0x35')]=_[_0x5f55('0x37')](_0x4e0b15[_0x5f55('0x32')],_0x4e0b15['query']);_0x5af7bb[_0x5f55('0x36')]=_[_0x5f55('0x37')](_0x4e0b15['model'],qs[_0x5f55('0x38')](_0x8bde8b[_0x5f55('0x33')][_0x5f55('0x38')]));_0x5af7bb[_0x5f55('0x36')]=_0x5af7bb['attributes'][_0x5f55('0x39')]?_0x5af7bb[_0x5f55('0x36')]:_0x4e0b15[_0x5f55('0x32')];_0x5af7bb[_0x5f55('0x3d')]=qs['sort'](_0x8bde8b[_0x5f55('0x33')][_0x5f55('0x3e')]);_0x5af7bb[_0x5f55('0x42')]=qs[_0x5f55('0x35')](_[_0x5f55('0x3f')](_0x8bde8b[_0x5f55('0x33')],_0x4e0b15[_0x5f55('0x35')]));if(_0x8bde8b[_0x5f55('0x33')][_0x5f55('0x40')]){_0x5af7bb[_0x5f55('0x42')]=_[_0x5f55('0x41')](_0x5af7bb[_0x5f55('0x42')],{'$or':_[_0x5f55('0x2c')](_0x5af7bb[_0x5f55('0x36')],function(_0x1e9ae0){var _0x5a305b={};_0x5a305b[_0x1e9ae0]={'$like':'%'+_0x8bde8b['query'][_0x5f55('0x40')]+'%'};return _0x5a305b;})});}_0x5af7bb=_[_0x5f55('0x41')]({},_0x5af7bb,_0x8bde8b['options']);return _0x16f128[_0x5f55('0x7a')](_0x5af7bb);}})[_0x5f55('0x24')](function(_0x1e6063){if(_0x1e6063){_0x83bc23=_0x1e6063['length'];if(!_0x8bde8b[_0x5f55('0x33')][_0x5f55('0x3a')](_0x5f55('0x3b'))){_0x5af7bb[_0x5f55('0x3c')]=qs['limit'](_0x8bde8b[_0x5f55('0x33')][_0x5f55('0x3c')]);_0x5af7bb['offset']=qs[_0x5f55('0x1e')](_0x8bde8b['query']['offset']);}return _0x16f128[_0x5f55('0x7a')](_0x5af7bb);}})[_0x5f55('0x24')](function(_0x2ebc10){if(_0x2ebc10){return _0x2ebc10?{'count':_0x83bc23,'rows':_0x2ebc10}:null;}})[_0x5f55('0x24')](respondWithResult(_0x4228d7,null))[_0x5f55('0x49')](handleError(_0x4228d7,null));};
\ No newline at end of file
+var _0x855e=['TeamVoiceQueue','User','findOrCreate','emit','QueueId','online','voicePause','interface','UserVoiceQueueRt','upsert','isNil','all','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','spread','removeAgents','Whatsapp','Queue:remove','getAgents','eml-format','rimraf','zip-dir','request-promise','bluebird','util','path','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./team.socket','register','status','end','offset','undefined','limit','json','apply','reject','update','then','sendStatus','error','stack','name','map','rawAttributes','fieldName','type','key','query','keys','attributes','intersection','model','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','VIRTUAL','merge','options','Team','count','include','findAll','rows','show','params','includeAll','find','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Teams','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','sequelize','SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20','Sequelize','QueryTypes','SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20','SELECT','VoiceQueueId','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','SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20','FaxQueueId','UserFaxQueue','OpenchannelQueueId','UserOpenchannelQueue','SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','UserProfileResource','send','channel','ValidationError','Unknown\x20channel','capitalize','toLowerCase','Queue','addQueues','findOne','Queues','ids','removeQueues','isValidChannel','remove','addAgents','isArray','Voice','Chat','Sms','Fax','Openchannel','transaction','through','penalty','defaults'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x855e,0x146));var _0xe855=function(_0x275fa1,_0x28af28){_0x275fa1=_0x275fa1-0x0;var _0x5c04db=_0x855e[_0x275fa1];return _0x5c04db;};'use strict';var emlformat=require(_0xe855('0x0'));var rimraf=require(_0xe855('0x1'));var zipdir=require(_0xe855('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe855('0x3'));var moment=require('moment');var BPromise=require(_0xe855('0x4'));var Mustache=require('mustache');var util=require(_0xe855('0x5'));var path=require(_0xe855('0x6'));var sox=require('sox');var csv=require(_0xe855('0x7'));var ejs=require(_0xe855('0x8'));var fs=require('fs');var fs_extra=require(_0xe855('0x9'));var _=require('lodash');var squel=require(_0xe855('0xa'));var crypto=require(_0xe855('0xb'));var jsforce=require(_0xe855('0xc'));var deskjs=require(_0xe855('0xd'));var toCsv=require(_0xe855('0x7'));var querystring=require(_0xe855('0xe'));var Papa=require(_0xe855('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xe855('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe855('0x11'));var logger=require(_0xe855('0x12'))(_0xe855('0x13'));var utils=require(_0xe855('0x14'));var config=require(_0xe855('0x15'));var licenseUtil=require(_0xe855('0x16'));var db=require(_0xe855('0x17'))['db'];config['redis']=_['defaults'](config[_0xe855('0x18')],{'host':_0xe855('0x19'),'port':0x18eb});var socket=require(_0xe855('0x1a'))(new Redis(config[_0xe855('0x18')]));require(_0xe855('0x1b'))[_0xe855('0x1c')](socket);function respondWithStatusCode(_0x3fa9e3,_0x15cdd1){_0x15cdd1=_0x15cdd1||0xcc;return function(_0x24dd78){if(_0x24dd78){return _0x3fa9e3['sendStatus'](_0x15cdd1);}return _0x3fa9e3[_0xe855('0x1d')](_0x15cdd1)[_0xe855('0x1e')]();};}function respondWithResult(_0x49c438,_0x42f5ad){_0x42f5ad=_0x42f5ad||0xc8;return function(_0x1805ba){if(_0x1805ba){return _0x49c438[_0xe855('0x1d')](_0x42f5ad)['json'](_0x1805ba);}};}function respondWithFilteredResult(_0x37447f,_0x1b1a2a){return function(_0x359d81){if(_0x359d81){var _0x285ee5=typeof _0x1b1a2a[_0xe855('0x1f')]===_0xe855('0x20')&&typeof _0x1b1a2a[_0xe855('0x21')]==='undefined';var _0x1183a0=_0x359d81['count'];var _0x5592be=_0x285ee5?0x0:_0x1b1a2a['offset'];var _0x2d0b61=_0x285ee5?_0x359d81['count']:_0x1b1a2a[_0xe855('0x1f')]+_0x1b1a2a[_0xe855('0x21')];var _0x4d84b8;if(_0x2d0b61>=_0x1183a0){_0x2d0b61=_0x1183a0;_0x4d84b8=0xc8;}else{_0x4d84b8=0xce;}_0x37447f[_0xe855('0x1d')](_0x4d84b8);return _0x37447f['set']('Content-Range',_0x5592be+'-'+_0x2d0b61+'/'+_0x1183a0)[_0xe855('0x22')](_0x359d81);}return null;};}function patchUpdates(_0x36271b){return function(_0x3081ff){try{jsonpatch[_0xe855('0x23')](_0x3081ff,_0x36271b,!![]);}catch(_0x10536a){return BPromise[_0xe855('0x24')](_0x10536a);}return _0x3081ff['save']();};}function saveUpdates(_0x3419fe,_0x4fd7ee){return function(_0x1b6ac6){if(_0x1b6ac6){return _0x1b6ac6[_0xe855('0x25')](_0x3419fe)[_0xe855('0x26')](function(_0x3b6b95){return _0x3b6b95;});}return null;};}function handleEntityNotFound(_0x4fc339,_0x474216){return function(_0xfbcda0){if(!_0xfbcda0){_0x4fc339[_0xe855('0x27')](0x194);}return _0xfbcda0;};}function handleError(_0x3822ab,_0x1aa372){_0x1aa372=_0x1aa372||0x1f4;return function(_0x4d5b9f){logger[_0xe855('0x28')](_0x4d5b9f[_0xe855('0x29')]);if(_0x4d5b9f[_0xe855('0x2a')]){delete _0x4d5b9f[_0xe855('0x2a')];}_0x3822ab[_0xe855('0x1d')](_0x1aa372)['send'](_0x4d5b9f);};}exports['index']=function(_0x54de1b,_0x11e8b4){var _0x1b001e={},_0x33eb02={},_0x147b9f={'count':0x0,'rows':[]};var _0x2e6f0f=_[_0xe855('0x2b')](db['Team'][_0xe855('0x2c')],function(_0x1646af){return{'name':_0x1646af[_0xe855('0x2d')],'type':_0x1646af[_0xe855('0x2e')][_0xe855('0x2f')]};});_0x33eb02['model']=_['map'](_0x2e6f0f,'name');_0x33eb02[_0xe855('0x30')]=_[_0xe855('0x31')](_0x54de1b[_0xe855('0x30')]);_0x33eb02['filters']=_['intersection'](_0x33eb02['model'],_0x33eb02[_0xe855('0x30')]);_0x1b001e[_0xe855('0x32')]=_[_0xe855('0x33')](_0x33eb02[_0xe855('0x34')],qs[_0xe855('0x35')](_0x54de1b[_0xe855('0x30')][_0xe855('0x35')]));_0x1b001e['attributes']=_0x1b001e[_0xe855('0x32')][_0xe855('0x36')]?_0x1b001e[_0xe855('0x32')]:_0x33eb02['model'];if(!_0x54de1b[_0xe855('0x30')][_0xe855('0x37')](_0xe855('0x38'))){_0x1b001e[_0xe855('0x21')]=qs[_0xe855('0x21')](_0x54de1b[_0xe855('0x30')][_0xe855('0x21')]);_0x1b001e[_0xe855('0x1f')]=qs[_0xe855('0x1f')](_0x54de1b[_0xe855('0x30')][_0xe855('0x1f')]);}_0x1b001e[_0xe855('0x39')]=qs[_0xe855('0x3a')](_0x54de1b[_0xe855('0x30')][_0xe855('0x3a')]);_0x1b001e[_0xe855('0x3b')]=qs[_0xe855('0x3c')](_[_0xe855('0x3d')](_0x54de1b[_0xe855('0x30')],_0x33eb02['filters']),_0x2e6f0f);if(_0x54de1b[_0xe855('0x30')][_0xe855('0x3e')]){_0x1b001e[_0xe855('0x3b')]=_['merge'](_0x1b001e[_0xe855('0x3b')],{'$or':_[_0xe855('0x2b')](_0x2e6f0f,function(_0x1c09d5){if(_0x1c09d5[_0xe855('0x2e')]!==_0xe855('0x3f')){var _0x3b298b={};_0x3b298b[_0x1c09d5['name']]={'$like':'%'+_0x54de1b[_0xe855('0x30')][_0xe855('0x3e')]+'%'};return _0x3b298b;}})});}_0x1b001e=_[_0xe855('0x40')]({},_0x1b001e,_0x54de1b[_0xe855('0x41')]);var _0x19f2cc={'where':_0x1b001e[_0xe855('0x3b')]};return db[_0xe855('0x42')][_0xe855('0x43')](_0x19f2cc)[_0xe855('0x26')](function(_0x930699){_0x147b9f[_0xe855('0x43')]=_0x930699;if(_0x54de1b[_0xe855('0x30')]['includeAll']){_0x1b001e[_0xe855('0x44')]=[{'all':!![]}];}return db[_0xe855('0x42')][_0xe855('0x45')](_0x1b001e);})['then'](function(_0x29e0db){_0x147b9f[_0xe855('0x46')]=_0x29e0db;return _0x147b9f;})['then'](respondWithFilteredResult(_0x11e8b4,_0x1b001e))['catch'](handleError(_0x11e8b4,null));};exports[_0xe855('0x47')]=function(_0x25920d,_0x55e766){var _0x38e942={'raw':![],'where':{'id':_0x25920d[_0xe855('0x48')]['id']}},_0x222a68={};_0x222a68[_0xe855('0x34')]=_[_0xe855('0x31')](db[_0xe855('0x42')][_0xe855('0x2c')]);_0x222a68['query']=_[_0xe855('0x31')](_0x25920d[_0xe855('0x30')]);_0x222a68['filters']=_[_0xe855('0x33')](_0x222a68[_0xe855('0x34')],_0x222a68['query']);_0x38e942[_0xe855('0x32')]=_[_0xe855('0x33')](_0x222a68[_0xe855('0x34')],qs[_0xe855('0x35')](_0x25920d[_0xe855('0x30')][_0xe855('0x35')]));_0x38e942['attributes']=_0x38e942['attributes']['length']?_0x38e942['attributes']:_0x222a68[_0xe855('0x34')];if(_0x25920d[_0xe855('0x30')][_0xe855('0x49')]){_0x38e942[_0xe855('0x44')]=[{'all':!![]}];}_0x38e942=_[_0xe855('0x40')]({},_0x38e942,_0x25920d['options']);return db[_0xe855('0x42')][_0xe855('0x4a')](_0x38e942)['then'](handleEntityNotFound(_0x55e766,null))[_0xe855('0x26')](respondWithResult(_0x55e766,null))[_0xe855('0x4b')](handleError(_0x55e766,null));};exports['create']=function(_0x1c4168,_0x94abd4){return db['Team'][_0xe855('0x4c')](_0x1c4168[_0xe855('0x4d')],{})[_0xe855('0x26')](function(_0x34016d){var _0xf8fb17=_0x1c4168[_0xe855('0x4e')][_0xe855('0x4f')]({'plain':!![]});if(!_0xf8fb17)throw new Error(_0xe855('0x50'));if(_0xf8fb17[_0xe855('0x51')]==='user'){var _0x530f4d=_0x34016d[_0xe855('0x4f')]({'plain':!![]});var _0x121fb1=_0xe855('0x52');return db[_0xe855('0x53')][_0xe855('0x4a')]({'where':{'name':_0x121fb1,'userProfileId':_0xf8fb17[_0xe855('0x54')]},'raw':!![]})[_0xe855('0x26')](function(_0x592267){if(_0x592267&&_0x592267[_0xe855('0x55')]===0x0){return db['UserProfileResource'][_0xe855('0x4c')]({'name':_0x530f4d['name'],'resourceId':_0x530f4d['id'],'type':_0x592267[_0xe855('0x2a')],'sectionId':_0x592267['id']},{})[_0xe855('0x26')](function(){return _0x34016d;});}else{return _0x34016d;}})[_0xe855('0x4b')](function(_0x230fbf){logger['error'](_0xe855('0x56'),_0x230fbf);throw _0x230fbf;});}return _0x34016d;})['then'](respondWithResult(_0x94abd4,0xc9))[_0xe855('0x4b')](handleError(_0x94abd4,null));};exports['update']=function(_0x37d0f4,_0x5e09be){if(_0x37d0f4[_0xe855('0x4d')]['id']){delete _0x37d0f4['body']['id'];}return db[_0xe855('0x42')][_0xe855('0x4a')]({'where':{'id':_0x37d0f4[_0xe855('0x48')]['id']}})[_0xe855('0x26')](handleEntityNotFound(_0x5e09be,null))[_0xe855('0x26')](saveUpdates(_0x37d0f4['body'],null))['then'](respondWithResult(_0x5e09be,null))[_0xe855('0x4b')](handleError(_0x5e09be,null));};exports[_0xe855('0x57')]=function(_0x100ecc,_0x120056){var _0x438a74=_0x100ecc[_0xe855('0x48')]['id'];var _0x53db82=[];return db[_0xe855('0x58')]['transaction'](function(_0x251057){var _0x51a829=_0xe855('0x59')+_0x438a74;return db[_0xe855('0x58')][_0xe855('0x30')](_0x51a829,{'type':db[_0xe855('0x5a')][_0xe855('0x5b')]['SELECT'],'raw':!![],'transaction':_0x251057})['then'](function(_0x3a0a0b){_0x53db82=_[_0xe855('0x2b')](_0x3a0a0b,function(_0x2d17a0){return Number(_0x2d17a0['UserId']);});})[_0xe855('0x26')](function(){var _0x448142=_0xe855('0x5c')+_0x438a74;return db[_0xe855('0x58')][_0xe855('0x30')](_0x448142,{'type':db['Sequelize'][_0xe855('0x5b')][_0xe855('0x5d')],'raw':!![],'transaction':_0x251057});})[_0xe855('0x26')](function(_0x464756){var _0x3139e7=_[_0xe855('0x2b')](_0x464756,function(_0x415461){return Number(_0x415461[_0xe855('0x5e')]);});return db['UserVoiceQueue']['destroy']({'where':{'UserId':{'$in':_0x53db82},'VoiceQueueId':{'$in':_0x3139e7}},'transaction':_0x251057});})[_0xe855('0x26')](function(){var _0x3ea669=_0xe855('0x5f')+_0x438a74;return db['sequelize']['query'](_0x3ea669,{'type':db[_0xe855('0x5a')]['QueryTypes'][_0xe855('0x5d')],'raw':!![],'transaction':_0x251057});})[_0xe855('0x26')](function(_0x458d73){var _0x56bf5c=_['map'](_0x458d73,function(_0xdc8834){return Number(_0xdc8834[_0xe855('0x60')]);});return db[_0xe855('0x61')][_0xe855('0x57')]({'where':{'UserId':{'$in':_0x53db82},'MailQueueId':{'$in':_0x56bf5c}},'transaction':_0x251057});})[_0xe855('0x26')](function(){var _0x412d65=_0xe855('0x62')+_0x438a74;return db[_0xe855('0x58')]['query'](_0x412d65,{'type':db[_0xe855('0x5a')]['QueryTypes'][_0xe855('0x5d')],'raw':!![],'transaction':_0x251057});})['then'](function(_0x440f7c){var _0x4b30c1=_[_0xe855('0x2b')](_0x440f7c,function(_0x562847){return Number(_0x562847[_0xe855('0x63')]);});return db[_0xe855('0x64')]['destroy']({'where':{'UserId':{'$in':_0x53db82},'SmsQueueId':{'$in':_0x4b30c1}},'transaction':_0x251057});})[_0xe855('0x26')](function(){var _0x2e35d2=_0xe855('0x65')+_0x438a74;return db['sequelize'][_0xe855('0x30')](_0x2e35d2,{'type':db['Sequelize'][_0xe855('0x5b')][_0xe855('0x5d')],'raw':!![],'transaction':_0x251057});})[_0xe855('0x26')](function(_0x1189d4){var _0x3ef368=_[_0xe855('0x2b')](_0x1189d4,function(_0x20bfd3){return Number(_0x20bfd3['ChatQueueId']);});return db['UserChatQueue'][_0xe855('0x57')]({'where':{'UserId':{'$in':_0x53db82},'ChatQueueId':{'$in':_0x3ef368}},'transaction':_0x251057});})['then'](function(){var _0x3069a7='SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20'+_0x438a74;return db[_0xe855('0x58')][_0xe855('0x30')](_0x3069a7,{'type':db['Sequelize']['QueryTypes'][_0xe855('0x5d')],'raw':!![],'transaction':_0x251057});})['then'](function(_0x4c67e8){var _0x1955f2=_[_0xe855('0x2b')](_0x4c67e8,function(_0x228ea0){return Number(_0x228ea0[_0xe855('0x66')]);});return db[_0xe855('0x67')][_0xe855('0x57')]({'where':{'UserId':{'$in':_0x53db82},'FaxQueueId':{'$in':_0x1955f2}},'transaction':_0x251057});})['then'](function(){var _0x3d292e='SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20'+_0x438a74;return db[_0xe855('0x58')][_0xe855('0x30')](_0x3d292e,{'type':db[_0xe855('0x5a')][_0xe855('0x5b')][_0xe855('0x5d')],'raw':!![],'transaction':_0x251057});})[_0xe855('0x26')](function(_0x385a2c){var _0x4a07cb=_['map'](_0x385a2c,function(_0x45d2b5){return Number(_0x45d2b5[_0xe855('0x68')]);});return db[_0xe855('0x69')][_0xe855('0x57')]({'where':{'UserId':{'$in':_0x53db82},'OpenchannelQueueId':{'$in':_0x4a07cb}},'transaction':_0x251057});})[_0xe855('0x26')](function(){var _0x272c85=_0xe855('0x6a')+_0x438a74;return db[_0xe855('0x58')][_0xe855('0x30')](_0x272c85,{'type':db[_0xe855('0x5a')][_0xe855('0x5b')]['SELECT'],'raw':!![],'transaction':_0x251057});})[_0xe855('0x26')](function(_0x25bf4c){var _0x38729a=_[_0xe855('0x2b')](_0x25bf4c,function(_0x2488e7){return Number(_0x2488e7['WhatsappQueueId']);});return db['UserWhatsappQueue'][_0xe855('0x57')]({'where':{'UserId':{'$in':_0x53db82},'WhatsappQueueId':{'$in':_0x38729a}},'transaction':_0x251057});})[_0xe855('0x26')](function(){return db['TeamVoicePrefix']['find']({'where':{'TeamId':_0x438a74}});})[_0xe855('0x26')](function(_0x152f15){if(_0x152f15===null){return;}return db['UserVoicePrefix']['destroy']({'where':{'UserId':{'$in':_0x53db82},'VoicePrefixId':_0x152f15['VoicePrefixId']},'transaction':_0x251057});})['then'](function(){return db[_0xe855('0x42')][_0xe855('0x57')]({'where':{'id':_0x438a74},'cascade':!![],'transaction':_0x251057});})[_0xe855('0x26')](function(_0x5f50c0){if(_0x5f50c0===0x0){_0x120056[_0xe855('0x27')](0x194);}else{return db[_0xe855('0x6b')]['destroy']({'where':{'type':_0xe855('0x52'),'resourceId':_0x438a74},'cascade':!![],'transaction':_0x251057})['then'](function(){_0x120056[_0xe855('0x1d')](0xcc)['end']();});}})[_0xe855('0x4b')](function(_0x3fc212){_0x120056[_0xe855('0x1d')](0x1f4)[_0xe855('0x6c')](_0x3fc212);});});};exports['getQueues']=function(_0x2a3490,_0x26c342,_0x335e46){return db['Team']['findOne']({'where':{'id':_0x2a3490[_0xe855('0x48')]['id']}})[_0xe855('0x26')](handleEntityNotFound(_0x26c342,null))[_0xe855('0x26')](function(_0x2bae25){if(!_0x2a3490[_0xe855('0x30')][_0xe855('0x6d')]||!utils['isValidChannel'](_0x2a3490['query'][_0xe855('0x6d')])){throw new db[(_0xe855('0x5a'))][(_0xe855('0x6e'))](_0xe855('0x6f'));}var _0x41c186={};var _0x177946={};_0x177946[_0xe855('0x34')]=_[_0xe855('0x31')](db[_[_0xe855('0x70')](_0x2a3490[_0xe855('0x30')][_0xe855('0x6d')][_0xe855('0x71')]())+_0xe855('0x72')]['rawAttributes']);_0x177946['query']=_[_0xe855('0x31')](_0x2a3490[_0xe855('0x30')]);_0x177946['filters']=_[_0xe855('0x33')](_0x177946['model'],_0x177946[_0xe855('0x30')]);_0x41c186[_0xe855('0x32')]=_[_0xe855('0x33')](_0x177946['model'],qs[_0xe855('0x35')](_0x2a3490[_0xe855('0x30')]['fields']));_0x41c186['attributes']=_0x41c186[_0xe855('0x32')][_0xe855('0x36')]?_0x41c186[_0xe855('0x32')]:_0x177946[_0xe855('0x34')];_0x41c186[_0xe855('0x21')]=qs[_0xe855('0x21')](_0x2a3490[_0xe855('0x30')][_0xe855('0x21')]);_0x41c186['offset']=qs[_0xe855('0x1f')](_0x2a3490[_0xe855('0x30')][_0xe855('0x1f')]);_0x41c186[_0xe855('0x39')]=qs[_0xe855('0x3a')](_0x2a3490['query'][_0xe855('0x3a')]);_0x41c186['where']=qs[_0xe855('0x3c')](_['pick'](_0x2a3490[_0xe855('0x30')],_0x177946[_0xe855('0x3c')]));_0x41c186=_[_0xe855('0x40')]({},_0x41c186,_0x2a3490['options']);return _0x2bae25['get'+_[_0xe855('0x70')](_0x2a3490[_0xe855('0x30')][_0xe855('0x6d')]['toLowerCase']())+'Queues'](_0x41c186);})['then'](respondWithResult(_0x26c342,null))[_0xe855('0x4b')](handleError(_0x26c342,null));};exports[_0xe855('0x73')]=function(_0x25e625,_0x3ab2e9,_0x4de4cb){return db[_0xe855('0x42')][_0xe855('0x74')]({'where':{'id':_0x25e625['params']['id']}})[_0xe855('0x26')](function(_0xd5d6bf){if(_0xd5d6bf){if(!_0x25e625['body']['channel']||!utils['isValidChannel'](_0x25e625[_0xe855('0x4d')][_0xe855('0x6d')])){throw new db['Sequelize'][(_0xe855('0x6e'))](_0xe855('0x6f'));}return _0xd5d6bf['add'+_[_0xe855('0x70')](_0x25e625[_0xe855('0x4d')][_0xe855('0x6d')][_0xe855('0x71')]())+_0xe855('0x75')](_0x25e625[_0xe855('0x4d')][_0xe855('0x76')]);}return null;})[_0xe855('0x26')](handleEntityNotFound(_0x3ab2e9,null))[_0xe855('0x26')](respondWithStatusCode(_0x3ab2e9,null))[_0xe855('0x4b')](handleError(_0x3ab2e9,null));};exports[_0xe855('0x77')]=function(_0x471207,_0x15bb1d,_0x7fa765){return db[_0xe855('0x42')][_0xe855('0x74')]({'where':{'id':_0x471207[_0xe855('0x48')]['id']}})['then'](function(_0x551fa4){if(_0x551fa4){if(!_0x471207[_0xe855('0x30')][_0xe855('0x6d')]||!utils[_0xe855('0x78')](_0x471207[_0xe855('0x30')][_0xe855('0x6d')])){throw new db['Sequelize'][(_0xe855('0x6e'))](_0xe855('0x6f'));}return _0x551fa4[_0xe855('0x79')+_[_0xe855('0x70')](_0x471207[_0xe855('0x30')][_0xe855('0x6d')][_0xe855('0x71')]())+_0xe855('0x75')](_0x471207[_0xe855('0x30')][_0xe855('0x76')]);}return null;})[_0xe855('0x26')](handleEntityNotFound(_0x15bb1d,null))[_0xe855('0x26')](respondWithStatusCode(_0x15bb1d,null))[_0xe855('0x4b')](handleError(_0x15bb1d,null));};exports[_0xe855('0x7a')]=function(_0x53e2de,_0xf6bc0c){var _0x4f7120=_[_0xe855('0x7b')](_0x53e2de[_0xe855('0x4d')][_0xe855('0x76')])?_0x53e2de['body'][_0xe855('0x76')]:[_0x53e2de[_0xe855('0x4d')][_0xe855('0x76')]];var _0x1048c3=_0x53e2de['params']['id'];return db[_0xe855('0x42')][_0xe855('0x4a')]({'where':{'id':_0x1048c3}})[_0xe855('0x26')](handleEntityNotFound(_0xf6bc0c,null))[_0xe855('0x26')](function(_0x5bec13){if(_0x5bec13){var _0x5a2b19=[_0xe855('0x7c'),_0xe855('0x7d'),'Mail',_0xe855('0x7e'),_0xe855('0x7f'),_0xe855('0x80'),'Whatsapp'];return db[_0xe855('0x58')][_0xe855('0x81')](function(_0x3ed76b){var _0x49717e=_[_0xe855('0x2b')](_0x5a2b19,function(_0xdceae0){var _0x4d53b0={'attributes':['id',_0xe855('0x2a')]};if(_0xdceae0===_0xe855('0x7c')){_0x4d53b0[_0xe855('0x82')]={'attributes':[_0xe855('0x83')]};}return _0x5bec13[_0xe855('0x4f')+_0xdceae0+'Queues'](_0x4d53b0)['then'](function(_0x497e97){var _0x3d240e=_[_0xe855('0x2b')](_0x497e97,function(_0x29604b){var _0x2c1126=_[_0xe855('0x2b')](_0x4f7120,function(_0x480c69){var _0x4a0dd8={'where':{'UserId':_0x480c69,[_0xdceae0+'QueueId']:_0x29604b['id']},'transaction':_0x3ed76b};if(_0xdceae0===_0xe855('0x7c')){_0x4a0dd8[_0xe855('0x84')]={'penalty':_0x29604b[_0xe855('0x85')]['penalty']};}return db[_0xe855('0x86')+_0xdceae0+_0xe855('0x72')][_0xe855('0x87')](_0x4a0dd8)[_0xe855('0x26')](function(){socket[_0xe855('0x88')]('user'+_0xdceae0+'Queue:save',{'UserId':_0x480c69,[_0xdceae0+_0xe855('0x89')]:_0x29604b['id']});if(_0xdceae0!==_0xe855('0x7c')){return;}return db[_0xe855('0x86')][_0xe855('0x45')]({'where':{'id':_0x4f7120,'online':0x1},'attributes':['id',_0xe855('0x2a'),_0xe855('0x8a'),_0xe855('0x8b'),_0xe855('0x8c')],'raw':!![]})[_0xe855('0x26')](function(_0x4cc594){var _0x55b964=_[_0xe855('0x2b')](_0x4cc594,function(_0x457509){return db[_0xe855('0x8d')][_0xe855('0x8e')]({'membername':_0x457509[_0xe855('0x2a')],'UserId':_0x457509['id'],'queue_name':_0x29604b[_0xe855('0x2a')],'VoiceQueueId':_0x29604b['id'],'interface':_[_0xe855('0x8f')](_0x457509[_0xe855('0x8c')])?util['format']('SIP/%s',_0x457509[_0xe855('0x2a')]):_0x457509[_0xe855('0x8c')],'paused':_0x457509['voicePause']||![],'penalty':_0x29604b[_0xe855('0x85')]['penalty']},{'transaction':_0x3ed76b});});return Promise[_0xe855('0x90')](_0x55b964);});});});return Promise[_0xe855('0x90')](_0x2c1126);});return Promise['all'](_0x3d240e);})[_0xe855('0x26')](function(){return db[_0xe855('0x91')][_0xe855('0x74')]({'where':{'teamId':_0x1048c3}})[_0xe855('0x26')](function(_0x45a22a){if(_0x45a22a){var _0x554b59=_[_0xe855('0x2b')](_0x4f7120,function(_0xda8f4){db[_0xe855('0x92')][_0xe855('0x8e')]({'UserId':_0xda8f4,'VoicePrefixId':_0x45a22a[_0xe855('0x93')]});});return Promise['all'](_0x554b59);}});});});return Promise[_0xe855('0x90')](_0x49717e)['then'](function(){return _0x5bec13[_0xe855('0x7a')](_0x4f7120,{'transaction':_0x3ed76b})[_0xe855('0x94')](function(_0x2e82e7){return _0x2e82e7;});});});}})[_0xe855('0x26')](respondWithResult(_0xf6bc0c,null))[_0xe855('0x4b')](handleError(_0xf6bc0c,null));};exports[_0xe855('0x95')]=function(_0x34ecf7,_0x39a375){var _0x17eae9=_[_0xe855('0x7b')](_0x34ecf7[_0xe855('0x30')][_0xe855('0x76')])?_0x34ecf7[_0xe855('0x30')][_0xe855('0x76')]:[_0x34ecf7[_0xe855('0x30')]['ids']];var _0x395396=_0x34ecf7['params']['id'];return db[_0xe855('0x42')][_0xe855('0x4a')]({'where':{'id':_0x395396}})[_0xe855('0x26')](handleEntityNotFound(_0x39a375,null))['then'](function(_0x5c8651){if(_0x5c8651){var _0x2cb71f=['Voice',_0xe855('0x7d'),'Mail',_0xe855('0x7e'),_0xe855('0x7f'),_0xe855('0x80'),_0xe855('0x96')];return db['sequelize'][_0xe855('0x81')](function(_0x4c359c){var _0x3a3f6a=_[_0xe855('0x2b')](_0x2cb71f,function(_0x4c475c){var _0x377ed6={'attributes':['id',_0xe855('0x2a')]};return _0x5c8651['get'+_0x4c475c+_0xe855('0x75')](_0x377ed6)['then'](function(_0x393a36){var _0x42b7b7=_[_0xe855('0x2b')](_0x393a36,function(_0x4afb88){return _0x4afb88[_0xe855('0x95')](_0x17eae9,{'transaction':_0x4c359c})['then'](function(){var _0x19a509=_[_0xe855('0x2b')](_0x17eae9,function(_0x1aff6a){socket[_0xe855('0x88')]('user'+_0x4c475c+_0xe855('0x97'),{'UserId':Number(_0x1aff6a),[_0x4c475c+_0xe855('0x89')]:_0x4afb88['id']});if(_0x4c475c!=='Voice'){return;}return db[_0xe855('0x8d')][_0xe855('0x57')]({'where':{'VoiceQueueId':_0x4afb88['id'],'UserId':_0x1aff6a},'transaction':_0x4c359c});});return Promise[_0xe855('0x90')](_0x19a509);});});return Promise['all'](_0x42b7b7);});});return Promise[_0xe855('0x90')](_0x3a3f6a)[_0xe855('0x26')](function(){return _0x5c8651['removeAgents'](_0x17eae9,{'transaction':_0x4c359c});})[_0xe855('0x26')](function(){return db[_0xe855('0x91')][_0xe855('0x74')]({'where':{'teamId':_0x395396}})[_0xe855('0x26')](function(_0x5330c7){if(_0x5330c7){var _0x512312=_['map'](_0x17eae9,function(_0xa056ef){db[_0xe855('0x92')][_0xe855('0x57')]({'where':{'UserId':_0xa056ef,'VoicePrefixId':_0x5330c7[_0xe855('0x93')]}});});return Promise['all'](_0x512312);}});});});}})[_0xe855('0x26')](respondWithStatusCode(_0x39a375,null))[_0xe855('0x4b')](handleError(_0x39a375,null));};exports[_0xe855('0x98')]=function(_0xa56ab9,_0x5235eb,_0x123d70){var _0x551989={};var _0x3b9f5e={};var _0x3a0e78;var _0x22622d;return db[_0xe855('0x42')][_0xe855('0x74')]({'where':{'id':_0xa56ab9[_0xe855('0x48')]['id']}})[_0xe855('0x26')](handleEntityNotFound(_0x5235eb,null))[_0xe855('0x26')](function(_0x5eabbb){if(_0x5eabbb){_0x3a0e78=_0x5eabbb;_0x3b9f5e[_0xe855('0x34')]=_[_0xe855('0x31')](db['User'][_0xe855('0x2c')]);_0x3b9f5e[_0xe855('0x30')]=_[_0xe855('0x31')](_0xa56ab9['query']);_0x3b9f5e['filters']=_[_0xe855('0x33')](_0x3b9f5e[_0xe855('0x34')],_0x3b9f5e['query']);_0x551989['attributes']=_[_0xe855('0x33')](_0x3b9f5e[_0xe855('0x34')],qs['fields'](_0xa56ab9[_0xe855('0x30')][_0xe855('0x35')]));_0x551989[_0xe855('0x32')]=_0x551989[_0xe855('0x32')][_0xe855('0x36')]?_0x551989[_0xe855('0x32')]:_0x3b9f5e['model'];_0x551989[_0xe855('0x39')]=qs[_0xe855('0x3a')](_0xa56ab9[_0xe855('0x30')][_0xe855('0x3a')]);_0x551989['where']=qs['filters'](_['pick'](_0xa56ab9[_0xe855('0x30')],_0x3b9f5e[_0xe855('0x3c')]));if(_0xa56ab9[_0xe855('0x30')][_0xe855('0x3e')]){_0x551989[_0xe855('0x3b')]=_[_0xe855('0x40')](_0x551989[_0xe855('0x3b')],{'$or':_['map'](_0x551989[_0xe855('0x32')],function(_0x87cb48){var _0x2f84ae={};_0x2f84ae[_0x87cb48]={'$like':'%'+_0xa56ab9[_0xe855('0x30')][_0xe855('0x3e')]+'%'};return _0x2f84ae;})});}_0x551989=_[_0xe855('0x40')]({},_0x551989,_0xa56ab9['options']);return _0x3a0e78[_0xe855('0x98')](_0x551989);}})['then'](function(_0x426058){if(_0x426058){_0x22622d=_0x426058['length'];if(!_0xa56ab9[_0xe855('0x30')]['hasOwnProperty'](_0xe855('0x38'))){_0x551989[_0xe855('0x21')]=qs[_0xe855('0x21')](_0xa56ab9[_0xe855('0x30')]['limit']);_0x551989['offset']=qs[_0xe855('0x1f')](_0xa56ab9[_0xe855('0x30')]['offset']);}return _0x3a0e78[_0xe855('0x98')](_0x551989);}})['then'](function(_0x2c0f3a){if(_0x2c0f3a){return _0x2c0f3a?{'count':_0x22622d,'rows':_0x2c0f3a}:null;}})[_0xe855('0x26')](respondWithResult(_0x5235eb,null))[_0xe855('0x4b')](handleError(_0x5235eb,null));};
\ No newline at end of file