Built motion from commit (unavailable).|2.5.25
[motion2.git] / server / api / team / team.controller.js
index 0879a16..e285c96 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 _0x8619=['send','index','map','Team','rawAttributes','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','findOne','channel','isValidChannel','Sequelize','ValidationError','Unknown\x20channel','capitalize','Queue','toLowerCase','addQueues','Queues','ids','removeQueues','remove','addAgents','Voice','Chat','Sms','Whatsapp','sequelize','penalty','QueueId','TeamVoiceQueue','User','findOrCreate','emit','Queue:save','online','voicePause','interface','UserVoiceQueueRt','upsert','format','SIP/%s','all','removeAgents','Fax','Openchannel','transaction','parse','Queue:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','register','status','end','count','offset','set','Content-Range','json','apply','reject','then','destroy','get','Teams','UserProfileResource','sendStatus','error','stack','name'];(function(_0x45ae3b,_0xce3adc){var _0x3443ec=function(_0x382687){while(--_0x382687){_0x45ae3b['push'](_0x45ae3b['shift']());}};_0x3443ec(++_0xce3adc);}(_0x8619,0xd5));var _0x9861=function(_0x6f3cfa,_0x45d689){_0x6f3cfa=_0x6f3cfa-0x0;var _0x41aa4e=_0x8619[_0x6f3cfa];return _0x41aa4e;};'use strict';var pdf=require(_0x9861('0x0'));var emlformat=require(_0x9861('0x1'));var rimraf=require(_0x9861('0x2'));var zipdir=require(_0x9861('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9861('0x4'));var moment=require(_0x9861('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x9861('0x6'));var util=require(_0x9861('0x7'));var path=require(_0x9861('0x8'));var sox=require(_0x9861('0x9'));var csv=require(_0x9861('0xa'));var ejs=require(_0x9861('0xb'));var fs=require('fs');var _=require(_0x9861('0xc'));var squel=require(_0x9861('0xd'));var crypto=require(_0x9861('0xe'));var jsforce=require(_0x9861('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x9861('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x9861('0x10'));var qs=require(_0x9861('0x11'));var as=require(_0x9861('0x12'));var hardwareService=require(_0x9861('0x13'));var logger=require('../../config/logger')(_0x9861('0x14'));var utils=require(_0x9861('0x15'));var config=require(_0x9861('0x16'));var licenseUtil=require(_0x9861('0x17'));var db=require(_0x9861('0x18'))['db'];config['redis']=_[_0x9861('0x19')](config[_0x9861('0x1a')],{'host':'localhost','port':0x18eb});var socket=require(_0x9861('0x1b'))(new Redis(config[_0x9861('0x1a')]));require('./team.socket')[_0x9861('0x1c')](socket);function respondWithStatusCode(_0x231867,_0xe8c3fd){_0xe8c3fd=_0xe8c3fd||0xcc;return function(_0x2635cb){if(_0x2635cb){return _0x231867['sendStatus'](_0xe8c3fd);}return _0x231867[_0x9861('0x1d')](_0xe8c3fd)[_0x9861('0x1e')]();};}function respondWithResult(_0x5671e6,_0x29ed0c){_0x29ed0c=_0x29ed0c||0xc8;return function(_0x57b9ba){if(_0x57b9ba){return _0x5671e6['status'](_0x29ed0c)['json'](_0x57b9ba);}};}function respondWithFilteredResult(_0xf79a19,_0x2d9975){return function(_0x307e51){if(_0x307e51){var _0x17c217=_0x307e51[_0x9861('0x1f')],_0x3d0c54=_0x2d9975[_0x9861('0x20')],_0x7a069e=_0x2d9975['offset']+_0x2d9975['limit'],_0x188ad1;if(_0x7a069e>=_0x17c217){_0x7a069e=_0x17c217;_0x188ad1=0xc8;}else{_0x188ad1=0xce;}_0xf79a19[_0x9861('0x1d')](_0x188ad1);return _0xf79a19[_0x9861('0x21')](_0x9861('0x22'),_0x3d0c54+'-'+_0x7a069e+'/'+_0x17c217)[_0x9861('0x23')](_0x307e51);}return null;};}function patchUpdates(_0x3e4150){return function(_0x5df569){try{jsonpatch[_0x9861('0x24')](_0x5df569,_0x3e4150,!![]);}catch(_0x284d56){return BPromise[_0x9861('0x25')](_0x284d56);}return _0x5df569['save']();};}function saveUpdates(_0xea9f7b,_0x3f2b52){return function(_0x2e64f5){if(_0x2e64f5){return _0x2e64f5['update'](_0xea9f7b)[_0x9861('0x26')](function(_0x110dea){return _0x110dea;});}return null;};}function removeEntity(_0x1ad899,_0x5db6e9){return function(_0x415e02){if(_0x415e02){return _0x415e02[_0x9861('0x27')]()[_0x9861('0x26')](function(){var _0x2cdc61=_0x415e02[_0x9861('0x28')]({'plain':!![]});var _0x37de35=_0x9861('0x29');return db[_0x9861('0x2a')][_0x9861('0x27')]({'where':{'type':_0x37de35,'resourceId':_0x2cdc61['id']}})[_0x9861('0x26')](function(){return _0x415e02;});})[_0x9861('0x26')](function(){_0x1ad899[_0x9861('0x1d')](0xcc)[_0x9861('0x1e')]();});}};}function handleEntityNotFound(_0x2cc989,_0x5de1ad){return function(_0x1603dc){if(!_0x1603dc){_0x2cc989[_0x9861('0x2b')](0x194);}return _0x1603dc;};}function handleError(_0x4f5399,_0x114dfc){_0x114dfc=_0x114dfc||0x1f4;return function(_0x218d42){logger[_0x9861('0x2c')](_0x218d42[_0x9861('0x2d')]);if(_0x218d42[_0x9861('0x2e')]){delete _0x218d42[_0x9861('0x2e')];}_0x4f5399[_0x9861('0x1d')](_0x114dfc)[_0x9861('0x2f')](_0x218d42);};}exports[_0x9861('0x30')]=function(_0x352d9a,_0x15dfdb){var _0x2eaa18={},_0x9da03c={},_0x18ef6f={'count':0x0,'rows':[]};var _0x11f4ed=_[_0x9861('0x31')](db[_0x9861('0x32')][_0x9861('0x33')],function(_0x2d6842){return{'name':_0x2d6842['fieldName'],'type':_0x2d6842[_0x9861('0x34')]['key']};});_0x9da03c[_0x9861('0x35')]=_[_0x9861('0x31')](_0x11f4ed,_0x9861('0x2e'));_0x9da03c[_0x9861('0x36')]=_[_0x9861('0x37')](_0x352d9a[_0x9861('0x36')]);_0x9da03c[_0x9861('0x38')]=_[_0x9861('0x39')](_0x9da03c[_0x9861('0x35')],_0x9da03c[_0x9861('0x36')]);_0x2eaa18[_0x9861('0x3a')]=_[_0x9861('0x39')](_0x9da03c['model'],qs['fields'](_0x352d9a[_0x9861('0x36')][_0x9861('0x3b')]));_0x2eaa18[_0x9861('0x3a')]=_0x2eaa18[_0x9861('0x3a')][_0x9861('0x3c')]?_0x2eaa18[_0x9861('0x3a')]:_0x9da03c[_0x9861('0x35')];if(!_0x352d9a['query'][_0x9861('0x3d')]('nolimit')){_0x2eaa18[_0x9861('0x3e')]=qs['limit'](_0x352d9a[_0x9861('0x36')][_0x9861('0x3e')]);_0x2eaa18[_0x9861('0x20')]=qs['offset'](_0x352d9a[_0x9861('0x36')]['offset']);}_0x2eaa18[_0x9861('0x3f')]=qs['sort'](_0x352d9a[_0x9861('0x36')][_0x9861('0x40')]);_0x2eaa18[_0x9861('0x41')]=qs[_0x9861('0x38')](_[_0x9861('0x42')](_0x352d9a[_0x9861('0x36')],_0x9da03c[_0x9861('0x38')]),_0x11f4ed);if(_0x352d9a[_0x9861('0x36')][_0x9861('0x43')]){_0x2eaa18[_0x9861('0x41')]=_[_0x9861('0x44')](_0x2eaa18['where'],{'$or':_[_0x9861('0x31')](_0x11f4ed,function(_0x392eba){if(_0x392eba[_0x9861('0x34')]!==_0x9861('0x45')){var _0x3fc017={};_0x3fc017[_0x392eba[_0x9861('0x2e')]]={'$like':'%'+_0x352d9a['query'][_0x9861('0x43')]+'%'};return _0x3fc017;}})});}_0x2eaa18=_[_0x9861('0x44')]({},_0x2eaa18,_0x352d9a[_0x9861('0x46')]);var _0x2b853f={'where':_0x2eaa18[_0x9861('0x41')]};return db[_0x9861('0x32')]['count'](_0x2b853f)['then'](function(_0x3b7b66){_0x18ef6f[_0x9861('0x1f')]=_0x3b7b66;if(_0x352d9a[_0x9861('0x36')][_0x9861('0x47')]){_0x2eaa18[_0x9861('0x48')]=[{'all':!![]}];}return db['Team'][_0x9861('0x49')](_0x2eaa18);})[_0x9861('0x26')](function(_0x497d51){_0x18ef6f[_0x9861('0x4a')]=_0x497d51;return _0x18ef6f;})[_0x9861('0x26')](respondWithFilteredResult(_0x15dfdb,_0x2eaa18))[_0x9861('0x4b')](handleError(_0x15dfdb,null));};exports[_0x9861('0x4c')]=function(_0x3db813,_0x5b7c0b){var _0xf62225={'raw':![],'where':{'id':_0x3db813[_0x9861('0x4d')]['id']}},_0x12c28b={};_0x12c28b['model']=_['keys'](db[_0x9861('0x32')][_0x9861('0x33')]);_0x12c28b['query']=_[_0x9861('0x37')](_0x3db813[_0x9861('0x36')]);_0x12c28b[_0x9861('0x38')]=_[_0x9861('0x39')](_0x12c28b[_0x9861('0x35')],_0x12c28b['query']);_0xf62225[_0x9861('0x3a')]=_[_0x9861('0x39')](_0x12c28b['model'],qs['fields'](_0x3db813[_0x9861('0x36')][_0x9861('0x3b')]));_0xf62225[_0x9861('0x3a')]=_0xf62225[_0x9861('0x3a')][_0x9861('0x3c')]?_0xf62225[_0x9861('0x3a')]:_0x12c28b[_0x9861('0x35')];if(_0x3db813[_0x9861('0x36')]['includeAll']){_0xf62225[_0x9861('0x48')]=[{'all':!![]}];}_0xf62225=_[_0x9861('0x44')]({},_0xf62225,_0x3db813[_0x9861('0x46')]);return db[_0x9861('0x32')][_0x9861('0x4e')](_0xf62225)[_0x9861('0x26')](handleEntityNotFound(_0x5b7c0b,null))[_0x9861('0x26')](respondWithResult(_0x5b7c0b,null))[_0x9861('0x4b')](handleError(_0x5b7c0b,null));};exports[_0x9861('0x4f')]=function(_0xa742e2,_0x580f4a){return db[_0x9861('0x32')][_0x9861('0x4f')](_0xa742e2[_0x9861('0x50')],{})['then'](function(_0x5631e4){var _0x436b3a=_0xa742e2[_0x9861('0x51')]['get']({'plain':!![]});if(!_0x436b3a)throw new Error(_0x9861('0x52'));if(_0x436b3a[_0x9861('0x53')]===_0x9861('0x51')){var _0x3cf527=_0x5631e4['get']({'plain':!![]});var _0x5608e3=_0x9861('0x29');return db['UserProfileSection'][_0x9861('0x4e')]({'where':{'name':_0x5608e3,'userProfileId':_0x436b3a[_0x9861('0x54')]},'raw':!![]})[_0x9861('0x26')](function(_0x520412){if(_0x520412&&_0x520412[_0x9861('0x55')]===0x0){return db['UserProfileResource']['create']({'name':_0x3cf527[_0x9861('0x2e')],'resourceId':_0x3cf527['id'],'type':_0x520412[_0x9861('0x2e')],'sectionId':_0x520412['id']},{})[_0x9861('0x26')](function(){return _0x5631e4;});}else{return _0x5631e4;}})['catch'](function(_0x3f138){logger[_0x9861('0x2c')](_0x9861('0x56'),_0x3f138);throw _0x3f138;});}return _0x5631e4;})[_0x9861('0x26')](respondWithResult(_0x580f4a,0xc9))['catch'](handleError(_0x580f4a,null));};exports[_0x9861('0x57')]=function(_0x2a8c36,_0x299622){if(_0x2a8c36['body']['id']){delete _0x2a8c36[_0x9861('0x50')]['id'];}return db[_0x9861('0x32')][_0x9861('0x4e')]({'where':{'id':_0x2a8c36['params']['id']}})[_0x9861('0x26')](handleEntityNotFound(_0x299622,null))[_0x9861('0x26')](saveUpdates(_0x2a8c36[_0x9861('0x50')],null))[_0x9861('0x26')](respondWithResult(_0x299622,null))['catch'](handleError(_0x299622,null));};exports[_0x9861('0x27')]=function(_0x1a94bd,_0x343aac){return db[_0x9861('0x32')]['find']({'where':{'id':_0x1a94bd[_0x9861('0x4d')]['id']}})[_0x9861('0x26')](handleEntityNotFound(_0x343aac,null))[_0x9861('0x26')](removeEntity(_0x343aac,null))[_0x9861('0x4b')](handleError(_0x343aac,null));};exports['getQueues']=function(_0x3859c2,_0x1ce9fe,_0x2a6958){return db[_0x9861('0x32')][_0x9861('0x58')]({'where':{'id':_0x3859c2['params']['id']}})['then'](handleEntityNotFound(_0x1ce9fe,null))[_0x9861('0x26')](function(_0x1ce5db){if(!_0x3859c2[_0x9861('0x36')][_0x9861('0x59')]||!utils[_0x9861('0x5a')](_0x3859c2[_0x9861('0x36')]['channel'])){throw new db[(_0x9861('0x5b'))][(_0x9861('0x5c'))](_0x9861('0x5d'));}var _0x2577c6={};var _0x4283a6={};_0x4283a6[_0x9861('0x35')]=_[_0x9861('0x37')](db[_[_0x9861('0x5e')](_0x3859c2[_0x9861('0x36')]['channel']['toLowerCase']())+_0x9861('0x5f')][_0x9861('0x33')]);_0x4283a6[_0x9861('0x36')]=_[_0x9861('0x37')](_0x3859c2[_0x9861('0x36')]);_0x4283a6['filters']=_[_0x9861('0x39')](_0x4283a6['model'],_0x4283a6[_0x9861('0x36')]);_0x2577c6[_0x9861('0x3a')]=_[_0x9861('0x39')](_0x4283a6[_0x9861('0x35')],qs['fields'](_0x3859c2[_0x9861('0x36')]['fields']));_0x2577c6['attributes']=_0x2577c6[_0x9861('0x3a')][_0x9861('0x3c')]?_0x2577c6[_0x9861('0x3a')]:_0x4283a6[_0x9861('0x35')];_0x2577c6['limit']=qs[_0x9861('0x3e')](_0x3859c2[_0x9861('0x36')][_0x9861('0x3e')]);_0x2577c6['offset']=qs[_0x9861('0x20')](_0x3859c2[_0x9861('0x36')][_0x9861('0x20')]);_0x2577c6[_0x9861('0x3f')]=qs['sort'](_0x3859c2[_0x9861('0x36')][_0x9861('0x40')]);_0x2577c6['where']=qs[_0x9861('0x38')](_[_0x9861('0x42')](_0x3859c2[_0x9861('0x36')],_0x4283a6[_0x9861('0x38')]));_0x2577c6=_[_0x9861('0x44')]({},_0x2577c6,_0x3859c2['options']);return _0x1ce5db[_0x9861('0x28')+_[_0x9861('0x5e')](_0x3859c2[_0x9861('0x36')][_0x9861('0x59')][_0x9861('0x60')]())+'Queues'](_0x2577c6);})[_0x9861('0x26')](respondWithResult(_0x1ce9fe,null))[_0x9861('0x4b')](handleError(_0x1ce9fe,null));};exports[_0x9861('0x61')]=function(_0x1a425c,_0x31f3dd,_0xad7fbd){return db['Team']['findOne']({'where':{'id':_0x1a425c[_0x9861('0x4d')]['id']}})[_0x9861('0x26')](function(_0x304643){if(_0x304643){if(!_0x1a425c[_0x9861('0x50')][_0x9861('0x59')]||!utils[_0x9861('0x5a')](_0x1a425c['body'][_0x9861('0x59')])){throw new db[(_0x9861('0x5b'))][(_0x9861('0x5c'))]('Unknown\x20channel');}return _0x304643['add'+_[_0x9861('0x5e')](_0x1a425c[_0x9861('0x50')][_0x9861('0x59')][_0x9861('0x60')]())+_0x9861('0x62')](_0x1a425c[_0x9861('0x50')][_0x9861('0x63')]);}return null;})['then'](handleEntityNotFound(_0x31f3dd,null))['then'](respondWithStatusCode(_0x31f3dd,null))[_0x9861('0x4b')](handleError(_0x31f3dd,null));};exports[_0x9861('0x64')]=function(_0x581ed5,_0x166ff8,_0xeeda3b){return db[_0x9861('0x32')][_0x9861('0x58')]({'where':{'id':_0x581ed5[_0x9861('0x4d')]['id']}})[_0x9861('0x26')](function(_0x5503c7){if(_0x5503c7){if(!_0x581ed5[_0x9861('0x36')][_0x9861('0x59')]||!utils[_0x9861('0x5a')](_0x581ed5['query'][_0x9861('0x59')])){throw new db[(_0x9861('0x5b'))][(_0x9861('0x5c'))](_0x9861('0x5d'));}return _0x5503c7[_0x9861('0x65')+_[_0x9861('0x5e')](_0x581ed5[_0x9861('0x36')][_0x9861('0x59')][_0x9861('0x60')]())+_0x9861('0x62')](_0x581ed5[_0x9861('0x36')][_0x9861('0x63')]);}return null;})[_0x9861('0x26')](handleEntityNotFound(_0x166ff8,null))[_0x9861('0x26')](respondWithStatusCode(_0x166ff8,null))[_0x9861('0x4b')](handleError(_0x166ff8,null));};exports[_0x9861('0x66')]=function(_0x595755,_0x5bb2d6){return db[_0x9861('0x32')]['find']({'where':{'id':_0x595755[_0x9861('0x4d')]['id']}})[_0x9861('0x26')](handleEntityNotFound(_0x5bb2d6,null))[_0x9861('0x26')](function(_0x4ed510){if(_0x4ed510){var _0x1ce98a=[_0x9861('0x67'),_0x9861('0x68'),'Mail',_0x9861('0x69'),'Fax','Openchannel',_0x9861('0x6a')];return db[_0x9861('0x6b')]['transaction'](function(_0x589aa1){var _0x15e480=_[_0x9861('0x31')](_0x1ce98a,function(_0x52d979){var _0x385e21={'attributes':['id',_0x9861('0x2e')]};if(_0x52d979==='Voice'){_0x385e21['through']={'attributes':[_0x9861('0x6c')]};}return _0x4ed510[_0x9861('0x28')+_0x52d979+_0x9861('0x62')](_0x385e21)[_0x9861('0x26')](function(_0x3516fa){var _0x3a5351=_[_0x9861('0x31')](_0x3516fa,function(_0x5dabeb){var _0x51d82a=_[_0x9861('0x31')](_0x595755['body'][_0x9861('0x63')],function(_0x325724){var _0x21419e={'where':{'UserId':_0x325724,[_0x52d979+_0x9861('0x6d')]:_0x5dabeb['id']},'transaction':_0x589aa1};if(_0x52d979===_0x9861('0x67')){_0x21419e[_0x9861('0x19')]={'penalty':_0x5dabeb[_0x9861('0x6e')][_0x9861('0x6c')]};}return db[_0x9861('0x6f')+_0x52d979+_0x9861('0x5f')][_0x9861('0x70')](_0x21419e)[_0x9861('0x26')](function(){socket[_0x9861('0x71')]('user'+_0x52d979+_0x9861('0x72'),{'UserId':_0x325724,[_0x52d979+'QueueId']:_0x5dabeb['id']});if(_0x52d979!==_0x9861('0x67'))return;return db[_0x9861('0x6f')][_0x9861('0x49')]({'where':{'id':_0x595755['body'][_0x9861('0x63')],'online':0x1},'attributes':['id',_0x9861('0x2e'),_0x9861('0x73'),_0x9861('0x74'),_0x9861('0x75')],'raw':!![]})['then'](function(_0x4fc174){var _0x264e04=_[_0x9861('0x31')](_0x4fc174,function(_0x1e0ec9){return db[_0x9861('0x76')][_0x9861('0x77')]({'membername':_0x1e0ec9[_0x9861('0x2e')],'UserId':_0x1e0ec9['id'],'queue_name':_0x5dabeb[_0x9861('0x2e')],'VoiceQueueId':_0x5dabeb['id'],'interface':_['isNil'](_0x1e0ec9[_0x9861('0x75')])?util[_0x9861('0x78')](_0x9861('0x79'),_0x1e0ec9[_0x9861('0x2e')]):_0x1e0ec9[_0x9861('0x75')],'paused':_0x1e0ec9[_0x9861('0x74')]||![],'penalty':_0x5dabeb[_0x9861('0x6e')][_0x9861('0x6c')]},{'transaction':_0x589aa1});});return Promise[_0x9861('0x7a')](_0x264e04);});});});return Promise[_0x9861('0x7a')](_0x51d82a);});return Promise[_0x9861('0x7a')](_0x3a5351);});});return Promise['all'](_0x15e480)[_0x9861('0x26')](function(){return _0x4ed510[_0x9861('0x66')](_0x595755[_0x9861('0x50')][_0x9861('0x63')],{'transaction':_0x589aa1})['spread'](function(_0x4fefb7){return _0x4fefb7;});});});}})[_0x9861('0x26')](respondWithResult(_0x5bb2d6,null))['catch'](handleError(_0x5bb2d6,null));};exports[_0x9861('0x7b')]=function(_0x261d77,_0x589ccb){return db[_0x9861('0x32')]['find']({'where':{'id':_0x261d77[_0x9861('0x4d')]['id']}})[_0x9861('0x26')](handleEntityNotFound(_0x589ccb,null))['then'](function(_0x32b971){if(_0x32b971){var _0x17dfc0=[_0x9861('0x67'),_0x9861('0x68'),'Mail','Sms',_0x9861('0x7c'),_0x9861('0x7d'),_0x9861('0x6a')];return db['sequelize'][_0x9861('0x7e')](function(_0x597dca){var _0x155fc1=_[_0x9861('0x31')](_0x17dfc0,function(_0x10a5b2){var _0x417ec9={'attributes':['id','name']};return _0x32b971[_0x9861('0x28')+_0x10a5b2+_0x9861('0x62')](_0x417ec9)[_0x9861('0x26')](function(_0x5ca473){var _0x42c7f3=_[_0x9861('0x31')](_0x5ca473,function(_0x11cda3){return _0x11cda3[_0x9861('0x7b')](_0x261d77['query'][_0x9861('0x63')],{'transaction':_0x597dca})[_0x9861('0x26')](function(){var _0x1b3d80=JSON[_0x9861('0x7f')]('['+_0x261d77[_0x9861('0x36')]['ids']+']');var _0x310822=_[_0x9861('0x31')](_0x1b3d80,function(_0x226604){socket['emit'](_0x9861('0x51')+_0x10a5b2+_0x9861('0x80'),{'UserId':Number(_0x226604),[_0x10a5b2+_0x9861('0x6d')]:_0x11cda3['id']});if(_0x10a5b2!==_0x9861('0x67'))return;return db[_0x9861('0x76')]['destroy']({'where':{'VoiceQueueId':_0x11cda3['id'],'UserId':_0x226604},'transaction':_0x597dca});});return Promise['all'](_0x310822);});});return Promise[_0x9861('0x7a')](_0x42c7f3);});});return Promise['all'](_0x155fc1)[_0x9861('0x26')](function(){return _0x32b971['removeAgents'](_0x261d77[_0x9861('0x36')]['ids'],{'transaction':_0x597dca});});});}})[_0x9861('0x26')](respondWithStatusCode(_0x589ccb,null))['catch'](handleError(_0x589ccb,null));};exports[_0x9861('0x81')]=function(_0x20215f,_0x48daa8,_0x211ce7){var _0x128db5={};var _0x5984c7={};var _0x45edf0;var _0x26b313;return db[_0x9861('0x32')][_0x9861('0x58')]({'where':{'id':_0x20215f[_0x9861('0x4d')]['id']}})['then'](handleEntityNotFound(_0x48daa8,null))['then'](function(_0x30bc1c){if(_0x30bc1c){_0x45edf0=_0x30bc1c;_0x5984c7['model']=_[_0x9861('0x37')](db['User'][_0x9861('0x33')]);_0x5984c7[_0x9861('0x36')]=_['keys'](_0x20215f[_0x9861('0x36')]);_0x5984c7[_0x9861('0x38')]=_[_0x9861('0x39')](_0x5984c7[_0x9861('0x35')],_0x5984c7[_0x9861('0x36')]);_0x128db5[_0x9861('0x3a')]=_['intersection'](_0x5984c7[_0x9861('0x35')],qs['fields'](_0x20215f[_0x9861('0x36')][_0x9861('0x3b')]));_0x128db5[_0x9861('0x3a')]=_0x128db5[_0x9861('0x3a')]['length']?_0x128db5['attributes']:_0x5984c7[_0x9861('0x35')];_0x128db5[_0x9861('0x3f')]=qs['sort'](_0x20215f['query'][_0x9861('0x40')]);_0x128db5[_0x9861('0x41')]=qs[_0x9861('0x38')](_[_0x9861('0x42')](_0x20215f[_0x9861('0x36')],_0x5984c7['filters']));if(_0x20215f[_0x9861('0x36')]['filter']){_0x128db5[_0x9861('0x41')]=_[_0x9861('0x44')](_0x128db5['where'],{'$or':_[_0x9861('0x31')](_0x128db5[_0x9861('0x3a')],function(_0x9eb079){var _0x54903e={};_0x54903e[_0x9eb079]={'$like':'%'+_0x20215f[_0x9861('0x36')][_0x9861('0x43')]+'%'};return _0x54903e;})});}_0x128db5=_[_0x9861('0x44')]({},_0x128db5,_0x20215f[_0x9861('0x46')]);return _0x45edf0[_0x9861('0x81')](_0x128db5);}})['then'](function(_0x327aff){if(_0x327aff){_0x26b313=_0x327aff[_0x9861('0x3c')];if(!_0x20215f['query']['hasOwnProperty']('nolimit')){_0x128db5['limit']=qs['limit'](_0x20215f[_0x9861('0x36')]['limit']);_0x128db5[_0x9861('0x20')]=qs['offset'](_0x20215f[_0x9861('0x36')][_0x9861('0x20')]);}return _0x45edf0['getAgents'](_0x128db5);}})[_0x9861('0x26')](function(_0x293512){if(_0x293512){return _0x293512?{'count':_0x26b313,'rows':_0x293512}:null;}})[_0x9861('0x26')](respondWithResult(_0x48daa8,null))['catch'](handleError(_0x48daa8,null));};
\ No newline at end of file