Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index 9da0d41..868113a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x755a=['online','voicePause','flatMap','sequelize','transaction','each','findOrCreate','emit','removeTeams','field','from','join','clone','ut.UserId\x20=\x20?','push','toString','SELECT','every','TeamId','includes','compact','value','isEmpty','removeAgents','forEach','userOpenchannelQueue:remove','addAgents','omit','spread','isArray','getAgents','lodash','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./openchannelQueue.socket','register','sendStatus','status','end','json','offset','count','set','Content-Range','then','get','UserProfileResource','destroy','error','stack','name','send','index','map','OpenchannelQueue','rawAttributes','fieldName','where','include','query','findAll','rows','catch','model','keys','filters','intersection','attributes','fields','length','merge','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','OpenchannelQueues','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','describe','getMembers','findOne','UserOpenchannelQueue','hasOwnProperty','nolimit','limit','order','sort','pick','OpenchannelQueueId','filter','options','User','UserId','agent','updatedAt','format','%s/%s','createdAt','getTeams','Team','addTeams','ids','Agents'];(function(_0xb1cf84,_0x813740){var _0x4bad2e=function(_0x53e6f2){while(--_0x53e6f2){_0xb1cf84['push'](_0xb1cf84['shift']());}};_0x4bad2e(++_0x813740);}(_0x755a,0x109));var _0xa755=function(_0x17d831,_0x2bacc7){_0x17d831=_0x17d831-0x0;var _0x13250d=_0x755a[_0x17d831];return _0x13250d;};'use strict';var BPromise=require('bluebird');var util=require('util');var _=require(_0xa755('0x0'));var squel=require(_0xa755('0x1'));var Redis=require(_0xa755('0x2'));var qs=require(_0xa755('0x3'));var logger=require(_0xa755('0x4'))(_0xa755('0x5'));var config=require(_0xa755('0x6'));var db=require(_0xa755('0x7'))['db'];config[_0xa755('0x8')]=_['defaults'](config[_0xa755('0x8')],{'host':_0xa755('0x9'),'port':0x18eb});var socket=require(_0xa755('0xa'))(new Redis(config[_0xa755('0x8')]));require(_0xa755('0xb'))[_0xa755('0xc')](socket);function respondWithStatusCode(_0x4987a3,_0x1cf6e9){_0x1cf6e9=_0x1cf6e9||0xcc;return function(_0x164b86){if(_0x164b86){return _0x4987a3[_0xa755('0xd')](_0x1cf6e9);}return _0x4987a3[_0xa755('0xe')](_0x1cf6e9)[_0xa755('0xf')]();};}function respondWithResult(_0x32120c,_0x24b17b){_0x24b17b=_0x24b17b||0xc8;return function(_0x19f732){if(_0x19f732){return _0x32120c['status'](_0x24b17b)[_0xa755('0x10')](_0x19f732);}};}function respondWithFilteredResult(_0x240048,_0xf3bc7){return function(_0x22a657){if(_0x22a657){var _0x5033f2=typeof _0xf3bc7[_0xa755('0x11')]==='undefined'&&typeof _0xf3bc7['limit']==='undefined';var _0x4a3bc6=_0x22a657[_0xa755('0x12')];var _0x1ea58e=_0x5033f2?0x0:_0xf3bc7[_0xa755('0x11')];var _0x5cb813=_0x5033f2?_0x22a657[_0xa755('0x12')]:_0xf3bc7[_0xa755('0x11')]+_0xf3bc7['limit'];var _0x75720a;if(_0x5cb813>=_0x4a3bc6){_0x5cb813=_0x4a3bc6;_0x75720a=0xc8;}else{_0x75720a=0xce;}_0x240048[_0xa755('0xe')](_0x75720a);return _0x240048[_0xa755('0x13')](_0xa755('0x14'),_0x1ea58e+'-'+_0x5cb813+'/'+_0x4a3bc6)['json'](_0x22a657);}return null;};}function saveUpdates(_0x4cd9e0){return function(_0x423c2b){if(_0x423c2b){return _0x423c2b['update'](_0x4cd9e0)[_0xa755('0x15')](function(_0x420ce4){return _0x420ce4;});}return null;};}function removeEntity(_0x3269ed){return function(_0x172a40){if(_0x172a40){return _0x172a40['destroy']()['then'](function(){var _0xe8bfaa=_0x172a40[_0xa755('0x16')]({'plain':!![]});var _0x2365be='OpenchannelQueues';return db[_0xa755('0x17')][_0xa755('0x18')]({'where':{'type':_0x2365be,'resourceId':_0xe8bfaa['id']}})[_0xa755('0x15')](function(){return _0x172a40;});})[_0xa755('0x15')](function(){_0x3269ed[_0xa755('0xe')](0xcc)[_0xa755('0xf')]();});}};}function handleEntityNotFound(_0x191410){return function(_0xac511c){if(!_0xac511c){_0x191410[_0xa755('0xd')](0x194);}return _0xac511c;};}function handleError(_0x425d68,_0x5d70eb){_0x5d70eb=_0x5d70eb||0x1f4;return function(_0x59474f){logger[_0xa755('0x19')](_0x59474f[_0xa755('0x1a')]);if(_0x59474f['name']){delete _0x59474f[_0xa755('0x1b')];}_0x425d68[_0xa755('0xe')](_0x5d70eb)[_0xa755('0x1c')](_0x59474f);};}exports[_0xa755('0x1d')]=function(_0x7ddda6,_0x34dce8){var _0x4a403d={};var _0x165116={'count':0x0,'rows':[]};var _0x5d42be=_[_0xa755('0x1e')](db[_0xa755('0x1f')][_0xa755('0x20')],function(_0x252bf9){return{'name':_0x252bf9[_0xa755('0x21')],'type':_0x252bf9['type']['key']};});_0x4a403d=qs['getOptions'](_0x5d42be,_0x7ddda6);var _0x5732eb={'where':_0x4a403d[_0xa755('0x22')]};return db[_0xa755('0x1f')][_0xa755('0x12')](_0x5732eb)[_0xa755('0x15')](function(_0x5a2e4d){_0x165116[_0xa755('0x12')]=_0x5a2e4d;_0x4a403d[_0xa755('0x23')]=qs[_0xa755('0x23')](_0x7ddda6[_0xa755('0x24')]);return db[_0xa755('0x1f')][_0xa755('0x25')](_0x4a403d);})[_0xa755('0x15')](function(_0x4aacd7){_0x165116[_0xa755('0x26')]=_0x4aacd7;return _0x165116;})['then'](respondWithFilteredResult(_0x34dce8,_0x4a403d))[_0xa755('0x27')](handleError(_0x34dce8,null));};exports['show']=function(_0x8596a2,_0x356835){var _0xffd19d={'raw':!![],'where':{'id':_0x8596a2['params']['id']}},_0x1f7aae={};_0x1f7aae[_0xa755('0x28')]=_[_0xa755('0x29')](db[_0xa755('0x1f')][_0xa755('0x20')]);_0x1f7aae['query']=_[_0xa755('0x29')](_0x8596a2['query']);_0x1f7aae[_0xa755('0x2a')]=_[_0xa755('0x2b')](_0x1f7aae[_0xa755('0x28')],_0x1f7aae['query']);_0xffd19d[_0xa755('0x2c')]=_[_0xa755('0x2b')](_0x1f7aae[_0xa755('0x28')],qs[_0xa755('0x2d')](_0x8596a2[_0xa755('0x24')][_0xa755('0x2d')]));_0xffd19d[_0xa755('0x2c')]=_0xffd19d[_0xa755('0x2c')][_0xa755('0x2e')]?_0xffd19d[_0xa755('0x2c')]:_0x1f7aae[_0xa755('0x28')];if(_0x8596a2[_0xa755('0x24')]['includeAll']){_0xffd19d['include']=[{'all':!![]}];}_0xffd19d=_[_0xa755('0x2f')]({},_0xffd19d,_0x8596a2['options']);return db[_0xa755('0x1f')]['find'](_0xffd19d)[_0xa755('0x15')](handleEntityNotFound(_0x356835,null))[_0xa755('0x15')](respondWithResult(_0x356835,null))['catch'](handleError(_0x356835,null));};exports['create']=function(_0x5a2666,_0x23a781){return db[_0xa755('0x1f')][_0xa755('0x30')](_0x5a2666[_0xa755('0x31')],{})[_0xa755('0x15')](function(_0x55f971){var _0x3e8443=_0x5a2666[_0xa755('0x32')][_0xa755('0x16')]({'plain':!![]});if(!_0x3e8443)throw new Error(_0xa755('0x33'));if(_0x3e8443[_0xa755('0x34')]===_0xa755('0x32')){var _0x231d7a=_0x55f971['get']({'plain':!![]});var _0x549bc2=_0xa755('0x35');return db[_0xa755('0x36')][_0xa755('0x37')]({'where':{'name':_0x549bc2,'userProfileId':_0x3e8443[_0xa755('0x38')]},'raw':!![]})[_0xa755('0x15')](function(_0x293d99){if(_0x293d99&&_0x293d99[_0xa755('0x39')]===0x0){return db[_0xa755('0x17')]['create']({'name':_0x231d7a[_0xa755('0x1b')],'resourceId':_0x231d7a['id'],'type':_0x293d99['name'],'sectionId':_0x293d99['id']},{})['then'](function(){return _0x55f971;});}else{return _0x55f971;}})[_0xa755('0x27')](function(_0x2fc6d4){logger[_0xa755('0x19')](_0xa755('0x3a'),_0x2fc6d4);throw _0x2fc6d4;});}return _0x55f971;})[_0xa755('0x15')](respondWithResult(_0x23a781,0xc9))['catch'](handleError(_0x23a781,null));};exports[_0xa755('0x3b')]=function(_0xf5cb8d,_0x5858ab){if(_0xf5cb8d[_0xa755('0x31')]['id']){delete _0xf5cb8d['body']['id'];}return db['OpenchannelQueue'][_0xa755('0x37')]({'where':{'id':_0xf5cb8d[_0xa755('0x3c')]['id']}})[_0xa755('0x15')](handleEntityNotFound(_0x5858ab,null))[_0xa755('0x15')](saveUpdates(_0xf5cb8d['body'],null))[_0xa755('0x15')](respondWithResult(_0x5858ab,null))['catch'](handleError(_0x5858ab,null));};exports[_0xa755('0x18')]=function(_0x378adb,_0x1c7315){return db['OpenchannelQueue'][_0xa755('0x37')]({'where':{'id':_0x378adb[_0xa755('0x3c')]['id']}})[_0xa755('0x15')](handleEntityNotFound(_0x1c7315,null))[_0xa755('0x15')](removeEntity(_0x1c7315,null))[_0xa755('0x27')](handleError(_0x1c7315,null));};exports[_0xa755('0x3d')]=function(_0x549c15,_0x5b39e4){return db[_0xa755('0x1f')][_0xa755('0x3d')]()[_0xa755('0x15')](respondWithResult(_0x5b39e4,null))['catch'](handleError(_0x5b39e4,null));};exports[_0xa755('0x3e')]=function(_0x42b97c,_0x1f42d6){var _0x402bed={'raw':!![],'where':{}},_0xf1e4b5={},_0x17d800;return db['OpenchannelQueue'][_0xa755('0x3f')]({'where':{'id':_0x42b97c[_0xa755('0x3c')]['id']}})[_0xa755('0x15')](handleEntityNotFound(_0x1f42d6,null))[_0xa755('0x15')](function(_0x49aa43){if(_0x49aa43){_0x17d800=_0x49aa43[_0xa755('0x16')]({'plain':!![]});_0xf1e4b5[_0xa755('0x28')]=_['keys'](db[_0xa755('0x40')][_0xa755('0x20')]);_0xf1e4b5['query']=_[_0xa755('0x29')](_0x42b97c[_0xa755('0x24')]);_0xf1e4b5[_0xa755('0x2a')]=_[_0xa755('0x2b')](_0xf1e4b5[_0xa755('0x28')],_0xf1e4b5[_0xa755('0x24')]);_0x402bed[_0xa755('0x2c')]=_[_0xa755('0x2b')](_0xf1e4b5[_0xa755('0x28')],qs[_0xa755('0x2d')](_0x42b97c['query'][_0xa755('0x2d')]));_0x402bed[_0xa755('0x2c')]=_0x402bed['attributes'][_0xa755('0x2e')]?_0x402bed[_0xa755('0x2c')]:_0xf1e4b5[_0xa755('0x28')];if(!_0x42b97c[_0xa755('0x24')][_0xa755('0x41')](_0xa755('0x42'))){_0x402bed[_0xa755('0x43')]=qs[_0xa755('0x43')](_0x42b97c[_0xa755('0x24')][_0xa755('0x43')]);_0x402bed[_0xa755('0x11')]=qs[_0xa755('0x11')](_0x42b97c['query'][_0xa755('0x11')]);}_0x402bed[_0xa755('0x44')]=qs[_0xa755('0x45')](_0x42b97c[_0xa755('0x24')][_0xa755('0x45')]);_0x402bed[_0xa755('0x22')]=qs[_0xa755('0x2a')](_[_0xa755('0x46')](_0x42b97c[_0xa755('0x24')],_0xf1e4b5[_0xa755('0x2a')]));_0x402bed[_0xa755('0x22')][_0xa755('0x47')]=_0x49aa43['id'];if(_0x42b97c['query'][_0xa755('0x48')]){_0x402bed[_0xa755('0x22')]=_[_0xa755('0x2f')](_0x402bed['where'],{'$or':_[_0xa755('0x1e')](_0x402bed[_0xa755('0x2c')],function(_0x3389f5){var _0x4847b3={};_0x4847b3[_0x3389f5]={'$like':'%'+_0x42b97c[_0xa755('0x24')][_0xa755('0x48')]+'%'};return _0x4847b3;})});}_0x402bed=_[_0xa755('0x2f')]({},_0x402bed,_0x42b97c[_0xa755('0x49')]);return db[_0xa755('0x40')][_0xa755('0x25')](_0x402bed);}})[_0xa755('0x15')](function(_0x47bdb2){if(_0x47bdb2){return db[_0xa755('0x4a')]['findAndCountAll']({'where':{'id':_[_0xa755('0x1e')](_0x47bdb2,_0xa755('0x4b')),'role':_0xa755('0x4c')},'attributes':['id',_0xa755('0x1b'),'openchannelPause',_0xa755('0x4d'),'createdAt']});}})['then'](function(_0x1eea41){if(_0x1eea41){return{'count':_0x1eea41[_0xa755('0x12')],'rows':_[_0xa755('0x1e')](_0x1eea41[_0xa755('0x26')],function(_0xaa800f){return{'membername':_0xaa800f['name'],'UserId':_0xaa800f['id'],'queue_name':_0x17d800['name'],'OpenchannelQueueId':_0x17d800['id'],'interface':util[_0xa755('0x4e')](_0xa755('0x4f'),'SIP',_0xaa800f['name']),'penalty':0x0,'paused':_0xaa800f['openchannelPause'],'createdAt':_0xaa800f[_0xa755('0x50')],'updatedAt':_0xaa800f[_0xa755('0x4d')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xa755('0x15')](respondWithFilteredResult(_0x1f42d6,_0x402bed))[_0xa755('0x27')](handleError(_0x1f42d6,null));};exports[_0xa755('0x51')]=function(_0x39b63a,_0x552a50){var _0x11f344={};var _0xba3fb5={};var _0x93af6d;var _0x53e600;return db[_0xa755('0x1f')]['findOne']({'where':{'id':_0x39b63a['params']['id']}})[_0xa755('0x15')](handleEntityNotFound(_0x552a50,null))[_0xa755('0x15')](function(_0x49bbc0){if(_0x49bbc0){_0x93af6d=_0x49bbc0;_0xba3fb5[_0xa755('0x28')]=_[_0xa755('0x29')](db[_0xa755('0x52')][_0xa755('0x20')]);_0xba3fb5['query']=_['keys'](_0x39b63a['query']);_0xba3fb5[_0xa755('0x2a')]=_[_0xa755('0x2b')](_0xba3fb5[_0xa755('0x28')],_0xba3fb5[_0xa755('0x24')]);_0x11f344['attributes']=_[_0xa755('0x2b')](_0xba3fb5[_0xa755('0x28')],qs['fields'](_0x39b63a[_0xa755('0x24')][_0xa755('0x2d')]));_0x11f344[_0xa755('0x2c')]=_0x11f344[_0xa755('0x2c')][_0xa755('0x2e')]?_0x11f344[_0xa755('0x2c')]:_0xba3fb5[_0xa755('0x28')];_0x11f344[_0xa755('0x44')]=qs[_0xa755('0x45')](_0x39b63a['query']['sort']);_0x11f344[_0xa755('0x22')]=qs[_0xa755('0x2a')](_[_0xa755('0x46')](_0x39b63a[_0xa755('0x24')],_0xba3fb5['filters']));if(_0x39b63a[_0xa755('0x24')][_0xa755('0x48')]){_0x11f344[_0xa755('0x22')]=_[_0xa755('0x2f')](_0x11f344[_0xa755('0x22')],{'$or':_['map'](_0x11f344[_0xa755('0x2c')],function(_0x39f152){var _0x122cfe={};_0x122cfe[_0x39f152]={'$like':'%'+_0x39b63a['query'][_0xa755('0x48')]+'%'};return _0x122cfe;})});}_0x11f344=_['merge']({},_0x11f344,_0x39b63a[_0xa755('0x49')]);return _0x93af6d[_0xa755('0x51')](_0x11f344);}})[_0xa755('0x15')](function(_0x85b239){if(_0x85b239){_0x53e600=_0x85b239[_0xa755('0x2e')];if(!_0x39b63a[_0xa755('0x24')]['hasOwnProperty'](_0xa755('0x42'))){_0x11f344[_0xa755('0x43')]=qs[_0xa755('0x43')](_0x39b63a[_0xa755('0x24')]['limit']);_0x11f344['offset']=qs[_0xa755('0x11')](_0x39b63a[_0xa755('0x24')]['offset']);}return _0x93af6d[_0xa755('0x51')](_0x11f344);}})[_0xa755('0x15')](function(_0x391775){if(_0x391775){return _0x391775?{'count':_0x53e600,'rows':_0x391775}:null;}})[_0xa755('0x15')](respondWithResult(_0x552a50,null))[_0xa755('0x27')](handleError(_0x552a50,null));};exports[_0xa755('0x53')]=function(_0x4bbb52,_0x41d47c){var _0xf68b35=_0x4bbb52[_0xa755('0x31')][_0xa755('0x54')];return db[_0xa755('0x52')][_0xa755('0x25')]({'where':{'id':_0xf68b35},'attributes':['id'],'include':[{'model':db[_0xa755('0x4a')],'as':_0xa755('0x55'),'attributes':['id',_0xa755('0x1b'),_0xa755('0x56'),_0xa755('0x57'),'interface'],'raw':!![]}]})['then'](function(_0x19cb08){if(_0x19cb08){var _0x140fea=_[_0xa755('0x58')](_0x19cb08,function(_0x2889c7){var _0x2c2953=_0x2889c7['get']({'plain':!![]});return _0x2c2953[_0xa755('0x55')];});return db[_0xa755('0x1f')][_0xa755('0x37')]({'where':{'id':_0x4bbb52['params']['id']}})[_0xa755('0x15')](function(_0x13ed30){return db[_0xa755('0x59')][_0xa755('0x5a')](function(_0x5d8bc8){return _0x13ed30[_0xa755('0x53')](_0xf68b35,{'transaction':_0x5d8bc8})[_0xa755('0x15')](function(){return BPromise[_0xa755('0x5b')](_0x140fea,function(_0xa7d8de){return db['UserOpenchannelQueue'][_0xa755('0x5c')]({'where':{'UserId':_0xa7d8de['id'],'OpenchannelQueueId':_0x4bbb52['params']['id']},'transaction':_0x5d8bc8});});})[_0xa755('0x15')](function(){_0x140fea['forEach'](function(_0x4532de){socket[_0xa755('0x5d')]('userOpenchannelQueue:save',{'UserId':_0x4532de['id'],'OpenchannelQueueId':_0x13ed30['id']});});});});});}})[_0xa755('0x15')](respondWithStatusCode(_0x41d47c,null))[_0xa755('0x27')](handleError(_0x41d47c,null));};exports[_0xa755('0x5e')]=function(_0xe6d4ed,_0x44d39f){return db[_0xa755('0x52')][_0xa755('0x25')]({'where':{'id':_0xe6d4ed[_0xa755('0x24')][_0xa755('0x54')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0xa755('0x55'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x44d39f,null))[_0xa755('0x15')](function(_0x2513f2){var _0x5ae837=_[_0xa755('0x1e')](_0x2513f2,'id');var _0x3c59e2=[];var _0x312313=[];var _0x70c141=squel['select']();_0x70c141[_0xa755('0x5f')]('tq.TeamId')[_0xa755('0x60')]('team_has_openchannel_queues','tq')[_0xa755('0x61')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0xa755('0x22')]('OpenchannelQueueId\x20=\x20?',_0xe6d4ed[_0xa755('0x3c')]['id']);for(var _0x335356=0x0;_0x335356<_0x2513f2[_0xa755('0x2e')];_0x335356+=0x1){let _0x11fa2f=_0x2513f2[_0x335356];for(var _0x3623f6=0x0;_0x3623f6<_0x11fa2f[_0xa755('0x55')]['length'];_0x3623f6+=0x1){let _0x174832=_0x11fa2f['Agents'][_0x3623f6];var _0x3933f8=_0x70c141[_0xa755('0x62')]();_0x3933f8[_0xa755('0x22')](_0xa755('0x63'),_0x174832['id']);_0x312313[_0xa755('0x64')](db['sequelize'][_0xa755('0x24')](_0x3933f8[_0xa755('0x65')](),{'type':db[_0xa755('0x59')]['QueryTypes'][_0xa755('0x66')]})[_0xa755('0x15')](function(_0x31210d){if(_0x31210d['length']===0x1){return _0x174832['id'];}else{var _0x1963f7=_[_0xa755('0x67')](_['map'](_0x31210d,_0xa755('0x68')),function(_0x384fe1){return _[_0xa755('0x69')](_0x5ae837,_0x384fe1);});if(_0x1963f7){return _0x174832['id'];}}}));}}return BPromise['all'](_0x312313)[_0xa755('0x15')](function(_0x4bdc53){_0x3c59e2=_(_0x3c59e2)['union'](_0x4bdc53)[_0xa755('0x6a')]()[_0xa755('0x6b')]();return db[_0xa755('0x1f')]['find']({'where':{'id':_0xe6d4ed['params']['id']}})[_0xa755('0x15')](function(_0x15e42a){return db['sequelize'][_0xa755('0x5a')](function(_0x5a2f0d){return _0x15e42a['removeTeams'](_0xe6d4ed[_0xa755('0x24')][_0xa755('0x54')],{'transaction':_0x5a2f0d})[_0xa755('0x15')](function(){if(!_[_0xa755('0x6c')](_0x3c59e2)){return _0x15e42a[_0xa755('0x6d')](_0x3c59e2,{'transaction':_0x5a2f0d});}})[_0xa755('0x15')](function(){_0x3c59e2[_0xa755('0x6e')](function(_0x31bada){socket[_0xa755('0x5d')](_0xa755('0x6f'),{'UserId':_0x31bada,'OpenchannelQueueId':_0x15e42a['id']});});});});});});})[_0xa755('0x15')](respondWithStatusCode(_0x44d39f,null))['catch'](handleError(_0x44d39f,null));};exports['addAgents']=function(_0x2ea7ac,_0x461092){return db[_0xa755('0x1f')][_0xa755('0x37')]({'where':{'id':_0x2ea7ac['params']['id']}})[_0xa755('0x15')](handleEntityNotFound(_0x461092,null))[_0xa755('0x15')](function(_0xf79371){if(_0xf79371){return _0xf79371[_0xa755('0x70')](_0x2ea7ac[_0xa755('0x31')]['ids'],_[_0xa755('0x71')](_0x2ea7ac['body'],[_0xa755('0x54'),'id'])||{})[_0xa755('0x72')](function(_0x1de184){for(var _0x5a035b=0x0;_0x5a035b<_0x2ea7ac[_0xa755('0x31')][_0xa755('0x54')]['length'];_0x5a035b+=0x1){socket[_0xa755('0x5d')]('userOpenchannelQueue:save',{'UserId':Number(_0x2ea7ac[_0xa755('0x31')]['ids'][_0x5a035b]),'OpenchannelQueueId':Number(_0x2ea7ac[_0xa755('0x3c')]['id'])});}return _0x1de184;});}})[_0xa755('0x15')](respondWithResult(_0x461092,null))[_0xa755('0x27')](handleError(_0x461092,null));};exports[_0xa755('0x6d')]=function(_0x2b1ffa,_0xee99b6){return db[_0xa755('0x1f')][_0xa755('0x37')]({'where':{'id':_0x2b1ffa['params']['id']}})[_0xa755('0x15')](handleEntityNotFound(_0xee99b6,null))['then'](function(_0x57a214){if(_0x57a214){return _0x57a214[_0xa755('0x6d')](_0x2b1ffa[_0xa755('0x24')][_0xa755('0x54')])[_0xa755('0x15')](function(){if(_[_0xa755('0x73')](_0x2b1ffa['query'][_0xa755('0x54')])){for(var _0x186b98=0x0;_0x186b98<_0x2b1ffa[_0xa755('0x24')][_0xa755('0x54')][_0xa755('0x2e')];_0x186b98+=0x1){socket[_0xa755('0x5d')](_0xa755('0x6f'),{'UserId':Number(_0x2b1ffa[_0xa755('0x24')]['ids'][_0x186b98]),'OpenchannelQueueId':Number(_0x2b1ffa[_0xa755('0x3c')]['id'])});}}else{socket[_0xa755('0x5d')](_0xa755('0x6f'),{'UserId':Number(_0x2b1ffa[_0xa755('0x24')][_0xa755('0x54')]),'OpenchannelQueueId':Number(_0x2b1ffa['params']['id'])});}});}})['then'](respondWithStatusCode(_0xee99b6,null))[_0xa755('0x27')](handleError(_0xee99b6,null));};exports[_0xa755('0x74')]=function(_0x3af0c2,_0x12a692){var _0x1d77b8={};var _0xdbebac={};var _0x1dce5;var _0x163197;return db[_0xa755('0x1f')][_0xa755('0x3f')]({'where':{'id':_0x3af0c2[_0xa755('0x3c')]['id']}})[_0xa755('0x15')](handleEntityNotFound(_0x12a692,null))[_0xa755('0x15')](function(_0x3e0454){if(_0x3e0454){_0x1dce5=_0x3e0454;_0xdbebac[_0xa755('0x28')]=_[_0xa755('0x29')](db[_0xa755('0x4a')][_0xa755('0x20')]);_0xdbebac[_0xa755('0x24')]=_[_0xa755('0x29')](_0x3af0c2['query']);_0xdbebac[_0xa755('0x2a')]=_[_0xa755('0x2b')](_0xdbebac['model'],_0xdbebac[_0xa755('0x24')]);_0x1d77b8['attributes']=_[_0xa755('0x2b')](_0xdbebac['model'],qs[_0xa755('0x2d')](_0x3af0c2[_0xa755('0x24')]['fields']));_0x1d77b8['attributes']=_0x1d77b8[_0xa755('0x2c')][_0xa755('0x2e')]?_0x1d77b8[_0xa755('0x2c')]:_0xdbebac[_0xa755('0x28')];_0x1d77b8['order']=qs[_0xa755('0x45')](_0x3af0c2['query'][_0xa755('0x45')]);_0x1d77b8[_0xa755('0x22')]=qs[_0xa755('0x2a')](_['pick'](_0x3af0c2['query'],_0xdbebac[_0xa755('0x2a')]));if(_0x3af0c2[_0xa755('0x24')][_0xa755('0x48')]){_0x1d77b8[_0xa755('0x22')]=_[_0xa755('0x2f')](_0x1d77b8[_0xa755('0x22')],{'$or':_[_0xa755('0x1e')](_0x1d77b8[_0xa755('0x2c')],function(_0x56135d){var _0x3e55cb={};_0x3e55cb[_0x56135d]={'$like':'%'+_0x3af0c2[_0xa755('0x24')][_0xa755('0x48')]+'%'};return _0x3e55cb;})});}_0x1d77b8=_['merge']({},_0x1d77b8,_0x3af0c2[_0xa755('0x49')]);return _0x1dce5[_0xa755('0x74')](_0x1d77b8);}})['then'](function(_0x25b0f5){if(_0x25b0f5){_0x163197=_0x25b0f5['length'];if(!_0x3af0c2[_0xa755('0x24')][_0xa755('0x41')](_0xa755('0x42'))){_0x1d77b8['limit']=qs['limit'](_0x3af0c2['query'][_0xa755('0x43')]);_0x1d77b8[_0xa755('0x11')]=qs['offset'](_0x3af0c2[_0xa755('0x24')][_0xa755('0x11')]);}return _0x1dce5[_0xa755('0x74')](_0x1d77b8);}})[_0xa755('0x15')](function(_0x44bf2b){if(_0x44bf2b){return _0x44bf2b?{'count':_0x163197,'rows':_0x44bf2b}:null;}})[_0xa755('0x15')](respondWithResult(_0x12a692,null))[_0xa755('0x27')](handleError(_0x12a692,null));};
\ No newline at end of file
+var _0xc48d=['sequelize','transaction','each','emit','userOpenchannelQueue:save','removeTeams','ids','select','field','from','team_has_openchannel_queues','join','OpenchannelQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','includes','all','compact','value','isEmpty','removeAgents','forEach','userOpenchannelQueue:remove','addAgents','getAgents','bluebird','util','lodash','ioredis','../../components/parsers/qs','../../config/logger','../../mysqldb','defaults','redis','localhost','register','sendStatus','status','end','offset','undefined','limit','count','Content-Range','json','update','then','destroy','get','OpenchannelQueues','UserProfileResource','error','stack','name','index','OpenchannelQueue','rawAttributes','fieldName','type','getOptions','where','include','query','findAll','rows','catch','show','params','model','keys','filters','intersection','fields','attributes','length','includeAll','merge','options','find','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','getMembers','findOne','UserOpenchannelQueue','nolimit','order','sort','pick','OpenchannelQueueId','filter','User','findAndCountAll','map','UserId','agent','openchannelPause','SIP','createdAt','updatedAt','Team','getTeams','addTeams','Agents','online','voicePause','interface','flatMap'];(function(_0x2718f4,_0x45a5bf){var _0x5778ec=function(_0x3e1803){while(--_0x3e1803){_0x2718f4['push'](_0x2718f4['shift']());}};_0x5778ec(++_0x45a5bf);}(_0xc48d,0x1ed));var _0xdc48=function(_0x30ae5e,_0x391fc4){_0x30ae5e=_0x30ae5e-0x0;var _0x1f2e93=_0xc48d[_0x30ae5e];return _0x1f2e93;};'use strict';var BPromise=require(_0xdc48('0x0'));var util=require(_0xdc48('0x1'));var _=require(_0xdc48('0x2'));var squel=require('squel');var Redis=require(_0xdc48('0x3'));var qs=require(_0xdc48('0x4'));var logger=require(_0xdc48('0x5'))('api');var config=require('../../config/environment');var db=require(_0xdc48('0x6'))['db'];config['redis']=_[_0xdc48('0x7')](config[_0xdc48('0x8')],{'host':_0xdc48('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./openchannelQueue.socket')[_0xdc48('0xa')](socket);function respondWithStatusCode(_0x3d7073,_0x27d5e4){_0x27d5e4=_0x27d5e4||0xcc;return function(_0x42d0b5){if(_0x42d0b5){return _0x3d7073[_0xdc48('0xb')](_0x27d5e4);}return _0x3d7073[_0xdc48('0xc')](_0x27d5e4)[_0xdc48('0xd')]();};}function respondWithResult(_0x10805e,_0xdc4a8b){_0xdc4a8b=_0xdc4a8b||0xc8;return function(_0x20a437){if(_0x20a437){return _0x10805e[_0xdc48('0xc')](_0xdc4a8b)['json'](_0x20a437);}};}function respondWithFilteredResult(_0x320f85,_0x1fb4c4){return function(_0x367139){if(_0x367139){var _0x5cf641=typeof _0x1fb4c4[_0xdc48('0xe')]===_0xdc48('0xf')&&typeof _0x1fb4c4[_0xdc48('0x10')]==='undefined';var _0x32350a=_0x367139[_0xdc48('0x11')];var _0x404966=_0x5cf641?0x0:_0x1fb4c4['offset'];var _0x1209af=_0x5cf641?_0x367139['count']:_0x1fb4c4[_0xdc48('0xe')]+_0x1fb4c4[_0xdc48('0x10')];var _0x52ac0d;if(_0x1209af>=_0x32350a){_0x1209af=_0x32350a;_0x52ac0d=0xc8;}else{_0x52ac0d=0xce;}_0x320f85[_0xdc48('0xc')](_0x52ac0d);return _0x320f85['set'](_0xdc48('0x12'),_0x404966+'-'+_0x1209af+'/'+_0x32350a)[_0xdc48('0x13')](_0x367139);}return null;};}function saveUpdates(_0x14866d){return function(_0xfe1efb){if(_0xfe1efb){return _0xfe1efb[_0xdc48('0x14')](_0x14866d)[_0xdc48('0x15')](function(_0x2efafe){return _0x2efafe;});}return null;};}function removeEntity(_0x4cc834){return function(_0x2c0eeb){if(_0x2c0eeb){return _0x2c0eeb[_0xdc48('0x16')]()['then'](function(){var _0x1b4a55=_0x2c0eeb[_0xdc48('0x17')]({'plain':!![]});var _0x7caec8=_0xdc48('0x18');return db[_0xdc48('0x19')]['destroy']({'where':{'type':_0x7caec8,'resourceId':_0x1b4a55['id']}})['then'](function(){return _0x2c0eeb;});})[_0xdc48('0x15')](function(){_0x4cc834[_0xdc48('0xc')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1e93cc){return function(_0x4f8c59){if(!_0x4f8c59){_0x1e93cc[_0xdc48('0xb')](0x194);}return _0x4f8c59;};}function handleError(_0x152bb8,_0x3955a1){_0x3955a1=_0x3955a1||0x1f4;return function(_0x4c3f32){logger[_0xdc48('0x1a')](_0x4c3f32[_0xdc48('0x1b')]);if(_0x4c3f32[_0xdc48('0x1c')]){delete _0x4c3f32[_0xdc48('0x1c')];}_0x152bb8['status'](_0x3955a1)['send'](_0x4c3f32);};}exports[_0xdc48('0x1d')]=function(_0x25046b,_0x1ceeac){var _0xf6de0c={};var _0xbfc65c={'count':0x0,'rows':[]};var _0x30c3de=_['map'](db[_0xdc48('0x1e')][_0xdc48('0x1f')],function(_0x22ea50){return{'name':_0x22ea50[_0xdc48('0x20')],'type':_0x22ea50[_0xdc48('0x21')]['key']};});_0xf6de0c=qs[_0xdc48('0x22')](_0x30c3de,_0x25046b);var _0x4621e1={'where':_0xf6de0c[_0xdc48('0x23')]};return db[_0xdc48('0x1e')][_0xdc48('0x11')](_0x4621e1)[_0xdc48('0x15')](function(_0x2c6cd1){_0xbfc65c[_0xdc48('0x11')]=_0x2c6cd1;_0xf6de0c[_0xdc48('0x24')]=qs[_0xdc48('0x24')](_0x25046b[_0xdc48('0x25')]);return db[_0xdc48('0x1e')][_0xdc48('0x26')](_0xf6de0c);})[_0xdc48('0x15')](function(_0x5dfe99){_0xbfc65c[_0xdc48('0x27')]=_0x5dfe99;return _0xbfc65c;})[_0xdc48('0x15')](respondWithFilteredResult(_0x1ceeac,_0xf6de0c))[_0xdc48('0x28')](handleError(_0x1ceeac,null));};exports[_0xdc48('0x29')]=function(_0x1b656a,_0xcdeee2){var _0x316931={'raw':!![],'where':{'id':_0x1b656a[_0xdc48('0x2a')]['id']}},_0x30f8c5={};_0x30f8c5[_0xdc48('0x2b')]=_[_0xdc48('0x2c')](db['OpenchannelQueue'][_0xdc48('0x1f')]);_0x30f8c5[_0xdc48('0x25')]=_[_0xdc48('0x2c')](_0x1b656a[_0xdc48('0x25')]);_0x30f8c5[_0xdc48('0x2d')]=_[_0xdc48('0x2e')](_0x30f8c5[_0xdc48('0x2b')],_0x30f8c5[_0xdc48('0x25')]);_0x316931['attributes']=_['intersection'](_0x30f8c5[_0xdc48('0x2b')],qs[_0xdc48('0x2f')](_0x1b656a[_0xdc48('0x25')][_0xdc48('0x2f')]));_0x316931['attributes']=_0x316931[_0xdc48('0x30')][_0xdc48('0x31')]?_0x316931[_0xdc48('0x30')]:_0x30f8c5[_0xdc48('0x2b')];if(_0x1b656a['query'][_0xdc48('0x32')]){_0x316931[_0xdc48('0x24')]=[{'all':!![]}];}_0x316931=_[_0xdc48('0x33')]({},_0x316931,_0x1b656a[_0xdc48('0x34')]);return db['OpenchannelQueue'][_0xdc48('0x35')](_0x316931)[_0xdc48('0x15')](handleEntityNotFound(_0xcdeee2,null))[_0xdc48('0x15')](respondWithResult(_0xcdeee2,null))[_0xdc48('0x28')](handleError(_0xcdeee2,null));};exports['create']=function(_0x2db4bf,_0x2720c9){return db['OpenchannelQueue']['create'](_0x2db4bf[_0xdc48('0x36')],{})[_0xdc48('0x15')](function(_0x530245){var _0x52fb5f=_0x2db4bf[_0xdc48('0x37')][_0xdc48('0x17')]({'plain':!![]});if(!_0x52fb5f)throw new Error(_0xdc48('0x38'));if(_0x52fb5f[_0xdc48('0x39')]===_0xdc48('0x37')){var _0x55bc8=_0x530245[_0xdc48('0x17')]({'plain':!![]});var _0x2978e7=_0xdc48('0x18');return db[_0xdc48('0x3a')][_0xdc48('0x35')]({'where':{'name':_0x2978e7,'userProfileId':_0x52fb5f[_0xdc48('0x3b')]},'raw':!![]})[_0xdc48('0x15')](function(_0x14ac85){if(_0x14ac85&&_0x14ac85[_0xdc48('0x3c')]===0x0){return db['UserProfileResource']['create']({'name':_0x55bc8[_0xdc48('0x1c')],'resourceId':_0x55bc8['id'],'type':_0x14ac85[_0xdc48('0x1c')],'sectionId':_0x14ac85['id']},{})[_0xdc48('0x15')](function(){return _0x530245;});}else{return _0x530245;}})[_0xdc48('0x28')](function(_0x4330a7){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4330a7);throw _0x4330a7;});}return _0x530245;})[_0xdc48('0x15')](respondWithResult(_0x2720c9,0xc9))[_0xdc48('0x28')](handleError(_0x2720c9,null));};exports[_0xdc48('0x14')]=function(_0x5da6eb,_0x5ddc30){if(_0x5da6eb[_0xdc48('0x36')]['id']){delete _0x5da6eb[_0xdc48('0x36')]['id'];}return db['OpenchannelQueue'][_0xdc48('0x35')]({'where':{'id':_0x5da6eb['params']['id']}})['then'](handleEntityNotFound(_0x5ddc30,null))[_0xdc48('0x15')](saveUpdates(_0x5da6eb[_0xdc48('0x36')],null))['then'](respondWithResult(_0x5ddc30,null))[_0xdc48('0x28')](handleError(_0x5ddc30,null));};exports[_0xdc48('0x16')]=function(_0x27e878,_0x596c30){return db[_0xdc48('0x1e')][_0xdc48('0x35')]({'where':{'id':_0x27e878[_0xdc48('0x2a')]['id']}})[_0xdc48('0x15')](handleEntityNotFound(_0x596c30,null))[_0xdc48('0x15')](removeEntity(_0x596c30,null))[_0xdc48('0x28')](handleError(_0x596c30,null));};exports['describe']=function(_0x1a5d11,_0x36c58a){return db[_0xdc48('0x1e')]['describe']()['then'](respondWithResult(_0x36c58a,null))[_0xdc48('0x28')](handleError(_0x36c58a,null));};exports[_0xdc48('0x3d')]=function(_0x1fee4e,_0x3ab323){var _0xc81734={'raw':!![],'where':{}},_0x243a93={},_0x57af53;return db['OpenchannelQueue'][_0xdc48('0x3e')]({'where':{'id':_0x1fee4e[_0xdc48('0x2a')]['id']}})[_0xdc48('0x15')](handleEntityNotFound(_0x3ab323,null))[_0xdc48('0x15')](function(_0x108c2e){if(_0x108c2e){_0x57af53=_0x108c2e[_0xdc48('0x17')]({'plain':!![]});_0x243a93[_0xdc48('0x2b')]=_[_0xdc48('0x2c')](db[_0xdc48('0x3f')][_0xdc48('0x1f')]);_0x243a93['query']=_[_0xdc48('0x2c')](_0x1fee4e[_0xdc48('0x25')]);_0x243a93['filters']=_[_0xdc48('0x2e')](_0x243a93[_0xdc48('0x2b')],_0x243a93['query']);_0xc81734[_0xdc48('0x30')]=_[_0xdc48('0x2e')](_0x243a93[_0xdc48('0x2b')],qs[_0xdc48('0x2f')](_0x1fee4e['query'][_0xdc48('0x2f')]));_0xc81734[_0xdc48('0x30')]=_0xc81734[_0xdc48('0x30')][_0xdc48('0x31')]?_0xc81734[_0xdc48('0x30')]:_0x243a93[_0xdc48('0x2b')];if(!_0x1fee4e[_0xdc48('0x25')]['hasOwnProperty'](_0xdc48('0x40'))){_0xc81734[_0xdc48('0x10')]=qs[_0xdc48('0x10')](_0x1fee4e['query'][_0xdc48('0x10')]);_0xc81734[_0xdc48('0xe')]=qs[_0xdc48('0xe')](_0x1fee4e[_0xdc48('0x25')][_0xdc48('0xe')]);}_0xc81734[_0xdc48('0x41')]=qs[_0xdc48('0x42')](_0x1fee4e[_0xdc48('0x25')][_0xdc48('0x42')]);_0xc81734[_0xdc48('0x23')]=qs['filters'](_[_0xdc48('0x43')](_0x1fee4e[_0xdc48('0x25')],_0x243a93[_0xdc48('0x2d')]));_0xc81734[_0xdc48('0x23')][_0xdc48('0x44')]=_0x108c2e['id'];if(_0x1fee4e[_0xdc48('0x25')][_0xdc48('0x45')]){_0xc81734[_0xdc48('0x23')]=_[_0xdc48('0x33')](_0xc81734[_0xdc48('0x23')],{'$or':_['map'](_0xc81734[_0xdc48('0x30')],function(_0x4643ee){var _0xb28910={};_0xb28910[_0x4643ee]={'$like':'%'+_0x1fee4e[_0xdc48('0x25')][_0xdc48('0x45')]+'%'};return _0xb28910;})});}_0xc81734=_[_0xdc48('0x33')]({},_0xc81734,_0x1fee4e[_0xdc48('0x34')]);return db[_0xdc48('0x3f')][_0xdc48('0x26')](_0xc81734);}})[_0xdc48('0x15')](function(_0x4b7415){if(_0x4b7415){return db[_0xdc48('0x46')][_0xdc48('0x47')]({'where':{'id':_[_0xdc48('0x48')](_0x4b7415,_0xdc48('0x49')),'role':_0xdc48('0x4a')},'attributes':['id','name',_0xdc48('0x4b'),'updatedAt','createdAt']});}})[_0xdc48('0x15')](function(_0x51af43){if(_0x51af43){return{'count':_0x51af43[_0xdc48('0x11')],'rows':_['map'](_0x51af43['rows'],function(_0x1511ad){return{'membername':_0x1511ad['name'],'UserId':_0x1511ad['id'],'queue_name':_0x57af53['name'],'OpenchannelQueueId':_0x57af53['id'],'interface':util['format']('%s/%s',_0xdc48('0x4c'),_0x1511ad['name']),'penalty':0x0,'paused':_0x1511ad[_0xdc48('0x4b')],'createdAt':_0x1511ad[_0xdc48('0x4d')],'updatedAt':_0x1511ad[_0xdc48('0x4e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xdc48('0x15')](respondWithFilteredResult(_0x3ab323,_0xc81734))[_0xdc48('0x28')](handleError(_0x3ab323,null));};exports['getTeams']=function(_0x121eae,_0x1635e1){var _0x3c42a0={};var _0x3be89b={};var _0x795be0;var _0x538dd2;return db['OpenchannelQueue'][_0xdc48('0x3e')]({'where':{'id':_0x121eae['params']['id']}})['then'](handleEntityNotFound(_0x1635e1,null))[_0xdc48('0x15')](function(_0x54e1e8){if(_0x54e1e8){_0x795be0=_0x54e1e8;_0x3be89b[_0xdc48('0x2b')]=_[_0xdc48('0x2c')](db[_0xdc48('0x4f')][_0xdc48('0x1f')]);_0x3be89b[_0xdc48('0x25')]=_[_0xdc48('0x2c')](_0x121eae[_0xdc48('0x25')]);_0x3be89b[_0xdc48('0x2d')]=_['intersection'](_0x3be89b['model'],_0x3be89b[_0xdc48('0x25')]);_0x3c42a0[_0xdc48('0x30')]=_[_0xdc48('0x2e')](_0x3be89b[_0xdc48('0x2b')],qs[_0xdc48('0x2f')](_0x121eae[_0xdc48('0x25')][_0xdc48('0x2f')]));_0x3c42a0[_0xdc48('0x30')]=_0x3c42a0[_0xdc48('0x30')][_0xdc48('0x31')]?_0x3c42a0[_0xdc48('0x30')]:_0x3be89b['model'];_0x3c42a0[_0xdc48('0x41')]=qs[_0xdc48('0x42')](_0x121eae[_0xdc48('0x25')]['sort']);_0x3c42a0[_0xdc48('0x23')]=qs[_0xdc48('0x2d')](_[_0xdc48('0x43')](_0x121eae[_0xdc48('0x25')],_0x3be89b[_0xdc48('0x2d')]));if(_0x121eae[_0xdc48('0x25')]['filter']){_0x3c42a0[_0xdc48('0x23')]=_['merge'](_0x3c42a0[_0xdc48('0x23')],{'$or':_[_0xdc48('0x48')](_0x3c42a0[_0xdc48('0x30')],function(_0x45230c){var _0x3310db={};_0x3310db[_0x45230c]={'$like':'%'+_0x121eae[_0xdc48('0x25')][_0xdc48('0x45')]+'%'};return _0x3310db;})});}_0x3c42a0=_[_0xdc48('0x33')]({},_0x3c42a0,_0x121eae[_0xdc48('0x34')]);return _0x795be0[_0xdc48('0x50')](_0x3c42a0);}})[_0xdc48('0x15')](function(_0x4adf8e){if(_0x4adf8e){_0x538dd2=_0x4adf8e[_0xdc48('0x31')];if(!_0x121eae[_0xdc48('0x25')]['hasOwnProperty'](_0xdc48('0x40'))){_0x3c42a0[_0xdc48('0x10')]=qs[_0xdc48('0x10')](_0x121eae[_0xdc48('0x25')][_0xdc48('0x10')]);_0x3c42a0[_0xdc48('0xe')]=qs[_0xdc48('0xe')](_0x121eae[_0xdc48('0x25')][_0xdc48('0xe')]);}return _0x795be0[_0xdc48('0x50')](_0x3c42a0);}})[_0xdc48('0x15')](function(_0x23f064){if(_0x23f064){return _0x23f064?{'count':_0x538dd2,'rows':_0x23f064}:null;}})[_0xdc48('0x15')](respondWithResult(_0x1635e1,null))[_0xdc48('0x28')](handleError(_0x1635e1,null));};exports[_0xdc48('0x51')]=function(_0x321f44,_0x502e7c){var _0x4d2a70=_0x321f44[_0xdc48('0x36')]['ids'];return db['Team'][_0xdc48('0x26')]({'where':{'id':_0x4d2a70},'attributes':['id'],'include':[{'model':db[_0xdc48('0x46')],'as':_0xdc48('0x52'),'attributes':['id','name',_0xdc48('0x53'),_0xdc48('0x54'),_0xdc48('0x55')],'raw':!![]}]})[_0xdc48('0x15')](function(_0x21e0d4){if(_0x21e0d4){var _0x1e8fe9=_[_0xdc48('0x56')](_0x21e0d4,function(_0x18549d){var _0x398e6b=_0x18549d[_0xdc48('0x17')]({'plain':!![]});return _0x398e6b[_0xdc48('0x52')];});return db[_0xdc48('0x1e')][_0xdc48('0x35')]({'where':{'id':_0x321f44[_0xdc48('0x2a')]['id']}})[_0xdc48('0x15')](function(_0x495243){return db[_0xdc48('0x57')][_0xdc48('0x58')](function(_0x36d17b){return _0x495243[_0xdc48('0x51')](_0x4d2a70,{'transaction':_0x36d17b})[_0xdc48('0x15')](function(){return BPromise[_0xdc48('0x59')](_0x1e8fe9,function(_0x5cc2d3){return db['UserOpenchannelQueue']['findOrCreate']({'where':{'UserId':_0x5cc2d3['id'],'OpenchannelQueueId':_0x321f44[_0xdc48('0x2a')]['id']},'transaction':_0x36d17b});});})[_0xdc48('0x15')](function(){_0x1e8fe9['forEach'](function(_0x400373){socket[_0xdc48('0x5a')](_0xdc48('0x5b'),{'UserId':_0x400373['id'],'OpenchannelQueueId':_0x495243['id']});});});});});}})[_0xdc48('0x15')](respondWithStatusCode(_0x502e7c,null))['catch'](handleError(_0x502e7c,null));};exports[_0xdc48('0x5c')]=function(_0x2c346c,_0x357cac){return db[_0xdc48('0x4f')][_0xdc48('0x26')]({'where':{'id':_0x2c346c['query'][_0xdc48('0x5d')]},'attributes':['id'],'include':[{'model':db[_0xdc48('0x46')],'as':_0xdc48('0x52'),'attributes':['id'],'raw':!![]}]})[_0xdc48('0x15')](handleEntityNotFound(_0x357cac,null))[_0xdc48('0x15')](function(_0x318237){var _0x34d49d=_[_0xdc48('0x48')](_0x318237,'id');var _0x4cb6fb=[];var _0x3316bd=[];var _0x2b646d=squel[_0xdc48('0x5e')]();_0x2b646d[_0xdc48('0x5f')]('tq.TeamId')[_0xdc48('0x60')](_0xdc48('0x61'),'tq')[_0xdc48('0x62')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0xdc48('0x63'),_0x2c346c[_0xdc48('0x2a')]['id']);for(var _0x2256d6=0x0;_0x2256d6<_0x318237['length'];_0x2256d6+=0x1){let _0x25c1ef=_0x318237[_0x2256d6];for(var _0x170b0d=0x0;_0x170b0d<_0x25c1ef[_0xdc48('0x52')]['length'];_0x170b0d+=0x1){let _0x3587b1=_0x25c1ef[_0xdc48('0x52')][_0x170b0d];var _0x6e2ae5=_0x2b646d[_0xdc48('0x64')]();_0x6e2ae5['where'](_0xdc48('0x65'),_0x3587b1['id']);_0x3316bd['push'](db[_0xdc48('0x57')][_0xdc48('0x25')](_0x6e2ae5[_0xdc48('0x66')](),{'type':db[_0xdc48('0x57')][_0xdc48('0x67')][_0xdc48('0x68')]})['then'](function(_0x1a53fa){if(_0x1a53fa[_0xdc48('0x31')]===0x1){return _0x3587b1['id'];}else{var _0x4c2121=_[_0xdc48('0x69')](_['map'](_0x1a53fa,'TeamId'),function(_0x348ea4){return _[_0xdc48('0x6a')](_0x34d49d,_0x348ea4);});if(_0x4c2121){return _0x3587b1['id'];}}}));}}return BPromise[_0xdc48('0x6b')](_0x3316bd)['then'](function(_0x1c23e9){_0x4cb6fb=_(_0x4cb6fb)['union'](_0x1c23e9)[_0xdc48('0x6c')]()[_0xdc48('0x6d')]();return db[_0xdc48('0x1e')][_0xdc48('0x35')]({'where':{'id':_0x2c346c[_0xdc48('0x2a')]['id']}})['then'](function(_0x20d7f5){return db[_0xdc48('0x57')]['transaction'](function(_0x46b01e){return _0x20d7f5[_0xdc48('0x5c')](_0x2c346c[_0xdc48('0x25')][_0xdc48('0x5d')],{'transaction':_0x46b01e})[_0xdc48('0x15')](function(){if(!_[_0xdc48('0x6e')](_0x4cb6fb)){return _0x20d7f5[_0xdc48('0x6f')](_0x4cb6fb,{'transaction':_0x46b01e});}})['then'](function(){_0x4cb6fb[_0xdc48('0x70')](function(_0x310c08){socket[_0xdc48('0x5a')](_0xdc48('0x71'),{'UserId':_0x310c08,'OpenchannelQueueId':_0x20d7f5['id']});});});});});});})['then'](respondWithStatusCode(_0x357cac,null))[_0xdc48('0x28')](handleError(_0x357cac,null));};exports[_0xdc48('0x72')]=function(_0x2de8c2,_0x3dd01d){return db[_0xdc48('0x1e')][_0xdc48('0x35')]({'where':{'id':_0x2de8c2[_0xdc48('0x2a')]['id']}})[_0xdc48('0x15')](handleEntityNotFound(_0x3dd01d,null))[_0xdc48('0x15')](function(_0x1dc840){if(_0x1dc840){return _0x1dc840[_0xdc48('0x72')](_0x2de8c2[_0xdc48('0x36')][_0xdc48('0x5d')],_['omit'](_0x2de8c2[_0xdc48('0x36')],[_0xdc48('0x5d'),'id'])||{})['spread'](function(_0x3bc2e9){for(var _0x47080b=0x0;_0x47080b<_0x2de8c2[_0xdc48('0x36')]['ids'][_0xdc48('0x31')];_0x47080b+=0x1){socket[_0xdc48('0x5a')](_0xdc48('0x5b'),{'UserId':Number(_0x2de8c2[_0xdc48('0x36')][_0xdc48('0x5d')][_0x47080b]),'OpenchannelQueueId':Number(_0x2de8c2['params']['id'])});}return _0x3bc2e9;});}})[_0xdc48('0x15')](respondWithResult(_0x3dd01d,null))['catch'](handleError(_0x3dd01d,null));};exports[_0xdc48('0x6f')]=function(_0x41c1b8,_0x58a949){return db[_0xdc48('0x1e')][_0xdc48('0x35')]({'where':{'id':_0x41c1b8[_0xdc48('0x2a')]['id']}})[_0xdc48('0x15')](handleEntityNotFound(_0x58a949,null))['then'](function(_0x234005){if(_0x234005){return _0x234005[_0xdc48('0x6f')](_0x41c1b8[_0xdc48('0x25')][_0xdc48('0x5d')])['then'](function(){if(_['isArray'](_0x41c1b8[_0xdc48('0x25')]['ids'])){for(var _0x2460fe=0x0;_0x2460fe<_0x41c1b8[_0xdc48('0x25')][_0xdc48('0x5d')][_0xdc48('0x31')];_0x2460fe+=0x1){socket[_0xdc48('0x5a')](_0xdc48('0x71'),{'UserId':Number(_0x41c1b8[_0xdc48('0x25')][_0xdc48('0x5d')][_0x2460fe]),'OpenchannelQueueId':Number(_0x41c1b8[_0xdc48('0x2a')]['id'])});}}else{socket[_0xdc48('0x5a')](_0xdc48('0x71'),{'UserId':Number(_0x41c1b8['query'][_0xdc48('0x5d')]),'OpenchannelQueueId':Number(_0x41c1b8[_0xdc48('0x2a')]['id'])});}});}})[_0xdc48('0x15')](respondWithStatusCode(_0x58a949,null))[_0xdc48('0x28')](handleError(_0x58a949,null));};exports['getAgents']=function(_0x1ff4be,_0x3364c7){var _0x186faf={};var _0x25874f={};var _0x27d348;var _0x24a937;return db[_0xdc48('0x1e')][_0xdc48('0x3e')]({'where':{'id':_0x1ff4be['params']['id']}})[_0xdc48('0x15')](handleEntityNotFound(_0x3364c7,null))[_0xdc48('0x15')](function(_0x3acd31){if(_0x3acd31){_0x27d348=_0x3acd31;_0x25874f[_0xdc48('0x2b')]=_['keys'](db['User'][_0xdc48('0x1f')]);_0x25874f['query']=_['keys'](_0x1ff4be[_0xdc48('0x25')]);_0x25874f[_0xdc48('0x2d')]=_['intersection'](_0x25874f['model'],_0x25874f[_0xdc48('0x25')]);_0x186faf[_0xdc48('0x30')]=_[_0xdc48('0x2e')](_0x25874f[_0xdc48('0x2b')],qs[_0xdc48('0x2f')](_0x1ff4be[_0xdc48('0x25')][_0xdc48('0x2f')]));_0x186faf['attributes']=_0x186faf[_0xdc48('0x30')]['length']?_0x186faf[_0xdc48('0x30')]:_0x25874f['model'];_0x186faf[_0xdc48('0x41')]=qs[_0xdc48('0x42')](_0x1ff4be['query']['sort']);_0x186faf[_0xdc48('0x23')]=qs[_0xdc48('0x2d')](_[_0xdc48('0x43')](_0x1ff4be[_0xdc48('0x25')],_0x25874f['filters']));if(_0x1ff4be[_0xdc48('0x25')][_0xdc48('0x45')]){_0x186faf['where']=_[_0xdc48('0x33')](_0x186faf[_0xdc48('0x23')],{'$or':_[_0xdc48('0x48')](_0x186faf['attributes'],function(_0x407162){var _0x22eb06={};_0x22eb06[_0x407162]={'$like':'%'+_0x1ff4be[_0xdc48('0x25')][_0xdc48('0x45')]+'%'};return _0x22eb06;})});}_0x186faf=_[_0xdc48('0x33')]({},_0x186faf,_0x1ff4be[_0xdc48('0x34')]);return _0x27d348['getAgents'](_0x186faf);}})['then'](function(_0x2fd706){if(_0x2fd706){_0x24a937=_0x2fd706[_0xdc48('0x31')];if(!_0x1ff4be['query']['hasOwnProperty'](_0xdc48('0x40'))){_0x186faf[_0xdc48('0x10')]=qs[_0xdc48('0x10')](_0x1ff4be[_0xdc48('0x25')][_0xdc48('0x10')]);_0x186faf[_0xdc48('0xe')]=qs[_0xdc48('0xe')](_0x1ff4be['query'][_0xdc48('0xe')]);}return _0x27d348[_0xdc48('0x73')](_0x186faf);}})[_0xdc48('0x15')](function(_0x540e89){if(_0x540e89){return _0x540e89?{'count':_0x24a937,'rows':_0x540e89}:null;}})['then'](respondWithResult(_0x3364c7,null))[_0xdc48('0x28')](handleError(_0x3364c7,null));};
\ No newline at end of file