Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / team / team.controller.js
index f10569c..a08a5f6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x63f2=['interface','UserVoiceQueueRt','upsert','format','SIP/%s','spread','emit','userTeam:save','voice','chat','mail','sms','fax','whatsapp','removeAgents','isArray','userTeam:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','ejs','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','./team.socket','register','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','sendStatus','error','name','send','map','Team','fieldName','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Teams','UserProfileSection','find','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','channel','isValidChannel','ValidationError','Unknown\x20channel','toLowerCase','Queue','capitalize','Queues','findOne','Sequelize','add','removeQueues','ids','Voice','Mail','Fax','Openchannel','Whatsapp','each','addAgents','User','online','voicePause'];(function(_0x962fc5,_0x58f074){var _0x43667c=function(_0x5e6ec0){while(--_0x5e6ec0){_0x962fc5['push'](_0x962fc5['shift']());}};_0x43667c(++_0x58f074);}(_0x63f2,0x19b));var _0x263f=function(_0x1e21c4,_0x2b2d05){_0x1e21c4=_0x1e21c4-0x0;var _0x5a1422=_0x63f2[_0x1e21c4];return _0x5a1422;};'use strict';var pdf=require(_0x263f('0x0'));var emlformat=require(_0x263f('0x1'));var rimraf=require(_0x263f('0x2'));var zipdir=require(_0x263f('0x3'));var jsonpatch=require(_0x263f('0x4'));var rp=require(_0x263f('0x5'));var moment=require(_0x263f('0x6'));var BPromise=require(_0x263f('0x7'));var Mustache=require(_0x263f('0x8'));var util=require('util');var path=require(_0x263f('0x9'));var sox=require(_0x263f('0xa'));var csv=require('to-csv');var ejs=require(_0x263f('0xb'));var fs=require('fs');var _=require(_0x263f('0xc'));var squel=require(_0x263f('0xd'));var crypto=require('crypto');var jsforce=require(_0x263f('0xe'));var deskjs=require(_0x263f('0xf'));var toCsv=require(_0x263f('0x10'));var querystring=require(_0x263f('0x11'));var Papa=require(_0x263f('0x12'));var Redis=require(_0x263f('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x263f('0x14'));var as=require(_0x263f('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x263f('0x16'))(_0x263f('0x17'));var utils=require(_0x263f('0x18'));var config=require(_0x263f('0x19'));var db=require(_0x263f('0x1a'))['db'];config[_0x263f('0x1b')]=_[_0x263f('0x1c')](config[_0x263f('0x1b')],{'host':_0x263f('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x263f('0x1b')]));require(_0x263f('0x1e'))[_0x263f('0x1f')](socket);function respondWithStatusCode(_0x2fd47f,_0x553413){_0x553413=_0x553413||0xcc;return function(_0x55b928){if(_0x55b928){return _0x2fd47f['sendStatus'](_0x553413);}return _0x2fd47f[_0x263f('0x20')](_0x553413)[_0x263f('0x21')]();};}function respondWithResult(_0x571c6e,_0x119170){_0x119170=_0x119170||0xc8;return function(_0x2cd876){if(_0x2cd876){return _0x571c6e[_0x263f('0x20')](_0x119170)[_0x263f('0x22')](_0x2cd876);}};}function respondWithFilteredResult(_0x5365ea,_0x4169c4){return function(_0x45698d){if(_0x45698d){var _0x143dcd=_0x45698d[_0x263f('0x23')],_0x408bf8=_0x4169c4[_0x263f('0x24')],_0x5a68cf=_0x4169c4[_0x263f('0x24')]+_0x4169c4[_0x263f('0x25')],_0x34fea3;if(_0x5a68cf>=_0x143dcd){_0x5a68cf=_0x143dcd;_0x34fea3=0xc8;}else{_0x34fea3=0xce;}_0x5365ea[_0x263f('0x20')](_0x34fea3);return _0x5365ea[_0x263f('0x26')](_0x263f('0x27'),_0x408bf8+'-'+_0x5a68cf+'/'+_0x143dcd)[_0x263f('0x22')](_0x45698d);}return null;};}function patchUpdates(_0x3ad729){return function(_0x52acc8){try{jsonpatch[_0x263f('0x28')](_0x52acc8,_0x3ad729,!![]);}catch(_0x28549f){return BPromise[_0x263f('0x29')](_0x28549f);}return _0x52acc8[_0x263f('0x2a')]();};}function saveUpdates(_0x3f1d6e,_0x12c090){return function(_0x3d208e){if(_0x3d208e){return _0x3d208e[_0x263f('0x2b')](_0x3f1d6e)[_0x263f('0x2c')](function(_0x30bb0c){return _0x30bb0c;});}return null;};}function removeEntity(_0x57ee4f,_0x3b3494){return function(_0x489af7){if(_0x489af7){return _0x489af7[_0x263f('0x2d')]()['then'](function(){var _0x55a0dd=_0x489af7['get']({'plain':!![]});var _0x399cc3='Teams';return db['UserProfileResource'][_0x263f('0x2d')]({'where':{'type':_0x399cc3,'resourceId':_0x55a0dd['id']}})[_0x263f('0x2c')](function(){return _0x489af7;});})['then'](function(){_0x57ee4f[_0x263f('0x20')](0xcc)[_0x263f('0x21')]();});}};}function handleEntityNotFound(_0x302e50,_0x35e358){return function(_0xdb34d6){if(!_0xdb34d6){_0x302e50[_0x263f('0x2e')](0x194);}return _0xdb34d6;};}function handleError(_0xea84b4,_0x2097bc){_0x2097bc=_0x2097bc||0x1f4;return function(_0x4ac6a6){logger[_0x263f('0x2f')](_0x4ac6a6['stack']);if(_0x4ac6a6[_0x263f('0x30')]){delete _0x4ac6a6[_0x263f('0x30')];}_0xea84b4[_0x263f('0x20')](_0x2097bc)[_0x263f('0x31')](_0x4ac6a6);};}exports['index']=function(_0x89c70c,_0x1d4404){var _0x25fe4a={},_0x645ddb={},_0x1a8f6a={'count':0x0,'rows':[]};var _0x46efba=_[_0x263f('0x32')](db[_0x263f('0x33')]['rawAttributes'],function(_0x1cf270){return{'name':_0x1cf270[_0x263f('0x34')],'type':_0x1cf270['type']['key']};});_0x645ddb[_0x263f('0x35')]=_[_0x263f('0x32')](_0x46efba,_0x263f('0x30'));_0x645ddb[_0x263f('0x36')]=_[_0x263f('0x37')](_0x89c70c[_0x263f('0x36')]);_0x645ddb[_0x263f('0x38')]=_[_0x263f('0x39')](_0x645ddb[_0x263f('0x35')],_0x645ddb['query']);_0x25fe4a[_0x263f('0x3a')]=_['intersection'](_0x645ddb[_0x263f('0x35')],qs[_0x263f('0x3b')](_0x89c70c[_0x263f('0x36')][_0x263f('0x3b')]));_0x25fe4a[_0x263f('0x3a')]=_0x25fe4a['attributes'][_0x263f('0x3c')]?_0x25fe4a['attributes']:_0x645ddb[_0x263f('0x35')];if(!_0x89c70c[_0x263f('0x36')][_0x263f('0x3d')](_0x263f('0x3e'))){_0x25fe4a[_0x263f('0x25')]=qs[_0x263f('0x25')](_0x89c70c[_0x263f('0x36')]['limit']);_0x25fe4a['offset']=qs[_0x263f('0x24')](_0x89c70c['query']['offset']);}_0x25fe4a[_0x263f('0x3f')]=qs[_0x263f('0x40')](_0x89c70c[_0x263f('0x36')][_0x263f('0x40')]);_0x25fe4a[_0x263f('0x41')]=qs[_0x263f('0x38')](_[_0x263f('0x42')](_0x89c70c[_0x263f('0x36')],_0x645ddb[_0x263f('0x38')]),_0x46efba);if(_0x89c70c[_0x263f('0x36')][_0x263f('0x43')]){_0x25fe4a[_0x263f('0x41')]=_[_0x263f('0x44')](_0x25fe4a[_0x263f('0x41')],{'$or':_[_0x263f('0x32')](_0x46efba,function(_0xf9a72b){if(_0xf9a72b['type']!==_0x263f('0x45')){var _0x5eff40={};_0x5eff40[_0xf9a72b[_0x263f('0x30')]]={'$like':'%'+_0x89c70c[_0x263f('0x36')][_0x263f('0x43')]+'%'};return _0x5eff40;}})});}_0x25fe4a=_[_0x263f('0x44')]({},_0x25fe4a,_0x89c70c[_0x263f('0x46')]);var _0x52e13a={'where':_0x25fe4a[_0x263f('0x41')]};return db['Team']['count'](_0x52e13a)[_0x263f('0x2c')](function(_0x1a1768){_0x1a8f6a[_0x263f('0x23')]=_0x1a1768;if(_0x89c70c['query'][_0x263f('0x47')]){_0x25fe4a[_0x263f('0x48')]=[{'all':!![]}];}return db[_0x263f('0x33')][_0x263f('0x49')](_0x25fe4a);})[_0x263f('0x2c')](function(_0x31c539){_0x1a8f6a[_0x263f('0x4a')]=_0x31c539;return _0x1a8f6a;})[_0x263f('0x2c')](respondWithFilteredResult(_0x1d4404,_0x25fe4a))[_0x263f('0x4b')](handleError(_0x1d4404,null));};exports[_0x263f('0x4c')]=function(_0x135550,_0x51f09c){var _0x30997d={'raw':![],'where':{'id':_0x135550[_0x263f('0x4d')]['id']}},_0x4eef5f={};_0x4eef5f['model']=_['keys'](db[_0x263f('0x33')][_0x263f('0x4e')]);_0x4eef5f['query']=_['keys'](_0x135550['query']);_0x4eef5f[_0x263f('0x38')]=_['intersection'](_0x4eef5f['model'],_0x4eef5f[_0x263f('0x36')]);_0x30997d[_0x263f('0x3a')]=_['intersection'](_0x4eef5f[_0x263f('0x35')],qs['fields'](_0x135550[_0x263f('0x36')][_0x263f('0x3b')]));_0x30997d[_0x263f('0x3a')]=_0x30997d[_0x263f('0x3a')][_0x263f('0x3c')]?_0x30997d[_0x263f('0x3a')]:_0x4eef5f[_0x263f('0x35')];if(_0x135550[_0x263f('0x36')][_0x263f('0x47')]){_0x30997d[_0x263f('0x48')]=[{'all':!![]}];}_0x30997d=_[_0x263f('0x44')]({},_0x30997d,_0x135550[_0x263f('0x46')]);return db[_0x263f('0x33')]['find'](_0x30997d)[_0x263f('0x2c')](handleEntityNotFound(_0x51f09c,null))[_0x263f('0x2c')](respondWithResult(_0x51f09c,null))[_0x263f('0x4b')](handleError(_0x51f09c,null));};exports[_0x263f('0x4f')]=function(_0x4d93a9,_0x448f96){return db[_0x263f('0x33')][_0x263f('0x4f')](_0x4d93a9[_0x263f('0x50')],{})[_0x263f('0x2c')](function(_0x2969a8){var _0x4cc5ac=_0x4d93a9['user'][_0x263f('0x51')]({'plain':!![]});if(!_0x4cc5ac)throw new Error(_0x263f('0x52'));if(_0x4cc5ac[_0x263f('0x53')]==='user'){var _0x41b79c=_0x2969a8['get']({'plain':!![]});var _0x2684b9=_0x263f('0x54');return db[_0x263f('0x55')][_0x263f('0x56')]({'where':{'name':_0x2684b9,'userProfileId':_0x4cc5ac['userProfileId']},'raw':!![]})[_0x263f('0x2c')](function(_0x32e070){if(_0x32e070&&_0x32e070[_0x263f('0x57')]===0x0){return db[_0x263f('0x58')][_0x263f('0x4f')]({'name':_0x41b79c[_0x263f('0x30')],'resourceId':_0x41b79c['id'],'type':_0x32e070['name'],'sectionId':_0x32e070['id']},{})['then'](function(){return _0x2969a8;});}else{return _0x2969a8;}})[_0x263f('0x4b')](function(_0x455e9b){logger[_0x263f('0x2f')](_0x263f('0x59'),_0x455e9b);throw _0x455e9b;});}return _0x2969a8;})[_0x263f('0x2c')](respondWithResult(_0x448f96,0xc9))[_0x263f('0x4b')](handleError(_0x448f96,null));};exports[_0x263f('0x2b')]=function(_0x891cba,_0x3c5b54){if(_0x891cba[_0x263f('0x50')]['id']){delete _0x891cba[_0x263f('0x50')]['id'];}return db[_0x263f('0x33')][_0x263f('0x56')]({'where':{'id':_0x891cba[_0x263f('0x4d')]['id']}})[_0x263f('0x2c')](handleEntityNotFound(_0x3c5b54,null))[_0x263f('0x2c')](saveUpdates(_0x891cba[_0x263f('0x50')],null))['then'](respondWithResult(_0x3c5b54,null))[_0x263f('0x4b')](handleError(_0x3c5b54,null));};exports[_0x263f('0x2d')]=function(_0x3a1c3e,_0x57fa2a){return db['Team'][_0x263f('0x56')]({'where':{'id':_0x3a1c3e[_0x263f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x57fa2a,null))[_0x263f('0x2c')](removeEntity(_0x57fa2a,null))[_0x263f('0x4b')](handleError(_0x57fa2a,null));};exports['getQueues']=function(_0x4a2cfc,_0x43023f,_0x5b88c6){return db[_0x263f('0x33')]['findOne']({'where':{'id':_0x4a2cfc[_0x263f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x43023f,null))[_0x263f('0x2c')](function(_0x4b5893){if(!_0x4a2cfc[_0x263f('0x36')][_0x263f('0x5a')]||!utils[_0x263f('0x5b')](_0x4a2cfc[_0x263f('0x36')][_0x263f('0x5a')])){throw new db['Sequelize'][(_0x263f('0x5c'))](_0x263f('0x5d'));}var _0x6ddb44={};var _0x236124={};_0x236124[_0x263f('0x35')]=_['keys'](db[_['capitalize'](_0x4a2cfc[_0x263f('0x36')][_0x263f('0x5a')][_0x263f('0x5e')]())+_0x263f('0x5f')][_0x263f('0x4e')]);_0x236124[_0x263f('0x36')]=_[_0x263f('0x37')](_0x4a2cfc[_0x263f('0x36')]);_0x236124[_0x263f('0x38')]=_['intersection'](_0x236124[_0x263f('0x35')],_0x236124[_0x263f('0x36')]);_0x6ddb44[_0x263f('0x3a')]=_[_0x263f('0x39')](_0x236124[_0x263f('0x35')],qs[_0x263f('0x3b')](_0x4a2cfc[_0x263f('0x36')]['fields']));_0x6ddb44[_0x263f('0x3a')]=_0x6ddb44[_0x263f('0x3a')][_0x263f('0x3c')]?_0x6ddb44[_0x263f('0x3a')]:_0x236124['model'];_0x6ddb44[_0x263f('0x25')]=qs[_0x263f('0x25')](_0x4a2cfc[_0x263f('0x36')]['limit']);_0x6ddb44[_0x263f('0x24')]=qs[_0x263f('0x24')](_0x4a2cfc[_0x263f('0x36')][_0x263f('0x24')]);_0x6ddb44[_0x263f('0x3f')]=qs[_0x263f('0x40')](_0x4a2cfc[_0x263f('0x36')]['sort']);_0x6ddb44[_0x263f('0x41')]=qs[_0x263f('0x38')](_[_0x263f('0x42')](_0x4a2cfc[_0x263f('0x36')],_0x236124[_0x263f('0x38')]));_0x6ddb44=_['merge']({},_0x6ddb44,_0x4a2cfc['options']);return _0x4b5893[_0x263f('0x51')+_[_0x263f('0x60')](_0x4a2cfc[_0x263f('0x36')]['channel'][_0x263f('0x5e')]())+_0x263f('0x61')](_0x6ddb44);})[_0x263f('0x2c')](respondWithResult(_0x43023f,null))[_0x263f('0x4b')](handleError(_0x43023f,null));};exports['addQueues']=function(_0x191d83,_0x5a9f24,_0x534c86){return db[_0x263f('0x33')][_0x263f('0x62')]({'where':{'id':_0x191d83[_0x263f('0x4d')]['id']}})[_0x263f('0x2c')](function(_0x13121c){if(_0x13121c){if(!_0x191d83[_0x263f('0x50')]['channel']||!utils['isValidChannel'](_0x191d83['body']['channel'])){throw new db[(_0x263f('0x63'))][(_0x263f('0x5c'))](_0x263f('0x5d'));}return _0x13121c[_0x263f('0x64')+_[_0x263f('0x60')](_0x191d83[_0x263f('0x50')][_0x263f('0x5a')][_0x263f('0x5e')]())+_0x263f('0x61')](_0x191d83[_0x263f('0x50')]['ids']);}return null;})['then'](handleEntityNotFound(_0x5a9f24,null))[_0x263f('0x2c')](respondWithStatusCode(_0x5a9f24,null))[_0x263f('0x4b')](handleError(_0x5a9f24,null));};exports[_0x263f('0x65')]=function(_0x8bd73e,_0x153515,_0x71a2ea){return db['Team']['findOne']({'where':{'id':_0x8bd73e['params']['id']}})[_0x263f('0x2c')](function(_0x497c93){if(_0x497c93){if(!_0x8bd73e[_0x263f('0x36')]['channel']||!utils[_0x263f('0x5b')](_0x8bd73e[_0x263f('0x36')][_0x263f('0x5a')])){throw new db[(_0x263f('0x63'))][(_0x263f('0x5c'))](_0x263f('0x5d'));}return _0x497c93['remove'+_['capitalize'](_0x8bd73e[_0x263f('0x36')][_0x263f('0x5a')][_0x263f('0x5e')]())+_0x263f('0x61')](_0x8bd73e[_0x263f('0x36')][_0x263f('0x66')]);}return null;})[_0x263f('0x2c')](handleEntityNotFound(_0x153515,null))[_0x263f('0x2c')](respondWithStatusCode(_0x153515,null))[_0x263f('0x4b')](handleError(_0x153515,null));};exports['addAgents']=function(_0x2ee4be,_0x1f577c,_0x587fe7){return db[_0x263f('0x33')][_0x263f('0x56')]({'where':{'id':_0x2ee4be[_0x263f('0x4d')]['id']}})[_0x263f('0x2c')](handleEntityNotFound(_0x1f577c,null))[_0x263f('0x2c')](function(_0xf7f73e){if(_0xf7f73e){var _0x79e8d0=[_0x263f('0x67'),'Chat',_0x263f('0x68'),'Sms',_0x263f('0x69'),_0x263f('0x6a'),_0x263f('0x6b')];return BPromise[_0x263f('0x6c')](_0x79e8d0,function(_0x5e9248){return _0xf7f73e[_0x263f('0x51')+_0x5e9248+_0x263f('0x61')]({'attributes':['id',_0x263f('0x30')]})['then'](function(_0x55717b){return BPromise['each'](_0x55717b,function(_0x4b9da8){return _0x4b9da8[_0x263f('0x6d')](_0x2ee4be[_0x263f('0x50')]['ids'])[_0x263f('0x2c')](function(){if(_0x5e9248===_0x263f('0x67')){return db[_0x263f('0x6e')][_0x263f('0x49')]({'where':{'id':_0x2ee4be[_0x263f('0x50')][_0x263f('0x66')]},'attributes':['id','name',_0x263f('0x6f'),_0x263f('0x70'),_0x263f('0x71')],'raw':!![]})[_0x263f('0x2c')](function(_0x2d82c5){return BPromise['each'](_[_0x263f('0x43')](_0x2d82c5,{'online':0x1}),function(_0x657206){return db[_0x263f('0x72')][_0x263f('0x73')]({'membername':_0x657206['name'],'UserId':_0x657206['id'],'queue_name':_0x4b9da8[_0x263f('0x30')],'VoiceQueueId':_0x4b9da8['id'],'interface':_['isNil'](_0x657206[_0x263f('0x71')])?util[_0x263f('0x74')](_0x263f('0x75'),_0x657206[_0x263f('0x30')]):_0x657206[_0x263f('0x71')],'paused':_0x657206[_0x263f('0x70')]||![],'penalty':0x0});});});}});});})[_0x263f('0x2c')](function(){return _0xf7f73e;});})['then'](function(){return _0xf7f73e;});}})[_0x263f('0x2c')](function(_0x15aa5e){if(_0x15aa5e){return _0x15aa5e[_0x263f('0x6d')](_0x2ee4be[_0x263f('0x50')][_0x263f('0x66')],_['omit'](_0x2ee4be[_0x263f('0x50')],[_0x263f('0x66'),'id'])||{})[_0x263f('0x76')](function(_0x2ada83){for(var _0x420097=0x0;_0x420097<_0x2ee4be['body'][_0x263f('0x66')]['length'];_0x420097+=0x1){socket[_0x263f('0x77')](_0x263f('0x78'),{'UserId':_0x2ee4be[_0x263f('0x50')][_0x263f('0x66')][_0x420097],'TeamId':_0x2ee4be['params']['id']});}return _0x2ada83;});}})['then'](respondWithResult(_0x1f577c,null))[_0x263f('0x4b')](handleError(_0x1f577c,null));};exports['removeAgents']=function(_0x517b22,_0x1fb119,_0x23f9fe){return db[_0x263f('0x33')][_0x263f('0x56')]({'where':{'id':_0x517b22['params']['id']}})[_0x263f('0x2c')](handleEntityNotFound(_0x1fb119,null))[_0x263f('0x2c')](function(_0x37a6e3){if(_0x37a6e3){return BPromise[_0x263f('0x6c')]([_0x263f('0x79'),_0x263f('0x7a'),_0x263f('0x7b'),_0x263f('0x7c'),_0x263f('0x7d'),'openchannel',_0x263f('0x7e')],function(_0x46f59c){return _0x37a6e3[_0x263f('0x51')+_['capitalize'](_0x46f59c)+'Queues']({'attributes':['id',_0x263f('0x30')]})[_0x263f('0x2c')](function(_0x3f0032){return BPromise['each'](_0x3f0032,function(_0xabcb40){return _0xabcb40[_0x263f('0x7f')](_0x517b22[_0x263f('0x36')][_0x263f('0x66')])[_0x263f('0x2c')](function(){if(_0x46f59c===_0x263f('0x79')){return db[_0x263f('0x72')][_0x263f('0x2d')]({'where':{'VoiceQueueId':_0xabcb40['id'],'UserId':_0x517b22[_0x263f('0x36')][_0x263f('0x66')]}});}});});})[_0x263f('0x2c')](function(){return _0x37a6e3;});})[_0x263f('0x2c')](function(){return _0x37a6e3;});}})[_0x263f('0x2c')](function(_0x1985de){if(_0x1985de){return _0x1985de[_0x263f('0x7f')](_0x517b22['query'][_0x263f('0x66')])[_0x263f('0x2c')](function(){if(_[_0x263f('0x80')](_0x517b22['query'][_0x263f('0x66')])){for(var _0x6c48ad=0x0;_0x6c48ad<_0x517b22[_0x263f('0x36')][_0x263f('0x66')][_0x263f('0x3c')];_0x6c48ad+=0x1){socket[_0x263f('0x77')](_0x263f('0x81'),{'UserId':Number(_0x517b22[_0x263f('0x36')][_0x263f('0x66')][_0x6c48ad]),'TeamId':Number(_0x517b22['params']['id'])});}}else{socket['emit'](_0x263f('0x81'),{'UserId':Number(_0x517b22[_0x263f('0x36')][_0x263f('0x66')]),'TeamId':Number(_0x517b22[_0x263f('0x4d')]['id'])});}});}})[_0x263f('0x2c')](respondWithStatusCode(_0x1fb119,null))[_0x263f('0x4b')](handleError(_0x1fb119,null));};exports[_0x263f('0x82')]=function(_0x559f3e,_0x3c446c,_0x487de4){var _0x29cd06={};var _0x82e8aa={};var _0x3bdbbf;var _0x3bd49d;return db[_0x263f('0x33')][_0x263f('0x62')]({'where':{'id':_0x559f3e['params']['id']}})[_0x263f('0x2c')](handleEntityNotFound(_0x3c446c,null))[_0x263f('0x2c')](function(_0x17b529){if(_0x17b529){_0x3bdbbf=_0x17b529;_0x82e8aa[_0x263f('0x35')]=_['keys'](db[_0x263f('0x6e')][_0x263f('0x4e')]);_0x82e8aa[_0x263f('0x36')]=_[_0x263f('0x37')](_0x559f3e[_0x263f('0x36')]);_0x82e8aa[_0x263f('0x38')]=_['intersection'](_0x82e8aa['model'],_0x82e8aa[_0x263f('0x36')]);_0x29cd06[_0x263f('0x3a')]=_[_0x263f('0x39')](_0x82e8aa[_0x263f('0x35')],qs[_0x263f('0x3b')](_0x559f3e[_0x263f('0x36')][_0x263f('0x3b')]));_0x29cd06[_0x263f('0x3a')]=_0x29cd06[_0x263f('0x3a')]['length']?_0x29cd06[_0x263f('0x3a')]:_0x82e8aa['model'];_0x29cd06[_0x263f('0x3f')]=qs[_0x263f('0x40')](_0x559f3e['query'][_0x263f('0x40')]);_0x29cd06[_0x263f('0x41')]=qs[_0x263f('0x38')](_[_0x263f('0x42')](_0x559f3e[_0x263f('0x36')],_0x82e8aa[_0x263f('0x38')]));if(_0x559f3e['query'][_0x263f('0x43')]){_0x29cd06[_0x263f('0x41')]=_[_0x263f('0x44')](_0x29cd06[_0x263f('0x41')],{'$or':_['map'](_0x29cd06['attributes'],function(_0x5494e8){var _0x3e34ef={};_0x3e34ef[_0x5494e8]={'$like':'%'+_0x559f3e[_0x263f('0x36')][_0x263f('0x43')]+'%'};return _0x3e34ef;})});}_0x29cd06=_[_0x263f('0x44')]({},_0x29cd06,_0x559f3e[_0x263f('0x46')]);return _0x3bdbbf[_0x263f('0x82')](_0x29cd06);}})[_0x263f('0x2c')](function(_0x5d7240){if(_0x5d7240){_0x3bd49d=_0x5d7240[_0x263f('0x3c')];if(!_0x559f3e[_0x263f('0x36')][_0x263f('0x3d')](_0x263f('0x3e'))){_0x29cd06[_0x263f('0x25')]=qs['limit'](_0x559f3e[_0x263f('0x36')][_0x263f('0x25')]);_0x29cd06['offset']=qs[_0x263f('0x24')](_0x559f3e[_0x263f('0x36')][_0x263f('0x24')]);}return _0x3bdbbf['getAgents'](_0x29cd06);}})[_0x263f('0x2c')](function(_0x16aa9b){if(_0x16aa9b){return _0x16aa9b?{'count':_0x3bd49d,'rows':_0x16aa9b}:null;}})['then'](respondWithResult(_0x3c446c,null))[_0x263f('0x4b')](handleError(_0x3c446c,null));};
\ No newline at end of file
+var _0x3b78=['Queue','Queues','isValidChannel','ValidationError','add','ids','removeQueues','Sequelize','remove','addAgents','Voice','Chat','Mail','Sms','Fax','Openchannel','Whatsapp','each','User','online','UserVoiceQueueRt','upsert','interface','format','SIP/%s','voicePause','omit','spread','emit','userTeam:save','removeAgents','voice','chat','mail','fax','whatsapp','userTeam:remove','getAgents','html-pdf','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','./team.socket','register','end','status','json','offset','limit','set','Content-Range','save','then','get','Teams','sendStatus','error','stack','name','send','index','Team','fieldName','key','map','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','count','include','findAll','show','params','includeAll','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','destroy','getQueues','findOne','channel','Unknown\x20channel','capitalize','toLowerCase'];(function(_0x23c383,_0x5e7fa1){var _0x2d8a5f=function(_0x22af9e){while(--_0x22af9e){_0x23c383['push'](_0x23c383['shift']());}};_0x2d8a5f(++_0x5e7fa1);}(_0x3b78,0xaa));var _0x83b7=function(_0x5dc89d,_0x53dd2c){_0x5dc89d=_0x5dc89d-0x0;var _0x3a18c2=_0x3b78[_0x5dc89d];return _0x3a18c2;};'use strict';var pdf=require(_0x83b7('0x0'));var emlformat=require(_0x83b7('0x1'));var rimraf=require(_0x83b7('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x83b7('0x3'));var moment=require(_0x83b7('0x4'));var BPromise=require(_0x83b7('0x5'));var Mustache=require(_0x83b7('0x6'));var util=require(_0x83b7('0x7'));var path=require('path');var sox=require(_0x83b7('0x8'));var csv=require(_0x83b7('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x83b7('0xa'));var squel=require(_0x83b7('0xb'));var crypto=require(_0x83b7('0xc'));var jsforce=require(_0x83b7('0xd'));var deskjs=require(_0x83b7('0xe'));var toCsv=require(_0x83b7('0x9'));var querystring=require(_0x83b7('0xf'));var Papa=require(_0x83b7('0x10'));var Redis=require(_0x83b7('0x11'));var authService=require(_0x83b7('0x12'));var qs=require(_0x83b7('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x83b7('0x14'));var logger=require(_0x83b7('0x15'))('api');var utils=require(_0x83b7('0x16'));var config=require(_0x83b7('0x17'));var db=require(_0x83b7('0x18'))['db'];config[_0x83b7('0x19')]=_[_0x83b7('0x1a')](config['redis'],{'host':_0x83b7('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x83b7('0x19')]));require(_0x83b7('0x1c'))[_0x83b7('0x1d')](socket);function respondWithStatusCode(_0x47abd5,_0x2a2d51){_0x2a2d51=_0x2a2d51||0xcc;return function(_0x243019){if(_0x243019){return _0x47abd5['sendStatus'](_0x2a2d51);}return _0x47abd5['status'](_0x2a2d51)[_0x83b7('0x1e')]();};}function respondWithResult(_0x3cc9f5,_0x481612){_0x481612=_0x481612||0xc8;return function(_0x5588d5){if(_0x5588d5){return _0x3cc9f5[_0x83b7('0x1f')](_0x481612)[_0x83b7('0x20')](_0x5588d5);}};}function respondWithFilteredResult(_0x333efd,_0x57704d){return function(_0x2d74f2){if(_0x2d74f2){var _0x2595b2=_0x2d74f2['count'],_0x1c6cc7=_0x57704d[_0x83b7('0x21')],_0x37e4fa=_0x57704d[_0x83b7('0x21')]+_0x57704d[_0x83b7('0x22')],_0x40ed74;if(_0x37e4fa>=_0x2595b2){_0x37e4fa=_0x2595b2;_0x40ed74=0xc8;}else{_0x40ed74=0xce;}_0x333efd[_0x83b7('0x1f')](_0x40ed74);return _0x333efd[_0x83b7('0x23')](_0x83b7('0x24'),_0x1c6cc7+'-'+_0x37e4fa+'/'+_0x2595b2)[_0x83b7('0x20')](_0x2d74f2);}return null;};}function patchUpdates(_0x3aa726){return function(_0x38f060){try{jsonpatch['apply'](_0x38f060,_0x3aa726,!![]);}catch(_0x41ec1b){return BPromise['reject'](_0x41ec1b);}return _0x38f060[_0x83b7('0x25')]();};}function saveUpdates(_0x1d533b,_0x34190e){return function(_0x3b0958){if(_0x3b0958){return _0x3b0958['update'](_0x1d533b)[_0x83b7('0x26')](function(_0x542d58){return _0x542d58;});}return null;};}function removeEntity(_0x5e2b2c,_0x120fde){return function(_0x3d2802){if(_0x3d2802){return _0x3d2802['destroy']()[_0x83b7('0x26')](function(){var _0x1d87a6=_0x3d2802[_0x83b7('0x27')]({'plain':!![]});var _0x29adaf=_0x83b7('0x28');return db['UserProfileResource']['destroy']({'where':{'type':_0x29adaf,'resourceId':_0x1d87a6['id']}})[_0x83b7('0x26')](function(){return _0x3d2802;});})[_0x83b7('0x26')](function(){_0x5e2b2c[_0x83b7('0x1f')](0xcc)[_0x83b7('0x1e')]();});}};}function handleEntityNotFound(_0x470c11,_0x385903){return function(_0x2dadf0){if(!_0x2dadf0){_0x470c11[_0x83b7('0x29')](0x194);}return _0x2dadf0;};}function handleError(_0x3a5f74,_0x1448cb){_0x1448cb=_0x1448cb||0x1f4;return function(_0x195413){logger[_0x83b7('0x2a')](_0x195413[_0x83b7('0x2b')]);if(_0x195413[_0x83b7('0x2c')]){delete _0x195413[_0x83b7('0x2c')];}_0x3a5f74['status'](_0x1448cb)[_0x83b7('0x2d')](_0x195413);};}exports[_0x83b7('0x2e')]=function(_0x11b888,_0x54bf9c){var _0x19cc9a={},_0x44265f={},_0x14e463={'count':0x0,'rows':[]};var _0x41e235=_['map'](db[_0x83b7('0x2f')]['rawAttributes'],function(_0x134273){return{'name':_0x134273[_0x83b7('0x30')],'type':_0x134273['type'][_0x83b7('0x31')]};});_0x44265f['model']=_[_0x83b7('0x32')](_0x41e235,_0x83b7('0x2c'));_0x44265f[_0x83b7('0x33')]=_[_0x83b7('0x34')](_0x11b888[_0x83b7('0x33')]);_0x44265f[_0x83b7('0x35')]=_[_0x83b7('0x36')](_0x44265f[_0x83b7('0x37')],_0x44265f[_0x83b7('0x33')]);_0x19cc9a['attributes']=_[_0x83b7('0x36')](_0x44265f[_0x83b7('0x37')],qs[_0x83b7('0x38')](_0x11b888['query']['fields']));_0x19cc9a['attributes']=_0x19cc9a[_0x83b7('0x39')][_0x83b7('0x3a')]?_0x19cc9a[_0x83b7('0x39')]:_0x44265f['model'];if(!_0x11b888[_0x83b7('0x33')][_0x83b7('0x3b')](_0x83b7('0x3c'))){_0x19cc9a[_0x83b7('0x22')]=qs[_0x83b7('0x22')](_0x11b888[_0x83b7('0x33')][_0x83b7('0x22')]);_0x19cc9a[_0x83b7('0x21')]=qs[_0x83b7('0x21')](_0x11b888[_0x83b7('0x33')][_0x83b7('0x21')]);}_0x19cc9a[_0x83b7('0x3d')]=qs[_0x83b7('0x3e')](_0x11b888[_0x83b7('0x33')][_0x83b7('0x3e')]);_0x19cc9a[_0x83b7('0x3f')]=qs[_0x83b7('0x35')](_[_0x83b7('0x40')](_0x11b888[_0x83b7('0x33')],_0x44265f[_0x83b7('0x35')]),_0x41e235);if(_0x11b888[_0x83b7('0x33')][_0x83b7('0x41')]){_0x19cc9a['where']=_[_0x83b7('0x42')](_0x19cc9a[_0x83b7('0x3f')],{'$or':_[_0x83b7('0x32')](_0x41e235,function(_0x5dfd01){if(_0x5dfd01['type']!==_0x83b7('0x43')){var _0x111d4e={};_0x111d4e[_0x5dfd01[_0x83b7('0x2c')]]={'$like':'%'+_0x11b888['query'][_0x83b7('0x41')]+'%'};return _0x111d4e;}})});}_0x19cc9a=_['merge']({},_0x19cc9a,_0x11b888[_0x83b7('0x44')]);var _0x53032e={'where':_0x19cc9a['where']};return db[_0x83b7('0x2f')]['count'](_0x53032e)[_0x83b7('0x26')](function(_0x20795b){_0x14e463[_0x83b7('0x45')]=_0x20795b;if(_0x11b888[_0x83b7('0x33')]['includeAll']){_0x19cc9a[_0x83b7('0x46')]=[{'all':!![]}];}return db[_0x83b7('0x2f')][_0x83b7('0x47')](_0x19cc9a);})['then'](function(_0x21a52d){_0x14e463['rows']=_0x21a52d;return _0x14e463;})[_0x83b7('0x26')](respondWithFilteredResult(_0x54bf9c,_0x19cc9a))['catch'](handleError(_0x54bf9c,null));};exports[_0x83b7('0x48')]=function(_0x280fc7,_0x5076f7){var _0x388187={'raw':![],'where':{'id':_0x280fc7[_0x83b7('0x49')]['id']}},_0x3c43b9={};_0x3c43b9[_0x83b7('0x37')]=_[_0x83b7('0x34')](db[_0x83b7('0x2f')]['rawAttributes']);_0x3c43b9[_0x83b7('0x33')]=_[_0x83b7('0x34')](_0x280fc7['query']);_0x3c43b9['filters']=_[_0x83b7('0x36')](_0x3c43b9[_0x83b7('0x37')],_0x3c43b9[_0x83b7('0x33')]);_0x388187[_0x83b7('0x39')]=_[_0x83b7('0x36')](_0x3c43b9['model'],qs[_0x83b7('0x38')](_0x280fc7[_0x83b7('0x33')][_0x83b7('0x38')]));_0x388187['attributes']=_0x388187[_0x83b7('0x39')][_0x83b7('0x3a')]?_0x388187['attributes']:_0x3c43b9['model'];if(_0x280fc7[_0x83b7('0x33')][_0x83b7('0x4a')]){_0x388187[_0x83b7('0x46')]=[{'all':!![]}];}_0x388187=_[_0x83b7('0x42')]({},_0x388187,_0x280fc7[_0x83b7('0x44')]);return db[_0x83b7('0x2f')][_0x83b7('0x4b')](_0x388187)['then'](handleEntityNotFound(_0x5076f7,null))['then'](respondWithResult(_0x5076f7,null))[_0x83b7('0x4c')](handleError(_0x5076f7,null));};exports[_0x83b7('0x4d')]=function(_0x230cc9,_0x2e83d7){return db[_0x83b7('0x2f')]['create'](_0x230cc9[_0x83b7('0x4e')],{})[_0x83b7('0x26')](function(_0x3c6c56){var _0x18e78d=_0x230cc9[_0x83b7('0x4f')]['get']({'plain':!![]});if(!_0x18e78d)throw new Error(_0x83b7('0x50'));if(_0x18e78d[_0x83b7('0x51')]===_0x83b7('0x4f')){var _0xabc8d5=_0x3c6c56[_0x83b7('0x27')]({'plain':!![]});var _0x35b50d=_0x83b7('0x28');return db[_0x83b7('0x52')][_0x83b7('0x4b')]({'where':{'name':_0x35b50d,'userProfileId':_0x18e78d[_0x83b7('0x53')]},'raw':!![]})['then'](function(_0x24bd7a){if(_0x24bd7a&&_0x24bd7a[_0x83b7('0x54')]===0x0){return db['UserProfileResource'][_0x83b7('0x4d')]({'name':_0xabc8d5[_0x83b7('0x2c')],'resourceId':_0xabc8d5['id'],'type':_0x24bd7a[_0x83b7('0x2c')],'sectionId':_0x24bd7a['id']},{})[_0x83b7('0x26')](function(){return _0x3c6c56;});}else{return _0x3c6c56;}})[_0x83b7('0x4c')](function(_0x50b0d5){logger['error'](_0x83b7('0x55'),_0x50b0d5);throw _0x50b0d5;});}return _0x3c6c56;})[_0x83b7('0x26')](respondWithResult(_0x2e83d7,0xc9))[_0x83b7('0x4c')](handleError(_0x2e83d7,null));};exports[_0x83b7('0x56')]=function(_0xa23955,_0x15979c){if(_0xa23955[_0x83b7('0x4e')]['id']){delete _0xa23955[_0x83b7('0x4e')]['id'];}return db[_0x83b7('0x2f')][_0x83b7('0x4b')]({'where':{'id':_0xa23955[_0x83b7('0x49')]['id']}})['then'](handleEntityNotFound(_0x15979c,null))['then'](saveUpdates(_0xa23955[_0x83b7('0x4e')],null))[_0x83b7('0x26')](respondWithResult(_0x15979c,null))[_0x83b7('0x4c')](handleError(_0x15979c,null));};exports[_0x83b7('0x57')]=function(_0x188079,_0x53ee85){return db[_0x83b7('0x2f')][_0x83b7('0x4b')]({'where':{'id':_0x188079[_0x83b7('0x49')]['id']}})[_0x83b7('0x26')](handleEntityNotFound(_0x53ee85,null))[_0x83b7('0x26')](removeEntity(_0x53ee85,null))[_0x83b7('0x4c')](handleError(_0x53ee85,null));};exports[_0x83b7('0x58')]=function(_0x496819,_0x3f053a,_0x1dea84){return db[_0x83b7('0x2f')][_0x83b7('0x59')]({'where':{'id':_0x496819[_0x83b7('0x49')]['id']}})[_0x83b7('0x26')](handleEntityNotFound(_0x3f053a,null))['then'](function(_0x4f45cc){if(!_0x496819[_0x83b7('0x33')][_0x83b7('0x5a')]||!utils['isValidChannel'](_0x496819[_0x83b7('0x33')][_0x83b7('0x5a')])){throw new db['Sequelize']['ValidationError'](_0x83b7('0x5b'));}var _0x46b131={};var _0x2ee573={};_0x2ee573[_0x83b7('0x37')]=_[_0x83b7('0x34')](db[_[_0x83b7('0x5c')](_0x496819['query']['channel'][_0x83b7('0x5d')]())+_0x83b7('0x5e')]['rawAttributes']);_0x2ee573[_0x83b7('0x33')]=_[_0x83b7('0x34')](_0x496819[_0x83b7('0x33')]);_0x2ee573[_0x83b7('0x35')]=_[_0x83b7('0x36')](_0x2ee573['model'],_0x2ee573[_0x83b7('0x33')]);_0x46b131[_0x83b7('0x39')]=_[_0x83b7('0x36')](_0x2ee573[_0x83b7('0x37')],qs['fields'](_0x496819['query'][_0x83b7('0x38')]));_0x46b131[_0x83b7('0x39')]=_0x46b131[_0x83b7('0x39')][_0x83b7('0x3a')]?_0x46b131['attributes']:_0x2ee573['model'];_0x46b131['limit']=qs[_0x83b7('0x22')](_0x496819[_0x83b7('0x33')]['limit']);_0x46b131[_0x83b7('0x21')]=qs[_0x83b7('0x21')](_0x496819[_0x83b7('0x33')][_0x83b7('0x21')]);_0x46b131[_0x83b7('0x3d')]=qs['sort'](_0x496819['query'][_0x83b7('0x3e')]);_0x46b131[_0x83b7('0x3f')]=qs[_0x83b7('0x35')](_['pick'](_0x496819['query'],_0x2ee573['filters']));_0x46b131=_[_0x83b7('0x42')]({},_0x46b131,_0x496819[_0x83b7('0x44')]);return _0x4f45cc[_0x83b7('0x27')+_[_0x83b7('0x5c')](_0x496819[_0x83b7('0x33')][_0x83b7('0x5a')][_0x83b7('0x5d')]())+_0x83b7('0x5f')](_0x46b131);})[_0x83b7('0x26')](respondWithResult(_0x3f053a,null))[_0x83b7('0x4c')](handleError(_0x3f053a,null));};exports['addQueues']=function(_0x2181f4,_0x50e41e,_0x310745){return db[_0x83b7('0x2f')][_0x83b7('0x59')]({'where':{'id':_0x2181f4[_0x83b7('0x49')]['id']}})[_0x83b7('0x26')](function(_0x4c680e){if(_0x4c680e){if(!_0x2181f4[_0x83b7('0x4e')][_0x83b7('0x5a')]||!utils[_0x83b7('0x60')](_0x2181f4[_0x83b7('0x4e')]['channel'])){throw new db['Sequelize'][(_0x83b7('0x61'))](_0x83b7('0x5b'));}return _0x4c680e[_0x83b7('0x62')+_[_0x83b7('0x5c')](_0x2181f4[_0x83b7('0x4e')][_0x83b7('0x5a')][_0x83b7('0x5d')]())+_0x83b7('0x5f')](_0x2181f4[_0x83b7('0x4e')][_0x83b7('0x63')]);}return null;})['then'](handleEntityNotFound(_0x50e41e,null))[_0x83b7('0x26')](respondWithStatusCode(_0x50e41e,null))[_0x83b7('0x4c')](handleError(_0x50e41e,null));};exports[_0x83b7('0x64')]=function(_0x161cd3,_0x1177c8,_0x152c75){return db[_0x83b7('0x2f')][_0x83b7('0x59')]({'where':{'id':_0x161cd3[_0x83b7('0x49')]['id']}})[_0x83b7('0x26')](function(_0x2f440b){if(_0x2f440b){if(!_0x161cd3[_0x83b7('0x33')][_0x83b7('0x5a')]||!utils[_0x83b7('0x60')](_0x161cd3[_0x83b7('0x33')]['channel'])){throw new db[(_0x83b7('0x65'))][(_0x83b7('0x61'))]('Unknown\x20channel');}return _0x2f440b[_0x83b7('0x66')+_[_0x83b7('0x5c')](_0x161cd3[_0x83b7('0x33')][_0x83b7('0x5a')]['toLowerCase']())+_0x83b7('0x5f')](_0x161cd3[_0x83b7('0x33')]['ids']);}return null;})[_0x83b7('0x26')](handleEntityNotFound(_0x1177c8,null))['then'](respondWithStatusCode(_0x1177c8,null))[_0x83b7('0x4c')](handleError(_0x1177c8,null));};exports[_0x83b7('0x67')]=function(_0x20c6fc,_0x32de98,_0x28b8d1){return db[_0x83b7('0x2f')][_0x83b7('0x4b')]({'where':{'id':_0x20c6fc[_0x83b7('0x49')]['id']}})[_0x83b7('0x26')](handleEntityNotFound(_0x32de98,null))['then'](function(_0x17fbe1){if(_0x17fbe1){var _0x57107c=[_0x83b7('0x68'),_0x83b7('0x69'),_0x83b7('0x6a'),_0x83b7('0x6b'),_0x83b7('0x6c'),_0x83b7('0x6d'),_0x83b7('0x6e')];return BPromise['each'](_0x57107c,function(_0x4673f3){return _0x17fbe1['get'+_0x4673f3+_0x83b7('0x5f')]({'attributes':['id',_0x83b7('0x2c')]})[_0x83b7('0x26')](function(_0x3b559a){return BPromise[_0x83b7('0x6f')](_0x3b559a,function(_0x202d48){return _0x202d48['addAgents'](_0x20c6fc[_0x83b7('0x4e')][_0x83b7('0x63')])[_0x83b7('0x26')](function(){if(_0x4673f3===_0x83b7('0x68')){return db[_0x83b7('0x70')]['findAll']({'where':{'id':_0x20c6fc[_0x83b7('0x4e')][_0x83b7('0x63')]},'attributes':['id','name',_0x83b7('0x71'),'voicePause','interface'],'raw':!![]})[_0x83b7('0x26')](function(_0x23a607){return BPromise['each'](_[_0x83b7('0x41')](_0x23a607,{'online':0x1}),function(_0x37254a){return db[_0x83b7('0x72')][_0x83b7('0x73')]({'membername':_0x37254a['name'],'UserId':_0x37254a['id'],'queue_name':_0x202d48[_0x83b7('0x2c')],'VoiceQueueId':_0x202d48['id'],'interface':_['isNil'](_0x37254a[_0x83b7('0x74')])?util[_0x83b7('0x75')](_0x83b7('0x76'),_0x37254a[_0x83b7('0x2c')]):_0x37254a['interface'],'paused':_0x37254a[_0x83b7('0x77')]||![],'penalty':0x0});});});}});});})[_0x83b7('0x26')](function(){return _0x17fbe1;});})['then'](function(){return _0x17fbe1;});}})[_0x83b7('0x26')](function(_0x15f398){if(_0x15f398){return _0x15f398[_0x83b7('0x67')](_0x20c6fc['body'][_0x83b7('0x63')],_[_0x83b7('0x78')](_0x20c6fc['body'],[_0x83b7('0x63'),'id'])||{})[_0x83b7('0x79')](function(_0x4088ad){for(var _0x4628be=0x0;_0x4628be<_0x20c6fc[_0x83b7('0x4e')][_0x83b7('0x63')][_0x83b7('0x3a')];_0x4628be+=0x1){socket[_0x83b7('0x7a')](_0x83b7('0x7b'),{'UserId':_0x20c6fc[_0x83b7('0x4e')][_0x83b7('0x63')][_0x4628be],'TeamId':_0x20c6fc[_0x83b7('0x49')]['id']});}return _0x4088ad;});}})[_0x83b7('0x26')](respondWithResult(_0x32de98,null))[_0x83b7('0x4c')](handleError(_0x32de98,null));};exports[_0x83b7('0x7c')]=function(_0x188d26,_0x4c3c5b,_0x44420c){return db['Team'][_0x83b7('0x4b')]({'where':{'id':_0x188d26[_0x83b7('0x49')]['id']}})[_0x83b7('0x26')](handleEntityNotFound(_0x4c3c5b,null))['then'](function(_0x524bcf){if(_0x524bcf){return BPromise[_0x83b7('0x6f')]([_0x83b7('0x7d'),_0x83b7('0x7e'),_0x83b7('0x7f'),'sms',_0x83b7('0x80'),'openchannel',_0x83b7('0x81')],function(_0x296b1c){return _0x524bcf[_0x83b7('0x27')+_[_0x83b7('0x5c')](_0x296b1c)+_0x83b7('0x5f')]({'attributes':['id',_0x83b7('0x2c')]})[_0x83b7('0x26')](function(_0x84d724){return BPromise[_0x83b7('0x6f')](_0x84d724,function(_0x2e9f6b){return _0x2e9f6b[_0x83b7('0x7c')](_0x188d26[_0x83b7('0x33')][_0x83b7('0x63')])[_0x83b7('0x26')](function(){if(_0x296b1c===_0x83b7('0x7d')){return db[_0x83b7('0x72')][_0x83b7('0x57')]({'where':{'VoiceQueueId':_0x2e9f6b['id'],'UserId':_0x188d26[_0x83b7('0x33')][_0x83b7('0x63')]}});}});});})[_0x83b7('0x26')](function(){return _0x524bcf;});})[_0x83b7('0x26')](function(){return _0x524bcf;});}})[_0x83b7('0x26')](function(_0x3c3683){if(_0x3c3683){return _0x3c3683[_0x83b7('0x7c')](_0x188d26[_0x83b7('0x33')][_0x83b7('0x63')])['then'](function(){if(_['isArray'](_0x188d26[_0x83b7('0x33')]['ids'])){for(var _0x5d7115=0x0;_0x5d7115<_0x188d26['query']['ids'][_0x83b7('0x3a')];_0x5d7115+=0x1){socket['emit'](_0x83b7('0x82'),{'UserId':Number(_0x188d26[_0x83b7('0x33')][_0x83b7('0x63')][_0x5d7115]),'TeamId':Number(_0x188d26[_0x83b7('0x49')]['id'])});}}else{socket['emit']('userTeam:remove',{'UserId':Number(_0x188d26[_0x83b7('0x33')][_0x83b7('0x63')]),'TeamId':Number(_0x188d26[_0x83b7('0x49')]['id'])});}});}})[_0x83b7('0x26')](respondWithStatusCode(_0x4c3c5b,null))[_0x83b7('0x4c')](handleError(_0x4c3c5b,null));};exports[_0x83b7('0x83')]=function(_0x2c0126,_0x3b8a62,_0x57e410){var _0x54a03b={};var _0x20d1f8={};var _0x1580a8;var _0x273008;return db['Team'][_0x83b7('0x59')]({'where':{'id':_0x2c0126[_0x83b7('0x49')]['id']}})[_0x83b7('0x26')](handleEntityNotFound(_0x3b8a62,null))[_0x83b7('0x26')](function(_0x1710d3){if(_0x1710d3){_0x1580a8=_0x1710d3;_0x20d1f8[_0x83b7('0x37')]=_[_0x83b7('0x34')](db[_0x83b7('0x70')]['rawAttributes']);_0x20d1f8[_0x83b7('0x33')]=_[_0x83b7('0x34')](_0x2c0126[_0x83b7('0x33')]);_0x20d1f8[_0x83b7('0x35')]=_[_0x83b7('0x36')](_0x20d1f8[_0x83b7('0x37')],_0x20d1f8[_0x83b7('0x33')]);_0x54a03b[_0x83b7('0x39')]=_[_0x83b7('0x36')](_0x20d1f8[_0x83b7('0x37')],qs[_0x83b7('0x38')](_0x2c0126[_0x83b7('0x33')][_0x83b7('0x38')]));_0x54a03b[_0x83b7('0x39')]=_0x54a03b[_0x83b7('0x39')]['length']?_0x54a03b['attributes']:_0x20d1f8[_0x83b7('0x37')];_0x54a03b[_0x83b7('0x3d')]=qs['sort'](_0x2c0126[_0x83b7('0x33')][_0x83b7('0x3e')]);_0x54a03b['where']=qs[_0x83b7('0x35')](_[_0x83b7('0x40')](_0x2c0126[_0x83b7('0x33')],_0x20d1f8[_0x83b7('0x35')]));if(_0x2c0126[_0x83b7('0x33')][_0x83b7('0x41')]){_0x54a03b['where']=_[_0x83b7('0x42')](_0x54a03b[_0x83b7('0x3f')],{'$or':_[_0x83b7('0x32')](_0x54a03b[_0x83b7('0x39')],function(_0x194542){var _0x5e91f3={};_0x5e91f3[_0x194542]={'$like':'%'+_0x2c0126[_0x83b7('0x33')][_0x83b7('0x41')]+'%'};return _0x5e91f3;})});}_0x54a03b=_[_0x83b7('0x42')]({},_0x54a03b,_0x2c0126[_0x83b7('0x44')]);return _0x1580a8[_0x83b7('0x83')](_0x54a03b);}})['then'](function(_0x217a42){if(_0x217a42){_0x273008=_0x217a42[_0x83b7('0x3a')];if(!_0x2c0126[_0x83b7('0x33')][_0x83b7('0x3b')](_0x83b7('0x3c'))){_0x54a03b[_0x83b7('0x22')]=qs[_0x83b7('0x22')](_0x2c0126[_0x83b7('0x33')]['limit']);_0x54a03b[_0x83b7('0x21')]=qs[_0x83b7('0x21')](_0x2c0126['query'][_0x83b7('0x21')]);}return _0x1580a8[_0x83b7('0x83')](_0x54a03b);}})[_0x83b7('0x26')](function(_0x2bfeb6){if(_0x2bfeb6){return _0x2bfeb6?{'count':_0x273008,'rows':_0x2bfeb6}:null;}})['then'](respondWithResult(_0x3b8a62,null))[_0x83b7('0x4c')](handleError(_0x3b8a62,null));};
\ No newline at end of file