Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index 1c18e31..f4b6db5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8f2b=['includeAll','include','findAll','rows','show','options','find','catch','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','userProfileId','autoAssociation','UserProfileResource','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','getMembers','findOne','UserOpenchannelQueue','OpenchannelQueueId','User','findAndCountAll','UserId','updatedAt','format','%s/%s','openchannelPause','createdAt','getTeams','Team','addTeams','ids','voicePause','interface','flatMap','Agents','each','forEach','userOpenchannelQueue:save','select','field','tq.TeamId','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','sequelize','toString','SELECT','every','TeamId','includes','all','value','transaction','removeTeams','isEmpty','removeAgents','emit','addAgents','omit','spread','isArray','userOpenchannelQueue:remove','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','fs-extra','lodash','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','get','OpenchannelQueues','end','stack','name','send','index','map','OpenchannelQueue','rawAttributes','fieldName','type','key','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filters','pick','filter','merge','where','VIRTUAL'];(function(_0x522c2e,_0x3cea60){var _0x269e79=function(_0x265346){while(--_0x265346){_0x522c2e['push'](_0x522c2e['shift']());}};_0x269e79(++_0x3cea60);}(_0x8f2b,0x1f0));var _0xb8f2=function(_0x52341e,_0x3cbda0){_0x52341e=_0x52341e-0x0;var _0x469b99=_0x8f2b[_0x52341e];return _0x469b99;};'use strict';var emlformat=require(_0xb8f2('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xb8f2('0x1'));var jsonpatch=require(_0xb8f2('0x2'));var rp=require(_0xb8f2('0x3'));var moment=require('moment');var BPromise=require(_0xb8f2('0x4'));var Mustache=require(_0xb8f2('0x5'));var util=require(_0xb8f2('0x6'));var path=require(_0xb8f2('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb8f2('0x8'));var _=require(_0xb8f2('0x9'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xb8f2('0xa'));var deskjs=require(_0xb8f2('0xb'));var toCsv=require(_0xb8f2('0xc'));var querystring=require('querystring');var Papa=require(_0xb8f2('0xd'));var Redis=require(_0xb8f2('0xe'));var authService=require(_0xb8f2('0xf'));var qs=require(_0xb8f2('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb8f2('0x11'));var logger=require(_0xb8f2('0x12'))(_0xb8f2('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xb8f2('0x14'));var db=require(_0xb8f2('0x15'))['db'];config[_0xb8f2('0x16')]=_[_0xb8f2('0x17')](config['redis'],{'host':_0xb8f2('0x18'),'port':0x18eb});var socket=require(_0xb8f2('0x19'))(new Redis(config[_0xb8f2('0x16')]));require(_0xb8f2('0x1a'))[_0xb8f2('0x1b')](socket);function respondWithStatusCode(_0x349421,_0x334906){_0x334906=_0x334906||0xcc;return function(_0x1523ff){if(_0x1523ff){return _0x349421[_0xb8f2('0x1c')](_0x334906);}return _0x349421[_0xb8f2('0x1d')](_0x334906)['end']();};}function respondWithResult(_0x411736,_0x112eca){_0x112eca=_0x112eca||0xc8;return function(_0x3ae9fe){if(_0x3ae9fe){return _0x411736[_0xb8f2('0x1d')](_0x112eca)[_0xb8f2('0x1e')](_0x3ae9fe);}};}function respondWithFilteredResult(_0x3fdd14,_0x44ea9d){return function(_0x42a77d){if(_0x42a77d){var _0x392e20=typeof _0x44ea9d[_0xb8f2('0x1f')]===_0xb8f2('0x20')&&typeof _0x44ea9d[_0xb8f2('0x21')]==='undefined';var _0x5090bd=_0x42a77d[_0xb8f2('0x22')];var _0x5dd635=_0x392e20?0x0:_0x44ea9d['offset'];var _0xf2b44e=_0x392e20?_0x42a77d[_0xb8f2('0x22')]:_0x44ea9d['offset']+_0x44ea9d[_0xb8f2('0x21')];var _0x50e6ac;if(_0xf2b44e>=_0x5090bd){_0xf2b44e=_0x5090bd;_0x50e6ac=0xc8;}else{_0x50e6ac=0xce;}_0x3fdd14['status'](_0x50e6ac);return _0x3fdd14[_0xb8f2('0x23')](_0xb8f2('0x24'),_0x5dd635+'-'+_0xf2b44e+'/'+_0x5090bd)[_0xb8f2('0x1e')](_0x42a77d);}return null;};}function patchUpdates(_0x36ba7e){return function(_0x3fa853){try{jsonpatch['apply'](_0x3fa853,_0x36ba7e,!![]);}catch(_0x50c242){return BPromise[_0xb8f2('0x25')](_0x50c242);}return _0x3fa853[_0xb8f2('0x26')]();};}function saveUpdates(_0x5800c1,_0x31173a){return function(_0x29ffaf){if(_0x29ffaf){return _0x29ffaf[_0xb8f2('0x27')](_0x5800c1)[_0xb8f2('0x28')](function(_0x1c812b){return _0x1c812b;});}return null;};}function removeEntity(_0xd06d11,_0x29642f){return function(_0x4cf82b){if(_0x4cf82b){return _0x4cf82b[_0xb8f2('0x29')]()['then'](function(){var _0x3ffb80=_0x4cf82b[_0xb8f2('0x2a')]({'plain':!![]});var _0x1b50ba=_0xb8f2('0x2b');return db['UserProfileResource'][_0xb8f2('0x29')]({'where':{'type':_0x1b50ba,'resourceId':_0x3ffb80['id']}})['then'](function(){return _0x4cf82b;});})[_0xb8f2('0x28')](function(){_0xd06d11[_0xb8f2('0x1d')](0xcc)[_0xb8f2('0x2c')]();});}};}function handleEntityNotFound(_0x3c72d8,_0x3a9441){return function(_0x858e71){if(!_0x858e71){_0x3c72d8[_0xb8f2('0x1c')](0x194);}return _0x858e71;};}function handleError(_0x4f81eb,_0x5cb6fb){_0x5cb6fb=_0x5cb6fb||0x1f4;return function(_0x38ec40){logger['error'](_0x38ec40[_0xb8f2('0x2d')]);if(_0x38ec40['name']){delete _0x38ec40[_0xb8f2('0x2e')];}_0x4f81eb['status'](_0x5cb6fb)[_0xb8f2('0x2f')](_0x38ec40);};}exports[_0xb8f2('0x30')]=function(_0x21f1be,_0x3c5e4d){var _0x33734c={},_0x49dff1={},_0x3a6c0c={'count':0x0,'rows':[]};var _0x1ae111=_[_0xb8f2('0x31')](db[_0xb8f2('0x32')][_0xb8f2('0x33')],function(_0x4c2480){return{'name':_0x4c2480[_0xb8f2('0x34')],'type':_0x4c2480[_0xb8f2('0x35')][_0xb8f2('0x36')]};});_0x49dff1[_0xb8f2('0x37')]=_['map'](_0x1ae111,_0xb8f2('0x2e'));_0x49dff1[_0xb8f2('0x38')]=_[_0xb8f2('0x39')](_0x21f1be[_0xb8f2('0x38')]);_0x49dff1['filters']=_[_0xb8f2('0x3a')](_0x49dff1[_0xb8f2('0x37')],_0x49dff1[_0xb8f2('0x38')]);_0x33734c['attributes']=_[_0xb8f2('0x3a')](_0x49dff1['model'],qs[_0xb8f2('0x3b')](_0x21f1be['query']['fields']));_0x33734c[_0xb8f2('0x3c')]=_0x33734c[_0xb8f2('0x3c')][_0xb8f2('0x3d')]?_0x33734c[_0xb8f2('0x3c')]:_0x49dff1['model'];if(!_0x21f1be[_0xb8f2('0x38')][_0xb8f2('0x3e')](_0xb8f2('0x3f'))){_0x33734c[_0xb8f2('0x21')]=qs[_0xb8f2('0x21')](_0x21f1be[_0xb8f2('0x38')][_0xb8f2('0x21')]);_0x33734c['offset']=qs['offset'](_0x21f1be[_0xb8f2('0x38')]['offset']);}_0x33734c[_0xb8f2('0x40')]=qs[_0xb8f2('0x41')](_0x21f1be[_0xb8f2('0x38')][_0xb8f2('0x41')]);_0x33734c['where']=qs[_0xb8f2('0x42')](_[_0xb8f2('0x43')](_0x21f1be[_0xb8f2('0x38')],_0x49dff1['filters']),_0x1ae111);if(_0x21f1be[_0xb8f2('0x38')][_0xb8f2('0x44')]){_0x33734c['where']=_[_0xb8f2('0x45')](_0x33734c[_0xb8f2('0x46')],{'$or':_[_0xb8f2('0x31')](_0x1ae111,function(_0x3e61e6){if(_0x3e61e6[_0xb8f2('0x35')]!==_0xb8f2('0x47')){var _0x20f7c4={};_0x20f7c4[_0x3e61e6[_0xb8f2('0x2e')]]={'$like':'%'+_0x21f1be[_0xb8f2('0x38')]['filter']+'%'};return _0x20f7c4;}})});}_0x33734c=_[_0xb8f2('0x45')]({},_0x33734c,_0x21f1be['options']);var _0x119a97={'where':_0x33734c[_0xb8f2('0x46')]};return db[_0xb8f2('0x32')][_0xb8f2('0x22')](_0x119a97)[_0xb8f2('0x28')](function(_0xaec0bc){_0x3a6c0c['count']=_0xaec0bc;if(_0x21f1be[_0xb8f2('0x38')][_0xb8f2('0x48')]){_0x33734c[_0xb8f2('0x49')]=[{'all':!![]}];}return db[_0xb8f2('0x32')][_0xb8f2('0x4a')](_0x33734c);})[_0xb8f2('0x28')](function(_0x56299f){_0x3a6c0c[_0xb8f2('0x4b')]=_0x56299f;return _0x3a6c0c;})[_0xb8f2('0x28')](respondWithFilteredResult(_0x3c5e4d,_0x33734c))['catch'](handleError(_0x3c5e4d,null));};exports[_0xb8f2('0x4c')]=function(_0x4d851e,_0x474448){var _0x584518={'raw':!![],'where':{'id':_0x4d851e['params']['id']}},_0x1b5ab9={};_0x1b5ab9[_0xb8f2('0x37')]=_[_0xb8f2('0x39')](db[_0xb8f2('0x32')][_0xb8f2('0x33')]);_0x1b5ab9[_0xb8f2('0x38')]=_[_0xb8f2('0x39')](_0x4d851e['query']);_0x1b5ab9[_0xb8f2('0x42')]=_[_0xb8f2('0x3a')](_0x1b5ab9[_0xb8f2('0x37')],_0x1b5ab9[_0xb8f2('0x38')]);_0x584518[_0xb8f2('0x3c')]=_[_0xb8f2('0x3a')](_0x1b5ab9[_0xb8f2('0x37')],qs['fields'](_0x4d851e[_0xb8f2('0x38')][_0xb8f2('0x3b')]));_0x584518[_0xb8f2('0x3c')]=_0x584518['attributes'][_0xb8f2('0x3d')]?_0x584518[_0xb8f2('0x3c')]:_0x1b5ab9[_0xb8f2('0x37')];if(_0x4d851e[_0xb8f2('0x38')][_0xb8f2('0x48')]){_0x584518['include']=[{'all':!![]}];}_0x584518=_[_0xb8f2('0x45')]({},_0x584518,_0x4d851e[_0xb8f2('0x4d')]);return db[_0xb8f2('0x32')][_0xb8f2('0x4e')](_0x584518)[_0xb8f2('0x28')](handleEntityNotFound(_0x474448,null))[_0xb8f2('0x28')](respondWithResult(_0x474448,null))[_0xb8f2('0x4f')](handleError(_0x474448,null));};exports[_0xb8f2('0x50')]=function(_0x3a22b3,_0x7bb3b2){return db[_0xb8f2('0x32')]['create'](_0x3a22b3['body'],{})[_0xb8f2('0x28')](function(_0x6a9371){var _0x28a76f=_0x3a22b3['user'][_0xb8f2('0x2a')]({'plain':!![]});if(!_0x28a76f)throw new Error(_0xb8f2('0x51'));if(_0x28a76f[_0xb8f2('0x52')]===_0xb8f2('0x53')){var _0x4d52cf=_0x6a9371[_0xb8f2('0x2a')]({'plain':!![]});var _0x410b06=_0xb8f2('0x2b');return db['UserProfileSection']['find']({'where':{'name':_0x410b06,'userProfileId':_0x28a76f[_0xb8f2('0x54')]},'raw':!![]})['then'](function(_0xda8368){if(_0xda8368&&_0xda8368[_0xb8f2('0x55')]===0x0){return db[_0xb8f2('0x56')]['create']({'name':_0x4d52cf['name'],'resourceId':_0x4d52cf['id'],'type':_0xda8368[_0xb8f2('0x2e')],'sectionId':_0xda8368['id']},{})['then'](function(){return _0x6a9371;});}else{return _0x6a9371;}})[_0xb8f2('0x4f')](function(_0x2453c6){logger[_0xb8f2('0x57')](_0xb8f2('0x58'),_0x2453c6);throw _0x2453c6;});}return _0x6a9371;})['then'](respondWithResult(_0x7bb3b2,0xc9))[_0xb8f2('0x4f')](handleError(_0x7bb3b2,null));};exports['update']=function(_0x21e276,_0x313a85){if(_0x21e276[_0xb8f2('0x59')]['id']){delete _0x21e276[_0xb8f2('0x59')]['id'];}return db[_0xb8f2('0x32')][_0xb8f2('0x4e')]({'where':{'id':_0x21e276[_0xb8f2('0x5a')]['id']}})[_0xb8f2('0x28')](handleEntityNotFound(_0x313a85,null))[_0xb8f2('0x28')](saveUpdates(_0x21e276[_0xb8f2('0x59')],null))[_0xb8f2('0x28')](respondWithResult(_0x313a85,null))[_0xb8f2('0x4f')](handleError(_0x313a85,null));};exports[_0xb8f2('0x29')]=function(_0x52d4ae,_0x354bb6){return db[_0xb8f2('0x32')]['find']({'where':{'id':_0x52d4ae[_0xb8f2('0x5a')]['id']}})[_0xb8f2('0x28')](handleEntityNotFound(_0x354bb6,null))[_0xb8f2('0x28')](removeEntity(_0x354bb6,null))[_0xb8f2('0x4f')](handleError(_0x354bb6,null));};exports[_0xb8f2('0x5b')]=function(_0x359e4e,_0xb78718){return db[_0xb8f2('0x32')][_0xb8f2('0x5b')]()[_0xb8f2('0x28')](respondWithResult(_0xb78718,null))['catch'](handleError(_0xb78718,null));};exports[_0xb8f2('0x5c')]=function(_0x305d41,_0x35112e,_0x27a50d){var _0x1bb7ce={'raw':!![],'where':{}},_0x4e6e1d={},_0x1e84fa;return db[_0xb8f2('0x32')][_0xb8f2('0x5d')]({'where':{'id':_0x305d41['params']['id']}})[_0xb8f2('0x28')](handleEntityNotFound(_0x35112e,null))['then'](function(_0x3c7344){if(_0x3c7344){_0x1e84fa=_0x3c7344[_0xb8f2('0x2a')]({'plain':!![]});_0x4e6e1d['model']=_[_0xb8f2('0x39')](db[_0xb8f2('0x5e')][_0xb8f2('0x33')]);_0x4e6e1d['query']=_[_0xb8f2('0x39')](_0x305d41[_0xb8f2('0x38')]);_0x4e6e1d[_0xb8f2('0x42')]=_['intersection'](_0x4e6e1d[_0xb8f2('0x37')],_0x4e6e1d[_0xb8f2('0x38')]);_0x1bb7ce[_0xb8f2('0x3c')]=_[_0xb8f2('0x3a')](_0x4e6e1d[_0xb8f2('0x37')],qs[_0xb8f2('0x3b')](_0x305d41[_0xb8f2('0x38')][_0xb8f2('0x3b')]));_0x1bb7ce[_0xb8f2('0x3c')]=_0x1bb7ce[_0xb8f2('0x3c')]['length']?_0x1bb7ce[_0xb8f2('0x3c')]:_0x4e6e1d[_0xb8f2('0x37')];if(!_0x305d41['query'][_0xb8f2('0x3e')](_0xb8f2('0x3f'))){_0x1bb7ce[_0xb8f2('0x21')]=qs[_0xb8f2('0x21')](_0x305d41[_0xb8f2('0x38')]['limit']);_0x1bb7ce[_0xb8f2('0x1f')]=qs[_0xb8f2('0x1f')](_0x305d41[_0xb8f2('0x38')][_0xb8f2('0x1f')]);}_0x1bb7ce[_0xb8f2('0x40')]=qs[_0xb8f2('0x41')](_0x305d41[_0xb8f2('0x38')]['sort']);_0x1bb7ce[_0xb8f2('0x46')]=qs[_0xb8f2('0x42')](_[_0xb8f2('0x43')](_0x305d41[_0xb8f2('0x38')],_0x4e6e1d[_0xb8f2('0x42')]));_0x1bb7ce[_0xb8f2('0x46')][_0xb8f2('0x5f')]=_0x3c7344['id'];if(_0x305d41['query'][_0xb8f2('0x44')]){_0x1bb7ce[_0xb8f2('0x46')]=_['merge'](_0x1bb7ce[_0xb8f2('0x46')],{'$or':_[_0xb8f2('0x31')](_0x1bb7ce['attributes'],function(_0x23fe41){var _0x194254={};_0x194254[_0x23fe41]={'$like':'%'+_0x305d41[_0xb8f2('0x38')]['filter']+'%'};return _0x194254;})});}_0x1bb7ce=_[_0xb8f2('0x45')]({},_0x1bb7ce,_0x305d41['options']);return db[_0xb8f2('0x5e')]['findAll'](_0x1bb7ce);}})['then'](function(_0x4af35e){if(_0x4af35e){return db[_0xb8f2('0x60')][_0xb8f2('0x61')]({'where':{'id':_[_0xb8f2('0x31')](_0x4af35e,_0xb8f2('0x62')),'role':'agent'},'attributes':['id',_0xb8f2('0x2e'),'openchannelPause',_0xb8f2('0x63'),'createdAt']});}})['then'](function(_0x3ab550){if(_0x3ab550){return{'count':_0x3ab550['count'],'rows':_['map'](_0x3ab550[_0xb8f2('0x4b')],function(_0x2fba34){return{'membername':_0x2fba34[_0xb8f2('0x2e')],'UserId':_0x2fba34['id'],'queue_name':_0x1e84fa[_0xb8f2('0x2e')],'OpenchannelQueueId':_0x1e84fa['id'],'interface':util[_0xb8f2('0x64')](_0xb8f2('0x65'),'SIP',_0x2fba34[_0xb8f2('0x2e')]),'penalty':0x0,'paused':_0x2fba34[_0xb8f2('0x66')],'createdAt':_0x2fba34[_0xb8f2('0x67')],'updatedAt':_0x2fba34[_0xb8f2('0x63')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xb8f2('0x28')](respondWithFilteredResult(_0x35112e,_0x1bb7ce))['catch'](handleError(_0x35112e,null));};exports[_0xb8f2('0x68')]=function(_0x250bc3,_0x30f0ef,_0x2ba640){var _0xada082={};var _0x242ff6={};var _0x5e26fa;var _0x185cda;return db[_0xb8f2('0x32')][_0xb8f2('0x5d')]({'where':{'id':_0x250bc3['params']['id']}})['then'](handleEntityNotFound(_0x30f0ef,null))['then'](function(_0x1d788a){if(_0x1d788a){_0x5e26fa=_0x1d788a;_0x242ff6[_0xb8f2('0x37')]=_[_0xb8f2('0x39')](db[_0xb8f2('0x69')][_0xb8f2('0x33')]);_0x242ff6[_0xb8f2('0x38')]=_[_0xb8f2('0x39')](_0x250bc3[_0xb8f2('0x38')]);_0x242ff6[_0xb8f2('0x42')]=_['intersection'](_0x242ff6['model'],_0x242ff6['query']);_0xada082[_0xb8f2('0x3c')]=_[_0xb8f2('0x3a')](_0x242ff6['model'],qs[_0xb8f2('0x3b')](_0x250bc3[_0xb8f2('0x38')][_0xb8f2('0x3b')]));_0xada082[_0xb8f2('0x3c')]=_0xada082[_0xb8f2('0x3c')]['length']?_0xada082[_0xb8f2('0x3c')]:_0x242ff6[_0xb8f2('0x37')];_0xada082[_0xb8f2('0x40')]=qs[_0xb8f2('0x41')](_0x250bc3[_0xb8f2('0x38')]['sort']);_0xada082[_0xb8f2('0x46')]=qs[_0xb8f2('0x42')](_[_0xb8f2('0x43')](_0x250bc3['query'],_0x242ff6['filters']));if(_0x250bc3[_0xb8f2('0x38')][_0xb8f2('0x44')]){_0xada082['where']=_[_0xb8f2('0x45')](_0xada082['where'],{'$or':_[_0xb8f2('0x31')](_0xada082['attributes'],function(_0x4e6cf4){var _0x504521={};_0x504521[_0x4e6cf4]={'$like':'%'+_0x250bc3['query']['filter']+'%'};return _0x504521;})});}_0xada082=_['merge']({},_0xada082,_0x250bc3['options']);return _0x5e26fa[_0xb8f2('0x68')](_0xada082);}})[_0xb8f2('0x28')](function(_0x4a0747){if(_0x4a0747){_0x185cda=_0x4a0747['length'];if(!_0x250bc3['query'][_0xb8f2('0x3e')](_0xb8f2('0x3f'))){_0xada082[_0xb8f2('0x21')]=qs[_0xb8f2('0x21')](_0x250bc3['query'][_0xb8f2('0x21')]);_0xada082[_0xb8f2('0x1f')]=qs[_0xb8f2('0x1f')](_0x250bc3[_0xb8f2('0x38')][_0xb8f2('0x1f')]);}return _0x5e26fa['getTeams'](_0xada082);}})[_0xb8f2('0x28')](function(_0x27e658){if(_0x27e658){return _0x27e658?{'count':_0x185cda,'rows':_0x27e658}:null;}})[_0xb8f2('0x28')](respondWithResult(_0x30f0ef,null))['catch'](handleError(_0x30f0ef,null));};exports[_0xb8f2('0x6a')]=function(_0x1af62b,_0xdbbe56,_0x51bdba){var _0x33718f=_0x1af62b['body'][_0xb8f2('0x6b')];return db[_0xb8f2('0x69')][_0xb8f2('0x4a')]({'where':{'id':_0x33718f},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0xb8f2('0x2e'),'online',_0xb8f2('0x6c'),_0xb8f2('0x6d')],'raw':!![]}]})[_0xb8f2('0x28')](function(_0x4e5c87){if(_0x4e5c87){var _0x30bc57=_[_0xb8f2('0x6e')](_0x4e5c87,function(_0x13feb1){var _0x4257ba=_0x13feb1[_0xb8f2('0x2a')]({'plain':!![]});return _0x4257ba[_0xb8f2('0x6f')];});return db['OpenchannelQueue'][_0xb8f2('0x4e')]({'where':{'id':_0x1af62b[_0xb8f2('0x5a')]['id']}})[_0xb8f2('0x28')](function(_0x1d80d1){return db['sequelize']['transaction'](function(_0x5dbbc5){return _0x1d80d1[_0xb8f2('0x6a')](_0x33718f,{'transaction':_0x5dbbc5})[_0xb8f2('0x28')](function(){return BPromise[_0xb8f2('0x70')](_0x30bc57,function(_0x16e927){return db['UserOpenchannelQueue']['findOrCreate']({'where':{'UserId':_0x16e927['id'],'OpenchannelQueueId':_0x1af62b[_0xb8f2('0x5a')]['id']},'transaction':_0x5dbbc5});});})[_0xb8f2('0x28')](function(){_0x30bc57[_0xb8f2('0x71')](function(_0x1d01e8){socket['emit'](_0xb8f2('0x72'),{'UserId':_0x1d01e8['id'],'OpenchannelQueueId':_0x1d80d1['id']});});});});});}})[_0xb8f2('0x28')](respondWithStatusCode(_0xdbbe56,null))[_0xb8f2('0x4f')](handleError(_0xdbbe56,null));};exports['removeTeams']=function(_0x464ded,_0x262d6f,_0x3e3252){return db[_0xb8f2('0x69')][_0xb8f2('0x4a')]({'where':{'id':_0x464ded[_0xb8f2('0x38')]['ids']},'attributes':['id'],'include':[{'model':db[_0xb8f2('0x60')],'as':_0xb8f2('0x6f'),'attributes':['id'],'raw':!![]}]})[_0xb8f2('0x28')](handleEntityNotFound(_0x262d6f,null))[_0xb8f2('0x28')](function(_0x466e6a){var _0x55b32b=_['map'](_0x466e6a,'id');var _0x46bfb9=[];var _0x30a804=[];var _0x37027c=squel[_0xb8f2('0x73')]();_0x37027c[_0xb8f2('0x74')](_0xb8f2('0x75'))['from']('team_has_openchannel_queues','tq')[_0xb8f2('0x76')](_0xb8f2('0x77'),'ut',_0xb8f2('0x78'))['where']('OpenchannelQueueId\x20=\x20?',_0x464ded[_0xb8f2('0x5a')]['id']);for(var _0x195e7e=0x0;_0x195e7e<_0x466e6a['length'];_0x195e7e+=0x1){let _0x11214e=_0x466e6a[_0x195e7e];for(var _0xe1f4c1=0x0;_0xe1f4c1<_0x11214e[_0xb8f2('0x6f')][_0xb8f2('0x3d')];_0xe1f4c1+=0x1){let _0x49d82f=_0x11214e['Agents'][_0xe1f4c1];var _0x2bd052=_0x37027c['clone']();_0x2bd052[_0xb8f2('0x46')](_0xb8f2('0x79'),_0x49d82f['id']);_0x30a804[_0xb8f2('0x7a')](db[_0xb8f2('0x7b')][_0xb8f2('0x38')](_0x2bd052[_0xb8f2('0x7c')](),{'type':db['sequelize']['QueryTypes'][_0xb8f2('0x7d')]})[_0xb8f2('0x28')](function(_0xf64277){if(_0xf64277[_0xb8f2('0x3d')]===0x1){return _0x49d82f['id'];}else{var _0x77d0a6=_[_0xb8f2('0x7e')](_[_0xb8f2('0x31')](_0xf64277,_0xb8f2('0x7f')),function(_0x2d158e){return _[_0xb8f2('0x80')](_0x55b32b,_0x2d158e);});if(_0x77d0a6){return _0x49d82f['id'];}}}));}}return BPromise[_0xb8f2('0x81')](_0x30a804)['then'](function(_0x25672a){_0x46bfb9=_(_0x46bfb9)['union'](_0x25672a)['compact']()[_0xb8f2('0x82')]();return db[_0xb8f2('0x32')]['find']({'where':{'id':_0x464ded['params']['id']}})['then'](function(_0x49f0c3){return db['sequelize'][_0xb8f2('0x83')](function(_0x15bbd7){return _0x49f0c3[_0xb8f2('0x84')](_0x464ded[_0xb8f2('0x38')][_0xb8f2('0x6b')],{'transaction':_0x15bbd7})[_0xb8f2('0x28')](function(){if(!_[_0xb8f2('0x85')](_0x46bfb9)){return _0x49f0c3[_0xb8f2('0x86')](_0x46bfb9,{'transaction':_0x15bbd7});}})[_0xb8f2('0x28')](function(){_0x46bfb9[_0xb8f2('0x71')](function(_0x3e66c0){socket[_0xb8f2('0x87')]('userOpenchannelQueue:remove',{'UserId':_0x3e66c0,'OpenchannelQueueId':_0x49f0c3['id']});});});});});});})[_0xb8f2('0x28')](respondWithStatusCode(_0x262d6f,null))[_0xb8f2('0x4f')](handleError(_0x262d6f,null));};exports[_0xb8f2('0x88')]=function(_0x2cdbc5,_0x5b68b3,_0x32a61b){return db[_0xb8f2('0x32')][_0xb8f2('0x4e')]({'where':{'id':_0x2cdbc5[_0xb8f2('0x5a')]['id']}})[_0xb8f2('0x28')](handleEntityNotFound(_0x5b68b3,null))['then'](function(_0x52a635){if(_0x52a635){return _0x52a635[_0xb8f2('0x88')](_0x2cdbc5['body'][_0xb8f2('0x6b')],_[_0xb8f2('0x89')](_0x2cdbc5[_0xb8f2('0x59')],['ids','id'])||{})[_0xb8f2('0x8a')](function(_0x2d6d4f){for(var _0x2a3ed7=0x0;_0x2a3ed7<_0x2cdbc5[_0xb8f2('0x59')][_0xb8f2('0x6b')][_0xb8f2('0x3d')];_0x2a3ed7+=0x1){socket['emit'](_0xb8f2('0x72'),{'UserId':Number(_0x2cdbc5[_0xb8f2('0x59')][_0xb8f2('0x6b')][_0x2a3ed7]),'OpenchannelQueueId':Number(_0x2cdbc5[_0xb8f2('0x5a')]['id'])});}return _0x2d6d4f;});}})[_0xb8f2('0x28')](respondWithResult(_0x5b68b3,null))[_0xb8f2('0x4f')](handleError(_0x5b68b3,null));};exports[_0xb8f2('0x86')]=function(_0x510a7c,_0x5745da,_0x6f5f47){return db['OpenchannelQueue'][_0xb8f2('0x4e')]({'where':{'id':_0x510a7c['params']['id']}})[_0xb8f2('0x28')](handleEntityNotFound(_0x5745da,null))['then'](function(_0x4fcc1e){if(_0x4fcc1e){return _0x4fcc1e[_0xb8f2('0x86')](_0x510a7c[_0xb8f2('0x38')]['ids'])[_0xb8f2('0x28')](function(){if(_[_0xb8f2('0x8b')](_0x510a7c[_0xb8f2('0x38')][_0xb8f2('0x6b')])){for(var _0x557a1c=0x0;_0x557a1c<_0x510a7c[_0xb8f2('0x38')][_0xb8f2('0x6b')][_0xb8f2('0x3d')];_0x557a1c+=0x1){socket[_0xb8f2('0x87')]('userOpenchannelQueue:remove',{'UserId':Number(_0x510a7c[_0xb8f2('0x38')][_0xb8f2('0x6b')][_0x557a1c]),'OpenchannelQueueId':Number(_0x510a7c['params']['id'])});}}else{socket[_0xb8f2('0x87')](_0xb8f2('0x8c'),{'UserId':Number(_0x510a7c[_0xb8f2('0x38')][_0xb8f2('0x6b')]),'OpenchannelQueueId':Number(_0x510a7c[_0xb8f2('0x5a')]['id'])});}});}})[_0xb8f2('0x28')](respondWithStatusCode(_0x5745da,null))[_0xb8f2('0x4f')](handleError(_0x5745da,null));};exports[_0xb8f2('0x8d')]=function(_0x5398fc,_0x258a47,_0x105fab){var _0x3e4eb2={};var _0x5048da={};var _0x145a58;var _0x189b4f;return db['OpenchannelQueue'][_0xb8f2('0x5d')]({'where':{'id':_0x5398fc['params']['id']}})['then'](handleEntityNotFound(_0x258a47,null))[_0xb8f2('0x28')](function(_0x5aa61d){if(_0x5aa61d){_0x145a58=_0x5aa61d;_0x5048da[_0xb8f2('0x37')]=_['keys'](db[_0xb8f2('0x60')][_0xb8f2('0x33')]);_0x5048da[_0xb8f2('0x38')]=_[_0xb8f2('0x39')](_0x5398fc['query']);_0x5048da[_0xb8f2('0x42')]=_[_0xb8f2('0x3a')](_0x5048da[_0xb8f2('0x37')],_0x5048da['query']);_0x3e4eb2[_0xb8f2('0x3c')]=_['intersection'](_0x5048da[_0xb8f2('0x37')],qs[_0xb8f2('0x3b')](_0x5398fc[_0xb8f2('0x38')][_0xb8f2('0x3b')]));_0x3e4eb2[_0xb8f2('0x3c')]=_0x3e4eb2[_0xb8f2('0x3c')][_0xb8f2('0x3d')]?_0x3e4eb2[_0xb8f2('0x3c')]:_0x5048da[_0xb8f2('0x37')];_0x3e4eb2[_0xb8f2('0x40')]=qs[_0xb8f2('0x41')](_0x5398fc[_0xb8f2('0x38')][_0xb8f2('0x41')]);_0x3e4eb2[_0xb8f2('0x46')]=qs[_0xb8f2('0x42')](_[_0xb8f2('0x43')](_0x5398fc[_0xb8f2('0x38')],_0x5048da[_0xb8f2('0x42')]));if(_0x5398fc[_0xb8f2('0x38')]['filter']){_0x3e4eb2['where']=_['merge'](_0x3e4eb2['where'],{'$or':_['map'](_0x3e4eb2['attributes'],function(_0x2e1885){var _0x13fb68={};_0x13fb68[_0x2e1885]={'$like':'%'+_0x5398fc[_0xb8f2('0x38')][_0xb8f2('0x44')]+'%'};return _0x13fb68;})});}_0x3e4eb2=_[_0xb8f2('0x45')]({},_0x3e4eb2,_0x5398fc[_0xb8f2('0x4d')]);return _0x145a58[_0xb8f2('0x8d')](_0x3e4eb2);}})['then'](function(_0x4260c8){if(_0x4260c8){_0x189b4f=_0x4260c8[_0xb8f2('0x3d')];if(!_0x5398fc['query'][_0xb8f2('0x3e')](_0xb8f2('0x3f'))){_0x3e4eb2[_0xb8f2('0x21')]=qs[_0xb8f2('0x21')](_0x5398fc[_0xb8f2('0x38')][_0xb8f2('0x21')]);_0x3e4eb2[_0xb8f2('0x1f')]=qs[_0xb8f2('0x1f')](_0x5398fc[_0xb8f2('0x38')][_0xb8f2('0x1f')]);}return _0x145a58[_0xb8f2('0x8d')](_0x3e4eb2);}})[_0xb8f2('0x28')](function(_0xcdaf93){if(_0xcdaf93){return _0xcdaf93?{'count':_0x189b4f,'rows':_0xcdaf93}:null;}})[_0xb8f2('0x28')](respondWithResult(_0x258a47,null))[_0xb8f2('0x4f')](handleError(_0x258a47,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