Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index 2080171..f4b6db5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd1d9=['join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','value','transaction','isEmpty','userOpenchannelQueue:remove','omit','userOpenchannelQueue:save','removeAgents','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','register','sendStatus','end','status','count','offset','set','Content-Range','json','apply','reject','save','update','destroy','then','get','UserProfileResource','error','send','index','rawAttributes','type','key','map','name','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','OpenchannelQueue','includeAll','include','show','params','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','OpenchannelQueues','UserProfileSection','userProfileId','autoAssociation','describe','findOne','UserOpenchannelQueue','User','findAndCountAll','UserId','agent','openchannelPause','updatedAt','createdAt','%s/%s','SIP','getTeams','Team','ids','online','voicePause','interface','flatMap','Agents','sequelize','addTeams','each','findOrCreate','forEach','emit','removeTeams','findAll','select','field','tq.TeamId','from','team_has_openchannel_queues'];(function(_0x211b15,_0x55ab8d){var _0x21db94=function(_0x12f6d8){while(--_0x12f6d8){_0x211b15['push'](_0x211b15['shift']());}};_0x21db94(++_0x55ab8d);}(_0xd1d9,0x1bf));var _0x9d1d=function(_0x80f271,_0xb83b94){_0x80f271=_0x80f271-0x0;var _0x11d8f3=_0xd1d9[_0x80f271];return _0x11d8f3;};'use strict';var pdf=require(_0x9d1d('0x0'));var emlformat=require(_0x9d1d('0x1'));var rimraf=require(_0x9d1d('0x2'));var zipdir=require(_0x9d1d('0x3'));var jsonpatch=require(_0x9d1d('0x4'));var rp=require(_0x9d1d('0x5'));var moment=require(_0x9d1d('0x6'));var BPromise=require(_0x9d1d('0x7'));var Mustache=require(_0x9d1d('0x8'));var util=require('util');var path=require(_0x9d1d('0x9'));var sox=require(_0x9d1d('0xa'));var csv=require(_0x9d1d('0xb'));var ejs=require(_0x9d1d('0xc'));var fs=require('fs');var _=require(_0x9d1d('0xd'));var squel=require(_0x9d1d('0xe'));var crypto=require(_0x9d1d('0xf'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x9d1d('0xb'));var querystring=require(_0x9d1d('0x10'));var Papa=require(_0x9d1d('0x11'));var Redis=require('ioredis');var authService=require(_0x9d1d('0x12'));var qs=require(_0x9d1d('0x13'));var as=require(_0x9d1d('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x9d1d('0x15'));var config=require(_0x9d1d('0x16'));var licenseUtil=require(_0x9d1d('0x17'));var db=require(_0x9d1d('0x18'))['db'];config[_0x9d1d('0x19')]=_[_0x9d1d('0x1a')](config[_0x9d1d('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x9d1d('0x1b'))(new Redis(config[_0x9d1d('0x19')]));require('./openchannelQueue.socket')[_0x9d1d('0x1c')](socket);function respondWithStatusCode(_0x4a409f,_0x59fba9){_0x59fba9=_0x59fba9||0xcc;return function(_0x5b0bf2){if(_0x5b0bf2){return _0x4a409f[_0x9d1d('0x1d')](_0x59fba9);}return _0x4a409f['status'](_0x59fba9)[_0x9d1d('0x1e')]();};}function respondWithResult(_0x2da2f4,_0x4eb8f8){_0x4eb8f8=_0x4eb8f8||0xc8;return function(_0x1683d2){if(_0x1683d2){return _0x2da2f4[_0x9d1d('0x1f')](_0x4eb8f8)['json'](_0x1683d2);}};}function respondWithFilteredResult(_0x1b52ee,_0x269340){return function(_0x32b93c){if(_0x32b93c){var _0xd688be=_0x32b93c[_0x9d1d('0x20')],_0x4bad7d=_0x269340['offset'],_0x3d4895=_0x269340[_0x9d1d('0x21')]+_0x269340['limit'],_0xeb9fbf;if(_0x3d4895>=_0xd688be){_0x3d4895=_0xd688be;_0xeb9fbf=0xc8;}else{_0xeb9fbf=0xce;}_0x1b52ee['status'](_0xeb9fbf);return _0x1b52ee[_0x9d1d('0x22')](_0x9d1d('0x23'),_0x4bad7d+'-'+_0x3d4895+'/'+_0xd688be)[_0x9d1d('0x24')](_0x32b93c);}return null;};}function patchUpdates(_0x481495){return function(_0x3d55c5){try{jsonpatch[_0x9d1d('0x25')](_0x3d55c5,_0x481495,!![]);}catch(_0x29a5ae){return BPromise[_0x9d1d('0x26')](_0x29a5ae);}return _0x3d55c5[_0x9d1d('0x27')]();};}function saveUpdates(_0x2be148,_0x2249f9){return function(_0x4ead20){if(_0x4ead20){return _0x4ead20[_0x9d1d('0x28')](_0x2be148)['then'](function(_0x184363){return _0x184363;});}return null;};}function removeEntity(_0x540481,_0x283fa0){return function(_0x54eb36){if(_0x54eb36){return _0x54eb36[_0x9d1d('0x29')]()[_0x9d1d('0x2a')](function(){var _0x37d56a=_0x54eb36[_0x9d1d('0x2b')]({'plain':!![]});var _0x31679e='OpenchannelQueues';return db[_0x9d1d('0x2c')][_0x9d1d('0x29')]({'where':{'type':_0x31679e,'resourceId':_0x37d56a['id']}})[_0x9d1d('0x2a')](function(){return _0x54eb36;});})['then'](function(){_0x540481[_0x9d1d('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x374edb,_0x487f62){return function(_0x237dd3){if(!_0x237dd3){_0x374edb[_0x9d1d('0x1d')](0x194);}return _0x237dd3;};}function handleError(_0x8f467f,_0x2d0962){_0x2d0962=_0x2d0962||0x1f4;return function(_0x511e4a){logger[_0x9d1d('0x2d')](_0x511e4a['stack']);if(_0x511e4a['name']){delete _0x511e4a['name'];}_0x8f467f['status'](_0x2d0962)[_0x9d1d('0x2e')](_0x511e4a);};}exports[_0x9d1d('0x2f')]=function(_0x21183b,_0x32b560){var _0x3d8378={},_0x161bea={},_0x8aad8={'count':0x0,'rows':[]};var _0xa0cfe0=_['map'](db['OpenchannelQueue'][_0x9d1d('0x30')],function(_0xb977ea){return{'name':_0xb977ea['fieldName'],'type':_0xb977ea[_0x9d1d('0x31')][_0x9d1d('0x32')]};});_0x161bea['model']=_[_0x9d1d('0x33')](_0xa0cfe0,_0x9d1d('0x34'));_0x161bea[_0x9d1d('0x35')]=_[_0x9d1d('0x36')](_0x21183b[_0x9d1d('0x35')]);_0x161bea[_0x9d1d('0x37')]=_[_0x9d1d('0x38')](_0x161bea[_0x9d1d('0x39')],_0x161bea[_0x9d1d('0x35')]);_0x3d8378['attributes']=_[_0x9d1d('0x38')](_0x161bea[_0x9d1d('0x39')],qs[_0x9d1d('0x3a')](_0x21183b[_0x9d1d('0x35')][_0x9d1d('0x3a')]));_0x3d8378[_0x9d1d('0x3b')]=_0x3d8378[_0x9d1d('0x3b')][_0x9d1d('0x3c')]?_0x3d8378[_0x9d1d('0x3b')]:_0x161bea['model'];if(!_0x21183b[_0x9d1d('0x35')][_0x9d1d('0x3d')](_0x9d1d('0x3e'))){_0x3d8378[_0x9d1d('0x3f')]=qs[_0x9d1d('0x3f')](_0x21183b[_0x9d1d('0x35')][_0x9d1d('0x3f')]);_0x3d8378['offset']=qs[_0x9d1d('0x21')](_0x21183b['query'][_0x9d1d('0x21')]);}_0x3d8378[_0x9d1d('0x40')]=qs[_0x9d1d('0x41')](_0x21183b[_0x9d1d('0x35')][_0x9d1d('0x41')]);_0x3d8378[_0x9d1d('0x42')]=qs[_0x9d1d('0x37')](_[_0x9d1d('0x43')](_0x21183b[_0x9d1d('0x35')],_0x161bea['filters']),_0xa0cfe0);if(_0x21183b[_0x9d1d('0x35')][_0x9d1d('0x44')]){_0x3d8378['where']=_[_0x9d1d('0x45')](_0x3d8378[_0x9d1d('0x42')],{'$or':_[_0x9d1d('0x33')](_0xa0cfe0,function(_0x1c4779){if(_0x1c4779[_0x9d1d('0x31')]!==_0x9d1d('0x46')){var _0x51ff61={};_0x51ff61[_0x1c4779['name']]={'$like':'%'+_0x21183b[_0x9d1d('0x35')]['filter']+'%'};return _0x51ff61;}})});}_0x3d8378=_['merge']({},_0x3d8378,_0x21183b[_0x9d1d('0x47')]);var _0x4c9985={'where':_0x3d8378[_0x9d1d('0x42')]};return db[_0x9d1d('0x48')][_0x9d1d('0x20')](_0x4c9985)['then'](function(_0x1bfbfc){_0x8aad8['count']=_0x1bfbfc;if(_0x21183b[_0x9d1d('0x35')][_0x9d1d('0x49')]){_0x3d8378[_0x9d1d('0x4a')]=[{'all':!![]}];}return db[_0x9d1d('0x48')]['findAll'](_0x3d8378);})[_0x9d1d('0x2a')](function(_0x3f6383){_0x8aad8['rows']=_0x3f6383;return _0x8aad8;})[_0x9d1d('0x2a')](respondWithFilteredResult(_0x32b560,_0x3d8378))['catch'](handleError(_0x32b560,null));};exports[_0x9d1d('0x4b')]=function(_0x4766dd,_0x2d4121){var _0x11b71f={'raw':!![],'where':{'id':_0x4766dd[_0x9d1d('0x4c')]['id']}},_0x8933dd={};_0x8933dd[_0x9d1d('0x39')]=_['keys'](db[_0x9d1d('0x48')][_0x9d1d('0x30')]);_0x8933dd[_0x9d1d('0x35')]=_[_0x9d1d('0x36')](_0x4766dd[_0x9d1d('0x35')]);_0x8933dd[_0x9d1d('0x37')]=_[_0x9d1d('0x38')](_0x8933dd[_0x9d1d('0x39')],_0x8933dd[_0x9d1d('0x35')]);_0x11b71f[_0x9d1d('0x3b')]=_[_0x9d1d('0x38')](_0x8933dd[_0x9d1d('0x39')],qs[_0x9d1d('0x3a')](_0x4766dd[_0x9d1d('0x35')][_0x9d1d('0x3a')]));_0x11b71f[_0x9d1d('0x3b')]=_0x11b71f[_0x9d1d('0x3b')][_0x9d1d('0x3c')]?_0x11b71f[_0x9d1d('0x3b')]:_0x8933dd['model'];if(_0x4766dd[_0x9d1d('0x35')][_0x9d1d('0x49')]){_0x11b71f['include']=[{'all':!![]}];}_0x11b71f=_[_0x9d1d('0x45')]({},_0x11b71f,_0x4766dd[_0x9d1d('0x47')]);return db[_0x9d1d('0x48')][_0x9d1d('0x4d')](_0x11b71f)[_0x9d1d('0x2a')](handleEntityNotFound(_0x2d4121,null))[_0x9d1d('0x2a')](respondWithResult(_0x2d4121,null))[_0x9d1d('0x4e')](handleError(_0x2d4121,null));};exports[_0x9d1d('0x4f')]=function(_0x599dd4,_0x5a5488){return db['OpenchannelQueue'][_0x9d1d('0x4f')](_0x599dd4[_0x9d1d('0x50')],{})[_0x9d1d('0x2a')](function(_0x213b60){var _0x1e7b07=_0x599dd4[_0x9d1d('0x51')]['get']({'plain':!![]});if(!_0x1e7b07)throw new Error(_0x9d1d('0x52'));if(_0x1e7b07[_0x9d1d('0x53')]===_0x9d1d('0x51')){var _0x5bebe0=_0x213b60[_0x9d1d('0x2b')]({'plain':!![]});var _0x3f64c7=_0x9d1d('0x54');return db[_0x9d1d('0x55')][_0x9d1d('0x4d')]({'where':{'name':_0x3f64c7,'userProfileId':_0x1e7b07[_0x9d1d('0x56')]},'raw':!![]})[_0x9d1d('0x2a')](function(_0x1ab766){if(_0x1ab766&&_0x1ab766[_0x9d1d('0x57')]===0x0){return db[_0x9d1d('0x2c')][_0x9d1d('0x4f')]({'name':_0x5bebe0[_0x9d1d('0x34')],'resourceId':_0x5bebe0['id'],'type':_0x1ab766[_0x9d1d('0x34')],'sectionId':_0x1ab766['id']},{})[_0x9d1d('0x2a')](function(){return _0x213b60;});}else{return _0x213b60;}})[_0x9d1d('0x4e')](function(_0xdb333d){logger[_0x9d1d('0x2d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xdb333d);throw _0xdb333d;});}return _0x213b60;})['then'](respondWithResult(_0x5a5488,0xc9))[_0x9d1d('0x4e')](handleError(_0x5a5488,null));};exports[_0x9d1d('0x28')]=function(_0x3e429f,_0x150aaf){if(_0x3e429f[_0x9d1d('0x50')]['id']){delete _0x3e429f['body']['id'];}return db[_0x9d1d('0x48')]['find']({'where':{'id':_0x3e429f['params']['id']}})[_0x9d1d('0x2a')](handleEntityNotFound(_0x150aaf,null))[_0x9d1d('0x2a')](saveUpdates(_0x3e429f[_0x9d1d('0x50')],null))['then'](respondWithResult(_0x150aaf,null))[_0x9d1d('0x4e')](handleError(_0x150aaf,null));};exports['destroy']=function(_0x11043c,_0x2153d5){return db[_0x9d1d('0x48')][_0x9d1d('0x4d')]({'where':{'id':_0x11043c[_0x9d1d('0x4c')]['id']}})[_0x9d1d('0x2a')](handleEntityNotFound(_0x2153d5,null))['then'](removeEntity(_0x2153d5,null))['catch'](handleError(_0x2153d5,null));};exports[_0x9d1d('0x58')]=function(_0xd84d73,_0x39d575){return db[_0x9d1d('0x48')][_0x9d1d('0x58')]()[_0x9d1d('0x2a')](respondWithResult(_0x39d575,null))[_0x9d1d('0x4e')](handleError(_0x39d575,null));};exports['getMembers']=function(_0xd7e0c1,_0x163d5e,_0x2508d8){var _0x494fa7={'raw':!![],'where':{}},_0x40b58d={},_0x383408;return db[_0x9d1d('0x48')][_0x9d1d('0x59')]({'where':{'id':_0xd7e0c1[_0x9d1d('0x4c')]['id']}})['then'](handleEntityNotFound(_0x163d5e,null))[_0x9d1d('0x2a')](function(_0x3465bb){if(_0x3465bb){_0x383408=_0x3465bb[_0x9d1d('0x2b')]({'plain':!![]});_0x40b58d[_0x9d1d('0x39')]=_['keys'](db['UserOpenchannelQueue']['rawAttributes']);_0x40b58d[_0x9d1d('0x35')]=_[_0x9d1d('0x36')](_0xd7e0c1[_0x9d1d('0x35')]);_0x40b58d[_0x9d1d('0x37')]=_['intersection'](_0x40b58d[_0x9d1d('0x39')],_0x40b58d[_0x9d1d('0x35')]);_0x494fa7[_0x9d1d('0x3b')]=_[_0x9d1d('0x38')](_0x40b58d['model'],qs['fields'](_0xd7e0c1[_0x9d1d('0x35')][_0x9d1d('0x3a')]));_0x494fa7[_0x9d1d('0x3b')]=_0x494fa7[_0x9d1d('0x3b')][_0x9d1d('0x3c')]?_0x494fa7['attributes']:_0x40b58d['model'];if(!_0xd7e0c1[_0x9d1d('0x35')]['hasOwnProperty'](_0x9d1d('0x3e'))){_0x494fa7[_0x9d1d('0x3f')]=qs[_0x9d1d('0x3f')](_0xd7e0c1[_0x9d1d('0x35')][_0x9d1d('0x3f')]);_0x494fa7[_0x9d1d('0x21')]=qs['offset'](_0xd7e0c1['query']['offset']);}_0x494fa7['order']=qs[_0x9d1d('0x41')](_0xd7e0c1[_0x9d1d('0x35')]['sort']);_0x494fa7[_0x9d1d('0x42')]=qs[_0x9d1d('0x37')](_['pick'](_0xd7e0c1['query'],_0x40b58d[_0x9d1d('0x37')]));_0x494fa7[_0x9d1d('0x42')]['OpenchannelQueueId']=_0x3465bb['id'];if(_0xd7e0c1[_0x9d1d('0x35')][_0x9d1d('0x44')]){_0x494fa7[_0x9d1d('0x42')]=_[_0x9d1d('0x45')](_0x494fa7[_0x9d1d('0x42')],{'$or':_[_0x9d1d('0x33')](_0x494fa7[_0x9d1d('0x3b')],function(_0x32c306){var _0xf1acad={};_0xf1acad[_0x32c306]={'$like':'%'+_0xd7e0c1[_0x9d1d('0x35')][_0x9d1d('0x44')]+'%'};return _0xf1acad;})});}_0x494fa7=_['merge']({},_0x494fa7,_0xd7e0c1[_0x9d1d('0x47')]);return db[_0x9d1d('0x5a')]['findAll'](_0x494fa7);}})[_0x9d1d('0x2a')](function(_0xa15e6e){if(_0xa15e6e){return db[_0x9d1d('0x5b')][_0x9d1d('0x5c')]({'where':{'id':_['map'](_0xa15e6e,_0x9d1d('0x5d')),'role':_0x9d1d('0x5e')},'attributes':['id',_0x9d1d('0x34'),_0x9d1d('0x5f'),_0x9d1d('0x60'),_0x9d1d('0x61')]});}})['then'](function(_0x5edd8a){if(_0x5edd8a){return{'count':_0x5edd8a[_0x9d1d('0x20')],'rows':_[_0x9d1d('0x33')](_0x5edd8a['rows'],function(_0x4c1365){return{'membername':_0x4c1365['name'],'UserId':_0x4c1365['id'],'queue_name':_0x383408[_0x9d1d('0x34')],'OpenchannelQueueId':_0x383408['id'],'interface':util['format'](_0x9d1d('0x62'),_0x9d1d('0x63'),_0x4c1365[_0x9d1d('0x34')]),'penalty':0x0,'paused':_0x4c1365[_0x9d1d('0x5f')],'createdAt':_0x4c1365['createdAt'],'updatedAt':_0x4c1365['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x9d1d('0x2a')](respondWithFilteredResult(_0x163d5e,_0x494fa7))[_0x9d1d('0x4e')](handleError(_0x163d5e,null));};exports[_0x9d1d('0x64')]=function(_0x1f48fe,_0x1bc85f,_0x512503){var _0x9dca75={};var _0x3e2b82={};var _0x2124f7;var _0x353303;return db[_0x9d1d('0x48')][_0x9d1d('0x59')]({'where':{'id':_0x1f48fe[_0x9d1d('0x4c')]['id']}})[_0x9d1d('0x2a')](handleEntityNotFound(_0x1bc85f,null))[_0x9d1d('0x2a')](function(_0x1585a7){if(_0x1585a7){_0x2124f7=_0x1585a7;_0x3e2b82[_0x9d1d('0x39')]=_['keys'](db[_0x9d1d('0x65')][_0x9d1d('0x30')]);_0x3e2b82[_0x9d1d('0x35')]=_[_0x9d1d('0x36')](_0x1f48fe[_0x9d1d('0x35')]);_0x3e2b82[_0x9d1d('0x37')]=_[_0x9d1d('0x38')](_0x3e2b82['model'],_0x3e2b82['query']);_0x9dca75[_0x9d1d('0x3b')]=_[_0x9d1d('0x38')](_0x3e2b82['model'],qs[_0x9d1d('0x3a')](_0x1f48fe[_0x9d1d('0x35')]['fields']));_0x9dca75[_0x9d1d('0x3b')]=_0x9dca75[_0x9d1d('0x3b')][_0x9d1d('0x3c')]?_0x9dca75[_0x9d1d('0x3b')]:_0x3e2b82[_0x9d1d('0x39')];_0x9dca75[_0x9d1d('0x40')]=qs[_0x9d1d('0x41')](_0x1f48fe[_0x9d1d('0x35')][_0x9d1d('0x41')]);_0x9dca75[_0x9d1d('0x42')]=qs[_0x9d1d('0x37')](_[_0x9d1d('0x43')](_0x1f48fe[_0x9d1d('0x35')],_0x3e2b82['filters']));if(_0x1f48fe[_0x9d1d('0x35')][_0x9d1d('0x44')]){_0x9dca75[_0x9d1d('0x42')]=_[_0x9d1d('0x45')](_0x9dca75[_0x9d1d('0x42')],{'$or':_[_0x9d1d('0x33')](_0x9dca75[_0x9d1d('0x3b')],function(_0x128f99){var _0x180188={};_0x180188[_0x128f99]={'$like':'%'+_0x1f48fe[_0x9d1d('0x35')][_0x9d1d('0x44')]+'%'};return _0x180188;})});}_0x9dca75=_[_0x9d1d('0x45')]({},_0x9dca75,_0x1f48fe[_0x9d1d('0x47')]);return _0x2124f7[_0x9d1d('0x64')](_0x9dca75);}})[_0x9d1d('0x2a')](function(_0x49bb2c){if(_0x49bb2c){_0x353303=_0x49bb2c['length'];if(!_0x1f48fe[_0x9d1d('0x35')]['hasOwnProperty'](_0x9d1d('0x3e'))){_0x9dca75[_0x9d1d('0x3f')]=qs[_0x9d1d('0x3f')](_0x1f48fe[_0x9d1d('0x35')]['limit']);_0x9dca75[_0x9d1d('0x21')]=qs[_0x9d1d('0x21')](_0x1f48fe['query'][_0x9d1d('0x21')]);}return _0x2124f7[_0x9d1d('0x64')](_0x9dca75);}})['then'](function(_0x5b1c53){if(_0x5b1c53){return _0x5b1c53?{'count':_0x353303,'rows':_0x5b1c53}:null;}})[_0x9d1d('0x2a')](respondWithResult(_0x1bc85f,null))[_0x9d1d('0x4e')](handleError(_0x1bc85f,null));};exports['addTeams']=function(_0x268803,_0x17ce7e,_0x3b2f7f){var _0xcdc8bb=_0x268803['body'][_0x9d1d('0x66')];return db[_0x9d1d('0x65')]['findAll']({'where':{'id':_0xcdc8bb},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id','name',_0x9d1d('0x67'),_0x9d1d('0x68'),_0x9d1d('0x69')],'raw':!![]}]})['then'](function(_0x336300){if(_0x336300){var _0x521a8f=_[_0x9d1d('0x6a')](_0x336300,function(_0x5db9ba){var _0x51eaae=_0x5db9ba[_0x9d1d('0x2b')]({'plain':!![]});return _0x51eaae[_0x9d1d('0x6b')];});return db[_0x9d1d('0x48')][_0x9d1d('0x4d')]({'where':{'id':_0x268803[_0x9d1d('0x4c')]['id']}})[_0x9d1d('0x2a')](function(_0x4c3cd6){return db[_0x9d1d('0x6c')]['transaction'](function(_0x44cefc){return _0x4c3cd6[_0x9d1d('0x6d')](_0xcdc8bb,{'transaction':_0x44cefc})['then'](function(){return BPromise[_0x9d1d('0x6e')](_0x521a8f,function(_0x158f17){return db[_0x9d1d('0x5a')][_0x9d1d('0x6f')]({'where':{'UserId':_0x158f17['id'],'OpenchannelQueueId':_0x268803[_0x9d1d('0x4c')]['id']},'transaction':_0x44cefc});});})[_0x9d1d('0x2a')](function(){_0x521a8f[_0x9d1d('0x70')](function(_0x268b0f){socket[_0x9d1d('0x71')]('userOpenchannelQueue:save',{'UserId':_0x268b0f['id'],'OpenchannelQueueId':_0x4c3cd6['id']});});});});});}})[_0x9d1d('0x2a')](respondWithStatusCode(_0x17ce7e,null))['catch'](handleError(_0x17ce7e,null));};exports[_0x9d1d('0x72')]=function(_0x5db944,_0x36285a,_0x472f3d){return db[_0x9d1d('0x65')][_0x9d1d('0x73')]({'where':{'id':_0x5db944[_0x9d1d('0x35')]['ids']},'attributes':['id'],'include':[{'model':db[_0x9d1d('0x5b')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x9d1d('0x2a')](handleEntityNotFound(_0x36285a,null))[_0x9d1d('0x2a')](function(_0x11e863){var _0x1bf281=_[_0x9d1d('0x33')](_0x11e863,'id');var _0x1a3a02=[];var _0x34a6c7=[];var _0xf0ba34=squel[_0x9d1d('0x74')]();_0xf0ba34[_0x9d1d('0x75')](_0x9d1d('0x76'))[_0x9d1d('0x77')](_0x9d1d('0x78'),'tq')[_0x9d1d('0x79')](_0x9d1d('0x7a'),'ut',_0x9d1d('0x7b'))[_0x9d1d('0x42')]('OpenchannelQueueId\x20=\x20?',_0x5db944[_0x9d1d('0x4c')]['id']);for(var _0x450892=0x0;_0x450892<_0x11e863[_0x9d1d('0x3c')];_0x450892+=0x1){let _0x17ac14=_0x11e863[_0x450892];for(var _0xd0e86a=0x0;_0xd0e86a<_0x17ac14[_0x9d1d('0x6b')][_0x9d1d('0x3c')];_0xd0e86a+=0x1){let _0x43d0e0=_0x17ac14[_0x9d1d('0x6b')][_0xd0e86a];var _0x563b43=_0xf0ba34[_0x9d1d('0x7c')]();_0x563b43[_0x9d1d('0x42')]('ut.UserId\x20=\x20?',_0x43d0e0['id']);_0x34a6c7[_0x9d1d('0x7d')](db['sequelize'][_0x9d1d('0x35')](_0x563b43[_0x9d1d('0x7e')](),{'type':db[_0x9d1d('0x6c')][_0x9d1d('0x7f')][_0x9d1d('0x80')]})[_0x9d1d('0x2a')](function(_0x50c6a6){if(_0x50c6a6['length']===0x1){return _0x43d0e0['id'];}else{var _0x3f1d9c=_[_0x9d1d('0x81')](_[_0x9d1d('0x33')](_0x50c6a6,_0x9d1d('0x82')),function(_0x2c10cb){return _[_0x9d1d('0x83')](_0x1bf281,_0x2c10cb);});if(_0x3f1d9c){return _0x43d0e0['id'];}}}));}}return BPromise[_0x9d1d('0x84')](_0x34a6c7)[_0x9d1d('0x2a')](function(_0x3fb488){_0x1a3a02=_(_0x1a3a02)['union'](_0x3fb488)['compact']()[_0x9d1d('0x85')]();return db[_0x9d1d('0x48')][_0x9d1d('0x4d')]({'where':{'id':_0x5db944[_0x9d1d('0x4c')]['id']}})[_0x9d1d('0x2a')](function(_0x301e0d){return db[_0x9d1d('0x6c')][_0x9d1d('0x86')](function(_0x1c7ff0){return _0x301e0d[_0x9d1d('0x72')](_0x5db944[_0x9d1d('0x35')][_0x9d1d('0x66')],{'transaction':_0x1c7ff0})['then'](function(){if(!_[_0x9d1d('0x87')](_0x1a3a02)){return _0x301e0d['removeAgents'](_0x1a3a02,{'transaction':_0x1c7ff0});}})[_0x9d1d('0x2a')](function(){_0x1a3a02[_0x9d1d('0x70')](function(_0x2c967b){socket[_0x9d1d('0x71')](_0x9d1d('0x88'),{'UserId':_0x2c967b,'OpenchannelQueueId':_0x301e0d['id']});});});});});});})['then'](respondWithStatusCode(_0x36285a,null))['catch'](handleError(_0x36285a,null));};exports['addAgents']=function(_0x577896,_0x58885a,_0x2140e8){return db['OpenchannelQueue'][_0x9d1d('0x4d')]({'where':{'id':_0x577896[_0x9d1d('0x4c')]['id']}})['then'](handleEntityNotFound(_0x58885a,null))[_0x9d1d('0x2a')](function(_0x66f23f){if(_0x66f23f){return _0x66f23f['addAgents'](_0x577896[_0x9d1d('0x50')][_0x9d1d('0x66')],_[_0x9d1d('0x89')](_0x577896[_0x9d1d('0x50')],[_0x9d1d('0x66'),'id'])||{})['spread'](function(_0x4ee2c8){for(var _0x1074dd=0x0;_0x1074dd<_0x577896[_0x9d1d('0x50')][_0x9d1d('0x66')][_0x9d1d('0x3c')];_0x1074dd+=0x1){socket[_0x9d1d('0x71')](_0x9d1d('0x8a'),{'UserId':_0x577896[_0x9d1d('0x50')][_0x9d1d('0x66')][_0x1074dd],'OpenchannelQueueId':_0x577896[_0x9d1d('0x4c')]['id']});}return _0x4ee2c8;});}})[_0x9d1d('0x2a')](respondWithResult(_0x58885a,null))[_0x9d1d('0x4e')](handleError(_0x58885a,null));};exports[_0x9d1d('0x8b')]=function(_0x11ec46,_0x57351a,_0x1c3be4){return db['OpenchannelQueue'][_0x9d1d('0x4d')]({'where':{'id':_0x11ec46[_0x9d1d('0x4c')]['id']}})['then'](handleEntityNotFound(_0x57351a,null))[_0x9d1d('0x2a')](function(_0x5e06c1){if(_0x5e06c1){return _0x5e06c1['removeAgents'](_0x11ec46[_0x9d1d('0x35')][_0x9d1d('0x66')])['then'](function(){if(_[_0x9d1d('0x8c')](_0x11ec46[_0x9d1d('0x35')][_0x9d1d('0x66')])){for(var _0x385df2=0x0;_0x385df2<_0x11ec46[_0x9d1d('0x35')][_0x9d1d('0x66')][_0x9d1d('0x3c')];_0x385df2+=0x1){socket['emit']('userOpenchannelQueue:remove',{'UserId':Number(_0x11ec46[_0x9d1d('0x35')][_0x9d1d('0x66')][_0x385df2]),'OpenchannelQueueId':Number(_0x11ec46[_0x9d1d('0x4c')]['id'])});}}else{socket[_0x9d1d('0x71')](_0x9d1d('0x88'),{'UserId':Number(_0x11ec46[_0x9d1d('0x35')][_0x9d1d('0x66')]),'OpenchannelQueueId':Number(_0x11ec46['params']['id'])});}});}})[_0x9d1d('0x2a')](respondWithStatusCode(_0x57351a,null))[_0x9d1d('0x4e')](handleError(_0x57351a,null));};exports['getAgents']=function(_0x28039c,_0x4b9f60,_0x506f74){var _0x5d0b1d={};var _0x45c212={};var _0x1c6842;var _0x22ba5d;return db[_0x9d1d('0x48')][_0x9d1d('0x59')]({'where':{'id':_0x28039c[_0x9d1d('0x4c')]['id']}})[_0x9d1d('0x2a')](handleEntityNotFound(_0x4b9f60,null))['then'](function(_0x16d027){if(_0x16d027){_0x1c6842=_0x16d027;_0x45c212['model']=_[_0x9d1d('0x36')](db['User']['rawAttributes']);_0x45c212[_0x9d1d('0x35')]=_[_0x9d1d('0x36')](_0x28039c[_0x9d1d('0x35')]);_0x45c212[_0x9d1d('0x37')]=_[_0x9d1d('0x38')](_0x45c212[_0x9d1d('0x39')],_0x45c212[_0x9d1d('0x35')]);_0x5d0b1d['attributes']=_['intersection'](_0x45c212[_0x9d1d('0x39')],qs[_0x9d1d('0x3a')](_0x28039c['query'][_0x9d1d('0x3a')]));_0x5d0b1d[_0x9d1d('0x3b')]=_0x5d0b1d['attributes'][_0x9d1d('0x3c')]?_0x5d0b1d[_0x9d1d('0x3b')]:_0x45c212[_0x9d1d('0x39')];_0x5d0b1d[_0x9d1d('0x40')]=qs[_0x9d1d('0x41')](_0x28039c[_0x9d1d('0x35')]['sort']);_0x5d0b1d[_0x9d1d('0x42')]=qs['filters'](_[_0x9d1d('0x43')](_0x28039c[_0x9d1d('0x35')],_0x45c212['filters']));if(_0x28039c[_0x9d1d('0x35')][_0x9d1d('0x44')]){_0x5d0b1d[_0x9d1d('0x42')]=_[_0x9d1d('0x45')](_0x5d0b1d[_0x9d1d('0x42')],{'$or':_[_0x9d1d('0x33')](_0x5d0b1d['attributes'],function(_0x545132){var _0x34a3ed={};_0x34a3ed[_0x545132]={'$like':'%'+_0x28039c[_0x9d1d('0x35')][_0x9d1d('0x44')]+'%'};return _0x34a3ed;})});}_0x5d0b1d=_[_0x9d1d('0x45')]({},_0x5d0b1d,_0x28039c[_0x9d1d('0x47')]);return _0x1c6842[_0x9d1d('0x8d')](_0x5d0b1d);}})[_0x9d1d('0x2a')](function(_0x5badcc){if(_0x5badcc){_0x22ba5d=_0x5badcc[_0x9d1d('0x3c')];if(!_0x28039c[_0x9d1d('0x35')][_0x9d1d('0x3d')]('nolimit')){_0x5d0b1d[_0x9d1d('0x3f')]=qs[_0x9d1d('0x3f')](_0x28039c[_0x9d1d('0x35')][_0x9d1d('0x3f')]);_0x5d0b1d['offset']=qs[_0x9d1d('0x21')](_0x28039c[_0x9d1d('0x35')]['offset']);}return _0x1c6842['getAgents'](_0x5d0b1d);}})[_0x9d1d('0x2a')](function(_0xc48452){if(_0xc48452){return _0xc48452?{'count':_0x22ba5d,'rows':_0xc48452}:null;}})[_0x9d1d('0x2a')](respondWithResult(_0x4b9f60,null))['catch'](handleError(_0x4b9f60,null));};
\ No newline at end of file
+var _0xacfb=['lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','status','json','undefined','count','offset','limit','Content-Range','reject','update','then','destroy','get','OpenchannelQueues','UserProfileResource','end','sendStatus','error','stack','name','send','map','OpenchannelQueue','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','sort','where','pick','merge','VIRTUAL','filter','options','findAll','rows','catch','show','params','length','includeAll','include','find','create','user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','findOne','UserOpenchannelQueue','order','OpenchannelQueueId','User','findAndCountAll','UserId','agent','updatedAt','createdAt','SIP','openchannelPause','getTeams','Team','addTeams','Agents','online','voicePause','flatMap','sequelize','transaction','each','findOrCreate','forEach','userOpenchannelQueue:save','removeTeams','ids','field','tq.TeamId','from','team_has_openchannel_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','push','QueryTypes','SELECT','TeamId','includes','all','union','value','isEmpty','removeAgents','userOpenchannelQueue:remove','addAgents','spread','emit','isArray','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra'];(function(_0x395bfe,_0x4db521){var _0x35c81c=function(_0x484a1b){while(--_0x484a1b){_0x395bfe['push'](_0x395bfe['shift']());}};_0x35c81c(++_0x4db521);}(_0xacfb,0x7f));var _0xbacf=function(_0x523651,_0x405839){_0x523651=_0x523651-0x0;var _0x2879c0=_0xacfb[_0x523651];return _0x2879c0;};'use strict';var emlformat=require(_0xbacf('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbacf('0x1'));var jsonpatch=require(_0xbacf('0x2'));var rp=require(_0xbacf('0x3'));var moment=require(_0xbacf('0x4'));var BPromise=require(_0xbacf('0x5'));var Mustache=require(_0xbacf('0x6'));var util=require(_0xbacf('0x7'));var path=require(_0xbacf('0x8'));var sox=require('sox');var csv=require(_0xbacf('0x9'));var ejs=require(_0xbacf('0xa'));var fs=require('fs');var fs_extra=require(_0xbacf('0xb'));var _=require(_0xbacf('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xbacf('0xd'));var deskjs=require(_0xbacf('0xe'));var toCsv=require(_0xbacf('0x9'));var querystring=require(_0xbacf('0xf'));var Papa=require(_0xbacf('0x10'));var Redis=require(_0xbacf('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xbacf('0x12'));var as=require(_0xbacf('0x13'));var hardwareService=require(_0xbacf('0x14'));var logger=require(_0xbacf('0x15'))(_0xbacf('0x16'));var utils=require(_0xbacf('0x17'));var config=require(_0xbacf('0x18'));var licenseUtil=require(_0xbacf('0x19'));var db=require(_0xbacf('0x1a'))['db'];config['redis']=_[_0xbacf('0x1b')](config[_0xbacf('0x1c')],{'host':_0xbacf('0x1d'),'port':0x18eb});var socket=require(_0xbacf('0x1e'))(new Redis(config['redis']));require('./openchannelQueue.socket')['register'](socket);function respondWithStatusCode(_0x39bd2d,_0x3724e2){_0x3724e2=_0x3724e2||0xcc;return function(_0x572940){if(_0x572940){return _0x39bd2d['sendStatus'](_0x3724e2);}return _0x39bd2d[_0xbacf('0x1f')](_0x3724e2)['end']();};}function respondWithResult(_0x130b54,_0x579a84){_0x579a84=_0x579a84||0xc8;return function(_0x5072a4){if(_0x5072a4){return _0x130b54[_0xbacf('0x1f')](_0x579a84)[_0xbacf('0x20')](_0x5072a4);}};}function respondWithFilteredResult(_0x7b2f01,_0x161d82){return function(_0x5141ea){if(_0x5141ea){var _0x58712f=typeof _0x161d82['offset']===_0xbacf('0x21')&&typeof _0x161d82['limit']===_0xbacf('0x21');var _0xa9b804=_0x5141ea[_0xbacf('0x22')];var _0x2a2ea9=_0x58712f?0x0:_0x161d82[_0xbacf('0x23')];var _0x3922b5=_0x58712f?_0x5141ea[_0xbacf('0x22')]:_0x161d82[_0xbacf('0x23')]+_0x161d82[_0xbacf('0x24')];var _0xaf6d59;if(_0x3922b5>=_0xa9b804){_0x3922b5=_0xa9b804;_0xaf6d59=0xc8;}else{_0xaf6d59=0xce;}_0x7b2f01[_0xbacf('0x1f')](_0xaf6d59);return _0x7b2f01['set'](_0xbacf('0x25'),_0x2a2ea9+'-'+_0x3922b5+'/'+_0xa9b804)[_0xbacf('0x20')](_0x5141ea);}return null;};}function patchUpdates(_0x14cd89){return function(_0x157a46){try{jsonpatch['apply'](_0x157a46,_0x14cd89,!![]);}catch(_0x42caac){return BPromise[_0xbacf('0x26')](_0x42caac);}return _0x157a46['save']();};}function saveUpdates(_0x559f2a,_0x4f78f9){return function(_0x440a1e){if(_0x440a1e){return _0x440a1e[_0xbacf('0x27')](_0x559f2a)[_0xbacf('0x28')](function(_0x21d1fc){return _0x21d1fc;});}return null;};}function removeEntity(_0x12ecd1,_0x1f073b){return function(_0x36bce2){if(_0x36bce2){return _0x36bce2[_0xbacf('0x29')]()[_0xbacf('0x28')](function(){var _0x2c415c=_0x36bce2[_0xbacf('0x2a')]({'plain':!![]});var _0x4ca6b4=_0xbacf('0x2b');return db[_0xbacf('0x2c')][_0xbacf('0x29')]({'where':{'type':_0x4ca6b4,'resourceId':_0x2c415c['id']}})[_0xbacf('0x28')](function(){return _0x36bce2;});})[_0xbacf('0x28')](function(){_0x12ecd1[_0xbacf('0x1f')](0xcc)[_0xbacf('0x2d')]();});}};}function handleEntityNotFound(_0x1359e0,_0x30bde2){return function(_0x499b6c){if(!_0x499b6c){_0x1359e0[_0xbacf('0x2e')](0x194);}return _0x499b6c;};}function handleError(_0x1ae953,_0x16952f){_0x16952f=_0x16952f||0x1f4;return function(_0x5d6157){logger[_0xbacf('0x2f')](_0x5d6157[_0xbacf('0x30')]);if(_0x5d6157[_0xbacf('0x31')]){delete _0x5d6157[_0xbacf('0x31')];}_0x1ae953['status'](_0x16952f)[_0xbacf('0x32')](_0x5d6157);};}exports['index']=function(_0x54b883,_0x54d10a){var _0x33d9f6={},_0x530e22={},_0x21757d={'count':0x0,'rows':[]};var _0x113d28=_[_0xbacf('0x33')](db[_0xbacf('0x34')][_0xbacf('0x35')],function(_0x245f6c){return{'name':_0x245f6c[_0xbacf('0x36')],'type':_0x245f6c[_0xbacf('0x37')][_0xbacf('0x38')]};});_0x530e22[_0xbacf('0x39')]=_[_0xbacf('0x33')](_0x113d28,_0xbacf('0x31'));_0x530e22[_0xbacf('0x3a')]=_[_0xbacf('0x3b')](_0x54b883['query']);_0x530e22[_0xbacf('0x3c')]=_['intersection'](_0x530e22[_0xbacf('0x39')],_0x530e22[_0xbacf('0x3a')]);_0x33d9f6[_0xbacf('0x3d')]=_[_0xbacf('0x3e')](_0x530e22['model'],qs[_0xbacf('0x3f')](_0x54b883[_0xbacf('0x3a')]['fields']));_0x33d9f6[_0xbacf('0x3d')]=_0x33d9f6[_0xbacf('0x3d')]['length']?_0x33d9f6[_0xbacf('0x3d')]:_0x530e22[_0xbacf('0x39')];if(!_0x54b883[_0xbacf('0x3a')][_0xbacf('0x40')](_0xbacf('0x41'))){_0x33d9f6[_0xbacf('0x24')]=qs['limit'](_0x54b883[_0xbacf('0x3a')][_0xbacf('0x24')]);_0x33d9f6[_0xbacf('0x23')]=qs[_0xbacf('0x23')](_0x54b883[_0xbacf('0x3a')][_0xbacf('0x23')]);}_0x33d9f6['order']=qs[_0xbacf('0x42')](_0x54b883['query'][_0xbacf('0x42')]);_0x33d9f6[_0xbacf('0x43')]=qs[_0xbacf('0x3c')](_[_0xbacf('0x44')](_0x54b883[_0xbacf('0x3a')],_0x530e22[_0xbacf('0x3c')]),_0x113d28);if(_0x54b883[_0xbacf('0x3a')]['filter']){_0x33d9f6[_0xbacf('0x43')]=_[_0xbacf('0x45')](_0x33d9f6[_0xbacf('0x43')],{'$or':_[_0xbacf('0x33')](_0x113d28,function(_0x282e20){if(_0x282e20[_0xbacf('0x37')]!==_0xbacf('0x46')){var _0x5f2654={};_0x5f2654[_0x282e20[_0xbacf('0x31')]]={'$like':'%'+_0x54b883['query'][_0xbacf('0x47')]+'%'};return _0x5f2654;}})});}_0x33d9f6=_[_0xbacf('0x45')]({},_0x33d9f6,_0x54b883[_0xbacf('0x48')]);var _0x540ded={'where':_0x33d9f6[_0xbacf('0x43')]};return db[_0xbacf('0x34')][_0xbacf('0x22')](_0x540ded)[_0xbacf('0x28')](function(_0x451191){_0x21757d[_0xbacf('0x22')]=_0x451191;if(_0x54b883[_0xbacf('0x3a')]['includeAll']){_0x33d9f6['include']=[{'all':!![]}];}return db[_0xbacf('0x34')][_0xbacf('0x49')](_0x33d9f6);})['then'](function(_0x63a8be){_0x21757d[_0xbacf('0x4a')]=_0x63a8be;return _0x21757d;})['then'](respondWithFilteredResult(_0x54d10a,_0x33d9f6))[_0xbacf('0x4b')](handleError(_0x54d10a,null));};exports[_0xbacf('0x4c')]=function(_0x4373bb,_0x400534){var _0x20d132={'raw':!![],'where':{'id':_0x4373bb[_0xbacf('0x4d')]['id']}},_0x2c610b={};_0x2c610b[_0xbacf('0x39')]=_[_0xbacf('0x3b')](db[_0xbacf('0x34')][_0xbacf('0x35')]);_0x2c610b[_0xbacf('0x3a')]=_['keys'](_0x4373bb[_0xbacf('0x3a')]);_0x2c610b[_0xbacf('0x3c')]=_[_0xbacf('0x3e')](_0x2c610b[_0xbacf('0x39')],_0x2c610b[_0xbacf('0x3a')]);_0x20d132['attributes']=_[_0xbacf('0x3e')](_0x2c610b[_0xbacf('0x39')],qs[_0xbacf('0x3f')](_0x4373bb[_0xbacf('0x3a')][_0xbacf('0x3f')]));_0x20d132[_0xbacf('0x3d')]=_0x20d132[_0xbacf('0x3d')][_0xbacf('0x4e')]?_0x20d132[_0xbacf('0x3d')]:_0x2c610b['model'];if(_0x4373bb[_0xbacf('0x3a')][_0xbacf('0x4f')]){_0x20d132[_0xbacf('0x50')]=[{'all':!![]}];}_0x20d132=_[_0xbacf('0x45')]({},_0x20d132,_0x4373bb['options']);return db['OpenchannelQueue'][_0xbacf('0x51')](_0x20d132)[_0xbacf('0x28')](handleEntityNotFound(_0x400534,null))[_0xbacf('0x28')](respondWithResult(_0x400534,null))[_0xbacf('0x4b')](handleError(_0x400534,null));};exports[_0xbacf('0x52')]=function(_0x544869,_0x22b470){return db[_0xbacf('0x34')][_0xbacf('0x52')](_0x544869['body'],{})[_0xbacf('0x28')](function(_0x509a33){var _0x345223=_0x544869['user'][_0xbacf('0x2a')]({'plain':!![]});if(!_0x345223)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x345223['role']===_0xbacf('0x53')){var _0x485295=_0x509a33['get']({'plain':!![]});var _0x3029e9='OpenchannelQueues';return db[_0xbacf('0x54')][_0xbacf('0x51')]({'where':{'name':_0x3029e9,'userProfileId':_0x345223['userProfileId']},'raw':!![]})[_0xbacf('0x28')](function(_0x9370fd){if(_0x9370fd&&_0x9370fd[_0xbacf('0x55')]===0x0){return db['UserProfileResource']['create']({'name':_0x485295[_0xbacf('0x31')],'resourceId':_0x485295['id'],'type':_0x9370fd['name'],'sectionId':_0x9370fd['id']},{})['then'](function(){return _0x509a33;});}else{return _0x509a33;}})['catch'](function(_0x542e77){logger[_0xbacf('0x2f')](_0xbacf('0x56'),_0x542e77);throw _0x542e77;});}return _0x509a33;})[_0xbacf('0x28')](respondWithResult(_0x22b470,0xc9))[_0xbacf('0x4b')](handleError(_0x22b470,null));};exports[_0xbacf('0x27')]=function(_0x3621d5,_0xe0c182){if(_0x3621d5[_0xbacf('0x57')]['id']){delete _0x3621d5['body']['id'];}return db[_0xbacf('0x34')]['find']({'where':{'id':_0x3621d5['params']['id']}})[_0xbacf('0x28')](handleEntityNotFound(_0xe0c182,null))[_0xbacf('0x28')](saveUpdates(_0x3621d5[_0xbacf('0x57')],null))['then'](respondWithResult(_0xe0c182,null))[_0xbacf('0x4b')](handleError(_0xe0c182,null));};exports[_0xbacf('0x29')]=function(_0x1dbf99,_0xf26718){return db[_0xbacf('0x34')][_0xbacf('0x51')]({'where':{'id':_0x1dbf99['params']['id']}})[_0xbacf('0x28')](handleEntityNotFound(_0xf26718,null))[_0xbacf('0x28')](removeEntity(_0xf26718,null))[_0xbacf('0x4b')](handleError(_0xf26718,null));};exports[_0xbacf('0x58')]=function(_0x20b48b,_0xdbda69){return db[_0xbacf('0x34')][_0xbacf('0x58')]()[_0xbacf('0x28')](respondWithResult(_0xdbda69,null))['catch'](handleError(_0xdbda69,null));};exports['getMembers']=function(_0x3808e2,_0x16c426,_0x457c3f){var _0x227601={'raw':!![],'where':{}},_0x182fbb={},_0xdc2ae3;return db[_0xbacf('0x34')][_0xbacf('0x59')]({'where':{'id':_0x3808e2[_0xbacf('0x4d')]['id']}})[_0xbacf('0x28')](handleEntityNotFound(_0x16c426,null))['then'](function(_0x3f0ea2){if(_0x3f0ea2){_0xdc2ae3=_0x3f0ea2[_0xbacf('0x2a')]({'plain':!![]});_0x182fbb[_0xbacf('0x39')]=_[_0xbacf('0x3b')](db[_0xbacf('0x5a')][_0xbacf('0x35')]);_0x182fbb[_0xbacf('0x3a')]=_[_0xbacf('0x3b')](_0x3808e2[_0xbacf('0x3a')]);_0x182fbb[_0xbacf('0x3c')]=_['intersection'](_0x182fbb[_0xbacf('0x39')],_0x182fbb['query']);_0x227601['attributes']=_['intersection'](_0x182fbb['model'],qs[_0xbacf('0x3f')](_0x3808e2[_0xbacf('0x3a')][_0xbacf('0x3f')]));_0x227601[_0xbacf('0x3d')]=_0x227601[_0xbacf('0x3d')]['length']?_0x227601[_0xbacf('0x3d')]:_0x182fbb[_0xbacf('0x39')];if(!_0x3808e2[_0xbacf('0x3a')][_0xbacf('0x40')]('nolimit')){_0x227601[_0xbacf('0x24')]=qs['limit'](_0x3808e2[_0xbacf('0x3a')][_0xbacf('0x24')]);_0x227601[_0xbacf('0x23')]=qs[_0xbacf('0x23')](_0x3808e2[_0xbacf('0x3a')][_0xbacf('0x23')]);}_0x227601[_0xbacf('0x5b')]=qs[_0xbacf('0x42')](_0x3808e2[_0xbacf('0x3a')][_0xbacf('0x42')]);_0x227601['where']=qs['filters'](_[_0xbacf('0x44')](_0x3808e2[_0xbacf('0x3a')],_0x182fbb[_0xbacf('0x3c')]));_0x227601['where'][_0xbacf('0x5c')]=_0x3f0ea2['id'];if(_0x3808e2[_0xbacf('0x3a')]['filter']){_0x227601[_0xbacf('0x43')]=_['merge'](_0x227601[_0xbacf('0x43')],{'$or':_[_0xbacf('0x33')](_0x227601[_0xbacf('0x3d')],function(_0xf26468){var _0x16b8a2={};_0x16b8a2[_0xf26468]={'$like':'%'+_0x3808e2['query']['filter']+'%'};return _0x16b8a2;})});}_0x227601=_[_0xbacf('0x45')]({},_0x227601,_0x3808e2[_0xbacf('0x48')]);return db[_0xbacf('0x5a')][_0xbacf('0x49')](_0x227601);}})[_0xbacf('0x28')](function(_0x2a0f62){if(_0x2a0f62){return db[_0xbacf('0x5d')][_0xbacf('0x5e')]({'where':{'id':_[_0xbacf('0x33')](_0x2a0f62,_0xbacf('0x5f')),'role':_0xbacf('0x60')},'attributes':['id',_0xbacf('0x31'),'openchannelPause',_0xbacf('0x61'),_0xbacf('0x62')]});}})[_0xbacf('0x28')](function(_0x3f6752){if(_0x3f6752){return{'count':_0x3f6752[_0xbacf('0x22')],'rows':_[_0xbacf('0x33')](_0x3f6752['rows'],function(_0x392326){return{'membername':_0x392326[_0xbacf('0x31')],'UserId':_0x392326['id'],'queue_name':_0xdc2ae3[_0xbacf('0x31')],'OpenchannelQueueId':_0xdc2ae3['id'],'interface':util['format']('%s/%s',_0xbacf('0x63'),_0x392326[_0xbacf('0x31')]),'penalty':0x0,'paused':_0x392326[_0xbacf('0x64')],'createdAt':_0x392326[_0xbacf('0x62')],'updatedAt':_0x392326[_0xbacf('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xbacf('0x28')](respondWithFilteredResult(_0x16c426,_0x227601))[_0xbacf('0x4b')](handleError(_0x16c426,null));};exports[_0xbacf('0x65')]=function(_0x4e8f23,_0x5a29fe,_0x36aa5d){var _0x15cd9e={};var _0x5e520e={};var _0x375369;var _0x1bde4b;return db[_0xbacf('0x34')]['findOne']({'where':{'id':_0x4e8f23[_0xbacf('0x4d')]['id']}})[_0xbacf('0x28')](handleEntityNotFound(_0x5a29fe,null))[_0xbacf('0x28')](function(_0x13d1ed){if(_0x13d1ed){_0x375369=_0x13d1ed;_0x5e520e[_0xbacf('0x39')]=_[_0xbacf('0x3b')](db[_0xbacf('0x66')][_0xbacf('0x35')]);_0x5e520e['query']=_['keys'](_0x4e8f23[_0xbacf('0x3a')]);_0x5e520e[_0xbacf('0x3c')]=_[_0xbacf('0x3e')](_0x5e520e[_0xbacf('0x39')],_0x5e520e[_0xbacf('0x3a')]);_0x15cd9e[_0xbacf('0x3d')]=_['intersection'](_0x5e520e[_0xbacf('0x39')],qs[_0xbacf('0x3f')](_0x4e8f23['query']['fields']));_0x15cd9e['attributes']=_0x15cd9e['attributes'][_0xbacf('0x4e')]?_0x15cd9e[_0xbacf('0x3d')]:_0x5e520e['model'];_0x15cd9e[_0xbacf('0x5b')]=qs[_0xbacf('0x42')](_0x4e8f23[_0xbacf('0x3a')][_0xbacf('0x42')]);_0x15cd9e['where']=qs[_0xbacf('0x3c')](_[_0xbacf('0x44')](_0x4e8f23['query'],_0x5e520e[_0xbacf('0x3c')]));if(_0x4e8f23[_0xbacf('0x3a')][_0xbacf('0x47')]){_0x15cd9e[_0xbacf('0x43')]=_[_0xbacf('0x45')](_0x15cd9e[_0xbacf('0x43')],{'$or':_[_0xbacf('0x33')](_0x15cd9e[_0xbacf('0x3d')],function(_0x3e5cf0){var _0x22ff07={};_0x22ff07[_0x3e5cf0]={'$like':'%'+_0x4e8f23[_0xbacf('0x3a')]['filter']+'%'};return _0x22ff07;})});}_0x15cd9e=_[_0xbacf('0x45')]({},_0x15cd9e,_0x4e8f23[_0xbacf('0x48')]);return _0x375369[_0xbacf('0x65')](_0x15cd9e);}})['then'](function(_0x2225bf){if(_0x2225bf){_0x1bde4b=_0x2225bf[_0xbacf('0x4e')];if(!_0x4e8f23[_0xbacf('0x3a')][_0xbacf('0x40')](_0xbacf('0x41'))){_0x15cd9e[_0xbacf('0x24')]=qs['limit'](_0x4e8f23[_0xbacf('0x3a')][_0xbacf('0x24')]);_0x15cd9e[_0xbacf('0x23')]=qs[_0xbacf('0x23')](_0x4e8f23['query'][_0xbacf('0x23')]);}return _0x375369[_0xbacf('0x65')](_0x15cd9e);}})[_0xbacf('0x28')](function(_0x4b1271){if(_0x4b1271){return _0x4b1271?{'count':_0x1bde4b,'rows':_0x4b1271}:null;}})[_0xbacf('0x28')](respondWithResult(_0x5a29fe,null))[_0xbacf('0x4b')](handleError(_0x5a29fe,null));};exports[_0xbacf('0x67')]=function(_0x5e9eeb,_0xd65bc3,_0x4fd821){var _0x3141a8=_0x5e9eeb[_0xbacf('0x57')]['ids'];return db['Team'][_0xbacf('0x49')]({'where':{'id':_0x3141a8},'attributes':['id'],'include':[{'model':db['User'],'as':_0xbacf('0x68'),'attributes':['id',_0xbacf('0x31'),_0xbacf('0x69'),_0xbacf('0x6a'),'interface'],'raw':!![]}]})[_0xbacf('0x28')](function(_0x100cff){if(_0x100cff){var _0x2bd598=_[_0xbacf('0x6b')](_0x100cff,function(_0x312f03){var _0x36efde=_0x312f03['get']({'plain':!![]});return _0x36efde[_0xbacf('0x68')];});return db[_0xbacf('0x34')][_0xbacf('0x51')]({'where':{'id':_0x5e9eeb[_0xbacf('0x4d')]['id']}})[_0xbacf('0x28')](function(_0x132459){return db[_0xbacf('0x6c')][_0xbacf('0x6d')](function(_0x37b3fa){return _0x132459[_0xbacf('0x67')](_0x3141a8,{'transaction':_0x37b3fa})[_0xbacf('0x28')](function(){return BPromise[_0xbacf('0x6e')](_0x2bd598,function(_0x27b089){return db['UserOpenchannelQueue'][_0xbacf('0x6f')]({'where':{'UserId':_0x27b089['id'],'OpenchannelQueueId':_0x5e9eeb['params']['id']},'transaction':_0x37b3fa});});})['then'](function(){_0x2bd598[_0xbacf('0x70')](function(_0x126b2a){socket['emit'](_0xbacf('0x71'),{'UserId':_0x126b2a['id'],'OpenchannelQueueId':_0x132459['id']});});});});});}})[_0xbacf('0x28')](respondWithStatusCode(_0xd65bc3,null))[_0xbacf('0x4b')](handleError(_0xd65bc3,null));};exports[_0xbacf('0x72')]=function(_0x55a478,_0x51f0dd,_0x4811ca){return db[_0xbacf('0x66')]['findAll']({'where':{'id':_0x55a478[_0xbacf('0x3a')][_0xbacf('0x73')]},'attributes':['id'],'include':[{'model':db[_0xbacf('0x5d')],'as':_0xbacf('0x68'),'attributes':['id'],'raw':!![]}]})[_0xbacf('0x28')](handleEntityNotFound(_0x51f0dd,null))[_0xbacf('0x28')](function(_0x250f69){var _0x257e14=_[_0xbacf('0x33')](_0x250f69,'id');var _0x4da641=[];var _0x5f29a4=[];var _0x3b3ab0=squel['select']();_0x3b3ab0[_0xbacf('0x74')](_0xbacf('0x75'))[_0xbacf('0x76')](_0xbacf('0x77'),'tq')['join'](_0xbacf('0x78'),'ut',_0xbacf('0x79'))[_0xbacf('0x43')]('OpenchannelQueueId\x20=\x20?',_0x55a478[_0xbacf('0x4d')]['id']);for(var _0x5e7098=0x0;_0x5e7098<_0x250f69[_0xbacf('0x4e')];_0x5e7098+=0x1){let _0x5579c4=_0x250f69[_0x5e7098];for(var _0x2dd7f9=0x0;_0x2dd7f9<_0x5579c4[_0xbacf('0x68')][_0xbacf('0x4e')];_0x2dd7f9+=0x1){let _0x20d85e=_0x5579c4[_0xbacf('0x68')][_0x2dd7f9];var _0xa97188=_0x3b3ab0[_0xbacf('0x7a')]();_0xa97188[_0xbacf('0x43')]('ut.UserId\x20=\x20?',_0x20d85e['id']);_0x5f29a4[_0xbacf('0x7b')](db[_0xbacf('0x6c')]['query'](_0xa97188['toString'](),{'type':db[_0xbacf('0x6c')][_0xbacf('0x7c')][_0xbacf('0x7d')]})['then'](function(_0x5aa8f1){if(_0x5aa8f1[_0xbacf('0x4e')]===0x1){return _0x20d85e['id'];}else{var _0x5ab7f5=_['every'](_['map'](_0x5aa8f1,_0xbacf('0x7e')),function(_0x266af9){return _[_0xbacf('0x7f')](_0x257e14,_0x266af9);});if(_0x5ab7f5){return _0x20d85e['id'];}}}));}}return BPromise[_0xbacf('0x80')](_0x5f29a4)[_0xbacf('0x28')](function(_0x1f3af7){_0x4da641=_(_0x4da641)[_0xbacf('0x81')](_0x1f3af7)['compact']()[_0xbacf('0x82')]();return db[_0xbacf('0x34')]['find']({'where':{'id':_0x55a478[_0xbacf('0x4d')]['id']}})[_0xbacf('0x28')](function(_0x3bb2c5){return db['sequelize'][_0xbacf('0x6d')](function(_0x25af0b){return _0x3bb2c5[_0xbacf('0x72')](_0x55a478[_0xbacf('0x3a')]['ids'],{'transaction':_0x25af0b})['then'](function(){if(!_[_0xbacf('0x83')](_0x4da641)){return _0x3bb2c5[_0xbacf('0x84')](_0x4da641,{'transaction':_0x25af0b});}})['then'](function(){_0x4da641['forEach'](function(_0x3e2127){socket['emit'](_0xbacf('0x85'),{'UserId':_0x3e2127,'OpenchannelQueueId':_0x3bb2c5['id']});});});});});});})[_0xbacf('0x28')](respondWithStatusCode(_0x51f0dd,null))[_0xbacf('0x4b')](handleError(_0x51f0dd,null));};exports[_0xbacf('0x86')]=function(_0x445f9f,_0x5e900e,_0x468d24){return db[_0xbacf('0x34')][_0xbacf('0x51')]({'where':{'id':_0x445f9f['params']['id']}})[_0xbacf('0x28')](handleEntityNotFound(_0x5e900e,null))[_0xbacf('0x28')](function(_0x16f0ea){if(_0x16f0ea){return _0x16f0ea['addAgents'](_0x445f9f['body'][_0xbacf('0x73')],_['omit'](_0x445f9f[_0xbacf('0x57')],['ids','id'])||{})[_0xbacf('0x87')](function(_0x1ba060){for(var _0xba408=0x0;_0xba408<_0x445f9f[_0xbacf('0x57')][_0xbacf('0x73')][_0xbacf('0x4e')];_0xba408+=0x1){socket[_0xbacf('0x88')](_0xbacf('0x71'),{'UserId':Number(_0x445f9f[_0xbacf('0x57')][_0xbacf('0x73')][_0xba408]),'OpenchannelQueueId':Number(_0x445f9f[_0xbacf('0x4d')]['id'])});}return _0x1ba060;});}})['then'](respondWithResult(_0x5e900e,null))[_0xbacf('0x4b')](handleError(_0x5e900e,null));};exports[_0xbacf('0x84')]=function(_0x131209,_0x57f33f,_0x3318bb){return db['OpenchannelQueue'][_0xbacf('0x51')]({'where':{'id':_0x131209[_0xbacf('0x4d')]['id']}})[_0xbacf('0x28')](handleEntityNotFound(_0x57f33f,null))[_0xbacf('0x28')](function(_0x4db62a){if(_0x4db62a){return _0x4db62a['removeAgents'](_0x131209[_0xbacf('0x3a')][_0xbacf('0x73')])['then'](function(){if(_[_0xbacf('0x89')](_0x131209['query'][_0xbacf('0x73')])){for(var _0x53c850=0x0;_0x53c850<_0x131209['query'][_0xbacf('0x73')][_0xbacf('0x4e')];_0x53c850+=0x1){socket['emit'](_0xbacf('0x85'),{'UserId':Number(_0x131209[_0xbacf('0x3a')][_0xbacf('0x73')][_0x53c850]),'OpenchannelQueueId':Number(_0x131209[_0xbacf('0x4d')]['id'])});}}else{socket[_0xbacf('0x88')](_0xbacf('0x85'),{'UserId':Number(_0x131209['query'][_0xbacf('0x73')]),'OpenchannelQueueId':Number(_0x131209[_0xbacf('0x4d')]['id'])});}});}})[_0xbacf('0x28')](respondWithStatusCode(_0x57f33f,null))[_0xbacf('0x4b')](handleError(_0x57f33f,null));};exports[_0xbacf('0x8a')]=function(_0x5de0db,_0x5eaa45,_0x28e44e){var _0x22366c={};var _0x32aeb3={};var _0x3143db;var _0x252b17;return db[_0xbacf('0x34')]['findOne']({'where':{'id':_0x5de0db['params']['id']}})[_0xbacf('0x28')](handleEntityNotFound(_0x5eaa45,null))['then'](function(_0x5eda31){if(_0x5eda31){_0x3143db=_0x5eda31;_0x32aeb3[_0xbacf('0x39')]=_[_0xbacf('0x3b')](db['User'][_0xbacf('0x35')]);_0x32aeb3[_0xbacf('0x3a')]=_[_0xbacf('0x3b')](_0x5de0db[_0xbacf('0x3a')]);_0x32aeb3['filters']=_['intersection'](_0x32aeb3[_0xbacf('0x39')],_0x32aeb3['query']);_0x22366c[_0xbacf('0x3d')]=_[_0xbacf('0x3e')](_0x32aeb3[_0xbacf('0x39')],qs[_0xbacf('0x3f')](_0x5de0db[_0xbacf('0x3a')]['fields']));_0x22366c[_0xbacf('0x3d')]=_0x22366c['attributes'][_0xbacf('0x4e')]?_0x22366c[_0xbacf('0x3d')]:_0x32aeb3[_0xbacf('0x39')];_0x22366c['order']=qs[_0xbacf('0x42')](_0x5de0db[_0xbacf('0x3a')][_0xbacf('0x42')]);_0x22366c[_0xbacf('0x43')]=qs[_0xbacf('0x3c')](_['pick'](_0x5de0db['query'],_0x32aeb3[_0xbacf('0x3c')]));if(_0x5de0db[_0xbacf('0x3a')]['filter']){_0x22366c[_0xbacf('0x43')]=_['merge'](_0x22366c['where'],{'$or':_[_0xbacf('0x33')](_0x22366c[_0xbacf('0x3d')],function(_0x38f50b){var _0x1dc7eb={};_0x1dc7eb[_0x38f50b]={'$like':'%'+_0x5de0db[_0xbacf('0x3a')][_0xbacf('0x47')]+'%'};return _0x1dc7eb;})});}_0x22366c=_['merge']({},_0x22366c,_0x5de0db[_0xbacf('0x48')]);return _0x3143db['getAgents'](_0x22366c);}})[_0xbacf('0x28')](function(_0x597bac){if(_0x597bac){_0x252b17=_0x597bac[_0xbacf('0x4e')];if(!_0x5de0db['query'][_0xbacf('0x40')](_0xbacf('0x41'))){_0x22366c[_0xbacf('0x24')]=qs[_0xbacf('0x24')](_0x5de0db[_0xbacf('0x3a')][_0xbacf('0x24')]);_0x22366c[_0xbacf('0x23')]=qs['offset'](_0x5de0db['query']['offset']);}return _0x3143db['getAgents'](_0x22366c);}})[_0xbacf('0x28')](function(_0x451b8b){if(_0x451b8b){return _0x451b8b?{'count':_0x252b17,'rows':_0x451b8b}:null;}})[_0xbacf('0x28')](respondWithResult(_0x5eaa45,null))[_0xbacf('0x4b')](handleError(_0x5eaa45,null));};
\ No newline at end of file