Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / team / team.controller.js
index 0879a16..4d40182 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 _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