Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / team / team.controller.js
index 542b715..4d40182 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x120b=['channel','isValidChannel','ValidationError','Unknown\x20channel','capitalize','toLowerCase','Queue','order','Queues','addQueues','Sequelize','add','ids','removeQueues','remove','addAgents','Voice','Chat','Mail','Sms','Fax','Whatsapp','each','User','voicePause','interface','UserVoiceQueueRt','upsert','isNil','SIP/%s','omit','spread','emit','userTeam:save','removeAgents','voice','chat','mail','sms','fax','openchannel','whatsapp','getAgents','hasOwnProperty','eml-format','rimraf','fast-json-patch','bluebird','path','sox','to-csv','lodash','querystring','papaparse','ioredis','../../components/auth/service','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','count','offset','limit','set','json','reject','save','update','then','destroy','get','Teams','UserProfileResource','error','stack','name','index','map','Team','rawAttributes','fieldName','type','key','query','intersection','model','attributes','fields','length','nolimit','sort','where','filters','pick','filter','merge','includeAll','include','findAll','rows','catch','show','params','keys','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getQueues','findOne'];(function(_0x152238,_0x388f1b){var _0x273b78=function(_0x1c3fac){while(--_0x1c3fac){_0x152238['push'](_0x152238['shift']());}};_0x273b78(++_0x388f1b);}(_0x120b,0x19d));var _0xb120=function(_0x284a4b,_0x317044){_0x284a4b=_0x284a4b-0x0;var _0x57c292=_0x120b[_0x284a4b];return _0x57c292;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xb120('0x0'));var rimraf=require(_0xb120('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb120('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xb120('0x3'));var Mustache=require('mustache');var util=require('util');var path=require(_0xb120('0x4'));var sox=require(_0xb120('0x5'));var csv=require(_0xb120('0x6'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xb120('0x7'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xb120('0x6'));var querystring=require(_0xb120('0x8'));var Papa=require(_0xb120('0x9'));var Redis=require(_0xb120('0xa'));var authService=require(_0xb120('0xb'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xb120('0xc'))(_0xb120('0xd'));var utils=require('../../config/utils');var config=require(_0xb120('0xe'));var db=require(_0xb120('0xf'))['db'];config[_0xb120('0x10')]=_[_0xb120('0x11')](config['redis'],{'host':_0xb120('0x12'),'port':0x18eb});var socket=require(_0xb120('0x13'))(new Redis(config[_0xb120('0x10')]));require('./team.socket')[_0xb120('0x14')](socket);function respondWithStatusCode(_0x500958,_0x49f15d){_0x49f15d=_0x49f15d||0xcc;return function(_0x5186c0){if(_0x5186c0){return _0x500958[_0xb120('0x15')](_0x49f15d);}return _0x500958[_0xb120('0x16')](_0x49f15d)[_0xb120('0x17')]();};}function respondWithResult(_0x5ed0e9,_0x457e9b){_0x457e9b=_0x457e9b||0xc8;return function(_0x38a3cf){if(_0x38a3cf){return _0x5ed0e9[_0xb120('0x16')](_0x457e9b)['json'](_0x38a3cf);}};}function respondWithFilteredResult(_0x549b74,_0x79532d){return function(_0x589fb0){if(_0x589fb0){var _0x42c14e=_0x589fb0[_0xb120('0x18')],_0x52b4b3=_0x79532d[_0xb120('0x19')],_0x19738c=_0x79532d[_0xb120('0x19')]+_0x79532d[_0xb120('0x1a')],_0x520f1c;if(_0x19738c>=_0x42c14e){_0x19738c=_0x42c14e;_0x520f1c=0xc8;}else{_0x520f1c=0xce;}_0x549b74[_0xb120('0x16')](_0x520f1c);return _0x549b74[_0xb120('0x1b')]('Content-Range',_0x52b4b3+'-'+_0x19738c+'/'+_0x42c14e)[_0xb120('0x1c')](_0x589fb0);}return null;};}function patchUpdates(_0x345102){return function(_0x53f2b4){try{jsonpatch['apply'](_0x53f2b4,_0x345102,!![]);}catch(_0x1003db){return BPromise[_0xb120('0x1d')](_0x1003db);}return _0x53f2b4[_0xb120('0x1e')]();};}function saveUpdates(_0x544378,_0x582769){return function(_0x4ff7c5){if(_0x4ff7c5){return _0x4ff7c5[_0xb120('0x1f')](_0x544378)[_0xb120('0x20')](function(_0x382cfa){return _0x382cfa;});}return null;};}function removeEntity(_0x5a8598,_0x473c20){return function(_0x174535){if(_0x174535){return _0x174535[_0xb120('0x21')]()[_0xb120('0x20')](function(){var _0x30666a=_0x174535[_0xb120('0x22')]({'plain':!![]});var _0x1695be=_0xb120('0x23');return db[_0xb120('0x24')]['destroy']({'where':{'type':_0x1695be,'resourceId':_0x30666a['id']}})[_0xb120('0x20')](function(){return _0x174535;});})[_0xb120('0x20')](function(){_0x5a8598[_0xb120('0x16')](0xcc)[_0xb120('0x17')]();});}};}function handleEntityNotFound(_0x42da04,_0x2e53d2){return function(_0x24be25){if(!_0x24be25){_0x42da04['sendStatus'](0x194);}return _0x24be25;};}function handleError(_0x181e75,_0x3136f6){_0x3136f6=_0x3136f6||0x1f4;return function(_0x582847){logger[_0xb120('0x25')](_0x582847[_0xb120('0x26')]);if(_0x582847[_0xb120('0x27')]){delete _0x582847[_0xb120('0x27')];}_0x181e75['status'](_0x3136f6)['send'](_0x582847);};}exports[_0xb120('0x28')]=function(_0x6c7520,_0x48b4a9){var _0x1c1918={},_0x5cd647={},_0x15daf1={'count':0x0,'rows':[]};var _0x479dff=_[_0xb120('0x29')](db[_0xb120('0x2a')][_0xb120('0x2b')],function(_0xa014cb){return{'name':_0xa014cb[_0xb120('0x2c')],'type':_0xa014cb[_0xb120('0x2d')][_0xb120('0x2e')]};});_0x5cd647['model']=_['map'](_0x479dff,_0xb120('0x27'));_0x5cd647[_0xb120('0x2f')]=_['keys'](_0x6c7520[_0xb120('0x2f')]);_0x5cd647['filters']=_[_0xb120('0x30')](_0x5cd647[_0xb120('0x31')],_0x5cd647[_0xb120('0x2f')]);_0x1c1918[_0xb120('0x32')]=_[_0xb120('0x30')](_0x5cd647['model'],qs[_0xb120('0x33')](_0x6c7520['query']['fields']));_0x1c1918['attributes']=_0x1c1918[_0xb120('0x32')][_0xb120('0x34')]?_0x1c1918[_0xb120('0x32')]:_0x5cd647[_0xb120('0x31')];if(!_0x6c7520[_0xb120('0x2f')]['hasOwnProperty'](_0xb120('0x35'))){_0x1c1918[_0xb120('0x1a')]=qs[_0xb120('0x1a')](_0x6c7520['query']['limit']);_0x1c1918['offset']=qs[_0xb120('0x19')](_0x6c7520[_0xb120('0x2f')][_0xb120('0x19')]);}_0x1c1918['order']=qs[_0xb120('0x36')](_0x6c7520[_0xb120('0x2f')]['sort']);_0x1c1918[_0xb120('0x37')]=qs[_0xb120('0x38')](_[_0xb120('0x39')](_0x6c7520[_0xb120('0x2f')],_0x5cd647[_0xb120('0x38')]),_0x479dff);if(_0x6c7520[_0xb120('0x2f')][_0xb120('0x3a')]){_0x1c1918[_0xb120('0x37')]=_[_0xb120('0x3b')](_0x1c1918[_0xb120('0x37')],{'$or':_[_0xb120('0x29')](_0x479dff,function(_0xcdfabe){if(_0xcdfabe[_0xb120('0x2d')]!=='VIRTUAL'){var _0x1725f5={};_0x1725f5[_0xcdfabe['name']]={'$like':'%'+_0x6c7520['query'][_0xb120('0x3a')]+'%'};return _0x1725f5;}})});}_0x1c1918=_[_0xb120('0x3b')]({},_0x1c1918,_0x6c7520['options']);var _0x158393={'where':_0x1c1918['where']};return db[_0xb120('0x2a')][_0xb120('0x18')](_0x158393)[_0xb120('0x20')](function(_0x17bdc1){_0x15daf1[_0xb120('0x18')]=_0x17bdc1;if(_0x6c7520[_0xb120('0x2f')][_0xb120('0x3c')]){_0x1c1918[_0xb120('0x3d')]=[{'all':!![]}];}return db[_0xb120('0x2a')][_0xb120('0x3e')](_0x1c1918);})['then'](function(_0x277b1b){_0x15daf1[_0xb120('0x3f')]=_0x277b1b;return _0x15daf1;})[_0xb120('0x20')](respondWithFilteredResult(_0x48b4a9,_0x1c1918))[_0xb120('0x40')](handleError(_0x48b4a9,null));};exports[_0xb120('0x41')]=function(_0x160479,_0x2e4914){var _0x5746fb={'raw':![],'where':{'id':_0x160479[_0xb120('0x42')]['id']}},_0x119657={};_0x119657[_0xb120('0x31')]=_[_0xb120('0x43')](db['Team'][_0xb120('0x2b')]);_0x119657['query']=_[_0xb120('0x43')](_0x160479['query']);_0x119657[_0xb120('0x38')]=_[_0xb120('0x30')](_0x119657[_0xb120('0x31')],_0x119657[_0xb120('0x2f')]);_0x5746fb[_0xb120('0x32')]=_['intersection'](_0x119657[_0xb120('0x31')],qs[_0xb120('0x33')](_0x160479[_0xb120('0x2f')][_0xb120('0x33')]));_0x5746fb[_0xb120('0x32')]=_0x5746fb[_0xb120('0x32')][_0xb120('0x34')]?_0x5746fb[_0xb120('0x32')]:_0x119657[_0xb120('0x31')];if(_0x160479[_0xb120('0x2f')][_0xb120('0x3c')]){_0x5746fb['include']=[{'all':!![]}];}_0x5746fb=_[_0xb120('0x3b')]({},_0x5746fb,_0x160479[_0xb120('0x44')]);return db['Team'][_0xb120('0x45')](_0x5746fb)[_0xb120('0x20')](handleEntityNotFound(_0x2e4914,null))[_0xb120('0x20')](respondWithResult(_0x2e4914,null))[_0xb120('0x40')](handleError(_0x2e4914,null));};exports[_0xb120('0x46')]=function(_0x37bd63,_0x3b2eeb){return db['Team'][_0xb120('0x46')](_0x37bd63[_0xb120('0x47')],{})[_0xb120('0x20')](function(_0x45073d){var _0x524b44=_0x37bd63[_0xb120('0x48')][_0xb120('0x22')]({'plain':!![]});if(!_0x524b44)throw new Error(_0xb120('0x49'));if(_0x524b44['role']===_0xb120('0x48')){var _0x2be703=_0x45073d[_0xb120('0x22')]({'plain':!![]});var _0x436ad1=_0xb120('0x23');return db[_0xb120('0x4a')][_0xb120('0x45')]({'where':{'name':_0x436ad1,'userProfileId':_0x524b44[_0xb120('0x4b')]},'raw':!![]})['then'](function(_0x901cf6){if(_0x901cf6&&_0x901cf6['autoAssociation']===0x0){return db[_0xb120('0x24')][_0xb120('0x46')]({'name':_0x2be703[_0xb120('0x27')],'resourceId':_0x2be703['id'],'type':_0x901cf6[_0xb120('0x27')],'sectionId':_0x901cf6['id']},{})[_0xb120('0x20')](function(){return _0x45073d;});}else{return _0x45073d;}})['catch'](function(_0x21ac73){logger['error'](_0xb120('0x4c'),_0x21ac73);throw _0x21ac73;});}return _0x45073d;})[_0xb120('0x20')](respondWithResult(_0x3b2eeb,0xc9))[_0xb120('0x40')](handleError(_0x3b2eeb,null));};exports[_0xb120('0x1f')]=function(_0x125205,_0x157321){if(_0x125205[_0xb120('0x47')]['id']){delete _0x125205[_0xb120('0x47')]['id'];}return db[_0xb120('0x2a')][_0xb120('0x45')]({'where':{'id':_0x125205[_0xb120('0x42')]['id']}})['then'](handleEntityNotFound(_0x157321,null))[_0xb120('0x20')](saveUpdates(_0x125205[_0xb120('0x47')],null))['then'](respondWithResult(_0x157321,null))[_0xb120('0x40')](handleError(_0x157321,null));};exports[_0xb120('0x21')]=function(_0x46a63e,_0x1ddf46){return db[_0xb120('0x2a')][_0xb120('0x45')]({'where':{'id':_0x46a63e[_0xb120('0x42')]['id']}})['then'](handleEntityNotFound(_0x1ddf46,null))[_0xb120('0x20')](removeEntity(_0x1ddf46,null))[_0xb120('0x40')](handleError(_0x1ddf46,null));};exports[_0xb120('0x4d')]=function(_0x543b76,_0x313a1e,_0x1a2db4){return db[_0xb120('0x2a')][_0xb120('0x4e')]({'where':{'id':_0x543b76[_0xb120('0x42')]['id']}})[_0xb120('0x20')](handleEntityNotFound(_0x313a1e,null))['then'](function(_0x3d33a3){if(!_0x543b76['query'][_0xb120('0x4f')]||!utils[_0xb120('0x50')](_0x543b76[_0xb120('0x2f')][_0xb120('0x4f')])){throw new db['Sequelize'][(_0xb120('0x51'))](_0xb120('0x52'));}var _0x2bc193={};var _0x3a59ae={};_0x3a59ae[_0xb120('0x31')]=_['keys'](db[_[_0xb120('0x53')](_0x543b76['query']['channel'][_0xb120('0x54')]())+_0xb120('0x55')][_0xb120('0x2b')]);_0x3a59ae[_0xb120('0x2f')]=_['keys'](_0x543b76['query']);_0x3a59ae['filters']=_[_0xb120('0x30')](_0x3a59ae[_0xb120('0x31')],_0x3a59ae[_0xb120('0x2f')]);_0x2bc193[_0xb120('0x32')]=_[_0xb120('0x30')](_0x3a59ae['model'],qs[_0xb120('0x33')](_0x543b76[_0xb120('0x2f')][_0xb120('0x33')]));_0x2bc193[_0xb120('0x32')]=_0x2bc193[_0xb120('0x32')]['length']?_0x2bc193[_0xb120('0x32')]:_0x3a59ae['model'];_0x2bc193[_0xb120('0x1a')]=qs['limit'](_0x543b76[_0xb120('0x2f')]['limit']);_0x2bc193[_0xb120('0x19')]=qs[_0xb120('0x19')](_0x543b76[_0xb120('0x2f')][_0xb120('0x19')]);_0x2bc193[_0xb120('0x56')]=qs[_0xb120('0x36')](_0x543b76['query']['sort']);_0x2bc193[_0xb120('0x37')]=qs[_0xb120('0x38')](_[_0xb120('0x39')](_0x543b76['query'],_0x3a59ae[_0xb120('0x38')]));_0x2bc193=_[_0xb120('0x3b')]({},_0x2bc193,_0x543b76[_0xb120('0x44')]);return _0x3d33a3['get'+_[_0xb120('0x53')](_0x543b76['query'][_0xb120('0x4f')][_0xb120('0x54')]())+_0xb120('0x57')](_0x2bc193);})[_0xb120('0x20')](respondWithResult(_0x313a1e,null))[_0xb120('0x40')](handleError(_0x313a1e,null));};exports[_0xb120('0x58')]=function(_0xd5d416,_0xf24bf8,_0x3d9d78){return db[_0xb120('0x2a')][_0xb120('0x4e')]({'where':{'id':_0xd5d416['params']['id']}})[_0xb120('0x20')](function(_0x4721c3){if(_0x4721c3){if(!_0xd5d416['body'][_0xb120('0x4f')]||!utils[_0xb120('0x50')](_0xd5d416[_0xb120('0x47')][_0xb120('0x4f')])){throw new db[(_0xb120('0x59'))]['ValidationError']('Unknown\x20channel');}return _0x4721c3[_0xb120('0x5a')+_[_0xb120('0x53')](_0xd5d416[_0xb120('0x47')][_0xb120('0x4f')]['toLowerCase']())+_0xb120('0x57')](_0xd5d416[_0xb120('0x47')][_0xb120('0x5b')]);}return null;})[_0xb120('0x20')](handleEntityNotFound(_0xf24bf8,null))[_0xb120('0x20')](respondWithStatusCode(_0xf24bf8,null))[_0xb120('0x40')](handleError(_0xf24bf8,null));};exports[_0xb120('0x5c')]=function(_0x1516f3,_0x2ccadd,_0x4c0399){return db[_0xb120('0x2a')][_0xb120('0x4e')]({'where':{'id':_0x1516f3[_0xb120('0x42')]['id']}})['then'](function(_0x4c6fd0){if(_0x4c6fd0){if(!_0x1516f3[_0xb120('0x2f')][_0xb120('0x4f')]||!utils[_0xb120('0x50')](_0x1516f3[_0xb120('0x2f')][_0xb120('0x4f')])){throw new db[(_0xb120('0x59'))]['ValidationError'](_0xb120('0x52'));}return _0x4c6fd0[_0xb120('0x5d')+_['capitalize'](_0x1516f3[_0xb120('0x2f')]['channel'][_0xb120('0x54')]())+_0xb120('0x57')](_0x1516f3['query'][_0xb120('0x5b')]);}return null;})['then'](handleEntityNotFound(_0x2ccadd,null))[_0xb120('0x20')](respondWithStatusCode(_0x2ccadd,null))[_0xb120('0x40')](handleError(_0x2ccadd,null));};exports[_0xb120('0x5e')]=function(_0x27c817,_0x591cc2,_0xb88175){return db['Team'][_0xb120('0x45')]({'where':{'id':_0x27c817[_0xb120('0x42')]['id']}})[_0xb120('0x20')](handleEntityNotFound(_0x591cc2,null))['then'](function(_0x406111){if(_0x406111){var _0x46cb2a=[_0xb120('0x5f'),_0xb120('0x60'),_0xb120('0x61'),_0xb120('0x62'),_0xb120('0x63'),'Openchannel',_0xb120('0x64')];return BPromise[_0xb120('0x65')](_0x46cb2a,function(_0xb9c030){return _0x406111['get'+_0xb9c030+_0xb120('0x57')]({'attributes':['id',_0xb120('0x27')]})[_0xb120('0x20')](function(_0x22ad58){return BPromise['each'](_0x22ad58,function(_0xc9d15d){return _0xc9d15d[_0xb120('0x5e')](_0x27c817[_0xb120('0x47')][_0xb120('0x5b')])[_0xb120('0x20')](function(){if(_0xb9c030===_0xb120('0x5f')){return db[_0xb120('0x66')]['findAll']({'where':{'id':_0x27c817[_0xb120('0x47')]['ids']},'attributes':['id',_0xb120('0x27'),'online',_0xb120('0x67'),_0xb120('0x68')],'raw':!![]})['then'](function(_0x11fb28){return BPromise[_0xb120('0x65')](_[_0xb120('0x3a')](_0x11fb28,{'online':0x1}),function(_0x31b457){return db[_0xb120('0x69')][_0xb120('0x6a')]({'membername':_0x31b457[_0xb120('0x27')],'UserId':_0x31b457['id'],'queue_name':_0xc9d15d[_0xb120('0x27')],'VoiceQueueId':_0xc9d15d['id'],'interface':_[_0xb120('0x6b')](_0x31b457['interface'])?util['format'](_0xb120('0x6c'),_0x31b457[_0xb120('0x27')]):_0x31b457[_0xb120('0x68')],'paused':_0x31b457[_0xb120('0x67')]||![],'penalty':0x0});});});}});});})[_0xb120('0x20')](function(){return _0x406111;});})['then'](function(){return _0x406111;});}})[_0xb120('0x20')](function(_0x4aed0d){if(_0x4aed0d){return _0x4aed0d['addAgents'](_0x27c817[_0xb120('0x47')][_0xb120('0x5b')],_[_0xb120('0x6d')](_0x27c817[_0xb120('0x47')],['ids','id'])||{})[_0xb120('0x6e')](function(_0x44c93b){for(var _0x14e738=0x0;_0x14e738<_0x27c817[_0xb120('0x47')][_0xb120('0x5b')][_0xb120('0x34')];_0x14e738+=0x1){socket[_0xb120('0x6f')](_0xb120('0x70'),{'UserId':_0x27c817[_0xb120('0x47')][_0xb120('0x5b')][_0x14e738],'TeamId':_0x27c817['params']['id']});}return _0x44c93b;});}})['then'](respondWithResult(_0x591cc2,null))[_0xb120('0x40')](handleError(_0x591cc2,null));};exports[_0xb120('0x71')]=function(_0x5cc835,_0x48fc1a,_0x20aa2b){return db[_0xb120('0x2a')][_0xb120('0x45')]({'where':{'id':_0x5cc835[_0xb120('0x42')]['id']}})[_0xb120('0x20')](handleEntityNotFound(_0x48fc1a,null))['then'](function(_0xd8a199){if(_0xd8a199){return BPromise[_0xb120('0x65')]([_0xb120('0x72'),_0xb120('0x73'),_0xb120('0x74'),_0xb120('0x75'),_0xb120('0x76'),_0xb120('0x77'),_0xb120('0x78')],function(_0x4c4252){return _0xd8a199['get'+_[_0xb120('0x53')](_0x4c4252)+_0xb120('0x57')]({'attributes':['id',_0xb120('0x27')]})[_0xb120('0x20')](function(_0x395920){return BPromise[_0xb120('0x65')](_0x395920,function(_0x2f1317){return _0x2f1317[_0xb120('0x71')](_0x5cc835[_0xb120('0x2f')]['ids'])[_0xb120('0x20')](function(){if(_0x4c4252===_0xb120('0x72')){return db[_0xb120('0x69')][_0xb120('0x21')]({'where':{'VoiceQueueId':_0x2f1317['id'],'UserId':_0x5cc835['query'][_0xb120('0x5b')]}});}});});})[_0xb120('0x20')](function(){return _0xd8a199;});})[_0xb120('0x20')](function(){return _0xd8a199;});}})['then'](function(_0x4363c7){if(_0x4363c7){return _0x4363c7[_0xb120('0x71')](_0x5cc835[_0xb120('0x2f')][_0xb120('0x5b')])['then'](function(){if(_['isArray'](_0x5cc835['query'][_0xb120('0x5b')])){for(var _0x2a21e6=0x0;_0x2a21e6<_0x5cc835[_0xb120('0x2f')][_0xb120('0x5b')][_0xb120('0x34')];_0x2a21e6+=0x1){socket[_0xb120('0x6f')]('userTeam:remove',{'UserId':Number(_0x5cc835[_0xb120('0x2f')][_0xb120('0x5b')][_0x2a21e6]),'TeamId':Number(_0x5cc835['params']['id'])});}}else{socket[_0xb120('0x6f')]('userTeam:remove',{'UserId':Number(_0x5cc835[_0xb120('0x2f')]['ids']),'TeamId':Number(_0x5cc835[_0xb120('0x42')]['id'])});}});}})[_0xb120('0x20')](respondWithStatusCode(_0x48fc1a,null))[_0xb120('0x40')](handleError(_0x48fc1a,null));};exports['getAgents']=function(_0x183097,_0x4964fc,_0x323020){var _0x59f331={};var _0x51c219={};var _0x450656;var _0x124368;return db[_0xb120('0x2a')][_0xb120('0x4e')]({'where':{'id':_0x183097[_0xb120('0x42')]['id']}})['then'](handleEntityNotFound(_0x4964fc,null))[_0xb120('0x20')](function(_0x462333){if(_0x462333){_0x450656=_0x462333;_0x51c219['model']=_['keys'](db[_0xb120('0x66')]['rawAttributes']);_0x51c219[_0xb120('0x2f')]=_[_0xb120('0x43')](_0x183097[_0xb120('0x2f')]);_0x51c219[_0xb120('0x38')]=_['intersection'](_0x51c219['model'],_0x51c219[_0xb120('0x2f')]);_0x59f331[_0xb120('0x32')]=_[_0xb120('0x30')](_0x51c219[_0xb120('0x31')],qs[_0xb120('0x33')](_0x183097[_0xb120('0x2f')]['fields']));_0x59f331[_0xb120('0x32')]=_0x59f331[_0xb120('0x32')][_0xb120('0x34')]?_0x59f331[_0xb120('0x32')]:_0x51c219[_0xb120('0x31')];_0x59f331[_0xb120('0x56')]=qs[_0xb120('0x36')](_0x183097['query'][_0xb120('0x36')]);_0x59f331[_0xb120('0x37')]=qs[_0xb120('0x38')](_[_0xb120('0x39')](_0x183097['query'],_0x51c219[_0xb120('0x38')]));if(_0x183097[_0xb120('0x2f')][_0xb120('0x3a')]){_0x59f331[_0xb120('0x37')]=_[_0xb120('0x3b')](_0x59f331[_0xb120('0x37')],{'$or':_['map'](_0x59f331['attributes'],function(_0x1fe600){var _0x1e0345={};_0x1e0345[_0x1fe600]={'$like':'%'+_0x183097[_0xb120('0x2f')][_0xb120('0x3a')]+'%'};return _0x1e0345;})});}_0x59f331=_[_0xb120('0x3b')]({},_0x59f331,_0x183097[_0xb120('0x44')]);return _0x450656[_0xb120('0x79')](_0x59f331);}})[_0xb120('0x20')](function(_0x476e6e){if(_0x476e6e){_0x124368=_0x476e6e[_0xb120('0x34')];if(!_0x183097[_0xb120('0x2f')][_0xb120('0x7a')]('nolimit')){_0x59f331[_0xb120('0x1a')]=qs[_0xb120('0x1a')](_0x183097[_0xb120('0x2f')][_0xb120('0x1a')]);_0x59f331[_0xb120('0x19')]=qs[_0xb120('0x19')](_0x183097[_0xb120('0x2f')]['offset']);}return _0x450656[_0xb120('0x79')](_0x59f331);}})[_0xb120('0x20')](function(_0x2b53ae){if(_0x2b53ae){return _0x2b53ae?{'count':_0x124368,'rows':_0x2b53ae}:null;}})[_0xb120('0x20')](respondWithResult(_0x4964fc,null))['catch'](handleError(_0x4964fc,null));};
\ No newline at end of file
+var _0xf86c=['addQueues','Sequelize','Queues','ids','removeQueues','remove','Voice','Chat','Sms','Fax','Openchannel','Whatsapp','each','addAgents','User','online','voicePause','interface','UserVoiceQueueRt','upsert','isNil','SIP/%s','spread','emit','userTeam:save','removeAgents','voice','chat','sms','fax','openchannel','whatsapp','isArray','userTeam:remove','getAgents','html-pdf','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','count','offset','limit','set','apply','then','destroy','get','Teams','UserProfileResource','name','send','index','map','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','pick','filter','merge','type','options','Team','includeAll','include','findAll','rows','show','params','rawAttributes','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','getQueues','findOne','channel','isValidChannel','ValidationError','Unknown\x20channel','toLowerCase','Queue','sort','capitalize'];(function(_0x2db735,_0x5ddb29){var _0x445d0e=function(_0x571f5a){while(--_0x571f5a){_0x2db735['push'](_0x2db735['shift']());}};_0x445d0e(++_0x5ddb29);}(_0xf86c,0x11f));var _0xcf86=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xf86c[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xcf86('0x0'));var emlformat=require(_0xcf86('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xcf86('0x2'));var rp=require(_0xcf86('0x3'));var moment=require(_0xcf86('0x4'));var BPromise=require(_0xcf86('0x5'));var Mustache=require(_0xcf86('0x6'));var util=require(_0xcf86('0x7'));var path=require(_0xcf86('0x8'));var sox=require(_0xcf86('0x9'));var csv=require(_0xcf86('0xa'));var ejs=require(_0xcf86('0xb'));var fs=require('fs');var _=require(_0xcf86('0xc'));var squel=require('squel');var crypto=require(_0xcf86('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xcf86('0xe'));var toCsv=require(_0xcf86('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xcf86('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xcf86('0x10'));var as=require(_0xcf86('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xcf86('0x12'))('api');var utils=require(_0xcf86('0x13'));var config=require(_0xcf86('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xcf86('0x15'))['db'];config[_0xcf86('0x16')]=_['defaults'](config[_0xcf86('0x16')],{'host':_0xcf86('0x17'),'port':0x18eb});var socket=require(_0xcf86('0x18'))(new Redis(config[_0xcf86('0x16')]));require('./team.socket')[_0xcf86('0x19')](socket);function respondWithStatusCode(_0x10e253,_0x211aee){_0x211aee=_0x211aee||0xcc;return function(_0x1b8384){if(_0x1b8384){return _0x10e253[_0xcf86('0x1a')](_0x211aee);}return _0x10e253[_0xcf86('0x1b')](_0x211aee)[_0xcf86('0x1c')]();};}function respondWithResult(_0x348782,_0x51bd52){_0x51bd52=_0x51bd52||0xc8;return function(_0x1ccc97){if(_0x1ccc97){return _0x348782[_0xcf86('0x1b')](_0x51bd52)[_0xcf86('0x1d')](_0x1ccc97);}};}function respondWithFilteredResult(_0x43b07c,_0x27ff8f){return function(_0xa519d4){if(_0xa519d4){var _0x2d55c0=_0xa519d4[_0xcf86('0x1e')],_0x4f76c8=_0x27ff8f[_0xcf86('0x1f')],_0x10c2cd=_0x27ff8f[_0xcf86('0x1f')]+_0x27ff8f[_0xcf86('0x20')],_0x18e3a2;if(_0x10c2cd>=_0x2d55c0){_0x10c2cd=_0x2d55c0;_0x18e3a2=0xc8;}else{_0x18e3a2=0xce;}_0x43b07c['status'](_0x18e3a2);return _0x43b07c[_0xcf86('0x21')]('Content-Range',_0x4f76c8+'-'+_0x10c2cd+'/'+_0x2d55c0)[_0xcf86('0x1d')](_0xa519d4);}return null;};}function patchUpdates(_0xdcb271){return function(_0x4ed71c){try{jsonpatch[_0xcf86('0x22')](_0x4ed71c,_0xdcb271,!![]);}catch(_0x10b709){return BPromise['reject'](_0x10b709);}return _0x4ed71c['save']();};}function saveUpdates(_0x52c93a,_0x4e8658){return function(_0x3df226){if(_0x3df226){return _0x3df226['update'](_0x52c93a)[_0xcf86('0x23')](function(_0x293a4f){return _0x293a4f;});}return null;};}function removeEntity(_0x1aa1f3,_0x409b6c){return function(_0x328bc0){if(_0x328bc0){return _0x328bc0[_0xcf86('0x24')]()[_0xcf86('0x23')](function(){var _0x1ddc7d=_0x328bc0[_0xcf86('0x25')]({'plain':!![]});var _0x26929f=_0xcf86('0x26');return db[_0xcf86('0x27')][_0xcf86('0x24')]({'where':{'type':_0x26929f,'resourceId':_0x1ddc7d['id']}})[_0xcf86('0x23')](function(){return _0x328bc0;});})[_0xcf86('0x23')](function(){_0x1aa1f3[_0xcf86('0x1b')](0xcc)[_0xcf86('0x1c')]();});}};}function handleEntityNotFound(_0x21fd0e,_0x569977){return function(_0x28aef4){if(!_0x28aef4){_0x21fd0e['sendStatus'](0x194);}return _0x28aef4;};}function handleError(_0x11e458,_0x25a632){_0x25a632=_0x25a632||0x1f4;return function(_0x47229e){logger['error'](_0x47229e['stack']);if(_0x47229e['name']){delete _0x47229e[_0xcf86('0x28')];}_0x11e458['status'](_0x25a632)[_0xcf86('0x29')](_0x47229e);};}exports[_0xcf86('0x2a')]=function(_0x2dcfb8,_0x1fe869){var _0xb5323c={},_0x437b94={},_0x3097c7={'count':0x0,'rows':[]};var _0x5c8f96=_[_0xcf86('0x2b')](db['Team']['rawAttributes'],function(_0x3f16e7){return{'name':_0x3f16e7['fieldName'],'type':_0x3f16e7['type'][_0xcf86('0x2c')]};});_0x437b94[_0xcf86('0x2d')]=_[_0xcf86('0x2b')](_0x5c8f96,_0xcf86('0x28'));_0x437b94[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x2dcfb8['query']);_0x437b94[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x437b94[_0xcf86('0x2d')],_0x437b94[_0xcf86('0x2e')]);_0xb5323c[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x437b94[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x33')]));_0xb5323c['attributes']=_0xb5323c['attributes'][_0xcf86('0x34')]?_0xb5323c[_0xcf86('0x32')]:_0x437b94['model'];if(!_0x2dcfb8['query'][_0xcf86('0x35')](_0xcf86('0x36'))){_0xb5323c[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x2dcfb8['query'][_0xcf86('0x20')]);_0xb5323c[_0xcf86('0x1f')]=qs[_0xcf86('0x1f')](_0x2dcfb8['query'][_0xcf86('0x1f')]);}_0xb5323c[_0xcf86('0x37')]=qs['sort'](_0x2dcfb8[_0xcf86('0x2e')]['sort']);_0xb5323c[_0xcf86('0x38')]=qs['filters'](_[_0xcf86('0x39')](_0x2dcfb8[_0xcf86('0x2e')],_0x437b94[_0xcf86('0x30')]),_0x5c8f96);if(_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3a')]){_0xb5323c['where']=_[_0xcf86('0x3b')](_0xb5323c[_0xcf86('0x38')],{'$or':_[_0xcf86('0x2b')](_0x5c8f96,function(_0x5eee4e){if(_0x5eee4e[_0xcf86('0x3c')]!=='VIRTUAL'){var _0x21bb42={};_0x21bb42[_0x5eee4e[_0xcf86('0x28')]]={'$like':'%'+_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3a')]+'%'};return _0x21bb42;}})});}_0xb5323c=_[_0xcf86('0x3b')]({},_0xb5323c,_0x2dcfb8[_0xcf86('0x3d')]);var _0x5029e8={'where':_0xb5323c['where']};return db[_0xcf86('0x3e')][_0xcf86('0x1e')](_0x5029e8)[_0xcf86('0x23')](function(_0x480fdb){_0x3097c7[_0xcf86('0x1e')]=_0x480fdb;if(_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3f')]){_0xb5323c[_0xcf86('0x40')]=[{'all':!![]}];}return db[_0xcf86('0x3e')][_0xcf86('0x41')](_0xb5323c);})[_0xcf86('0x23')](function(_0x5966b6){_0x3097c7[_0xcf86('0x42')]=_0x5966b6;return _0x3097c7;})[_0xcf86('0x23')](respondWithFilteredResult(_0x1fe869,_0xb5323c))['catch'](handleError(_0x1fe869,null));};exports[_0xcf86('0x43')]=function(_0x33e92a,_0x27a089){var _0x18518b={'raw':![],'where':{'id':_0x33e92a[_0xcf86('0x44')]['id']}},_0x204fd5={};_0x204fd5[_0xcf86('0x2d')]=_[_0xcf86('0x2f')](db[_0xcf86('0x3e')][_0xcf86('0x45')]);_0x204fd5[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x33e92a[_0xcf86('0x2e')]);_0x204fd5[_0xcf86('0x30')]=_['intersection'](_0x204fd5[_0xcf86('0x2d')],_0x204fd5[_0xcf86('0x2e')]);_0x18518b[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x204fd5[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x33e92a[_0xcf86('0x2e')][_0xcf86('0x33')]));_0x18518b[_0xcf86('0x32')]=_0x18518b['attributes'][_0xcf86('0x34')]?_0x18518b[_0xcf86('0x32')]:_0x204fd5[_0xcf86('0x2d')];if(_0x33e92a[_0xcf86('0x2e')][_0xcf86('0x3f')]){_0x18518b['include']=[{'all':!![]}];}_0x18518b=_[_0xcf86('0x3b')]({},_0x18518b,_0x33e92a[_0xcf86('0x3d')]);return db[_0xcf86('0x3e')][_0xcf86('0x46')](_0x18518b)['then'](handleEntityNotFound(_0x27a089,null))['then'](respondWithResult(_0x27a089,null))[_0xcf86('0x47')](handleError(_0x27a089,null));};exports[_0xcf86('0x48')]=function(_0x138ead,_0x2392bd){return db[_0xcf86('0x3e')]['create'](_0x138ead[_0xcf86('0x49')],{})[_0xcf86('0x23')](function(_0x264f26){var _0x5d3b07=_0x138ead[_0xcf86('0x4a')][_0xcf86('0x25')]({'plain':!![]});if(!_0x5d3b07)throw new Error(_0xcf86('0x4b'));if(_0x5d3b07[_0xcf86('0x4c')]===_0xcf86('0x4a')){var _0x353b4a=_0x264f26[_0xcf86('0x25')]({'plain':!![]});var _0x2ddd87='Teams';return db['UserProfileSection'][_0xcf86('0x46')]({'where':{'name':_0x2ddd87,'userProfileId':_0x5d3b07[_0xcf86('0x4d')]},'raw':!![]})[_0xcf86('0x23')](function(_0x4a4008){if(_0x4a4008&&_0x4a4008['autoAssociation']===0x0){return db[_0xcf86('0x27')][_0xcf86('0x48')]({'name':_0x353b4a[_0xcf86('0x28')],'resourceId':_0x353b4a['id'],'type':_0x4a4008[_0xcf86('0x28')],'sectionId':_0x4a4008['id']},{})[_0xcf86('0x23')](function(){return _0x264f26;});}else{return _0x264f26;}})['catch'](function(_0x4bd781){logger[_0xcf86('0x4e')](_0xcf86('0x4f'),_0x4bd781);throw _0x4bd781;});}return _0x264f26;})[_0xcf86('0x23')](respondWithResult(_0x2392bd,0xc9))[_0xcf86('0x47')](handleError(_0x2392bd,null));};exports[_0xcf86('0x50')]=function(_0x424da,_0x27af8f){if(_0x424da[_0xcf86('0x49')]['id']){delete _0x424da[_0xcf86('0x49')]['id'];}return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x424da[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x27af8f,null))[_0xcf86('0x23')](saveUpdates(_0x424da[_0xcf86('0x49')],null))['then'](respondWithResult(_0x27af8f,null))[_0xcf86('0x47')](handleError(_0x27af8f,null));};exports[_0xcf86('0x24')]=function(_0x4a4403,_0x5487ab){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x4a4403[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x5487ab,null))[_0xcf86('0x23')](removeEntity(_0x5487ab,null))[_0xcf86('0x47')](handleError(_0x5487ab,null));};exports[_0xcf86('0x51')]=function(_0x3eb775,_0x315881,_0x78c63c){return db[_0xcf86('0x3e')][_0xcf86('0x52')]({'where':{'id':_0x3eb775[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x315881,null))[_0xcf86('0x23')](function(_0x284330){if(!_0x3eb775['query'][_0xcf86('0x53')]||!utils[_0xcf86('0x54')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')])){throw new db['Sequelize'][(_0xcf86('0x55'))](_0xcf86('0x56'));}var _0x2395f7={};var _0x10a79c={};_0x10a79c[_0xcf86('0x2d')]=_[_0xcf86('0x2f')](db[_['capitalize'](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')][_0xcf86('0x57')]())+_0xcf86('0x58')][_0xcf86('0x45')]);_0x10a79c[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x3eb775[_0xcf86('0x2e')]);_0x10a79c[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x10a79c[_0xcf86('0x2d')],_0x10a79c['query']);_0x2395f7[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x10a79c[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x3eb775[_0xcf86('0x2e')]['fields']));_0x2395f7['attributes']=_0x2395f7[_0xcf86('0x32')][_0xcf86('0x34')]?_0x2395f7[_0xcf86('0x32')]:_0x10a79c[_0xcf86('0x2d')];_0x2395f7[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x20')]);_0x2395f7['offset']=qs[_0xcf86('0x1f')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x1f')]);_0x2395f7[_0xcf86('0x37')]=qs[_0xcf86('0x59')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x59')]);_0x2395f7[_0xcf86('0x38')]=qs[_0xcf86('0x30')](_[_0xcf86('0x39')](_0x3eb775[_0xcf86('0x2e')],_0x10a79c[_0xcf86('0x30')]));_0x2395f7=_['merge']({},_0x2395f7,_0x3eb775[_0xcf86('0x3d')]);return _0x284330[_0xcf86('0x25')+_[_0xcf86('0x5a')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')][_0xcf86('0x57')]())+'Queues'](_0x2395f7);})['then'](respondWithResult(_0x315881,null))['catch'](handleError(_0x315881,null));};exports[_0xcf86('0x5b')]=function(_0x550bc0,_0x2968b8,_0x57255c){return db[_0xcf86('0x3e')]['findOne']({'where':{'id':_0x550bc0['params']['id']}})[_0xcf86('0x23')](function(_0x2100f8){if(_0x2100f8){if(!_0x550bc0[_0xcf86('0x49')][_0xcf86('0x53')]||!utils['isValidChannel'](_0x550bc0[_0xcf86('0x49')][_0xcf86('0x53')])){throw new db[(_0xcf86('0x5c'))]['ValidationError'](_0xcf86('0x56'));}return _0x2100f8['add'+_[_0xcf86('0x5a')](_0x550bc0[_0xcf86('0x49')]['channel'][_0xcf86('0x57')]())+_0xcf86('0x5d')](_0x550bc0['body'][_0xcf86('0x5e')]);}return null;})[_0xcf86('0x23')](handleEntityNotFound(_0x2968b8,null))[_0xcf86('0x23')](respondWithStatusCode(_0x2968b8,null))['catch'](handleError(_0x2968b8,null));};exports[_0xcf86('0x5f')]=function(_0xf0e230,_0x450ad9,_0x559877){return db[_0xcf86('0x3e')][_0xcf86('0x52')]({'where':{'id':_0xf0e230[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](function(_0x4e2e1e){if(_0x4e2e1e){if(!_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x53')]||!utils[_0xcf86('0x54')](_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x53')])){throw new db[(_0xcf86('0x5c'))][(_0xcf86('0x55'))](_0xcf86('0x56'));}return _0x4e2e1e[_0xcf86('0x60')+_['capitalize'](_0xf0e230['query'][_0xcf86('0x53')][_0xcf86('0x57')]())+'Queues'](_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x5e')]);}return null;})[_0xcf86('0x23')](handleEntityNotFound(_0x450ad9,null))[_0xcf86('0x23')](respondWithStatusCode(_0x450ad9,null))[_0xcf86('0x47')](handleError(_0x450ad9,null));};exports['addAgents']=function(_0x18e898,_0x11b629,_0x131d61){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x18e898['params']['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x11b629,null))[_0xcf86('0x23')](function(_0x2cb634){if(_0x2cb634){var _0x1fcb82=[_0xcf86('0x61'),_0xcf86('0x62'),'Mail',_0xcf86('0x63'),_0xcf86('0x64'),_0xcf86('0x65'),_0xcf86('0x66')];return BPromise[_0xcf86('0x67')](_0x1fcb82,function(_0x45e9ec){return _0x2cb634[_0xcf86('0x25')+_0x45e9ec+_0xcf86('0x5d')]({'attributes':['id',_0xcf86('0x28')]})[_0xcf86('0x23')](function(_0x15b521){return BPromise['each'](_0x15b521,function(_0x4c4a52){return _0x4c4a52[_0xcf86('0x68')](_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')])['then'](function(){if(_0x45e9ec==='Voice'){return db[_0xcf86('0x69')][_0xcf86('0x41')]({'where':{'id':_0x18e898['body']['ids']},'attributes':['id',_0xcf86('0x28'),_0xcf86('0x6a'),_0xcf86('0x6b'),_0xcf86('0x6c')],'raw':!![]})[_0xcf86('0x23')](function(_0x265802){return BPromise[_0xcf86('0x67')](_[_0xcf86('0x3a')](_0x265802,{'online':0x1}),function(_0x8d6a51){return db[_0xcf86('0x6d')][_0xcf86('0x6e')]({'membername':_0x8d6a51[_0xcf86('0x28')],'UserId':_0x8d6a51['id'],'queue_name':_0x4c4a52[_0xcf86('0x28')],'VoiceQueueId':_0x4c4a52['id'],'interface':_[_0xcf86('0x6f')](_0x8d6a51['interface'])?util['format'](_0xcf86('0x70'),_0x8d6a51[_0xcf86('0x28')]):_0x8d6a51[_0xcf86('0x6c')],'paused':_0x8d6a51[_0xcf86('0x6b')]||![],'penalty':0x0});});});}});});})[_0xcf86('0x23')](function(){return _0x2cb634;});})[_0xcf86('0x23')](function(){return _0x2cb634;});}})[_0xcf86('0x23')](function(_0x15d468){if(_0x15d468){return _0x15d468['addAgents'](_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')],_['omit'](_0x18e898[_0xcf86('0x49')],[_0xcf86('0x5e'),'id'])||{})[_0xcf86('0x71')](function(_0x54fda8){for(var _0xd2e31e=0x0;_0xd2e31e<_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')][_0xcf86('0x34')];_0xd2e31e+=0x1){socket[_0xcf86('0x72')](_0xcf86('0x73'),{'UserId':_0x18e898['body']['ids'][_0xd2e31e],'TeamId':_0x18e898[_0xcf86('0x44')]['id']});}return _0x54fda8;});}})[_0xcf86('0x23')](respondWithResult(_0x11b629,null))[_0xcf86('0x47')](handleError(_0x11b629,null));};exports[_0xcf86('0x74')]=function(_0x40fd1a,_0x45f981,_0x319346){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x40fd1a[_0xcf86('0x44')]['id']}})['then'](handleEntityNotFound(_0x45f981,null))[_0xcf86('0x23')](function(_0x339856){if(_0x339856){return BPromise[_0xcf86('0x67')]([_0xcf86('0x75'),_0xcf86('0x76'),'mail',_0xcf86('0x77'),_0xcf86('0x78'),_0xcf86('0x79'),_0xcf86('0x7a')],function(_0x9ac1a5){return _0x339856[_0xcf86('0x25')+_[_0xcf86('0x5a')](_0x9ac1a5)+_0xcf86('0x5d')]({'attributes':['id',_0xcf86('0x28')]})[_0xcf86('0x23')](function(_0x5ffa59){return BPromise[_0xcf86('0x67')](_0x5ffa59,function(_0x467cc7){return _0x467cc7['removeAgents'](_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')])[_0xcf86('0x23')](function(){if(_0x9ac1a5===_0xcf86('0x75')){return db[_0xcf86('0x6d')][_0xcf86('0x24')]({'where':{'VoiceQueueId':_0x467cc7['id'],'UserId':_0x40fd1a[_0xcf86('0x2e')]['ids']}});}});});})['then'](function(){return _0x339856;});})[_0xcf86('0x23')](function(){return _0x339856;});}})[_0xcf86('0x23')](function(_0x2966b3){if(_0x2966b3){return _0x2966b3[_0xcf86('0x74')](_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')])[_0xcf86('0x23')](function(){if(_[_0xcf86('0x7b')](_0x40fd1a['query'][_0xcf86('0x5e')])){for(var _0xcab53a=0x0;_0xcab53a<_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')][_0xcf86('0x34')];_0xcab53a+=0x1){socket['emit'](_0xcf86('0x7c'),{'UserId':Number(_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')][_0xcab53a]),'TeamId':Number(_0x40fd1a['params']['id'])});}}else{socket['emit'](_0xcf86('0x7c'),{'UserId':Number(_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')]),'TeamId':Number(_0x40fd1a[_0xcf86('0x44')]['id'])});}});}})[_0xcf86('0x23')](respondWithStatusCode(_0x45f981,null))['catch'](handleError(_0x45f981,null));};exports[_0xcf86('0x7d')]=function(_0x319ada,_0x457e08,_0x4cf4bf){var _0x31f519={};var _0x32b1e7={};var _0x3fc4ff;var _0x1b41f7;return db[_0xcf86('0x3e')]['findOne']({'where':{'id':_0x319ada[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x457e08,null))[_0xcf86('0x23')](function(_0x11a059){if(_0x11a059){_0x3fc4ff=_0x11a059;_0x32b1e7['model']=_[_0xcf86('0x2f')](db[_0xcf86('0x69')][_0xcf86('0x45')]);_0x32b1e7[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x319ada[_0xcf86('0x2e')]);_0x32b1e7[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x32b1e7[_0xcf86('0x2d')],_0x32b1e7[_0xcf86('0x2e')]);_0x31f519[_0xcf86('0x32')]=_['intersection'](_0x32b1e7[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x319ada[_0xcf86('0x2e')]['fields']));_0x31f519[_0xcf86('0x32')]=_0x31f519[_0xcf86('0x32')][_0xcf86('0x34')]?_0x31f519[_0xcf86('0x32')]:_0x32b1e7['model'];_0x31f519['order']=qs[_0xcf86('0x59')](_0x319ada[_0xcf86('0x2e')]['sort']);_0x31f519['where']=qs[_0xcf86('0x30')](_[_0xcf86('0x39')](_0x319ada['query'],_0x32b1e7['filters']));if(_0x319ada['query']['filter']){_0x31f519[_0xcf86('0x38')]=_['merge'](_0x31f519[_0xcf86('0x38')],{'$or':_[_0xcf86('0x2b')](_0x31f519['attributes'],function(_0x32b0b5){var _0x99972a={};_0x99972a[_0x32b0b5]={'$like':'%'+_0x319ada[_0xcf86('0x2e')][_0xcf86('0x3a')]+'%'};return _0x99972a;})});}_0x31f519=_[_0xcf86('0x3b')]({},_0x31f519,_0x319ada['options']);return _0x3fc4ff[_0xcf86('0x7d')](_0x31f519);}})[_0xcf86('0x23')](function(_0xbe67a8){if(_0xbe67a8){_0x1b41f7=_0xbe67a8[_0xcf86('0x34')];if(!_0x319ada[_0xcf86('0x2e')][_0xcf86('0x35')]('nolimit')){_0x31f519[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x319ada[_0xcf86('0x2e')][_0xcf86('0x20')]);_0x31f519[_0xcf86('0x1f')]=qs['offset'](_0x319ada[_0xcf86('0x2e')][_0xcf86('0x1f')]);}return _0x3fc4ff[_0xcf86('0x7d')](_0x31f519);}})[_0xcf86('0x23')](function(_0x38aff2){if(_0x38aff2){return _0x38aff2?{'count':_0x1b41f7,'rows':_0x38aff2}:null;}})['then'](respondWithResult(_0x457e08,null))[_0xcf86('0x47')](handleError(_0x457e08,null));};
\ No newline at end of file