Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index c1d502d..1efd4bf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x85b9=['rows','%s/%s','SIP','findOne','Team','getTeams','nolimit','ids','Agents','voicePause','interface','flatMap','sequelize','transaction','addTeams','each','findOrCreate','forEach','emit','userOpenchannelQueue:save','removeTeams','tq.TeamId','from','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','removeAgents','addAgents','omit','spread','isArray','userOpenchannelQueue:remove','getAgents','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./openchannelQueue.socket','register','sendStatus','status','end','offset','limit','set','Content-Range','json','apply','reject','then','destroy','get','UserProfileResource','error','stack','name','send','index','map','OpenchannelQueue','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','fields','length','order','sort','where','pick','merge','type','VIRTUAL','filter','options','count','includeAll','include','findAll','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','describe','getMembers','hasOwnProperty','OpenchannelQueueId','UserOpenchannelQueue','User','findAndCountAll','UserId','agent','openchannelPause','updatedAt'];(function(_0x2313d6,_0x1d38af){var _0x38a7ef=function(_0xe66113){while(--_0xe66113){_0x2313d6['push'](_0x2313d6['shift']());}};_0x38a7ef(++_0x1d38af);}(_0x85b9,0xc1));var _0x985b=function(_0x344a3f,_0x579a22){_0x344a3f=_0x344a3f-0x0;var _0x264712=_0x85b9[_0x344a3f];return _0x264712;};'use strict';var pdf=require(_0x985b('0x0'));var emlformat=require(_0x985b('0x1'));var rimraf=require(_0x985b('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x985b('0x3'));var rp=require(_0x985b('0x4'));var moment=require(_0x985b('0x5'));var BPromise=require(_0x985b('0x6'));var Mustache=require(_0x985b('0x7'));var util=require(_0x985b('0x8'));var path=require(_0x985b('0x9'));var sox=require(_0x985b('0xa'));var csv=require(_0x985b('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x985b('0xc'));var squel=require(_0x985b('0xd'));var crypto=require(_0x985b('0xe'));var jsforce=require(_0x985b('0xf'));var deskjs=require(_0x985b('0x10'));var toCsv=require(_0x985b('0xb'));var querystring=require(_0x985b('0x11'));var Papa=require(_0x985b('0x12'));var Redis=require(_0x985b('0x13'));var authService=require(_0x985b('0x14'));var qs=require(_0x985b('0x15'));var as=require(_0x985b('0x16'));var hardwareService=require(_0x985b('0x17'));var logger=require(_0x985b('0x18'))(_0x985b('0x19'));var utils=require(_0x985b('0x1a'));var config=require(_0x985b('0x1b'));var db=require(_0x985b('0x1c'))['db'];config[_0x985b('0x1d')]=_['defaults'](config['redis'],{'host':_0x985b('0x1e'),'port':0x18eb});var socket=require(_0x985b('0x1f'))(new Redis(config[_0x985b('0x1d')]));require(_0x985b('0x20'))[_0x985b('0x21')](socket);function respondWithStatusCode(_0x49a3f9,_0x2fc776){_0x2fc776=_0x2fc776||0xcc;return function(_0x3db472){if(_0x3db472){return _0x49a3f9[_0x985b('0x22')](_0x2fc776);}return _0x49a3f9[_0x985b('0x23')](_0x2fc776)[_0x985b('0x24')]();};}function respondWithResult(_0x557df5,_0x1e8c07){_0x1e8c07=_0x1e8c07||0xc8;return function(_0xe82b53){if(_0xe82b53){return _0x557df5['status'](_0x1e8c07)['json'](_0xe82b53);}};}function respondWithFilteredResult(_0x3b08fe,_0x19942a){return function(_0x1b3201){if(_0x1b3201){var _0x73a7c9=_0x1b3201['count'],_0x26a60f=_0x19942a['offset'],_0x15ea22=_0x19942a[_0x985b('0x25')]+_0x19942a[_0x985b('0x26')],_0x5d9c94;if(_0x15ea22>=_0x73a7c9){_0x15ea22=_0x73a7c9;_0x5d9c94=0xc8;}else{_0x5d9c94=0xce;}_0x3b08fe[_0x985b('0x23')](_0x5d9c94);return _0x3b08fe[_0x985b('0x27')](_0x985b('0x28'),_0x26a60f+'-'+_0x15ea22+'/'+_0x73a7c9)[_0x985b('0x29')](_0x1b3201);}return null;};}function patchUpdates(_0x1c674f){return function(_0x39c927){try{jsonpatch[_0x985b('0x2a')](_0x39c927,_0x1c674f,!![]);}catch(_0x11581f){return BPromise[_0x985b('0x2b')](_0x11581f);}return _0x39c927['save']();};}function saveUpdates(_0x1cee17,_0x5ef099){return function(_0x3a0dfc){if(_0x3a0dfc){return _0x3a0dfc['update'](_0x1cee17)[_0x985b('0x2c')](function(_0x5c90b7){return _0x5c90b7;});}return null;};}function removeEntity(_0x432b3f,_0x150c2d){return function(_0x3a76ab){if(_0x3a76ab){return _0x3a76ab[_0x985b('0x2d')]()[_0x985b('0x2c')](function(){var _0x35b421=_0x3a76ab[_0x985b('0x2e')]({'plain':!![]});var _0x437f5a='OpenchannelQueues';return db[_0x985b('0x2f')]['destroy']({'where':{'type':_0x437f5a,'resourceId':_0x35b421['id']}})['then'](function(){return _0x3a76ab;});})[_0x985b('0x2c')](function(){_0x432b3f[_0x985b('0x23')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2662ef,_0x3a7236){return function(_0x5a9632){if(!_0x5a9632){_0x2662ef[_0x985b('0x22')](0x194);}return _0x5a9632;};}function handleError(_0x119f5c,_0x3cada0){_0x3cada0=_0x3cada0||0x1f4;return function(_0x29f64e){logger[_0x985b('0x30')](_0x29f64e[_0x985b('0x31')]);if(_0x29f64e[_0x985b('0x32')]){delete _0x29f64e[_0x985b('0x32')];}_0x119f5c['status'](_0x3cada0)[_0x985b('0x33')](_0x29f64e);};}exports[_0x985b('0x34')]=function(_0x2b36fc,_0x5c84d8){var _0x59df84={},_0x34dce8={},_0x50a580={'count':0x0,'rows':[]};var _0x391fb5=_[_0x985b('0x35')](db[_0x985b('0x36')][_0x985b('0x37')],function(_0x392c8d){return{'name':_0x392c8d[_0x985b('0x38')],'type':_0x392c8d['type']['key']};});_0x34dce8[_0x985b('0x39')]=_[_0x985b('0x35')](_0x391fb5,_0x985b('0x32'));_0x34dce8[_0x985b('0x3a')]=_[_0x985b('0x3b')](_0x2b36fc[_0x985b('0x3a')]);_0x34dce8[_0x985b('0x3c')]=_[_0x985b('0x3d')](_0x34dce8[_0x985b('0x39')],_0x34dce8[_0x985b('0x3a')]);_0x59df84[_0x985b('0x3e')]=_['intersection'](_0x34dce8['model'],qs[_0x985b('0x3f')](_0x2b36fc[_0x985b('0x3a')][_0x985b('0x3f')]));_0x59df84[_0x985b('0x3e')]=_0x59df84[_0x985b('0x3e')][_0x985b('0x40')]?_0x59df84[_0x985b('0x3e')]:_0x34dce8[_0x985b('0x39')];if(!_0x2b36fc[_0x985b('0x3a')]['hasOwnProperty']('nolimit')){_0x59df84[_0x985b('0x26')]=qs[_0x985b('0x26')](_0x2b36fc[_0x985b('0x3a')][_0x985b('0x26')]);_0x59df84[_0x985b('0x25')]=qs[_0x985b('0x25')](_0x2b36fc[_0x985b('0x3a')][_0x985b('0x25')]);}_0x59df84[_0x985b('0x41')]=qs[_0x985b('0x42')](_0x2b36fc[_0x985b('0x3a')][_0x985b('0x42')]);_0x59df84[_0x985b('0x43')]=qs[_0x985b('0x3c')](_[_0x985b('0x44')](_0x2b36fc[_0x985b('0x3a')],_0x34dce8[_0x985b('0x3c')]));if(_0x2b36fc[_0x985b('0x3a')]['filter']){_0x59df84[_0x985b('0x43')]=_[_0x985b('0x45')](_0x59df84['where'],{'$or':_[_0x985b('0x35')](_0x391fb5,function(_0x4bba0e){if(_0x4bba0e[_0x985b('0x46')]!==_0x985b('0x47')){var _0x45045a={};_0x45045a[_0x4bba0e[_0x985b('0x32')]]={'$like':'%'+_0x2b36fc[_0x985b('0x3a')][_0x985b('0x48')]+'%'};return _0x45045a;}})});}_0x59df84=_[_0x985b('0x45')]({},_0x59df84,_0x2b36fc[_0x985b('0x49')]);var _0x29de24={'where':_0x59df84[_0x985b('0x43')]};return db['OpenchannelQueue']['count'](_0x29de24)['then'](function(_0x552e3a){_0x50a580[_0x985b('0x4a')]=_0x552e3a;if(_0x2b36fc[_0x985b('0x3a')][_0x985b('0x4b')]){_0x59df84[_0x985b('0x4c')]=[{'all':!![]}];}return db[_0x985b('0x36')][_0x985b('0x4d')](_0x59df84);})[_0x985b('0x2c')](function(_0x3da4d6){_0x50a580['rows']=_0x3da4d6;return _0x50a580;})[_0x985b('0x2c')](respondWithFilteredResult(_0x5c84d8,_0x59df84))[_0x985b('0x4e')](handleError(_0x5c84d8,null));};exports['show']=function(_0x5d362b,_0x97e2bd){var _0x2eece3={'raw':!![],'where':{'id':_0x5d362b['params']['id']}},_0x685b2a={};_0x685b2a[_0x985b('0x39')]=_[_0x985b('0x3b')](db[_0x985b('0x36')]['rawAttributes']);_0x685b2a[_0x985b('0x3a')]=_[_0x985b('0x3b')](_0x5d362b['query']);_0x685b2a[_0x985b('0x3c')]=_[_0x985b('0x3d')](_0x685b2a['model'],_0x685b2a['query']);_0x2eece3[_0x985b('0x3e')]=_[_0x985b('0x3d')](_0x685b2a['model'],qs['fields'](_0x5d362b[_0x985b('0x3a')][_0x985b('0x3f')]));_0x2eece3[_0x985b('0x3e')]=_0x2eece3['attributes'][_0x985b('0x40')]?_0x2eece3[_0x985b('0x3e')]:_0x685b2a['model'];if(_0x5d362b[_0x985b('0x3a')][_0x985b('0x4b')]){_0x2eece3[_0x985b('0x4c')]=[{'all':!![]}];}_0x2eece3=_['merge']({},_0x2eece3,_0x5d362b[_0x985b('0x49')]);return db[_0x985b('0x36')]['find'](_0x2eece3)[_0x985b('0x2c')](handleEntityNotFound(_0x97e2bd,null))[_0x985b('0x2c')](respondWithResult(_0x97e2bd,null))[_0x985b('0x4e')](handleError(_0x97e2bd,null));};exports[_0x985b('0x4f')]=function(_0x56a577,_0x4449bd){return db[_0x985b('0x36')][_0x985b('0x4f')](_0x56a577[_0x985b('0x50')],{})[_0x985b('0x2c')](function(_0x37301a){var _0x54e0d2=_0x56a577[_0x985b('0x51')][_0x985b('0x2e')]({'plain':!![]});if(!_0x54e0d2)throw new Error(_0x985b('0x52'));if(_0x54e0d2[_0x985b('0x53')]===_0x985b('0x51')){var _0x2160cf=_0x37301a[_0x985b('0x2e')]({'plain':!![]});var _0x2e863f='OpenchannelQueues';return db['UserProfileSection'][_0x985b('0x54')]({'where':{'name':_0x2e863f,'userProfileId':_0x54e0d2[_0x985b('0x55')]},'raw':!![]})['then'](function(_0x1665ef){if(_0x1665ef&&_0x1665ef[_0x985b('0x56')]===0x0){return db['UserProfileResource'][_0x985b('0x4f')]({'name':_0x2160cf[_0x985b('0x32')],'resourceId':_0x2160cf['id'],'type':_0x1665ef[_0x985b('0x32')],'sectionId':_0x1665ef['id']},{})['then'](function(){return _0x37301a;});}else{return _0x37301a;}})[_0x985b('0x4e')](function(_0xa1ca33){logger[_0x985b('0x30')](_0x985b('0x57'),_0xa1ca33);throw _0xa1ca33;});}return _0x37301a;})[_0x985b('0x2c')](respondWithResult(_0x4449bd,0xc9))[_0x985b('0x4e')](handleError(_0x4449bd,null));};exports[_0x985b('0x58')]=function(_0x2555e8,_0x204a5a){if(_0x2555e8[_0x985b('0x50')]['id']){delete _0x2555e8[_0x985b('0x50')]['id'];}return db[_0x985b('0x36')][_0x985b('0x54')]({'where':{'id':_0x2555e8[_0x985b('0x59')]['id']}})['then'](handleEntityNotFound(_0x204a5a,null))[_0x985b('0x2c')](saveUpdates(_0x2555e8[_0x985b('0x50')],null))[_0x985b('0x2c')](respondWithResult(_0x204a5a,null))['catch'](handleError(_0x204a5a,null));};exports[_0x985b('0x2d')]=function(_0x2cdbae,_0x2cc293){return db['OpenchannelQueue'][_0x985b('0x54')]({'where':{'id':_0x2cdbae[_0x985b('0x59')]['id']}})[_0x985b('0x2c')](handleEntityNotFound(_0x2cc293,null))[_0x985b('0x2c')](removeEntity(_0x2cc293,null))[_0x985b('0x4e')](handleError(_0x2cc293,null));};exports[_0x985b('0x5a')]=function(_0x1f2b24,_0x3e4d40){return db['OpenchannelQueue'][_0x985b('0x5a')]()[_0x985b('0x2c')](respondWithResult(_0x3e4d40,null))['catch'](handleError(_0x3e4d40,null));};exports[_0x985b('0x5b')]=function(_0x466f50,_0x5ef063,_0x1bff7d){var _0x5be5e8={'raw':!![],'where':{}},_0x4ac887={},_0x57eb01;return db[_0x985b('0x36')]['findOne']({'where':{'id':_0x466f50[_0x985b('0x59')]['id']}})[_0x985b('0x2c')](handleEntityNotFound(_0x5ef063,null))['then'](function(_0x17c657){if(_0x17c657){_0x57eb01=_0x17c657['get']({'plain':!![]});_0x4ac887[_0x985b('0x39')]=_[_0x985b('0x3b')](db['UserOpenchannelQueue'][_0x985b('0x37')]);_0x4ac887[_0x985b('0x3a')]=_[_0x985b('0x3b')](_0x466f50['query']);_0x4ac887[_0x985b('0x3c')]=_['intersection'](_0x4ac887[_0x985b('0x39')],_0x4ac887[_0x985b('0x3a')]);_0x5be5e8[_0x985b('0x3e')]=_[_0x985b('0x3d')](_0x4ac887[_0x985b('0x39')],qs['fields'](_0x466f50[_0x985b('0x3a')]['fields']));_0x5be5e8['attributes']=_0x5be5e8[_0x985b('0x3e')][_0x985b('0x40')]?_0x5be5e8[_0x985b('0x3e')]:_0x4ac887[_0x985b('0x39')];if(!_0x466f50[_0x985b('0x3a')][_0x985b('0x5c')]('nolimit')){_0x5be5e8[_0x985b('0x26')]=qs[_0x985b('0x26')](_0x466f50[_0x985b('0x3a')][_0x985b('0x26')]);_0x5be5e8[_0x985b('0x25')]=qs[_0x985b('0x25')](_0x466f50[_0x985b('0x3a')][_0x985b('0x25')]);}_0x5be5e8[_0x985b('0x41')]=qs['sort'](_0x466f50[_0x985b('0x3a')]['sort']);_0x5be5e8[_0x985b('0x43')]=qs['filters'](_[_0x985b('0x44')](_0x466f50[_0x985b('0x3a')],_0x4ac887[_0x985b('0x3c')]));_0x5be5e8[_0x985b('0x43')][_0x985b('0x5d')]=_0x17c657['id'];if(_0x466f50[_0x985b('0x3a')][_0x985b('0x48')]){_0x5be5e8['where']=_[_0x985b('0x45')](_0x5be5e8['where'],{'$or':_['map'](_0x5be5e8[_0x985b('0x3e')],function(_0x35f499){var _0x487175={};_0x487175[_0x35f499]={'$like':'%'+_0x466f50['query'][_0x985b('0x48')]+'%'};return _0x487175;})});}_0x5be5e8=_[_0x985b('0x45')]({},_0x5be5e8,_0x466f50[_0x985b('0x49')]);return db[_0x985b('0x5e')][_0x985b('0x4d')](_0x5be5e8);}})['then'](function(_0xd8ddbc){if(_0xd8ddbc){return db[_0x985b('0x5f')][_0x985b('0x60')]({'where':{'id':_[_0x985b('0x35')](_0xd8ddbc,_0x985b('0x61')),'role':_0x985b('0x62')},'attributes':['id',_0x985b('0x32'),_0x985b('0x63'),_0x985b('0x64'),'createdAt']});}})[_0x985b('0x2c')](function(_0x3e81fb){if(_0x3e81fb){return{'count':_0x3e81fb['count'],'rows':_[_0x985b('0x35')](_0x3e81fb[_0x985b('0x65')],function(_0x1cd171){return{'membername':_0x1cd171[_0x985b('0x32')],'UserId':_0x1cd171['id'],'queue_name':_0x57eb01[_0x985b('0x32')],'OpenchannelQueueId':_0x57eb01['id'],'interface':util['format'](_0x985b('0x66'),_0x985b('0x67'),_0x1cd171[_0x985b('0x32')]),'penalty':0x0,'paused':_0x1cd171['openchannelPause'],'createdAt':_0x1cd171['createdAt'],'updatedAt':_0x1cd171[_0x985b('0x64')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x5ef063,_0x5be5e8))[_0x985b('0x4e')](handleError(_0x5ef063,null));};exports['getTeams']=function(_0x93a86f,_0x574e32,_0x3c480b){var _0x51db4f={};var _0x28f2c7={};var _0x11cd2a;var _0x4dbc14;return db[_0x985b('0x36')][_0x985b('0x68')]({'where':{'id':_0x93a86f[_0x985b('0x59')]['id']}})[_0x985b('0x2c')](handleEntityNotFound(_0x574e32,null))[_0x985b('0x2c')](function(_0x354b9a){if(_0x354b9a){_0x11cd2a=_0x354b9a;_0x28f2c7['model']=_[_0x985b('0x3b')](db[_0x985b('0x69')][_0x985b('0x37')]);_0x28f2c7[_0x985b('0x3a')]=_['keys'](_0x93a86f[_0x985b('0x3a')]);_0x28f2c7[_0x985b('0x3c')]=_['intersection'](_0x28f2c7['model'],_0x28f2c7[_0x985b('0x3a')]);_0x51db4f[_0x985b('0x3e')]=_[_0x985b('0x3d')](_0x28f2c7[_0x985b('0x39')],qs['fields'](_0x93a86f[_0x985b('0x3a')][_0x985b('0x3f')]));_0x51db4f[_0x985b('0x3e')]=_0x51db4f[_0x985b('0x3e')]['length']?_0x51db4f[_0x985b('0x3e')]:_0x28f2c7[_0x985b('0x39')];_0x51db4f[_0x985b('0x41')]=qs[_0x985b('0x42')](_0x93a86f[_0x985b('0x3a')][_0x985b('0x42')]);_0x51db4f['where']=qs[_0x985b('0x3c')](_['pick'](_0x93a86f['query'],_0x28f2c7[_0x985b('0x3c')]));if(_0x93a86f[_0x985b('0x3a')][_0x985b('0x48')]){_0x51db4f['where']=_[_0x985b('0x45')](_0x51db4f[_0x985b('0x43')],{'$or':_['map'](_0x51db4f['attributes'],function(_0x15170f){var _0xc3ae1a={};_0xc3ae1a[_0x15170f]={'$like':'%'+_0x93a86f[_0x985b('0x3a')]['filter']+'%'};return _0xc3ae1a;})});}_0x51db4f=_[_0x985b('0x45')]({},_0x51db4f,_0x93a86f['options']);return _0x11cd2a[_0x985b('0x6a')](_0x51db4f);}})[_0x985b('0x2c')](function(_0x32aa47){if(_0x32aa47){_0x4dbc14=_0x32aa47[_0x985b('0x40')];if(!_0x93a86f[_0x985b('0x3a')][_0x985b('0x5c')](_0x985b('0x6b'))){_0x51db4f['limit']=qs[_0x985b('0x26')](_0x93a86f['query'][_0x985b('0x26')]);_0x51db4f[_0x985b('0x25')]=qs[_0x985b('0x25')](_0x93a86f[_0x985b('0x3a')][_0x985b('0x25')]);}return _0x11cd2a[_0x985b('0x6a')](_0x51db4f);}})[_0x985b('0x2c')](function(_0x3c9614){if(_0x3c9614){return _0x3c9614?{'count':_0x4dbc14,'rows':_0x3c9614}:null;}})[_0x985b('0x2c')](respondWithResult(_0x574e32,null))[_0x985b('0x4e')](handleError(_0x574e32,null));};exports['addTeams']=function(_0x1777e4,_0x5a118a,_0x45e593){var _0x350249=_0x1777e4[_0x985b('0x50')][_0x985b('0x6c')];return db[_0x985b('0x69')][_0x985b('0x4d')]({'where':{'id':_0x350249},'attributes':['id'],'include':[{'model':db[_0x985b('0x5f')],'as':_0x985b('0x6d'),'attributes':['id',_0x985b('0x32'),'online',_0x985b('0x6e'),_0x985b('0x6f')],'raw':!![]}]})[_0x985b('0x2c')](function(_0x574ad7){if(_0x574ad7){var _0x2b7754=_[_0x985b('0x70')](_0x574ad7,function(_0x28f150){var _0x925fd7=_0x28f150[_0x985b('0x2e')]({'plain':!![]});return _0x925fd7[_0x985b('0x6d')];});return db[_0x985b('0x36')][_0x985b('0x54')]({'where':{'id':_0x1777e4['params']['id']}})['then'](function(_0x54ea5f){return db[_0x985b('0x71')][_0x985b('0x72')](function(_0x4dfd46){return _0x54ea5f[_0x985b('0x73')](_0x350249,{'transaction':_0x4dfd46})['then'](function(){return BPromise[_0x985b('0x74')](_0x2b7754,function(_0x32c7a3){return db[_0x985b('0x5e')][_0x985b('0x75')]({'where':{'UserId':_0x32c7a3['id'],'OpenchannelQueueId':_0x1777e4['params']['id']},'transaction':_0x4dfd46});});})[_0x985b('0x2c')](function(){_0x2b7754[_0x985b('0x76')](function(_0x2c6f09){socket[_0x985b('0x77')](_0x985b('0x78'),{'UserId':_0x2c6f09['id'],'OpenchannelQueueId':_0x54ea5f['id']});});});});});}})[_0x985b('0x2c')](respondWithStatusCode(_0x5a118a,null))['catch'](handleError(_0x5a118a,null));};exports[_0x985b('0x79')]=function(_0x5e5b97,_0xd4ec33,_0xfcf8de){return db[_0x985b('0x69')][_0x985b('0x4d')]({'where':{'id':_0x5e5b97[_0x985b('0x3a')][_0x985b('0x6c')]},'attributes':['id'],'include':[{'model':db[_0x985b('0x5f')],'as':_0x985b('0x6d'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0xd4ec33,null))[_0x985b('0x2c')](function(_0x36f423){var _0x23a63a=_[_0x985b('0x35')](_0x36f423,'id');var _0x55cb24=[];var _0x54b6a5=[];var _0x363e5d=squel['select']();_0x363e5d['field'](_0x985b('0x7a'))[_0x985b('0x7b')]('team_has_openchannel_queues','tq')['join'](_0x985b('0x7c'),'ut',_0x985b('0x7d'))[_0x985b('0x43')](_0x985b('0x7e'),_0x5e5b97[_0x985b('0x59')]['id']);for(var _0x1c33a3=0x0;_0x1c33a3<_0x36f423['length'];_0x1c33a3+=0x1){let _0x504eb2=_0x36f423[_0x1c33a3];for(var _0x4291cf=0x0;_0x4291cf<_0x504eb2[_0x985b('0x6d')][_0x985b('0x40')];_0x4291cf+=0x1){let _0x3d655a=_0x504eb2[_0x985b('0x6d')][_0x4291cf];var _0x499813=_0x363e5d[_0x985b('0x7f')]();_0x499813[_0x985b('0x43')](_0x985b('0x80'),_0x3d655a['id']);_0x54b6a5[_0x985b('0x81')](db[_0x985b('0x71')][_0x985b('0x3a')](_0x499813['toString'](),{'type':db[_0x985b('0x71')][_0x985b('0x82')][_0x985b('0x83')]})['then'](function(_0x4eaafd){if(_0x4eaafd['length']===0x1){return _0x3d655a['id'];}else{var _0x29d9b9=_[_0x985b('0x84')](_[_0x985b('0x35')](_0x4eaafd,_0x985b('0x85')),function(_0xff846b){return _[_0x985b('0x86')](_0x23a63a,_0xff846b);});if(_0x29d9b9){return _0x3d655a['id'];}}}));}}return BPromise[_0x985b('0x87')](_0x54b6a5)[_0x985b('0x2c')](function(_0x517e19){_0x55cb24=_(_0x55cb24)[_0x985b('0x88')](_0x517e19)[_0x985b('0x89')]()[_0x985b('0x8a')]();return db[_0x985b('0x36')][_0x985b('0x54')]({'where':{'id':_0x5e5b97['params']['id']}})[_0x985b('0x2c')](function(_0x1427e4){return db[_0x985b('0x71')][_0x985b('0x72')](function(_0x29a6a4){return _0x1427e4['removeTeams'](_0x5e5b97[_0x985b('0x3a')]['ids'],{'transaction':_0x29a6a4})[_0x985b('0x2c')](function(){if(!_[_0x985b('0x8b')](_0x55cb24)){return _0x1427e4[_0x985b('0x8c')](_0x55cb24,{'transaction':_0x29a6a4});}})['then'](function(){_0x55cb24[_0x985b('0x76')](function(_0x2aca0f){socket[_0x985b('0x77')]('userOpenchannelQueue:remove',{'UserId':_0x2aca0f,'OpenchannelQueueId':_0x1427e4['id']});});});});});});})[_0x985b('0x2c')](respondWithStatusCode(_0xd4ec33,null))[_0x985b('0x4e')](handleError(_0xd4ec33,null));};exports['addAgents']=function(_0x5f140f,_0x2c126c,_0xf83486){return db[_0x985b('0x36')][_0x985b('0x54')]({'where':{'id':_0x5f140f[_0x985b('0x59')]['id']}})[_0x985b('0x2c')](handleEntityNotFound(_0x2c126c,null))[_0x985b('0x2c')](function(_0x27428e){if(_0x27428e){return _0x27428e[_0x985b('0x8d')](_0x5f140f['body'][_0x985b('0x6c')],_[_0x985b('0x8e')](_0x5f140f[_0x985b('0x50')],[_0x985b('0x6c'),'id'])||{})[_0x985b('0x8f')](function(_0x5b0a33){for(var _0x586c43=0x0;_0x586c43<_0x5f140f[_0x985b('0x50')][_0x985b('0x6c')][_0x985b('0x40')];_0x586c43+=0x1){socket[_0x985b('0x77')](_0x985b('0x78'),{'UserId':_0x5f140f['body'][_0x985b('0x6c')][_0x586c43],'OpenchannelQueueId':_0x5f140f['params']['id']});}return _0x5b0a33;});}})[_0x985b('0x2c')](respondWithResult(_0x2c126c,null))['catch'](handleError(_0x2c126c,null));};exports[_0x985b('0x8c')]=function(_0x2979b9,_0x1135e7,_0x1cbc54){return db[_0x985b('0x36')][_0x985b('0x54')]({'where':{'id':_0x2979b9['params']['id']}})['then'](handleEntityNotFound(_0x1135e7,null))['then'](function(_0x37412f){if(_0x37412f){return _0x37412f[_0x985b('0x8c')](_0x2979b9[_0x985b('0x3a')][_0x985b('0x6c')])['then'](function(){if(_[_0x985b('0x90')](_0x2979b9['query'][_0x985b('0x6c')])){for(var _0xc220cc=0x0;_0xc220cc<_0x2979b9[_0x985b('0x3a')]['ids']['length'];_0xc220cc+=0x1){socket['emit'](_0x985b('0x91'),{'UserId':Number(_0x2979b9[_0x985b('0x3a')]['ids'][_0xc220cc]),'OpenchannelQueueId':Number(_0x2979b9[_0x985b('0x59')]['id'])});}}else{socket[_0x985b('0x77')](_0x985b('0x91'),{'UserId':Number(_0x2979b9[_0x985b('0x3a')][_0x985b('0x6c')]),'OpenchannelQueueId':Number(_0x2979b9[_0x985b('0x59')]['id'])});}});}})[_0x985b('0x2c')](respondWithStatusCode(_0x1135e7,null))[_0x985b('0x4e')](handleError(_0x1135e7,null));};exports['getAgents']=function(_0x544f7e,_0x4b921c,_0x3c03f9){var _0x563457={};var _0x2c6a65={};var _0x3c1e3e;var _0x42787f;return db[_0x985b('0x36')][_0x985b('0x68')]({'where':{'id':_0x544f7e['params']['id']}})[_0x985b('0x2c')](handleEntityNotFound(_0x4b921c,null))['then'](function(_0x11a719){if(_0x11a719){_0x3c1e3e=_0x11a719;_0x2c6a65['model']=_['keys'](db['User'][_0x985b('0x37')]);_0x2c6a65[_0x985b('0x3a')]=_[_0x985b('0x3b')](_0x544f7e[_0x985b('0x3a')]);_0x2c6a65['filters']=_[_0x985b('0x3d')](_0x2c6a65[_0x985b('0x39')],_0x2c6a65[_0x985b('0x3a')]);_0x563457[_0x985b('0x3e')]=_[_0x985b('0x3d')](_0x2c6a65[_0x985b('0x39')],qs[_0x985b('0x3f')](_0x544f7e[_0x985b('0x3a')]['fields']));_0x563457[_0x985b('0x3e')]=_0x563457[_0x985b('0x3e')]['length']?_0x563457[_0x985b('0x3e')]:_0x2c6a65[_0x985b('0x39')];_0x563457['order']=qs[_0x985b('0x42')](_0x544f7e['query']['sort']);_0x563457[_0x985b('0x43')]=qs[_0x985b('0x3c')](_['pick'](_0x544f7e[_0x985b('0x3a')],_0x2c6a65[_0x985b('0x3c')]));if(_0x544f7e[_0x985b('0x3a')][_0x985b('0x48')]){_0x563457[_0x985b('0x43')]=_['merge'](_0x563457['where'],{'$or':_[_0x985b('0x35')](_0x563457[_0x985b('0x3e')],function(_0x51da05){var _0x3b384a={};_0x3b384a[_0x51da05]={'$like':'%'+_0x544f7e[_0x985b('0x3a')][_0x985b('0x48')]+'%'};return _0x3b384a;})});}_0x563457=_[_0x985b('0x45')]({},_0x563457,_0x544f7e[_0x985b('0x49')]);return _0x3c1e3e[_0x985b('0x92')](_0x563457);}})[_0x985b('0x2c')](function(_0x5b385a){if(_0x5b385a){_0x42787f=_0x5b385a[_0x985b('0x40')];if(!_0x544f7e[_0x985b('0x3a')][_0x985b('0x5c')](_0x985b('0x6b'))){_0x563457['limit']=qs[_0x985b('0x26')](_0x544f7e[_0x985b('0x3a')][_0x985b('0x26')]);_0x563457[_0x985b('0x25')]=qs[_0x985b('0x25')](_0x544f7e[_0x985b('0x3a')]['offset']);}return _0x3c1e3e[_0x985b('0x92')](_0x563457);}})['then'](function(_0x494947){if(_0x494947){return _0x494947?{'count':_0x42787f,'rows':_0x494947}:null;}})['then'](respondWithResult(_0x4b921c,null))[_0x985b('0x4e')](handleError(_0x4b921c,null));};
\ No newline at end of file
+var _0xf178=['fields','attributes','length','include','merge','options','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','find','userProfileId','UserProfileResource','describe','findOne','keys','UserOpenchannelQueue','hasOwnProperty','nolimit','sort','where','filters','OpenchannelQueueId','filter','findAndCountAll','agent','openchannelPause','format','%s/%s','createdAt','updatedAt','getTeams','Team','order','ids','Agents','online','voicePause','flatMap','sequelize','transaction','addTeams','each','findOrCreate','forEach','emit','removeTeams','User','select','field','tq.TeamId','from','team_has_openchannel_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','every','TeamId','all','union','isEmpty','removeAgents','userOpenchannelQueue:remove','omit','userOpenchannelQueue:save','isArray','getAgents','pick','bluebird','util','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','sendStatus','status','end','offset','undefined','count','limit','set','Content-Range','json','update','then','destroy','OpenchannelQueues','error','stack','name','index','map','OpenchannelQueue','rawAttributes','fieldName','query','findAll','rows','catch','params','model','intersection'];(function(_0x49a694,_0x281f2d){var _0x13db1e=function(_0xcc3fdc){while(--_0xcc3fdc){_0x49a694['push'](_0x49a694['shift']());}};_0x13db1e(++_0x281f2d);}(_0xf178,0x1b0));var _0x8f17=function(_0x4b1012,_0x1415eb){_0x4b1012=_0x4b1012-0x0;var _0x23d715=_0xf178[_0x4b1012];return _0x23d715;};'use strict';var BPromise=require(_0x8f17('0x0'));var util=require(_0x8f17('0x1'));var _=require('lodash');var squel=require(_0x8f17('0x2'));var Redis=require(_0x8f17('0x3'));var qs=require(_0x8f17('0x4'));var logger=require(_0x8f17('0x5'))(_0x8f17('0x6'));var config=require(_0x8f17('0x7'));var db=require(_0x8f17('0x8'))['db'];config[_0x8f17('0x9')]=_[_0x8f17('0xa')](config[_0x8f17('0x9')],{'host':_0x8f17('0xb'),'port':0x18eb});var socket=require(_0x8f17('0xc'))(new Redis(config[_0x8f17('0x9')]));require(_0x8f17('0xd'))[_0x8f17('0xe')](socket);function respondWithStatusCode(_0x436378,_0x54929c){_0x54929c=_0x54929c||0xcc;return function(_0x1cb313){if(_0x1cb313){return _0x436378[_0x8f17('0xf')](_0x54929c);}return _0x436378[_0x8f17('0x10')](_0x54929c)[_0x8f17('0x11')]();};}function respondWithResult(_0x27df23,_0x3381fa){_0x3381fa=_0x3381fa||0xc8;return function(_0x3e5a4f){if(_0x3e5a4f){return _0x27df23[_0x8f17('0x10')](_0x3381fa)['json'](_0x3e5a4f);}};}function respondWithFilteredResult(_0x10f908,_0x2ba1f0){return function(_0x1e9ffa){if(_0x1e9ffa){var _0x2d05ea=typeof _0x2ba1f0[_0x8f17('0x12')]===_0x8f17('0x13')&&typeof _0x2ba1f0['limit']==='undefined';var _0x50ba79=_0x1e9ffa[_0x8f17('0x14')];var _0x14fc71=_0x2d05ea?0x0:_0x2ba1f0[_0x8f17('0x12')];var _0x1dc5fe=_0x2d05ea?_0x1e9ffa[_0x8f17('0x14')]:_0x2ba1f0['offset']+_0x2ba1f0[_0x8f17('0x15')];var _0x1ce889;if(_0x1dc5fe>=_0x50ba79){_0x1dc5fe=_0x50ba79;_0x1ce889=0xc8;}else{_0x1ce889=0xce;}_0x10f908['status'](_0x1ce889);return _0x10f908[_0x8f17('0x16')](_0x8f17('0x17'),_0x14fc71+'-'+_0x1dc5fe+'/'+_0x50ba79)[_0x8f17('0x18')](_0x1e9ffa);}return null;};}function saveUpdates(_0x5eb1c0){return function(_0x1446c8){if(_0x1446c8){return _0x1446c8[_0x8f17('0x19')](_0x5eb1c0)[_0x8f17('0x1a')](function(_0x48dd84){return _0x48dd84;});}return null;};}function removeEntity(_0x18b9ff){return function(_0x261c6f){if(_0x261c6f){return _0x261c6f[_0x8f17('0x1b')]()[_0x8f17('0x1a')](function(){var _0x335d69=_0x261c6f['get']({'plain':!![]});var _0x4b88b3=_0x8f17('0x1c');return db['UserProfileResource'][_0x8f17('0x1b')]({'where':{'type':_0x4b88b3,'resourceId':_0x335d69['id']}})[_0x8f17('0x1a')](function(){return _0x261c6f;});})['then'](function(){_0x18b9ff[_0x8f17('0x10')](0xcc)['end']();});}};}function handleEntityNotFound(_0x367f74){return function(_0x40f841){if(!_0x40f841){_0x367f74[_0x8f17('0xf')](0x194);}return _0x40f841;};}function handleError(_0x67ea16,_0x3fa58a){_0x3fa58a=_0x3fa58a||0x1f4;return function(_0x5c2772){logger[_0x8f17('0x1d')](_0x5c2772[_0x8f17('0x1e')]);if(_0x5c2772[_0x8f17('0x1f')]){delete _0x5c2772[_0x8f17('0x1f')];}_0x67ea16[_0x8f17('0x10')](_0x3fa58a)['send'](_0x5c2772);};}exports[_0x8f17('0x20')]=function(_0x5d2bfd,_0x14d417){var _0x402296={};var _0x29e7ab={'count':0x0,'rows':[]};var _0x530e16=_[_0x8f17('0x21')](db[_0x8f17('0x22')][_0x8f17('0x23')],function(_0x1ec63c){return{'name':_0x1ec63c[_0x8f17('0x24')],'type':_0x1ec63c['type']['key']};});_0x402296=qs['getOptions'](_0x530e16,_0x5d2bfd);var _0x5aae25={'where':_0x402296['where']};return db[_0x8f17('0x22')][_0x8f17('0x14')](_0x5aae25)['then'](function(_0xcdce95){_0x29e7ab[_0x8f17('0x14')]=_0xcdce95;_0x402296['include']=qs['include'](_0x5d2bfd[_0x8f17('0x25')]);return db[_0x8f17('0x22')][_0x8f17('0x26')](_0x402296);})[_0x8f17('0x1a')](function(_0x2cf142){_0x29e7ab[_0x8f17('0x27')]=_0x2cf142;return _0x29e7ab;})[_0x8f17('0x1a')](respondWithFilteredResult(_0x14d417,_0x402296))[_0x8f17('0x28')](handleError(_0x14d417,null));};exports['show']=function(_0x36b886,_0x371f6d){var _0x50fd5a={'raw':!![],'where':{'id':_0x36b886[_0x8f17('0x29')]['id']}},_0x3669a8={};_0x3669a8[_0x8f17('0x2a')]=_['keys'](db[_0x8f17('0x22')][_0x8f17('0x23')]);_0x3669a8[_0x8f17('0x25')]=_['keys'](_0x36b886[_0x8f17('0x25')]);_0x3669a8['filters']=_[_0x8f17('0x2b')](_0x3669a8['model'],_0x3669a8[_0x8f17('0x25')]);_0x50fd5a['attributes']=_[_0x8f17('0x2b')](_0x3669a8['model'],qs['fields'](_0x36b886[_0x8f17('0x25')][_0x8f17('0x2c')]));_0x50fd5a['attributes']=_0x50fd5a[_0x8f17('0x2d')][_0x8f17('0x2e')]?_0x50fd5a['attributes']:_0x3669a8['model'];if(_0x36b886[_0x8f17('0x25')]['includeAll']){_0x50fd5a[_0x8f17('0x2f')]=[{'all':!![]}];}_0x50fd5a=_[_0x8f17('0x30')]({},_0x50fd5a,_0x36b886[_0x8f17('0x31')]);return db[_0x8f17('0x22')]['find'](_0x50fd5a)['then'](handleEntityNotFound(_0x371f6d,null))['then'](respondWithResult(_0x371f6d,null))['catch'](handleError(_0x371f6d,null));};exports[_0x8f17('0x32')]=function(_0x5c2007,_0x43ae5c){return db['OpenchannelQueue'][_0x8f17('0x32')](_0x5c2007[_0x8f17('0x33')],{})[_0x8f17('0x1a')](function(_0x1bd662){var _0x1abcca=_0x5c2007[_0x8f17('0x34')][_0x8f17('0x35')]({'plain':!![]});if(!_0x1abcca)throw new Error(_0x8f17('0x36'));if(_0x1abcca[_0x8f17('0x37')]==='user'){var _0xb0688a=_0x1bd662[_0x8f17('0x35')]({'plain':!![]});var _0x239c5f=_0x8f17('0x1c');return db['UserProfileSection'][_0x8f17('0x38')]({'where':{'name':_0x239c5f,'userProfileId':_0x1abcca[_0x8f17('0x39')]},'raw':!![]})[_0x8f17('0x1a')](function(_0x1799ac){if(_0x1799ac&&_0x1799ac['autoAssociation']===0x0){return db[_0x8f17('0x3a')]['create']({'name':_0xb0688a[_0x8f17('0x1f')],'resourceId':_0xb0688a['id'],'type':_0x1799ac['name'],'sectionId':_0x1799ac['id']},{})[_0x8f17('0x1a')](function(){return _0x1bd662;});}else{return _0x1bd662;}})[_0x8f17('0x28')](function(_0x3e2f18){logger[_0x8f17('0x1d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3e2f18);throw _0x3e2f18;});}return _0x1bd662;})[_0x8f17('0x1a')](respondWithResult(_0x43ae5c,0xc9))[_0x8f17('0x28')](handleError(_0x43ae5c,null));};exports[_0x8f17('0x19')]=function(_0x57f04f,_0x626e3e){if(_0x57f04f[_0x8f17('0x33')]['id']){delete _0x57f04f[_0x8f17('0x33')]['id'];}return db[_0x8f17('0x22')][_0x8f17('0x38')]({'where':{'id':_0x57f04f['params']['id']}})['then'](handleEntityNotFound(_0x626e3e,null))[_0x8f17('0x1a')](saveUpdates(_0x57f04f[_0x8f17('0x33')],null))[_0x8f17('0x1a')](respondWithResult(_0x626e3e,null))[_0x8f17('0x28')](handleError(_0x626e3e,null));};exports[_0x8f17('0x1b')]=function(_0x1b7f91,_0x2e5b22){return db['OpenchannelQueue'][_0x8f17('0x38')]({'where':{'id':_0x1b7f91['params']['id']}})[_0x8f17('0x1a')](handleEntityNotFound(_0x2e5b22,null))[_0x8f17('0x1a')](removeEntity(_0x2e5b22,null))[_0x8f17('0x28')](handleError(_0x2e5b22,null));};exports[_0x8f17('0x3b')]=function(_0x649c5b,_0xdffe03){return db[_0x8f17('0x22')][_0x8f17('0x3b')]()[_0x8f17('0x1a')](respondWithResult(_0xdffe03,null))['catch'](handleError(_0xdffe03,null));};exports['getMembers']=function(_0x2470d9,_0x145c12){var _0x3a5c5e={'raw':!![],'where':{}},_0x4de61b={},_0x1c94c9;return db[_0x8f17('0x22')][_0x8f17('0x3c')]({'where':{'id':_0x2470d9[_0x8f17('0x29')]['id']}})[_0x8f17('0x1a')](handleEntityNotFound(_0x145c12,null))[_0x8f17('0x1a')](function(_0x4cf91e){if(_0x4cf91e){_0x1c94c9=_0x4cf91e[_0x8f17('0x35')]({'plain':!![]});_0x4de61b[_0x8f17('0x2a')]=_[_0x8f17('0x3d')](db[_0x8f17('0x3e')]['rawAttributes']);_0x4de61b['query']=_['keys'](_0x2470d9[_0x8f17('0x25')]);_0x4de61b['filters']=_[_0x8f17('0x2b')](_0x4de61b[_0x8f17('0x2a')],_0x4de61b[_0x8f17('0x25')]);_0x3a5c5e[_0x8f17('0x2d')]=_[_0x8f17('0x2b')](_0x4de61b[_0x8f17('0x2a')],qs[_0x8f17('0x2c')](_0x2470d9[_0x8f17('0x25')][_0x8f17('0x2c')]));_0x3a5c5e[_0x8f17('0x2d')]=_0x3a5c5e[_0x8f17('0x2d')][_0x8f17('0x2e')]?_0x3a5c5e['attributes']:_0x4de61b['model'];if(!_0x2470d9[_0x8f17('0x25')][_0x8f17('0x3f')](_0x8f17('0x40'))){_0x3a5c5e[_0x8f17('0x15')]=qs[_0x8f17('0x15')](_0x2470d9['query'][_0x8f17('0x15')]);_0x3a5c5e[_0x8f17('0x12')]=qs[_0x8f17('0x12')](_0x2470d9[_0x8f17('0x25')][_0x8f17('0x12')]);}_0x3a5c5e['order']=qs[_0x8f17('0x41')](_0x2470d9['query']['sort']);_0x3a5c5e[_0x8f17('0x42')]=qs[_0x8f17('0x43')](_['pick'](_0x2470d9[_0x8f17('0x25')],_0x4de61b['filters']));_0x3a5c5e[_0x8f17('0x42')][_0x8f17('0x44')]=_0x4cf91e['id'];if(_0x2470d9[_0x8f17('0x25')][_0x8f17('0x45')]){_0x3a5c5e[_0x8f17('0x42')]=_[_0x8f17('0x30')](_0x3a5c5e[_0x8f17('0x42')],{'$or':_['map'](_0x3a5c5e[_0x8f17('0x2d')],function(_0xd2522a){var _0x248bb6={};_0x248bb6[_0xd2522a]={'$like':'%'+_0x2470d9[_0x8f17('0x25')][_0x8f17('0x45')]+'%'};return _0x248bb6;})});}_0x3a5c5e=_['merge']({},_0x3a5c5e,_0x2470d9[_0x8f17('0x31')]);return db[_0x8f17('0x3e')][_0x8f17('0x26')](_0x3a5c5e);}})['then'](function(_0x3650a3){if(_0x3650a3){return db['User'][_0x8f17('0x46')]({'where':{'id':_[_0x8f17('0x21')](_0x3650a3,'UserId'),'role':_0x8f17('0x47')},'attributes':['id','name',_0x8f17('0x48'),'updatedAt','createdAt']});}})[_0x8f17('0x1a')](function(_0x5c4546){if(_0x5c4546){return{'count':_0x5c4546['count'],'rows':_[_0x8f17('0x21')](_0x5c4546[_0x8f17('0x27')],function(_0x3e15f0){return{'membername':_0x3e15f0['name'],'UserId':_0x3e15f0['id'],'queue_name':_0x1c94c9[_0x8f17('0x1f')],'OpenchannelQueueId':_0x1c94c9['id'],'interface':util[_0x8f17('0x49')](_0x8f17('0x4a'),'SIP',_0x3e15f0[_0x8f17('0x1f')]),'penalty':0x0,'paused':_0x3e15f0[_0x8f17('0x48')],'createdAt':_0x3e15f0[_0x8f17('0x4b')],'updatedAt':_0x3e15f0[_0x8f17('0x4c')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x145c12,_0x3a5c5e))[_0x8f17('0x28')](handleError(_0x145c12,null));};exports[_0x8f17('0x4d')]=function(_0x175ed2,_0x50ce33){var _0x4c5f1e={};var _0x4ab467={};var _0x50456d;var _0x54bbc3;return db[_0x8f17('0x22')][_0x8f17('0x3c')]({'where':{'id':_0x175ed2[_0x8f17('0x29')]['id']}})['then'](handleEntityNotFound(_0x50ce33,null))[_0x8f17('0x1a')](function(_0x53f53a){if(_0x53f53a){_0x50456d=_0x53f53a;_0x4ab467[_0x8f17('0x2a')]=_[_0x8f17('0x3d')](db[_0x8f17('0x4e')][_0x8f17('0x23')]);_0x4ab467[_0x8f17('0x25')]=_['keys'](_0x175ed2['query']);_0x4ab467[_0x8f17('0x43')]=_[_0x8f17('0x2b')](_0x4ab467[_0x8f17('0x2a')],_0x4ab467[_0x8f17('0x25')]);_0x4c5f1e[_0x8f17('0x2d')]=_[_0x8f17('0x2b')](_0x4ab467[_0x8f17('0x2a')],qs[_0x8f17('0x2c')](_0x175ed2[_0x8f17('0x25')][_0x8f17('0x2c')]));_0x4c5f1e[_0x8f17('0x2d')]=_0x4c5f1e['attributes'][_0x8f17('0x2e')]?_0x4c5f1e[_0x8f17('0x2d')]:_0x4ab467[_0x8f17('0x2a')];_0x4c5f1e[_0x8f17('0x4f')]=qs[_0x8f17('0x41')](_0x175ed2['query'][_0x8f17('0x41')]);_0x4c5f1e[_0x8f17('0x42')]=qs[_0x8f17('0x43')](_['pick'](_0x175ed2[_0x8f17('0x25')],_0x4ab467[_0x8f17('0x43')]));if(_0x175ed2[_0x8f17('0x25')][_0x8f17('0x45')]){_0x4c5f1e['where']=_[_0x8f17('0x30')](_0x4c5f1e[_0x8f17('0x42')],{'$or':_['map'](_0x4c5f1e[_0x8f17('0x2d')],function(_0x52f858){var _0x5bc97a={};_0x5bc97a[_0x52f858]={'$like':'%'+_0x175ed2['query']['filter']+'%'};return _0x5bc97a;})});}_0x4c5f1e=_['merge']({},_0x4c5f1e,_0x175ed2[_0x8f17('0x31')]);return _0x50456d[_0x8f17('0x4d')](_0x4c5f1e);}})[_0x8f17('0x1a')](function(_0xbe8d5){if(_0xbe8d5){_0x54bbc3=_0xbe8d5['length'];if(!_0x175ed2[_0x8f17('0x25')][_0x8f17('0x3f')]('nolimit')){_0x4c5f1e['limit']=qs[_0x8f17('0x15')](_0x175ed2['query'][_0x8f17('0x15')]);_0x4c5f1e[_0x8f17('0x12')]=qs['offset'](_0x175ed2[_0x8f17('0x25')][_0x8f17('0x12')]);}return _0x50456d[_0x8f17('0x4d')](_0x4c5f1e);}})[_0x8f17('0x1a')](function(_0x56ed76){if(_0x56ed76){return _0x56ed76?{'count':_0x54bbc3,'rows':_0x56ed76}:null;}})[_0x8f17('0x1a')](respondWithResult(_0x50ce33,null))[_0x8f17('0x28')](handleError(_0x50ce33,null));};exports['addTeams']=function(_0x27f995,_0x1d7c53){var _0x559075=_0x27f995[_0x8f17('0x33')][_0x8f17('0x50')];return db[_0x8f17('0x4e')][_0x8f17('0x26')]({'where':{'id':_0x559075},'attributes':['id'],'include':[{'model':db['User'],'as':_0x8f17('0x51'),'attributes':['id',_0x8f17('0x1f'),_0x8f17('0x52'),_0x8f17('0x53'),'interface'],'raw':!![]}]})['then'](function(_0x13bf8){if(_0x13bf8){var _0x4010f5=_[_0x8f17('0x54')](_0x13bf8,function(_0x2f1b14){var _0x3a34b9=_0x2f1b14['get']({'plain':!![]});return _0x3a34b9['Agents'];});return db[_0x8f17('0x22')][_0x8f17('0x38')]({'where':{'id':_0x27f995[_0x8f17('0x29')]['id']}})[_0x8f17('0x1a')](function(_0x42f5dd){return db[_0x8f17('0x55')][_0x8f17('0x56')](function(_0x2867c9){return _0x42f5dd[_0x8f17('0x57')](_0x559075,{'transaction':_0x2867c9})[_0x8f17('0x1a')](function(){return BPromise[_0x8f17('0x58')](_0x4010f5,function(_0x33791a){return db[_0x8f17('0x3e')][_0x8f17('0x59')]({'where':{'UserId':_0x33791a['id'],'OpenchannelQueueId':_0x27f995['params']['id']},'transaction':_0x2867c9});});})[_0x8f17('0x1a')](function(){_0x4010f5[_0x8f17('0x5a')](function(_0x4ab490){socket[_0x8f17('0x5b')]('userOpenchannelQueue:save',{'UserId':_0x4ab490['id'],'OpenchannelQueueId':_0x42f5dd['id']});});});});});}})[_0x8f17('0x1a')](respondWithStatusCode(_0x1d7c53,null))[_0x8f17('0x28')](handleError(_0x1d7c53,null));};exports[_0x8f17('0x5c')]=function(_0x276954,_0x172eab){return db[_0x8f17('0x4e')][_0x8f17('0x26')]({'where':{'id':_0x276954[_0x8f17('0x25')]['ids']},'attributes':['id'],'include':[{'model':db[_0x8f17('0x5d')],'as':_0x8f17('0x51'),'attributes':['id'],'raw':!![]}]})[_0x8f17('0x1a')](handleEntityNotFound(_0x172eab,null))[_0x8f17('0x1a')](function(_0x4480be){var _0x359a11=_[_0x8f17('0x21')](_0x4480be,'id');var _0x125fdd=[];var _0x13d796=[];var _0x465ad6=squel[_0x8f17('0x5e')]();_0x465ad6[_0x8f17('0x5f')](_0x8f17('0x60'))[_0x8f17('0x61')](_0x8f17('0x62'),'tq')['join'](_0x8f17('0x63'),'ut',_0x8f17('0x64'))[_0x8f17('0x42')](_0x8f17('0x65'),_0x276954['params']['id']);for(var _0x533943=0x0;_0x533943<_0x4480be[_0x8f17('0x2e')];_0x533943+=0x1){let _0x41ab89=_0x4480be[_0x533943];for(var _0x504b67=0x0;_0x504b67<_0x41ab89[_0x8f17('0x51')]['length'];_0x504b67+=0x1){let _0x5da659=_0x41ab89[_0x8f17('0x51')][_0x504b67];var _0x29b089=_0x465ad6[_0x8f17('0x66')]();_0x29b089['where'](_0x8f17('0x67'),_0x5da659['id']);_0x13d796[_0x8f17('0x68')](db[_0x8f17('0x55')]['query'](_0x29b089['toString'](),{'type':db[_0x8f17('0x55')][_0x8f17('0x69')][_0x8f17('0x6a')]})[_0x8f17('0x1a')](function(_0x420a4b){if(_0x420a4b[_0x8f17('0x2e')]===0x1){return _0x5da659['id'];}else{var _0x2f3c47=_[_0x8f17('0x6b')](_['map'](_0x420a4b,_0x8f17('0x6c')),function(_0x20098f){return _['includes'](_0x359a11,_0x20098f);});if(_0x2f3c47){return _0x5da659['id'];}}}));}}return BPromise[_0x8f17('0x6d')](_0x13d796)[_0x8f17('0x1a')](function(_0x7e4fb){_0x125fdd=_(_0x125fdd)[_0x8f17('0x6e')](_0x7e4fb)['compact']()['value']();return db['OpenchannelQueue']['find']({'where':{'id':_0x276954[_0x8f17('0x29')]['id']}})[_0x8f17('0x1a')](function(_0x51110a){return db[_0x8f17('0x55')]['transaction'](function(_0x4dfee9){return _0x51110a[_0x8f17('0x5c')](_0x276954['query'][_0x8f17('0x50')],{'transaction':_0x4dfee9})[_0x8f17('0x1a')](function(){if(!_[_0x8f17('0x6f')](_0x125fdd)){return _0x51110a[_0x8f17('0x70')](_0x125fdd,{'transaction':_0x4dfee9});}})['then'](function(){_0x125fdd[_0x8f17('0x5a')](function(_0x1160d7){socket[_0x8f17('0x5b')](_0x8f17('0x71'),{'UserId':_0x1160d7,'OpenchannelQueueId':_0x51110a['id']});});});});});});})[_0x8f17('0x1a')](respondWithStatusCode(_0x172eab,null))[_0x8f17('0x28')](handleError(_0x172eab,null));};exports['addAgents']=function(_0x5ba08e,_0x3d824e){return db['OpenchannelQueue'][_0x8f17('0x38')]({'where':{'id':_0x5ba08e[_0x8f17('0x29')]['id']}})['then'](handleEntityNotFound(_0x3d824e,null))[_0x8f17('0x1a')](function(_0x21a63f){if(_0x21a63f){return _0x21a63f['addAgents'](_0x5ba08e['body']['ids'],_[_0x8f17('0x72')](_0x5ba08e[_0x8f17('0x33')],[_0x8f17('0x50'),'id'])||{})['spread'](function(_0x204f2f){for(var _0x2ef855=0x0;_0x2ef855<_0x5ba08e[_0x8f17('0x33')][_0x8f17('0x50')][_0x8f17('0x2e')];_0x2ef855+=0x1){socket['emit'](_0x8f17('0x73'),{'UserId':Number(_0x5ba08e[_0x8f17('0x33')][_0x8f17('0x50')][_0x2ef855]),'OpenchannelQueueId':Number(_0x5ba08e[_0x8f17('0x29')]['id'])});}return _0x204f2f;});}})[_0x8f17('0x1a')](respondWithResult(_0x3d824e,null))[_0x8f17('0x28')](handleError(_0x3d824e,null));};exports['removeAgents']=function(_0x1818cc,_0x13c18a){return db[_0x8f17('0x22')][_0x8f17('0x38')]({'where':{'id':_0x1818cc[_0x8f17('0x29')]['id']}})[_0x8f17('0x1a')](handleEntityNotFound(_0x13c18a,null))[_0x8f17('0x1a')](function(_0x6c5e65){if(_0x6c5e65){return _0x6c5e65[_0x8f17('0x70')](_0x1818cc[_0x8f17('0x25')][_0x8f17('0x50')])[_0x8f17('0x1a')](function(){if(_[_0x8f17('0x74')](_0x1818cc[_0x8f17('0x25')][_0x8f17('0x50')])){for(var _0x5ca5e1=0x0;_0x5ca5e1<_0x1818cc[_0x8f17('0x25')][_0x8f17('0x50')][_0x8f17('0x2e')];_0x5ca5e1+=0x1){socket['emit'](_0x8f17('0x71'),{'UserId':Number(_0x1818cc['query']['ids'][_0x5ca5e1]),'OpenchannelQueueId':Number(_0x1818cc['params']['id'])});}}else{socket[_0x8f17('0x5b')](_0x8f17('0x71'),{'UserId':Number(_0x1818cc[_0x8f17('0x25')][_0x8f17('0x50')]),'OpenchannelQueueId':Number(_0x1818cc[_0x8f17('0x29')]['id'])});}});}})[_0x8f17('0x1a')](respondWithStatusCode(_0x13c18a,null))['catch'](handleError(_0x13c18a,null));};exports[_0x8f17('0x75')]=function(_0xe5832e,_0x1df4c5){var _0x382cb9={};var _0x33a4fe={};var _0x30cbbc;var _0x28a784;return db['OpenchannelQueue']['findOne']({'where':{'id':_0xe5832e[_0x8f17('0x29')]['id']}})[_0x8f17('0x1a')](handleEntityNotFound(_0x1df4c5,null))[_0x8f17('0x1a')](function(_0x1aa48a){if(_0x1aa48a){_0x30cbbc=_0x1aa48a;_0x33a4fe[_0x8f17('0x2a')]=_[_0x8f17('0x3d')](db[_0x8f17('0x5d')][_0x8f17('0x23')]);_0x33a4fe['query']=_[_0x8f17('0x3d')](_0xe5832e[_0x8f17('0x25')]);_0x33a4fe[_0x8f17('0x43')]=_[_0x8f17('0x2b')](_0x33a4fe[_0x8f17('0x2a')],_0x33a4fe[_0x8f17('0x25')]);_0x382cb9[_0x8f17('0x2d')]=_[_0x8f17('0x2b')](_0x33a4fe[_0x8f17('0x2a')],qs[_0x8f17('0x2c')](_0xe5832e['query']['fields']));_0x382cb9['attributes']=_0x382cb9[_0x8f17('0x2d')][_0x8f17('0x2e')]?_0x382cb9[_0x8f17('0x2d')]:_0x33a4fe[_0x8f17('0x2a')];_0x382cb9[_0x8f17('0x4f')]=qs['sort'](_0xe5832e[_0x8f17('0x25')][_0x8f17('0x41')]);_0x382cb9[_0x8f17('0x42')]=qs[_0x8f17('0x43')](_[_0x8f17('0x76')](_0xe5832e[_0x8f17('0x25')],_0x33a4fe[_0x8f17('0x43')]));if(_0xe5832e[_0x8f17('0x25')]['filter']){_0x382cb9[_0x8f17('0x42')]=_['merge'](_0x382cb9[_0x8f17('0x42')],{'$or':_['map'](_0x382cb9[_0x8f17('0x2d')],function(_0x2121a2){var _0x466bdf={};_0x466bdf[_0x2121a2]={'$like':'%'+_0xe5832e[_0x8f17('0x25')]['filter']+'%'};return _0x466bdf;})});}_0x382cb9=_[_0x8f17('0x30')]({},_0x382cb9,_0xe5832e['options']);return _0x30cbbc['getAgents'](_0x382cb9);}})[_0x8f17('0x1a')](function(_0x4c2331){if(_0x4c2331){_0x28a784=_0x4c2331['length'];if(!_0xe5832e[_0x8f17('0x25')][_0x8f17('0x3f')]('nolimit')){_0x382cb9[_0x8f17('0x15')]=qs[_0x8f17('0x15')](_0xe5832e[_0x8f17('0x25')][_0x8f17('0x15')]);_0x382cb9['offset']=qs[_0x8f17('0x12')](_0xe5832e[_0x8f17('0x25')][_0x8f17('0x12')]);}return _0x30cbbc[_0x8f17('0x75')](_0x382cb9);}})['then'](function(_0x58dcc5){if(_0x58dcc5){return _0x58dcc5?{'count':_0x28a784,'rows':_0x58dcc5}:null;}})[_0x8f17('0x1a')](respondWithResult(_0x1df4c5,null))[_0x8f17('0x28')](handleError(_0x1df4c5,null));};
\ No newline at end of file