Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index 1a35666..f4b6db5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc9bc=['limit','Content-Range','json','apply','reject','update','then','destroy','UserProfileResource','sendStatus','error','stack','name','send','OpenchannelQueue','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','VIRTUAL','includeAll','include','rows','catch','show','params','keys','rawAttributes','options','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','OpenchannelQueues','UserProfileSection','userProfileId','autoAssociation','getMembers','UserOpenchannelQueue','OpenchannelQueueId','findAll','UserId','agent','openchannelPause','updatedAt','createdAt','format','%s/%s','getTeams','findOne','addTeams','User','online','voicePause','interface','flatMap','Agents','sequelize','transaction','each','findOrCreate','forEach','emit','userOpenchannelQueue:save','ids','field','from','team_has_openchannel_queues','join','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','userOpenchannelQueue:remove','addAgents','spread','removeAgents','getAgents','eml-format','rimraf','zip-dir','request-promise','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','end','status','offset','undefined','count'];(function(_0x50bff9,_0x478430){var _0x23556b=function(_0x1406f4){while(--_0x1406f4){_0x50bff9['push'](_0x50bff9['shift']());}};_0x23556b(++_0x478430);}(_0xc9bc,0x185));var _0xcc9b=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xc9bc[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xcc9b('0x0'));var rimraf=require(_0xcc9b('0x1'));var zipdir=require(_0xcc9b('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xcc9b('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xcc9b('0x4'));var path=require(_0xcc9b('0x5'));var sox=require(_0xcc9b('0x6'));var csv=require(_0xcc9b('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xcc9b('0x8'));var _=require(_0xcc9b('0x9'));var squel=require(_0xcc9b('0xa'));var crypto=require(_0xcc9b('0xb'));var jsforce=require(_0xcc9b('0xc'));var deskjs=require(_0xcc9b('0xd'));var toCsv=require('to-csv');var querystring=require(_0xcc9b('0xe'));var Papa=require(_0xcc9b('0xf'));var Redis=require(_0xcc9b('0x10'));var authService=require(_0xcc9b('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xcc9b('0x12'));var logger=require(_0xcc9b('0x13'))('api');var utils=require(_0xcc9b('0x14'));var config=require(_0xcc9b('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xcc9b('0x16'))['db'];config[_0xcc9b('0x17')]=_[_0xcc9b('0x18')](config[_0xcc9b('0x17')],{'host':_0xcc9b('0x19'),'port':0x18eb});var socket=require(_0xcc9b('0x1a'))(new Redis(config[_0xcc9b('0x17')]));require(_0xcc9b('0x1b'))[_0xcc9b('0x1c')](socket);function respondWithStatusCode(_0x5dfa44,_0x3daa6c){_0x3daa6c=_0x3daa6c||0xcc;return function(_0x49b7ee){if(_0x49b7ee){return _0x5dfa44['sendStatus'](_0x3daa6c);}return _0x5dfa44['status'](_0x3daa6c)[_0xcc9b('0x1d')]();};}function respondWithResult(_0x576d49,_0x8a484){_0x8a484=_0x8a484||0xc8;return function(_0x54fdf5){if(_0x54fdf5){return _0x576d49[_0xcc9b('0x1e')](_0x8a484)['json'](_0x54fdf5);}};}function respondWithFilteredResult(_0x42e21c,_0x32da7d){return function(_0x5d81e3){if(_0x5d81e3){var _0x51ef55=typeof _0x32da7d[_0xcc9b('0x1f')]==='undefined'&&typeof _0x32da7d['limit']===_0xcc9b('0x20');var _0x47bff3=_0x5d81e3[_0xcc9b('0x21')];var _0x413f15=_0x51ef55?0x0:_0x32da7d[_0xcc9b('0x1f')];var _0xb14fb=_0x51ef55?_0x5d81e3[_0xcc9b('0x21')]:_0x32da7d['offset']+_0x32da7d[_0xcc9b('0x22')];var _0xc25526;if(_0xb14fb>=_0x47bff3){_0xb14fb=_0x47bff3;_0xc25526=0xc8;}else{_0xc25526=0xce;}_0x42e21c['status'](_0xc25526);return _0x42e21c['set'](_0xcc9b('0x23'),_0x413f15+'-'+_0xb14fb+'/'+_0x47bff3)[_0xcc9b('0x24')](_0x5d81e3);}return null;};}function patchUpdates(_0xac784e){return function(_0x380136){try{jsonpatch[_0xcc9b('0x25')](_0x380136,_0xac784e,!![]);}catch(_0x391d03){return BPromise[_0xcc9b('0x26')](_0x391d03);}return _0x380136['save']();};}function saveUpdates(_0x3ed0a0,_0x1ab253){return function(_0x210d77){if(_0x210d77){return _0x210d77[_0xcc9b('0x27')](_0x3ed0a0)[_0xcc9b('0x28')](function(_0x5ab59d){return _0x5ab59d;});}return null;};}function removeEntity(_0x54c2c2,_0x542e78){return function(_0x17cb5d){if(_0x17cb5d){return _0x17cb5d[_0xcc9b('0x29')]()[_0xcc9b('0x28')](function(){var _0x344325=_0x17cb5d['get']({'plain':!![]});var _0x990793='OpenchannelQueues';return db[_0xcc9b('0x2a')]['destroy']({'where':{'type':_0x990793,'resourceId':_0x344325['id']}})[_0xcc9b('0x28')](function(){return _0x17cb5d;});})[_0xcc9b('0x28')](function(){_0x54c2c2[_0xcc9b('0x1e')](0xcc)[_0xcc9b('0x1d')]();});}};}function handleEntityNotFound(_0x382ae9,_0x29744a){return function(_0x3aaadf){if(!_0x3aaadf){_0x382ae9[_0xcc9b('0x2b')](0x194);}return _0x3aaadf;};}function handleError(_0x381beb,_0x568a96){_0x568a96=_0x568a96||0x1f4;return function(_0x2cdef5){logger[_0xcc9b('0x2c')](_0x2cdef5[_0xcc9b('0x2d')]);if(_0x2cdef5[_0xcc9b('0x2e')]){delete _0x2cdef5[_0xcc9b('0x2e')];}_0x381beb[_0xcc9b('0x1e')](_0x568a96)[_0xcc9b('0x2f')](_0x2cdef5);};}exports['index']=function(_0x3318ac,_0x226308){var _0x563cd7={},_0x3d88c5={},_0x3ddefe={'count':0x0,'rows':[]};var _0x9e6bf9=_['map'](db[_0xcc9b('0x30')]['rawAttributes'],function(_0x3997b6){return{'name':_0x3997b6[_0xcc9b('0x31')],'type':_0x3997b6[_0xcc9b('0x32')][_0xcc9b('0x33')]};});_0x3d88c5[_0xcc9b('0x34')]=_['map'](_0x9e6bf9,_0xcc9b('0x2e'));_0x3d88c5['query']=_['keys'](_0x3318ac[_0xcc9b('0x35')]);_0x3d88c5[_0xcc9b('0x36')]=_[_0xcc9b('0x37')](_0x3d88c5[_0xcc9b('0x34')],_0x3d88c5[_0xcc9b('0x35')]);_0x563cd7[_0xcc9b('0x38')]=_['intersection'](_0x3d88c5[_0xcc9b('0x34')],qs[_0xcc9b('0x39')](_0x3318ac['query'][_0xcc9b('0x39')]));_0x563cd7[_0xcc9b('0x38')]=_0x563cd7[_0xcc9b('0x38')][_0xcc9b('0x3a')]?_0x563cd7['attributes']:_0x3d88c5[_0xcc9b('0x34')];if(!_0x3318ac[_0xcc9b('0x35')][_0xcc9b('0x3b')](_0xcc9b('0x3c'))){_0x563cd7[_0xcc9b('0x22')]=qs[_0xcc9b('0x22')](_0x3318ac['query'][_0xcc9b('0x22')]);_0x563cd7['offset']=qs['offset'](_0x3318ac[_0xcc9b('0x35')]['offset']);}_0x563cd7[_0xcc9b('0x3d')]=qs[_0xcc9b('0x3e')](_0x3318ac[_0xcc9b('0x35')][_0xcc9b('0x3e')]);_0x563cd7[_0xcc9b('0x3f')]=qs[_0xcc9b('0x36')](_[_0xcc9b('0x40')](_0x3318ac[_0xcc9b('0x35')],_0x3d88c5[_0xcc9b('0x36')]),_0x9e6bf9);if(_0x3318ac[_0xcc9b('0x35')][_0xcc9b('0x41')]){_0x563cd7[_0xcc9b('0x3f')]=_[_0xcc9b('0x42')](_0x563cd7[_0xcc9b('0x3f')],{'$or':_[_0xcc9b('0x43')](_0x9e6bf9,function(_0x868226){if(_0x868226[_0xcc9b('0x32')]!==_0xcc9b('0x44')){var _0x2d2c7e={};_0x2d2c7e[_0x868226[_0xcc9b('0x2e')]]={'$like':'%'+_0x3318ac[_0xcc9b('0x35')][_0xcc9b('0x41')]+'%'};return _0x2d2c7e;}})});}_0x563cd7=_[_0xcc9b('0x42')]({},_0x563cd7,_0x3318ac['options']);var _0x56def0={'where':_0x563cd7[_0xcc9b('0x3f')]};return db[_0xcc9b('0x30')][_0xcc9b('0x21')](_0x56def0)['then'](function(_0x3c99da){_0x3ddefe[_0xcc9b('0x21')]=_0x3c99da;if(_0x3318ac[_0xcc9b('0x35')][_0xcc9b('0x45')]){_0x563cd7[_0xcc9b('0x46')]=[{'all':!![]}];}return db[_0xcc9b('0x30')]['findAll'](_0x563cd7);})[_0xcc9b('0x28')](function(_0x146aa1){_0x3ddefe[_0xcc9b('0x47')]=_0x146aa1;return _0x3ddefe;})[_0xcc9b('0x28')](respondWithFilteredResult(_0x226308,_0x563cd7))[_0xcc9b('0x48')](handleError(_0x226308,null));};exports[_0xcc9b('0x49')]=function(_0x57f167,_0x2ac83c){var _0xc9a2e9={'raw':!![],'where':{'id':_0x57f167[_0xcc9b('0x4a')]['id']}},_0x56df0a={};_0x56df0a[_0xcc9b('0x34')]=_[_0xcc9b('0x4b')](db[_0xcc9b('0x30')][_0xcc9b('0x4c')]);_0x56df0a[_0xcc9b('0x35')]=_['keys'](_0x57f167[_0xcc9b('0x35')]);_0x56df0a[_0xcc9b('0x36')]=_[_0xcc9b('0x37')](_0x56df0a[_0xcc9b('0x34')],_0x56df0a[_0xcc9b('0x35')]);_0xc9a2e9['attributes']=_['intersection'](_0x56df0a[_0xcc9b('0x34')],qs[_0xcc9b('0x39')](_0x57f167[_0xcc9b('0x35')][_0xcc9b('0x39')]));_0xc9a2e9['attributes']=_0xc9a2e9['attributes']['length']?_0xc9a2e9[_0xcc9b('0x38')]:_0x56df0a[_0xcc9b('0x34')];if(_0x57f167[_0xcc9b('0x35')][_0xcc9b('0x45')]){_0xc9a2e9[_0xcc9b('0x46')]=[{'all':!![]}];}_0xc9a2e9=_[_0xcc9b('0x42')]({},_0xc9a2e9,_0x57f167[_0xcc9b('0x4d')]);return db[_0xcc9b('0x30')][_0xcc9b('0x4e')](_0xc9a2e9)[_0xcc9b('0x28')](handleEntityNotFound(_0x2ac83c,null))[_0xcc9b('0x28')](respondWithResult(_0x2ac83c,null))[_0xcc9b('0x48')](handleError(_0x2ac83c,null));};exports[_0xcc9b('0x4f')]=function(_0xc6918c,_0x1e092a){return db[_0xcc9b('0x30')][_0xcc9b('0x4f')](_0xc6918c[_0xcc9b('0x50')],{})[_0xcc9b('0x28')](function(_0x19bf5b){var _0x2f7abc=_0xc6918c[_0xcc9b('0x51')][_0xcc9b('0x52')]({'plain':!![]});if(!_0x2f7abc)throw new Error(_0xcc9b('0x53'));if(_0x2f7abc[_0xcc9b('0x54')]===_0xcc9b('0x51')){var _0x1de976=_0x19bf5b[_0xcc9b('0x52')]({'plain':!![]});var _0x27bbb4=_0xcc9b('0x55');return db[_0xcc9b('0x56')][_0xcc9b('0x4e')]({'where':{'name':_0x27bbb4,'userProfileId':_0x2f7abc[_0xcc9b('0x57')]},'raw':!![]})[_0xcc9b('0x28')](function(_0x2a67ff){if(_0x2a67ff&&_0x2a67ff[_0xcc9b('0x58')]===0x0){return db['UserProfileResource'][_0xcc9b('0x4f')]({'name':_0x1de976[_0xcc9b('0x2e')],'resourceId':_0x1de976['id'],'type':_0x2a67ff[_0xcc9b('0x2e')],'sectionId':_0x2a67ff['id']},{})[_0xcc9b('0x28')](function(){return _0x19bf5b;});}else{return _0x19bf5b;}})[_0xcc9b('0x48')](function(_0x261c6b){logger[_0xcc9b('0x2c')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x261c6b);throw _0x261c6b;});}return _0x19bf5b;})[_0xcc9b('0x28')](respondWithResult(_0x1e092a,0xc9))[_0xcc9b('0x48')](handleError(_0x1e092a,null));};exports[_0xcc9b('0x27')]=function(_0x189b31,_0x4a1530){if(_0x189b31[_0xcc9b('0x50')]['id']){delete _0x189b31[_0xcc9b('0x50')]['id'];}return db[_0xcc9b('0x30')][_0xcc9b('0x4e')]({'where':{'id':_0x189b31['params']['id']}})['then'](handleEntityNotFound(_0x4a1530,null))[_0xcc9b('0x28')](saveUpdates(_0x189b31[_0xcc9b('0x50')],null))['then'](respondWithResult(_0x4a1530,null))['catch'](handleError(_0x4a1530,null));};exports[_0xcc9b('0x29')]=function(_0x2864d7,_0x4b60bb){return db[_0xcc9b('0x30')][_0xcc9b('0x4e')]({'where':{'id':_0x2864d7[_0xcc9b('0x4a')]['id']}})[_0xcc9b('0x28')](handleEntityNotFound(_0x4b60bb,null))['then'](removeEntity(_0x4b60bb,null))['catch'](handleError(_0x4b60bb,null));};exports['describe']=function(_0x25a811,_0x16f278){return db[_0xcc9b('0x30')]['describe']()['then'](respondWithResult(_0x16f278,null))[_0xcc9b('0x48')](handleError(_0x16f278,null));};exports[_0xcc9b('0x59')]=function(_0x146e98,_0x2890fa,_0x444051){var _0x19cfdc={'raw':!![],'where':{}},_0x1e8dea={},_0xaf5f1e;return db[_0xcc9b('0x30')]['findOne']({'where':{'id':_0x146e98[_0xcc9b('0x4a')]['id']}})[_0xcc9b('0x28')](handleEntityNotFound(_0x2890fa,null))[_0xcc9b('0x28')](function(_0x33a2ad){if(_0x33a2ad){_0xaf5f1e=_0x33a2ad['get']({'plain':!![]});_0x1e8dea[_0xcc9b('0x34')]=_['keys'](db[_0xcc9b('0x5a')][_0xcc9b('0x4c')]);_0x1e8dea[_0xcc9b('0x35')]=_['keys'](_0x146e98[_0xcc9b('0x35')]);_0x1e8dea['filters']=_[_0xcc9b('0x37')](_0x1e8dea['model'],_0x1e8dea[_0xcc9b('0x35')]);_0x19cfdc[_0xcc9b('0x38')]=_[_0xcc9b('0x37')](_0x1e8dea[_0xcc9b('0x34')],qs[_0xcc9b('0x39')](_0x146e98[_0xcc9b('0x35')][_0xcc9b('0x39')]));_0x19cfdc['attributes']=_0x19cfdc[_0xcc9b('0x38')][_0xcc9b('0x3a')]?_0x19cfdc[_0xcc9b('0x38')]:_0x1e8dea[_0xcc9b('0x34')];if(!_0x146e98[_0xcc9b('0x35')][_0xcc9b('0x3b')](_0xcc9b('0x3c'))){_0x19cfdc[_0xcc9b('0x22')]=qs[_0xcc9b('0x22')](_0x146e98['query'][_0xcc9b('0x22')]);_0x19cfdc['offset']=qs[_0xcc9b('0x1f')](_0x146e98[_0xcc9b('0x35')][_0xcc9b('0x1f')]);}_0x19cfdc[_0xcc9b('0x3d')]=qs[_0xcc9b('0x3e')](_0x146e98[_0xcc9b('0x35')][_0xcc9b('0x3e')]);_0x19cfdc['where']=qs[_0xcc9b('0x36')](_[_0xcc9b('0x40')](_0x146e98[_0xcc9b('0x35')],_0x1e8dea[_0xcc9b('0x36')]));_0x19cfdc[_0xcc9b('0x3f')][_0xcc9b('0x5b')]=_0x33a2ad['id'];if(_0x146e98['query'][_0xcc9b('0x41')]){_0x19cfdc[_0xcc9b('0x3f')]=_[_0xcc9b('0x42')](_0x19cfdc[_0xcc9b('0x3f')],{'$or':_['map'](_0x19cfdc[_0xcc9b('0x38')],function(_0x5218a9){var _0x3aa17d={};_0x3aa17d[_0x5218a9]={'$like':'%'+_0x146e98[_0xcc9b('0x35')][_0xcc9b('0x41')]+'%'};return _0x3aa17d;})});}_0x19cfdc=_[_0xcc9b('0x42')]({},_0x19cfdc,_0x146e98['options']);return db[_0xcc9b('0x5a')][_0xcc9b('0x5c')](_0x19cfdc);}})[_0xcc9b('0x28')](function(_0x1f1ff1){if(_0x1f1ff1){return db['User']['findAndCountAll']({'where':{'id':_['map'](_0x1f1ff1,_0xcc9b('0x5d')),'role':_0xcc9b('0x5e')},'attributes':['id','name',_0xcc9b('0x5f'),_0xcc9b('0x60'),_0xcc9b('0x61')]});}})[_0xcc9b('0x28')](function(_0x42cd4b){if(_0x42cd4b){return{'count':_0x42cd4b[_0xcc9b('0x21')],'rows':_[_0xcc9b('0x43')](_0x42cd4b[_0xcc9b('0x47')],function(_0x3b9b90){return{'membername':_0x3b9b90[_0xcc9b('0x2e')],'UserId':_0x3b9b90['id'],'queue_name':_0xaf5f1e[_0xcc9b('0x2e')],'OpenchannelQueueId':_0xaf5f1e['id'],'interface':util[_0xcc9b('0x62')](_0xcc9b('0x63'),'SIP',_0x3b9b90[_0xcc9b('0x2e')]),'penalty':0x0,'paused':_0x3b9b90[_0xcc9b('0x5f')],'createdAt':_0x3b9b90[_0xcc9b('0x61')],'updatedAt':_0x3b9b90['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x2890fa,_0x19cfdc))[_0xcc9b('0x48')](handleError(_0x2890fa,null));};exports[_0xcc9b('0x64')]=function(_0x2811dd,_0x1d4053,_0x34ebd5){var _0x10ed3b={};var _0x57ddcf={};var _0x455619;var _0x38fce2;return db[_0xcc9b('0x30')][_0xcc9b('0x65')]({'where':{'id':_0x2811dd[_0xcc9b('0x4a')]['id']}})[_0xcc9b('0x28')](handleEntityNotFound(_0x1d4053,null))['then'](function(_0x4c7988){if(_0x4c7988){_0x455619=_0x4c7988;_0x57ddcf['model']=_['keys'](db['Team']['rawAttributes']);_0x57ddcf['query']=_[_0xcc9b('0x4b')](_0x2811dd[_0xcc9b('0x35')]);_0x57ddcf['filters']=_[_0xcc9b('0x37')](_0x57ddcf[_0xcc9b('0x34')],_0x57ddcf[_0xcc9b('0x35')]);_0x10ed3b[_0xcc9b('0x38')]=_['intersection'](_0x57ddcf['model'],qs['fields'](_0x2811dd[_0xcc9b('0x35')][_0xcc9b('0x39')]));_0x10ed3b[_0xcc9b('0x38')]=_0x10ed3b[_0xcc9b('0x38')][_0xcc9b('0x3a')]?_0x10ed3b['attributes']:_0x57ddcf[_0xcc9b('0x34')];_0x10ed3b[_0xcc9b('0x3d')]=qs[_0xcc9b('0x3e')](_0x2811dd['query'][_0xcc9b('0x3e')]);_0x10ed3b[_0xcc9b('0x3f')]=qs[_0xcc9b('0x36')](_[_0xcc9b('0x40')](_0x2811dd[_0xcc9b('0x35')],_0x57ddcf[_0xcc9b('0x36')]));if(_0x2811dd[_0xcc9b('0x35')]['filter']){_0x10ed3b[_0xcc9b('0x3f')]=_[_0xcc9b('0x42')](_0x10ed3b[_0xcc9b('0x3f')],{'$or':_[_0xcc9b('0x43')](_0x10ed3b[_0xcc9b('0x38')],function(_0x531f22){var _0x23285f={};_0x23285f[_0x531f22]={'$like':'%'+_0x2811dd['query']['filter']+'%'};return _0x23285f;})});}_0x10ed3b=_[_0xcc9b('0x42')]({},_0x10ed3b,_0x2811dd[_0xcc9b('0x4d')]);return _0x455619[_0xcc9b('0x64')](_0x10ed3b);}})[_0xcc9b('0x28')](function(_0x44c597){if(_0x44c597){_0x38fce2=_0x44c597[_0xcc9b('0x3a')];if(!_0x2811dd[_0xcc9b('0x35')][_0xcc9b('0x3b')](_0xcc9b('0x3c'))){_0x10ed3b[_0xcc9b('0x22')]=qs['limit'](_0x2811dd['query'][_0xcc9b('0x22')]);_0x10ed3b[_0xcc9b('0x1f')]=qs[_0xcc9b('0x1f')](_0x2811dd[_0xcc9b('0x35')]['offset']);}return _0x455619[_0xcc9b('0x64')](_0x10ed3b);}})[_0xcc9b('0x28')](function(_0x4fdd7d){if(_0x4fdd7d){return _0x4fdd7d?{'count':_0x38fce2,'rows':_0x4fdd7d}:null;}})['then'](respondWithResult(_0x1d4053,null))['catch'](handleError(_0x1d4053,null));};exports[_0xcc9b('0x66')]=function(_0x149a72,_0x214c5c,_0x349958){var _0x1c978=_0x149a72[_0xcc9b('0x50')]['ids'];return db['Team'][_0xcc9b('0x5c')]({'where':{'id':_0x1c978},'attributes':['id'],'include':[{'model':db[_0xcc9b('0x67')],'as':'Agents','attributes':['id','name',_0xcc9b('0x68'),_0xcc9b('0x69'),_0xcc9b('0x6a')],'raw':!![]}]})[_0xcc9b('0x28')](function(_0x3073ca){if(_0x3073ca){var _0x3e0ea2=_[_0xcc9b('0x6b')](_0x3073ca,function(_0x3f5519){var _0x2390d1=_0x3f5519['get']({'plain':!![]});return _0x2390d1[_0xcc9b('0x6c')];});return db['OpenchannelQueue'][_0xcc9b('0x4e')]({'where':{'id':_0x149a72[_0xcc9b('0x4a')]['id']}})['then'](function(_0x326432){return db[_0xcc9b('0x6d')][_0xcc9b('0x6e')](function(_0x4a821c){return _0x326432[_0xcc9b('0x66')](_0x1c978,{'transaction':_0x4a821c})[_0xcc9b('0x28')](function(){return BPromise[_0xcc9b('0x6f')](_0x3e0ea2,function(_0xc8c2e8){return db[_0xcc9b('0x5a')][_0xcc9b('0x70')]({'where':{'UserId':_0xc8c2e8['id'],'OpenchannelQueueId':_0x149a72[_0xcc9b('0x4a')]['id']},'transaction':_0x4a821c});});})['then'](function(){_0x3e0ea2[_0xcc9b('0x71')](function(_0x55f9e9){socket[_0xcc9b('0x72')](_0xcc9b('0x73'),{'UserId':_0x55f9e9['id'],'OpenchannelQueueId':_0x326432['id']});});});});});}})[_0xcc9b('0x28')](respondWithStatusCode(_0x214c5c,null))[_0xcc9b('0x48')](handleError(_0x214c5c,null));};exports['removeTeams']=function(_0x5e3462,_0x177240,_0x4cf3a3){return db['Team']['findAll']({'where':{'id':_0x5e3462[_0xcc9b('0x35')][_0xcc9b('0x74')]},'attributes':['id'],'include':[{'model':db[_0xcc9b('0x67')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xcc9b('0x28')](handleEntityNotFound(_0x177240,null))[_0xcc9b('0x28')](function(_0x3a67a1){var _0x3448a9=_[_0xcc9b('0x43')](_0x3a67a1,'id');var _0x10ed4a=[];var _0x3dee10=[];var _0x39bee7=squel['select']();_0x39bee7[_0xcc9b('0x75')]('tq.TeamId')[_0xcc9b('0x76')](_0xcc9b('0x77'),'tq')[_0xcc9b('0x78')]('user_has_teams','ut',_0xcc9b('0x79'))['where'](_0xcc9b('0x7a'),_0x5e3462['params']['id']);for(var _0x5a52fc=0x0;_0x5a52fc<_0x3a67a1['length'];_0x5a52fc+=0x1){let _0x2c89f7=_0x3a67a1[_0x5a52fc];for(var _0x9c4d2e=0x0;_0x9c4d2e<_0x2c89f7['Agents'][_0xcc9b('0x3a')];_0x9c4d2e+=0x1){let _0x23f3e2=_0x2c89f7[_0xcc9b('0x6c')][_0x9c4d2e];var _0xc7d874=_0x39bee7[_0xcc9b('0x7b')]();_0xc7d874[_0xcc9b('0x3f')](_0xcc9b('0x7c'),_0x23f3e2['id']);_0x3dee10['push'](db[_0xcc9b('0x6d')][_0xcc9b('0x35')](_0xc7d874[_0xcc9b('0x7d')](),{'type':db[_0xcc9b('0x6d')][_0xcc9b('0x7e')][_0xcc9b('0x7f')]})[_0xcc9b('0x28')](function(_0x4a4735){if(_0x4a4735[_0xcc9b('0x3a')]===0x1){return _0x23f3e2['id'];}else{var _0x4a1cc1=_[_0xcc9b('0x80')](_[_0xcc9b('0x43')](_0x4a4735,_0xcc9b('0x81')),function(_0x232747){return _[_0xcc9b('0x82')](_0x3448a9,_0x232747);});if(_0x4a1cc1){return _0x23f3e2['id'];}}}));}}return BPromise[_0xcc9b('0x83')](_0x3dee10)[_0xcc9b('0x28')](function(_0x19ee2c){_0x10ed4a=_(_0x10ed4a)[_0xcc9b('0x84')](_0x19ee2c)[_0xcc9b('0x85')]()[_0xcc9b('0x86')]();return db[_0xcc9b('0x30')]['find']({'where':{'id':_0x5e3462[_0xcc9b('0x4a')]['id']}})[_0xcc9b('0x28')](function(_0xad1cee){return db[_0xcc9b('0x6d')]['transaction'](function(_0x2972e0){return _0xad1cee['removeTeams'](_0x5e3462[_0xcc9b('0x35')][_0xcc9b('0x74')],{'transaction':_0x2972e0})[_0xcc9b('0x28')](function(){if(!_[_0xcc9b('0x87')](_0x10ed4a)){return _0xad1cee['removeAgents'](_0x10ed4a,{'transaction':_0x2972e0});}})[_0xcc9b('0x28')](function(){_0x10ed4a[_0xcc9b('0x71')](function(_0x201148){socket[_0xcc9b('0x72')](_0xcc9b('0x88'),{'UserId':_0x201148,'OpenchannelQueueId':_0xad1cee['id']});});});});});});})[_0xcc9b('0x28')](respondWithStatusCode(_0x177240,null))['catch'](handleError(_0x177240,null));};exports[_0xcc9b('0x89')]=function(_0x165653,_0x5ac486,_0x3fc04a){return db['OpenchannelQueue']['find']({'where':{'id':_0x165653[_0xcc9b('0x4a')]['id']}})[_0xcc9b('0x28')](handleEntityNotFound(_0x5ac486,null))['then'](function(_0x1c66e7){if(_0x1c66e7){return _0x1c66e7['addAgents'](_0x165653['body'][_0xcc9b('0x74')],_['omit'](_0x165653[_0xcc9b('0x50')],[_0xcc9b('0x74'),'id'])||{})[_0xcc9b('0x8a')](function(_0x12f8e4){for(var _0x159865=0x0;_0x159865<_0x165653[_0xcc9b('0x50')][_0xcc9b('0x74')]['length'];_0x159865+=0x1){socket[_0xcc9b('0x72')](_0xcc9b('0x73'),{'UserId':Number(_0x165653[_0xcc9b('0x50')][_0xcc9b('0x74')][_0x159865]),'OpenchannelQueueId':Number(_0x165653[_0xcc9b('0x4a')]['id'])});}return _0x12f8e4;});}})[_0xcc9b('0x28')](respondWithResult(_0x5ac486,null))[_0xcc9b('0x48')](handleError(_0x5ac486,null));};exports[_0xcc9b('0x8b')]=function(_0x2d68f0,_0x413b02,_0x218b76){return db['OpenchannelQueue'][_0xcc9b('0x4e')]({'where':{'id':_0x2d68f0[_0xcc9b('0x4a')]['id']}})[_0xcc9b('0x28')](handleEntityNotFound(_0x413b02,null))[_0xcc9b('0x28')](function(_0x39469a){if(_0x39469a){return _0x39469a[_0xcc9b('0x8b')](_0x2d68f0[_0xcc9b('0x35')][_0xcc9b('0x74')])[_0xcc9b('0x28')](function(){if(_['isArray'](_0x2d68f0[_0xcc9b('0x35')][_0xcc9b('0x74')])){for(var _0x32332c=0x0;_0x32332c<_0x2d68f0['query']['ids'][_0xcc9b('0x3a')];_0x32332c+=0x1){socket[_0xcc9b('0x72')]('userOpenchannelQueue:remove',{'UserId':Number(_0x2d68f0[_0xcc9b('0x35')][_0xcc9b('0x74')][_0x32332c]),'OpenchannelQueueId':Number(_0x2d68f0[_0xcc9b('0x4a')]['id'])});}}else{socket[_0xcc9b('0x72')](_0xcc9b('0x88'),{'UserId':Number(_0x2d68f0[_0xcc9b('0x35')]['ids']),'OpenchannelQueueId':Number(_0x2d68f0[_0xcc9b('0x4a')]['id'])});}});}})[_0xcc9b('0x28')](respondWithStatusCode(_0x413b02,null))[_0xcc9b('0x48')](handleError(_0x413b02,null));};exports[_0xcc9b('0x8c')]=function(_0x8516d8,_0x3a0cb2,_0x5b3a39){var _0x3e5ada={};var _0x5d6c11={};var _0x4c282a;var _0x4c9445;return db[_0xcc9b('0x30')]['findOne']({'where':{'id':_0x8516d8[_0xcc9b('0x4a')]['id']}})[_0xcc9b('0x28')](handleEntityNotFound(_0x3a0cb2,null))[_0xcc9b('0x28')](function(_0x3799c7){if(_0x3799c7){_0x4c282a=_0x3799c7;_0x5d6c11[_0xcc9b('0x34')]=_['keys'](db[_0xcc9b('0x67')][_0xcc9b('0x4c')]);_0x5d6c11[_0xcc9b('0x35')]=_[_0xcc9b('0x4b')](_0x8516d8[_0xcc9b('0x35')]);_0x5d6c11['filters']=_[_0xcc9b('0x37')](_0x5d6c11[_0xcc9b('0x34')],_0x5d6c11[_0xcc9b('0x35')]);_0x3e5ada[_0xcc9b('0x38')]=_[_0xcc9b('0x37')](_0x5d6c11[_0xcc9b('0x34')],qs[_0xcc9b('0x39')](_0x8516d8[_0xcc9b('0x35')]['fields']));_0x3e5ada[_0xcc9b('0x38')]=_0x3e5ada['attributes'][_0xcc9b('0x3a')]?_0x3e5ada[_0xcc9b('0x38')]:_0x5d6c11['model'];_0x3e5ada[_0xcc9b('0x3d')]=qs[_0xcc9b('0x3e')](_0x8516d8[_0xcc9b('0x35')]['sort']);_0x3e5ada[_0xcc9b('0x3f')]=qs[_0xcc9b('0x36')](_['pick'](_0x8516d8[_0xcc9b('0x35')],_0x5d6c11[_0xcc9b('0x36')]));if(_0x8516d8['query']['filter']){_0x3e5ada[_0xcc9b('0x3f')]=_['merge'](_0x3e5ada[_0xcc9b('0x3f')],{'$or':_[_0xcc9b('0x43')](_0x3e5ada[_0xcc9b('0x38')],function(_0x3054cb){var _0x527555={};_0x527555[_0x3054cb]={'$like':'%'+_0x8516d8[_0xcc9b('0x35')][_0xcc9b('0x41')]+'%'};return _0x527555;})});}_0x3e5ada=_['merge']({},_0x3e5ada,_0x8516d8[_0xcc9b('0x4d')]);return _0x4c282a[_0xcc9b('0x8c')](_0x3e5ada);}})[_0xcc9b('0x28')](function(_0x52e0e0){if(_0x52e0e0){_0x4c9445=_0x52e0e0[_0xcc9b('0x3a')];if(!_0x8516d8['query'][_0xcc9b('0x3b')]('nolimit')){_0x3e5ada['limit']=qs[_0xcc9b('0x22')](_0x8516d8[_0xcc9b('0x35')][_0xcc9b('0x22')]);_0x3e5ada[_0xcc9b('0x1f')]=qs[_0xcc9b('0x1f')](_0x8516d8[_0xcc9b('0x35')][_0xcc9b('0x1f')]);}return _0x4c282a[_0xcc9b('0x8c')](_0x3e5ada);}})['then'](function(_0x30de41){if(_0x30de41){return _0x30de41?{'count':_0x4c9445,'rows':_0x30de41}:null;}})[_0xcc9b('0x28')](respondWithResult(_0x3a0cb2,null))[_0xcc9b('0x48')](handleError(_0x3a0cb2,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