Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index 7f3bbbe..a3eee10 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x22d0=['path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','redis','defaults','socket.io-emitter','./openchannelQueue.socket','status','end','offset','limit','set','Content-Range','json','apply','reject','update','then','destroy','get','UserProfileResource','sendStatus','error','stack','send','index','OpenchannelQueue','rawAttributes','key','model','map','name','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','pick','filter','where','type','options','count','includeAll','include','findAll','rows','catch','show','params','find','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','OpenchannelQueues','userProfileId','autoAssociation','create','body','describe','getMembers','findOne','UserOpenchannelQueue','hasOwnProperty','merge','findAndCountAll','UserId','agent','format','%s/%s','SIP','openchannelPause','createdAt','updatedAt','Team','addTeams','ids','User','Agents','online','voicePause','flatMap','sequelize','transaction','each','forEach','emit','userOpenchannelQueue:save','removeTeams','from','join','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','removeAgents','userOpenchannelQueue:remove','addAgents','omit','spread','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache'];(function(_0x45de7d,_0x476e39){var _0x463dea=function(_0x42526e){while(--_0x42526e){_0x45de7d['push'](_0x45de7d['shift']());}};_0x463dea(++_0x476e39);}(_0x22d0,0x106));var _0x022d=function(_0x202b05,_0x5a246c){_0x202b05=_0x202b05-0x0;var _0x22a0a7=_0x22d0[_0x202b05];return _0x22a0a7;};'use strict';var pdf=require(_0x022d('0x0'));var emlformat=require(_0x022d('0x1'));var rimraf=require(_0x022d('0x2'));var zipdir=require(_0x022d('0x3'));var jsonpatch=require(_0x022d('0x4'));var rp=require(_0x022d('0x5'));var moment=require(_0x022d('0x6'));var BPromise=require('bluebird');var Mustache=require(_0x022d('0x7'));var util=require('util');var path=require(_0x022d('0x8'));var sox=require(_0x022d('0x9'));var csv=require(_0x022d('0xa'));var ejs=require(_0x022d('0xb'));var fs=require('fs');var _=require(_0x022d('0xc'));var squel=require('squel');var crypto=require(_0x022d('0xd'));var jsforce=require(_0x022d('0xe'));var deskjs=require(_0x022d('0xf'));var toCsv=require('to-csv');var querystring=require(_0x022d('0x10'));var Papa=require(_0x022d('0x11'));var Redis=require(_0x022d('0x12'));var authService=require(_0x022d('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0x022d('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x022d('0x15'))('api');var utils=require(_0x022d('0x16'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x022d('0x17')]=_[_0x022d('0x18')](config[_0x022d('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0x022d('0x19'))(new Redis(config[_0x022d('0x17')]));require(_0x022d('0x1a'))['register'](socket);function respondWithStatusCode(_0x2e2c2d,_0x50a1be){_0x50a1be=_0x50a1be||0xcc;return function(_0x1068cc){if(_0x1068cc){return _0x2e2c2d['sendStatus'](_0x50a1be);}return _0x2e2c2d[_0x022d('0x1b')](_0x50a1be)[_0x022d('0x1c')]();};}function respondWithResult(_0x5d95e4,_0x20a2ea){_0x20a2ea=_0x20a2ea||0xc8;return function(_0x5e8c7f){if(_0x5e8c7f){return _0x5d95e4[_0x022d('0x1b')](_0x20a2ea)['json'](_0x5e8c7f);}};}function respondWithFilteredResult(_0x76c774,_0x4a78ca){return function(_0x31ae8d){if(_0x31ae8d){var _0x2b2720=_0x31ae8d['count'],_0xd0a4c9=_0x4a78ca['offset'],_0x4df1a4=_0x4a78ca[_0x022d('0x1d')]+_0x4a78ca[_0x022d('0x1e')],_0x5d4cc2;if(_0x4df1a4>=_0x2b2720){_0x4df1a4=_0x2b2720;_0x5d4cc2=0xc8;}else{_0x5d4cc2=0xce;}_0x76c774[_0x022d('0x1b')](_0x5d4cc2);return _0x76c774[_0x022d('0x1f')](_0x022d('0x20'),_0xd0a4c9+'-'+_0x4df1a4+'/'+_0x2b2720)[_0x022d('0x21')](_0x31ae8d);}return null;};}function patchUpdates(_0x1fe5d7){return function(_0x90bfb3){try{jsonpatch[_0x022d('0x22')](_0x90bfb3,_0x1fe5d7,!![]);}catch(_0x257609){return BPromise[_0x022d('0x23')](_0x257609);}return _0x90bfb3['save']();};}function saveUpdates(_0x5c8160,_0x16a1ec){return function(_0x32c89d){if(_0x32c89d){return _0x32c89d[_0x022d('0x24')](_0x5c8160)[_0x022d('0x25')](function(_0x5a7dc1){return _0x5a7dc1;});}return null;};}function removeEntity(_0x54f7ce,_0x35f340){return function(_0x16a53a){if(_0x16a53a){return _0x16a53a[_0x022d('0x26')]()[_0x022d('0x25')](function(){var _0x106297=_0x16a53a[_0x022d('0x27')]({'plain':!![]});var _0x3c1a16='OpenchannelQueues';return db[_0x022d('0x28')][_0x022d('0x26')]({'where':{'type':_0x3c1a16,'resourceId':_0x106297['id']}})[_0x022d('0x25')](function(){return _0x16a53a;});})[_0x022d('0x25')](function(){_0x54f7ce[_0x022d('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2acee2,_0xf90e62){return function(_0x1da7ab){if(!_0x1da7ab){_0x2acee2[_0x022d('0x29')](0x194);}return _0x1da7ab;};}function handleError(_0x300bdd,_0xcf823e){_0xcf823e=_0xcf823e||0x1f4;return function(_0xd624c6){logger[_0x022d('0x2a')](_0xd624c6[_0x022d('0x2b')]);if(_0xd624c6['name']){delete _0xd624c6['name'];}_0x300bdd[_0x022d('0x1b')](_0xcf823e)[_0x022d('0x2c')](_0xd624c6);};}exports[_0x022d('0x2d')]=function(_0x8b7865,_0x110a2d){var _0x2526dc={},_0x196903={},_0x833c1a={'count':0x0,'rows':[]};var _0x3482d4=_['map'](db[_0x022d('0x2e')][_0x022d('0x2f')],function(_0x3ec5bd){return{'name':_0x3ec5bd['fieldName'],'type':_0x3ec5bd['type'][_0x022d('0x30')]};});_0x196903[_0x022d('0x31')]=_[_0x022d('0x32')](_0x3482d4,_0x022d('0x33'));_0x196903[_0x022d('0x34')]=_[_0x022d('0x35')](_0x8b7865[_0x022d('0x34')]);_0x196903[_0x022d('0x36')]=_[_0x022d('0x37')](_0x196903[_0x022d('0x31')],_0x196903[_0x022d('0x34')]);_0x2526dc[_0x022d('0x38')]=_[_0x022d('0x37')](_0x196903[_0x022d('0x31')],qs[_0x022d('0x39')](_0x8b7865[_0x022d('0x34')][_0x022d('0x39')]));_0x2526dc['attributes']=_0x2526dc[_0x022d('0x38')][_0x022d('0x3a')]?_0x2526dc[_0x022d('0x38')]:_0x196903[_0x022d('0x31')];if(!_0x8b7865[_0x022d('0x34')]['hasOwnProperty'](_0x022d('0x3b'))){_0x2526dc[_0x022d('0x1e')]=qs[_0x022d('0x1e')](_0x8b7865[_0x022d('0x34')][_0x022d('0x1e')]);_0x2526dc[_0x022d('0x1d')]=qs[_0x022d('0x1d')](_0x8b7865[_0x022d('0x34')][_0x022d('0x1d')]);}_0x2526dc[_0x022d('0x3c')]=qs[_0x022d('0x3d')](_0x8b7865[_0x022d('0x34')]['sort']);_0x2526dc['where']=qs[_0x022d('0x36')](_[_0x022d('0x3e')](_0x8b7865[_0x022d('0x34')],_0x196903['filters']));if(_0x8b7865[_0x022d('0x34')][_0x022d('0x3f')]){_0x2526dc[_0x022d('0x40')]=_['merge'](_0x2526dc[_0x022d('0x40')],{'$or':_[_0x022d('0x32')](_0x3482d4,function(_0x55825e){if(_0x55825e[_0x022d('0x41')]!=='VIRTUAL'){var _0x10877c={};_0x10877c[_0x55825e[_0x022d('0x33')]]={'$like':'%'+_0x8b7865[_0x022d('0x34')][_0x022d('0x3f')]+'%'};return _0x10877c;}})});}_0x2526dc=_['merge']({},_0x2526dc,_0x8b7865[_0x022d('0x42')]);var _0x38a261={'where':_0x2526dc[_0x022d('0x40')]};return db[_0x022d('0x2e')]['count'](_0x38a261)[_0x022d('0x25')](function(_0x25b554){_0x833c1a[_0x022d('0x43')]=_0x25b554;if(_0x8b7865[_0x022d('0x34')][_0x022d('0x44')]){_0x2526dc[_0x022d('0x45')]=[{'all':!![]}];}return db[_0x022d('0x2e')][_0x022d('0x46')](_0x2526dc);})[_0x022d('0x25')](function(_0x28a5c4){_0x833c1a[_0x022d('0x47')]=_0x28a5c4;return _0x833c1a;})['then'](respondWithFilteredResult(_0x110a2d,_0x2526dc))[_0x022d('0x48')](handleError(_0x110a2d,null));};exports[_0x022d('0x49')]=function(_0x2da3b6,_0x4c5d61){var _0x1db316={'raw':!![],'where':{'id':_0x2da3b6[_0x022d('0x4a')]['id']}},_0x199066={};_0x199066[_0x022d('0x31')]=_[_0x022d('0x35')](db[_0x022d('0x2e')]['rawAttributes']);_0x199066[_0x022d('0x34')]=_[_0x022d('0x35')](_0x2da3b6[_0x022d('0x34')]);_0x199066[_0x022d('0x36')]=_[_0x022d('0x37')](_0x199066['model'],_0x199066[_0x022d('0x34')]);_0x1db316[_0x022d('0x38')]=_[_0x022d('0x37')](_0x199066[_0x022d('0x31')],qs[_0x022d('0x39')](_0x2da3b6['query']['fields']));_0x1db316[_0x022d('0x38')]=_0x1db316[_0x022d('0x38')][_0x022d('0x3a')]?_0x1db316[_0x022d('0x38')]:_0x199066[_0x022d('0x31')];if(_0x2da3b6[_0x022d('0x34')][_0x022d('0x44')]){_0x1db316['include']=[{'all':!![]}];}_0x1db316=_['merge']({},_0x1db316,_0x2da3b6['options']);return db['OpenchannelQueue'][_0x022d('0x4b')](_0x1db316)['then'](handleEntityNotFound(_0x4c5d61,null))[_0x022d('0x25')](respondWithResult(_0x4c5d61,null))[_0x022d('0x48')](handleError(_0x4c5d61,null));};exports['create']=function(_0x5e093e,_0xea583){return db[_0x022d('0x2e')]['create'](_0x5e093e['body'],{})['then'](function(_0x10eb34){var _0x8b7069=_0x5e093e['user']['get']({'plain':!![]});if(!_0x8b7069)throw new Error(_0x022d('0x4c'));if(_0x8b7069[_0x022d('0x4d')]==='user'){var _0xe4f7ff=_0x10eb34['get']({'plain':!![]});var _0x434d97=_0x022d('0x4e');return db['UserProfileSection'][_0x022d('0x4b')]({'where':{'name':_0x434d97,'userProfileId':_0x8b7069[_0x022d('0x4f')]},'raw':!![]})[_0x022d('0x25')](function(_0x573f32){if(_0x573f32&&_0x573f32[_0x022d('0x50')]===0x0){return db['UserProfileResource'][_0x022d('0x51')]({'name':_0xe4f7ff['name'],'resourceId':_0xe4f7ff['id'],'type':_0x573f32[_0x022d('0x33')],'sectionId':_0x573f32['id']},{})[_0x022d('0x25')](function(){return _0x10eb34;});}else{return _0x10eb34;}})[_0x022d('0x48')](function(_0x156f7e){logger[_0x022d('0x2a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x156f7e);throw _0x156f7e;});}return _0x10eb34;})[_0x022d('0x25')](respondWithResult(_0xea583,0xc9))[_0x022d('0x48')](handleError(_0xea583,null));};exports[_0x022d('0x24')]=function(_0x5b18a5,_0x171534){if(_0x5b18a5[_0x022d('0x52')]['id']){delete _0x5b18a5[_0x022d('0x52')]['id'];}return db[_0x022d('0x2e')]['find']({'where':{'id':_0x5b18a5[_0x022d('0x4a')]['id']}})[_0x022d('0x25')](handleEntityNotFound(_0x171534,null))[_0x022d('0x25')](saveUpdates(_0x5b18a5[_0x022d('0x52')],null))['then'](respondWithResult(_0x171534,null))[_0x022d('0x48')](handleError(_0x171534,null));};exports[_0x022d('0x26')]=function(_0x14fe6d,_0x130869){return db[_0x022d('0x2e')][_0x022d('0x4b')]({'where':{'id':_0x14fe6d[_0x022d('0x4a')]['id']}})['then'](handleEntityNotFound(_0x130869,null))[_0x022d('0x25')](removeEntity(_0x130869,null))[_0x022d('0x48')](handleError(_0x130869,null));};exports[_0x022d('0x53')]=function(_0x267393,_0x1d7662){return db[_0x022d('0x2e')][_0x022d('0x53')]()['then'](respondWithResult(_0x1d7662,null))[_0x022d('0x48')](handleError(_0x1d7662,null));};exports[_0x022d('0x54')]=function(_0x1abca3,_0x5c3053,_0x37a2df){var _0x3e008a={'raw':!![],'where':{}},_0x4b8e86={},_0x3b7a36;return db[_0x022d('0x2e')][_0x022d('0x55')]({'where':{'id':_0x1abca3[_0x022d('0x4a')]['id']}})['then'](handleEntityNotFound(_0x5c3053,null))['then'](function(_0x2e8ad5){if(_0x2e8ad5){_0x3b7a36=_0x2e8ad5[_0x022d('0x27')]({'plain':!![]});_0x4b8e86[_0x022d('0x31')]=_['keys'](db[_0x022d('0x56')][_0x022d('0x2f')]);_0x4b8e86[_0x022d('0x34')]=_['keys'](_0x1abca3[_0x022d('0x34')]);_0x4b8e86[_0x022d('0x36')]=_[_0x022d('0x37')](_0x4b8e86[_0x022d('0x31')],_0x4b8e86[_0x022d('0x34')]);_0x3e008a['attributes']=_[_0x022d('0x37')](_0x4b8e86[_0x022d('0x31')],qs['fields'](_0x1abca3[_0x022d('0x34')]['fields']));_0x3e008a['attributes']=_0x3e008a['attributes'][_0x022d('0x3a')]?_0x3e008a[_0x022d('0x38')]:_0x4b8e86[_0x022d('0x31')];if(!_0x1abca3[_0x022d('0x34')][_0x022d('0x57')](_0x022d('0x3b'))){_0x3e008a[_0x022d('0x1e')]=qs[_0x022d('0x1e')](_0x1abca3[_0x022d('0x34')][_0x022d('0x1e')]);_0x3e008a[_0x022d('0x1d')]=qs['offset'](_0x1abca3[_0x022d('0x34')]['offset']);}_0x3e008a['order']=qs['sort'](_0x1abca3['query'][_0x022d('0x3d')]);_0x3e008a['where']=qs[_0x022d('0x36')](_[_0x022d('0x3e')](_0x1abca3['query'],_0x4b8e86[_0x022d('0x36')]));_0x3e008a['where']['OpenchannelQueueId']=_0x2e8ad5['id'];if(_0x1abca3[_0x022d('0x34')][_0x022d('0x3f')]){_0x3e008a[_0x022d('0x40')]=_['merge'](_0x3e008a[_0x022d('0x40')],{'$or':_[_0x022d('0x32')](_0x3e008a[_0x022d('0x38')],function(_0x302574){var _0x45d301={};_0x45d301[_0x302574]={'$like':'%'+_0x1abca3[_0x022d('0x34')][_0x022d('0x3f')]+'%'};return _0x45d301;})});}_0x3e008a=_[_0x022d('0x58')]({},_0x3e008a,_0x1abca3['options']);return db[_0x022d('0x56')][_0x022d('0x46')](_0x3e008a);}})[_0x022d('0x25')](function(_0x2302d2){if(_0x2302d2){return db['User'][_0x022d('0x59')]({'where':{'id':_[_0x022d('0x32')](_0x2302d2,_0x022d('0x5a')),'role':_0x022d('0x5b')},'attributes':['id',_0x022d('0x33'),'openchannelPause','updatedAt','createdAt']});}})[_0x022d('0x25')](function(_0x386da9){if(_0x386da9){return{'count':_0x386da9['count'],'rows':_[_0x022d('0x32')](_0x386da9[_0x022d('0x47')],function(_0x101d99){return{'membername':_0x101d99['name'],'UserId':_0x101d99['id'],'queue_name':_0x3b7a36[_0x022d('0x33')],'OpenchannelQueueId':_0x3b7a36['id'],'interface':util[_0x022d('0x5c')](_0x022d('0x5d'),_0x022d('0x5e'),_0x101d99['name']),'penalty':0x0,'paused':_0x101d99[_0x022d('0x5f')],'createdAt':_0x101d99[_0x022d('0x60')],'updatedAt':_0x101d99[_0x022d('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x022d('0x25')](respondWithFilteredResult(_0x5c3053,_0x3e008a))[_0x022d('0x48')](handleError(_0x5c3053,null));};exports['getTeams']=function(_0x51fa6b,_0x2ca61c,_0x24f756){var _0x4c103b={};var _0x466528={};var _0x504bd0;var _0x506d46;return db['OpenchannelQueue'][_0x022d('0x55')]({'where':{'id':_0x51fa6b['params']['id']}})['then'](handleEntityNotFound(_0x2ca61c,null))['then'](function(_0x56653d){if(_0x56653d){_0x504bd0=_0x56653d;_0x466528[_0x022d('0x31')]=_[_0x022d('0x35')](db[_0x022d('0x62')][_0x022d('0x2f')]);_0x466528['query']=_['keys'](_0x51fa6b[_0x022d('0x34')]);_0x466528[_0x022d('0x36')]=_['intersection'](_0x466528[_0x022d('0x31')],_0x466528[_0x022d('0x34')]);_0x4c103b[_0x022d('0x38')]=_['intersection'](_0x466528[_0x022d('0x31')],qs[_0x022d('0x39')](_0x51fa6b[_0x022d('0x34')][_0x022d('0x39')]));_0x4c103b[_0x022d('0x38')]=_0x4c103b[_0x022d('0x38')][_0x022d('0x3a')]?_0x4c103b[_0x022d('0x38')]:_0x466528[_0x022d('0x31')];_0x4c103b[_0x022d('0x3c')]=qs[_0x022d('0x3d')](_0x51fa6b[_0x022d('0x34')][_0x022d('0x3d')]);_0x4c103b[_0x022d('0x40')]=qs[_0x022d('0x36')](_['pick'](_0x51fa6b[_0x022d('0x34')],_0x466528[_0x022d('0x36')]));if(_0x51fa6b[_0x022d('0x34')][_0x022d('0x3f')]){_0x4c103b[_0x022d('0x40')]=_[_0x022d('0x58')](_0x4c103b[_0x022d('0x40')],{'$or':_[_0x022d('0x32')](_0x4c103b[_0x022d('0x38')],function(_0x350352){var _0x1d709c={};_0x1d709c[_0x350352]={'$like':'%'+_0x51fa6b[_0x022d('0x34')][_0x022d('0x3f')]+'%'};return _0x1d709c;})});}_0x4c103b=_[_0x022d('0x58')]({},_0x4c103b,_0x51fa6b[_0x022d('0x42')]);return _0x504bd0['getTeams'](_0x4c103b);}})[_0x022d('0x25')](function(_0x483646){if(_0x483646){_0x506d46=_0x483646[_0x022d('0x3a')];if(!_0x51fa6b['query'][_0x022d('0x57')](_0x022d('0x3b'))){_0x4c103b['limit']=qs['limit'](_0x51fa6b[_0x022d('0x34')][_0x022d('0x1e')]);_0x4c103b[_0x022d('0x1d')]=qs[_0x022d('0x1d')](_0x51fa6b[_0x022d('0x34')]['offset']);}return _0x504bd0['getTeams'](_0x4c103b);}})['then'](function(_0x570f16){if(_0x570f16){return _0x570f16?{'count':_0x506d46,'rows':_0x570f16}:null;}})[_0x022d('0x25')](respondWithResult(_0x2ca61c,null))['catch'](handleError(_0x2ca61c,null));};exports[_0x022d('0x63')]=function(_0x531c04,_0x8f6bb8,_0x472027){var _0x314331=_0x531c04[_0x022d('0x52')][_0x022d('0x64')];return db[_0x022d('0x62')][_0x022d('0x46')]({'where':{'id':_0x314331},'attributes':['id'],'include':[{'model':db[_0x022d('0x65')],'as':_0x022d('0x66'),'attributes':['id','name',_0x022d('0x67'),_0x022d('0x68'),'interface'],'raw':!![]}]})[_0x022d('0x25')](function(_0x25048f){if(_0x25048f){var _0x23ae54=_[_0x022d('0x69')](_0x25048f,function(_0x9a0cad){var _0x369b13=_0x9a0cad[_0x022d('0x27')]({'plain':!![]});return _0x369b13[_0x022d('0x66')];});return db[_0x022d('0x2e')]['find']({'where':{'id':_0x531c04[_0x022d('0x4a')]['id']}})[_0x022d('0x25')](function(_0x25f7b5){return db[_0x022d('0x6a')][_0x022d('0x6b')](function(_0x2ee309){return _0x25f7b5[_0x022d('0x63')](_0x314331,{'transaction':_0x2ee309})[_0x022d('0x25')](function(){return BPromise[_0x022d('0x6c')](_0x23ae54,function(_0x43ee86){return db[_0x022d('0x56')]['findOrCreate']({'where':{'UserId':_0x43ee86['id'],'OpenchannelQueueId':_0x531c04[_0x022d('0x4a')]['id']},'transaction':_0x2ee309});});})['then'](function(){_0x23ae54[_0x022d('0x6d')](function(_0x2c9b4f){socket[_0x022d('0x6e')](_0x022d('0x6f'),{'UserId':_0x2c9b4f['id'],'OpenchannelQueueId':_0x25f7b5['id']});});});});});}})[_0x022d('0x25')](respondWithStatusCode(_0x8f6bb8,null))[_0x022d('0x48')](handleError(_0x8f6bb8,null));};exports[_0x022d('0x70')]=function(_0x15f8a5,_0x3b7868,_0xcdce46){return db[_0x022d('0x62')]['findAll']({'where':{'id':_0x15f8a5[_0x022d('0x34')][_0x022d('0x64')]},'attributes':['id'],'include':[{'model':db[_0x022d('0x65')],'as':_0x022d('0x66'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x3b7868,null))[_0x022d('0x25')](function(_0x23cc77){var _0x4534b6=_['map'](_0x23cc77,'id');var _0x1a603c=[];var _0x386197=[];var _0x43303c=squel['select']();_0x43303c['field']('tq.TeamId')[_0x022d('0x71')]('team_has_openchannel_queues','tq')[_0x022d('0x72')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0x022d('0x40')]('OpenchannelQueueId\x20=\x20?',_0x15f8a5['params']['id']);for(var _0xcba340=0x0;_0xcba340<_0x23cc77[_0x022d('0x3a')];_0xcba340+=0x1){let _0x4bdac1=_0x23cc77[_0xcba340];for(var _0x4cc611=0x0;_0x4cc611<_0x4bdac1[_0x022d('0x66')][_0x022d('0x3a')];_0x4cc611+=0x1){let _0x5158a1=_0x4bdac1[_0x022d('0x66')][_0x4cc611];var _0x4a88f9=_0x43303c[_0x022d('0x73')]();_0x4a88f9['where'](_0x022d('0x74'),_0x5158a1['id']);_0x386197[_0x022d('0x75')](db['sequelize'][_0x022d('0x34')](_0x4a88f9[_0x022d('0x76')](),{'type':db['sequelize'][_0x022d('0x77')][_0x022d('0x78')]})[_0x022d('0x25')](function(_0x490a9f){if(_0x490a9f[_0x022d('0x3a')]===0x1){return _0x5158a1['id'];}else{var _0x22650e=_[_0x022d('0x79')](_[_0x022d('0x32')](_0x490a9f,_0x022d('0x7a')),function(_0x18c34d){return _[_0x022d('0x7b')](_0x4534b6,_0x18c34d);});if(_0x22650e){return _0x5158a1['id'];}}}));}}return BPromise[_0x022d('0x7c')](_0x386197)['then'](function(_0x9f0157){_0x1a603c=_(_0x1a603c)[_0x022d('0x7d')](_0x9f0157)[_0x022d('0x7e')]()[_0x022d('0x7f')]();return db[_0x022d('0x2e')]['find']({'where':{'id':_0x15f8a5['params']['id']}})[_0x022d('0x25')](function(_0xf78025){return db[_0x022d('0x6a')][_0x022d('0x6b')](function(_0x1376e2){return _0xf78025[_0x022d('0x70')](_0x15f8a5['query'][_0x022d('0x64')],{'transaction':_0x1376e2})[_0x022d('0x25')](function(){if(!_[_0x022d('0x80')](_0x1a603c)){return _0xf78025[_0x022d('0x81')](_0x1a603c,{'transaction':_0x1376e2});}})['then'](function(){_0x1a603c[_0x022d('0x6d')](function(_0xc54f27){socket[_0x022d('0x6e')](_0x022d('0x82'),{'UserId':_0xc54f27,'OpenchannelQueueId':_0xf78025['id']});});});});});});})['then'](respondWithStatusCode(_0x3b7868,null))['catch'](handleError(_0x3b7868,null));};exports[_0x022d('0x83')]=function(_0x1afa67,_0x2de7b1,_0x1fb8c3){return db[_0x022d('0x2e')][_0x022d('0x4b')]({'where':{'id':_0x1afa67[_0x022d('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2de7b1,null))['then'](function(_0x263e01){if(_0x263e01){return _0x263e01[_0x022d('0x83')](_0x1afa67[_0x022d('0x52')][_0x022d('0x64')],_[_0x022d('0x84')](_0x1afa67['body'],[_0x022d('0x64'),'id'])||{})[_0x022d('0x85')](function(_0x20afe1){for(var _0xa32f43=0x0;_0xa32f43<_0x1afa67['body']['ids'][_0x022d('0x3a')];_0xa32f43+=0x1){socket[_0x022d('0x6e')](_0x022d('0x6f'),{'UserId':_0x1afa67[_0x022d('0x52')][_0x022d('0x64')][_0xa32f43],'OpenchannelQueueId':_0x1afa67[_0x022d('0x4a')]['id']});}return _0x20afe1;});}})[_0x022d('0x25')](respondWithResult(_0x2de7b1,null))[_0x022d('0x48')](handleError(_0x2de7b1,null));};exports[_0x022d('0x81')]=function(_0x1f41f6,_0x28891f,_0x2d0d9b){return db['OpenchannelQueue']['find']({'where':{'id':_0x1f41f6[_0x022d('0x4a')]['id']}})['then'](handleEntityNotFound(_0x28891f,null))['then'](function(_0x5f5d8b){if(_0x5f5d8b){return _0x5f5d8b[_0x022d('0x81')](_0x1f41f6[_0x022d('0x34')]['ids'])['then'](function(){if(_['isArray'](_0x1f41f6['query']['ids'])){for(var _0x3c320a=0x0;_0x3c320a<_0x1f41f6['query'][_0x022d('0x64')][_0x022d('0x3a')];_0x3c320a+=0x1){socket[_0x022d('0x6e')]('userOpenchannelQueue:remove',{'UserId':Number(_0x1f41f6[_0x022d('0x34')][_0x022d('0x64')][_0x3c320a]),'OpenchannelQueueId':Number(_0x1f41f6['params']['id'])});}}else{socket[_0x022d('0x6e')](_0x022d('0x82'),{'UserId':Number(_0x1f41f6['query'][_0x022d('0x64')]),'OpenchannelQueueId':Number(_0x1f41f6[_0x022d('0x4a')]['id'])});}});}})[_0x022d('0x25')](respondWithStatusCode(_0x28891f,null))[_0x022d('0x48')](handleError(_0x28891f,null));};exports['getAgents']=function(_0xf47c46,_0x51473f,_0x20b767){var _0x310cd8={};var _0x382bc7={};var _0x541911;var _0x50d160;return db[_0x022d('0x2e')][_0x022d('0x55')]({'where':{'id':_0xf47c46['params']['id']}})[_0x022d('0x25')](handleEntityNotFound(_0x51473f,null))[_0x022d('0x25')](function(_0xc6352c){if(_0xc6352c){_0x541911=_0xc6352c;_0x382bc7['model']=_[_0x022d('0x35')](db[_0x022d('0x65')][_0x022d('0x2f')]);_0x382bc7['query']=_[_0x022d('0x35')](_0xf47c46[_0x022d('0x34')]);_0x382bc7['filters']=_[_0x022d('0x37')](_0x382bc7[_0x022d('0x31')],_0x382bc7[_0x022d('0x34')]);_0x310cd8[_0x022d('0x38')]=_[_0x022d('0x37')](_0x382bc7['model'],qs[_0x022d('0x39')](_0xf47c46['query']['fields']));_0x310cd8[_0x022d('0x38')]=_0x310cd8[_0x022d('0x38')]['length']?_0x310cd8[_0x022d('0x38')]:_0x382bc7['model'];_0x310cd8[_0x022d('0x3c')]=qs[_0x022d('0x3d')](_0xf47c46[_0x022d('0x34')][_0x022d('0x3d')]);_0x310cd8[_0x022d('0x40')]=qs[_0x022d('0x36')](_['pick'](_0xf47c46['query'],_0x382bc7[_0x022d('0x36')]));if(_0xf47c46[_0x022d('0x34')][_0x022d('0x3f')]){_0x310cd8['where']=_[_0x022d('0x58')](_0x310cd8[_0x022d('0x40')],{'$or':_[_0x022d('0x32')](_0x310cd8[_0x022d('0x38')],function(_0x463eba){var _0x43259b={};_0x43259b[_0x463eba]={'$like':'%'+_0xf47c46[_0x022d('0x34')]['filter']+'%'};return _0x43259b;})});}_0x310cd8=_[_0x022d('0x58')]({},_0x310cd8,_0xf47c46[_0x022d('0x42')]);return _0x541911[_0x022d('0x86')](_0x310cd8);}})[_0x022d('0x25')](function(_0x4aa723){if(_0x4aa723){_0x50d160=_0x4aa723[_0x022d('0x3a')];if(!_0xf47c46[_0x022d('0x34')][_0x022d('0x57')](_0x022d('0x3b'))){_0x310cd8[_0x022d('0x1e')]=qs[_0x022d('0x1e')](_0xf47c46[_0x022d('0x34')][_0x022d('0x1e')]);_0x310cd8[_0x022d('0x1d')]=qs[_0x022d('0x1d')](_0xf47c46[_0x022d('0x34')][_0x022d('0x1d')]);}return _0x541911[_0x022d('0x86')](_0x310cd8);}})[_0x022d('0x25')](function(_0x3fdb06){if(_0x3fdb06){return _0x3fdb06?{'count':_0x50d160,'rows':_0x3fdb06}:null;}})[_0x022d('0x25')](respondWithResult(_0x51473f,null))[_0x022d('0x48')](handleError(_0x51473f,null));};
\ No newline at end of file
+var _0xb6ee=['hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','include','rows','catch','show','params','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','describe','getMembers','findOne','UserOpenchannelQueue','OpenchannelQueueId','findAll','User','findAndCountAll','agent','openchannelPause','updatedAt','createdAt','format','SIP','getTeams','ids','Team','Agents','interface','flatMap','sequelize','each','findOrCreate','forEach','emit','removeTeams','field','tq.TeamId','from','team_has_openchannel_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','QueryTypes','SELECT','every','TeamId','includes','all','compact','value','transaction','isEmpty','removeAgents','addAgents','spread','userOpenchannelQueue:save','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','ejs','fs-extra','lodash','squel','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./openchannelQueue.socket','register','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','save','update','then','OpenchannelQueues','UserProfileResource','sendStatus','stack','name','send','index','OpenchannelQueue','rawAttributes','fieldName','key','model','map','query','keys','filters','intersection','attributes','fields','length'];(function(_0x1a450a,_0x4dcb72){var _0x4f8ef4=function(_0x44c6ba){while(--_0x44c6ba){_0x1a450a['push'](_0x1a450a['shift']());}};_0x4f8ef4(++_0x4dcb72);}(_0xb6ee,0x175));var _0xeb6e=function(_0x5eacb4,_0x5a6733){_0x5eacb4=_0x5eacb4-0x0;var _0x34dcbc=_0xb6ee[_0x5eacb4];return _0x34dcbc;};'use strict';var emlformat=require(_0xeb6e('0x0'));var rimraf=require(_0xeb6e('0x1'));var zipdir=require(_0xeb6e('0x2'));var jsonpatch=require(_0xeb6e('0x3'));var rp=require('request-promise');var moment=require(_0xeb6e('0x4'));var BPromise=require(_0xeb6e('0x5'));var Mustache=require(_0xeb6e('0x6'));var util=require(_0xeb6e('0x7'));var path=require(_0xeb6e('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xeb6e('0x9'));var fs=require('fs');var fs_extra=require(_0xeb6e('0xa'));var _=require(_0xeb6e('0xb'));var squel=require(_0xeb6e('0xc'));var crypto=require('crypto');var jsforce=require(_0xeb6e('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xeb6e('0xe'));var querystring=require(_0xeb6e('0xf'));var Papa=require(_0xeb6e('0x10'));var Redis=require(_0xeb6e('0x11'));var authService=require(_0xeb6e('0x12'));var qs=require(_0xeb6e('0x13'));var as=require(_0xeb6e('0x14'));var hardwareService=require(_0xeb6e('0x15'));var logger=require(_0xeb6e('0x16'))(_0xeb6e('0x17'));var utils=require('../../config/utils');var config=require(_0xeb6e('0x18'));var licenseUtil=require(_0xeb6e('0x19'));var db=require(_0xeb6e('0x1a'))['db'];config['redis']=_['defaults'](config[_0xeb6e('0x1b')],{'host':_0xeb6e('0x1c'),'port':0x18eb});var socket=require(_0xeb6e('0x1d'))(new Redis(config[_0xeb6e('0x1b')]));require(_0xeb6e('0x1e'))[_0xeb6e('0x1f')](socket);function respondWithStatusCode(_0x9c4636,_0x126242){_0x126242=_0x126242||0xcc;return function(_0x25d544){if(_0x25d544){return _0x9c4636['sendStatus'](_0x126242);}return _0x9c4636[_0xeb6e('0x20')](_0x126242)[_0xeb6e('0x21')]();};}function respondWithResult(_0x33d6af,_0xc4a3ce){_0xc4a3ce=_0xc4a3ce||0xc8;return function(_0x8f15c3){if(_0x8f15c3){return _0x33d6af[_0xeb6e('0x20')](_0xc4a3ce)[_0xeb6e('0x22')](_0x8f15c3);}};}function respondWithFilteredResult(_0x4f8952,_0x2bcac5){return function(_0x437bc6){if(_0x437bc6){var _0x9dd17=typeof _0x2bcac5['offset']===_0xeb6e('0x23')&&typeof _0x2bcac5[_0xeb6e('0x24')]==='undefined';var _0x1868d6=_0x437bc6[_0xeb6e('0x25')];var _0x15743d=_0x9dd17?0x0:_0x2bcac5[_0xeb6e('0x26')];var _0x47b3b1=_0x9dd17?_0x437bc6['count']:_0x2bcac5['offset']+_0x2bcac5[_0xeb6e('0x24')];var _0x5ce628;if(_0x47b3b1>=_0x1868d6){_0x47b3b1=_0x1868d6;_0x5ce628=0xc8;}else{_0x5ce628=0xce;}_0x4f8952[_0xeb6e('0x20')](_0x5ce628);return _0x4f8952[_0xeb6e('0x27')](_0xeb6e('0x28'),_0x15743d+'-'+_0x47b3b1+'/'+_0x1868d6)[_0xeb6e('0x22')](_0x437bc6);}return null;};}function patchUpdates(_0x348307){return function(_0x268b8c){try{jsonpatch[_0xeb6e('0x29')](_0x268b8c,_0x348307,!![]);}catch(_0x51ac80){return BPromise['reject'](_0x51ac80);}return _0x268b8c[_0xeb6e('0x2a')]();};}function saveUpdates(_0x53c56d,_0x4663be){return function(_0x1ec53f){if(_0x1ec53f){return _0x1ec53f[_0xeb6e('0x2b')](_0x53c56d)[_0xeb6e('0x2c')](function(_0x23d2a3){return _0x23d2a3;});}return null;};}function removeEntity(_0x30f4d1,_0x424398){return function(_0x2bde22){if(_0x2bde22){return _0x2bde22['destroy']()[_0xeb6e('0x2c')](function(){var _0x2901fa=_0x2bde22['get']({'plain':!![]});var _0x21790f=_0xeb6e('0x2d');return db[_0xeb6e('0x2e')]['destroy']({'where':{'type':_0x21790f,'resourceId':_0x2901fa['id']}})[_0xeb6e('0x2c')](function(){return _0x2bde22;});})[_0xeb6e('0x2c')](function(){_0x30f4d1['status'](0xcc)[_0xeb6e('0x21')]();});}};}function handleEntityNotFound(_0x5dba70,_0x2f84fa){return function(_0x15e14d){if(!_0x15e14d){_0x5dba70[_0xeb6e('0x2f')](0x194);}return _0x15e14d;};}function handleError(_0x50ba22,_0x91e9ce){_0x91e9ce=_0x91e9ce||0x1f4;return function(_0x431dd7){logger['error'](_0x431dd7[_0xeb6e('0x30')]);if(_0x431dd7[_0xeb6e('0x31')]){delete _0x431dd7[_0xeb6e('0x31')];}_0x50ba22['status'](_0x91e9ce)[_0xeb6e('0x32')](_0x431dd7);};}exports[_0xeb6e('0x33')]=function(_0x28d177,_0x36402a){var _0x11a598={},_0x47095a={},_0x5c3224={'count':0x0,'rows':[]};var _0xbbdfe8=_['map'](db[_0xeb6e('0x34')][_0xeb6e('0x35')],function(_0x3a89dc){return{'name':_0x3a89dc[_0xeb6e('0x36')],'type':_0x3a89dc['type'][_0xeb6e('0x37')]};});_0x47095a[_0xeb6e('0x38')]=_[_0xeb6e('0x39')](_0xbbdfe8,'name');_0x47095a[_0xeb6e('0x3a')]=_[_0xeb6e('0x3b')](_0x28d177[_0xeb6e('0x3a')]);_0x47095a[_0xeb6e('0x3c')]=_[_0xeb6e('0x3d')](_0x47095a[_0xeb6e('0x38')],_0x47095a[_0xeb6e('0x3a')]);_0x11a598[_0xeb6e('0x3e')]=_[_0xeb6e('0x3d')](_0x47095a[_0xeb6e('0x38')],qs[_0xeb6e('0x3f')](_0x28d177[_0xeb6e('0x3a')]['fields']));_0x11a598[_0xeb6e('0x3e')]=_0x11a598[_0xeb6e('0x3e')][_0xeb6e('0x40')]?_0x11a598[_0xeb6e('0x3e')]:_0x47095a[_0xeb6e('0x38')];if(!_0x28d177['query'][_0xeb6e('0x41')](_0xeb6e('0x42'))){_0x11a598['limit']=qs[_0xeb6e('0x24')](_0x28d177['query'][_0xeb6e('0x24')]);_0x11a598[_0xeb6e('0x26')]=qs[_0xeb6e('0x26')](_0x28d177['query'][_0xeb6e('0x26')]);}_0x11a598[_0xeb6e('0x43')]=qs[_0xeb6e('0x44')](_0x28d177['query'][_0xeb6e('0x44')]);_0x11a598[_0xeb6e('0x45')]=qs[_0xeb6e('0x3c')](_[_0xeb6e('0x46')](_0x28d177[_0xeb6e('0x3a')],_0x47095a[_0xeb6e('0x3c')]),_0xbbdfe8);if(_0x28d177['query'][_0xeb6e('0x47')]){_0x11a598[_0xeb6e('0x45')]=_[_0xeb6e('0x48')](_0x11a598[_0xeb6e('0x45')],{'$or':_[_0xeb6e('0x39')](_0xbbdfe8,function(_0x16d5c2){if(_0x16d5c2[_0xeb6e('0x49')]!==_0xeb6e('0x4a')){var _0x5ebd81={};_0x5ebd81[_0x16d5c2[_0xeb6e('0x31')]]={'$like':'%'+_0x28d177[_0xeb6e('0x3a')][_0xeb6e('0x47')]+'%'};return _0x5ebd81;}})});}_0x11a598=_[_0xeb6e('0x48')]({},_0x11a598,_0x28d177[_0xeb6e('0x4b')]);var _0x44ad56={'where':_0x11a598[_0xeb6e('0x45')]};return db['OpenchannelQueue'][_0xeb6e('0x25')](_0x44ad56)[_0xeb6e('0x2c')](function(_0x1b5dcc){_0x5c3224[_0xeb6e('0x25')]=_0x1b5dcc;if(_0x28d177[_0xeb6e('0x3a')][_0xeb6e('0x4c')]){_0x11a598[_0xeb6e('0x4d')]=[{'all':!![]}];}return db[_0xeb6e('0x34')]['findAll'](_0x11a598);})['then'](function(_0x15a29c){_0x5c3224[_0xeb6e('0x4e')]=_0x15a29c;return _0x5c3224;})['then'](respondWithFilteredResult(_0x36402a,_0x11a598))[_0xeb6e('0x4f')](handleError(_0x36402a,null));};exports[_0xeb6e('0x50')]=function(_0x3abd51,_0x3cc09e){var _0xc2dd1={'raw':!![],'where':{'id':_0x3abd51[_0xeb6e('0x51')]['id']}},_0x500c48={};_0x500c48[_0xeb6e('0x38')]=_[_0xeb6e('0x3b')](db[_0xeb6e('0x34')]['rawAttributes']);_0x500c48[_0xeb6e('0x3a')]=_[_0xeb6e('0x3b')](_0x3abd51[_0xeb6e('0x3a')]);_0x500c48[_0xeb6e('0x3c')]=_[_0xeb6e('0x3d')](_0x500c48[_0xeb6e('0x38')],_0x500c48[_0xeb6e('0x3a')]);_0xc2dd1[_0xeb6e('0x3e')]=_[_0xeb6e('0x3d')](_0x500c48[_0xeb6e('0x38')],qs[_0xeb6e('0x3f')](_0x3abd51[_0xeb6e('0x3a')]['fields']));_0xc2dd1[_0xeb6e('0x3e')]=_0xc2dd1[_0xeb6e('0x3e')][_0xeb6e('0x40')]?_0xc2dd1[_0xeb6e('0x3e')]:_0x500c48[_0xeb6e('0x38')];if(_0x3abd51[_0xeb6e('0x3a')][_0xeb6e('0x4c')]){_0xc2dd1[_0xeb6e('0x4d')]=[{'all':!![]}];}_0xc2dd1=_[_0xeb6e('0x48')]({},_0xc2dd1,_0x3abd51[_0xeb6e('0x4b')]);return db[_0xeb6e('0x34')][_0xeb6e('0x52')](_0xc2dd1)[_0xeb6e('0x2c')](handleEntityNotFound(_0x3cc09e,null))[_0xeb6e('0x2c')](respondWithResult(_0x3cc09e,null))['catch'](handleError(_0x3cc09e,null));};exports[_0xeb6e('0x53')]=function(_0x4e262d,_0x4a6de7){return db[_0xeb6e('0x34')][_0xeb6e('0x53')](_0x4e262d[_0xeb6e('0x54')],{})['then'](function(_0x50deec){var _0x1ab2f1=_0x4e262d[_0xeb6e('0x55')][_0xeb6e('0x56')]({'plain':!![]});if(!_0x1ab2f1)throw new Error(_0xeb6e('0x57'));if(_0x1ab2f1[_0xeb6e('0x58')]===_0xeb6e('0x55')){var _0x42122a=_0x50deec[_0xeb6e('0x56')]({'plain':!![]});var _0x452592=_0xeb6e('0x2d');return db[_0xeb6e('0x59')][_0xeb6e('0x52')]({'where':{'name':_0x452592,'userProfileId':_0x1ab2f1['userProfileId']},'raw':!![]})['then'](function(_0x5940a6){if(_0x5940a6&&_0x5940a6[_0xeb6e('0x5a')]===0x0){return db['UserProfileResource'][_0xeb6e('0x53')]({'name':_0x42122a[_0xeb6e('0x31')],'resourceId':_0x42122a['id'],'type':_0x5940a6['name'],'sectionId':_0x5940a6['id']},{})['then'](function(){return _0x50deec;});}else{return _0x50deec;}})[_0xeb6e('0x4f')](function(_0x496923){logger[_0xeb6e('0x5b')](_0xeb6e('0x5c'),_0x496923);throw _0x496923;});}return _0x50deec;})['then'](respondWithResult(_0x4a6de7,0xc9))['catch'](handleError(_0x4a6de7,null));};exports[_0xeb6e('0x2b')]=function(_0x40528b,_0x5ed6e8){if(_0x40528b[_0xeb6e('0x54')]['id']){delete _0x40528b[_0xeb6e('0x54')]['id'];}return db[_0xeb6e('0x34')][_0xeb6e('0x52')]({'where':{'id':_0x40528b['params']['id']}})[_0xeb6e('0x2c')](handleEntityNotFound(_0x5ed6e8,null))[_0xeb6e('0x2c')](saveUpdates(_0x40528b['body'],null))[_0xeb6e('0x2c')](respondWithResult(_0x5ed6e8,null))[_0xeb6e('0x4f')](handleError(_0x5ed6e8,null));};exports[_0xeb6e('0x5d')]=function(_0x242c9f,_0x4c2737){return db[_0xeb6e('0x34')]['find']({'where':{'id':_0x242c9f[_0xeb6e('0x51')]['id']}})['then'](handleEntityNotFound(_0x4c2737,null))[_0xeb6e('0x2c')](removeEntity(_0x4c2737,null))[_0xeb6e('0x4f')](handleError(_0x4c2737,null));};exports[_0xeb6e('0x5e')]=function(_0x4234da,_0x41cde5){return db[_0xeb6e('0x34')][_0xeb6e('0x5e')]()[_0xeb6e('0x2c')](respondWithResult(_0x41cde5,null))[_0xeb6e('0x4f')](handleError(_0x41cde5,null));};exports[_0xeb6e('0x5f')]=function(_0x287b1b,_0x2bd3c6,_0x5368d7){var _0x420d1f={'raw':!![],'where':{}},_0x112325={},_0x23ea1e;return db[_0xeb6e('0x34')][_0xeb6e('0x60')]({'where':{'id':_0x287b1b['params']['id']}})[_0xeb6e('0x2c')](handleEntityNotFound(_0x2bd3c6,null))[_0xeb6e('0x2c')](function(_0x2484f3){if(_0x2484f3){_0x23ea1e=_0x2484f3['get']({'plain':!![]});_0x112325[_0xeb6e('0x38')]=_['keys'](db[_0xeb6e('0x61')][_0xeb6e('0x35')]);_0x112325[_0xeb6e('0x3a')]=_[_0xeb6e('0x3b')](_0x287b1b[_0xeb6e('0x3a')]);_0x112325[_0xeb6e('0x3c')]=_[_0xeb6e('0x3d')](_0x112325[_0xeb6e('0x38')],_0x112325[_0xeb6e('0x3a')]);_0x420d1f[_0xeb6e('0x3e')]=_['intersection'](_0x112325[_0xeb6e('0x38')],qs[_0xeb6e('0x3f')](_0x287b1b[_0xeb6e('0x3a')][_0xeb6e('0x3f')]));_0x420d1f[_0xeb6e('0x3e')]=_0x420d1f['attributes'][_0xeb6e('0x40')]?_0x420d1f[_0xeb6e('0x3e')]:_0x112325[_0xeb6e('0x38')];if(!_0x287b1b[_0xeb6e('0x3a')][_0xeb6e('0x41')](_0xeb6e('0x42'))){_0x420d1f[_0xeb6e('0x24')]=qs[_0xeb6e('0x24')](_0x287b1b[_0xeb6e('0x3a')]['limit']);_0x420d1f[_0xeb6e('0x26')]=qs[_0xeb6e('0x26')](_0x287b1b['query'][_0xeb6e('0x26')]);}_0x420d1f[_0xeb6e('0x43')]=qs[_0xeb6e('0x44')](_0x287b1b[_0xeb6e('0x3a')]['sort']);_0x420d1f['where']=qs[_0xeb6e('0x3c')](_[_0xeb6e('0x46')](_0x287b1b[_0xeb6e('0x3a')],_0x112325[_0xeb6e('0x3c')]));_0x420d1f[_0xeb6e('0x45')][_0xeb6e('0x62')]=_0x2484f3['id'];if(_0x287b1b[_0xeb6e('0x3a')][_0xeb6e('0x47')]){_0x420d1f[_0xeb6e('0x45')]=_[_0xeb6e('0x48')](_0x420d1f[_0xeb6e('0x45')],{'$or':_['map'](_0x420d1f['attributes'],function(_0x2b62b9){var _0xc054c0={};_0xc054c0[_0x2b62b9]={'$like':'%'+_0x287b1b[_0xeb6e('0x3a')][_0xeb6e('0x47')]+'%'};return _0xc054c0;})});}_0x420d1f=_[_0xeb6e('0x48')]({},_0x420d1f,_0x287b1b['options']);return db['UserOpenchannelQueue'][_0xeb6e('0x63')](_0x420d1f);}})[_0xeb6e('0x2c')](function(_0x2cc1cc){if(_0x2cc1cc){return db[_0xeb6e('0x64')][_0xeb6e('0x65')]({'where':{'id':_['map'](_0x2cc1cc,'UserId'),'role':_0xeb6e('0x66')},'attributes':['id',_0xeb6e('0x31'),_0xeb6e('0x67'),_0xeb6e('0x68'),_0xeb6e('0x69')]});}})[_0xeb6e('0x2c')](function(_0x10464c){if(_0x10464c){return{'count':_0x10464c['count'],'rows':_[_0xeb6e('0x39')](_0x10464c['rows'],function(_0x3f1016){return{'membername':_0x3f1016[_0xeb6e('0x31')],'UserId':_0x3f1016['id'],'queue_name':_0x23ea1e[_0xeb6e('0x31')],'OpenchannelQueueId':_0x23ea1e['id'],'interface':util[_0xeb6e('0x6a')]('%s/%s',_0xeb6e('0x6b'),_0x3f1016[_0xeb6e('0x31')]),'penalty':0x0,'paused':_0x3f1016[_0xeb6e('0x67')],'createdAt':_0x3f1016[_0xeb6e('0x69')],'updatedAt':_0x3f1016[_0xeb6e('0x68')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xeb6e('0x2c')](respondWithFilteredResult(_0x2bd3c6,_0x420d1f))[_0xeb6e('0x4f')](handleError(_0x2bd3c6,null));};exports[_0xeb6e('0x6c')]=function(_0x2b716c,_0xba460c,_0x74a8ca){var _0x2d71e2={};var _0x2b6b7e={};var _0x1f4384;var _0xae05eb;return db['OpenchannelQueue']['findOne']({'where':{'id':_0x2b716c[_0xeb6e('0x51')]['id']}})['then'](handleEntityNotFound(_0xba460c,null))[_0xeb6e('0x2c')](function(_0xf111a0){if(_0xf111a0){_0x1f4384=_0xf111a0;_0x2b6b7e[_0xeb6e('0x38')]=_['keys'](db['Team']['rawAttributes']);_0x2b6b7e['query']=_[_0xeb6e('0x3b')](_0x2b716c[_0xeb6e('0x3a')]);_0x2b6b7e[_0xeb6e('0x3c')]=_[_0xeb6e('0x3d')](_0x2b6b7e[_0xeb6e('0x38')],_0x2b6b7e['query']);_0x2d71e2[_0xeb6e('0x3e')]=_['intersection'](_0x2b6b7e[_0xeb6e('0x38')],qs[_0xeb6e('0x3f')](_0x2b716c['query'][_0xeb6e('0x3f')]));_0x2d71e2[_0xeb6e('0x3e')]=_0x2d71e2[_0xeb6e('0x3e')][_0xeb6e('0x40')]?_0x2d71e2['attributes']:_0x2b6b7e[_0xeb6e('0x38')];_0x2d71e2[_0xeb6e('0x43')]=qs[_0xeb6e('0x44')](_0x2b716c['query'][_0xeb6e('0x44')]);_0x2d71e2[_0xeb6e('0x45')]=qs[_0xeb6e('0x3c')](_[_0xeb6e('0x46')](_0x2b716c['query'],_0x2b6b7e['filters']));if(_0x2b716c[_0xeb6e('0x3a')][_0xeb6e('0x47')]){_0x2d71e2['where']=_['merge'](_0x2d71e2[_0xeb6e('0x45')],{'$or':_[_0xeb6e('0x39')](_0x2d71e2[_0xeb6e('0x3e')],function(_0x168fec){var _0x22db13={};_0x22db13[_0x168fec]={'$like':'%'+_0x2b716c['query'][_0xeb6e('0x47')]+'%'};return _0x22db13;})});}_0x2d71e2=_[_0xeb6e('0x48')]({},_0x2d71e2,_0x2b716c[_0xeb6e('0x4b')]);return _0x1f4384['getTeams'](_0x2d71e2);}})[_0xeb6e('0x2c')](function(_0x2eb2f8){if(_0x2eb2f8){_0xae05eb=_0x2eb2f8[_0xeb6e('0x40')];if(!_0x2b716c['query'][_0xeb6e('0x41')]('nolimit')){_0x2d71e2[_0xeb6e('0x24')]=qs['limit'](_0x2b716c[_0xeb6e('0x3a')][_0xeb6e('0x24')]);_0x2d71e2[_0xeb6e('0x26')]=qs[_0xeb6e('0x26')](_0x2b716c[_0xeb6e('0x3a')][_0xeb6e('0x26')]);}return _0x1f4384[_0xeb6e('0x6c')](_0x2d71e2);}})[_0xeb6e('0x2c')](function(_0x5811d3){if(_0x5811d3){return _0x5811d3?{'count':_0xae05eb,'rows':_0x5811d3}:null;}})[_0xeb6e('0x2c')](respondWithResult(_0xba460c,null))['catch'](handleError(_0xba460c,null));};exports['addTeams']=function(_0x544926,_0x56da12,_0x4b0cb2){var _0x2deaa7=_0x544926[_0xeb6e('0x54')][_0xeb6e('0x6d')];return db[_0xeb6e('0x6e')]['findAll']({'where':{'id':_0x2deaa7},'attributes':['id'],'include':[{'model':db[_0xeb6e('0x64')],'as':_0xeb6e('0x6f'),'attributes':['id',_0xeb6e('0x31'),'online','voicePause',_0xeb6e('0x70')],'raw':!![]}]})[_0xeb6e('0x2c')](function(_0x25bc92){if(_0x25bc92){var _0x1119a7=_[_0xeb6e('0x71')](_0x25bc92,function(_0x576b13){var _0x263b54=_0x576b13[_0xeb6e('0x56')]({'plain':!![]});return _0x263b54['Agents'];});return db['OpenchannelQueue'][_0xeb6e('0x52')]({'where':{'id':_0x544926[_0xeb6e('0x51')]['id']}})['then'](function(_0x1a8374){return db[_0xeb6e('0x72')]['transaction'](function(_0x4fd05f){return _0x1a8374['addTeams'](_0x2deaa7,{'transaction':_0x4fd05f})[_0xeb6e('0x2c')](function(){return BPromise[_0xeb6e('0x73')](_0x1119a7,function(_0x1a0829){return db[_0xeb6e('0x61')][_0xeb6e('0x74')]({'where':{'UserId':_0x1a0829['id'],'OpenchannelQueueId':_0x544926[_0xeb6e('0x51')]['id']},'transaction':_0x4fd05f});});})[_0xeb6e('0x2c')](function(){_0x1119a7[_0xeb6e('0x75')](function(_0xb7d6ec){socket[_0xeb6e('0x76')]('userOpenchannelQueue:save',{'UserId':_0xb7d6ec['id'],'OpenchannelQueueId':_0x1a8374['id']});});});});});}})[_0xeb6e('0x2c')](respondWithStatusCode(_0x56da12,null))[_0xeb6e('0x4f')](handleError(_0x56da12,null));};exports[_0xeb6e('0x77')]=function(_0xda68c,_0x343a6c,_0x27325e){return db[_0xeb6e('0x6e')][_0xeb6e('0x63')]({'where':{'id':_0xda68c[_0xeb6e('0x3a')][_0xeb6e('0x6d')]},'attributes':['id'],'include':[{'model':db[_0xeb6e('0x64')],'as':_0xeb6e('0x6f'),'attributes':['id'],'raw':!![]}]})[_0xeb6e('0x2c')](handleEntityNotFound(_0x343a6c,null))['then'](function(_0x8a47b5){var _0x3f06c0=_[_0xeb6e('0x39')](_0x8a47b5,'id');var _0x4e9177=[];var _0x90c2ae=[];var _0x47489d=squel['select']();_0x47489d[_0xeb6e('0x78')](_0xeb6e('0x79'))[_0xeb6e('0x7a')](_0xeb6e('0x7b'),'tq')[_0xeb6e('0x7c')](_0xeb6e('0x7d'),'ut',_0xeb6e('0x7e'))['where'](_0xeb6e('0x7f'),_0xda68c[_0xeb6e('0x51')]['id']);for(var _0x4b80b4=0x0;_0x4b80b4<_0x8a47b5[_0xeb6e('0x40')];_0x4b80b4+=0x1){let _0x196f57=_0x8a47b5[_0x4b80b4];for(var _0x42213f=0x0;_0x42213f<_0x196f57[_0xeb6e('0x6f')][_0xeb6e('0x40')];_0x42213f+=0x1){let _0x1d649c=_0x196f57['Agents'][_0x42213f];var _0x121c3f=_0x47489d[_0xeb6e('0x80')]();_0x121c3f['where'](_0xeb6e('0x81'),_0x1d649c['id']);_0x90c2ae['push'](db[_0xeb6e('0x72')][_0xeb6e('0x3a')](_0x121c3f['toString'](),{'type':db['sequelize'][_0xeb6e('0x82')][_0xeb6e('0x83')]})['then'](function(_0x2fb407){if(_0x2fb407[_0xeb6e('0x40')]===0x1){return _0x1d649c['id'];}else{var _0x4d359b=_[_0xeb6e('0x84')](_[_0xeb6e('0x39')](_0x2fb407,_0xeb6e('0x85')),function(_0x5c85e3){return _[_0xeb6e('0x86')](_0x3f06c0,_0x5c85e3);});if(_0x4d359b){return _0x1d649c['id'];}}}));}}return BPromise[_0xeb6e('0x87')](_0x90c2ae)[_0xeb6e('0x2c')](function(_0x3c0341){_0x4e9177=_(_0x4e9177)['union'](_0x3c0341)[_0xeb6e('0x88')]()[_0xeb6e('0x89')]();return db[_0xeb6e('0x34')][_0xeb6e('0x52')]({'where':{'id':_0xda68c[_0xeb6e('0x51')]['id']}})[_0xeb6e('0x2c')](function(_0x2828e3){return db[_0xeb6e('0x72')][_0xeb6e('0x8a')](function(_0x3fc9b2){return _0x2828e3[_0xeb6e('0x77')](_0xda68c[_0xeb6e('0x3a')]['ids'],{'transaction':_0x3fc9b2})['then'](function(){if(!_[_0xeb6e('0x8b')](_0x4e9177)){return _0x2828e3[_0xeb6e('0x8c')](_0x4e9177,{'transaction':_0x3fc9b2});}})[_0xeb6e('0x2c')](function(){_0x4e9177[_0xeb6e('0x75')](function(_0x56ae45){socket['emit']('userOpenchannelQueue:remove',{'UserId':_0x56ae45,'OpenchannelQueueId':_0x2828e3['id']});});});});});});})[_0xeb6e('0x2c')](respondWithStatusCode(_0x343a6c,null))[_0xeb6e('0x4f')](handleError(_0x343a6c,null));};exports[_0xeb6e('0x8d')]=function(_0x2d2351,_0x30de46,_0x382f5b){return db[_0xeb6e('0x34')][_0xeb6e('0x52')]({'where':{'id':_0x2d2351[_0xeb6e('0x51')]['id']}})[_0xeb6e('0x2c')](handleEntityNotFound(_0x30de46,null))[_0xeb6e('0x2c')](function(_0x3ec1b4){if(_0x3ec1b4){return _0x3ec1b4['addAgents'](_0x2d2351[_0xeb6e('0x54')][_0xeb6e('0x6d')],_['omit'](_0x2d2351['body'],[_0xeb6e('0x6d'),'id'])||{})[_0xeb6e('0x8e')](function(_0x34d6ed){for(var _0x436609=0x0;_0x436609<_0x2d2351[_0xeb6e('0x54')]['ids'][_0xeb6e('0x40')];_0x436609+=0x1){socket['emit'](_0xeb6e('0x8f'),{'UserId':Number(_0x2d2351['body'][_0xeb6e('0x6d')][_0x436609]),'OpenchannelQueueId':Number(_0x2d2351[_0xeb6e('0x51')]['id'])});}return _0x34d6ed;});}})['then'](respondWithResult(_0x30de46,null))['catch'](handleError(_0x30de46,null));};exports['removeAgents']=function(_0x2a557c,_0x271ea5,_0x1f8ead){return db['OpenchannelQueue']['find']({'where':{'id':_0x2a557c[_0xeb6e('0x51')]['id']}})[_0xeb6e('0x2c')](handleEntityNotFound(_0x271ea5,null))[_0xeb6e('0x2c')](function(_0x47f085){if(_0x47f085){return _0x47f085[_0xeb6e('0x8c')](_0x2a557c[_0xeb6e('0x3a')][_0xeb6e('0x6d')])[_0xeb6e('0x2c')](function(){if(_[_0xeb6e('0x90')](_0x2a557c[_0xeb6e('0x3a')][_0xeb6e('0x6d')])){for(var _0x58dcf3=0x0;_0x58dcf3<_0x2a557c[_0xeb6e('0x3a')][_0xeb6e('0x6d')][_0xeb6e('0x40')];_0x58dcf3+=0x1){socket['emit']('userOpenchannelQueue:remove',{'UserId':Number(_0x2a557c['query']['ids'][_0x58dcf3]),'OpenchannelQueueId':Number(_0x2a557c[_0xeb6e('0x51')]['id'])});}}else{socket['emit']('userOpenchannelQueue:remove',{'UserId':Number(_0x2a557c[_0xeb6e('0x3a')][_0xeb6e('0x6d')]),'OpenchannelQueueId':Number(_0x2a557c[_0xeb6e('0x51')]['id'])});}});}})['then'](respondWithStatusCode(_0x271ea5,null))[_0xeb6e('0x4f')](handleError(_0x271ea5,null));};exports[_0xeb6e('0x91')]=function(_0x4341ff,_0x432fdc,_0x5f003d){var _0x5e5e37={};var _0x379c99={};var _0x4aa59e;var _0x1ddbf1;return db[_0xeb6e('0x34')][_0xeb6e('0x60')]({'where':{'id':_0x4341ff[_0xeb6e('0x51')]['id']}})['then'](handleEntityNotFound(_0x432fdc,null))[_0xeb6e('0x2c')](function(_0x1a746d){if(_0x1a746d){_0x4aa59e=_0x1a746d;_0x379c99[_0xeb6e('0x38')]=_[_0xeb6e('0x3b')](db[_0xeb6e('0x64')][_0xeb6e('0x35')]);_0x379c99[_0xeb6e('0x3a')]=_[_0xeb6e('0x3b')](_0x4341ff[_0xeb6e('0x3a')]);_0x379c99[_0xeb6e('0x3c')]=_[_0xeb6e('0x3d')](_0x379c99[_0xeb6e('0x38')],_0x379c99[_0xeb6e('0x3a')]);_0x5e5e37[_0xeb6e('0x3e')]=_[_0xeb6e('0x3d')](_0x379c99[_0xeb6e('0x38')],qs[_0xeb6e('0x3f')](_0x4341ff[_0xeb6e('0x3a')][_0xeb6e('0x3f')]));_0x5e5e37['attributes']=_0x5e5e37[_0xeb6e('0x3e')][_0xeb6e('0x40')]?_0x5e5e37[_0xeb6e('0x3e')]:_0x379c99[_0xeb6e('0x38')];_0x5e5e37[_0xeb6e('0x43')]=qs['sort'](_0x4341ff[_0xeb6e('0x3a')][_0xeb6e('0x44')]);_0x5e5e37[_0xeb6e('0x45')]=qs[_0xeb6e('0x3c')](_[_0xeb6e('0x46')](_0x4341ff['query'],_0x379c99[_0xeb6e('0x3c')]));if(_0x4341ff[_0xeb6e('0x3a')][_0xeb6e('0x47')]){_0x5e5e37[_0xeb6e('0x45')]=_[_0xeb6e('0x48')](_0x5e5e37[_0xeb6e('0x45')],{'$or':_['map'](_0x5e5e37[_0xeb6e('0x3e')],function(_0x29d3d3){var _0x4cbde8={};_0x4cbde8[_0x29d3d3]={'$like':'%'+_0x4341ff[_0xeb6e('0x3a')][_0xeb6e('0x47')]+'%'};return _0x4cbde8;})});}_0x5e5e37=_['merge']({},_0x5e5e37,_0x4341ff[_0xeb6e('0x4b')]);return _0x4aa59e['getAgents'](_0x5e5e37);}})[_0xeb6e('0x2c')](function(_0x47d298){if(_0x47d298){_0x1ddbf1=_0x47d298[_0xeb6e('0x40')];if(!_0x4341ff['query'][_0xeb6e('0x41')](_0xeb6e('0x42'))){_0x5e5e37[_0xeb6e('0x24')]=qs[_0xeb6e('0x24')](_0x4341ff[_0xeb6e('0x3a')]['limit']);_0x5e5e37[_0xeb6e('0x26')]=qs[_0xeb6e('0x26')](_0x4341ff[_0xeb6e('0x3a')]['offset']);}return _0x4aa59e[_0xeb6e('0x91')](_0x5e5e37);}})['then'](function(_0x15770d){if(_0x15770d){return _0x15770d?{'count':_0x1ddbf1,'rows':_0x15770d}:null;}})['then'](respondWithResult(_0x432fdc,null))[_0xeb6e('0x4f')](handleError(_0x432fdc,null));};
\ No newline at end of file