Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / team / team.controller.js
index 184aafc..41419d6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0d16=['sort','where','filters','pick','filter','merge','VIRTUAL','options','include','findAll','catch','params','rawAttributes','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getQueues','findOne','isValidChannel','channel','ValidationError','capitalize','toLowerCase','Queue','Queues','Unknown\x20channel','add','Sequelize','ids','addAgents','Voice','Chat','Mail','Fax','Openchannel','Whatsapp','each','User','online','voicePause','interface','upsert','isNil','SIP/%s','omit','spread','emit','userTeam:save','removeAgents','voice','chat','mail','openchannel','userTeam:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','to-csv','ejs','lodash','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','redis','defaults','localhost','./team.socket','register','status','end','json','count','offset','set','Content-Range','apply','save','update','destroy','then','get','Teams','UserProfileResource','sendStatus','stack','name','send','index','map','Team','fieldName','type','key','query','keys','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','limit','order'];(function(_0x433a86,_0x175b5c){var _0x23000c=function(_0x4b1fa0){while(--_0x4b1fa0){_0x433a86['push'](_0x433a86['shift']());}};_0x23000c(++_0x175b5c);}(_0x0d16,0xbb));var _0x60d1=function(_0x5f1334,_0x5012bd){_0x5f1334=_0x5f1334-0x0;var _0x455f8e=_0x0d16[_0x5f1334];return _0x455f8e;};'use strict';var pdf=require(_0x60d1('0x0'));var emlformat=require(_0x60d1('0x1'));var rimraf=require(_0x60d1('0x2'));var zipdir=require(_0x60d1('0x3'));var jsonpatch=require(_0x60d1('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x60d1('0x5'));var Mustache=require('mustache');var util=require(_0x60d1('0x6'));var path=require(_0x60d1('0x7'));var sox=require(_0x60d1('0x8'));var csv=require(_0x60d1('0x9'));var ejs=require(_0x60d1('0xa'));var fs=require('fs');var _=require(_0x60d1('0xb'));var squel=require('squel');var crypto=require(_0x60d1('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x60d1('0xd'));var toCsv=require(_0x60d1('0x9'));var querystring=require(_0x60d1('0xe'));var Papa=require('papaparse');var Redis=require(_0x60d1('0xf'));var authService=require(_0x60d1('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x60d1('0x11'));var hardwareService=require(_0x60d1('0x12'));var logger=require(_0x60d1('0x13'))('api');var utils=require('../../config/utils');var config=require(_0x60d1('0x14'));var licenseUtil=require(_0x60d1('0x15'));var db=require('../../mysqldb')['db'];config[_0x60d1('0x16')]=_[_0x60d1('0x17')](config['redis'],{'host':_0x60d1('0x18'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x60d1('0x19'))[_0x60d1('0x1a')](socket);function respondWithStatusCode(_0x159acd,_0x10ad3d){_0x10ad3d=_0x10ad3d||0xcc;return function(_0x7aea12){if(_0x7aea12){return _0x159acd['sendStatus'](_0x10ad3d);}return _0x159acd[_0x60d1('0x1b')](_0x10ad3d)[_0x60d1('0x1c')]();};}function respondWithResult(_0x26a359,_0x22f89a){_0x22f89a=_0x22f89a||0xc8;return function(_0x166416){if(_0x166416){return _0x26a359[_0x60d1('0x1b')](_0x22f89a)[_0x60d1('0x1d')](_0x166416);}};}function respondWithFilteredResult(_0x5d3686,_0x121b03){return function(_0x37887c){if(_0x37887c){var _0x4b9b39=_0x37887c[_0x60d1('0x1e')],_0x5004ae=_0x121b03[_0x60d1('0x1f')],_0x42eb98=_0x121b03[_0x60d1('0x1f')]+_0x121b03['limit'],_0x38a1e6;if(_0x42eb98>=_0x4b9b39){_0x42eb98=_0x4b9b39;_0x38a1e6=0xc8;}else{_0x38a1e6=0xce;}_0x5d3686[_0x60d1('0x1b')](_0x38a1e6);return _0x5d3686[_0x60d1('0x20')](_0x60d1('0x21'),_0x5004ae+'-'+_0x42eb98+'/'+_0x4b9b39)[_0x60d1('0x1d')](_0x37887c);}return null;};}function patchUpdates(_0x443fe0){return function(_0x2e4fb7){try{jsonpatch[_0x60d1('0x22')](_0x2e4fb7,_0x443fe0,!![]);}catch(_0x2081b1){return BPromise['reject'](_0x2081b1);}return _0x2e4fb7[_0x60d1('0x23')]();};}function saveUpdates(_0xe88c45,_0x273946){return function(_0x5eaf1e){if(_0x5eaf1e){return _0x5eaf1e[_0x60d1('0x24')](_0xe88c45)['then'](function(_0x51bbb0){return _0x51bbb0;});}return null;};}function removeEntity(_0x44ecc5,_0x12fcc8){return function(_0xf9337a){if(_0xf9337a){return _0xf9337a[_0x60d1('0x25')]()[_0x60d1('0x26')](function(){var _0x281685=_0xf9337a[_0x60d1('0x27')]({'plain':!![]});var _0xb6817f=_0x60d1('0x28');return db[_0x60d1('0x29')][_0x60d1('0x25')]({'where':{'type':_0xb6817f,'resourceId':_0x281685['id']}})[_0x60d1('0x26')](function(){return _0xf9337a;});})['then'](function(){_0x44ecc5[_0x60d1('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0xfddafa,_0x30f7d3){return function(_0x22ea59){if(!_0x22ea59){_0xfddafa[_0x60d1('0x2a')](0x194);}return _0x22ea59;};}function handleError(_0x3c4d3b,_0x59d77b){_0x59d77b=_0x59d77b||0x1f4;return function(_0x5b0119){logger['error'](_0x5b0119[_0x60d1('0x2b')]);if(_0x5b0119[_0x60d1('0x2c')]){delete _0x5b0119[_0x60d1('0x2c')];}_0x3c4d3b[_0x60d1('0x1b')](_0x59d77b)[_0x60d1('0x2d')](_0x5b0119);};}exports[_0x60d1('0x2e')]=function(_0x4b54b4,_0xaf643c){var _0x44011c={},_0x19fbaf={},_0x216371={'count':0x0,'rows':[]};var _0x4094cc=_[_0x60d1('0x2f')](db[_0x60d1('0x30')]['rawAttributes'],function(_0x18ddb8){return{'name':_0x18ddb8[_0x60d1('0x31')],'type':_0x18ddb8[_0x60d1('0x32')][_0x60d1('0x33')]};});_0x19fbaf['model']=_['map'](_0x4094cc,_0x60d1('0x2c'));_0x19fbaf[_0x60d1('0x34')]=_[_0x60d1('0x35')](_0x4b54b4['query']);_0x19fbaf['filters']=_[_0x60d1('0x36')](_0x19fbaf[_0x60d1('0x37')],_0x19fbaf[_0x60d1('0x34')]);_0x44011c['attributes']=_[_0x60d1('0x36')](_0x19fbaf[_0x60d1('0x37')],qs[_0x60d1('0x38')](_0x4b54b4['query'][_0x60d1('0x38')]));_0x44011c[_0x60d1('0x39')]=_0x44011c[_0x60d1('0x39')][_0x60d1('0x3a')]?_0x44011c['attributes']:_0x19fbaf[_0x60d1('0x37')];if(!_0x4b54b4[_0x60d1('0x34')][_0x60d1('0x3b')](_0x60d1('0x3c'))){_0x44011c[_0x60d1('0x3d')]=qs[_0x60d1('0x3d')](_0x4b54b4[_0x60d1('0x34')][_0x60d1('0x3d')]);_0x44011c[_0x60d1('0x1f')]=qs[_0x60d1('0x1f')](_0x4b54b4['query']['offset']);}_0x44011c[_0x60d1('0x3e')]=qs[_0x60d1('0x3f')](_0x4b54b4[_0x60d1('0x34')]['sort']);_0x44011c[_0x60d1('0x40')]=qs[_0x60d1('0x41')](_[_0x60d1('0x42')](_0x4b54b4[_0x60d1('0x34')],_0x19fbaf[_0x60d1('0x41')]),_0x4094cc);if(_0x4b54b4['query'][_0x60d1('0x43')]){_0x44011c['where']=_[_0x60d1('0x44')](_0x44011c[_0x60d1('0x40')],{'$or':_[_0x60d1('0x2f')](_0x4094cc,function(_0x1a1e06){if(_0x1a1e06[_0x60d1('0x32')]!==_0x60d1('0x45')){var _0x268407={};_0x268407[_0x1a1e06[_0x60d1('0x2c')]]={'$like':'%'+_0x4b54b4[_0x60d1('0x34')][_0x60d1('0x43')]+'%'};return _0x268407;}})});}_0x44011c=_[_0x60d1('0x44')]({},_0x44011c,_0x4b54b4[_0x60d1('0x46')]);var _0x16916f={'where':_0x44011c['where']};return db[_0x60d1('0x30')][_0x60d1('0x1e')](_0x16916f)['then'](function(_0x9da175){_0x216371[_0x60d1('0x1e')]=_0x9da175;if(_0x4b54b4[_0x60d1('0x34')]['includeAll']){_0x44011c[_0x60d1('0x47')]=[{'all':!![]}];}return db[_0x60d1('0x30')][_0x60d1('0x48')](_0x44011c);})[_0x60d1('0x26')](function(_0x2dee10){_0x216371['rows']=_0x2dee10;return _0x216371;})['then'](respondWithFilteredResult(_0xaf643c,_0x44011c))[_0x60d1('0x49')](handleError(_0xaf643c,null));};exports['show']=function(_0x42af8e,_0x4d32c3){var _0x16c55c={'raw':![],'where':{'id':_0x42af8e[_0x60d1('0x4a')]['id']}},_0x386d41={};_0x386d41[_0x60d1('0x37')]=_[_0x60d1('0x35')](db[_0x60d1('0x30')][_0x60d1('0x4b')]);_0x386d41[_0x60d1('0x34')]=_[_0x60d1('0x35')](_0x42af8e[_0x60d1('0x34')]);_0x386d41[_0x60d1('0x41')]=_['intersection'](_0x386d41['model'],_0x386d41[_0x60d1('0x34')]);_0x16c55c[_0x60d1('0x39')]=_[_0x60d1('0x36')](_0x386d41[_0x60d1('0x37')],qs['fields'](_0x42af8e[_0x60d1('0x34')]['fields']));_0x16c55c[_0x60d1('0x39')]=_0x16c55c[_0x60d1('0x39')][_0x60d1('0x3a')]?_0x16c55c[_0x60d1('0x39')]:_0x386d41[_0x60d1('0x37')];if(_0x42af8e['query']['includeAll']){_0x16c55c[_0x60d1('0x47')]=[{'all':!![]}];}_0x16c55c=_[_0x60d1('0x44')]({},_0x16c55c,_0x42af8e[_0x60d1('0x46')]);return db[_0x60d1('0x30')][_0x60d1('0x4c')](_0x16c55c)['then'](handleEntityNotFound(_0x4d32c3,null))[_0x60d1('0x26')](respondWithResult(_0x4d32c3,null))['catch'](handleError(_0x4d32c3,null));};exports[_0x60d1('0x4d')]=function(_0x596528,_0x253718){return db[_0x60d1('0x30')][_0x60d1('0x4d')](_0x596528[_0x60d1('0x4e')],{})[_0x60d1('0x26')](function(_0x28f107){var _0x4ec997=_0x596528[_0x60d1('0x4f')]['get']({'plain':!![]});if(!_0x4ec997)throw new Error(_0x60d1('0x50'));if(_0x4ec997['role']==='user'){var _0x3221c6=_0x28f107[_0x60d1('0x27')]({'plain':!![]});var _0x527621=_0x60d1('0x28');return db[_0x60d1('0x51')]['find']({'where':{'name':_0x527621,'userProfileId':_0x4ec997[_0x60d1('0x52')]},'raw':!![]})[_0x60d1('0x26')](function(_0x246eaf){if(_0x246eaf&&_0x246eaf[_0x60d1('0x53')]===0x0){return db[_0x60d1('0x29')][_0x60d1('0x4d')]({'name':_0x3221c6[_0x60d1('0x2c')],'resourceId':_0x3221c6['id'],'type':_0x246eaf[_0x60d1('0x2c')],'sectionId':_0x246eaf['id']},{})['then'](function(){return _0x28f107;});}else{return _0x28f107;}})['catch'](function(_0x47f9f9){logger[_0x60d1('0x54')](_0x60d1('0x55'),_0x47f9f9);throw _0x47f9f9;});}return _0x28f107;})[_0x60d1('0x26')](respondWithResult(_0x253718,0xc9))[_0x60d1('0x49')](handleError(_0x253718,null));};exports[_0x60d1('0x24')]=function(_0x1ff049,_0x4b8484){if(_0x1ff049[_0x60d1('0x4e')]['id']){delete _0x1ff049['body']['id'];}return db['Team'][_0x60d1('0x4c')]({'where':{'id':_0x1ff049[_0x60d1('0x4a')]['id']}})['then'](handleEntityNotFound(_0x4b8484,null))[_0x60d1('0x26')](saveUpdates(_0x1ff049[_0x60d1('0x4e')],null))[_0x60d1('0x26')](respondWithResult(_0x4b8484,null))[_0x60d1('0x49')](handleError(_0x4b8484,null));};exports[_0x60d1('0x25')]=function(_0x180e67,_0x2bdeae){return db[_0x60d1('0x30')][_0x60d1('0x4c')]({'where':{'id':_0x180e67[_0x60d1('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2bdeae,null))['then'](removeEntity(_0x2bdeae,null))['catch'](handleError(_0x2bdeae,null));};exports[_0x60d1('0x56')]=function(_0x34643e,_0x44e2cf,_0x25b747){return db['Team'][_0x60d1('0x57')]({'where':{'id':_0x34643e['params']['id']}})[_0x60d1('0x26')](handleEntityNotFound(_0x44e2cf,null))[_0x60d1('0x26')](function(_0x4e4555){if(!_0x34643e[_0x60d1('0x34')]['channel']||!utils[_0x60d1('0x58')](_0x34643e[_0x60d1('0x34')][_0x60d1('0x59')])){throw new db['Sequelize'][(_0x60d1('0x5a'))]('Unknown\x20channel');}var _0x276aa3={};var _0x124834={};_0x124834[_0x60d1('0x37')]=_['keys'](db[_[_0x60d1('0x5b')](_0x34643e['query']['channel'][_0x60d1('0x5c')]())+_0x60d1('0x5d')]['rawAttributes']);_0x124834[_0x60d1('0x34')]=_[_0x60d1('0x35')](_0x34643e[_0x60d1('0x34')]);_0x124834[_0x60d1('0x41')]=_[_0x60d1('0x36')](_0x124834['model'],_0x124834['query']);_0x276aa3[_0x60d1('0x39')]=_[_0x60d1('0x36')](_0x124834[_0x60d1('0x37')],qs[_0x60d1('0x38')](_0x34643e[_0x60d1('0x34')][_0x60d1('0x38')]));_0x276aa3[_0x60d1('0x39')]=_0x276aa3[_0x60d1('0x39')][_0x60d1('0x3a')]?_0x276aa3[_0x60d1('0x39')]:_0x124834[_0x60d1('0x37')];_0x276aa3[_0x60d1('0x3d')]=qs['limit'](_0x34643e[_0x60d1('0x34')][_0x60d1('0x3d')]);_0x276aa3[_0x60d1('0x1f')]=qs[_0x60d1('0x1f')](_0x34643e['query'][_0x60d1('0x1f')]);_0x276aa3['order']=qs[_0x60d1('0x3f')](_0x34643e[_0x60d1('0x34')][_0x60d1('0x3f')]);_0x276aa3[_0x60d1('0x40')]=qs[_0x60d1('0x41')](_[_0x60d1('0x42')](_0x34643e['query'],_0x124834[_0x60d1('0x41')]));_0x276aa3=_[_0x60d1('0x44')]({},_0x276aa3,_0x34643e[_0x60d1('0x46')]);return _0x4e4555['get'+_[_0x60d1('0x5b')](_0x34643e[_0x60d1('0x34')][_0x60d1('0x59')][_0x60d1('0x5c')]())+_0x60d1('0x5e')](_0x276aa3);})[_0x60d1('0x26')](respondWithResult(_0x44e2cf,null))[_0x60d1('0x49')](handleError(_0x44e2cf,null));};exports['addQueues']=function(_0xda96b2,_0x15c2f0,_0x2b7a91){return db[_0x60d1('0x30')][_0x60d1('0x57')]({'where':{'id':_0xda96b2['params']['id']}})[_0x60d1('0x26')](function(_0x2e3c1b){if(_0x2e3c1b){if(!_0xda96b2[_0x60d1('0x4e')][_0x60d1('0x59')]||!utils[_0x60d1('0x58')](_0xda96b2[_0x60d1('0x4e')]['channel'])){throw new db['Sequelize'][(_0x60d1('0x5a'))](_0x60d1('0x5f'));}return _0x2e3c1b[_0x60d1('0x60')+_[_0x60d1('0x5b')](_0xda96b2[_0x60d1('0x4e')][_0x60d1('0x59')][_0x60d1('0x5c')]())+_0x60d1('0x5e')](_0xda96b2[_0x60d1('0x4e')]['ids']);}return null;})[_0x60d1('0x26')](handleEntityNotFound(_0x15c2f0,null))[_0x60d1('0x26')](respondWithStatusCode(_0x15c2f0,null))[_0x60d1('0x49')](handleError(_0x15c2f0,null));};exports['removeQueues']=function(_0x1d1eff,_0x503e95,_0x5c33a4){return db[_0x60d1('0x30')][_0x60d1('0x57')]({'where':{'id':_0x1d1eff[_0x60d1('0x4a')]['id']}})[_0x60d1('0x26')](function(_0x5008c2){if(_0x5008c2){if(!_0x1d1eff[_0x60d1('0x34')][_0x60d1('0x59')]||!utils[_0x60d1('0x58')](_0x1d1eff[_0x60d1('0x34')][_0x60d1('0x59')])){throw new db[(_0x60d1('0x61'))]['ValidationError'](_0x60d1('0x5f'));}return _0x5008c2['remove'+_[_0x60d1('0x5b')](_0x1d1eff['query'][_0x60d1('0x59')][_0x60d1('0x5c')]())+_0x60d1('0x5e')](_0x1d1eff[_0x60d1('0x34')][_0x60d1('0x62')]);}return null;})[_0x60d1('0x26')](handleEntityNotFound(_0x503e95,null))[_0x60d1('0x26')](respondWithStatusCode(_0x503e95,null))[_0x60d1('0x49')](handleError(_0x503e95,null));};exports[_0x60d1('0x63')]=function(_0x1dbc5a,_0x803bca,_0x546022){return db[_0x60d1('0x30')][_0x60d1('0x4c')]({'where':{'id':_0x1dbc5a[_0x60d1('0x4a')]['id']}})[_0x60d1('0x26')](handleEntityNotFound(_0x803bca,null))['then'](function(_0x952df1){if(_0x952df1){var _0x3361bf=[_0x60d1('0x64'),_0x60d1('0x65'),_0x60d1('0x66'),'Sms',_0x60d1('0x67'),_0x60d1('0x68'),_0x60d1('0x69')];return BPromise['each'](_0x3361bf,function(_0x2f97f7){return _0x952df1[_0x60d1('0x27')+_0x2f97f7+_0x60d1('0x5e')]({'attributes':['id','name']})['then'](function(_0x4a0a78){return BPromise[_0x60d1('0x6a')](_0x4a0a78,function(_0x87e8d0){return _0x87e8d0[_0x60d1('0x63')](_0x1dbc5a[_0x60d1('0x4e')]['ids'])[_0x60d1('0x26')](function(){if(_0x2f97f7===_0x60d1('0x64')){return db[_0x60d1('0x6b')][_0x60d1('0x48')]({'where':{'id':_0x1dbc5a[_0x60d1('0x4e')]['ids']},'attributes':['id',_0x60d1('0x2c'),_0x60d1('0x6c'),_0x60d1('0x6d'),_0x60d1('0x6e')],'raw':!![]})[_0x60d1('0x26')](function(_0x511966){return BPromise[_0x60d1('0x6a')](_[_0x60d1('0x43')](_0x511966,{'online':0x1}),function(_0x3bcdd6){return db['UserVoiceQueueRt'][_0x60d1('0x6f')]({'membername':_0x3bcdd6[_0x60d1('0x2c')],'UserId':_0x3bcdd6['id'],'queue_name':_0x87e8d0['name'],'VoiceQueueId':_0x87e8d0['id'],'interface':_[_0x60d1('0x70')](_0x3bcdd6[_0x60d1('0x6e')])?util['format'](_0x60d1('0x71'),_0x3bcdd6['name']):_0x3bcdd6[_0x60d1('0x6e')],'paused':_0x3bcdd6['voicePause']||![],'penalty':0x0});});});}});});})['then'](function(){return _0x952df1;});})[_0x60d1('0x26')](function(){return _0x952df1;});}})[_0x60d1('0x26')](function(_0x12afbd){if(_0x12afbd){return _0x12afbd[_0x60d1('0x63')](_0x1dbc5a[_0x60d1('0x4e')][_0x60d1('0x62')],_[_0x60d1('0x72')](_0x1dbc5a['body'],[_0x60d1('0x62'),'id'])||{})[_0x60d1('0x73')](function(_0x1a9f01){for(var _0x1fe863=0x0;_0x1fe863<_0x1dbc5a[_0x60d1('0x4e')]['ids'][_0x60d1('0x3a')];_0x1fe863+=0x1){socket[_0x60d1('0x74')](_0x60d1('0x75'),{'UserId':_0x1dbc5a[_0x60d1('0x4e')][_0x60d1('0x62')][_0x1fe863],'TeamId':_0x1dbc5a[_0x60d1('0x4a')]['id']});}return _0x1a9f01;});}})[_0x60d1('0x26')](respondWithResult(_0x803bca,null))[_0x60d1('0x49')](handleError(_0x803bca,null));};exports[_0x60d1('0x76')]=function(_0xc65169,_0x15e2d4,_0x5ebc23){return db[_0x60d1('0x30')][_0x60d1('0x4c')]({'where':{'id':_0xc65169[_0x60d1('0x4a')]['id']}})[_0x60d1('0x26')](handleEntityNotFound(_0x15e2d4,null))[_0x60d1('0x26')](function(_0x1176df){if(_0x1176df){return BPromise[_0x60d1('0x6a')]([_0x60d1('0x77'),_0x60d1('0x78'),_0x60d1('0x79'),'sms','fax',_0x60d1('0x7a'),'whatsapp'],function(_0x16fcc2){return _0x1176df[_0x60d1('0x27')+_['capitalize'](_0x16fcc2)+_0x60d1('0x5e')]({'attributes':['id',_0x60d1('0x2c')]})[_0x60d1('0x26')](function(_0x51afbc){return BPromise['each'](_0x51afbc,function(_0x20eba0){return _0x20eba0[_0x60d1('0x76')](_0xc65169[_0x60d1('0x34')][_0x60d1('0x62')])[_0x60d1('0x26')](function(){if(_0x16fcc2===_0x60d1('0x77')){return db['UserVoiceQueueRt'][_0x60d1('0x25')]({'where':{'VoiceQueueId':_0x20eba0['id'],'UserId':_0xc65169['query'][_0x60d1('0x62')]}});}});});})[_0x60d1('0x26')](function(){return _0x1176df;});})[_0x60d1('0x26')](function(){return _0x1176df;});}})[_0x60d1('0x26')](function(_0x9fb731){if(_0x9fb731){return _0x9fb731[_0x60d1('0x76')](_0xc65169[_0x60d1('0x34')][_0x60d1('0x62')])['then'](function(){if(_['isArray'](_0xc65169['query'][_0x60d1('0x62')])){for(var _0x16f807=0x0;_0x16f807<_0xc65169[_0x60d1('0x34')][_0x60d1('0x62')]['length'];_0x16f807+=0x1){socket[_0x60d1('0x74')]('userTeam:remove',{'UserId':Number(_0xc65169[_0x60d1('0x34')][_0x60d1('0x62')][_0x16f807]),'TeamId':Number(_0xc65169[_0x60d1('0x4a')]['id'])});}}else{socket['emit'](_0x60d1('0x7b'),{'UserId':Number(_0xc65169[_0x60d1('0x34')][_0x60d1('0x62')]),'TeamId':Number(_0xc65169['params']['id'])});}});}})['then'](respondWithStatusCode(_0x15e2d4,null))[_0x60d1('0x49')](handleError(_0x15e2d4,null));};exports[_0x60d1('0x7c')]=function(_0x2fce35,_0x1a80b6,_0x12e337){var _0x2230cd={};var _0x2e808a={};var _0x514b16;var _0x41418c;return db[_0x60d1('0x30')][_0x60d1('0x57')]({'where':{'id':_0x2fce35[_0x60d1('0x4a')]['id']}})[_0x60d1('0x26')](handleEntityNotFound(_0x1a80b6,null))[_0x60d1('0x26')](function(_0x3caf4a){if(_0x3caf4a){_0x514b16=_0x3caf4a;_0x2e808a[_0x60d1('0x37')]=_['keys'](db['User'][_0x60d1('0x4b')]);_0x2e808a[_0x60d1('0x34')]=_[_0x60d1('0x35')](_0x2fce35[_0x60d1('0x34')]);_0x2e808a['filters']=_[_0x60d1('0x36')](_0x2e808a['model'],_0x2e808a['query']);_0x2230cd[_0x60d1('0x39')]=_[_0x60d1('0x36')](_0x2e808a[_0x60d1('0x37')],qs['fields'](_0x2fce35[_0x60d1('0x34')][_0x60d1('0x38')]));_0x2230cd['attributes']=_0x2230cd[_0x60d1('0x39')][_0x60d1('0x3a')]?_0x2230cd[_0x60d1('0x39')]:_0x2e808a[_0x60d1('0x37')];_0x2230cd[_0x60d1('0x3e')]=qs['sort'](_0x2fce35[_0x60d1('0x34')][_0x60d1('0x3f')]);_0x2230cd[_0x60d1('0x40')]=qs[_0x60d1('0x41')](_['pick'](_0x2fce35[_0x60d1('0x34')],_0x2e808a[_0x60d1('0x41')]));if(_0x2fce35[_0x60d1('0x34')][_0x60d1('0x43')]){_0x2230cd[_0x60d1('0x40')]=_[_0x60d1('0x44')](_0x2230cd[_0x60d1('0x40')],{'$or':_[_0x60d1('0x2f')](_0x2230cd[_0x60d1('0x39')],function(_0x5b7189){var _0x50f7e9={};_0x50f7e9[_0x5b7189]={'$like':'%'+_0x2fce35[_0x60d1('0x34')][_0x60d1('0x43')]+'%'};return _0x50f7e9;})});}_0x2230cd=_[_0x60d1('0x44')]({},_0x2230cd,_0x2fce35[_0x60d1('0x46')]);return _0x514b16[_0x60d1('0x7c')](_0x2230cd);}})[_0x60d1('0x26')](function(_0x5ef215){if(_0x5ef215){_0x41418c=_0x5ef215[_0x60d1('0x3a')];if(!_0x2fce35[_0x60d1('0x34')]['hasOwnProperty'](_0x60d1('0x3c'))){_0x2230cd[_0x60d1('0x3d')]=qs[_0x60d1('0x3d')](_0x2fce35[_0x60d1('0x34')][_0x60d1('0x3d')]);_0x2230cd['offset']=qs[_0x60d1('0x1f')](_0x2fce35[_0x60d1('0x34')][_0x60d1('0x1f')]);}return _0x514b16['getAgents'](_0x2230cd);}})['then'](function(_0x309ab8){if(_0x309ab8){return _0x309ab8?{'count':_0x41418c,'rows':_0x309ab8}:null;}})[_0x60d1('0x26')](respondWithResult(_0x1a80b6,null))['catch'](handleError(_0x1a80b6,null));};
\ No newline at end of file
+var _0xf928=['set','Content-Range','reject','save','update','then','get','Teams','UserProfileResource','destroy','stack','name','send','index','map','Team','rawAttributes','fieldName','type','key','model','query','filters','fields','attributes','length','nolimit','limit','order','sort','where','pick','filter','VIRTUAL','options','includeAll','findAll','rows','show','params','keys','intersection','include','merge','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','autoAssociation','catch','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','channel','isValidChannel','Sequelize','ValidationError','Unknown\x20channel','capitalize','toLowerCase','Queue','Queues','addQueues','findOne','add','ids','removeQueues','addAgents','Voice','Chat','Sms','Openchannel','User','interface','upsert','format','SIP/%s','voicePause','spread','emit','userTeam:save','removeAgents','voice','chat','mail','whatsapp','each','UserVoiceQueueRt','isArray','userTeam:remove','getAgents','hasOwnProperty','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','socket.io-emitter','./team.socket','register','sendStatus','end','status','json','count','offset'];(function(_0x117f4c,_0x36a9b1){var _0x2b24e9=function(_0x31761b){while(--_0x31761b){_0x117f4c['push'](_0x117f4c['shift']());}};_0x2b24e9(++_0x36a9b1);}(_0xf928,0xe0));var _0x8f92=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xf928[_0x14add3];return _0x4a174f;};'use strict';var pdf=require(_0x8f92('0x0'));var emlformat=require(_0x8f92('0x1'));var rimraf=require(_0x8f92('0x2'));var zipdir=require(_0x8f92('0x3'));var jsonpatch=require(_0x8f92('0x4'));var rp=require(_0x8f92('0x5'));var moment=require(_0x8f92('0x6'));var BPromise=require(_0x8f92('0x7'));var Mustache=require(_0x8f92('0x8'));var util=require(_0x8f92('0x9'));var path=require(_0x8f92('0xa'));var sox=require(_0x8f92('0xb'));var csv=require(_0x8f92('0xc'));var ejs=require(_0x8f92('0xd'));var fs=require('fs');var _=require('lodash');var squel=require(_0x8f92('0xe'));var crypto=require(_0x8f92('0xf'));var jsforce=require(_0x8f92('0x10'));var deskjs=require(_0x8f92('0x11'));var toCsv=require(_0x8f92('0xc'));var querystring=require(_0x8f92('0x12'));var Papa=require(_0x8f92('0x13'));var Redis=require(_0x8f92('0x14'));var authService=require(_0x8f92('0x15'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x8f92('0x16'));var logger=require(_0x8f92('0x17'))(_0x8f92('0x18'));var utils=require(_0x8f92('0x19'));var config=require('../../config/environment');var licenseUtil=require(_0x8f92('0x1a'));var db=require(_0x8f92('0x1b'))['db'];config[_0x8f92('0x1c')]=_['defaults'](config[_0x8f92('0x1c')],{'host':'localhost','port':0x18eb});var socket=require(_0x8f92('0x1d'))(new Redis(config['redis']));require(_0x8f92('0x1e'))[_0x8f92('0x1f')](socket);function respondWithStatusCode(_0xdfa620,_0x2f53cd){_0x2f53cd=_0x2f53cd||0xcc;return function(_0x18a8ae){if(_0x18a8ae){return _0xdfa620[_0x8f92('0x20')](_0x2f53cd);}return _0xdfa620['status'](_0x2f53cd)[_0x8f92('0x21')]();};}function respondWithResult(_0x348bc3,_0x187271){_0x187271=_0x187271||0xc8;return function(_0x3b34d3){if(_0x3b34d3){return _0x348bc3[_0x8f92('0x22')](_0x187271)[_0x8f92('0x23')](_0x3b34d3);}};}function respondWithFilteredResult(_0xfece0b,_0x547d04){return function(_0x4c2608){if(_0x4c2608){var _0x1f8de5=_0x4c2608[_0x8f92('0x24')],_0x1db5e1=_0x547d04['offset'],_0x58b3fb=_0x547d04[_0x8f92('0x25')]+_0x547d04['limit'],_0x3d84bc;if(_0x58b3fb>=_0x1f8de5){_0x58b3fb=_0x1f8de5;_0x3d84bc=0xc8;}else{_0x3d84bc=0xce;}_0xfece0b[_0x8f92('0x22')](_0x3d84bc);return _0xfece0b[_0x8f92('0x26')](_0x8f92('0x27'),_0x1db5e1+'-'+_0x58b3fb+'/'+_0x1f8de5)['json'](_0x4c2608);}return null;};}function patchUpdates(_0x1119b4){return function(_0x572300){try{jsonpatch['apply'](_0x572300,_0x1119b4,!![]);}catch(_0x5f0bcd){return BPromise[_0x8f92('0x28')](_0x5f0bcd);}return _0x572300[_0x8f92('0x29')]();};}function saveUpdates(_0x26c275,_0x4e6c3b){return function(_0x369936){if(_0x369936){return _0x369936[_0x8f92('0x2a')](_0x26c275)['then'](function(_0x4c2ca5){return _0x4c2ca5;});}return null;};}function removeEntity(_0x32a821,_0x2201de){return function(_0x448159){if(_0x448159){return _0x448159['destroy']()[_0x8f92('0x2b')](function(){var _0x5a9d12=_0x448159[_0x8f92('0x2c')]({'plain':!![]});var _0x4f617f=_0x8f92('0x2d');return db[_0x8f92('0x2e')][_0x8f92('0x2f')]({'where':{'type':_0x4f617f,'resourceId':_0x5a9d12['id']}})[_0x8f92('0x2b')](function(){return _0x448159;});})['then'](function(){_0x32a821[_0x8f92('0x22')](0xcc)[_0x8f92('0x21')]();});}};}function handleEntityNotFound(_0x4a8462,_0x22c7b0){return function(_0x3e85f4){if(!_0x3e85f4){_0x4a8462[_0x8f92('0x20')](0x194);}return _0x3e85f4;};}function handleError(_0x2295d7,_0x5dcac5){_0x5dcac5=_0x5dcac5||0x1f4;return function(_0x338a3c){logger['error'](_0x338a3c[_0x8f92('0x30')]);if(_0x338a3c[_0x8f92('0x31')]){delete _0x338a3c[_0x8f92('0x31')];}_0x2295d7[_0x8f92('0x22')](_0x5dcac5)[_0x8f92('0x32')](_0x338a3c);};}exports[_0x8f92('0x33')]=function(_0x1abb1c,_0x5bfdcc){var _0x47625d={},_0x60f772={},_0x364441={'count':0x0,'rows':[]};var _0x5efcc4=_[_0x8f92('0x34')](db[_0x8f92('0x35')][_0x8f92('0x36')],function(_0x2019c8){return{'name':_0x2019c8[_0x8f92('0x37')],'type':_0x2019c8[_0x8f92('0x38')][_0x8f92('0x39')]};});_0x60f772[_0x8f92('0x3a')]=_[_0x8f92('0x34')](_0x5efcc4,_0x8f92('0x31'));_0x60f772[_0x8f92('0x3b')]=_['keys'](_0x1abb1c['query']);_0x60f772[_0x8f92('0x3c')]=_['intersection'](_0x60f772[_0x8f92('0x3a')],_0x60f772[_0x8f92('0x3b')]);_0x47625d['attributes']=_['intersection'](_0x60f772[_0x8f92('0x3a')],qs[_0x8f92('0x3d')](_0x1abb1c[_0x8f92('0x3b')][_0x8f92('0x3d')]));_0x47625d[_0x8f92('0x3e')]=_0x47625d[_0x8f92('0x3e')][_0x8f92('0x3f')]?_0x47625d[_0x8f92('0x3e')]:_0x60f772[_0x8f92('0x3a')];if(!_0x1abb1c[_0x8f92('0x3b')]['hasOwnProperty'](_0x8f92('0x40'))){_0x47625d[_0x8f92('0x41')]=qs[_0x8f92('0x41')](_0x1abb1c[_0x8f92('0x3b')][_0x8f92('0x41')]);_0x47625d[_0x8f92('0x25')]=qs[_0x8f92('0x25')](_0x1abb1c[_0x8f92('0x3b')]['offset']);}_0x47625d[_0x8f92('0x42')]=qs[_0x8f92('0x43')](_0x1abb1c[_0x8f92('0x3b')]['sort']);_0x47625d[_0x8f92('0x44')]=qs[_0x8f92('0x3c')](_[_0x8f92('0x45')](_0x1abb1c[_0x8f92('0x3b')],_0x60f772[_0x8f92('0x3c')]),_0x5efcc4);if(_0x1abb1c['query'][_0x8f92('0x46')]){_0x47625d[_0x8f92('0x44')]=_['merge'](_0x47625d['where'],{'$or':_['map'](_0x5efcc4,function(_0x3154d8){if(_0x3154d8[_0x8f92('0x38')]!==_0x8f92('0x47')){var _0x7f7834={};_0x7f7834[_0x3154d8[_0x8f92('0x31')]]={'$like':'%'+_0x1abb1c[_0x8f92('0x3b')][_0x8f92('0x46')]+'%'};return _0x7f7834;}})});}_0x47625d=_['merge']({},_0x47625d,_0x1abb1c[_0x8f92('0x48')]);var _0x346683={'where':_0x47625d[_0x8f92('0x44')]};return db[_0x8f92('0x35')][_0x8f92('0x24')](_0x346683)['then'](function(_0x30607d){_0x364441[_0x8f92('0x24')]=_0x30607d;if(_0x1abb1c[_0x8f92('0x3b')][_0x8f92('0x49')]){_0x47625d['include']=[{'all':!![]}];}return db[_0x8f92('0x35')][_0x8f92('0x4a')](_0x47625d);})['then'](function(_0x53c304){_0x364441[_0x8f92('0x4b')]=_0x53c304;return _0x364441;})[_0x8f92('0x2b')](respondWithFilteredResult(_0x5bfdcc,_0x47625d))['catch'](handleError(_0x5bfdcc,null));};exports[_0x8f92('0x4c')]=function(_0x1cc1dc,_0x496710){var _0x50845a={'raw':![],'where':{'id':_0x1cc1dc[_0x8f92('0x4d')]['id']}},_0x61e935={};_0x61e935[_0x8f92('0x3a')]=_[_0x8f92('0x4e')](db[_0x8f92('0x35')][_0x8f92('0x36')]);_0x61e935[_0x8f92('0x3b')]=_['keys'](_0x1cc1dc['query']);_0x61e935[_0x8f92('0x3c')]=_[_0x8f92('0x4f')](_0x61e935[_0x8f92('0x3a')],_0x61e935['query']);_0x50845a['attributes']=_[_0x8f92('0x4f')](_0x61e935['model'],qs[_0x8f92('0x3d')](_0x1cc1dc[_0x8f92('0x3b')][_0x8f92('0x3d')]));_0x50845a[_0x8f92('0x3e')]=_0x50845a[_0x8f92('0x3e')]['length']?_0x50845a[_0x8f92('0x3e')]:_0x61e935['model'];if(_0x1cc1dc[_0x8f92('0x3b')][_0x8f92('0x49')]){_0x50845a[_0x8f92('0x50')]=[{'all':!![]}];}_0x50845a=_[_0x8f92('0x51')]({},_0x50845a,_0x1cc1dc[_0x8f92('0x48')]);return db[_0x8f92('0x35')][_0x8f92('0x52')](_0x50845a)[_0x8f92('0x2b')](handleEntityNotFound(_0x496710,null))[_0x8f92('0x2b')](respondWithResult(_0x496710,null))['catch'](handleError(_0x496710,null));};exports[_0x8f92('0x53')]=function(_0x1306ee,_0x58bcb6){return db['Team']['create'](_0x1306ee[_0x8f92('0x54')],{})[_0x8f92('0x2b')](function(_0x1150fb){var _0x2369b1=_0x1306ee[_0x8f92('0x55')][_0x8f92('0x2c')]({'plain':!![]});if(!_0x2369b1)throw new Error(_0x8f92('0x56'));if(_0x2369b1['role']===_0x8f92('0x55')){var _0x4ce106=_0x1150fb[_0x8f92('0x2c')]({'plain':!![]});var _0x1c9509=_0x8f92('0x2d');return db[_0x8f92('0x57')][_0x8f92('0x52')]({'where':{'name':_0x1c9509,'userProfileId':_0x2369b1['userProfileId']},'raw':!![]})[_0x8f92('0x2b')](function(_0x92c6ff){if(_0x92c6ff&&_0x92c6ff[_0x8f92('0x58')]===0x0){return db[_0x8f92('0x2e')]['create']({'name':_0x4ce106[_0x8f92('0x31')],'resourceId':_0x4ce106['id'],'type':_0x92c6ff[_0x8f92('0x31')],'sectionId':_0x92c6ff['id']},{})[_0x8f92('0x2b')](function(){return _0x1150fb;});}else{return _0x1150fb;}})[_0x8f92('0x59')](function(_0x216e93){logger[_0x8f92('0x5a')](_0x8f92('0x5b'),_0x216e93);throw _0x216e93;});}return _0x1150fb;})[_0x8f92('0x2b')](respondWithResult(_0x58bcb6,0xc9))[_0x8f92('0x59')](handleError(_0x58bcb6,null));};exports[_0x8f92('0x2a')]=function(_0x23d32d,_0x5a006f){if(_0x23d32d['body']['id']){delete _0x23d32d[_0x8f92('0x54')]['id'];}return db[_0x8f92('0x35')][_0x8f92('0x52')]({'where':{'id':_0x23d32d[_0x8f92('0x4d')]['id']}})[_0x8f92('0x2b')](handleEntityNotFound(_0x5a006f,null))[_0x8f92('0x2b')](saveUpdates(_0x23d32d[_0x8f92('0x54')],null))[_0x8f92('0x2b')](respondWithResult(_0x5a006f,null))[_0x8f92('0x59')](handleError(_0x5a006f,null));};exports[_0x8f92('0x2f')]=function(_0x21415e,_0x325b8f){return db['Team'][_0x8f92('0x52')]({'where':{'id':_0x21415e[_0x8f92('0x4d')]['id']}})[_0x8f92('0x2b')](handleEntityNotFound(_0x325b8f,null))['then'](removeEntity(_0x325b8f,null))[_0x8f92('0x59')](handleError(_0x325b8f,null));};exports['getQueues']=function(_0x388ff4,_0x4cf741,_0x590de8){return db[_0x8f92('0x35')]['findOne']({'where':{'id':_0x388ff4[_0x8f92('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4cf741,null))['then'](function(_0x13dea8){if(!_0x388ff4[_0x8f92('0x3b')][_0x8f92('0x5c')]||!utils[_0x8f92('0x5d')](_0x388ff4[_0x8f92('0x3b')][_0x8f92('0x5c')])){throw new db[(_0x8f92('0x5e'))][(_0x8f92('0x5f'))](_0x8f92('0x60'));}var _0x4973e0={};var _0x4ddcfc={};_0x4ddcfc['model']=_[_0x8f92('0x4e')](db[_[_0x8f92('0x61')](_0x388ff4[_0x8f92('0x3b')][_0x8f92('0x5c')][_0x8f92('0x62')]())+_0x8f92('0x63')]['rawAttributes']);_0x4ddcfc[_0x8f92('0x3b')]=_[_0x8f92('0x4e')](_0x388ff4[_0x8f92('0x3b')]);_0x4ddcfc[_0x8f92('0x3c')]=_[_0x8f92('0x4f')](_0x4ddcfc[_0x8f92('0x3a')],_0x4ddcfc[_0x8f92('0x3b')]);_0x4973e0[_0x8f92('0x3e')]=_[_0x8f92('0x4f')](_0x4ddcfc[_0x8f92('0x3a')],qs['fields'](_0x388ff4[_0x8f92('0x3b')][_0x8f92('0x3d')]));_0x4973e0[_0x8f92('0x3e')]=_0x4973e0[_0x8f92('0x3e')]['length']?_0x4973e0['attributes']:_0x4ddcfc['model'];_0x4973e0[_0x8f92('0x41')]=qs[_0x8f92('0x41')](_0x388ff4['query'][_0x8f92('0x41')]);_0x4973e0[_0x8f92('0x25')]=qs['offset'](_0x388ff4[_0x8f92('0x3b')]['offset']);_0x4973e0['order']=qs[_0x8f92('0x43')](_0x388ff4[_0x8f92('0x3b')]['sort']);_0x4973e0[_0x8f92('0x44')]=qs[_0x8f92('0x3c')](_[_0x8f92('0x45')](_0x388ff4[_0x8f92('0x3b')],_0x4ddcfc[_0x8f92('0x3c')]));_0x4973e0=_[_0x8f92('0x51')]({},_0x4973e0,_0x388ff4[_0x8f92('0x48')]);return _0x13dea8[_0x8f92('0x2c')+_[_0x8f92('0x61')](_0x388ff4[_0x8f92('0x3b')]['channel']['toLowerCase']())+_0x8f92('0x64')](_0x4973e0);})['then'](respondWithResult(_0x4cf741,null))[_0x8f92('0x59')](handleError(_0x4cf741,null));};exports[_0x8f92('0x65')]=function(_0x106213,_0x2b4132,_0x19c7d4){return db[_0x8f92('0x35')][_0x8f92('0x66')]({'where':{'id':_0x106213[_0x8f92('0x4d')]['id']}})['then'](function(_0x39d761){if(_0x39d761){if(!_0x106213[_0x8f92('0x54')][_0x8f92('0x5c')]||!utils[_0x8f92('0x5d')](_0x106213[_0x8f92('0x54')]['channel'])){throw new db[(_0x8f92('0x5e'))][(_0x8f92('0x5f'))]('Unknown\x20channel');}return _0x39d761[_0x8f92('0x67')+_[_0x8f92('0x61')](_0x106213['body']['channel'][_0x8f92('0x62')]())+_0x8f92('0x64')](_0x106213[_0x8f92('0x54')][_0x8f92('0x68')]);}return null;})[_0x8f92('0x2b')](handleEntityNotFound(_0x2b4132,null))[_0x8f92('0x2b')](respondWithStatusCode(_0x2b4132,null))['catch'](handleError(_0x2b4132,null));};exports[_0x8f92('0x69')]=function(_0xde781e,_0x420467,_0x2301a1){return db['Team'][_0x8f92('0x66')]({'where':{'id':_0xde781e[_0x8f92('0x4d')]['id']}})['then'](function(_0x2f78f8){if(_0x2f78f8){if(!_0xde781e[_0x8f92('0x3b')]['channel']||!utils[_0x8f92('0x5d')](_0xde781e[_0x8f92('0x3b')][_0x8f92('0x5c')])){throw new db[(_0x8f92('0x5e'))][(_0x8f92('0x5f'))](_0x8f92('0x60'));}return _0x2f78f8['remove'+_['capitalize'](_0xde781e['query'][_0x8f92('0x5c')][_0x8f92('0x62')]())+_0x8f92('0x64')](_0xde781e[_0x8f92('0x3b')][_0x8f92('0x68')]);}return null;})['then'](handleEntityNotFound(_0x420467,null))[_0x8f92('0x2b')](respondWithStatusCode(_0x420467,null))[_0x8f92('0x59')](handleError(_0x420467,null));};exports[_0x8f92('0x6a')]=function(_0x5f2a82,_0x336902,_0x8ea1ed){return db[_0x8f92('0x35')]['find']({'where':{'id':_0x5f2a82[_0x8f92('0x4d')]['id']}})['then'](handleEntityNotFound(_0x336902,null))[_0x8f92('0x2b')](function(_0x22a589){if(_0x22a589){var _0x12fad5=[_0x8f92('0x6b'),_0x8f92('0x6c'),'Mail',_0x8f92('0x6d'),'Fax',_0x8f92('0x6e'),'Whatsapp'];return BPromise['each'](_0x12fad5,function(_0x5e0703){return _0x22a589[_0x8f92('0x2c')+_0x5e0703+_0x8f92('0x64')]({'attributes':['id',_0x8f92('0x31')]})[_0x8f92('0x2b')](function(_0x48e648){return BPromise['each'](_0x48e648,function(_0x49425c){return _0x49425c[_0x8f92('0x6a')](_0x5f2a82[_0x8f92('0x54')]['ids'])[_0x8f92('0x2b')](function(){if(_0x5e0703===_0x8f92('0x6b')){return db[_0x8f92('0x6f')][_0x8f92('0x4a')]({'where':{'id':_0x5f2a82['body'][_0x8f92('0x68')]},'attributes':['id',_0x8f92('0x31'),'online','voicePause',_0x8f92('0x70')],'raw':!![]})['then'](function(_0x2fbe52){return BPromise['each'](_[_0x8f92('0x46')](_0x2fbe52,{'online':0x1}),function(_0x4704c3){return db['UserVoiceQueueRt'][_0x8f92('0x71')]({'membername':_0x4704c3[_0x8f92('0x31')],'UserId':_0x4704c3['id'],'queue_name':_0x49425c[_0x8f92('0x31')],'VoiceQueueId':_0x49425c['id'],'interface':_['isNil'](_0x4704c3['interface'])?util[_0x8f92('0x72')](_0x8f92('0x73'),_0x4704c3[_0x8f92('0x31')]):_0x4704c3['interface'],'paused':_0x4704c3[_0x8f92('0x74')]||![],'penalty':0x0});});});}});});})[_0x8f92('0x2b')](function(){return _0x22a589;});})[_0x8f92('0x2b')](function(){return _0x22a589;});}})[_0x8f92('0x2b')](function(_0x58263b){if(_0x58263b){return _0x58263b[_0x8f92('0x6a')](_0x5f2a82[_0x8f92('0x54')]['ids'],_['omit'](_0x5f2a82[_0x8f92('0x54')],[_0x8f92('0x68'),'id'])||{})[_0x8f92('0x75')](function(_0x565dfc){for(var _0x2a2540=0x0;_0x2a2540<_0x5f2a82[_0x8f92('0x54')][_0x8f92('0x68')]['length'];_0x2a2540+=0x1){socket[_0x8f92('0x76')](_0x8f92('0x77'),{'UserId':_0x5f2a82[_0x8f92('0x54')]['ids'][_0x2a2540],'TeamId':_0x5f2a82[_0x8f92('0x4d')]['id']});}return _0x565dfc;});}})[_0x8f92('0x2b')](respondWithResult(_0x336902,null))[_0x8f92('0x59')](handleError(_0x336902,null));};exports[_0x8f92('0x78')]=function(_0x587b3b,_0xc963ec,_0xb6dd22){return db[_0x8f92('0x35')][_0x8f92('0x52')]({'where':{'id':_0x587b3b[_0x8f92('0x4d')]['id']}})[_0x8f92('0x2b')](handleEntityNotFound(_0xc963ec,null))['then'](function(_0x318491){if(_0x318491){return BPromise['each']([_0x8f92('0x79'),_0x8f92('0x7a'),_0x8f92('0x7b'),'sms','fax','openchannel',_0x8f92('0x7c')],function(_0x39841a){return _0x318491['get'+_['capitalize'](_0x39841a)+_0x8f92('0x64')]({'attributes':['id',_0x8f92('0x31')]})[_0x8f92('0x2b')](function(_0x2bb0c7){return BPromise[_0x8f92('0x7d')](_0x2bb0c7,function(_0x56dc87){return _0x56dc87[_0x8f92('0x78')](_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')])[_0x8f92('0x2b')](function(){if(_0x39841a==='voice'){return db[_0x8f92('0x7e')]['destroy']({'where':{'VoiceQueueId':_0x56dc87['id'],'UserId':_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')]}});}});});})[_0x8f92('0x2b')](function(){return _0x318491;});})[_0x8f92('0x2b')](function(){return _0x318491;});}})[_0x8f92('0x2b')](function(_0x478be4){if(_0x478be4){return _0x478be4[_0x8f92('0x78')](_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')])[_0x8f92('0x2b')](function(){if(_[_0x8f92('0x7f')](_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')])){for(var _0x84328=0x0;_0x84328<_0x587b3b[_0x8f92('0x3b')][_0x8f92('0x68')][_0x8f92('0x3f')];_0x84328+=0x1){socket[_0x8f92('0x76')](_0x8f92('0x80'),{'UserId':Number(_0x587b3b['query'][_0x8f92('0x68')][_0x84328]),'TeamId':Number(_0x587b3b[_0x8f92('0x4d')]['id'])});}}else{socket[_0x8f92('0x76')](_0x8f92('0x80'),{'UserId':Number(_0x587b3b['query'][_0x8f92('0x68')]),'TeamId':Number(_0x587b3b['params']['id'])});}});}})['then'](respondWithStatusCode(_0xc963ec,null))[_0x8f92('0x59')](handleError(_0xc963ec,null));};exports[_0x8f92('0x81')]=function(_0x38e8cd,_0x4d0600,_0x3cd5f1){var _0x5bf70d={};var _0x26fcbc={};var _0x53dab6;var _0x3095f6;return db[_0x8f92('0x35')]['findOne']({'where':{'id':_0x38e8cd[_0x8f92('0x4d')]['id']}})[_0x8f92('0x2b')](handleEntityNotFound(_0x4d0600,null))[_0x8f92('0x2b')](function(_0x43a939){if(_0x43a939){_0x53dab6=_0x43a939;_0x26fcbc[_0x8f92('0x3a')]=_['keys'](db[_0x8f92('0x6f')][_0x8f92('0x36')]);_0x26fcbc[_0x8f92('0x3b')]=_[_0x8f92('0x4e')](_0x38e8cd[_0x8f92('0x3b')]);_0x26fcbc['filters']=_['intersection'](_0x26fcbc[_0x8f92('0x3a')],_0x26fcbc[_0x8f92('0x3b')]);_0x5bf70d[_0x8f92('0x3e')]=_[_0x8f92('0x4f')](_0x26fcbc[_0x8f92('0x3a')],qs[_0x8f92('0x3d')](_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x3d')]));_0x5bf70d[_0x8f92('0x3e')]=_0x5bf70d[_0x8f92('0x3e')][_0x8f92('0x3f')]?_0x5bf70d[_0x8f92('0x3e')]:_0x26fcbc[_0x8f92('0x3a')];_0x5bf70d[_0x8f92('0x42')]=qs[_0x8f92('0x43')](_0x38e8cd['query']['sort']);_0x5bf70d['where']=qs['filters'](_['pick'](_0x38e8cd[_0x8f92('0x3b')],_0x26fcbc[_0x8f92('0x3c')]));if(_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x46')]){_0x5bf70d[_0x8f92('0x44')]=_[_0x8f92('0x51')](_0x5bf70d[_0x8f92('0x44')],{'$or':_[_0x8f92('0x34')](_0x5bf70d['attributes'],function(_0x1d9869){var _0x2f864f={};_0x2f864f[_0x1d9869]={'$like':'%'+_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x46')]+'%'};return _0x2f864f;})});}_0x5bf70d=_[_0x8f92('0x51')]({},_0x5bf70d,_0x38e8cd[_0x8f92('0x48')]);return _0x53dab6['getAgents'](_0x5bf70d);}})[_0x8f92('0x2b')](function(_0x4ab081){if(_0x4ab081){_0x3095f6=_0x4ab081[_0x8f92('0x3f')];if(!_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x82')]('nolimit')){_0x5bf70d[_0x8f92('0x41')]=qs[_0x8f92('0x41')](_0x38e8cd[_0x8f92('0x3b')][_0x8f92('0x41')]);_0x5bf70d[_0x8f92('0x25')]=qs['offset'](_0x38e8cd[_0x8f92('0x3b')]['offset']);}return _0x53dab6[_0x8f92('0x81')](_0x5bf70d);}})['then'](function(_0x56032d){if(_0x56032d){return _0x56032d?{'count':_0x3095f6,'rows':_0x56032d}:null;}})[_0x8f92('0x2b')](respondWithResult(_0x4d0600,null))[_0x8f92('0x59')](handleError(_0x4d0600,null));};
\ No newline at end of file