Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index f48c988..f4b6db5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x065c=['ids','Team','Agents','interface','flatMap','sequelize','each','findOrCreate','userOpenchannelQueue:save','removeTeams','select','tq.TeamId','from','team_has_openchannel_queues','join','OpenchannelQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','QueryTypes','every','TeamId','all','union','compact','value','isEmpty','removeAgents','emit','userOpenchannelQueue:remove','addAgents','omit','spread','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','squel','crypto','jsforce','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./openchannelQueue.socket','register','sendStatus','status','count','offset','limit','set','Content-Range','apply','update','then','UserProfileResource','destroy','end','error','stack','name','map','OpenchannelQueue','type','query','keys','filters','intersection','model','fields','attributes','hasOwnProperty','order','sort','where','pick','merge','VIRTUAL','filter','includeAll','include','findAll','rows','catch','show','params','rawAttributes','length','options','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','OpenchannelQueues','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','get','UserOpenchannelQueue','OpenchannelQueueId','User','findAndCountAll','UserId','agent','openchannelPause','updatedAt','SIP','getTeams','addTeams'];(function(_0x28509b,_0x5831ff){var _0x1e0b6=function(_0x37d8a2){while(--_0x37d8a2){_0x28509b['push'](_0x28509b['shift']());}};_0x1e0b6(++_0x5831ff);}(_0x065c,0xa9));var _0xc065=function(_0x173113,_0x316a7c){_0x173113=_0x173113-0x0;var _0x3bea89=_0x065c[_0x173113];return _0x3bea89;};'use strict';var pdf=require(_0xc065('0x0'));var emlformat=require(_0xc065('0x1'));var rimraf=require(_0xc065('0x2'));var zipdir=require(_0xc065('0x3'));var jsonpatch=require(_0xc065('0x4'));var rp=require(_0xc065('0x5'));var moment=require(_0xc065('0x6'));var BPromise=require(_0xc065('0x7'));var Mustache=require(_0xc065('0x8'));var util=require(_0xc065('0x9'));var path=require(_0xc065('0xa'));var sox=require(_0xc065('0xb'));var csv=require(_0xc065('0xc'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xc065('0xd'));var crypto=require(_0xc065('0xe'));var jsforce=require(_0xc065('0xf'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xc065('0x10'));var Redis=require(_0xc065('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xc065('0x12'));var as=require(_0xc065('0x13'));var hardwareService=require(_0xc065('0x14'));var logger=require('../../config/logger')(_0xc065('0x15'));var utils=require(_0xc065('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xc065('0x17'));var db=require(_0xc065('0x18'))['db'];config[_0xc065('0x19')]=_['defaults'](config[_0xc065('0x19')],{'host':_0xc065('0x1a'),'port':0x18eb});var socket=require(_0xc065('0x1b'))(new Redis(config[_0xc065('0x19')]));require(_0xc065('0x1c'))[_0xc065('0x1d')](socket);function respondWithStatusCode(_0x177bb5,_0x84d888){_0x84d888=_0x84d888||0xcc;return function(_0x4c50a2){if(_0x4c50a2){return _0x177bb5[_0xc065('0x1e')](_0x84d888);}return _0x177bb5[_0xc065('0x1f')](_0x84d888)['end']();};}function respondWithResult(_0x4a7c02,_0x26cf0e){_0x26cf0e=_0x26cf0e||0xc8;return function(_0x34dcf9){if(_0x34dcf9){return _0x4a7c02[_0xc065('0x1f')](_0x26cf0e)['json'](_0x34dcf9);}};}function respondWithFilteredResult(_0x8502aa,_0x391f3e){return function(_0x27cf59){if(_0x27cf59){var _0x5863b8=_0x27cf59[_0xc065('0x20')],_0x58276c=_0x391f3e['offset'],_0xd9ce9e=_0x391f3e[_0xc065('0x21')]+_0x391f3e[_0xc065('0x22')],_0x2e7c04;if(_0xd9ce9e>=_0x5863b8){_0xd9ce9e=_0x5863b8;_0x2e7c04=0xc8;}else{_0x2e7c04=0xce;}_0x8502aa[_0xc065('0x1f')](_0x2e7c04);return _0x8502aa[_0xc065('0x23')](_0xc065('0x24'),_0x58276c+'-'+_0xd9ce9e+'/'+_0x5863b8)['json'](_0x27cf59);}return null;};}function patchUpdates(_0x393601){return function(_0x44e2ed){try{jsonpatch[_0xc065('0x25')](_0x44e2ed,_0x393601,!![]);}catch(_0x144f1b){return BPromise['reject'](_0x144f1b);}return _0x44e2ed['save']();};}function saveUpdates(_0x3306fc,_0x54a91c){return function(_0x5af6db){if(_0x5af6db){return _0x5af6db[_0xc065('0x26')](_0x3306fc)[_0xc065('0x27')](function(_0x423598){return _0x423598;});}return null;};}function removeEntity(_0x146f36,_0x4d3595){return function(_0x417946){if(_0x417946){return _0x417946['destroy']()['then'](function(){var _0x258499=_0x417946['get']({'plain':!![]});var _0x49d101='OpenchannelQueues';return db[_0xc065('0x28')][_0xc065('0x29')]({'where':{'type':_0x49d101,'resourceId':_0x258499['id']}})[_0xc065('0x27')](function(){return _0x417946;});})[_0xc065('0x27')](function(){_0x146f36[_0xc065('0x1f')](0xcc)[_0xc065('0x2a')]();});}};}function handleEntityNotFound(_0x14c4d0,_0x429795){return function(_0x48fd6a){if(!_0x48fd6a){_0x14c4d0[_0xc065('0x1e')](0x194);}return _0x48fd6a;};}function handleError(_0x3f2cad,_0x2b94b1){_0x2b94b1=_0x2b94b1||0x1f4;return function(_0x10908c){logger[_0xc065('0x2b')](_0x10908c[_0xc065('0x2c')]);if(_0x10908c[_0xc065('0x2d')]){delete _0x10908c[_0xc065('0x2d')];}_0x3f2cad['status'](_0x2b94b1)['send'](_0x10908c);};}exports['index']=function(_0x544b4c,_0x31f223){var _0x58c001={},_0x10bf08={},_0x1745bc={'count':0x0,'rows':[]};var _0x37c2ac=_[_0xc065('0x2e')](db[_0xc065('0x2f')]['rawAttributes'],function(_0x19b845){return{'name':_0x19b845['fieldName'],'type':_0x19b845[_0xc065('0x30')]['key']};});_0x10bf08['model']=_[_0xc065('0x2e')](_0x37c2ac,'name');_0x10bf08[_0xc065('0x31')]=_[_0xc065('0x32')](_0x544b4c[_0xc065('0x31')]);_0x10bf08[_0xc065('0x33')]=_['intersection'](_0x10bf08['model'],_0x10bf08[_0xc065('0x31')]);_0x58c001['attributes']=_[_0xc065('0x34')](_0x10bf08[_0xc065('0x35')],qs[_0xc065('0x36')](_0x544b4c['query'][_0xc065('0x36')]));_0x58c001['attributes']=_0x58c001[_0xc065('0x37')]['length']?_0x58c001[_0xc065('0x37')]:_0x10bf08[_0xc065('0x35')];if(!_0x544b4c[_0xc065('0x31')][_0xc065('0x38')]('nolimit')){_0x58c001['limit']=qs[_0xc065('0x22')](_0x544b4c[_0xc065('0x31')][_0xc065('0x22')]);_0x58c001['offset']=qs['offset'](_0x544b4c['query'][_0xc065('0x21')]);}_0x58c001[_0xc065('0x39')]=qs[_0xc065('0x3a')](_0x544b4c[_0xc065('0x31')][_0xc065('0x3a')]);_0x58c001[_0xc065('0x3b')]=qs[_0xc065('0x33')](_[_0xc065('0x3c')](_0x544b4c[_0xc065('0x31')],_0x10bf08['filters']),_0x37c2ac);if(_0x544b4c[_0xc065('0x31')]['filter']){_0x58c001[_0xc065('0x3b')]=_[_0xc065('0x3d')](_0x58c001['where'],{'$or':_[_0xc065('0x2e')](_0x37c2ac,function(_0x106e55){if(_0x106e55[_0xc065('0x30')]!==_0xc065('0x3e')){var _0x4a36c3={};_0x4a36c3[_0x106e55[_0xc065('0x2d')]]={'$like':'%'+_0x544b4c[_0xc065('0x31')][_0xc065('0x3f')]+'%'};return _0x4a36c3;}})});}_0x58c001=_[_0xc065('0x3d')]({},_0x58c001,_0x544b4c['options']);var _0x2bb06f={'where':_0x58c001['where']};return db[_0xc065('0x2f')][_0xc065('0x20')](_0x2bb06f)[_0xc065('0x27')](function(_0xeefe3d){_0x1745bc[_0xc065('0x20')]=_0xeefe3d;if(_0x544b4c[_0xc065('0x31')][_0xc065('0x40')]){_0x58c001[_0xc065('0x41')]=[{'all':!![]}];}return db['OpenchannelQueue'][_0xc065('0x42')](_0x58c001);})[_0xc065('0x27')](function(_0x3eb2c1){_0x1745bc[_0xc065('0x43')]=_0x3eb2c1;return _0x1745bc;})['then'](respondWithFilteredResult(_0x31f223,_0x58c001))[_0xc065('0x44')](handleError(_0x31f223,null));};exports[_0xc065('0x45')]=function(_0x12f259,_0x59c18d){var _0x40ee91={'raw':!![],'where':{'id':_0x12f259[_0xc065('0x46')]['id']}},_0x35804d={};_0x35804d[_0xc065('0x35')]=_[_0xc065('0x32')](db[_0xc065('0x2f')][_0xc065('0x47')]);_0x35804d[_0xc065('0x31')]=_['keys'](_0x12f259['query']);_0x35804d['filters']=_[_0xc065('0x34')](_0x35804d[_0xc065('0x35')],_0x35804d['query']);_0x40ee91[_0xc065('0x37')]=_['intersection'](_0x35804d[_0xc065('0x35')],qs['fields'](_0x12f259[_0xc065('0x31')][_0xc065('0x36')]));_0x40ee91[_0xc065('0x37')]=_0x40ee91[_0xc065('0x37')][_0xc065('0x48')]?_0x40ee91[_0xc065('0x37')]:_0x35804d['model'];if(_0x12f259['query'][_0xc065('0x40')]){_0x40ee91[_0xc065('0x41')]=[{'all':!![]}];}_0x40ee91=_[_0xc065('0x3d')]({},_0x40ee91,_0x12f259[_0xc065('0x49')]);return db[_0xc065('0x2f')][_0xc065('0x4a')](_0x40ee91)['then'](handleEntityNotFound(_0x59c18d,null))[_0xc065('0x27')](respondWithResult(_0x59c18d,null))[_0xc065('0x44')](handleError(_0x59c18d,null));};exports[_0xc065('0x4b')]=function(_0x351410,_0x4cd90d){return db[_0xc065('0x2f')][_0xc065('0x4b')](_0x351410[_0xc065('0x4c')],{})['then'](function(_0x5bf228){var _0x47489a=_0x351410['user']['get']({'plain':!![]});if(!_0x47489a)throw new Error(_0xc065('0x4d'));if(_0x47489a[_0xc065('0x4e')]===_0xc065('0x4f')){var _0x49afa6=_0x5bf228['get']({'plain':!![]});var _0x41f75c=_0xc065('0x50');return db[_0xc065('0x51')][_0xc065('0x4a')]({'where':{'name':_0x41f75c,'userProfileId':_0x47489a[_0xc065('0x52')]},'raw':!![]})[_0xc065('0x27')](function(_0x382881){if(_0x382881&&_0x382881[_0xc065('0x53')]===0x0){return db[_0xc065('0x28')][_0xc065('0x4b')]({'name':_0x49afa6[_0xc065('0x2d')],'resourceId':_0x49afa6['id'],'type':_0x382881[_0xc065('0x2d')],'sectionId':_0x382881['id']},{})[_0xc065('0x27')](function(){return _0x5bf228;});}else{return _0x5bf228;}})[_0xc065('0x44')](function(_0x2b89f7){logger[_0xc065('0x2b')](_0xc065('0x54'),_0x2b89f7);throw _0x2b89f7;});}return _0x5bf228;})['then'](respondWithResult(_0x4cd90d,0xc9))['catch'](handleError(_0x4cd90d,null));};exports[_0xc065('0x26')]=function(_0x35482b,_0x18f03f){if(_0x35482b[_0xc065('0x4c')]['id']){delete _0x35482b[_0xc065('0x4c')]['id'];}return db[_0xc065('0x2f')][_0xc065('0x4a')]({'where':{'id':_0x35482b[_0xc065('0x46')]['id']}})[_0xc065('0x27')](handleEntityNotFound(_0x18f03f,null))[_0xc065('0x27')](saveUpdates(_0x35482b['body'],null))[_0xc065('0x27')](respondWithResult(_0x18f03f,null))[_0xc065('0x44')](handleError(_0x18f03f,null));};exports[_0xc065('0x29')]=function(_0x2e8b18,_0x394cad){return db[_0xc065('0x2f')][_0xc065('0x4a')]({'where':{'id':_0x2e8b18[_0xc065('0x46')]['id']}})[_0xc065('0x27')](handleEntityNotFound(_0x394cad,null))[_0xc065('0x27')](removeEntity(_0x394cad,null))[_0xc065('0x44')](handleError(_0x394cad,null));};exports['describe']=function(_0x20f90a,_0x1263f8){return db['OpenchannelQueue'][_0xc065('0x55')]()[_0xc065('0x27')](respondWithResult(_0x1263f8,null))[_0xc065('0x44')](handleError(_0x1263f8,null));};exports['getMembers']=function(_0x2138e1,_0x4e57b0,_0x395c9a){var _0x440f1e={'raw':!![],'where':{}},_0x612556={},_0x2a34d5;return db[_0xc065('0x2f')][_0xc065('0x56')]({'where':{'id':_0x2138e1['params']['id']}})[_0xc065('0x27')](handleEntityNotFound(_0x4e57b0,null))[_0xc065('0x27')](function(_0x312d9f){if(_0x312d9f){_0x2a34d5=_0x312d9f[_0xc065('0x57')]({'plain':!![]});_0x612556[_0xc065('0x35')]=_[_0xc065('0x32')](db[_0xc065('0x58')][_0xc065('0x47')]);_0x612556[_0xc065('0x31')]=_[_0xc065('0x32')](_0x2138e1[_0xc065('0x31')]);_0x612556[_0xc065('0x33')]=_[_0xc065('0x34')](_0x612556[_0xc065('0x35')],_0x612556[_0xc065('0x31')]);_0x440f1e[_0xc065('0x37')]=_[_0xc065('0x34')](_0x612556['model'],qs[_0xc065('0x36')](_0x2138e1[_0xc065('0x31')]['fields']));_0x440f1e[_0xc065('0x37')]=_0x440f1e['attributes'][_0xc065('0x48')]?_0x440f1e['attributes']:_0x612556[_0xc065('0x35')];if(!_0x2138e1[_0xc065('0x31')][_0xc065('0x38')]('nolimit')){_0x440f1e['limit']=qs[_0xc065('0x22')](_0x2138e1[_0xc065('0x31')][_0xc065('0x22')]);_0x440f1e[_0xc065('0x21')]=qs['offset'](_0x2138e1[_0xc065('0x31')]['offset']);}_0x440f1e[_0xc065('0x39')]=qs['sort'](_0x2138e1['query'][_0xc065('0x3a')]);_0x440f1e['where']=qs[_0xc065('0x33')](_['pick'](_0x2138e1[_0xc065('0x31')],_0x612556[_0xc065('0x33')]));_0x440f1e[_0xc065('0x3b')][_0xc065('0x59')]=_0x312d9f['id'];if(_0x2138e1[_0xc065('0x31')][_0xc065('0x3f')]){_0x440f1e[_0xc065('0x3b')]=_['merge'](_0x440f1e['where'],{'$or':_['map'](_0x440f1e['attributes'],function(_0x4139ea){var _0x363d74={};_0x363d74[_0x4139ea]={'$like':'%'+_0x2138e1[_0xc065('0x31')]['filter']+'%'};return _0x363d74;})});}_0x440f1e=_[_0xc065('0x3d')]({},_0x440f1e,_0x2138e1[_0xc065('0x49')]);return db[_0xc065('0x58')]['findAll'](_0x440f1e);}})[_0xc065('0x27')](function(_0xd947b6){if(_0xd947b6){return db[_0xc065('0x5a')][_0xc065('0x5b')]({'where':{'id':_['map'](_0xd947b6,_0xc065('0x5c')),'role':_0xc065('0x5d')},'attributes':['id',_0xc065('0x2d'),_0xc065('0x5e'),_0xc065('0x5f'),'createdAt']});}})[_0xc065('0x27')](function(_0x40cd26){if(_0x40cd26){return{'count':_0x40cd26[_0xc065('0x20')],'rows':_['map'](_0x40cd26['rows'],function(_0x77a9f7){return{'membername':_0x77a9f7[_0xc065('0x2d')],'UserId':_0x77a9f7['id'],'queue_name':_0x2a34d5[_0xc065('0x2d')],'OpenchannelQueueId':_0x2a34d5['id'],'interface':util['format']('%s/%s',_0xc065('0x60'),_0x77a9f7['name']),'penalty':0x0,'paused':_0x77a9f7[_0xc065('0x5e')],'createdAt':_0x77a9f7['createdAt'],'updatedAt':_0x77a9f7[_0xc065('0x5f')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xc065('0x27')](respondWithFilteredResult(_0x4e57b0,_0x440f1e))[_0xc065('0x44')](handleError(_0x4e57b0,null));};exports[_0xc065('0x61')]=function(_0x539355,_0x223879,_0x2a8fd1){var _0x18954d={};var _0x52ef0f={};var _0x114cf7;var _0x30a44b;return db[_0xc065('0x2f')][_0xc065('0x56')]({'where':{'id':_0x539355[_0xc065('0x46')]['id']}})['then'](handleEntityNotFound(_0x223879,null))[_0xc065('0x27')](function(_0x2306ff){if(_0x2306ff){_0x114cf7=_0x2306ff;_0x52ef0f[_0xc065('0x35')]=_[_0xc065('0x32')](db['Team'][_0xc065('0x47')]);_0x52ef0f[_0xc065('0x31')]=_[_0xc065('0x32')](_0x539355[_0xc065('0x31')]);_0x52ef0f[_0xc065('0x33')]=_['intersection'](_0x52ef0f[_0xc065('0x35')],_0x52ef0f['query']);_0x18954d[_0xc065('0x37')]=_[_0xc065('0x34')](_0x52ef0f[_0xc065('0x35')],qs[_0xc065('0x36')](_0x539355['query']['fields']));_0x18954d[_0xc065('0x37')]=_0x18954d[_0xc065('0x37')]['length']?_0x18954d['attributes']:_0x52ef0f[_0xc065('0x35')];_0x18954d['order']=qs['sort'](_0x539355['query'][_0xc065('0x3a')]);_0x18954d['where']=qs['filters'](_[_0xc065('0x3c')](_0x539355['query'],_0x52ef0f[_0xc065('0x33')]));if(_0x539355[_0xc065('0x31')][_0xc065('0x3f')]){_0x18954d[_0xc065('0x3b')]=_[_0xc065('0x3d')](_0x18954d[_0xc065('0x3b')],{'$or':_[_0xc065('0x2e')](_0x18954d[_0xc065('0x37')],function(_0x1b1e4f){var _0x4a5f18={};_0x4a5f18[_0x1b1e4f]={'$like':'%'+_0x539355[_0xc065('0x31')][_0xc065('0x3f')]+'%'};return _0x4a5f18;})});}_0x18954d=_[_0xc065('0x3d')]({},_0x18954d,_0x539355[_0xc065('0x49')]);return _0x114cf7[_0xc065('0x61')](_0x18954d);}})['then'](function(_0x2ee48f){if(_0x2ee48f){_0x30a44b=_0x2ee48f['length'];if(!_0x539355[_0xc065('0x31')][_0xc065('0x38')]('nolimit')){_0x18954d['limit']=qs[_0xc065('0x22')](_0x539355[_0xc065('0x31')][_0xc065('0x22')]);_0x18954d[_0xc065('0x21')]=qs[_0xc065('0x21')](_0x539355[_0xc065('0x31')][_0xc065('0x21')]);}return _0x114cf7['getTeams'](_0x18954d);}})[_0xc065('0x27')](function(_0x99591c){if(_0x99591c){return _0x99591c?{'count':_0x30a44b,'rows':_0x99591c}:null;}})[_0xc065('0x27')](respondWithResult(_0x223879,null))['catch'](handleError(_0x223879,null));};exports[_0xc065('0x62')]=function(_0x1190cb,_0x23b002,_0x2f4de6){var _0x512cd3=_0x1190cb['body'][_0xc065('0x63')];return db[_0xc065('0x64')][_0xc065('0x42')]({'where':{'id':_0x512cd3},'attributes':['id'],'include':[{'model':db[_0xc065('0x5a')],'as':_0xc065('0x65'),'attributes':['id',_0xc065('0x2d'),'online','voicePause',_0xc065('0x66')],'raw':!![]}]})[_0xc065('0x27')](function(_0x3a0c9e){if(_0x3a0c9e){var _0x5bc0f3=_[_0xc065('0x67')](_0x3a0c9e,function(_0x177fdf){var _0x2cfda3=_0x177fdf[_0xc065('0x57')]({'plain':!![]});return _0x2cfda3['Agents'];});return db[_0xc065('0x2f')][_0xc065('0x4a')]({'where':{'id':_0x1190cb[_0xc065('0x46')]['id']}})[_0xc065('0x27')](function(_0x18a3d9){return db[_0xc065('0x68')]['transaction'](function(_0xa037bd){return _0x18a3d9[_0xc065('0x62')](_0x512cd3,{'transaction':_0xa037bd})[_0xc065('0x27')](function(){return BPromise[_0xc065('0x69')](_0x5bc0f3,function(_0x35719b){return db['UserOpenchannelQueue'][_0xc065('0x6a')]({'where':{'UserId':_0x35719b['id'],'OpenchannelQueueId':_0x1190cb['params']['id']},'transaction':_0xa037bd});});})[_0xc065('0x27')](function(){_0x5bc0f3['forEach'](function(_0x12eaed){socket['emit'](_0xc065('0x6b'),{'UserId':_0x12eaed['id'],'OpenchannelQueueId':_0x18a3d9['id']});});});});});}})[_0xc065('0x27')](respondWithStatusCode(_0x23b002,null))['catch'](handleError(_0x23b002,null));};exports[_0xc065('0x6c')]=function(_0x5ba020,_0x167593,_0x2f0291){return db[_0xc065('0x64')][_0xc065('0x42')]({'where':{'id':_0x5ba020['query'][_0xc065('0x63')]},'attributes':['id'],'include':[{'model':db[_0xc065('0x5a')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xc065('0x27')](handleEntityNotFound(_0x167593,null))['then'](function(_0x170381){var _0x401770=_[_0xc065('0x2e')](_0x170381,'id');var _0x475a14=[];var _0x301a26=[];var _0xd85219=squel[_0xc065('0x6d')]();_0xd85219['field'](_0xc065('0x6e'))[_0xc065('0x6f')](_0xc065('0x70'),'tq')[_0xc065('0x71')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0xc065('0x3b')](_0xc065('0x72'),_0x5ba020['params']['id']);for(var _0x78ac1c=0x0;_0x78ac1c<_0x170381[_0xc065('0x48')];_0x78ac1c+=0x1){let _0x15ff18=_0x170381[_0x78ac1c];for(var _0x8edb2f=0x0;_0x8edb2f<_0x15ff18[_0xc065('0x65')][_0xc065('0x48')];_0x8edb2f+=0x1){let _0x52c30b=_0x15ff18[_0xc065('0x65')][_0x8edb2f];var _0x35d8be=_0xd85219['clone']();_0x35d8be[_0xc065('0x3b')](_0xc065('0x73'),_0x52c30b['id']);_0x301a26[_0xc065('0x74')](db['sequelize']['query'](_0x35d8be[_0xc065('0x75')](),{'type':db['sequelize'][_0xc065('0x76')]['SELECT']})[_0xc065('0x27')](function(_0x5d8673){if(_0x5d8673[_0xc065('0x48')]===0x1){return _0x52c30b['id'];}else{var _0x14fd13=_[_0xc065('0x77')](_[_0xc065('0x2e')](_0x5d8673,_0xc065('0x78')),function(_0x545ad6){return _['includes'](_0x401770,_0x545ad6);});if(_0x14fd13){return _0x52c30b['id'];}}}));}}return BPromise[_0xc065('0x79')](_0x301a26)[_0xc065('0x27')](function(_0x3a8068){_0x475a14=_(_0x475a14)[_0xc065('0x7a')](_0x3a8068)[_0xc065('0x7b')]()[_0xc065('0x7c')]();return db[_0xc065('0x2f')]['find']({'where':{'id':_0x5ba020[_0xc065('0x46')]['id']}})[_0xc065('0x27')](function(_0x57b458){return db['sequelize']['transaction'](function(_0x1b8cbf){return _0x57b458[_0xc065('0x6c')](_0x5ba020[_0xc065('0x31')]['ids'],{'transaction':_0x1b8cbf})[_0xc065('0x27')](function(){if(!_[_0xc065('0x7d')](_0x475a14)){return _0x57b458[_0xc065('0x7e')](_0x475a14,{'transaction':_0x1b8cbf});}})['then'](function(){_0x475a14['forEach'](function(_0x2ca408){socket[_0xc065('0x7f')](_0xc065('0x80'),{'UserId':_0x2ca408,'OpenchannelQueueId':_0x57b458['id']});});});});});});})[_0xc065('0x27')](respondWithStatusCode(_0x167593,null))[_0xc065('0x44')](handleError(_0x167593,null));};exports[_0xc065('0x81')]=function(_0x583e80,_0x4b0d93,_0x3107a8){return db[_0xc065('0x2f')]['find']({'where':{'id':_0x583e80[_0xc065('0x46')]['id']}})[_0xc065('0x27')](handleEntityNotFound(_0x4b0d93,null))[_0xc065('0x27')](function(_0x43c364){if(_0x43c364){return _0x43c364['addAgents'](_0x583e80[_0xc065('0x4c')][_0xc065('0x63')],_[_0xc065('0x82')](_0x583e80[_0xc065('0x4c')],[_0xc065('0x63'),'id'])||{})[_0xc065('0x83')](function(_0x38530c){for(var _0x3b3106=0x0;_0x3b3106<_0x583e80[_0xc065('0x4c')][_0xc065('0x63')][_0xc065('0x48')];_0x3b3106+=0x1){socket[_0xc065('0x7f')](_0xc065('0x6b'),{'UserId':_0x583e80[_0xc065('0x4c')][_0xc065('0x63')][_0x3b3106],'OpenchannelQueueId':_0x583e80[_0xc065('0x46')]['id']});}return _0x38530c;});}})[_0xc065('0x27')](respondWithResult(_0x4b0d93,null))[_0xc065('0x44')](handleError(_0x4b0d93,null));};exports[_0xc065('0x7e')]=function(_0x1a24b6,_0x5da060,_0x358be9){return db[_0xc065('0x2f')][_0xc065('0x4a')]({'where':{'id':_0x1a24b6[_0xc065('0x46')]['id']}})['then'](handleEntityNotFound(_0x5da060,null))[_0xc065('0x27')](function(_0x3e5853){if(_0x3e5853){return _0x3e5853['removeAgents'](_0x1a24b6['query']['ids'])[_0xc065('0x27')](function(){if(_[_0xc065('0x84')](_0x1a24b6[_0xc065('0x31')][_0xc065('0x63')])){for(var _0x4827d9=0x0;_0x4827d9<_0x1a24b6[_0xc065('0x31')][_0xc065('0x63')][_0xc065('0x48')];_0x4827d9+=0x1){socket[_0xc065('0x7f')](_0xc065('0x80'),{'UserId':Number(_0x1a24b6['query'][_0xc065('0x63')][_0x4827d9]),'OpenchannelQueueId':Number(_0x1a24b6[_0xc065('0x46')]['id'])});}}else{socket[_0xc065('0x7f')](_0xc065('0x80'),{'UserId':Number(_0x1a24b6[_0xc065('0x31')][_0xc065('0x63')]),'OpenchannelQueueId':Number(_0x1a24b6[_0xc065('0x46')]['id'])});}});}})[_0xc065('0x27')](respondWithStatusCode(_0x5da060,null))['catch'](handleError(_0x5da060,null));};exports[_0xc065('0x85')]=function(_0x3b88e8,_0x539225,_0x2c37f6){var _0x48be80={};var _0x3fcbd2={};var _0xc97572;var _0x37e329;return db[_0xc065('0x2f')]['findOne']({'where':{'id':_0x3b88e8[_0xc065('0x46')]['id']}})[_0xc065('0x27')](handleEntityNotFound(_0x539225,null))[_0xc065('0x27')](function(_0x26b19a){if(_0x26b19a){_0xc97572=_0x26b19a;_0x3fcbd2[_0xc065('0x35')]=_[_0xc065('0x32')](db[_0xc065('0x5a')][_0xc065('0x47')]);_0x3fcbd2[_0xc065('0x31')]=_[_0xc065('0x32')](_0x3b88e8['query']);_0x3fcbd2[_0xc065('0x33')]=_[_0xc065('0x34')](_0x3fcbd2[_0xc065('0x35')],_0x3fcbd2[_0xc065('0x31')]);_0x48be80['attributes']=_[_0xc065('0x34')](_0x3fcbd2[_0xc065('0x35')],qs[_0xc065('0x36')](_0x3b88e8[_0xc065('0x31')][_0xc065('0x36')]));_0x48be80[_0xc065('0x37')]=_0x48be80[_0xc065('0x37')]['length']?_0x48be80['attributes']:_0x3fcbd2[_0xc065('0x35')];_0x48be80['order']=qs['sort'](_0x3b88e8[_0xc065('0x31')][_0xc065('0x3a')]);_0x48be80[_0xc065('0x3b')]=qs[_0xc065('0x33')](_[_0xc065('0x3c')](_0x3b88e8[_0xc065('0x31')],_0x3fcbd2[_0xc065('0x33')]));if(_0x3b88e8[_0xc065('0x31')][_0xc065('0x3f')]){_0x48be80[_0xc065('0x3b')]=_['merge'](_0x48be80[_0xc065('0x3b')],{'$or':_[_0xc065('0x2e')](_0x48be80[_0xc065('0x37')],function(_0x2f2c49){var _0x2f976e={};_0x2f976e[_0x2f2c49]={'$like':'%'+_0x3b88e8[_0xc065('0x31')][_0xc065('0x3f')]+'%'};return _0x2f976e;})});}_0x48be80=_[_0xc065('0x3d')]({},_0x48be80,_0x3b88e8[_0xc065('0x49')]);return _0xc97572[_0xc065('0x85')](_0x48be80);}})[_0xc065('0x27')](function(_0x56118c){if(_0x56118c){_0x37e329=_0x56118c[_0xc065('0x48')];if(!_0x3b88e8[_0xc065('0x31')][_0xc065('0x38')]('nolimit')){_0x48be80[_0xc065('0x22')]=qs[_0xc065('0x22')](_0x3b88e8[_0xc065('0x31')][_0xc065('0x22')]);_0x48be80[_0xc065('0x21')]=qs[_0xc065('0x21')](_0x3b88e8[_0xc065('0x31')][_0xc065('0x21')]);}return _0xc97572[_0xc065('0x85')](_0x48be80);}})[_0xc065('0x27')](function(_0x42f737){if(_0x42f737){return _0x42f737?{'count':_0x37e329,'rows':_0x42f737}:null;}})[_0xc065('0x27')](respondWithResult(_0x539225,null))[_0xc065('0x44')](handleError(_0x539225,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