Built motion from commit 19a84241.|2.5.34
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index de32df4..c545d18 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xaad8=['apply','reject','save','then','destroy','get','OpenchannelQueues','UserProfileResource','sendStatus','stack','name','send','map','OpenchannelQueue','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','type','VIRTUAL','includeAll','include','rows','catch','show','params','options','find','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','create','update','describe','getMembers','findOne','pick','OpenchannelQueueId','UserOpenchannelQueue','findAll','User','findAndCountAll','agent','format','SIP','openchannelPause','createdAt','updatedAt','getTeams','addTeams','ids','Team','Agents','online','interface','flatMap','sequelize','transaction','each','findOrCreate','forEach','emit','removeTeams','select','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?','push','toString','SELECT','every','union','value','isEmpty','removeAgents','userOpenchannelQueue:remove','omit','spread','userOpenchannelQueue:save','isArray','getAgents','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./openchannelQueue.socket','status','end','json','count','offset','limit','set','Content-Range'];(function(_0x45a4f3,_0x5e5649){var _0x14365b=function(_0x3ae9fb){while(--_0x3ae9fb){_0x45a4f3['push'](_0x45a4f3['shift']());}};_0x14365b(++_0x5e5649);}(_0xaad8,0x182));var _0x8aad=function(_0xb45891,_0x34b408){_0xb45891=_0xb45891-0x0;var _0x2ca817=_0xaad8[_0xb45891];return _0x2ca817;};'use strict';var pdf=require(_0x8aad('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x8aad('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8aad('0x2'));var rp=require(_0x8aad('0x3'));var moment=require(_0x8aad('0x4'));var BPromise=require(_0x8aad('0x5'));var Mustache=require(_0x8aad('0x6'));var util=require('util');var path=require(_0x8aad('0x7'));var sox=require('sox');var csv=require(_0x8aad('0x8'));var ejs=require(_0x8aad('0x9'));var fs=require('fs');var _=require(_0x8aad('0xa'));var squel=require(_0x8aad('0xb'));var crypto=require(_0x8aad('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x8aad('0xd'));var toCsv=require(_0x8aad('0x8'));var querystring=require(_0x8aad('0xe'));var Papa=require(_0x8aad('0xf'));var Redis=require(_0x8aad('0x10'));var authService=require(_0x8aad('0x11'));var qs=require(_0x8aad('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x8aad('0x13'));var logger=require(_0x8aad('0x14'))('api');var utils=require(_0x8aad('0x15'));var config=require(_0x8aad('0x16'));var licenseUtil=require(_0x8aad('0x17'));var db=require(_0x8aad('0x18'))['db'];config[_0x8aad('0x19')]=_['defaults'](config[_0x8aad('0x19')],{'host':_0x8aad('0x1a'),'port':0x18eb});var socket=require(_0x8aad('0x1b'))(new Redis(config['redis']));require(_0x8aad('0x1c'))['register'](socket);function respondWithStatusCode(_0x334b95,_0x2f0175){_0x2f0175=_0x2f0175||0xcc;return function(_0x47267e){if(_0x47267e){return _0x334b95['sendStatus'](_0x2f0175);}return _0x334b95[_0x8aad('0x1d')](_0x2f0175)[_0x8aad('0x1e')]();};}function respondWithResult(_0x2a361a,_0x38b72e){_0x38b72e=_0x38b72e||0xc8;return function(_0x421100){if(_0x421100){return _0x2a361a[_0x8aad('0x1d')](_0x38b72e)[_0x8aad('0x1f')](_0x421100);}};}function respondWithFilteredResult(_0xa38675,_0x4bb2e4){return function(_0x4f1a63){if(_0x4f1a63){var _0x56271a=_0x4f1a63[_0x8aad('0x20')],_0x591c1d=_0x4bb2e4[_0x8aad('0x21')],_0x59db26=_0x4bb2e4[_0x8aad('0x21')]+_0x4bb2e4[_0x8aad('0x22')],_0x379761;if(_0x59db26>=_0x56271a){_0x59db26=_0x56271a;_0x379761=0xc8;}else{_0x379761=0xce;}_0xa38675[_0x8aad('0x1d')](_0x379761);return _0xa38675[_0x8aad('0x23')](_0x8aad('0x24'),_0x591c1d+'-'+_0x59db26+'/'+_0x56271a)[_0x8aad('0x1f')](_0x4f1a63);}return null;};}function patchUpdates(_0x4254d2){return function(_0x42f917){try{jsonpatch[_0x8aad('0x25')](_0x42f917,_0x4254d2,!![]);}catch(_0x3657f5){return BPromise[_0x8aad('0x26')](_0x3657f5);}return _0x42f917[_0x8aad('0x27')]();};}function saveUpdates(_0x364287,_0x3d5a6f){return function(_0x8a741a){if(_0x8a741a){return _0x8a741a['update'](_0x364287)[_0x8aad('0x28')](function(_0x64bf9e){return _0x64bf9e;});}return null;};}function removeEntity(_0x1fed78,_0x24c465){return function(_0x55901d){if(_0x55901d){return _0x55901d[_0x8aad('0x29')]()[_0x8aad('0x28')](function(){var _0x89d3c4=_0x55901d[_0x8aad('0x2a')]({'plain':!![]});var _0x4b3c57=_0x8aad('0x2b');return db[_0x8aad('0x2c')][_0x8aad('0x29')]({'where':{'type':_0x4b3c57,'resourceId':_0x89d3c4['id']}})['then'](function(){return _0x55901d;});})[_0x8aad('0x28')](function(){_0x1fed78[_0x8aad('0x1d')](0xcc)[_0x8aad('0x1e')]();});}};}function handleEntityNotFound(_0x3ed06c,_0x369537){return function(_0xcec732){if(!_0xcec732){_0x3ed06c[_0x8aad('0x2d')](0x194);}return _0xcec732;};}function handleError(_0x330745,_0x4fe5f0){_0x4fe5f0=_0x4fe5f0||0x1f4;return function(_0x55ac0e){logger['error'](_0x55ac0e[_0x8aad('0x2e')]);if(_0x55ac0e[_0x8aad('0x2f')]){delete _0x55ac0e[_0x8aad('0x2f')];}_0x330745[_0x8aad('0x1d')](_0x4fe5f0)[_0x8aad('0x30')](_0x55ac0e);};}exports['index']=function(_0x5aa0d7,_0x35d30e){var _0xd4ec03={},_0x17b67c={},_0x57386d={'count':0x0,'rows':[]};var _0x2eb02d=_[_0x8aad('0x31')](db[_0x8aad('0x32')][_0x8aad('0x33')],function(_0x46e0e5){return{'name':_0x46e0e5[_0x8aad('0x34')],'type':_0x46e0e5['type']['key']};});_0x17b67c[_0x8aad('0x35')]=_[_0x8aad('0x31')](_0x2eb02d,_0x8aad('0x2f'));_0x17b67c[_0x8aad('0x36')]=_[_0x8aad('0x37')](_0x5aa0d7[_0x8aad('0x36')]);_0x17b67c[_0x8aad('0x38')]=_[_0x8aad('0x39')](_0x17b67c[_0x8aad('0x35')],_0x17b67c[_0x8aad('0x36')]);_0xd4ec03[_0x8aad('0x3a')]=_[_0x8aad('0x39')](_0x17b67c[_0x8aad('0x35')],qs[_0x8aad('0x3b')](_0x5aa0d7[_0x8aad('0x36')][_0x8aad('0x3b')]));_0xd4ec03['attributes']=_0xd4ec03[_0x8aad('0x3a')][_0x8aad('0x3c')]?_0xd4ec03['attributes']:_0x17b67c['model'];if(!_0x5aa0d7[_0x8aad('0x36')][_0x8aad('0x3d')](_0x8aad('0x3e'))){_0xd4ec03[_0x8aad('0x22')]=qs[_0x8aad('0x22')](_0x5aa0d7[_0x8aad('0x36')][_0x8aad('0x22')]);_0xd4ec03[_0x8aad('0x21')]=qs[_0x8aad('0x21')](_0x5aa0d7[_0x8aad('0x36')][_0x8aad('0x21')]);}_0xd4ec03[_0x8aad('0x3f')]=qs[_0x8aad('0x40')](_0x5aa0d7[_0x8aad('0x36')][_0x8aad('0x40')]);_0xd4ec03[_0x8aad('0x41')]=qs[_0x8aad('0x38')](_['pick'](_0x5aa0d7['query'],_0x17b67c[_0x8aad('0x38')]),_0x2eb02d);if(_0x5aa0d7['query'][_0x8aad('0x42')]){_0xd4ec03['where']=_[_0x8aad('0x43')](_0xd4ec03[_0x8aad('0x41')],{'$or':_[_0x8aad('0x31')](_0x2eb02d,function(_0x4f9451){if(_0x4f9451[_0x8aad('0x44')]!==_0x8aad('0x45')){var _0x2f04ca={};_0x2f04ca[_0x4f9451[_0x8aad('0x2f')]]={'$like':'%'+_0x5aa0d7[_0x8aad('0x36')]['filter']+'%'};return _0x2f04ca;}})});}_0xd4ec03=_['merge']({},_0xd4ec03,_0x5aa0d7['options']);var _0x597cea={'where':_0xd4ec03['where']};return db['OpenchannelQueue']['count'](_0x597cea)[_0x8aad('0x28')](function(_0x1c547d){_0x57386d['count']=_0x1c547d;if(_0x5aa0d7[_0x8aad('0x36')][_0x8aad('0x46')]){_0xd4ec03[_0x8aad('0x47')]=[{'all':!![]}];}return db[_0x8aad('0x32')]['findAll'](_0xd4ec03);})['then'](function(_0x3d4ec1){_0x57386d[_0x8aad('0x48')]=_0x3d4ec1;return _0x57386d;})['then'](respondWithFilteredResult(_0x35d30e,_0xd4ec03))[_0x8aad('0x49')](handleError(_0x35d30e,null));};exports[_0x8aad('0x4a')]=function(_0x58c423,_0x477d29){var _0x2ec99d={'raw':!![],'where':{'id':_0x58c423[_0x8aad('0x4b')]['id']}},_0x874445={};_0x874445[_0x8aad('0x35')]=_[_0x8aad('0x37')](db[_0x8aad('0x32')][_0x8aad('0x33')]);_0x874445[_0x8aad('0x36')]=_['keys'](_0x58c423[_0x8aad('0x36')]);_0x874445[_0x8aad('0x38')]=_['intersection'](_0x874445[_0x8aad('0x35')],_0x874445['query']);_0x2ec99d[_0x8aad('0x3a')]=_[_0x8aad('0x39')](_0x874445['model'],qs[_0x8aad('0x3b')](_0x58c423['query']['fields']));_0x2ec99d['attributes']=_0x2ec99d[_0x8aad('0x3a')][_0x8aad('0x3c')]?_0x2ec99d[_0x8aad('0x3a')]:_0x874445[_0x8aad('0x35')];if(_0x58c423['query'][_0x8aad('0x46')]){_0x2ec99d[_0x8aad('0x47')]=[{'all':!![]}];}_0x2ec99d=_[_0x8aad('0x43')]({},_0x2ec99d,_0x58c423[_0x8aad('0x4c')]);return db[_0x8aad('0x32')][_0x8aad('0x4d')](_0x2ec99d)[_0x8aad('0x28')](handleEntityNotFound(_0x477d29,null))['then'](respondWithResult(_0x477d29,null))['catch'](handleError(_0x477d29,null));};exports['create']=function(_0x767427,_0x425840){return db[_0x8aad('0x32')]['create'](_0x767427[_0x8aad('0x4e')],{})['then'](function(_0xa6c9a2){var _0x3b121b=_0x767427['user'][_0x8aad('0x2a')]({'plain':!![]});if(!_0x3b121b)throw new Error(_0x8aad('0x4f'));if(_0x3b121b[_0x8aad('0x50')]==='user'){var _0x4494b4=_0xa6c9a2[_0x8aad('0x2a')]({'plain':!![]});var _0x3b6141=_0x8aad('0x2b');return db[_0x8aad('0x51')][_0x8aad('0x4d')]({'where':{'name':_0x3b6141,'userProfileId':_0x3b121b[_0x8aad('0x52')]},'raw':!![]})[_0x8aad('0x28')](function(_0x3046d8){if(_0x3046d8&&_0x3046d8[_0x8aad('0x53')]===0x0){return db['UserProfileResource'][_0x8aad('0x54')]({'name':_0x4494b4[_0x8aad('0x2f')],'resourceId':_0x4494b4['id'],'type':_0x3046d8[_0x8aad('0x2f')],'sectionId':_0x3046d8['id']},{})[_0x8aad('0x28')](function(){return _0xa6c9a2;});}else{return _0xa6c9a2;}})['catch'](function(_0x315b00){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x315b00);throw _0x315b00;});}return _0xa6c9a2;})[_0x8aad('0x28')](respondWithResult(_0x425840,0xc9))['catch'](handleError(_0x425840,null));};exports[_0x8aad('0x55')]=function(_0x31e2c6,_0x140bda){if(_0x31e2c6[_0x8aad('0x4e')]['id']){delete _0x31e2c6[_0x8aad('0x4e')]['id'];}return db[_0x8aad('0x32')][_0x8aad('0x4d')]({'where':{'id':_0x31e2c6['params']['id']}})[_0x8aad('0x28')](handleEntityNotFound(_0x140bda,null))[_0x8aad('0x28')](saveUpdates(_0x31e2c6['body'],null))[_0x8aad('0x28')](respondWithResult(_0x140bda,null))[_0x8aad('0x49')](handleError(_0x140bda,null));};exports[_0x8aad('0x29')]=function(_0x2878f6,_0x89ede5){return db[_0x8aad('0x32')][_0x8aad('0x4d')]({'where':{'id':_0x2878f6['params']['id']}})['then'](handleEntityNotFound(_0x89ede5,null))[_0x8aad('0x28')](removeEntity(_0x89ede5,null))[_0x8aad('0x49')](handleError(_0x89ede5,null));};exports[_0x8aad('0x56')]=function(_0x21dfd1,_0x246a45){return db['OpenchannelQueue'][_0x8aad('0x56')]()[_0x8aad('0x28')](respondWithResult(_0x246a45,null))['catch'](handleError(_0x246a45,null));};exports[_0x8aad('0x57')]=function(_0x358958,_0x348244,_0x4d6e3d){var _0x16b5b9={'raw':!![],'where':{}},_0x1018a0={},_0x4a3044;return db['OpenchannelQueue'][_0x8aad('0x58')]({'where':{'id':_0x358958[_0x8aad('0x4b')]['id']}})['then'](handleEntityNotFound(_0x348244,null))['then'](function(_0x48cafe){if(_0x48cafe){_0x4a3044=_0x48cafe[_0x8aad('0x2a')]({'plain':!![]});_0x1018a0['model']=_[_0x8aad('0x37')](db['UserOpenchannelQueue'][_0x8aad('0x33')]);_0x1018a0[_0x8aad('0x36')]=_[_0x8aad('0x37')](_0x358958[_0x8aad('0x36')]);_0x1018a0[_0x8aad('0x38')]=_[_0x8aad('0x39')](_0x1018a0[_0x8aad('0x35')],_0x1018a0['query']);_0x16b5b9['attributes']=_[_0x8aad('0x39')](_0x1018a0['model'],qs[_0x8aad('0x3b')](_0x358958[_0x8aad('0x36')][_0x8aad('0x3b')]));_0x16b5b9[_0x8aad('0x3a')]=_0x16b5b9['attributes'][_0x8aad('0x3c')]?_0x16b5b9[_0x8aad('0x3a')]:_0x1018a0['model'];if(!_0x358958[_0x8aad('0x36')][_0x8aad('0x3d')](_0x8aad('0x3e'))){_0x16b5b9['limit']=qs[_0x8aad('0x22')](_0x358958[_0x8aad('0x36')]['limit']);_0x16b5b9['offset']=qs[_0x8aad('0x21')](_0x358958[_0x8aad('0x36')]['offset']);}_0x16b5b9[_0x8aad('0x3f')]=qs[_0x8aad('0x40')](_0x358958[_0x8aad('0x36')]['sort']);_0x16b5b9[_0x8aad('0x41')]=qs[_0x8aad('0x38')](_[_0x8aad('0x59')](_0x358958[_0x8aad('0x36')],_0x1018a0[_0x8aad('0x38')]));_0x16b5b9[_0x8aad('0x41')][_0x8aad('0x5a')]=_0x48cafe['id'];if(_0x358958[_0x8aad('0x36')][_0x8aad('0x42')]){_0x16b5b9[_0x8aad('0x41')]=_[_0x8aad('0x43')](_0x16b5b9[_0x8aad('0x41')],{'$or':_['map'](_0x16b5b9[_0x8aad('0x3a')],function(_0x3c7007){var _0x5d6120={};_0x5d6120[_0x3c7007]={'$like':'%'+_0x358958['query'][_0x8aad('0x42')]+'%'};return _0x5d6120;})});}_0x16b5b9=_[_0x8aad('0x43')]({},_0x16b5b9,_0x358958[_0x8aad('0x4c')]);return db[_0x8aad('0x5b')][_0x8aad('0x5c')](_0x16b5b9);}})['then'](function(_0x272004){if(_0x272004){return db[_0x8aad('0x5d')][_0x8aad('0x5e')]({'where':{'id':_[_0x8aad('0x31')](_0x272004,'UserId'),'role':_0x8aad('0x5f')},'attributes':['id',_0x8aad('0x2f'),'openchannelPause','updatedAt','createdAt']});}})['then'](function(_0x3b0e03){if(_0x3b0e03){return{'count':_0x3b0e03['count'],'rows':_[_0x8aad('0x31')](_0x3b0e03[_0x8aad('0x48')],function(_0x3fc3cd){return{'membername':_0x3fc3cd['name'],'UserId':_0x3fc3cd['id'],'queue_name':_0x4a3044['name'],'OpenchannelQueueId':_0x4a3044['id'],'interface':util[_0x8aad('0x60')]('%s/%s',_0x8aad('0x61'),_0x3fc3cd['name']),'penalty':0x0,'paused':_0x3fc3cd[_0x8aad('0x62')],'createdAt':_0x3fc3cd[_0x8aad('0x63')],'updatedAt':_0x3fc3cd[_0x8aad('0x64')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x8aad('0x28')](respondWithFilteredResult(_0x348244,_0x16b5b9))[_0x8aad('0x49')](handleError(_0x348244,null));};exports['getTeams']=function(_0x513ce6,_0x2e17b3,_0x20ef1e){var _0x291ae7={};var _0x204b51={};var _0x5158f0;var _0x9c94a9;return db[_0x8aad('0x32')][_0x8aad('0x58')]({'where':{'id':_0x513ce6[_0x8aad('0x4b')]['id']}})[_0x8aad('0x28')](handleEntityNotFound(_0x2e17b3,null))[_0x8aad('0x28')](function(_0x197cbd){if(_0x197cbd){_0x5158f0=_0x197cbd;_0x204b51[_0x8aad('0x35')]=_[_0x8aad('0x37')](db['Team'][_0x8aad('0x33')]);_0x204b51[_0x8aad('0x36')]=_[_0x8aad('0x37')](_0x513ce6['query']);_0x204b51[_0x8aad('0x38')]=_['intersection'](_0x204b51['model'],_0x204b51[_0x8aad('0x36')]);_0x291ae7[_0x8aad('0x3a')]=_[_0x8aad('0x39')](_0x204b51[_0x8aad('0x35')],qs[_0x8aad('0x3b')](_0x513ce6[_0x8aad('0x36')][_0x8aad('0x3b')]));_0x291ae7['attributes']=_0x291ae7[_0x8aad('0x3a')]['length']?_0x291ae7[_0x8aad('0x3a')]:_0x204b51['model'];_0x291ae7[_0x8aad('0x3f')]=qs['sort'](_0x513ce6[_0x8aad('0x36')][_0x8aad('0x40')]);_0x291ae7[_0x8aad('0x41')]=qs[_0x8aad('0x38')](_[_0x8aad('0x59')](_0x513ce6['query'],_0x204b51['filters']));if(_0x513ce6[_0x8aad('0x36')][_0x8aad('0x42')]){_0x291ae7[_0x8aad('0x41')]=_[_0x8aad('0x43')](_0x291ae7[_0x8aad('0x41')],{'$or':_[_0x8aad('0x31')](_0x291ae7[_0x8aad('0x3a')],function(_0x133952){var _0x50fd65={};_0x50fd65[_0x133952]={'$like':'%'+_0x513ce6[_0x8aad('0x36')][_0x8aad('0x42')]+'%'};return _0x50fd65;})});}_0x291ae7=_[_0x8aad('0x43')]({},_0x291ae7,_0x513ce6[_0x8aad('0x4c')]);return _0x5158f0[_0x8aad('0x65')](_0x291ae7);}})[_0x8aad('0x28')](function(_0x131811){if(_0x131811){_0x9c94a9=_0x131811[_0x8aad('0x3c')];if(!_0x513ce6[_0x8aad('0x36')][_0x8aad('0x3d')]('nolimit')){_0x291ae7[_0x8aad('0x22')]=qs[_0x8aad('0x22')](_0x513ce6[_0x8aad('0x36')][_0x8aad('0x22')]);_0x291ae7[_0x8aad('0x21')]=qs[_0x8aad('0x21')](_0x513ce6[_0x8aad('0x36')]['offset']);}return _0x5158f0['getTeams'](_0x291ae7);}})[_0x8aad('0x28')](function(_0x3df77f){if(_0x3df77f){return _0x3df77f?{'count':_0x9c94a9,'rows':_0x3df77f}:null;}})[_0x8aad('0x28')](respondWithResult(_0x2e17b3,null))[_0x8aad('0x49')](handleError(_0x2e17b3,null));};exports[_0x8aad('0x66')]=function(_0xe6e898,_0x303958,_0x4fdae8){var _0x357bd8=_0xe6e898[_0x8aad('0x4e')][_0x8aad('0x67')];return db[_0x8aad('0x68')][_0x8aad('0x5c')]({'where':{'id':_0x357bd8},'attributes':['id'],'include':[{'model':db[_0x8aad('0x5d')],'as':_0x8aad('0x69'),'attributes':['id','name',_0x8aad('0x6a'),'voicePause',_0x8aad('0x6b')],'raw':!![]}]})[_0x8aad('0x28')](function(_0x25b6cb){if(_0x25b6cb){var _0x2ed022=_[_0x8aad('0x6c')](_0x25b6cb,function(_0x570d34){var _0x56eb80=_0x570d34['get']({'plain':!![]});return _0x56eb80[_0x8aad('0x69')];});return db[_0x8aad('0x32')][_0x8aad('0x4d')]({'where':{'id':_0xe6e898['params']['id']}})[_0x8aad('0x28')](function(_0x4cccc3){return db[_0x8aad('0x6d')][_0x8aad('0x6e')](function(_0x3206e5){return _0x4cccc3[_0x8aad('0x66')](_0x357bd8,{'transaction':_0x3206e5})[_0x8aad('0x28')](function(){return BPromise[_0x8aad('0x6f')](_0x2ed022,function(_0x250849){return db[_0x8aad('0x5b')][_0x8aad('0x70')]({'where':{'UserId':_0x250849['id'],'OpenchannelQueueId':_0xe6e898[_0x8aad('0x4b')]['id']},'transaction':_0x3206e5});});})[_0x8aad('0x28')](function(){_0x2ed022[_0x8aad('0x71')](function(_0x20bb84){socket[_0x8aad('0x72')]('userOpenchannelQueue:save',{'UserId':_0x20bb84['id'],'OpenchannelQueueId':_0x4cccc3['id']});});});});});}})[_0x8aad('0x28')](respondWithStatusCode(_0x303958,null))[_0x8aad('0x49')](handleError(_0x303958,null));};exports[_0x8aad('0x73')]=function(_0x3add3,_0x2be599,_0x239c2c){return db[_0x8aad('0x68')][_0x8aad('0x5c')]({'where':{'id':_0x3add3['query'][_0x8aad('0x67')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x8aad('0x69'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x2be599,null))['then'](function(_0x42b145){var _0x5d44b8=_[_0x8aad('0x31')](_0x42b145,'id');var _0x311010=[];var _0x26effd=[];var _0x101148=squel[_0x8aad('0x74')]();_0x101148[_0x8aad('0x75')](_0x8aad('0x76'))[_0x8aad('0x77')](_0x8aad('0x78'),'tq')[_0x8aad('0x79')](_0x8aad('0x7a'),'ut',_0x8aad('0x7b'))[_0x8aad('0x41')](_0x8aad('0x7c'),_0x3add3[_0x8aad('0x4b')]['id']);for(var _0x33628a=0x0;_0x33628a<_0x42b145[_0x8aad('0x3c')];_0x33628a+=0x1){let _0xa792d=_0x42b145[_0x33628a];for(var _0x2f4caf=0x0;_0x2f4caf<_0xa792d[_0x8aad('0x69')][_0x8aad('0x3c')];_0x2f4caf+=0x1){let _0x19d7a2=_0xa792d[_0x8aad('0x69')][_0x2f4caf];var _0x51b2d6=_0x101148[_0x8aad('0x7d')]();_0x51b2d6[_0x8aad('0x41')](_0x8aad('0x7e'),_0x19d7a2['id']);_0x26effd[_0x8aad('0x7f')](db[_0x8aad('0x6d')][_0x8aad('0x36')](_0x51b2d6[_0x8aad('0x80')](),{'type':db[_0x8aad('0x6d')]['QueryTypes'][_0x8aad('0x81')]})[_0x8aad('0x28')](function(_0x207ab1){if(_0x207ab1[_0x8aad('0x3c')]===0x1){return _0x19d7a2['id'];}else{var _0x132614=_[_0x8aad('0x82')](_['map'](_0x207ab1,'TeamId'),function(_0x5bb86e){return _['includes'](_0x5d44b8,_0x5bb86e);});if(_0x132614){return _0x19d7a2['id'];}}}));}}return BPromise['all'](_0x26effd)[_0x8aad('0x28')](function(_0x65c647){_0x311010=_(_0x311010)[_0x8aad('0x83')](_0x65c647)['compact']()[_0x8aad('0x84')]();return db[_0x8aad('0x32')][_0x8aad('0x4d')]({'where':{'id':_0x3add3[_0x8aad('0x4b')]['id']}})[_0x8aad('0x28')](function(_0x2e58b4){return db[_0x8aad('0x6d')][_0x8aad('0x6e')](function(_0x32d73b){return _0x2e58b4[_0x8aad('0x73')](_0x3add3[_0x8aad('0x36')]['ids'],{'transaction':_0x32d73b})[_0x8aad('0x28')](function(){if(!_[_0x8aad('0x85')](_0x311010)){return _0x2e58b4[_0x8aad('0x86')](_0x311010,{'transaction':_0x32d73b});}})[_0x8aad('0x28')](function(){_0x311010['forEach'](function(_0x1c4eb7){socket[_0x8aad('0x72')](_0x8aad('0x87'),{'UserId':_0x1c4eb7,'OpenchannelQueueId':_0x2e58b4['id']});});});});});});})[_0x8aad('0x28')](respondWithStatusCode(_0x2be599,null))[_0x8aad('0x49')](handleError(_0x2be599,null));};exports['addAgents']=function(_0x3fe566,_0x13ec56,_0x5ba4dc){return db['OpenchannelQueue'][_0x8aad('0x4d')]({'where':{'id':_0x3fe566['params']['id']}})[_0x8aad('0x28')](handleEntityNotFound(_0x13ec56,null))[_0x8aad('0x28')](function(_0x2bc27c){if(_0x2bc27c){return _0x2bc27c['addAgents'](_0x3fe566[_0x8aad('0x4e')][_0x8aad('0x67')],_[_0x8aad('0x88')](_0x3fe566[_0x8aad('0x4e')],[_0x8aad('0x67'),'id'])||{})[_0x8aad('0x89')](function(_0x2cb21a){for(var _0x299376=0x0;_0x299376<_0x3fe566[_0x8aad('0x4e')]['ids'][_0x8aad('0x3c')];_0x299376+=0x1){socket['emit'](_0x8aad('0x8a'),{'UserId':_0x3fe566[_0x8aad('0x4e')][_0x8aad('0x67')][_0x299376],'OpenchannelQueueId':_0x3fe566[_0x8aad('0x4b')]['id']});}return _0x2cb21a;});}})[_0x8aad('0x28')](respondWithResult(_0x13ec56,null))['catch'](handleError(_0x13ec56,null));};exports[_0x8aad('0x86')]=function(_0x1f2631,_0x49c15b,_0x57ad09){return db[_0x8aad('0x32')][_0x8aad('0x4d')]({'where':{'id':_0x1f2631['params']['id']}})[_0x8aad('0x28')](handleEntityNotFound(_0x49c15b,null))[_0x8aad('0x28')](function(_0x3f011a){if(_0x3f011a){return _0x3f011a[_0x8aad('0x86')](_0x1f2631[_0x8aad('0x36')][_0x8aad('0x67')])[_0x8aad('0x28')](function(){if(_[_0x8aad('0x8b')](_0x1f2631[_0x8aad('0x36')][_0x8aad('0x67')])){for(var _0x1e09f3=0x0;_0x1e09f3<_0x1f2631[_0x8aad('0x36')][_0x8aad('0x67')][_0x8aad('0x3c')];_0x1e09f3+=0x1){socket[_0x8aad('0x72')]('userOpenchannelQueue:remove',{'UserId':Number(_0x1f2631[_0x8aad('0x36')]['ids'][_0x1e09f3]),'OpenchannelQueueId':Number(_0x1f2631[_0x8aad('0x4b')]['id'])});}}else{socket[_0x8aad('0x72')](_0x8aad('0x87'),{'UserId':Number(_0x1f2631['query']['ids']),'OpenchannelQueueId':Number(_0x1f2631[_0x8aad('0x4b')]['id'])});}});}})[_0x8aad('0x28')](respondWithStatusCode(_0x49c15b,null))[_0x8aad('0x49')](handleError(_0x49c15b,null));};exports[_0x8aad('0x8c')]=function(_0x40fe70,_0x253156,_0x31fc26){var _0x33b9b7={};var _0x5efdf0={};var _0x4bd114;var _0x5ebd62;return db[_0x8aad('0x32')][_0x8aad('0x58')]({'where':{'id':_0x40fe70[_0x8aad('0x4b')]['id']}})['then'](handleEntityNotFound(_0x253156,null))['then'](function(_0x2adc1c){if(_0x2adc1c){_0x4bd114=_0x2adc1c;_0x5efdf0[_0x8aad('0x35')]=_['keys'](db[_0x8aad('0x5d')][_0x8aad('0x33')]);_0x5efdf0[_0x8aad('0x36')]=_['keys'](_0x40fe70[_0x8aad('0x36')]);_0x5efdf0[_0x8aad('0x38')]=_[_0x8aad('0x39')](_0x5efdf0['model'],_0x5efdf0['query']);_0x33b9b7['attributes']=_['intersection'](_0x5efdf0['model'],qs[_0x8aad('0x3b')](_0x40fe70[_0x8aad('0x36')][_0x8aad('0x3b')]));_0x33b9b7['attributes']=_0x33b9b7[_0x8aad('0x3a')][_0x8aad('0x3c')]?_0x33b9b7[_0x8aad('0x3a')]:_0x5efdf0[_0x8aad('0x35')];_0x33b9b7[_0x8aad('0x3f')]=qs[_0x8aad('0x40')](_0x40fe70['query'][_0x8aad('0x40')]);_0x33b9b7[_0x8aad('0x41')]=qs[_0x8aad('0x38')](_['pick'](_0x40fe70[_0x8aad('0x36')],_0x5efdf0[_0x8aad('0x38')]));if(_0x40fe70[_0x8aad('0x36')][_0x8aad('0x42')]){_0x33b9b7[_0x8aad('0x41')]=_[_0x8aad('0x43')](_0x33b9b7[_0x8aad('0x41')],{'$or':_[_0x8aad('0x31')](_0x33b9b7['attributes'],function(_0x76e584){var _0x18ddc9={};_0x18ddc9[_0x76e584]={'$like':'%'+_0x40fe70[_0x8aad('0x36')]['filter']+'%'};return _0x18ddc9;})});}_0x33b9b7=_[_0x8aad('0x43')]({},_0x33b9b7,_0x40fe70[_0x8aad('0x4c')]);return _0x4bd114[_0x8aad('0x8c')](_0x33b9b7);}})[_0x8aad('0x28')](function(_0x55fda4){if(_0x55fda4){_0x5ebd62=_0x55fda4[_0x8aad('0x3c')];if(!_0x40fe70[_0x8aad('0x36')][_0x8aad('0x3d')](_0x8aad('0x3e'))){_0x33b9b7[_0x8aad('0x22')]=qs['limit'](_0x40fe70[_0x8aad('0x36')][_0x8aad('0x22')]);_0x33b9b7[_0x8aad('0x21')]=qs['offset'](_0x40fe70[_0x8aad('0x36')][_0x8aad('0x21')]);}return _0x4bd114[_0x8aad('0x8c')](_0x33b9b7);}})[_0x8aad('0x28')](function(_0x2437fc){if(_0x2437fc){return _0x2437fc?{'count':_0x5ebd62,'rows':_0x2437fc}:null;}})[_0x8aad('0x28')](respondWithResult(_0x253156,null))[_0x8aad('0x49')](handleError(_0x253156,null));};
\ No newline at end of file
+var _0xe8f0=['interface','flatMap','sequelize','each','findOrCreate','forEach','emit','userOpenchannelQueue:save','removeTeams','select','field','tq.TeamId','team_has_openchannel_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','every','TeamId','includes','all','value','isEmpty','removeAgents','addAgents','omit','spread','isArray','userOpenchannelQueue:remove','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','register','sendStatus','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','update','then','get','OpenchannelQueues','UserProfileResource','destroy','error','name','send','index','map','OpenchannelQueue','rawAttributes','type','model','query','filters','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','include','findAll','rows','catch','show','params','keys','intersection','length','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','describe','getMembers','findOne','UserOpenchannelQueue','OpenchannelQueueId','User','findAndCountAll','UserId','agent','openchannelPause','updatedAt','createdAt','format','%s/%s','getTeams','Team','options','addTeams','ids','Agents'];(function(_0x2170d0,_0x1aaf1d){var _0x4644a1=function(_0x131700){while(--_0x131700){_0x2170d0['push'](_0x2170d0['shift']());}};_0x4644a1(++_0x1aaf1d);}(_0xe8f0,0x141));var _0x0e8f=function(_0x255f10,_0xa8323f){_0x255f10=_0x255f10-0x0;var _0x20fe33=_0xe8f0[_0x255f10];return _0x20fe33;};'use strict';var emlformat=require(_0x0e8f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0e8f('0x1'));var jsonpatch=require(_0x0e8f('0x2'));var rp=require(_0x0e8f('0x3'));var moment=require(_0x0e8f('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x0e8f('0x5'));var util=require(_0x0e8f('0x6'));var path=require(_0x0e8f('0x7'));var sox=require(_0x0e8f('0x8'));var csv=require(_0x0e8f('0x9'));var ejs=require(_0x0e8f('0xa'));var fs=require('fs');var fs_extra=require(_0x0e8f('0xb'));var _=require('lodash');var squel=require(_0x0e8f('0xc'));var crypto=require(_0x0e8f('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x0e8f('0xe'));var toCsv=require(_0x0e8f('0x9'));var querystring=require(_0x0e8f('0xf'));var Papa=require(_0x0e8f('0x10'));var Redis=require(_0x0e8f('0x11'));var authService=require(_0x0e8f('0x12'));var qs=require(_0x0e8f('0x13'));var as=require(_0x0e8f('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0e8f('0x15'))(_0x0e8f('0x16'));var utils=require('../../config/utils');var config=require(_0x0e8f('0x17'));var licenseUtil=require(_0x0e8f('0x18'));var db=require(_0x0e8f('0x19'))['db'];config['redis']=_[_0x0e8f('0x1a')](config[_0x0e8f('0x1b')],{'host':_0x0e8f('0x1c'),'port':0x18eb});var socket=require(_0x0e8f('0x1d'))(new Redis(config[_0x0e8f('0x1b')]));require('./openchannelQueue.socket')[_0x0e8f('0x1e')](socket);function respondWithStatusCode(_0x4b8229,_0x3179d8){_0x3179d8=_0x3179d8||0xcc;return function(_0x4125f3){if(_0x4125f3){return _0x4b8229[_0x0e8f('0x1f')](_0x3179d8);}return _0x4b8229[_0x0e8f('0x20')](_0x3179d8)[_0x0e8f('0x21')]();};}function respondWithResult(_0x117a7b,_0x4a2692){_0x4a2692=_0x4a2692||0xc8;return function(_0x453968){if(_0x453968){return _0x117a7b['status'](_0x4a2692)['json'](_0x453968);}};}function respondWithFilteredResult(_0x4cf1c9,_0x4ba573){return function(_0x1be063){if(_0x1be063){var _0x2de0d0=typeof _0x4ba573[_0x0e8f('0x22')]===_0x0e8f('0x23')&&typeof _0x4ba573[_0x0e8f('0x24')]==='undefined';var _0x5af118=_0x1be063[_0x0e8f('0x25')];var _0x4d1fe6=_0x2de0d0?0x0:_0x4ba573[_0x0e8f('0x22')];var _0x584af9=_0x2de0d0?_0x1be063[_0x0e8f('0x25')]:_0x4ba573[_0x0e8f('0x22')]+_0x4ba573[_0x0e8f('0x24')];var _0x518067;if(_0x584af9>=_0x5af118){_0x584af9=_0x5af118;_0x518067=0xc8;}else{_0x518067=0xce;}_0x4cf1c9[_0x0e8f('0x20')](_0x518067);return _0x4cf1c9['set'](_0x0e8f('0x26'),_0x4d1fe6+'-'+_0x584af9+'/'+_0x5af118)[_0x0e8f('0x27')](_0x1be063);}return null;};}function patchUpdates(_0x14e9a6){return function(_0x24992){try{jsonpatch[_0x0e8f('0x28')](_0x24992,_0x14e9a6,!![]);}catch(_0x27643c){return BPromise[_0x0e8f('0x29')](_0x27643c);}return _0x24992['save']();};}function saveUpdates(_0x5d4b2c,_0x506967){return function(_0x582360){if(_0x582360){return _0x582360[_0x0e8f('0x2a')](_0x5d4b2c)[_0x0e8f('0x2b')](function(_0x694da1){return _0x694da1;});}return null;};}function removeEntity(_0x33ea88,_0x3b220c){return function(_0x513a3b){if(_0x513a3b){return _0x513a3b['destroy']()[_0x0e8f('0x2b')](function(){var _0x2da682=_0x513a3b[_0x0e8f('0x2c')]({'plain':!![]});var _0x224e89=_0x0e8f('0x2d');return db[_0x0e8f('0x2e')][_0x0e8f('0x2f')]({'where':{'type':_0x224e89,'resourceId':_0x2da682['id']}})[_0x0e8f('0x2b')](function(){return _0x513a3b;});})['then'](function(){_0x33ea88[_0x0e8f('0x20')](0xcc)[_0x0e8f('0x21')]();});}};}function handleEntityNotFound(_0x2c9c3a,_0x3764b5){return function(_0xe04e41){if(!_0xe04e41){_0x2c9c3a['sendStatus'](0x194);}return _0xe04e41;};}function handleError(_0x39c7b3,_0x3c711a){_0x3c711a=_0x3c711a||0x1f4;return function(_0x43bd65){logger[_0x0e8f('0x30')](_0x43bd65['stack']);if(_0x43bd65[_0x0e8f('0x31')]){delete _0x43bd65[_0x0e8f('0x31')];}_0x39c7b3[_0x0e8f('0x20')](_0x3c711a)[_0x0e8f('0x32')](_0x43bd65);};}exports[_0x0e8f('0x33')]=function(_0x432cbe,_0xa8f75b){var _0x4302f5={},_0x4af03b={},_0x54e52f={'count':0x0,'rows':[]};var _0x3ea154=_[_0x0e8f('0x34')](db[_0x0e8f('0x35')][_0x0e8f('0x36')],function(_0x354007){return{'name':_0x354007['fieldName'],'type':_0x354007[_0x0e8f('0x37')]['key']};});_0x4af03b[_0x0e8f('0x38')]=_[_0x0e8f('0x34')](_0x3ea154,_0x0e8f('0x31'));_0x4af03b[_0x0e8f('0x39')]=_['keys'](_0x432cbe[_0x0e8f('0x39')]);_0x4af03b[_0x0e8f('0x3a')]=_['intersection'](_0x4af03b['model'],_0x4af03b[_0x0e8f('0x39')]);_0x4302f5[_0x0e8f('0x3b')]=_['intersection'](_0x4af03b[_0x0e8f('0x38')],qs[_0x0e8f('0x3c')](_0x432cbe[_0x0e8f('0x39')]['fields']));_0x4302f5[_0x0e8f('0x3b')]=_0x4302f5[_0x0e8f('0x3b')]['length']?_0x4302f5['attributes']:_0x4af03b[_0x0e8f('0x38')];if(!_0x432cbe[_0x0e8f('0x39')][_0x0e8f('0x3d')](_0x0e8f('0x3e'))){_0x4302f5[_0x0e8f('0x24')]=qs[_0x0e8f('0x24')](_0x432cbe[_0x0e8f('0x39')][_0x0e8f('0x24')]);_0x4302f5['offset']=qs[_0x0e8f('0x22')](_0x432cbe[_0x0e8f('0x39')][_0x0e8f('0x22')]);}_0x4302f5[_0x0e8f('0x3f')]=qs['sort'](_0x432cbe['query'][_0x0e8f('0x40')]);_0x4302f5[_0x0e8f('0x41')]=qs[_0x0e8f('0x3a')](_[_0x0e8f('0x42')](_0x432cbe['query'],_0x4af03b[_0x0e8f('0x3a')]),_0x3ea154);if(_0x432cbe[_0x0e8f('0x39')]['filter']){_0x4302f5['where']=_[_0x0e8f('0x43')](_0x4302f5['where'],{'$or':_[_0x0e8f('0x34')](_0x3ea154,function(_0x3c3c91){if(_0x3c3c91[_0x0e8f('0x37')]!==_0x0e8f('0x44')){var _0x41bb19={};_0x41bb19[_0x3c3c91[_0x0e8f('0x31')]]={'$like':'%'+_0x432cbe[_0x0e8f('0x39')][_0x0e8f('0x45')]+'%'};return _0x41bb19;}})});}_0x4302f5=_[_0x0e8f('0x43')]({},_0x4302f5,_0x432cbe['options']);var _0x38b3c7={'where':_0x4302f5[_0x0e8f('0x41')]};return db[_0x0e8f('0x35')]['count'](_0x38b3c7)[_0x0e8f('0x2b')](function(_0x28f372){_0x54e52f['count']=_0x28f372;if(_0x432cbe[_0x0e8f('0x39')]['includeAll']){_0x4302f5[_0x0e8f('0x46')]=[{'all':!![]}];}return db['OpenchannelQueue'][_0x0e8f('0x47')](_0x4302f5);})[_0x0e8f('0x2b')](function(_0x229e3d){_0x54e52f[_0x0e8f('0x48')]=_0x229e3d;return _0x54e52f;})['then'](respondWithFilteredResult(_0xa8f75b,_0x4302f5))[_0x0e8f('0x49')](handleError(_0xa8f75b,null));};exports[_0x0e8f('0x4a')]=function(_0x3165d1,_0x217ad3){var _0x15a09e={'raw':!![],'where':{'id':_0x3165d1[_0x0e8f('0x4b')]['id']}},_0x3d686d={};_0x3d686d[_0x0e8f('0x38')]=_['keys'](db[_0x0e8f('0x35')][_0x0e8f('0x36')]);_0x3d686d[_0x0e8f('0x39')]=_[_0x0e8f('0x4c')](_0x3165d1['query']);_0x3d686d['filters']=_['intersection'](_0x3d686d[_0x0e8f('0x38')],_0x3d686d[_0x0e8f('0x39')]);_0x15a09e[_0x0e8f('0x3b')]=_[_0x0e8f('0x4d')](_0x3d686d[_0x0e8f('0x38')],qs[_0x0e8f('0x3c')](_0x3165d1['query']['fields']));_0x15a09e[_0x0e8f('0x3b')]=_0x15a09e[_0x0e8f('0x3b')][_0x0e8f('0x4e')]?_0x15a09e[_0x0e8f('0x3b')]:_0x3d686d[_0x0e8f('0x38')];if(_0x3165d1['query']['includeAll']){_0x15a09e[_0x0e8f('0x46')]=[{'all':!![]}];}_0x15a09e=_[_0x0e8f('0x43')]({},_0x15a09e,_0x3165d1['options']);return db[_0x0e8f('0x35')]['find'](_0x15a09e)[_0x0e8f('0x2b')](handleEntityNotFound(_0x217ad3,null))[_0x0e8f('0x2b')](respondWithResult(_0x217ad3,null))[_0x0e8f('0x49')](handleError(_0x217ad3,null));};exports[_0x0e8f('0x4f')]=function(_0x4fcc47,_0x22b849){return db[_0x0e8f('0x35')]['create'](_0x4fcc47[_0x0e8f('0x50')],{})['then'](function(_0x5ad187){var _0x23e396=_0x4fcc47[_0x0e8f('0x51')]['get']({'plain':!![]});if(!_0x23e396)throw new Error(_0x0e8f('0x52'));if(_0x23e396[_0x0e8f('0x53')]===_0x0e8f('0x51')){var _0x2fc67e=_0x5ad187[_0x0e8f('0x2c')]({'plain':!![]});var _0x2090c1=_0x0e8f('0x2d');return db['UserProfileSection']['find']({'where':{'name':_0x2090c1,'userProfileId':_0x23e396[_0x0e8f('0x54')]},'raw':!![]})[_0x0e8f('0x2b')](function(_0x254483){if(_0x254483&&_0x254483[_0x0e8f('0x55')]===0x0){return db[_0x0e8f('0x2e')][_0x0e8f('0x4f')]({'name':_0x2fc67e[_0x0e8f('0x31')],'resourceId':_0x2fc67e['id'],'type':_0x254483['name'],'sectionId':_0x254483['id']},{})['then'](function(){return _0x5ad187;});}else{return _0x5ad187;}})['catch'](function(_0x39c182){logger[_0x0e8f('0x30')](_0x0e8f('0x56'),_0x39c182);throw _0x39c182;});}return _0x5ad187;})[_0x0e8f('0x2b')](respondWithResult(_0x22b849,0xc9))['catch'](handleError(_0x22b849,null));};exports[_0x0e8f('0x2a')]=function(_0x124bf5,_0x5a6ef1){if(_0x124bf5[_0x0e8f('0x50')]['id']){delete _0x124bf5[_0x0e8f('0x50')]['id'];}return db['OpenchannelQueue'][_0x0e8f('0x57')]({'where':{'id':_0x124bf5[_0x0e8f('0x4b')]['id']}})[_0x0e8f('0x2b')](handleEntityNotFound(_0x5a6ef1,null))[_0x0e8f('0x2b')](saveUpdates(_0x124bf5[_0x0e8f('0x50')],null))['then'](respondWithResult(_0x5a6ef1,null))[_0x0e8f('0x49')](handleError(_0x5a6ef1,null));};exports[_0x0e8f('0x2f')]=function(_0x251d1e,_0x562259){return db[_0x0e8f('0x35')][_0x0e8f('0x57')]({'where':{'id':_0x251d1e[_0x0e8f('0x4b')]['id']}})[_0x0e8f('0x2b')](handleEntityNotFound(_0x562259,null))['then'](removeEntity(_0x562259,null))['catch'](handleError(_0x562259,null));};exports[_0x0e8f('0x58')]=function(_0x4c289c,_0x53d864){return db[_0x0e8f('0x35')][_0x0e8f('0x58')]()[_0x0e8f('0x2b')](respondWithResult(_0x53d864,null))[_0x0e8f('0x49')](handleError(_0x53d864,null));};exports[_0x0e8f('0x59')]=function(_0x15a5ac,_0x1df696,_0x2e3250){var _0x4b4235={'raw':!![],'where':{}},_0x5dca7a={},_0x54e00c;return db[_0x0e8f('0x35')][_0x0e8f('0x5a')]({'where':{'id':_0x15a5ac[_0x0e8f('0x4b')]['id']}})[_0x0e8f('0x2b')](handleEntityNotFound(_0x1df696,null))[_0x0e8f('0x2b')](function(_0x5cc4c0){if(_0x5cc4c0){_0x54e00c=_0x5cc4c0['get']({'plain':!![]});_0x5dca7a[_0x0e8f('0x38')]=_[_0x0e8f('0x4c')](db[_0x0e8f('0x5b')][_0x0e8f('0x36')]);_0x5dca7a[_0x0e8f('0x39')]=_[_0x0e8f('0x4c')](_0x15a5ac[_0x0e8f('0x39')]);_0x5dca7a['filters']=_['intersection'](_0x5dca7a[_0x0e8f('0x38')],_0x5dca7a[_0x0e8f('0x39')]);_0x4b4235[_0x0e8f('0x3b')]=_[_0x0e8f('0x4d')](_0x5dca7a[_0x0e8f('0x38')],qs['fields'](_0x15a5ac[_0x0e8f('0x39')][_0x0e8f('0x3c')]));_0x4b4235[_0x0e8f('0x3b')]=_0x4b4235[_0x0e8f('0x3b')][_0x0e8f('0x4e')]?_0x4b4235[_0x0e8f('0x3b')]:_0x5dca7a['model'];if(!_0x15a5ac[_0x0e8f('0x39')][_0x0e8f('0x3d')](_0x0e8f('0x3e'))){_0x4b4235['limit']=qs[_0x0e8f('0x24')](_0x15a5ac[_0x0e8f('0x39')][_0x0e8f('0x24')]);_0x4b4235[_0x0e8f('0x22')]=qs[_0x0e8f('0x22')](_0x15a5ac['query'][_0x0e8f('0x22')]);}_0x4b4235[_0x0e8f('0x3f')]=qs['sort'](_0x15a5ac['query']['sort']);_0x4b4235[_0x0e8f('0x41')]=qs['filters'](_[_0x0e8f('0x42')](_0x15a5ac[_0x0e8f('0x39')],_0x5dca7a[_0x0e8f('0x3a')]));_0x4b4235[_0x0e8f('0x41')][_0x0e8f('0x5c')]=_0x5cc4c0['id'];if(_0x15a5ac[_0x0e8f('0x39')][_0x0e8f('0x45')]){_0x4b4235[_0x0e8f('0x41')]=_[_0x0e8f('0x43')](_0x4b4235[_0x0e8f('0x41')],{'$or':_[_0x0e8f('0x34')](_0x4b4235[_0x0e8f('0x3b')],function(_0x445d7a){var _0x1e0d25={};_0x1e0d25[_0x445d7a]={'$like':'%'+_0x15a5ac[_0x0e8f('0x39')][_0x0e8f('0x45')]+'%'};return _0x1e0d25;})});}_0x4b4235=_[_0x0e8f('0x43')]({},_0x4b4235,_0x15a5ac['options']);return db['UserOpenchannelQueue'][_0x0e8f('0x47')](_0x4b4235);}})['then'](function(_0x5621be){if(_0x5621be){return db[_0x0e8f('0x5d')][_0x0e8f('0x5e')]({'where':{'id':_[_0x0e8f('0x34')](_0x5621be,_0x0e8f('0x5f')),'role':_0x0e8f('0x60')},'attributes':['id',_0x0e8f('0x31'),_0x0e8f('0x61'),_0x0e8f('0x62'),_0x0e8f('0x63')]});}})[_0x0e8f('0x2b')](function(_0x5dbf21){if(_0x5dbf21){return{'count':_0x5dbf21[_0x0e8f('0x25')],'rows':_[_0x0e8f('0x34')](_0x5dbf21[_0x0e8f('0x48')],function(_0x5e8913){return{'membername':_0x5e8913[_0x0e8f('0x31')],'UserId':_0x5e8913['id'],'queue_name':_0x54e00c[_0x0e8f('0x31')],'OpenchannelQueueId':_0x54e00c['id'],'interface':util[_0x0e8f('0x64')](_0x0e8f('0x65'),'SIP',_0x5e8913[_0x0e8f('0x31')]),'penalty':0x0,'paused':_0x5e8913['openchannelPause'],'createdAt':_0x5e8913[_0x0e8f('0x63')],'updatedAt':_0x5e8913[_0x0e8f('0x62')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x1df696,_0x4b4235))[_0x0e8f('0x49')](handleError(_0x1df696,null));};exports[_0x0e8f('0x66')]=function(_0x29f6be,_0x256041,_0x2094d0){var _0x1a2f39={};var _0x39d874={};var _0x163a98;var _0x5b63aa;return db[_0x0e8f('0x35')]['findOne']({'where':{'id':_0x29f6be[_0x0e8f('0x4b')]['id']}})[_0x0e8f('0x2b')](handleEntityNotFound(_0x256041,null))['then'](function(_0x53791a){if(_0x53791a){_0x163a98=_0x53791a;_0x39d874[_0x0e8f('0x38')]=_['keys'](db[_0x0e8f('0x67')]['rawAttributes']);_0x39d874[_0x0e8f('0x39')]=_[_0x0e8f('0x4c')](_0x29f6be['query']);_0x39d874[_0x0e8f('0x3a')]=_[_0x0e8f('0x4d')](_0x39d874[_0x0e8f('0x38')],_0x39d874['query']);_0x1a2f39[_0x0e8f('0x3b')]=_[_0x0e8f('0x4d')](_0x39d874[_0x0e8f('0x38')],qs[_0x0e8f('0x3c')](_0x29f6be[_0x0e8f('0x39')][_0x0e8f('0x3c')]));_0x1a2f39[_0x0e8f('0x3b')]=_0x1a2f39[_0x0e8f('0x3b')][_0x0e8f('0x4e')]?_0x1a2f39[_0x0e8f('0x3b')]:_0x39d874[_0x0e8f('0x38')];_0x1a2f39[_0x0e8f('0x3f')]=qs['sort'](_0x29f6be[_0x0e8f('0x39')][_0x0e8f('0x40')]);_0x1a2f39[_0x0e8f('0x41')]=qs[_0x0e8f('0x3a')](_[_0x0e8f('0x42')](_0x29f6be[_0x0e8f('0x39')],_0x39d874[_0x0e8f('0x3a')]));if(_0x29f6be[_0x0e8f('0x39')][_0x0e8f('0x45')]){_0x1a2f39[_0x0e8f('0x41')]=_['merge'](_0x1a2f39[_0x0e8f('0x41')],{'$or':_[_0x0e8f('0x34')](_0x1a2f39[_0x0e8f('0x3b')],function(_0x1e21dd){var _0x2fb55d={};_0x2fb55d[_0x1e21dd]={'$like':'%'+_0x29f6be[_0x0e8f('0x39')]['filter']+'%'};return _0x2fb55d;})});}_0x1a2f39=_[_0x0e8f('0x43')]({},_0x1a2f39,_0x29f6be[_0x0e8f('0x68')]);return _0x163a98[_0x0e8f('0x66')](_0x1a2f39);}})[_0x0e8f('0x2b')](function(_0xb8641c){if(_0xb8641c){_0x5b63aa=_0xb8641c[_0x0e8f('0x4e')];if(!_0x29f6be[_0x0e8f('0x39')][_0x0e8f('0x3d')](_0x0e8f('0x3e'))){_0x1a2f39[_0x0e8f('0x24')]=qs[_0x0e8f('0x24')](_0x29f6be[_0x0e8f('0x39')]['limit']);_0x1a2f39[_0x0e8f('0x22')]=qs[_0x0e8f('0x22')](_0x29f6be[_0x0e8f('0x39')][_0x0e8f('0x22')]);}return _0x163a98[_0x0e8f('0x66')](_0x1a2f39);}})['then'](function(_0x5053ce){if(_0x5053ce){return _0x5053ce?{'count':_0x5b63aa,'rows':_0x5053ce}:null;}})[_0x0e8f('0x2b')](respondWithResult(_0x256041,null))[_0x0e8f('0x49')](handleError(_0x256041,null));};exports[_0x0e8f('0x69')]=function(_0x4c4356,_0x265f49,_0x2a1158){var _0x1e1641=_0x4c4356[_0x0e8f('0x50')][_0x0e8f('0x6a')];return db[_0x0e8f('0x67')][_0x0e8f('0x47')]({'where':{'id':_0x1e1641},'attributes':['id'],'include':[{'model':db[_0x0e8f('0x5d')],'as':_0x0e8f('0x6b'),'attributes':['id',_0x0e8f('0x31'),'online','voicePause',_0x0e8f('0x6c')],'raw':!![]}]})['then'](function(_0x3b01e2){if(_0x3b01e2){var _0x3ecc70=_[_0x0e8f('0x6d')](_0x3b01e2,function(_0x2fccd9){var _0x140d87=_0x2fccd9[_0x0e8f('0x2c')]({'plain':!![]});return _0x140d87[_0x0e8f('0x6b')];});return db['OpenchannelQueue'][_0x0e8f('0x57')]({'where':{'id':_0x4c4356['params']['id']}})[_0x0e8f('0x2b')](function(_0x2786c8){return db[_0x0e8f('0x6e')]['transaction'](function(_0x3e86dc){return _0x2786c8[_0x0e8f('0x69')](_0x1e1641,{'transaction':_0x3e86dc})[_0x0e8f('0x2b')](function(){return BPromise[_0x0e8f('0x6f')](_0x3ecc70,function(_0x529efb){return db['UserOpenchannelQueue'][_0x0e8f('0x70')]({'where':{'UserId':_0x529efb['id'],'OpenchannelQueueId':_0x4c4356[_0x0e8f('0x4b')]['id']},'transaction':_0x3e86dc});});})[_0x0e8f('0x2b')](function(){_0x3ecc70[_0x0e8f('0x71')](function(_0xa58573){socket[_0x0e8f('0x72')](_0x0e8f('0x73'),{'UserId':_0xa58573['id'],'OpenchannelQueueId':_0x2786c8['id']});});});});});}})[_0x0e8f('0x2b')](respondWithStatusCode(_0x265f49,null))['catch'](handleError(_0x265f49,null));};exports[_0x0e8f('0x74')]=function(_0x4a0e4c,_0x3a2443,_0x130deb){return db[_0x0e8f('0x67')][_0x0e8f('0x47')]({'where':{'id':_0x4a0e4c[_0x0e8f('0x39')][_0x0e8f('0x6a')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x0e8f('0x6b'),'attributes':['id'],'raw':!![]}]})[_0x0e8f('0x2b')](handleEntityNotFound(_0x3a2443,null))[_0x0e8f('0x2b')](function(_0x3c6d24){var _0x56f7c5=_['map'](_0x3c6d24,'id');var _0x23d3d4=[];var _0x542253=[];var _0x187efd=squel[_0x0e8f('0x75')]();_0x187efd[_0x0e8f('0x76')](_0x0e8f('0x77'))['from'](_0x0e8f('0x78'),'tq')[_0x0e8f('0x79')](_0x0e8f('0x7a'),'ut',_0x0e8f('0x7b'))['where'](_0x0e8f('0x7c'),_0x4a0e4c[_0x0e8f('0x4b')]['id']);for(var _0x3b9615=0x0;_0x3b9615<_0x3c6d24[_0x0e8f('0x4e')];_0x3b9615+=0x1){let _0x3c2ed4=_0x3c6d24[_0x3b9615];for(var _0x430493=0x0;_0x430493<_0x3c2ed4['Agents'][_0x0e8f('0x4e')];_0x430493+=0x1){let _0x1b8be8=_0x3c2ed4[_0x0e8f('0x6b')][_0x430493];var _0x4ae595=_0x187efd[_0x0e8f('0x7d')]();_0x4ae595[_0x0e8f('0x41')](_0x0e8f('0x7e'),_0x1b8be8['id']);_0x542253[_0x0e8f('0x7f')](db['sequelize'][_0x0e8f('0x39')](_0x4ae595['toString'](),{'type':db[_0x0e8f('0x6e')][_0x0e8f('0x80')][_0x0e8f('0x81')]})[_0x0e8f('0x2b')](function(_0x58e4d6){if(_0x58e4d6[_0x0e8f('0x4e')]===0x1){return _0x1b8be8['id'];}else{var _0x586240=_[_0x0e8f('0x82')](_[_0x0e8f('0x34')](_0x58e4d6,_0x0e8f('0x83')),function(_0x4142e8){return _[_0x0e8f('0x84')](_0x56f7c5,_0x4142e8);});if(_0x586240){return _0x1b8be8['id'];}}}));}}return BPromise[_0x0e8f('0x85')](_0x542253)[_0x0e8f('0x2b')](function(_0x2f896a){_0x23d3d4=_(_0x23d3d4)['union'](_0x2f896a)['compact']()[_0x0e8f('0x86')]();return db[_0x0e8f('0x35')][_0x0e8f('0x57')]({'where':{'id':_0x4a0e4c[_0x0e8f('0x4b')]['id']}})[_0x0e8f('0x2b')](function(_0x4c34e7){return db[_0x0e8f('0x6e')]['transaction'](function(_0xdb2a8b){return _0x4c34e7[_0x0e8f('0x74')](_0x4a0e4c[_0x0e8f('0x39')][_0x0e8f('0x6a')],{'transaction':_0xdb2a8b})[_0x0e8f('0x2b')](function(){if(!_[_0x0e8f('0x87')](_0x23d3d4)){return _0x4c34e7[_0x0e8f('0x88')](_0x23d3d4,{'transaction':_0xdb2a8b});}})[_0x0e8f('0x2b')](function(){_0x23d3d4[_0x0e8f('0x71')](function(_0x500991){socket[_0x0e8f('0x72')]('userOpenchannelQueue:remove',{'UserId':_0x500991,'OpenchannelQueueId':_0x4c34e7['id']});});});});});});})['then'](respondWithStatusCode(_0x3a2443,null))[_0x0e8f('0x49')](handleError(_0x3a2443,null));};exports[_0x0e8f('0x89')]=function(_0x530e83,_0x14c9a8,_0x1fafcc){return db[_0x0e8f('0x35')]['find']({'where':{'id':_0x530e83['params']['id']}})[_0x0e8f('0x2b')](handleEntityNotFound(_0x14c9a8,null))['then'](function(_0x3f2e4a){if(_0x3f2e4a){return _0x3f2e4a[_0x0e8f('0x89')](_0x530e83[_0x0e8f('0x50')][_0x0e8f('0x6a')],_[_0x0e8f('0x8a')](_0x530e83['body'],[_0x0e8f('0x6a'),'id'])||{})[_0x0e8f('0x8b')](function(_0x3ffa09){for(var _0x46e88f=0x0;_0x46e88f<_0x530e83[_0x0e8f('0x50')][_0x0e8f('0x6a')][_0x0e8f('0x4e')];_0x46e88f+=0x1){socket['emit'](_0x0e8f('0x73'),{'UserId':Number(_0x530e83[_0x0e8f('0x50')][_0x0e8f('0x6a')][_0x46e88f]),'OpenchannelQueueId':Number(_0x530e83[_0x0e8f('0x4b')]['id'])});}return _0x3ffa09;});}})[_0x0e8f('0x2b')](respondWithResult(_0x14c9a8,null))['catch'](handleError(_0x14c9a8,null));};exports['removeAgents']=function(_0x50f627,_0x2427f1,_0x3b077e){return db[_0x0e8f('0x35')][_0x0e8f('0x57')]({'where':{'id':_0x50f627[_0x0e8f('0x4b')]['id']}})[_0x0e8f('0x2b')](handleEntityNotFound(_0x2427f1,null))[_0x0e8f('0x2b')](function(_0x434b8b){if(_0x434b8b){return _0x434b8b['removeAgents'](_0x50f627['query'][_0x0e8f('0x6a')])[_0x0e8f('0x2b')](function(){if(_[_0x0e8f('0x8c')](_0x50f627['query'][_0x0e8f('0x6a')])){for(var _0x5a7c68=0x0;_0x5a7c68<_0x50f627[_0x0e8f('0x39')][_0x0e8f('0x6a')]['length'];_0x5a7c68+=0x1){socket['emit'](_0x0e8f('0x8d'),{'UserId':Number(_0x50f627[_0x0e8f('0x39')][_0x0e8f('0x6a')][_0x5a7c68]),'OpenchannelQueueId':Number(_0x50f627[_0x0e8f('0x4b')]['id'])});}}else{socket[_0x0e8f('0x72')](_0x0e8f('0x8d'),{'UserId':Number(_0x50f627[_0x0e8f('0x39')]['ids']),'OpenchannelQueueId':Number(_0x50f627[_0x0e8f('0x4b')]['id'])});}});}})[_0x0e8f('0x2b')](respondWithStatusCode(_0x2427f1,null))['catch'](handleError(_0x2427f1,null));};exports[_0x0e8f('0x8e')]=function(_0x349a43,_0x310440,_0x4a3dad){var _0x118053={};var _0x1e8cad={};var _0x35dd92;var _0x4b1972;return db[_0x0e8f('0x35')][_0x0e8f('0x5a')]({'where':{'id':_0x349a43['params']['id']}})[_0x0e8f('0x2b')](handleEntityNotFound(_0x310440,null))[_0x0e8f('0x2b')](function(_0x16c05d){if(_0x16c05d){_0x35dd92=_0x16c05d;_0x1e8cad[_0x0e8f('0x38')]=_['keys'](db[_0x0e8f('0x5d')][_0x0e8f('0x36')]);_0x1e8cad['query']=_[_0x0e8f('0x4c')](_0x349a43[_0x0e8f('0x39')]);_0x1e8cad[_0x0e8f('0x3a')]=_[_0x0e8f('0x4d')](_0x1e8cad[_0x0e8f('0x38')],_0x1e8cad[_0x0e8f('0x39')]);_0x118053['attributes']=_[_0x0e8f('0x4d')](_0x1e8cad['model'],qs[_0x0e8f('0x3c')](_0x349a43[_0x0e8f('0x39')][_0x0e8f('0x3c')]));_0x118053['attributes']=_0x118053[_0x0e8f('0x3b')][_0x0e8f('0x4e')]?_0x118053['attributes']:_0x1e8cad[_0x0e8f('0x38')];_0x118053[_0x0e8f('0x3f')]=qs['sort'](_0x349a43[_0x0e8f('0x39')]['sort']);_0x118053[_0x0e8f('0x41')]=qs[_0x0e8f('0x3a')](_[_0x0e8f('0x42')](_0x349a43['query'],_0x1e8cad[_0x0e8f('0x3a')]));if(_0x349a43[_0x0e8f('0x39')][_0x0e8f('0x45')]){_0x118053[_0x0e8f('0x41')]=_[_0x0e8f('0x43')](_0x118053[_0x0e8f('0x41')],{'$or':_['map'](_0x118053[_0x0e8f('0x3b')],function(_0x4986aa){var _0x11bd9c={};_0x11bd9c[_0x4986aa]={'$like':'%'+_0x349a43['query'][_0x0e8f('0x45')]+'%'};return _0x11bd9c;})});}_0x118053=_[_0x0e8f('0x43')]({},_0x118053,_0x349a43['options']);return _0x35dd92[_0x0e8f('0x8e')](_0x118053);}})[_0x0e8f('0x2b')](function(_0x3309fd){if(_0x3309fd){_0x4b1972=_0x3309fd[_0x0e8f('0x4e')];if(!_0x349a43[_0x0e8f('0x39')][_0x0e8f('0x3d')]('nolimit')){_0x118053[_0x0e8f('0x24')]=qs['limit'](_0x349a43['query'][_0x0e8f('0x24')]);_0x118053['offset']=qs[_0x0e8f('0x22')](_0x349a43[_0x0e8f('0x39')][_0x0e8f('0x22')]);}return _0x35dd92['getAgents'](_0x118053);}})['then'](function(_0x47b01e){if(_0x47b01e){return _0x47b01e?{'count':_0x4b1972,'rows':_0x47b01e}:null;}})[_0x0e8f('0x2b')](respondWithResult(_0x310440,null))[_0x0e8f('0x49')](handleError(_0x310440,null));};
\ No newline at end of file