Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index dd47855..f4b6db5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x074d=['union','compact','removeTeams','isEmpty','removeAgents','forEach','userOpenchannelQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','defaults','socket.io-emitter','redis','./openchannelQueue.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','apply','reject','save','then','destroy','get','OpenchannelQueues','UserProfileResource','error','name','OpenchannelQueue','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','params','keys','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','find','describe','getMembers','findOne','UserOpenchannelQueue','nolimit','order','OpenchannelQueueId','findAndCountAll','map','agent','updatedAt','createdAt','format','SIP','openchannelPause','getTeams','Team','addTeams','User','Agents','online','voicePause','interface','flatMap','sequelize','each','findOrCreate','emit','userOpenchannelQueue:save','ids','select','field','tq.TeamId','from','team_has_openchannel_queues','user_has_teams','OpenchannelQueueId\x20=\x20?','push','QueryTypes','SELECT','every','includes','all'];(function(_0x13f353,_0x101eda){var _0x139d67=function(_0x20eef1){while(--_0x20eef1){_0x13f353['push'](_0x13f353['shift']());}};_0x139d67(++_0x101eda);}(_0x074d,0x98));var _0xd074=function(_0x58698c,_0x3f9b82){_0x58698c=_0x58698c-0x0;var _0x23bc2f=_0x074d[_0x58698c];return _0x23bc2f;};'use strict';var emlformat=require(_0xd074('0x0'));var rimraf=require(_0xd074('0x1'));var zipdir=require(_0xd074('0x2'));var jsonpatch=require(_0xd074('0x3'));var rp=require(_0xd074('0x4'));var moment=require(_0xd074('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xd074('0x6'));var path=require(_0xd074('0x7'));var sox=require(_0xd074('0x8'));var csv=require(_0xd074('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xd074('0xa'));var crypto=require(_0xd074('0xb'));var jsforce=require(_0xd074('0xc'));var deskjs=require(_0xd074('0xd'));var toCsv=require('to-csv');var querystring=require(_0xd074('0xe'));var Papa=require(_0xd074('0xf'));var Redis=require(_0xd074('0x10'));var authService=require(_0xd074('0x11'));var qs=require(_0xd074('0x12'));var as=require(_0xd074('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xd074('0x14'))(_0xd074('0x15'));var utils=require(_0xd074('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xd074('0x17'));var db=require(_0xd074('0x18'))['db'];config['redis']=_[_0xd074('0x19')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xd074('0x1a'))(new Redis(config[_0xd074('0x1b')]));require(_0xd074('0x1c'))[_0xd074('0x1d')](socket);function respondWithStatusCode(_0x55fb63,_0x2ef095){_0x2ef095=_0x2ef095||0xcc;return function(_0x3cac19){if(_0x3cac19){return _0x55fb63[_0xd074('0x1e')](_0x2ef095);}return _0x55fb63[_0xd074('0x1f')](_0x2ef095)[_0xd074('0x20')]();};}function respondWithResult(_0xb0d3d1,_0x1c22ac){_0x1c22ac=_0x1c22ac||0xc8;return function(_0x3de38f){if(_0x3de38f){return _0xb0d3d1['status'](_0x1c22ac)[_0xd074('0x21')](_0x3de38f);}};}function respondWithFilteredResult(_0x415a27,_0x3bd762){return function(_0x11b8f4){if(_0x11b8f4){var _0xe90d6f=typeof _0x3bd762[_0xd074('0x22')]===_0xd074('0x23')&&typeof _0x3bd762[_0xd074('0x24')]===_0xd074('0x23');var _0xf418da=_0x11b8f4[_0xd074('0x25')];var _0x1d0fa8=_0xe90d6f?0x0:_0x3bd762[_0xd074('0x22')];var _0xf19209=_0xe90d6f?_0x11b8f4[_0xd074('0x25')]:_0x3bd762[_0xd074('0x22')]+_0x3bd762[_0xd074('0x24')];var _0x42a2ae;if(_0xf19209>=_0xf418da){_0xf19209=_0xf418da;_0x42a2ae=0xc8;}else{_0x42a2ae=0xce;}_0x415a27['status'](_0x42a2ae);return _0x415a27['set']('Content-Range',_0x1d0fa8+'-'+_0xf19209+'/'+_0xf418da)[_0xd074('0x21')](_0x11b8f4);}return null;};}function patchUpdates(_0x1278db){return function(_0x35f374){try{jsonpatch[_0xd074('0x26')](_0x35f374,_0x1278db,!![]);}catch(_0x42cd1d){return BPromise[_0xd074('0x27')](_0x42cd1d);}return _0x35f374[_0xd074('0x28')]();};}function saveUpdates(_0x2e9240,_0x11f423){return function(_0x2d456c){if(_0x2d456c){return _0x2d456c['update'](_0x2e9240)[_0xd074('0x29')](function(_0x484b18){return _0x484b18;});}return null;};}function removeEntity(_0x461552,_0x1d97f6){return function(_0x2200aa){if(_0x2200aa){return _0x2200aa[_0xd074('0x2a')]()[_0xd074('0x29')](function(){var _0x45f72f=_0x2200aa[_0xd074('0x2b')]({'plain':!![]});var _0x1f8f75=_0xd074('0x2c');return db[_0xd074('0x2d')][_0xd074('0x2a')]({'where':{'type':_0x1f8f75,'resourceId':_0x45f72f['id']}})[_0xd074('0x29')](function(){return _0x2200aa;});})[_0xd074('0x29')](function(){_0x461552[_0xd074('0x1f')](0xcc)[_0xd074('0x20')]();});}};}function handleEntityNotFound(_0x3cfc45,_0x53f671){return function(_0x2e39ab){if(!_0x2e39ab){_0x3cfc45['sendStatus'](0x194);}return _0x2e39ab;};}function handleError(_0x400b0d,_0x2c7f39){_0x2c7f39=_0x2c7f39||0x1f4;return function(_0xef45c){logger[_0xd074('0x2e')](_0xef45c['stack']);if(_0xef45c[_0xd074('0x2f')]){delete _0xef45c['name'];}_0x400b0d['status'](_0x2c7f39)['send'](_0xef45c);};}exports['index']=function(_0x17e02f,_0x6a55e2){var _0x351449={},_0xa9b140={},_0x1e25b9={'count':0x0,'rows':[]};var _0x597e5d=_['map'](db[_0xd074('0x30')][_0xd074('0x31')],function(_0x396c19){return{'name':_0x396c19[_0xd074('0x32')],'type':_0x396c19[_0xd074('0x33')][_0xd074('0x34')]};});_0xa9b140[_0xd074('0x35')]=_['map'](_0x597e5d,_0xd074('0x2f'));_0xa9b140[_0xd074('0x36')]=_['keys'](_0x17e02f[_0xd074('0x36')]);_0xa9b140[_0xd074('0x37')]=_[_0xd074('0x38')](_0xa9b140[_0xd074('0x35')],_0xa9b140[_0xd074('0x36')]);_0x351449[_0xd074('0x39')]=_['intersection'](_0xa9b140['model'],qs[_0xd074('0x3a')](_0x17e02f[_0xd074('0x36')][_0xd074('0x3a')]));_0x351449[_0xd074('0x39')]=_0x351449[_0xd074('0x39')][_0xd074('0x3b')]?_0x351449[_0xd074('0x39')]:_0xa9b140[_0xd074('0x35')];if(!_0x17e02f[_0xd074('0x36')][_0xd074('0x3c')]('nolimit')){_0x351449[_0xd074('0x24')]=qs[_0xd074('0x24')](_0x17e02f[_0xd074('0x36')][_0xd074('0x24')]);_0x351449[_0xd074('0x22')]=qs[_0xd074('0x22')](_0x17e02f[_0xd074('0x36')][_0xd074('0x22')]);}_0x351449['order']=qs[_0xd074('0x3d')](_0x17e02f[_0xd074('0x36')][_0xd074('0x3d')]);_0x351449[_0xd074('0x3e')]=qs[_0xd074('0x37')](_[_0xd074('0x3f')](_0x17e02f['query'],_0xa9b140[_0xd074('0x37')]),_0x597e5d);if(_0x17e02f[_0xd074('0x36')][_0xd074('0x40')]){_0x351449[_0xd074('0x3e')]=_['merge'](_0x351449[_0xd074('0x3e')],{'$or':_['map'](_0x597e5d,function(_0x4d7be3){if(_0x4d7be3[_0xd074('0x33')]!==_0xd074('0x41')){var _0x485dad={};_0x485dad[_0x4d7be3['name']]={'$like':'%'+_0x17e02f[_0xd074('0x36')]['filter']+'%'};return _0x485dad;}})});}_0x351449=_[_0xd074('0x42')]({},_0x351449,_0x17e02f[_0xd074('0x43')]);var _0xb81f12={'where':_0x351449[_0xd074('0x3e')]};return db[_0xd074('0x30')][_0xd074('0x25')](_0xb81f12)['then'](function(_0x595eb8){_0x1e25b9[_0xd074('0x25')]=_0x595eb8;if(_0x17e02f[_0xd074('0x36')][_0xd074('0x44')]){_0x351449[_0xd074('0x45')]=[{'all':!![]}];}return db[_0xd074('0x30')][_0xd074('0x46')](_0x351449);})[_0xd074('0x29')](function(_0x4bcf3b){_0x1e25b9[_0xd074('0x47')]=_0x4bcf3b;return _0x1e25b9;})[_0xd074('0x29')](respondWithFilteredResult(_0x6a55e2,_0x351449))[_0xd074('0x48')](handleError(_0x6a55e2,null));};exports['show']=function(_0x50cf5c,_0x599d85){var _0x146a72={'raw':!![],'where':{'id':_0x50cf5c[_0xd074('0x49')]['id']}},_0x500617={};_0x500617[_0xd074('0x35')]=_[_0xd074('0x4a')](db[_0xd074('0x30')][_0xd074('0x31')]);_0x500617['query']=_[_0xd074('0x4a')](_0x50cf5c[_0xd074('0x36')]);_0x500617[_0xd074('0x37')]=_[_0xd074('0x38')](_0x500617[_0xd074('0x35')],_0x500617[_0xd074('0x36')]);_0x146a72[_0xd074('0x39')]=_[_0xd074('0x38')](_0x500617[_0xd074('0x35')],qs['fields'](_0x50cf5c[_0xd074('0x36')][_0xd074('0x3a')]));_0x146a72[_0xd074('0x39')]=_0x146a72[_0xd074('0x39')]['length']?_0x146a72[_0xd074('0x39')]:_0x500617[_0xd074('0x35')];if(_0x50cf5c[_0xd074('0x36')][_0xd074('0x44')]){_0x146a72[_0xd074('0x45')]=[{'all':!![]}];}_0x146a72=_[_0xd074('0x42')]({},_0x146a72,_0x50cf5c['options']);return db['OpenchannelQueue']['find'](_0x146a72)[_0xd074('0x29')](handleEntityNotFound(_0x599d85,null))['then'](respondWithResult(_0x599d85,null))['catch'](handleError(_0x599d85,null));};exports[_0xd074('0x4b')]=function(_0x4e5e32,_0x3389ec){return db['OpenchannelQueue']['create'](_0x4e5e32['body'],{})[_0xd074('0x29')](function(_0x10d690){var _0x331756=_0x4e5e32['user'][_0xd074('0x2b')]({'plain':!![]});if(!_0x331756)throw new Error(_0xd074('0x4c'));if(_0x331756[_0xd074('0x4d')]===_0xd074('0x4e')){var _0x11c291=_0x10d690[_0xd074('0x2b')]({'plain':!![]});var _0x2292e2=_0xd074('0x2c');return db[_0xd074('0x4f')]['find']({'where':{'name':_0x2292e2,'userProfileId':_0x331756[_0xd074('0x50')]},'raw':!![]})[_0xd074('0x29')](function(_0xfba178){if(_0xfba178&&_0xfba178['autoAssociation']===0x0){return db['UserProfileResource'][_0xd074('0x4b')]({'name':_0x11c291[_0xd074('0x2f')],'resourceId':_0x11c291['id'],'type':_0xfba178['name'],'sectionId':_0xfba178['id']},{})[_0xd074('0x29')](function(){return _0x10d690;});}else{return _0x10d690;}})[_0xd074('0x48')](function(_0x447c23){logger['error'](_0xd074('0x51'),_0x447c23);throw _0x447c23;});}return _0x10d690;})[_0xd074('0x29')](respondWithResult(_0x3389ec,0xc9))[_0xd074('0x48')](handleError(_0x3389ec,null));};exports[_0xd074('0x52')]=function(_0x2da027,_0x1cdac7){if(_0x2da027[_0xd074('0x53')]['id']){delete _0x2da027[_0xd074('0x53')]['id'];}return db['OpenchannelQueue'][_0xd074('0x54')]({'where':{'id':_0x2da027[_0xd074('0x49')]['id']}})[_0xd074('0x29')](handleEntityNotFound(_0x1cdac7,null))[_0xd074('0x29')](saveUpdates(_0x2da027['body'],null))[_0xd074('0x29')](respondWithResult(_0x1cdac7,null))['catch'](handleError(_0x1cdac7,null));};exports[_0xd074('0x2a')]=function(_0x20fcc7,_0x459d2f){return db[_0xd074('0x30')][_0xd074('0x54')]({'where':{'id':_0x20fcc7['params']['id']}})[_0xd074('0x29')](handleEntityNotFound(_0x459d2f,null))['then'](removeEntity(_0x459d2f,null))[_0xd074('0x48')](handleError(_0x459d2f,null));};exports[_0xd074('0x55')]=function(_0xdae92b,_0x613fcf){return db[_0xd074('0x30')][_0xd074('0x55')]()[_0xd074('0x29')](respondWithResult(_0x613fcf,null))[_0xd074('0x48')](handleError(_0x613fcf,null));};exports[_0xd074('0x56')]=function(_0xa33fe2,_0x5baa47,_0x48442d){var _0x4c46cf={'raw':!![],'where':{}},_0x217b43={},_0x592c73;return db[_0xd074('0x30')][_0xd074('0x57')]({'where':{'id':_0xa33fe2[_0xd074('0x49')]['id']}})[_0xd074('0x29')](handleEntityNotFound(_0x5baa47,null))[_0xd074('0x29')](function(_0x1e7b8c){if(_0x1e7b8c){_0x592c73=_0x1e7b8c[_0xd074('0x2b')]({'plain':!![]});_0x217b43[_0xd074('0x35')]=_[_0xd074('0x4a')](db[_0xd074('0x58')]['rawAttributes']);_0x217b43[_0xd074('0x36')]=_[_0xd074('0x4a')](_0xa33fe2[_0xd074('0x36')]);_0x217b43[_0xd074('0x37')]=_[_0xd074('0x38')](_0x217b43['model'],_0x217b43[_0xd074('0x36')]);_0x4c46cf[_0xd074('0x39')]=_[_0xd074('0x38')](_0x217b43[_0xd074('0x35')],qs['fields'](_0xa33fe2['query'][_0xd074('0x3a')]));_0x4c46cf[_0xd074('0x39')]=_0x4c46cf['attributes']['length']?_0x4c46cf[_0xd074('0x39')]:_0x217b43['model'];if(!_0xa33fe2['query'][_0xd074('0x3c')](_0xd074('0x59'))){_0x4c46cf['limit']=qs[_0xd074('0x24')](_0xa33fe2[_0xd074('0x36')]['limit']);_0x4c46cf[_0xd074('0x22')]=qs[_0xd074('0x22')](_0xa33fe2['query']['offset']);}_0x4c46cf[_0xd074('0x5a')]=qs['sort'](_0xa33fe2[_0xd074('0x36')][_0xd074('0x3d')]);_0x4c46cf[_0xd074('0x3e')]=qs[_0xd074('0x37')](_[_0xd074('0x3f')](_0xa33fe2['query'],_0x217b43[_0xd074('0x37')]));_0x4c46cf[_0xd074('0x3e')][_0xd074('0x5b')]=_0x1e7b8c['id'];if(_0xa33fe2[_0xd074('0x36')][_0xd074('0x40')]){_0x4c46cf[_0xd074('0x3e')]=_['merge'](_0x4c46cf[_0xd074('0x3e')],{'$or':_['map'](_0x4c46cf[_0xd074('0x39')],function(_0x3a9781){var _0x5b3e22={};_0x5b3e22[_0x3a9781]={'$like':'%'+_0xa33fe2[_0xd074('0x36')][_0xd074('0x40')]+'%'};return _0x5b3e22;})});}_0x4c46cf=_[_0xd074('0x42')]({},_0x4c46cf,_0xa33fe2['options']);return db[_0xd074('0x58')][_0xd074('0x46')](_0x4c46cf);}})[_0xd074('0x29')](function(_0x191057){if(_0x191057){return db['User'][_0xd074('0x5c')]({'where':{'id':_[_0xd074('0x5d')](_0x191057,'UserId'),'role':_0xd074('0x5e')},'attributes':['id','name','openchannelPause',_0xd074('0x5f'),_0xd074('0x60')]});}})['then'](function(_0x386ea5){if(_0x386ea5){return{'count':_0x386ea5[_0xd074('0x25')],'rows':_[_0xd074('0x5d')](_0x386ea5[_0xd074('0x47')],function(_0x4c1cf0){return{'membername':_0x4c1cf0[_0xd074('0x2f')],'UserId':_0x4c1cf0['id'],'queue_name':_0x592c73['name'],'OpenchannelQueueId':_0x592c73['id'],'interface':util[_0xd074('0x61')]('%s/%s',_0xd074('0x62'),_0x4c1cf0[_0xd074('0x2f')]),'penalty':0x0,'paused':_0x4c1cf0[_0xd074('0x63')],'createdAt':_0x4c1cf0[_0xd074('0x60')],'updatedAt':_0x4c1cf0[_0xd074('0x5f')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x5baa47,_0x4c46cf))['catch'](handleError(_0x5baa47,null));};exports[_0xd074('0x64')]=function(_0x341201,_0x26c57f,_0x3ec3c9){var _0x18b8cf={};var _0x2e7b5d={};var _0x593945;var _0x80b9f9;return db[_0xd074('0x30')]['findOne']({'where':{'id':_0x341201[_0xd074('0x49')]['id']}})[_0xd074('0x29')](handleEntityNotFound(_0x26c57f,null))[_0xd074('0x29')](function(_0x3e87e1){if(_0x3e87e1){_0x593945=_0x3e87e1;_0x2e7b5d[_0xd074('0x35')]=_['keys'](db[_0xd074('0x65')]['rawAttributes']);_0x2e7b5d[_0xd074('0x36')]=_[_0xd074('0x4a')](_0x341201['query']);_0x2e7b5d[_0xd074('0x37')]=_[_0xd074('0x38')](_0x2e7b5d[_0xd074('0x35')],_0x2e7b5d[_0xd074('0x36')]);_0x18b8cf[_0xd074('0x39')]=_['intersection'](_0x2e7b5d[_0xd074('0x35')],qs[_0xd074('0x3a')](_0x341201['query']['fields']));_0x18b8cf[_0xd074('0x39')]=_0x18b8cf[_0xd074('0x39')]['length']?_0x18b8cf[_0xd074('0x39')]:_0x2e7b5d[_0xd074('0x35')];_0x18b8cf[_0xd074('0x5a')]=qs[_0xd074('0x3d')](_0x341201[_0xd074('0x36')]['sort']);_0x18b8cf[_0xd074('0x3e')]=qs[_0xd074('0x37')](_[_0xd074('0x3f')](_0x341201[_0xd074('0x36')],_0x2e7b5d[_0xd074('0x37')]));if(_0x341201[_0xd074('0x36')][_0xd074('0x40')]){_0x18b8cf[_0xd074('0x3e')]=_[_0xd074('0x42')](_0x18b8cf[_0xd074('0x3e')],{'$or':_[_0xd074('0x5d')](_0x18b8cf['attributes'],function(_0x214b07){var _0x2de455={};_0x2de455[_0x214b07]={'$like':'%'+_0x341201[_0xd074('0x36')][_0xd074('0x40')]+'%'};return _0x2de455;})});}_0x18b8cf=_[_0xd074('0x42')]({},_0x18b8cf,_0x341201['options']);return _0x593945[_0xd074('0x64')](_0x18b8cf);}})[_0xd074('0x29')](function(_0x1f3c41){if(_0x1f3c41){_0x80b9f9=_0x1f3c41[_0xd074('0x3b')];if(!_0x341201[_0xd074('0x36')][_0xd074('0x3c')](_0xd074('0x59'))){_0x18b8cf[_0xd074('0x24')]=qs[_0xd074('0x24')](_0x341201[_0xd074('0x36')]['limit']);_0x18b8cf[_0xd074('0x22')]=qs[_0xd074('0x22')](_0x341201[_0xd074('0x36')][_0xd074('0x22')]);}return _0x593945[_0xd074('0x64')](_0x18b8cf);}})[_0xd074('0x29')](function(_0x4bf58a){if(_0x4bf58a){return _0x4bf58a?{'count':_0x80b9f9,'rows':_0x4bf58a}:null;}})[_0xd074('0x29')](respondWithResult(_0x26c57f,null))[_0xd074('0x48')](handleError(_0x26c57f,null));};exports[_0xd074('0x66')]=function(_0x4f1796,_0x3c9ab6,_0x1e93cb){var _0x487b84=_0x4f1796['body']['ids'];return db['Team']['findAll']({'where':{'id':_0x487b84},'attributes':['id'],'include':[{'model':db[_0xd074('0x67')],'as':_0xd074('0x68'),'attributes':['id',_0xd074('0x2f'),_0xd074('0x69'),_0xd074('0x6a'),_0xd074('0x6b')],'raw':!![]}]})[_0xd074('0x29')](function(_0x38e7b5){if(_0x38e7b5){var _0x29a00b=_[_0xd074('0x6c')](_0x38e7b5,function(_0x56a5a8){var _0x2dbfdc=_0x56a5a8[_0xd074('0x2b')]({'plain':!![]});return _0x2dbfdc['Agents'];});return db[_0xd074('0x30')]['find']({'where':{'id':_0x4f1796['params']['id']}})[_0xd074('0x29')](function(_0x2f8342){return db[_0xd074('0x6d')]['transaction'](function(_0x393f7e){return _0x2f8342['addTeams'](_0x487b84,{'transaction':_0x393f7e})[_0xd074('0x29')](function(){return BPromise[_0xd074('0x6e')](_0x29a00b,function(_0x13ec49){return db[_0xd074('0x58')][_0xd074('0x6f')]({'where':{'UserId':_0x13ec49['id'],'OpenchannelQueueId':_0x4f1796[_0xd074('0x49')]['id']},'transaction':_0x393f7e});});})[_0xd074('0x29')](function(){_0x29a00b['forEach'](function(_0x32c5c9){socket[_0xd074('0x70')](_0xd074('0x71'),{'UserId':_0x32c5c9['id'],'OpenchannelQueueId':_0x2f8342['id']});});});});});}})[_0xd074('0x29')](respondWithStatusCode(_0x3c9ab6,null))[_0xd074('0x48')](handleError(_0x3c9ab6,null));};exports['removeTeams']=function(_0x4fb3c1,_0xa11261,_0x4ba747){return db[_0xd074('0x65')][_0xd074('0x46')]({'where':{'id':_0x4fb3c1[_0xd074('0x36')][_0xd074('0x72')]},'attributes':['id'],'include':[{'model':db[_0xd074('0x67')],'as':_0xd074('0x68'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0xa11261,null))['then'](function(_0x4377c1){var _0x6276d4=_[_0xd074('0x5d')](_0x4377c1,'id');var _0x4d3bf6=[];var _0x1f86ee=[];var _0x4863be=squel[_0xd074('0x73')]();_0x4863be[_0xd074('0x74')](_0xd074('0x75'))[_0xd074('0x76')](_0xd074('0x77'),'tq')['join'](_0xd074('0x78'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0xd074('0x79'),_0x4fb3c1[_0xd074('0x49')]['id']);for(var _0x59e06b=0x0;_0x59e06b<_0x4377c1['length'];_0x59e06b+=0x1){let _0x3dfee4=_0x4377c1[_0x59e06b];for(var _0x5a39fa=0x0;_0x5a39fa<_0x3dfee4[_0xd074('0x68')][_0xd074('0x3b')];_0x5a39fa+=0x1){let _0x488a52=_0x3dfee4[_0xd074('0x68')][_0x5a39fa];var _0x42fd55=_0x4863be['clone']();_0x42fd55[_0xd074('0x3e')]('ut.UserId\x20=\x20?',_0x488a52['id']);_0x1f86ee[_0xd074('0x7a')](db[_0xd074('0x6d')][_0xd074('0x36')](_0x42fd55['toString'](),{'type':db[_0xd074('0x6d')][_0xd074('0x7b')][_0xd074('0x7c')]})[_0xd074('0x29')](function(_0x25b2cc){if(_0x25b2cc[_0xd074('0x3b')]===0x1){return _0x488a52['id'];}else{var _0x2afce6=_[_0xd074('0x7d')](_['map'](_0x25b2cc,'TeamId'),function(_0x390234){return _[_0xd074('0x7e')](_0x6276d4,_0x390234);});if(_0x2afce6){return _0x488a52['id'];}}}));}}return BPromise[_0xd074('0x7f')](_0x1f86ee)['then'](function(_0x21939d){_0x4d3bf6=_(_0x4d3bf6)[_0xd074('0x80')](_0x21939d)[_0xd074('0x81')]()['value']();return db[_0xd074('0x30')][_0xd074('0x54')]({'where':{'id':_0x4fb3c1[_0xd074('0x49')]['id']}})['then'](function(_0x24078b){return db[_0xd074('0x6d')]['transaction'](function(_0x21c8e2){return _0x24078b[_0xd074('0x82')](_0x4fb3c1['query']['ids'],{'transaction':_0x21c8e2})[_0xd074('0x29')](function(){if(!_[_0xd074('0x83')](_0x4d3bf6)){return _0x24078b[_0xd074('0x84')](_0x4d3bf6,{'transaction':_0x21c8e2});}})['then'](function(){_0x4d3bf6[_0xd074('0x85')](function(_0x3eebe1){socket[_0xd074('0x70')](_0xd074('0x86'),{'UserId':_0x3eebe1,'OpenchannelQueueId':_0x24078b['id']});});});});});});})[_0xd074('0x29')](respondWithStatusCode(_0xa11261,null))['catch'](handleError(_0xa11261,null));};exports[_0xd074('0x87')]=function(_0x167bb6,_0x3d4f84,_0x473d1c){return db[_0xd074('0x30')][_0xd074('0x54')]({'where':{'id':_0x167bb6['params']['id']}})[_0xd074('0x29')](handleEntityNotFound(_0x3d4f84,null))[_0xd074('0x29')](function(_0x585360){if(_0x585360){return _0x585360[_0xd074('0x87')](_0x167bb6['body']['ids'],_[_0xd074('0x88')](_0x167bb6[_0xd074('0x53')],[_0xd074('0x72'),'id'])||{})[_0xd074('0x89')](function(_0x4752d7){for(var _0x544559=0x0;_0x544559<_0x167bb6[_0xd074('0x53')][_0xd074('0x72')]['length'];_0x544559+=0x1){socket[_0xd074('0x70')](_0xd074('0x71'),{'UserId':Number(_0x167bb6['body']['ids'][_0x544559]),'OpenchannelQueueId':Number(_0x167bb6['params']['id'])});}return _0x4752d7;});}})['then'](respondWithResult(_0x3d4f84,null))[_0xd074('0x48')](handleError(_0x3d4f84,null));};exports[_0xd074('0x84')]=function(_0x3e4eb3,_0x3d3a37,_0x3feb16){return db[_0xd074('0x30')]['find']({'where':{'id':_0x3e4eb3[_0xd074('0x49')]['id']}})[_0xd074('0x29')](handleEntityNotFound(_0x3d3a37,null))[_0xd074('0x29')](function(_0x2a543a){if(_0x2a543a){return _0x2a543a['removeAgents'](_0x3e4eb3['query'][_0xd074('0x72')])[_0xd074('0x29')](function(){if(_[_0xd074('0x8a')](_0x3e4eb3[_0xd074('0x36')][_0xd074('0x72')])){for(var _0x3bb9ff=0x0;_0x3bb9ff<_0x3e4eb3['query']['ids']['length'];_0x3bb9ff+=0x1){socket[_0xd074('0x70')](_0xd074('0x86'),{'UserId':Number(_0x3e4eb3['query'][_0xd074('0x72')][_0x3bb9ff]),'OpenchannelQueueId':Number(_0x3e4eb3[_0xd074('0x49')]['id'])});}}else{socket[_0xd074('0x70')](_0xd074('0x86'),{'UserId':Number(_0x3e4eb3[_0xd074('0x36')]['ids']),'OpenchannelQueueId':Number(_0x3e4eb3[_0xd074('0x49')]['id'])});}});}})['then'](respondWithStatusCode(_0x3d3a37,null))[_0xd074('0x48')](handleError(_0x3d3a37,null));};exports[_0xd074('0x8b')]=function(_0x4204f8,_0x2668a0,_0x575bf1){var _0x2b0dda={};var _0x251033={};var _0x44f245;var _0xcfc7b4;return db[_0xd074('0x30')]['findOne']({'where':{'id':_0x4204f8[_0xd074('0x49')]['id']}})[_0xd074('0x29')](handleEntityNotFound(_0x2668a0,null))[_0xd074('0x29')](function(_0x72446c){if(_0x72446c){_0x44f245=_0x72446c;_0x251033[_0xd074('0x35')]=_[_0xd074('0x4a')](db[_0xd074('0x67')][_0xd074('0x31')]);_0x251033[_0xd074('0x36')]=_[_0xd074('0x4a')](_0x4204f8[_0xd074('0x36')]);_0x251033[_0xd074('0x37')]=_['intersection'](_0x251033[_0xd074('0x35')],_0x251033[_0xd074('0x36')]);_0x2b0dda['attributes']=_[_0xd074('0x38')](_0x251033['model'],qs[_0xd074('0x3a')](_0x4204f8['query'][_0xd074('0x3a')]));_0x2b0dda['attributes']=_0x2b0dda['attributes'][_0xd074('0x3b')]?_0x2b0dda[_0xd074('0x39')]:_0x251033[_0xd074('0x35')];_0x2b0dda[_0xd074('0x5a')]=qs[_0xd074('0x3d')](_0x4204f8['query'][_0xd074('0x3d')]);_0x2b0dda[_0xd074('0x3e')]=qs[_0xd074('0x37')](_[_0xd074('0x3f')](_0x4204f8[_0xd074('0x36')],_0x251033['filters']));if(_0x4204f8[_0xd074('0x36')][_0xd074('0x40')]){_0x2b0dda[_0xd074('0x3e')]=_[_0xd074('0x42')](_0x2b0dda[_0xd074('0x3e')],{'$or':_['map'](_0x2b0dda[_0xd074('0x39')],function(_0x4f98c8){var _0x30228b={};_0x30228b[_0x4f98c8]={'$like':'%'+_0x4204f8[_0xd074('0x36')][_0xd074('0x40')]+'%'};return _0x30228b;})});}_0x2b0dda=_[_0xd074('0x42')]({},_0x2b0dda,_0x4204f8[_0xd074('0x43')]);return _0x44f245[_0xd074('0x8b')](_0x2b0dda);}})['then'](function(_0xd58dce){if(_0xd58dce){_0xcfc7b4=_0xd58dce[_0xd074('0x3b')];if(!_0x4204f8[_0xd074('0x36')][_0xd074('0x3c')](_0xd074('0x59'))){_0x2b0dda['limit']=qs[_0xd074('0x24')](_0x4204f8[_0xd074('0x36')][_0xd074('0x24')]);_0x2b0dda[_0xd074('0x22')]=qs[_0xd074('0x22')](_0x4204f8['query'][_0xd074('0x22')]);}return _0x44f245['getAgents'](_0x2b0dda);}})[_0xd074('0x29')](function(_0x16b74e){if(_0x16b74e){return _0x16b74e?{'count':_0xcfc7b4,'rows':_0x16b74e}:null;}})[_0xd074('0x29')](respondWithResult(_0x2668a0,null))[_0xd074('0x48')](handleError(_0x2668a0,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