Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index b9620db..8d5125b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7f3f=['bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','end','json','offset','undefined','count','limit','status','set','Content-Range','apply','reject','save','update','then','destroy','UserProfileResource','error','stack','name','send','index','map','OpenchannelQueue','fieldName','type','model','query','keys','filters','intersection','fields','attributes','nolimit','order','sort','filter','where','VIRTUAL','merge','options','findAll','rows','catch','show','rawAttributes','length','includeAll','include','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','describe','params','get','hasOwnProperty','OpenchannelQueueId','UserOpenchannelQueue','findAndCountAll','UserId','agent','openchannelPause','createdAt','format','%s/%s','SIP','getTeams','findOne','Team','addTeams','ids','Agents','sequelize','each','findOrCreate','forEach','userOpenchannelQueue:save','removeTeams','User','field','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','includes','all','compact','value','transaction','isEmpty','removeAgents','emit','userOpenchannelQueue:remove','addAgents','spread','isArray','getAgents','pick'];(function(_0x4702ee,_0xaf6a45){var _0x62ca7d=function(_0x5b3af7){while(--_0x5b3af7){_0x4702ee['push'](_0x4702ee['shift']());}};_0x62ca7d(++_0xaf6a45);}(_0x7f3f,0x86));var _0xf7f3=function(_0x4f8f3b,_0x43281b){_0x4f8f3b=_0x4f8f3b-0x0;var _0x4c250c=_0x7f3f[_0x4f8f3b];return _0x4c250c;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf7f3('0x0'));var Mustache=require(_0xf7f3('0x1'));var util=require('util');var path=require(_0xf7f3('0x2'));var sox=require(_0xf7f3('0x3'));var csv=require(_0xf7f3('0x4'));var ejs=require(_0xf7f3('0x5'));var fs=require('fs');var fs_extra=require(_0xf7f3('0x6'));var _=require(_0xf7f3('0x7'));var squel=require('squel');var crypto=require(_0xf7f3('0x8'));var jsforce=require(_0xf7f3('0x9'));var deskjs=require('desk.js');var toCsv=require(_0xf7f3('0x4'));var querystring=require(_0xf7f3('0xa'));var Papa=require(_0xf7f3('0xb'));var Redis=require(_0xf7f3('0xc'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xf7f3('0xd'));var hardwareService=require(_0xf7f3('0xe'));var logger=require(_0xf7f3('0xf'))('api');var utils=require(_0xf7f3('0x10'));var config=require(_0xf7f3('0x11'));var licenseUtil=require('../../config/license/util');var db=require(_0xf7f3('0x12'))['db'];config[_0xf7f3('0x13')]=_[_0xf7f3('0x14')](config[_0xf7f3('0x13')],{'host':_0xf7f3('0x15'),'port':0x18eb});var socket=require(_0xf7f3('0x16'))(new Redis(config['redis']));require('./openchannelQueue.socket')[_0xf7f3('0x17')](socket);function respondWithStatusCode(_0x1dadb9,_0x4fc752){_0x4fc752=_0x4fc752||0xcc;return function(_0x567a86){if(_0x567a86){return _0x1dadb9[_0xf7f3('0x18')](_0x4fc752);}return _0x1dadb9['status'](_0x4fc752)[_0xf7f3('0x19')]();};}function respondWithResult(_0x1c1c3e,_0x4ff844){_0x4ff844=_0x4ff844||0xc8;return function(_0x9ae23f){if(_0x9ae23f){return _0x1c1c3e['status'](_0x4ff844)[_0xf7f3('0x1a')](_0x9ae23f);}};}function respondWithFilteredResult(_0x47a3c8,_0x2e4c5a){return function(_0x117d6f){if(_0x117d6f){var _0x3a5dd7=typeof _0x2e4c5a[_0xf7f3('0x1b')]===_0xf7f3('0x1c')&&typeof _0x2e4c5a['limit']===_0xf7f3('0x1c');var _0x104c38=_0x117d6f[_0xf7f3('0x1d')];var _0x3416c0=_0x3a5dd7?0x0:_0x2e4c5a[_0xf7f3('0x1b')];var _0x4bc744=_0x3a5dd7?_0x117d6f[_0xf7f3('0x1d')]:_0x2e4c5a[_0xf7f3('0x1b')]+_0x2e4c5a[_0xf7f3('0x1e')];var _0x38f598;if(_0x4bc744>=_0x104c38){_0x4bc744=_0x104c38;_0x38f598=0xc8;}else{_0x38f598=0xce;}_0x47a3c8[_0xf7f3('0x1f')](_0x38f598);return _0x47a3c8[_0xf7f3('0x20')](_0xf7f3('0x21'),_0x3416c0+'-'+_0x4bc744+'/'+_0x104c38)['json'](_0x117d6f);}return null;};}function patchUpdates(_0xaa51b8){return function(_0x38f594){try{jsonpatch[_0xf7f3('0x22')](_0x38f594,_0xaa51b8,!![]);}catch(_0x34c825){return BPromise[_0xf7f3('0x23')](_0x34c825);}return _0x38f594[_0xf7f3('0x24')]();};}function saveUpdates(_0x317c0b,_0x84d23){return function(_0x42d9d8){if(_0x42d9d8){return _0x42d9d8[_0xf7f3('0x25')](_0x317c0b)[_0xf7f3('0x26')](function(_0x4294df){return _0x4294df;});}return null;};}function removeEntity(_0x5e11a0,_0x3a0f7e){return function(_0x26aefc){if(_0x26aefc){return _0x26aefc[_0xf7f3('0x27')]()[_0xf7f3('0x26')](function(){var _0x1db927=_0x26aefc['get']({'plain':!![]});var _0x4595e2='OpenchannelQueues';return db[_0xf7f3('0x28')][_0xf7f3('0x27')]({'where':{'type':_0x4595e2,'resourceId':_0x1db927['id']}})[_0xf7f3('0x26')](function(){return _0x26aefc;});})[_0xf7f3('0x26')](function(){_0x5e11a0[_0xf7f3('0x1f')](0xcc)[_0xf7f3('0x19')]();});}};}function handleEntityNotFound(_0x26d7d7,_0xb185b8){return function(_0x3ba11a){if(!_0x3ba11a){_0x26d7d7[_0xf7f3('0x18')](0x194);}return _0x3ba11a;};}function handleError(_0x7eef9d,_0x31abae){_0x31abae=_0x31abae||0x1f4;return function(_0x2a0e86){logger[_0xf7f3('0x29')](_0x2a0e86[_0xf7f3('0x2a')]);if(_0x2a0e86['name']){delete _0x2a0e86[_0xf7f3('0x2b')];}_0x7eef9d[_0xf7f3('0x1f')](_0x31abae)[_0xf7f3('0x2c')](_0x2a0e86);};}exports[_0xf7f3('0x2d')]=function(_0x1370ef,_0x3682f0){var _0x2a90e9={},_0xb6f15c={},_0x32279a={'count':0x0,'rows':[]};var _0x3285d7=_[_0xf7f3('0x2e')](db[_0xf7f3('0x2f')]['rawAttributes'],function(_0x5deb6d){return{'name':_0x5deb6d[_0xf7f3('0x30')],'type':_0x5deb6d[_0xf7f3('0x31')]['key']};});_0xb6f15c[_0xf7f3('0x32')]=_[_0xf7f3('0x2e')](_0x3285d7,_0xf7f3('0x2b'));_0xb6f15c[_0xf7f3('0x33')]=_[_0xf7f3('0x34')](_0x1370ef[_0xf7f3('0x33')]);_0xb6f15c[_0xf7f3('0x35')]=_[_0xf7f3('0x36')](_0xb6f15c[_0xf7f3('0x32')],_0xb6f15c['query']);_0x2a90e9['attributes']=_['intersection'](_0xb6f15c['model'],qs['fields'](_0x1370ef[_0xf7f3('0x33')][_0xf7f3('0x37')]));_0x2a90e9[_0xf7f3('0x38')]=_0x2a90e9[_0xf7f3('0x38')]['length']?_0x2a90e9['attributes']:_0xb6f15c['model'];if(!_0x1370ef[_0xf7f3('0x33')]['hasOwnProperty'](_0xf7f3('0x39'))){_0x2a90e9[_0xf7f3('0x1e')]=qs['limit'](_0x1370ef['query'][_0xf7f3('0x1e')]);_0x2a90e9[_0xf7f3('0x1b')]=qs['offset'](_0x1370ef[_0xf7f3('0x33')][_0xf7f3('0x1b')]);}_0x2a90e9[_0xf7f3('0x3a')]=qs[_0xf7f3('0x3b')](_0x1370ef[_0xf7f3('0x33')]['sort']);_0x2a90e9['where']=qs[_0xf7f3('0x35')](_['pick'](_0x1370ef[_0xf7f3('0x33')],_0xb6f15c[_0xf7f3('0x35')]),_0x3285d7);if(_0x1370ef[_0xf7f3('0x33')][_0xf7f3('0x3c')]){_0x2a90e9[_0xf7f3('0x3d')]=_['merge'](_0x2a90e9[_0xf7f3('0x3d')],{'$or':_[_0xf7f3('0x2e')](_0x3285d7,function(_0x546da1){if(_0x546da1[_0xf7f3('0x31')]!==_0xf7f3('0x3e')){var _0x1ee97a={};_0x1ee97a[_0x546da1['name']]={'$like':'%'+_0x1370ef[_0xf7f3('0x33')]['filter']+'%'};return _0x1ee97a;}})});}_0x2a90e9=_[_0xf7f3('0x3f')]({},_0x2a90e9,_0x1370ef[_0xf7f3('0x40')]);var _0x1fef06={'where':_0x2a90e9[_0xf7f3('0x3d')]};return db[_0xf7f3('0x2f')][_0xf7f3('0x1d')](_0x1fef06)['then'](function(_0x5357e2){_0x32279a[_0xf7f3('0x1d')]=_0x5357e2;if(_0x1370ef[_0xf7f3('0x33')]['includeAll']){_0x2a90e9['include']=[{'all':!![]}];}return db[_0xf7f3('0x2f')][_0xf7f3('0x41')](_0x2a90e9);})['then'](function(_0x4ebb14){_0x32279a[_0xf7f3('0x42')]=_0x4ebb14;return _0x32279a;})[_0xf7f3('0x26')](respondWithFilteredResult(_0x3682f0,_0x2a90e9))[_0xf7f3('0x43')](handleError(_0x3682f0,null));};exports[_0xf7f3('0x44')]=function(_0x108017,_0x5c8054){var _0x2465e9={'raw':!![],'where':{'id':_0x108017['params']['id']}},_0x1b74da={};_0x1b74da[_0xf7f3('0x32')]=_[_0xf7f3('0x34')](db[_0xf7f3('0x2f')][_0xf7f3('0x45')]);_0x1b74da[_0xf7f3('0x33')]=_[_0xf7f3('0x34')](_0x108017[_0xf7f3('0x33')]);_0x1b74da[_0xf7f3('0x35')]=_[_0xf7f3('0x36')](_0x1b74da['model'],_0x1b74da[_0xf7f3('0x33')]);_0x2465e9[_0xf7f3('0x38')]=_[_0xf7f3('0x36')](_0x1b74da[_0xf7f3('0x32')],qs['fields'](_0x108017[_0xf7f3('0x33')][_0xf7f3('0x37')]));_0x2465e9[_0xf7f3('0x38')]=_0x2465e9[_0xf7f3('0x38')][_0xf7f3('0x46')]?_0x2465e9[_0xf7f3('0x38')]:_0x1b74da[_0xf7f3('0x32')];if(_0x108017[_0xf7f3('0x33')][_0xf7f3('0x47')]){_0x2465e9[_0xf7f3('0x48')]=[{'all':!![]}];}_0x2465e9=_[_0xf7f3('0x3f')]({},_0x2465e9,_0x108017['options']);return db['OpenchannelQueue'][_0xf7f3('0x49')](_0x2465e9)[_0xf7f3('0x26')](handleEntityNotFound(_0x5c8054,null))[_0xf7f3('0x26')](respondWithResult(_0x5c8054,null))[_0xf7f3('0x43')](handleError(_0x5c8054,null));};exports[_0xf7f3('0x4a')]=function(_0x2170e7,_0x3b8c58){return db['OpenchannelQueue']['create'](_0x2170e7[_0xf7f3('0x4b')],{})[_0xf7f3('0x26')](function(_0x57560e){var _0x2e05c6=_0x2170e7[_0xf7f3('0x4c')]['get']({'plain':!![]});if(!_0x2e05c6)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2e05c6[_0xf7f3('0x4d')]==='user'){var _0x32ec27=_0x57560e['get']({'plain':!![]});var _0xd823d7='OpenchannelQueues';return db[_0xf7f3('0x4e')][_0xf7f3('0x49')]({'where':{'name':_0xd823d7,'userProfileId':_0x2e05c6[_0xf7f3('0x4f')]},'raw':!![]})['then'](function(_0x4a63f5){if(_0x4a63f5&&_0x4a63f5[_0xf7f3('0x50')]===0x0){return db['UserProfileResource']['create']({'name':_0x32ec27[_0xf7f3('0x2b')],'resourceId':_0x32ec27['id'],'type':_0x4a63f5[_0xf7f3('0x2b')],'sectionId':_0x4a63f5['id']},{})[_0xf7f3('0x26')](function(){return _0x57560e;});}else{return _0x57560e;}})[_0xf7f3('0x43')](function(_0x592b22){logger[_0xf7f3('0x29')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x592b22);throw _0x592b22;});}return _0x57560e;})[_0xf7f3('0x26')](respondWithResult(_0x3b8c58,0xc9))['catch'](handleError(_0x3b8c58,null));};exports['update']=function(_0x3644ad,_0x10c6ed){if(_0x3644ad[_0xf7f3('0x4b')]['id']){delete _0x3644ad[_0xf7f3('0x4b')]['id'];}return db[_0xf7f3('0x2f')][_0xf7f3('0x49')]({'where':{'id':_0x3644ad['params']['id']}})[_0xf7f3('0x26')](handleEntityNotFound(_0x10c6ed,null))['then'](saveUpdates(_0x3644ad['body'],null))[_0xf7f3('0x26')](respondWithResult(_0x10c6ed,null))[_0xf7f3('0x43')](handleError(_0x10c6ed,null));};exports[_0xf7f3('0x27')]=function(_0x50f391,_0x1bad8e){return db[_0xf7f3('0x2f')]['find']({'where':{'id':_0x50f391['params']['id']}})[_0xf7f3('0x26')](handleEntityNotFound(_0x1bad8e,null))[_0xf7f3('0x26')](removeEntity(_0x1bad8e,null))[_0xf7f3('0x43')](handleError(_0x1bad8e,null));};exports['describe']=function(_0x459096,_0x4cfecf){return db['OpenchannelQueue'][_0xf7f3('0x51')]()[_0xf7f3('0x26')](respondWithResult(_0x4cfecf,null))[_0xf7f3('0x43')](handleError(_0x4cfecf,null));};exports['getMembers']=function(_0x5a879c,_0x3b7978,_0x2c1c61){var _0x10836c={'raw':!![],'where':{}},_0xf3d6d4={},_0x674b9;return db[_0xf7f3('0x2f')]['findOne']({'where':{'id':_0x5a879c[_0xf7f3('0x52')]['id']}})[_0xf7f3('0x26')](handleEntityNotFound(_0x3b7978,null))[_0xf7f3('0x26')](function(_0x12020e){if(_0x12020e){_0x674b9=_0x12020e[_0xf7f3('0x53')]({'plain':!![]});_0xf3d6d4[_0xf7f3('0x32')]=_['keys'](db['UserOpenchannelQueue'][_0xf7f3('0x45')]);_0xf3d6d4[_0xf7f3('0x33')]=_[_0xf7f3('0x34')](_0x5a879c['query']);_0xf3d6d4['filters']=_[_0xf7f3('0x36')](_0xf3d6d4[_0xf7f3('0x32')],_0xf3d6d4[_0xf7f3('0x33')]);_0x10836c[_0xf7f3('0x38')]=_['intersection'](_0xf3d6d4[_0xf7f3('0x32')],qs[_0xf7f3('0x37')](_0x5a879c[_0xf7f3('0x33')]['fields']));_0x10836c[_0xf7f3('0x38')]=_0x10836c[_0xf7f3('0x38')][_0xf7f3('0x46')]?_0x10836c[_0xf7f3('0x38')]:_0xf3d6d4[_0xf7f3('0x32')];if(!_0x5a879c[_0xf7f3('0x33')][_0xf7f3('0x54')]('nolimit')){_0x10836c[_0xf7f3('0x1e')]=qs['limit'](_0x5a879c[_0xf7f3('0x33')][_0xf7f3('0x1e')]);_0x10836c['offset']=qs[_0xf7f3('0x1b')](_0x5a879c[_0xf7f3('0x33')][_0xf7f3('0x1b')]);}_0x10836c[_0xf7f3('0x3a')]=qs['sort'](_0x5a879c[_0xf7f3('0x33')][_0xf7f3('0x3b')]);_0x10836c['where']=qs['filters'](_['pick'](_0x5a879c['query'],_0xf3d6d4[_0xf7f3('0x35')]));_0x10836c[_0xf7f3('0x3d')][_0xf7f3('0x55')]=_0x12020e['id'];if(_0x5a879c[_0xf7f3('0x33')][_0xf7f3('0x3c')]){_0x10836c[_0xf7f3('0x3d')]=_[_0xf7f3('0x3f')](_0x10836c[_0xf7f3('0x3d')],{'$or':_[_0xf7f3('0x2e')](_0x10836c[_0xf7f3('0x38')],function(_0x573af3){var _0x1d1466={};_0x1d1466[_0x573af3]={'$like':'%'+_0x5a879c[_0xf7f3('0x33')][_0xf7f3('0x3c')]+'%'};return _0x1d1466;})});}_0x10836c=_['merge']({},_0x10836c,_0x5a879c[_0xf7f3('0x40')]);return db[_0xf7f3('0x56')][_0xf7f3('0x41')](_0x10836c);}})['then'](function(_0x30ad84){if(_0x30ad84){return db['User'][_0xf7f3('0x57')]({'where':{'id':_[_0xf7f3('0x2e')](_0x30ad84,_0xf7f3('0x58')),'role':_0xf7f3('0x59')},'attributes':['id','name',_0xf7f3('0x5a'),'updatedAt',_0xf7f3('0x5b')]});}})[_0xf7f3('0x26')](function(_0x5df963){if(_0x5df963){return{'count':_0x5df963[_0xf7f3('0x1d')],'rows':_[_0xf7f3('0x2e')](_0x5df963[_0xf7f3('0x42')],function(_0x1e89ad){return{'membername':_0x1e89ad['name'],'UserId':_0x1e89ad['id'],'queue_name':_0x674b9[_0xf7f3('0x2b')],'OpenchannelQueueId':_0x674b9['id'],'interface':util[_0xf7f3('0x5c')](_0xf7f3('0x5d'),_0xf7f3('0x5e'),_0x1e89ad[_0xf7f3('0x2b')]),'penalty':0x0,'paused':_0x1e89ad[_0xf7f3('0x5a')],'createdAt':_0x1e89ad[_0xf7f3('0x5b')],'updatedAt':_0x1e89ad['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xf7f3('0x26')](respondWithFilteredResult(_0x3b7978,_0x10836c))['catch'](handleError(_0x3b7978,null));};exports[_0xf7f3('0x5f')]=function(_0x23a5d5,_0x1b78f8,_0x25c346){var _0x5b5791={};var _0x2453c3={};var _0x18368d;var _0x186c07;return db['OpenchannelQueue'][_0xf7f3('0x60')]({'where':{'id':_0x23a5d5[_0xf7f3('0x52')]['id']}})[_0xf7f3('0x26')](handleEntityNotFound(_0x1b78f8,null))[_0xf7f3('0x26')](function(_0x3d11c1){if(_0x3d11c1){_0x18368d=_0x3d11c1;_0x2453c3[_0xf7f3('0x32')]=_[_0xf7f3('0x34')](db[_0xf7f3('0x61')][_0xf7f3('0x45')]);_0x2453c3[_0xf7f3('0x33')]=_[_0xf7f3('0x34')](_0x23a5d5[_0xf7f3('0x33')]);_0x2453c3['filters']=_[_0xf7f3('0x36')](_0x2453c3[_0xf7f3('0x32')],_0x2453c3['query']);_0x5b5791[_0xf7f3('0x38')]=_[_0xf7f3('0x36')](_0x2453c3[_0xf7f3('0x32')],qs[_0xf7f3('0x37')](_0x23a5d5[_0xf7f3('0x33')]['fields']));_0x5b5791[_0xf7f3('0x38')]=_0x5b5791[_0xf7f3('0x38')]['length']?_0x5b5791[_0xf7f3('0x38')]:_0x2453c3['model'];_0x5b5791['order']=qs[_0xf7f3('0x3b')](_0x23a5d5['query']['sort']);_0x5b5791[_0xf7f3('0x3d')]=qs['filters'](_['pick'](_0x23a5d5[_0xf7f3('0x33')],_0x2453c3[_0xf7f3('0x35')]));if(_0x23a5d5[_0xf7f3('0x33')]['filter']){_0x5b5791[_0xf7f3('0x3d')]=_[_0xf7f3('0x3f')](_0x5b5791[_0xf7f3('0x3d')],{'$or':_[_0xf7f3('0x2e')](_0x5b5791[_0xf7f3('0x38')],function(_0x1dbde9){var _0x2fdc77={};_0x2fdc77[_0x1dbde9]={'$like':'%'+_0x23a5d5[_0xf7f3('0x33')][_0xf7f3('0x3c')]+'%'};return _0x2fdc77;})});}_0x5b5791=_[_0xf7f3('0x3f')]({},_0x5b5791,_0x23a5d5[_0xf7f3('0x40')]);return _0x18368d[_0xf7f3('0x5f')](_0x5b5791);}})[_0xf7f3('0x26')](function(_0x584aa4){if(_0x584aa4){_0x186c07=_0x584aa4[_0xf7f3('0x46')];if(!_0x23a5d5[_0xf7f3('0x33')][_0xf7f3('0x54')](_0xf7f3('0x39'))){_0x5b5791['limit']=qs['limit'](_0x23a5d5['query'][_0xf7f3('0x1e')]);_0x5b5791[_0xf7f3('0x1b')]=qs[_0xf7f3('0x1b')](_0x23a5d5[_0xf7f3('0x33')]['offset']);}return _0x18368d['getTeams'](_0x5b5791);}})[_0xf7f3('0x26')](function(_0x151cef){if(_0x151cef){return _0x151cef?{'count':_0x186c07,'rows':_0x151cef}:null;}})[_0xf7f3('0x26')](respondWithResult(_0x1b78f8,null))['catch'](handleError(_0x1b78f8,null));};exports[_0xf7f3('0x62')]=function(_0x14b6cb,_0x5815d0,_0x2609bb){var _0x51fd6d=_0x14b6cb[_0xf7f3('0x4b')][_0xf7f3('0x63')];return db[_0xf7f3('0x61')]['findAll']({'where':{'id':_0x51fd6d},'attributes':['id'],'include':[{'model':db['User'],'as':_0xf7f3('0x64'),'attributes':['id',_0xf7f3('0x2b'),'online','voicePause','interface'],'raw':!![]}]})[_0xf7f3('0x26')](function(_0x417ab4){if(_0x417ab4){var _0xb0f521=_['flatMap'](_0x417ab4,function(_0x2e037c){var _0x2f21fd=_0x2e037c[_0xf7f3('0x53')]({'plain':!![]});return _0x2f21fd[_0xf7f3('0x64')];});return db[_0xf7f3('0x2f')]['find']({'where':{'id':_0x14b6cb[_0xf7f3('0x52')]['id']}})[_0xf7f3('0x26')](function(_0x340a4a){return db[_0xf7f3('0x65')]['transaction'](function(_0x195ea3){return _0x340a4a[_0xf7f3('0x62')](_0x51fd6d,{'transaction':_0x195ea3})[_0xf7f3('0x26')](function(){return BPromise[_0xf7f3('0x66')](_0xb0f521,function(_0x515733){return db[_0xf7f3('0x56')][_0xf7f3('0x67')]({'where':{'UserId':_0x515733['id'],'OpenchannelQueueId':_0x14b6cb['params']['id']},'transaction':_0x195ea3});});})[_0xf7f3('0x26')](function(){_0xb0f521[_0xf7f3('0x68')](function(_0x80c2ae){socket['emit'](_0xf7f3('0x69'),{'UserId':_0x80c2ae['id'],'OpenchannelQueueId':_0x340a4a['id']});});});});});}})[_0xf7f3('0x26')](respondWithStatusCode(_0x5815d0,null))[_0xf7f3('0x43')](handleError(_0x5815d0,null));};exports[_0xf7f3('0x6a')]=function(_0x56bbce,_0x9e42a1,_0x5342d9){return db[_0xf7f3('0x61')][_0xf7f3('0x41')]({'where':{'id':_0x56bbce[_0xf7f3('0x33')][_0xf7f3('0x63')]},'attributes':['id'],'include':[{'model':db[_0xf7f3('0x6b')],'as':_0xf7f3('0x64'),'attributes':['id'],'raw':!![]}]})[_0xf7f3('0x26')](handleEntityNotFound(_0x9e42a1,null))[_0xf7f3('0x26')](function(_0x45822){var _0x4b3e6f=_[_0xf7f3('0x2e')](_0x45822,'id');var _0x4b8684=[];var _0xb05289=[];var _0x433aa2=squel['select']();_0x433aa2[_0xf7f3('0x6c')]('tq.TeamId')[_0xf7f3('0x6d')]('team_has_openchannel_queues','tq')[_0xf7f3('0x6e')](_0xf7f3('0x6f'),'ut',_0xf7f3('0x70'))['where'](_0xf7f3('0x71'),_0x56bbce[_0xf7f3('0x52')]['id']);for(var _0x517cf1=0x0;_0x517cf1<_0x45822[_0xf7f3('0x46')];_0x517cf1+=0x1){let _0x3555f2=_0x45822[_0x517cf1];for(var _0x50b763=0x0;_0x50b763<_0x3555f2[_0xf7f3('0x64')][_0xf7f3('0x46')];_0x50b763+=0x1){let _0x5e7673=_0x3555f2[_0xf7f3('0x64')][_0x50b763];var _0x23b2a2=_0x433aa2[_0xf7f3('0x72')]();_0x23b2a2['where'](_0xf7f3('0x73'),_0x5e7673['id']);_0xb05289[_0xf7f3('0x74')](db[_0xf7f3('0x65')][_0xf7f3('0x33')](_0x23b2a2[_0xf7f3('0x75')](),{'type':db[_0xf7f3('0x65')][_0xf7f3('0x76')][_0xf7f3('0x77')]})[_0xf7f3('0x26')](function(_0x24832a){if(_0x24832a['length']===0x1){return _0x5e7673['id'];}else{var _0x57253b=_['every'](_['map'](_0x24832a,'TeamId'),function(_0x54626e){return _[_0xf7f3('0x78')](_0x4b3e6f,_0x54626e);});if(_0x57253b){return _0x5e7673['id'];}}}));}}return BPromise[_0xf7f3('0x79')](_0xb05289)['then'](function(_0x39c498){_0x4b8684=_(_0x4b8684)['union'](_0x39c498)[_0xf7f3('0x7a')]()[_0xf7f3('0x7b')]();return db[_0xf7f3('0x2f')][_0xf7f3('0x49')]({'where':{'id':_0x56bbce[_0xf7f3('0x52')]['id']}})[_0xf7f3('0x26')](function(_0x531f2d){return db[_0xf7f3('0x65')][_0xf7f3('0x7c')](function(_0x536c6f){return _0x531f2d[_0xf7f3('0x6a')](_0x56bbce[_0xf7f3('0x33')][_0xf7f3('0x63')],{'transaction':_0x536c6f})['then'](function(){if(!_[_0xf7f3('0x7d')](_0x4b8684)){return _0x531f2d[_0xf7f3('0x7e')](_0x4b8684,{'transaction':_0x536c6f});}})[_0xf7f3('0x26')](function(){_0x4b8684[_0xf7f3('0x68')](function(_0x49c807){socket[_0xf7f3('0x7f')](_0xf7f3('0x80'),{'UserId':_0x49c807,'OpenchannelQueueId':_0x531f2d['id']});});});});});});})['then'](respondWithStatusCode(_0x9e42a1,null))[_0xf7f3('0x43')](handleError(_0x9e42a1,null));};exports[_0xf7f3('0x81')]=function(_0x400247,_0x55078e,_0x45ea06){return db['OpenchannelQueue'][_0xf7f3('0x49')]({'where':{'id':_0x400247[_0xf7f3('0x52')]['id']}})[_0xf7f3('0x26')](handleEntityNotFound(_0x55078e,null))['then'](function(_0x580b11){if(_0x580b11){return _0x580b11[_0xf7f3('0x81')](_0x400247[_0xf7f3('0x4b')][_0xf7f3('0x63')],_['omit'](_0x400247[_0xf7f3('0x4b')],['ids','id'])||{})[_0xf7f3('0x82')](function(_0x2f8b97){for(var _0x275283=0x0;_0x275283<_0x400247['body']['ids'][_0xf7f3('0x46')];_0x275283+=0x1){socket[_0xf7f3('0x7f')]('userOpenchannelQueue:save',{'UserId':Number(_0x400247['body'][_0xf7f3('0x63')][_0x275283]),'OpenchannelQueueId':Number(_0x400247[_0xf7f3('0x52')]['id'])});}return _0x2f8b97;});}})[_0xf7f3('0x26')](respondWithResult(_0x55078e,null))['catch'](handleError(_0x55078e,null));};exports[_0xf7f3('0x7e')]=function(_0x1af5f0,_0x8d8c5,_0x1a3342){return db[_0xf7f3('0x2f')][_0xf7f3('0x49')]({'where':{'id':_0x1af5f0[_0xf7f3('0x52')]['id']}})['then'](handleEntityNotFound(_0x8d8c5,null))[_0xf7f3('0x26')](function(_0x3f87f7){if(_0x3f87f7){return _0x3f87f7['removeAgents'](_0x1af5f0[_0xf7f3('0x33')]['ids'])[_0xf7f3('0x26')](function(){if(_[_0xf7f3('0x83')](_0x1af5f0[_0xf7f3('0x33')]['ids'])){for(var _0xb1fd97=0x0;_0xb1fd97<_0x1af5f0[_0xf7f3('0x33')]['ids']['length'];_0xb1fd97+=0x1){socket[_0xf7f3('0x7f')]('userOpenchannelQueue:remove',{'UserId':Number(_0x1af5f0['query']['ids'][_0xb1fd97]),'OpenchannelQueueId':Number(_0x1af5f0[_0xf7f3('0x52')]['id'])});}}else{socket[_0xf7f3('0x7f')](_0xf7f3('0x80'),{'UserId':Number(_0x1af5f0['query'][_0xf7f3('0x63')]),'OpenchannelQueueId':Number(_0x1af5f0[_0xf7f3('0x52')]['id'])});}});}})[_0xf7f3('0x26')](respondWithStatusCode(_0x8d8c5,null))[_0xf7f3('0x43')](handleError(_0x8d8c5,null));};exports[_0xf7f3('0x84')]=function(_0x20d517,_0x2328b8,_0x109875){var _0x520718={};var _0x54fa7c={};var _0x22b169;var _0x27c110;return db[_0xf7f3('0x2f')][_0xf7f3('0x60')]({'where':{'id':_0x20d517[_0xf7f3('0x52')]['id']}})[_0xf7f3('0x26')](handleEntityNotFound(_0x2328b8,null))[_0xf7f3('0x26')](function(_0x3e766c){if(_0x3e766c){_0x22b169=_0x3e766c;_0x54fa7c['model']=_['keys'](db[_0xf7f3('0x6b')][_0xf7f3('0x45')]);_0x54fa7c[_0xf7f3('0x33')]=_[_0xf7f3('0x34')](_0x20d517[_0xf7f3('0x33')]);_0x54fa7c['filters']=_[_0xf7f3('0x36')](_0x54fa7c['model'],_0x54fa7c[_0xf7f3('0x33')]);_0x520718[_0xf7f3('0x38')]=_[_0xf7f3('0x36')](_0x54fa7c['model'],qs[_0xf7f3('0x37')](_0x20d517[_0xf7f3('0x33')][_0xf7f3('0x37')]));_0x520718[_0xf7f3('0x38')]=_0x520718[_0xf7f3('0x38')][_0xf7f3('0x46')]?_0x520718[_0xf7f3('0x38')]:_0x54fa7c[_0xf7f3('0x32')];_0x520718['order']=qs[_0xf7f3('0x3b')](_0x20d517[_0xf7f3('0x33')][_0xf7f3('0x3b')]);_0x520718['where']=qs[_0xf7f3('0x35')](_[_0xf7f3('0x85')](_0x20d517[_0xf7f3('0x33')],_0x54fa7c['filters']));if(_0x20d517[_0xf7f3('0x33')][_0xf7f3('0x3c')]){_0x520718['where']=_['merge'](_0x520718[_0xf7f3('0x3d')],{'$or':_['map'](_0x520718[_0xf7f3('0x38')],function(_0x56e6f0){var _0x4119b5={};_0x4119b5[_0x56e6f0]={'$like':'%'+_0x20d517[_0xf7f3('0x33')][_0xf7f3('0x3c')]+'%'};return _0x4119b5;})});}_0x520718=_['merge']({},_0x520718,_0x20d517[_0xf7f3('0x40')]);return _0x22b169['getAgents'](_0x520718);}})[_0xf7f3('0x26')](function(_0x25e7b1){if(_0x25e7b1){_0x27c110=_0x25e7b1[_0xf7f3('0x46')];if(!_0x20d517[_0xf7f3('0x33')]['hasOwnProperty'](_0xf7f3('0x39'))){_0x520718[_0xf7f3('0x1e')]=qs[_0xf7f3('0x1e')](_0x20d517[_0xf7f3('0x33')][_0xf7f3('0x1e')]);_0x520718[_0xf7f3('0x1b')]=qs[_0xf7f3('0x1b')](_0x20d517[_0xf7f3('0x33')][_0xf7f3('0x1b')]);}return _0x22b169[_0xf7f3('0x84')](_0x520718);}})['then'](function(_0x396a9a){if(_0x396a9a){return _0x396a9a?{'count':_0x27c110,'rows':_0x396a9a}:null;}})['then'](respondWithResult(_0x2328b8,null))[_0xf7f3('0x43')](handleError(_0x2328b8,null));};
\ No newline at end of file
+var _0x480b=['../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./openchannelQueue.socket','register','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','get','OpenchannelQueues','UserProfileResource','then','error','name','send','index','OpenchannelQueue','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','nolimit','order','sort','pick','merge','options','includeAll','include','findAll','rows','catch','show','rawAttributes','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','params','describe','UserOpenchannelQueue','length','hasOwnProperty','where','OpenchannelQueueId','filter','User','findAndCountAll','map','openchannelPause','updatedAt','createdAt','%s/%s','SIP','findOne','Team','getTeams','addTeams','Agents','online','voicePause','interface','flatMap','sequelize','findOrCreate','emit','userOpenchannelQueue:save','removeTeams','ids','select','field','tq.TeamId','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','all','union','compact','value','transaction','removeAgents','userOpenchannelQueue:remove','addAgents','omit','spread','isArray','getAgents','zip-dir','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x5706e0,_0xbb3fb7){var _0x48a81f=function(_0x300b0d){while(--_0x300b0d){_0x5706e0['push'](_0x5706e0['shift']());}};_0x48a81f(++_0xbb3fb7);}(_0x480b,0x100));var _0xb480=function(_0x58b630,_0x421e40){_0x58b630=_0x58b630-0x0;var _0x21cb95=_0x480b[_0x58b630];return _0x21cb95;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xb480('0x0'));var jsonpatch=require(_0xb480('0x1'));var rp=require(_0xb480('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xb480('0x3'));var util=require(_0xb480('0x4'));var path=require(_0xb480('0x5'));var sox=require(_0xb480('0x6'));var csv=require(_0xb480('0x7'));var ejs=require(_0xb480('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xb480('0x9'));var squel=require(_0xb480('0xa'));var crypto=require(_0xb480('0xb'));var jsforce=require(_0xb480('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xb480('0x7'));var querystring=require(_0xb480('0xd'));var Papa=require(_0xb480('0xe'));var Redis=require('ioredis');var authService=require(_0xb480('0xf'));var qs=require(_0xb480('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb480('0x11'));var logger=require(_0xb480('0x12'))(_0xb480('0x13'));var utils=require(_0xb480('0x14'));var config=require(_0xb480('0x15'));var licenseUtil=require(_0xb480('0x16'));var db=require(_0xb480('0x17'))['db'];config['redis']=_[_0xb480('0x18')](config[_0xb480('0x19')],{'host':_0xb480('0x1a'),'port':0x18eb});var socket=require(_0xb480('0x1b'))(new Redis(config['redis']));require(_0xb480('0x1c'))[_0xb480('0x1d')](socket);function respondWithStatusCode(_0x389436,_0x23ea4c){_0x23ea4c=_0x23ea4c||0xcc;return function(_0x1a3fa0){if(_0x1a3fa0){return _0x389436['sendStatus'](_0x23ea4c);}return _0x389436['status'](_0x23ea4c)[_0xb480('0x1e')]();};}function respondWithResult(_0x4f6235,_0x3b6d97){_0x3b6d97=_0x3b6d97||0xc8;return function(_0x5b1215){if(_0x5b1215){return _0x4f6235[_0xb480('0x1f')](_0x3b6d97)[_0xb480('0x20')](_0x5b1215);}};}function respondWithFilteredResult(_0x5dbc5d,_0x368b1c){return function(_0x333769){if(_0x333769){var _0x379711=typeof _0x368b1c[_0xb480('0x21')]===_0xb480('0x22')&&typeof _0x368b1c[_0xb480('0x23')]==='undefined';var _0x11cbde=_0x333769['count'];var _0x3c38f0=_0x379711?0x0:_0x368b1c[_0xb480('0x21')];var _0x16587c=_0x379711?_0x333769[_0xb480('0x24')]:_0x368b1c[_0xb480('0x21')]+_0x368b1c[_0xb480('0x23')];var _0x5c35a3;if(_0x16587c>=_0x11cbde){_0x16587c=_0x11cbde;_0x5c35a3=0xc8;}else{_0x5c35a3=0xce;}_0x5dbc5d[_0xb480('0x1f')](_0x5c35a3);return _0x5dbc5d[_0xb480('0x25')](_0xb480('0x26'),_0x3c38f0+'-'+_0x16587c+'/'+_0x11cbde)[_0xb480('0x20')](_0x333769);}return null;};}function patchUpdates(_0x31bfa8){return function(_0x48f8ac){try{jsonpatch[_0xb480('0x27')](_0x48f8ac,_0x31bfa8,!![]);}catch(_0x4916cb){return BPromise[_0xb480('0x28')](_0x4916cb);}return _0x48f8ac[_0xb480('0x29')]();};}function saveUpdates(_0xed1db3,_0x45d476){return function(_0x2c702b){if(_0x2c702b){return _0x2c702b[_0xb480('0x2a')](_0xed1db3)['then'](function(_0x36c5e8){return _0x36c5e8;});}return null;};}function removeEntity(_0x35db51,_0x379c8a){return function(_0x33a784){if(_0x33a784){return _0x33a784[_0xb480('0x2b')]()['then'](function(){var _0x4c471b=_0x33a784[_0xb480('0x2c')]({'plain':!![]});var _0x4e0a24=_0xb480('0x2d');return db[_0xb480('0x2e')][_0xb480('0x2b')]({'where':{'type':_0x4e0a24,'resourceId':_0x4c471b['id']}})[_0xb480('0x2f')](function(){return _0x33a784;});})['then'](function(){_0x35db51['status'](0xcc)[_0xb480('0x1e')]();});}};}function handleEntityNotFound(_0x324096,_0x1dc544){return function(_0x475576){if(!_0x475576){_0x324096['sendStatus'](0x194);}return _0x475576;};}function handleError(_0x3e2fd6,_0x44dee9){_0x44dee9=_0x44dee9||0x1f4;return function(_0x249819){logger[_0xb480('0x30')](_0x249819['stack']);if(_0x249819[_0xb480('0x31')]){delete _0x249819[_0xb480('0x31')];}_0x3e2fd6[_0xb480('0x1f')](_0x44dee9)[_0xb480('0x32')](_0x249819);};}exports[_0xb480('0x33')]=function(_0xabfe88,_0x577fcc){var _0x4a5812={},_0x370932={},_0x384ae9={'count':0x0,'rows':[]};var _0x4ab7c9=_['map'](db[_0xb480('0x34')]['rawAttributes'],function(_0x16f46e){return{'name':_0x16f46e[_0xb480('0x35')],'type':_0x16f46e[_0xb480('0x36')][_0xb480('0x37')]};});_0x370932['model']=_['map'](_0x4ab7c9,_0xb480('0x31'));_0x370932[_0xb480('0x38')]=_[_0xb480('0x39')](_0xabfe88[_0xb480('0x38')]);_0x370932[_0xb480('0x3a')]=_[_0xb480('0x3b')](_0x370932[_0xb480('0x3c')],_0x370932['query']);_0x4a5812[_0xb480('0x3d')]=_[_0xb480('0x3b')](_0x370932[_0xb480('0x3c')],qs[_0xb480('0x3e')](_0xabfe88[_0xb480('0x38')][_0xb480('0x3e')]));_0x4a5812[_0xb480('0x3d')]=_0x4a5812[_0xb480('0x3d')]['length']?_0x4a5812[_0xb480('0x3d')]:_0x370932[_0xb480('0x3c')];if(!_0xabfe88[_0xb480('0x38')]['hasOwnProperty'](_0xb480('0x3f'))){_0x4a5812[_0xb480('0x23')]=qs[_0xb480('0x23')](_0xabfe88[_0xb480('0x38')][_0xb480('0x23')]);_0x4a5812['offset']=qs[_0xb480('0x21')](_0xabfe88['query'][_0xb480('0x21')]);}_0x4a5812[_0xb480('0x40')]=qs[_0xb480('0x41')](_0xabfe88[_0xb480('0x38')][_0xb480('0x41')]);_0x4a5812['where']=qs[_0xb480('0x3a')](_[_0xb480('0x42')](_0xabfe88[_0xb480('0x38')],_0x370932[_0xb480('0x3a')]),_0x4ab7c9);if(_0xabfe88[_0xb480('0x38')]['filter']){_0x4a5812['where']=_[_0xb480('0x43')](_0x4a5812['where'],{'$or':_['map'](_0x4ab7c9,function(_0x5332ba){if(_0x5332ba['type']!=='VIRTUAL'){var _0x954b91={};_0x954b91[_0x5332ba['name']]={'$like':'%'+_0xabfe88['query']['filter']+'%'};return _0x954b91;}})});}_0x4a5812=_['merge']({},_0x4a5812,_0xabfe88[_0xb480('0x44')]);var _0x3d9fd5={'where':_0x4a5812['where']};return db[_0xb480('0x34')][_0xb480('0x24')](_0x3d9fd5)[_0xb480('0x2f')](function(_0x23b7cf){_0x384ae9[_0xb480('0x24')]=_0x23b7cf;if(_0xabfe88[_0xb480('0x38')][_0xb480('0x45')]){_0x4a5812[_0xb480('0x46')]=[{'all':!![]}];}return db[_0xb480('0x34')][_0xb480('0x47')](_0x4a5812);})[_0xb480('0x2f')](function(_0x466eed){_0x384ae9[_0xb480('0x48')]=_0x466eed;return _0x384ae9;})['then'](respondWithFilteredResult(_0x577fcc,_0x4a5812))[_0xb480('0x49')](handleError(_0x577fcc,null));};exports[_0xb480('0x4a')]=function(_0x2c40f1,_0x4d7627){var _0x3eff61={'raw':!![],'where':{'id':_0x2c40f1['params']['id']}},_0x9122de={};_0x9122de[_0xb480('0x3c')]=_[_0xb480('0x39')](db['OpenchannelQueue'][_0xb480('0x4b')]);_0x9122de[_0xb480('0x38')]=_[_0xb480('0x39')](_0x2c40f1['query']);_0x9122de[_0xb480('0x3a')]=_['intersection'](_0x9122de[_0xb480('0x3c')],_0x9122de['query']);_0x3eff61[_0xb480('0x3d')]=_['intersection'](_0x9122de[_0xb480('0x3c')],qs[_0xb480('0x3e')](_0x2c40f1[_0xb480('0x38')][_0xb480('0x3e')]));_0x3eff61[_0xb480('0x3d')]=_0x3eff61[_0xb480('0x3d')]['length']?_0x3eff61['attributes']:_0x9122de[_0xb480('0x3c')];if(_0x2c40f1[_0xb480('0x38')][_0xb480('0x45')]){_0x3eff61[_0xb480('0x46')]=[{'all':!![]}];}_0x3eff61=_['merge']({},_0x3eff61,_0x2c40f1['options']);return db[_0xb480('0x34')][_0xb480('0x4c')](_0x3eff61)['then'](handleEntityNotFound(_0x4d7627,null))[_0xb480('0x2f')](respondWithResult(_0x4d7627,null))[_0xb480('0x49')](handleError(_0x4d7627,null));};exports[_0xb480('0x4d')]=function(_0x46136c,_0x299a4d){return db['OpenchannelQueue'][_0xb480('0x4d')](_0x46136c[_0xb480('0x4e')],{})[_0xb480('0x2f')](function(_0x24474e){var _0x4a43d5=_0x46136c[_0xb480('0x4f')][_0xb480('0x2c')]({'plain':!![]});if(!_0x4a43d5)throw new Error(_0xb480('0x50'));if(_0x4a43d5[_0xb480('0x51')]==='user'){var _0x442c5e=_0x24474e[_0xb480('0x2c')]({'plain':!![]});var _0x43ed01=_0xb480('0x2d');return db[_0xb480('0x52')]['find']({'where':{'name':_0x43ed01,'userProfileId':_0x4a43d5['userProfileId']},'raw':!![]})[_0xb480('0x2f')](function(_0x1ee1aa){if(_0x1ee1aa&&_0x1ee1aa['autoAssociation']===0x0){return db[_0xb480('0x2e')]['create']({'name':_0x442c5e['name'],'resourceId':_0x442c5e['id'],'type':_0x1ee1aa[_0xb480('0x31')],'sectionId':_0x1ee1aa['id']},{})[_0xb480('0x2f')](function(){return _0x24474e;});}else{return _0x24474e;}})[_0xb480('0x49')](function(_0x4c7eda){logger[_0xb480('0x30')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4c7eda);throw _0x4c7eda;});}return _0x24474e;})[_0xb480('0x2f')](respondWithResult(_0x299a4d,0xc9))[_0xb480('0x49')](handleError(_0x299a4d,null));};exports['update']=function(_0x580c5b,_0x21ae12){if(_0x580c5b['body']['id']){delete _0x580c5b[_0xb480('0x4e')]['id'];}return db[_0xb480('0x34')][_0xb480('0x4c')]({'where':{'id':_0x580c5b[_0xb480('0x53')]['id']}})[_0xb480('0x2f')](handleEntityNotFound(_0x21ae12,null))[_0xb480('0x2f')](saveUpdates(_0x580c5b['body'],null))[_0xb480('0x2f')](respondWithResult(_0x21ae12,null))[_0xb480('0x49')](handleError(_0x21ae12,null));};exports['destroy']=function(_0x20bcb8,_0x9919cf){return db['OpenchannelQueue'][_0xb480('0x4c')]({'where':{'id':_0x20bcb8['params']['id']}})[_0xb480('0x2f')](handleEntityNotFound(_0x9919cf,null))[_0xb480('0x2f')](removeEntity(_0x9919cf,null))[_0xb480('0x49')](handleError(_0x9919cf,null));};exports[_0xb480('0x54')]=function(_0x21cb30,_0x30e4f6){return db[_0xb480('0x34')][_0xb480('0x54')]()[_0xb480('0x2f')](respondWithResult(_0x30e4f6,null))[_0xb480('0x49')](handleError(_0x30e4f6,null));};exports['getMembers']=function(_0xc27ff9,_0x38cc4d,_0x22903c){var _0x38b991={'raw':!![],'where':{}},_0x263c92={},_0x5312a6;return db[_0xb480('0x34')]['findOne']({'where':{'id':_0xc27ff9[_0xb480('0x53')]['id']}})[_0xb480('0x2f')](handleEntityNotFound(_0x38cc4d,null))[_0xb480('0x2f')](function(_0x3f4c7a){if(_0x3f4c7a){_0x5312a6=_0x3f4c7a['get']({'plain':!![]});_0x263c92['model']=_[_0xb480('0x39')](db[_0xb480('0x55')]['rawAttributes']);_0x263c92['query']=_[_0xb480('0x39')](_0xc27ff9[_0xb480('0x38')]);_0x263c92[_0xb480('0x3a')]=_[_0xb480('0x3b')](_0x263c92[_0xb480('0x3c')],_0x263c92[_0xb480('0x38')]);_0x38b991['attributes']=_['intersection'](_0x263c92[_0xb480('0x3c')],qs[_0xb480('0x3e')](_0xc27ff9[_0xb480('0x38')][_0xb480('0x3e')]));_0x38b991[_0xb480('0x3d')]=_0x38b991[_0xb480('0x3d')][_0xb480('0x56')]?_0x38b991['attributes']:_0x263c92['model'];if(!_0xc27ff9[_0xb480('0x38')][_0xb480('0x57')]('nolimit')){_0x38b991['limit']=qs[_0xb480('0x23')](_0xc27ff9[_0xb480('0x38')][_0xb480('0x23')]);_0x38b991[_0xb480('0x21')]=qs['offset'](_0xc27ff9[_0xb480('0x38')][_0xb480('0x21')]);}_0x38b991[_0xb480('0x40')]=qs[_0xb480('0x41')](_0xc27ff9[_0xb480('0x38')]['sort']);_0x38b991[_0xb480('0x58')]=qs[_0xb480('0x3a')](_[_0xb480('0x42')](_0xc27ff9['query'],_0x263c92[_0xb480('0x3a')]));_0x38b991[_0xb480('0x58')][_0xb480('0x59')]=_0x3f4c7a['id'];if(_0xc27ff9[_0xb480('0x38')][_0xb480('0x5a')]){_0x38b991[_0xb480('0x58')]=_[_0xb480('0x43')](_0x38b991[_0xb480('0x58')],{'$or':_['map'](_0x38b991['attributes'],function(_0x2f18b1){var _0x145ea9={};_0x145ea9[_0x2f18b1]={'$like':'%'+_0xc27ff9[_0xb480('0x38')][_0xb480('0x5a')]+'%'};return _0x145ea9;})});}_0x38b991=_[_0xb480('0x43')]({},_0x38b991,_0xc27ff9['options']);return db[_0xb480('0x55')][_0xb480('0x47')](_0x38b991);}})[_0xb480('0x2f')](function(_0x5bce5f){if(_0x5bce5f){return db[_0xb480('0x5b')][_0xb480('0x5c')]({'where':{'id':_[_0xb480('0x5d')](_0x5bce5f,'UserId'),'role':'agent'},'attributes':['id',_0xb480('0x31'),_0xb480('0x5e'),_0xb480('0x5f'),_0xb480('0x60')]});}})[_0xb480('0x2f')](function(_0x52a390){if(_0x52a390){return{'count':_0x52a390[_0xb480('0x24')],'rows':_['map'](_0x52a390[_0xb480('0x48')],function(_0xefcda9){return{'membername':_0xefcda9[_0xb480('0x31')],'UserId':_0xefcda9['id'],'queue_name':_0x5312a6[_0xb480('0x31')],'OpenchannelQueueId':_0x5312a6['id'],'interface':util['format'](_0xb480('0x61'),_0xb480('0x62'),_0xefcda9['name']),'penalty':0x0,'paused':_0xefcda9[_0xb480('0x5e')],'createdAt':_0xefcda9['createdAt'],'updatedAt':_0xefcda9[_0xb480('0x5f')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x38cc4d,_0x38b991))[_0xb480('0x49')](handleError(_0x38cc4d,null));};exports['getTeams']=function(_0xaed731,_0x3a30e8,_0x4f68cf){var _0x1e3d8b={};var _0x29172b={};var _0x3c5eec;var _0x400e8f;return db[_0xb480('0x34')][_0xb480('0x63')]({'where':{'id':_0xaed731[_0xb480('0x53')]['id']}})[_0xb480('0x2f')](handleEntityNotFound(_0x3a30e8,null))[_0xb480('0x2f')](function(_0x323214){if(_0x323214){_0x3c5eec=_0x323214;_0x29172b['model']=_[_0xb480('0x39')](db[_0xb480('0x64')][_0xb480('0x4b')]);_0x29172b[_0xb480('0x38')]=_[_0xb480('0x39')](_0xaed731[_0xb480('0x38')]);_0x29172b[_0xb480('0x3a')]=_[_0xb480('0x3b')](_0x29172b[_0xb480('0x3c')],_0x29172b[_0xb480('0x38')]);_0x1e3d8b[_0xb480('0x3d')]=_[_0xb480('0x3b')](_0x29172b[_0xb480('0x3c')],qs[_0xb480('0x3e')](_0xaed731['query'][_0xb480('0x3e')]));_0x1e3d8b[_0xb480('0x3d')]=_0x1e3d8b[_0xb480('0x3d')][_0xb480('0x56')]?_0x1e3d8b['attributes']:_0x29172b[_0xb480('0x3c')];_0x1e3d8b[_0xb480('0x40')]=qs['sort'](_0xaed731[_0xb480('0x38')]['sort']);_0x1e3d8b['where']=qs[_0xb480('0x3a')](_[_0xb480('0x42')](_0xaed731['query'],_0x29172b[_0xb480('0x3a')]));if(_0xaed731[_0xb480('0x38')]['filter']){_0x1e3d8b[_0xb480('0x58')]=_[_0xb480('0x43')](_0x1e3d8b[_0xb480('0x58')],{'$or':_[_0xb480('0x5d')](_0x1e3d8b[_0xb480('0x3d')],function(_0x31273a){var _0x1ada35={};_0x1ada35[_0x31273a]={'$like':'%'+_0xaed731['query'][_0xb480('0x5a')]+'%'};return _0x1ada35;})});}_0x1e3d8b=_[_0xb480('0x43')]({},_0x1e3d8b,_0xaed731[_0xb480('0x44')]);return _0x3c5eec[_0xb480('0x65')](_0x1e3d8b);}})[_0xb480('0x2f')](function(_0x59a6f1){if(_0x59a6f1){_0x400e8f=_0x59a6f1['length'];if(!_0xaed731[_0xb480('0x38')][_0xb480('0x57')](_0xb480('0x3f'))){_0x1e3d8b['limit']=qs[_0xb480('0x23')](_0xaed731[_0xb480('0x38')][_0xb480('0x23')]);_0x1e3d8b[_0xb480('0x21')]=qs[_0xb480('0x21')](_0xaed731['query'][_0xb480('0x21')]);}return _0x3c5eec[_0xb480('0x65')](_0x1e3d8b);}})[_0xb480('0x2f')](function(_0x17fa76){if(_0x17fa76){return _0x17fa76?{'count':_0x400e8f,'rows':_0x17fa76}:null;}})[_0xb480('0x2f')](respondWithResult(_0x3a30e8,null))[_0xb480('0x49')](handleError(_0x3a30e8,null));};exports[_0xb480('0x66')]=function(_0x3dce61,_0x44c4de,_0x56c692){var _0x507344=_0x3dce61[_0xb480('0x4e')]['ids'];return db[_0xb480('0x64')][_0xb480('0x47')]({'where':{'id':_0x507344},'attributes':['id'],'include':[{'model':db[_0xb480('0x5b')],'as':_0xb480('0x67'),'attributes':['id','name',_0xb480('0x68'),_0xb480('0x69'),_0xb480('0x6a')],'raw':!![]}]})[_0xb480('0x2f')](function(_0x233042){if(_0x233042){var _0x4e1ec6=_[_0xb480('0x6b')](_0x233042,function(_0xa5f1f8){var _0xcee52b=_0xa5f1f8['get']({'plain':!![]});return _0xcee52b[_0xb480('0x67')];});return db[_0xb480('0x34')][_0xb480('0x4c')]({'where':{'id':_0x3dce61[_0xb480('0x53')]['id']}})[_0xb480('0x2f')](function(_0x5416d6){return db[_0xb480('0x6c')]['transaction'](function(_0x5584b6){return _0x5416d6['addTeams'](_0x507344,{'transaction':_0x5584b6})[_0xb480('0x2f')](function(){return BPromise['each'](_0x4e1ec6,function(_0x5ebea8){return db[_0xb480('0x55')][_0xb480('0x6d')]({'where':{'UserId':_0x5ebea8['id'],'OpenchannelQueueId':_0x3dce61[_0xb480('0x53')]['id']},'transaction':_0x5584b6});});})[_0xb480('0x2f')](function(){_0x4e1ec6['forEach'](function(_0x11c336){socket[_0xb480('0x6e')](_0xb480('0x6f'),{'UserId':_0x11c336['id'],'OpenchannelQueueId':_0x5416d6['id']});});});});});}})[_0xb480('0x2f')](respondWithStatusCode(_0x44c4de,null))['catch'](handleError(_0x44c4de,null));};exports[_0xb480('0x70')]=function(_0x19f0b7,_0x2ae782,_0x115ce9){return db[_0xb480('0x64')][_0xb480('0x47')]({'where':{'id':_0x19f0b7[_0xb480('0x38')][_0xb480('0x71')]},'attributes':['id'],'include':[{'model':db[_0xb480('0x5b')],'as':_0xb480('0x67'),'attributes':['id'],'raw':!![]}]})[_0xb480('0x2f')](handleEntityNotFound(_0x2ae782,null))['then'](function(_0xbedfa2){var _0x343f16=_[_0xb480('0x5d')](_0xbedfa2,'id');var _0x2e8f95=[];var _0x1d4002=[];var _0x2cd02c=squel[_0xb480('0x72')]();_0x2cd02c[_0xb480('0x73')](_0xb480('0x74'))['from']('team_has_openchannel_queues','tq')[_0xb480('0x75')](_0xb480('0x76'),'ut',_0xb480('0x77'))[_0xb480('0x58')](_0xb480('0x78'),_0x19f0b7[_0xb480('0x53')]['id']);for(var _0x65bea0=0x0;_0x65bea0<_0xbedfa2[_0xb480('0x56')];_0x65bea0+=0x1){let _0x4ec34=_0xbedfa2[_0x65bea0];for(var _0x39a6aa=0x0;_0x39a6aa<_0x4ec34[_0xb480('0x67')][_0xb480('0x56')];_0x39a6aa+=0x1){let _0x1eb906=_0x4ec34['Agents'][_0x39a6aa];var _0x61edc3=_0x2cd02c['clone']();_0x61edc3[_0xb480('0x58')]('ut.UserId\x20=\x20?',_0x1eb906['id']);_0x1d4002[_0xb480('0x79')](db[_0xb480('0x6c')][_0xb480('0x38')](_0x61edc3[_0xb480('0x7a')](),{'type':db[_0xb480('0x6c')][_0xb480('0x7b')][_0xb480('0x7c')]})[_0xb480('0x2f')](function(_0x1982cd){if(_0x1982cd['length']===0x1){return _0x1eb906['id'];}else{var _0xb8a7b6=_[_0xb480('0x7d')](_[_0xb480('0x5d')](_0x1982cd,_0xb480('0x7e')),function(_0x5a9672){return _['includes'](_0x343f16,_0x5a9672);});if(_0xb8a7b6){return _0x1eb906['id'];}}}));}}return BPromise[_0xb480('0x7f')](_0x1d4002)[_0xb480('0x2f')](function(_0x47efdd){_0x2e8f95=_(_0x2e8f95)[_0xb480('0x80')](_0x47efdd)[_0xb480('0x81')]()[_0xb480('0x82')]();return db[_0xb480('0x34')][_0xb480('0x4c')]({'where':{'id':_0x19f0b7['params']['id']}})[_0xb480('0x2f')](function(_0x425879){return db[_0xb480('0x6c')][_0xb480('0x83')](function(_0x23dc7a){return _0x425879[_0xb480('0x70')](_0x19f0b7['query']['ids'],{'transaction':_0x23dc7a})[_0xb480('0x2f')](function(){if(!_['isEmpty'](_0x2e8f95)){return _0x425879[_0xb480('0x84')](_0x2e8f95,{'transaction':_0x23dc7a});}})['then'](function(){_0x2e8f95['forEach'](function(_0x27ed4e){socket[_0xb480('0x6e')](_0xb480('0x85'),{'UserId':_0x27ed4e,'OpenchannelQueueId':_0x425879['id']});});});});});});})[_0xb480('0x2f')](respondWithStatusCode(_0x2ae782,null))[_0xb480('0x49')](handleError(_0x2ae782,null));};exports[_0xb480('0x86')]=function(_0x289f0e,_0x1cfc22,_0x28fefb){return db[_0xb480('0x34')]['find']({'where':{'id':_0x289f0e[_0xb480('0x53')]['id']}})[_0xb480('0x2f')](handleEntityNotFound(_0x1cfc22,null))[_0xb480('0x2f')](function(_0x1dfcbf){if(_0x1dfcbf){return _0x1dfcbf[_0xb480('0x86')](_0x289f0e[_0xb480('0x4e')]['ids'],_[_0xb480('0x87')](_0x289f0e[_0xb480('0x4e')],['ids','id'])||{})[_0xb480('0x88')](function(_0x219875){for(var _0xa8df7=0x0;_0xa8df7<_0x289f0e[_0xb480('0x4e')][_0xb480('0x71')][_0xb480('0x56')];_0xa8df7+=0x1){socket[_0xb480('0x6e')](_0xb480('0x6f'),{'UserId':Number(_0x289f0e['body'][_0xb480('0x71')][_0xa8df7]),'OpenchannelQueueId':Number(_0x289f0e[_0xb480('0x53')]['id'])});}return _0x219875;});}})[_0xb480('0x2f')](respondWithResult(_0x1cfc22,null))[_0xb480('0x49')](handleError(_0x1cfc22,null));};exports[_0xb480('0x84')]=function(_0x27d26b,_0x4c832a,_0x5d0039){return db['OpenchannelQueue'][_0xb480('0x4c')]({'where':{'id':_0x27d26b['params']['id']}})[_0xb480('0x2f')](handleEntityNotFound(_0x4c832a,null))[_0xb480('0x2f')](function(_0x3968a7){if(_0x3968a7){return _0x3968a7['removeAgents'](_0x27d26b['query'][_0xb480('0x71')])[_0xb480('0x2f')](function(){if(_[_0xb480('0x89')](_0x27d26b['query'][_0xb480('0x71')])){for(var _0x1fe883=0x0;_0x1fe883<_0x27d26b[_0xb480('0x38')]['ids'][_0xb480('0x56')];_0x1fe883+=0x1){socket['emit'](_0xb480('0x85'),{'UserId':Number(_0x27d26b['query'][_0xb480('0x71')][_0x1fe883]),'OpenchannelQueueId':Number(_0x27d26b[_0xb480('0x53')]['id'])});}}else{socket[_0xb480('0x6e')](_0xb480('0x85'),{'UserId':Number(_0x27d26b[_0xb480('0x38')][_0xb480('0x71')]),'OpenchannelQueueId':Number(_0x27d26b[_0xb480('0x53')]['id'])});}});}})[_0xb480('0x2f')](respondWithStatusCode(_0x4c832a,null))[_0xb480('0x49')](handleError(_0x4c832a,null));};exports[_0xb480('0x8a')]=function(_0x2bbae9,_0x1b02e7,_0x4c5713){var _0x2d31b9={};var _0x488cac={};var _0x1fe258;var _0x59c03e;return db[_0xb480('0x34')][_0xb480('0x63')]({'where':{'id':_0x2bbae9[_0xb480('0x53')]['id']}})['then'](handleEntityNotFound(_0x1b02e7,null))[_0xb480('0x2f')](function(_0x4ec9f1){if(_0x4ec9f1){_0x1fe258=_0x4ec9f1;_0x488cac[_0xb480('0x3c')]=_['keys'](db[_0xb480('0x5b')][_0xb480('0x4b')]);_0x488cac[_0xb480('0x38')]=_[_0xb480('0x39')](_0x2bbae9[_0xb480('0x38')]);_0x488cac[_0xb480('0x3a')]=_['intersection'](_0x488cac['model'],_0x488cac[_0xb480('0x38')]);_0x2d31b9['attributes']=_[_0xb480('0x3b')](_0x488cac[_0xb480('0x3c')],qs['fields'](_0x2bbae9['query'][_0xb480('0x3e')]));_0x2d31b9[_0xb480('0x3d')]=_0x2d31b9['attributes'][_0xb480('0x56')]?_0x2d31b9[_0xb480('0x3d')]:_0x488cac[_0xb480('0x3c')];_0x2d31b9['order']=qs['sort'](_0x2bbae9[_0xb480('0x38')][_0xb480('0x41')]);_0x2d31b9[_0xb480('0x58')]=qs['filters'](_[_0xb480('0x42')](_0x2bbae9[_0xb480('0x38')],_0x488cac['filters']));if(_0x2bbae9[_0xb480('0x38')][_0xb480('0x5a')]){_0x2d31b9[_0xb480('0x58')]=_[_0xb480('0x43')](_0x2d31b9[_0xb480('0x58')],{'$or':_[_0xb480('0x5d')](_0x2d31b9['attributes'],function(_0x3d913e){var _0x426aad={};_0x426aad[_0x3d913e]={'$like':'%'+_0x2bbae9[_0xb480('0x38')][_0xb480('0x5a')]+'%'};return _0x426aad;})});}_0x2d31b9=_[_0xb480('0x43')]({},_0x2d31b9,_0x2bbae9[_0xb480('0x44')]);return _0x1fe258[_0xb480('0x8a')](_0x2d31b9);}})['then'](function(_0x426737){if(_0x426737){_0x59c03e=_0x426737[_0xb480('0x56')];if(!_0x2bbae9[_0xb480('0x38')][_0xb480('0x57')](_0xb480('0x3f'))){_0x2d31b9[_0xb480('0x23')]=qs['limit'](_0x2bbae9[_0xb480('0x38')][_0xb480('0x23')]);_0x2d31b9['offset']=qs[_0xb480('0x21')](_0x2bbae9[_0xb480('0x38')][_0xb480('0x21')]);}return _0x1fe258[_0xb480('0x8a')](_0x2d31b9);}})[_0xb480('0x2f')](function(_0x402b6e){if(_0x402b6e){return _0x402b6e?{'count':_0x59c03e,'rows':_0x402b6e}:null;}})[_0xb480('0x2f')](respondWithResult(_0x1b02e7,null))['catch'](handleError(_0x1b02e7,null));};
\ No newline at end of file