Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index 1e417e1..a6d2dff 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7d64=['destroy','get','UserProfileResource','error','stack','name','send','index','map','OpenchannelQueue','fieldName','type','key','model','query','keys','intersection','attributes','fields','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','count','includeAll','include','findAll','rows','catch','show','rawAttributes','create','body','user','role','OpenchannelQueues','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','UserOpenchannelQueue','length','hasOwnProperty','OpenchannelQueueId','options','User','findAndCountAll','UserId','agent','openchannelPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','ids','interface','each','findOrCreate','forEach','emit','userOpenchannelQueue:save','select','field','team_has_openchannel_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','Agents','clone','ut.UserId\x20=\x20?','toString','sequelize','QueryTypes','SELECT','every','TeamId','all','union','compact','transaction','isEmpty','removeAgents','userOpenchannelQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','defaults','redis','localhost','socket.io-emitter','./openchannelQueue.socket','register','sendStatus','status','end','json','offset','limit','set','reject','then'];(function(_0x3dc7a6,_0xc642aa){var _0x1ef266=function(_0x2f6cd5){while(--_0x2f6cd5){_0x3dc7a6['push'](_0x3dc7a6['shift']());}};_0x1ef266(++_0xc642aa);}(_0x7d64,0x67));var _0x47d6=function(_0x3631f5,_0x8040ee){_0x3631f5=_0x3631f5-0x0;var _0x23288f=_0x7d64[_0x3631f5];return _0x23288f;};'use strict';var emlformat=require(_0x47d6('0x0'));var rimraf=require(_0x47d6('0x1'));var zipdir=require(_0x47d6('0x2'));var jsonpatch=require(_0x47d6('0x3'));var rp=require('request-promise');var moment=require(_0x47d6('0x4'));var BPromise=require(_0x47d6('0x5'));var Mustache=require(_0x47d6('0x6'));var util=require(_0x47d6('0x7'));var path=require('path');var sox=require(_0x47d6('0x8'));var csv=require(_0x47d6('0x9'));var ejs=require(_0x47d6('0xa'));var fs=require('fs');var fs_extra=require(_0x47d6('0xb'));var _=require(_0x47d6('0xc'));var squel=require('squel');var crypto=require(_0x47d6('0xd'));var jsforce=require(_0x47d6('0xe'));var deskjs=require(_0x47d6('0xf'));var toCsv=require(_0x47d6('0x9'));var querystring=require(_0x47d6('0x10'));var Papa=require(_0x47d6('0x11'));var Redis=require(_0x47d6('0x12'));var authService=require(_0x47d6('0x13'));var qs=require(_0x47d6('0x14'));var as=require(_0x47d6('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x47d6('0x16'))(_0x47d6('0x17'));var utils=require(_0x47d6('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x47d6('0x19'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x47d6('0x1a')](config[_0x47d6('0x1b')],{'host':_0x47d6('0x1c'),'port':0x18eb});var socket=require(_0x47d6('0x1d'))(new Redis(config[_0x47d6('0x1b')]));require(_0x47d6('0x1e'))[_0x47d6('0x1f')](socket);function respondWithStatusCode(_0x3fae58,_0x233262){_0x233262=_0x233262||0xcc;return function(_0x4488c0){if(_0x4488c0){return _0x3fae58[_0x47d6('0x20')](_0x233262);}return _0x3fae58[_0x47d6('0x21')](_0x233262)[_0x47d6('0x22')]();};}function respondWithResult(_0x171895,_0x11908a){_0x11908a=_0x11908a||0xc8;return function(_0x165d48){if(_0x165d48){return _0x171895[_0x47d6('0x21')](_0x11908a)[_0x47d6('0x23')](_0x165d48);}};}function respondWithFilteredResult(_0x5c47f3,_0x343cf7){return function(_0x4518eb){if(_0x4518eb){var _0x3dad4a=typeof _0x343cf7[_0x47d6('0x24')]==='undefined'&&typeof _0x343cf7[_0x47d6('0x25')]==='undefined';var _0x1178d0=_0x4518eb['count'];var _0xd8dc68=_0x3dad4a?0x0:_0x343cf7[_0x47d6('0x24')];var _0x289781=_0x3dad4a?_0x4518eb['count']:_0x343cf7['offset']+_0x343cf7[_0x47d6('0x25')];var _0x16b253;if(_0x289781>=_0x1178d0){_0x289781=_0x1178d0;_0x16b253=0xc8;}else{_0x16b253=0xce;}_0x5c47f3[_0x47d6('0x21')](_0x16b253);return _0x5c47f3[_0x47d6('0x26')]('Content-Range',_0xd8dc68+'-'+_0x289781+'/'+_0x1178d0)[_0x47d6('0x23')](_0x4518eb);}return null;};}function patchUpdates(_0x389aea){return function(_0x4a6874){try{jsonpatch['apply'](_0x4a6874,_0x389aea,!![]);}catch(_0x4fc424){return BPromise[_0x47d6('0x27')](_0x4fc424);}return _0x4a6874['save']();};}function saveUpdates(_0x45c68b,_0x43cdc7){return function(_0x19a5ba){if(_0x19a5ba){return _0x19a5ba['update'](_0x45c68b)[_0x47d6('0x28')](function(_0x43fdca){return _0x43fdca;});}return null;};}function removeEntity(_0x3ed7f2,_0x3d2af1){return function(_0x6b8167){if(_0x6b8167){return _0x6b8167[_0x47d6('0x29')]()[_0x47d6('0x28')](function(){var _0x2dad97=_0x6b8167[_0x47d6('0x2a')]({'plain':!![]});var _0x52183c='OpenchannelQueues';return db[_0x47d6('0x2b')][_0x47d6('0x29')]({'where':{'type':_0x52183c,'resourceId':_0x2dad97['id']}})['then'](function(){return _0x6b8167;});})['then'](function(){_0x3ed7f2[_0x47d6('0x21')](0xcc)[_0x47d6('0x22')]();});}};}function handleEntityNotFound(_0x1e43d7,_0x4834ae){return function(_0xc91e19){if(!_0xc91e19){_0x1e43d7['sendStatus'](0x194);}return _0xc91e19;};}function handleError(_0x43c2c7,_0x5918f9){_0x5918f9=_0x5918f9||0x1f4;return function(_0x19eb4e){logger[_0x47d6('0x2c')](_0x19eb4e[_0x47d6('0x2d')]);if(_0x19eb4e[_0x47d6('0x2e')]){delete _0x19eb4e['name'];}_0x43c2c7[_0x47d6('0x21')](_0x5918f9)[_0x47d6('0x2f')](_0x19eb4e);};}exports[_0x47d6('0x30')]=function(_0x255830,_0x96f28c){var _0x6c9ecb={},_0xcf17c4={},_0x443f6c={'count':0x0,'rows':[]};var _0x4ef553=_[_0x47d6('0x31')](db[_0x47d6('0x32')]['rawAttributes'],function(_0x54d608){return{'name':_0x54d608[_0x47d6('0x33')],'type':_0x54d608[_0x47d6('0x34')][_0x47d6('0x35')]};});_0xcf17c4[_0x47d6('0x36')]=_[_0x47d6('0x31')](_0x4ef553,_0x47d6('0x2e'));_0xcf17c4[_0x47d6('0x37')]=_[_0x47d6('0x38')](_0x255830['query']);_0xcf17c4['filters']=_[_0x47d6('0x39')](_0xcf17c4['model'],_0xcf17c4['query']);_0x6c9ecb[_0x47d6('0x3a')]=_[_0x47d6('0x39')](_0xcf17c4[_0x47d6('0x36')],qs[_0x47d6('0x3b')](_0x255830[_0x47d6('0x37')]['fields']));_0x6c9ecb['attributes']=_0x6c9ecb[_0x47d6('0x3a')]['length']?_0x6c9ecb[_0x47d6('0x3a')]:_0xcf17c4['model'];if(!_0x255830[_0x47d6('0x37')]['hasOwnProperty'](_0x47d6('0x3c'))){_0x6c9ecb[_0x47d6('0x25')]=qs[_0x47d6('0x25')](_0x255830[_0x47d6('0x37')][_0x47d6('0x25')]);_0x6c9ecb['offset']=qs[_0x47d6('0x24')](_0x255830['query']['offset']);}_0x6c9ecb[_0x47d6('0x3d')]=qs[_0x47d6('0x3e')](_0x255830[_0x47d6('0x37')]['sort']);_0x6c9ecb[_0x47d6('0x3f')]=qs[_0x47d6('0x40')](_[_0x47d6('0x41')](_0x255830[_0x47d6('0x37')],_0xcf17c4[_0x47d6('0x40')]),_0x4ef553);if(_0x255830['query'][_0x47d6('0x42')]){_0x6c9ecb['where']=_[_0x47d6('0x43')](_0x6c9ecb[_0x47d6('0x3f')],{'$or':_[_0x47d6('0x31')](_0x4ef553,function(_0x1fba81){if(_0x1fba81[_0x47d6('0x34')]!==_0x47d6('0x44')){var _0xedec3={};_0xedec3[_0x1fba81['name']]={'$like':'%'+_0x255830[_0x47d6('0x37')][_0x47d6('0x42')]+'%'};return _0xedec3;}})});}_0x6c9ecb=_[_0x47d6('0x43')]({},_0x6c9ecb,_0x255830['options']);var _0x42ceb3={'where':_0x6c9ecb[_0x47d6('0x3f')]};return db[_0x47d6('0x32')][_0x47d6('0x45')](_0x42ceb3)[_0x47d6('0x28')](function(_0x2f623b){_0x443f6c['count']=_0x2f623b;if(_0x255830[_0x47d6('0x37')][_0x47d6('0x46')]){_0x6c9ecb[_0x47d6('0x47')]=[{'all':!![]}];}return db[_0x47d6('0x32')][_0x47d6('0x48')](_0x6c9ecb);})[_0x47d6('0x28')](function(_0xb6155a){_0x443f6c[_0x47d6('0x49')]=_0xb6155a;return _0x443f6c;})[_0x47d6('0x28')](respondWithFilteredResult(_0x96f28c,_0x6c9ecb))[_0x47d6('0x4a')](handleError(_0x96f28c,null));};exports[_0x47d6('0x4b')]=function(_0x93db2a,_0x5d123d){var _0x1b26d5={'raw':!![],'where':{'id':_0x93db2a['params']['id']}},_0x4358c7={};_0x4358c7[_0x47d6('0x36')]=_[_0x47d6('0x38')](db[_0x47d6('0x32')][_0x47d6('0x4c')]);_0x4358c7['query']=_['keys'](_0x93db2a[_0x47d6('0x37')]);_0x4358c7[_0x47d6('0x40')]=_[_0x47d6('0x39')](_0x4358c7[_0x47d6('0x36')],_0x4358c7[_0x47d6('0x37')]);_0x1b26d5[_0x47d6('0x3a')]=_['intersection'](_0x4358c7[_0x47d6('0x36')],qs[_0x47d6('0x3b')](_0x93db2a[_0x47d6('0x37')][_0x47d6('0x3b')]));_0x1b26d5[_0x47d6('0x3a')]=_0x1b26d5['attributes']['length']?_0x1b26d5[_0x47d6('0x3a')]:_0x4358c7['model'];if(_0x93db2a[_0x47d6('0x37')]['includeAll']){_0x1b26d5[_0x47d6('0x47')]=[{'all':!![]}];}_0x1b26d5=_[_0x47d6('0x43')]({},_0x1b26d5,_0x93db2a['options']);return db['OpenchannelQueue']['find'](_0x1b26d5)[_0x47d6('0x28')](handleEntityNotFound(_0x5d123d,null))['then'](respondWithResult(_0x5d123d,null))[_0x47d6('0x4a')](handleError(_0x5d123d,null));};exports['create']=function(_0x199441,_0x12be77){return db[_0x47d6('0x32')][_0x47d6('0x4d')](_0x199441[_0x47d6('0x4e')],{})[_0x47d6('0x28')](function(_0xf20b87){var _0x5e1a14=_0x199441[_0x47d6('0x4f')][_0x47d6('0x2a')]({'plain':!![]});if(!_0x5e1a14)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5e1a14[_0x47d6('0x50')]===_0x47d6('0x4f')){var _0x52a069=_0xf20b87[_0x47d6('0x2a')]({'plain':!![]});var _0x16d361=_0x47d6('0x51');return db[_0x47d6('0x52')][_0x47d6('0x53')]({'where':{'name':_0x16d361,'userProfileId':_0x5e1a14[_0x47d6('0x54')]},'raw':!![]})[_0x47d6('0x28')](function(_0x1c26aa){if(_0x1c26aa&&_0x1c26aa[_0x47d6('0x55')]===0x0){return db['UserProfileResource'][_0x47d6('0x4d')]({'name':_0x52a069[_0x47d6('0x2e')],'resourceId':_0x52a069['id'],'type':_0x1c26aa['name'],'sectionId':_0x1c26aa['id']},{})[_0x47d6('0x28')](function(){return _0xf20b87;});}else{return _0xf20b87;}})[_0x47d6('0x4a')](function(_0x25074a){logger[_0x47d6('0x2c')](_0x47d6('0x56'),_0x25074a);throw _0x25074a;});}return _0xf20b87;})[_0x47d6('0x28')](respondWithResult(_0x12be77,0xc9))[_0x47d6('0x4a')](handleError(_0x12be77,null));};exports['update']=function(_0x3e84e7,_0xc8612b){if(_0x3e84e7['body']['id']){delete _0x3e84e7[_0x47d6('0x4e')]['id'];}return db[_0x47d6('0x32')]['find']({'where':{'id':_0x3e84e7[_0x47d6('0x57')]['id']}})[_0x47d6('0x28')](handleEntityNotFound(_0xc8612b,null))[_0x47d6('0x28')](saveUpdates(_0x3e84e7[_0x47d6('0x4e')],null))[_0x47d6('0x28')](respondWithResult(_0xc8612b,null))[_0x47d6('0x4a')](handleError(_0xc8612b,null));};exports['destroy']=function(_0x24254a,_0x286da2){return db[_0x47d6('0x32')][_0x47d6('0x53')]({'where':{'id':_0x24254a[_0x47d6('0x57')]['id']}})[_0x47d6('0x28')](handleEntityNotFound(_0x286da2,null))[_0x47d6('0x28')](removeEntity(_0x286da2,null))[_0x47d6('0x4a')](handleError(_0x286da2,null));};exports[_0x47d6('0x58')]=function(_0x5a4e1e,_0x18a26b){return db[_0x47d6('0x32')][_0x47d6('0x58')]()[_0x47d6('0x28')](respondWithResult(_0x18a26b,null))[_0x47d6('0x4a')](handleError(_0x18a26b,null));};exports[_0x47d6('0x59')]=function(_0x23d2e4,_0x512917,_0xb46f66){var _0x496792={'raw':!![],'where':{}},_0x25294d={},_0x18a785;return db[_0x47d6('0x32')][_0x47d6('0x5a')]({'where':{'id':_0x23d2e4[_0x47d6('0x57')]['id']}})['then'](handleEntityNotFound(_0x512917,null))[_0x47d6('0x28')](function(_0x2c0158){if(_0x2c0158){_0x18a785=_0x2c0158[_0x47d6('0x2a')]({'plain':!![]});_0x25294d[_0x47d6('0x36')]=_[_0x47d6('0x38')](db[_0x47d6('0x5b')][_0x47d6('0x4c')]);_0x25294d[_0x47d6('0x37')]=_[_0x47d6('0x38')](_0x23d2e4[_0x47d6('0x37')]);_0x25294d[_0x47d6('0x40')]=_[_0x47d6('0x39')](_0x25294d[_0x47d6('0x36')],_0x25294d[_0x47d6('0x37')]);_0x496792[_0x47d6('0x3a')]=_['intersection'](_0x25294d['model'],qs[_0x47d6('0x3b')](_0x23d2e4['query'][_0x47d6('0x3b')]));_0x496792['attributes']=_0x496792[_0x47d6('0x3a')][_0x47d6('0x5c')]?_0x496792[_0x47d6('0x3a')]:_0x25294d[_0x47d6('0x36')];if(!_0x23d2e4[_0x47d6('0x37')][_0x47d6('0x5d')](_0x47d6('0x3c'))){_0x496792['limit']=qs[_0x47d6('0x25')](_0x23d2e4['query']['limit']);_0x496792['offset']=qs[_0x47d6('0x24')](_0x23d2e4[_0x47d6('0x37')][_0x47d6('0x24')]);}_0x496792[_0x47d6('0x3d')]=qs[_0x47d6('0x3e')](_0x23d2e4[_0x47d6('0x37')][_0x47d6('0x3e')]);_0x496792[_0x47d6('0x3f')]=qs[_0x47d6('0x40')](_[_0x47d6('0x41')](_0x23d2e4[_0x47d6('0x37')],_0x25294d[_0x47d6('0x40')]));_0x496792[_0x47d6('0x3f')][_0x47d6('0x5e')]=_0x2c0158['id'];if(_0x23d2e4[_0x47d6('0x37')][_0x47d6('0x42')]){_0x496792[_0x47d6('0x3f')]=_[_0x47d6('0x43')](_0x496792[_0x47d6('0x3f')],{'$or':_[_0x47d6('0x31')](_0x496792[_0x47d6('0x3a')],function(_0x412b3d){var _0x4960d8={};_0x4960d8[_0x412b3d]={'$like':'%'+_0x23d2e4[_0x47d6('0x37')][_0x47d6('0x42')]+'%'};return _0x4960d8;})});}_0x496792=_[_0x47d6('0x43')]({},_0x496792,_0x23d2e4[_0x47d6('0x5f')]);return db['UserOpenchannelQueue'][_0x47d6('0x48')](_0x496792);}})[_0x47d6('0x28')](function(_0x201f87){if(_0x201f87){return db[_0x47d6('0x60')][_0x47d6('0x61')]({'where':{'id':_['map'](_0x201f87,_0x47d6('0x62')),'role':_0x47d6('0x63')},'attributes':['id',_0x47d6('0x2e'),_0x47d6('0x64'),_0x47d6('0x65'),_0x47d6('0x66')]});}})[_0x47d6('0x28')](function(_0x438fa2){if(_0x438fa2){return{'count':_0x438fa2[_0x47d6('0x45')],'rows':_[_0x47d6('0x31')](_0x438fa2[_0x47d6('0x49')],function(_0x10cb09){return{'membername':_0x10cb09[_0x47d6('0x2e')],'UserId':_0x10cb09['id'],'queue_name':_0x18a785['name'],'OpenchannelQueueId':_0x18a785['id'],'interface':util[_0x47d6('0x67')](_0x47d6('0x68'),_0x47d6('0x69'),_0x10cb09['name']),'penalty':0x0,'paused':_0x10cb09[_0x47d6('0x64')],'createdAt':_0x10cb09[_0x47d6('0x66')],'updatedAt':_0x10cb09[_0x47d6('0x65')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x512917,_0x496792))[_0x47d6('0x4a')](handleError(_0x512917,null));};exports[_0x47d6('0x6a')]=function(_0x15b03a,_0x37e5a4,_0x530a36){var _0x5688a3={};var _0x414c0f={};var _0x238fac;var _0x29f83c;return db[_0x47d6('0x32')][_0x47d6('0x5a')]({'where':{'id':_0x15b03a[_0x47d6('0x57')]['id']}})[_0x47d6('0x28')](handleEntityNotFound(_0x37e5a4,null))[_0x47d6('0x28')](function(_0x205f9e){if(_0x205f9e){_0x238fac=_0x205f9e;_0x414c0f[_0x47d6('0x36')]=_['keys'](db[_0x47d6('0x6b')][_0x47d6('0x4c')]);_0x414c0f[_0x47d6('0x37')]=_[_0x47d6('0x38')](_0x15b03a[_0x47d6('0x37')]);_0x414c0f[_0x47d6('0x40')]=_[_0x47d6('0x39')](_0x414c0f['model'],_0x414c0f[_0x47d6('0x37')]);_0x5688a3['attributes']=_['intersection'](_0x414c0f[_0x47d6('0x36')],qs[_0x47d6('0x3b')](_0x15b03a[_0x47d6('0x37')][_0x47d6('0x3b')]));_0x5688a3[_0x47d6('0x3a')]=_0x5688a3[_0x47d6('0x3a')]['length']?_0x5688a3[_0x47d6('0x3a')]:_0x414c0f['model'];_0x5688a3[_0x47d6('0x3d')]=qs[_0x47d6('0x3e')](_0x15b03a['query']['sort']);_0x5688a3[_0x47d6('0x3f')]=qs['filters'](_[_0x47d6('0x41')](_0x15b03a[_0x47d6('0x37')],_0x414c0f[_0x47d6('0x40')]));if(_0x15b03a[_0x47d6('0x37')]['filter']){_0x5688a3[_0x47d6('0x3f')]=_[_0x47d6('0x43')](_0x5688a3[_0x47d6('0x3f')],{'$or':_[_0x47d6('0x31')](_0x5688a3[_0x47d6('0x3a')],function(_0x2b4829){var _0xe34c64={};_0xe34c64[_0x2b4829]={'$like':'%'+_0x15b03a[_0x47d6('0x37')][_0x47d6('0x42')]+'%'};return _0xe34c64;})});}_0x5688a3=_[_0x47d6('0x43')]({},_0x5688a3,_0x15b03a[_0x47d6('0x5f')]);return _0x238fac[_0x47d6('0x6a')](_0x5688a3);}})['then'](function(_0x10e0ce){if(_0x10e0ce){_0x29f83c=_0x10e0ce[_0x47d6('0x5c')];if(!_0x15b03a['query'][_0x47d6('0x5d')](_0x47d6('0x3c'))){_0x5688a3['limit']=qs['limit'](_0x15b03a['query']['limit']);_0x5688a3[_0x47d6('0x24')]=qs[_0x47d6('0x24')](_0x15b03a['query'][_0x47d6('0x24')]);}return _0x238fac[_0x47d6('0x6a')](_0x5688a3);}})[_0x47d6('0x28')](function(_0x54dfc7){if(_0x54dfc7){return _0x54dfc7?{'count':_0x29f83c,'rows':_0x54dfc7}:null;}})[_0x47d6('0x28')](respondWithResult(_0x37e5a4,null))[_0x47d6('0x4a')](handleError(_0x37e5a4,null));};exports[_0x47d6('0x6c')]=function(_0x18cf64,_0x52cb7e,_0x16271f){var _0xf7f94b=_0x18cf64['body'][_0x47d6('0x6d')];return db[_0x47d6('0x6b')][_0x47d6('0x48')]({'where':{'id':_0xf7f94b},'attributes':['id'],'include':[{'model':db[_0x47d6('0x60')],'as':'Agents','attributes':['id','name','online','voicePause',_0x47d6('0x6e')],'raw':!![]}]})[_0x47d6('0x28')](function(_0x18ae0d){if(_0x18ae0d){var _0x2d8ad0=_['flatMap'](_0x18ae0d,function(_0x4c0902){var _0x410819=_0x4c0902[_0x47d6('0x2a')]({'plain':!![]});return _0x410819['Agents'];});return db['OpenchannelQueue'][_0x47d6('0x53')]({'where':{'id':_0x18cf64['params']['id']}})[_0x47d6('0x28')](function(_0x193ab1){return db['sequelize']['transaction'](function(_0x597165){return _0x193ab1[_0x47d6('0x6c')](_0xf7f94b,{'transaction':_0x597165})[_0x47d6('0x28')](function(){return BPromise[_0x47d6('0x6f')](_0x2d8ad0,function(_0xba60d9){return db[_0x47d6('0x5b')][_0x47d6('0x70')]({'where':{'UserId':_0xba60d9['id'],'OpenchannelQueueId':_0x18cf64[_0x47d6('0x57')]['id']},'transaction':_0x597165});});})[_0x47d6('0x28')](function(){_0x2d8ad0[_0x47d6('0x71')](function(_0x10728b){socket[_0x47d6('0x72')](_0x47d6('0x73'),{'UserId':_0x10728b['id'],'OpenchannelQueueId':_0x193ab1['id']});});});});});}})[_0x47d6('0x28')](respondWithStatusCode(_0x52cb7e,null))['catch'](handleError(_0x52cb7e,null));};exports['removeTeams']=function(_0x5d045f,_0x1b29fa,_0x578185){return db['Team'][_0x47d6('0x48')]({'where':{'id':_0x5d045f['query']['ids']},'attributes':['id'],'include':[{'model':db[_0x47d6('0x60')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x47d6('0x28')](handleEntityNotFound(_0x1b29fa,null))[_0x47d6('0x28')](function(_0x1f45df){var _0x142719=_[_0x47d6('0x31')](_0x1f45df,'id');var _0x4e550a=[];var _0x4bc886=[];var _0x18fd14=squel[_0x47d6('0x74')]();_0x18fd14[_0x47d6('0x75')]('tq.TeamId')['from'](_0x47d6('0x76'),'tq')[_0x47d6('0x77')](_0x47d6('0x78'),'ut',_0x47d6('0x79'))[_0x47d6('0x3f')](_0x47d6('0x7a'),_0x5d045f[_0x47d6('0x57')]['id']);for(var _0x258339=0x0;_0x258339<_0x1f45df['length'];_0x258339+=0x1){let _0x1d72dc=_0x1f45df[_0x258339];for(var _0x57f43f=0x0;_0x57f43f<_0x1d72dc[_0x47d6('0x7b')][_0x47d6('0x5c')];_0x57f43f+=0x1){let _0x9edac5=_0x1d72dc[_0x47d6('0x7b')][_0x57f43f];var _0x597037=_0x18fd14[_0x47d6('0x7c')]();_0x597037['where'](_0x47d6('0x7d'),_0x9edac5['id']);_0x4bc886['push'](db['sequelize']['query'](_0x597037[_0x47d6('0x7e')](),{'type':db[_0x47d6('0x7f')][_0x47d6('0x80')][_0x47d6('0x81')]})['then'](function(_0x559057){if(_0x559057[_0x47d6('0x5c')]===0x1){return _0x9edac5['id'];}else{var _0xdd3695=_[_0x47d6('0x82')](_['map'](_0x559057,_0x47d6('0x83')),function(_0x56a317){return _['includes'](_0x142719,_0x56a317);});if(_0xdd3695){return _0x9edac5['id'];}}}));}}return BPromise[_0x47d6('0x84')](_0x4bc886)[_0x47d6('0x28')](function(_0x4b1871){_0x4e550a=_(_0x4e550a)[_0x47d6('0x85')](_0x4b1871)[_0x47d6('0x86')]()['value']();return db[_0x47d6('0x32')][_0x47d6('0x53')]({'where':{'id':_0x5d045f[_0x47d6('0x57')]['id']}})[_0x47d6('0x28')](function(_0x31581f){return db['sequelize'][_0x47d6('0x87')](function(_0x1a93b3){return _0x31581f['removeTeams'](_0x5d045f[_0x47d6('0x37')][_0x47d6('0x6d')],{'transaction':_0x1a93b3})[_0x47d6('0x28')](function(){if(!_[_0x47d6('0x88')](_0x4e550a)){return _0x31581f[_0x47d6('0x89')](_0x4e550a,{'transaction':_0x1a93b3});}})[_0x47d6('0x28')](function(){_0x4e550a[_0x47d6('0x71')](function(_0x199b5f){socket['emit'](_0x47d6('0x8a'),{'UserId':_0x199b5f,'OpenchannelQueueId':_0x31581f['id']});});});});});});})[_0x47d6('0x28')](respondWithStatusCode(_0x1b29fa,null))[_0x47d6('0x4a')](handleError(_0x1b29fa,null));};exports['addAgents']=function(_0x5bce72,_0x1a8990,_0x2798f2){return db[_0x47d6('0x32')][_0x47d6('0x53')]({'where':{'id':_0x5bce72['params']['id']}})[_0x47d6('0x28')](handleEntityNotFound(_0x1a8990,null))['then'](function(_0x3ac415){if(_0x3ac415){return _0x3ac415[_0x47d6('0x8b')](_0x5bce72['body'][_0x47d6('0x6d')],_[_0x47d6('0x8c')](_0x5bce72[_0x47d6('0x4e')],[_0x47d6('0x6d'),'id'])||{})[_0x47d6('0x8d')](function(_0x415ff5){for(var _0x1ddc7e=0x0;_0x1ddc7e<_0x5bce72[_0x47d6('0x4e')]['ids']['length'];_0x1ddc7e+=0x1){socket[_0x47d6('0x72')](_0x47d6('0x73'),{'UserId':Number(_0x5bce72['body'][_0x47d6('0x6d')][_0x1ddc7e]),'OpenchannelQueueId':Number(_0x5bce72[_0x47d6('0x57')]['id'])});}return _0x415ff5;});}})[_0x47d6('0x28')](respondWithResult(_0x1a8990,null))[_0x47d6('0x4a')](handleError(_0x1a8990,null));};exports['removeAgents']=function(_0x26c71a,_0x1162ae,_0x35c781){return db[_0x47d6('0x32')][_0x47d6('0x53')]({'where':{'id':_0x26c71a[_0x47d6('0x57')]['id']}})[_0x47d6('0x28')](handleEntityNotFound(_0x1162ae,null))['then'](function(_0x27844a){if(_0x27844a){return _0x27844a[_0x47d6('0x89')](_0x26c71a[_0x47d6('0x37')][_0x47d6('0x6d')])[_0x47d6('0x28')](function(){if(_[_0x47d6('0x8e')](_0x26c71a[_0x47d6('0x37')][_0x47d6('0x6d')])){for(var _0x157b58=0x0;_0x157b58<_0x26c71a['query'][_0x47d6('0x6d')][_0x47d6('0x5c')];_0x157b58+=0x1){socket['emit']('userOpenchannelQueue:remove',{'UserId':Number(_0x26c71a[_0x47d6('0x37')]['ids'][_0x157b58]),'OpenchannelQueueId':Number(_0x26c71a['params']['id'])});}}else{socket[_0x47d6('0x72')](_0x47d6('0x8a'),{'UserId':Number(_0x26c71a[_0x47d6('0x37')][_0x47d6('0x6d')]),'OpenchannelQueueId':Number(_0x26c71a['params']['id'])});}});}})[_0x47d6('0x28')](respondWithStatusCode(_0x1162ae,null))[_0x47d6('0x4a')](handleError(_0x1162ae,null));};exports[_0x47d6('0x8f')]=function(_0x1ef833,_0x58979f,_0x125474){var _0x2292e0={};var _0x18c803={};var _0x602558;var _0x15fc78;return db[_0x47d6('0x32')][_0x47d6('0x5a')]({'where':{'id':_0x1ef833['params']['id']}})['then'](handleEntityNotFound(_0x58979f,null))[_0x47d6('0x28')](function(_0x2261cd){if(_0x2261cd){_0x602558=_0x2261cd;_0x18c803[_0x47d6('0x36')]=_[_0x47d6('0x38')](db['User']['rawAttributes']);_0x18c803[_0x47d6('0x37')]=_[_0x47d6('0x38')](_0x1ef833[_0x47d6('0x37')]);_0x18c803[_0x47d6('0x40')]=_['intersection'](_0x18c803[_0x47d6('0x36')],_0x18c803['query']);_0x2292e0[_0x47d6('0x3a')]=_[_0x47d6('0x39')](_0x18c803[_0x47d6('0x36')],qs[_0x47d6('0x3b')](_0x1ef833['query']['fields']));_0x2292e0[_0x47d6('0x3a')]=_0x2292e0[_0x47d6('0x3a')][_0x47d6('0x5c')]?_0x2292e0['attributes']:_0x18c803[_0x47d6('0x36')];_0x2292e0['order']=qs[_0x47d6('0x3e')](_0x1ef833[_0x47d6('0x37')]['sort']);_0x2292e0[_0x47d6('0x3f')]=qs[_0x47d6('0x40')](_['pick'](_0x1ef833['query'],_0x18c803[_0x47d6('0x40')]));if(_0x1ef833[_0x47d6('0x37')][_0x47d6('0x42')]){_0x2292e0[_0x47d6('0x3f')]=_[_0x47d6('0x43')](_0x2292e0[_0x47d6('0x3f')],{'$or':_[_0x47d6('0x31')](_0x2292e0[_0x47d6('0x3a')],function(_0x978c6e){var _0x53b2fa={};_0x53b2fa[_0x978c6e]={'$like':'%'+_0x1ef833[_0x47d6('0x37')][_0x47d6('0x42')]+'%'};return _0x53b2fa;})});}_0x2292e0=_['merge']({},_0x2292e0,_0x1ef833['options']);return _0x602558[_0x47d6('0x8f')](_0x2292e0);}})[_0x47d6('0x28')](function(_0x40db8f){if(_0x40db8f){_0x15fc78=_0x40db8f[_0x47d6('0x5c')];if(!_0x1ef833[_0x47d6('0x37')][_0x47d6('0x5d')]('nolimit')){_0x2292e0['limit']=qs[_0x47d6('0x25')](_0x1ef833['query']['limit']);_0x2292e0[_0x47d6('0x24')]=qs[_0x47d6('0x24')](_0x1ef833[_0x47d6('0x37')][_0x47d6('0x24')]);}return _0x602558[_0x47d6('0x8f')](_0x2292e0);}})[_0x47d6('0x28')](function(_0x1192bb){if(_0x1192bb){return _0x1192bb?{'count':_0x15fc78,'rows':_0x1192bb}:null;}})['then'](respondWithResult(_0x58979f,null))['catch'](handleError(_0x58979f,null));};
\ No newline at end of file
+var _0x35aa=['getTeams','addTeams','ids','Agents','online','voicePause','flatMap','sequelize','each','findOrCreate','userOpenchannelQueue:save','select','field','from','team_has_openchannel_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','QueryTypes','SELECT','every','includes','all','union','compact','value','transaction','removeTeams','removeAgents','emit','userOpenchannelQueue:remove','omit','spread','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./openchannelQueue.socket','status','json','undefined','count','offset','limit','set','Content-Range','save','then','get','OpenchannelQueues','destroy','end','sendStatus','stack','name','send','index','OpenchannelQueue','fieldName','key','map','keys','query','intersection','model','length','nolimit','order','sort','filters','where','merge','VIRTUAL','filter','options','includeAll','findAll','rows','catch','show','params','rawAttributes','attributes','fields','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','error','update','describe','getMembers','findOne','hasOwnProperty','pick','OpenchannelQueueId','UserOpenchannelQueue','User','agent','openchannelPause','updatedAt','createdAt','format','%s/%s','SIP','Team'];(function(_0x16ced5,_0x4e113a){var _0xc55063=function(_0x2a0518){while(--_0x2a0518){_0x16ced5['push'](_0x16ced5['shift']());}};_0xc55063(++_0x4e113a);}(_0x35aa,0x1be));var _0xa35a=function(_0x3b4638,_0x2d8442){_0x3b4638=_0x3b4638-0x0;var _0x445338=_0x35aa[_0x3b4638];return _0x445338;};'use strict';var emlformat=require(_0xa35a('0x0'));var rimraf=require(_0xa35a('0x1'));var zipdir=require(_0xa35a('0x2'));var jsonpatch=require(_0xa35a('0x3'));var rp=require(_0xa35a('0x4'));var moment=require(_0xa35a('0x5'));var BPromise=require(_0xa35a('0x6'));var Mustache=require(_0xa35a('0x7'));var util=require(_0xa35a('0x8'));var path=require(_0xa35a('0x9'));var sox=require(_0xa35a('0xa'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xa35a('0xb'));var crypto=require(_0xa35a('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xa35a('0xd'));var toCsv=require(_0xa35a('0xe'));var querystring=require(_0xa35a('0xf'));var Papa=require(_0xa35a('0x10'));var Redis=require(_0xa35a('0x11'));var authService=require(_0xa35a('0x12'));var qs=require(_0xa35a('0x13'));var as=require(_0xa35a('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xa35a('0x15'));var utils=require('../../config/utils');var config=require(_0xa35a('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xa35a('0x17'))['db'];config[_0xa35a('0x18')]=_['defaults'](config[_0xa35a('0x18')],{'host':_0xa35a('0x19'),'port':0x18eb});var socket=require(_0xa35a('0x1a'))(new Redis(config[_0xa35a('0x18')]));require(_0xa35a('0x1b'))['register'](socket);function respondWithStatusCode(_0x3a7009,_0x217da7){_0x217da7=_0x217da7||0xcc;return function(_0x26e61d){if(_0x26e61d){return _0x3a7009['sendStatus'](_0x217da7);}return _0x3a7009[_0xa35a('0x1c')](_0x217da7)['end']();};}function respondWithResult(_0xe0ecb3,_0x67a699){_0x67a699=_0x67a699||0xc8;return function(_0x7db98f){if(_0x7db98f){return _0xe0ecb3[_0xa35a('0x1c')](_0x67a699)[_0xa35a('0x1d')](_0x7db98f);}};}function respondWithFilteredResult(_0x4c1807,_0x27d352){return function(_0xff5189){if(_0xff5189){var _0x577697=typeof _0x27d352['offset']==='undefined'&&typeof _0x27d352['limit']===_0xa35a('0x1e');var _0x57d3f4=_0xff5189[_0xa35a('0x1f')];var _0x418c26=_0x577697?0x0:_0x27d352[_0xa35a('0x20')];var _0x3105bc=_0x577697?_0xff5189['count']:_0x27d352[_0xa35a('0x20')]+_0x27d352[_0xa35a('0x21')];var _0x4bf16e;if(_0x3105bc>=_0x57d3f4){_0x3105bc=_0x57d3f4;_0x4bf16e=0xc8;}else{_0x4bf16e=0xce;}_0x4c1807[_0xa35a('0x1c')](_0x4bf16e);return _0x4c1807[_0xa35a('0x22')](_0xa35a('0x23'),_0x418c26+'-'+_0x3105bc+'/'+_0x57d3f4)[_0xa35a('0x1d')](_0xff5189);}return null;};}function patchUpdates(_0x4399ef){return function(_0x21e532){try{jsonpatch['apply'](_0x21e532,_0x4399ef,!![]);}catch(_0x415045){return BPromise['reject'](_0x415045);}return _0x21e532[_0xa35a('0x24')]();};}function saveUpdates(_0x217bd5,_0x979010){return function(_0x2e673c){if(_0x2e673c){return _0x2e673c['update'](_0x217bd5)[_0xa35a('0x25')](function(_0x13e800){return _0x13e800;});}return null;};}function removeEntity(_0x1b03bc,_0x3887cf){return function(_0x39624a){if(_0x39624a){return _0x39624a['destroy']()[_0xa35a('0x25')](function(){var _0x3d7731=_0x39624a[_0xa35a('0x26')]({'plain':!![]});var _0x460604=_0xa35a('0x27');return db['UserProfileResource'][_0xa35a('0x28')]({'where':{'type':_0x460604,'resourceId':_0x3d7731['id']}})['then'](function(){return _0x39624a;});})['then'](function(){_0x1b03bc['status'](0xcc)[_0xa35a('0x29')]();});}};}function handleEntityNotFound(_0x43fdb4,_0x1cff9d){return function(_0x3e3339){if(!_0x3e3339){_0x43fdb4[_0xa35a('0x2a')](0x194);}return _0x3e3339;};}function handleError(_0x91df2d,_0x3e5962){_0x3e5962=_0x3e5962||0x1f4;return function(_0x40db0b){logger['error'](_0x40db0b[_0xa35a('0x2b')]);if(_0x40db0b[_0xa35a('0x2c')]){delete _0x40db0b[_0xa35a('0x2c')];}_0x91df2d[_0xa35a('0x1c')](_0x3e5962)[_0xa35a('0x2d')](_0x40db0b);};}exports[_0xa35a('0x2e')]=function(_0x2bba00,_0x556260){var _0x5e4f66={},_0x2acaeb={},_0x54548c={'count':0x0,'rows':[]};var _0x1c844f=_['map'](db[_0xa35a('0x2f')]['rawAttributes'],function(_0x4b253d){return{'name':_0x4b253d[_0xa35a('0x30')],'type':_0x4b253d['type'][_0xa35a('0x31')]};});_0x2acaeb['model']=_[_0xa35a('0x32')](_0x1c844f,_0xa35a('0x2c'));_0x2acaeb['query']=_[_0xa35a('0x33')](_0x2bba00[_0xa35a('0x34')]);_0x2acaeb['filters']=_[_0xa35a('0x35')](_0x2acaeb[_0xa35a('0x36')],_0x2acaeb[_0xa35a('0x34')]);_0x5e4f66['attributes']=_[_0xa35a('0x35')](_0x2acaeb[_0xa35a('0x36')],qs['fields'](_0x2bba00['query']['fields']));_0x5e4f66['attributes']=_0x5e4f66['attributes'][_0xa35a('0x37')]?_0x5e4f66['attributes']:_0x2acaeb['model'];if(!_0x2bba00[_0xa35a('0x34')]['hasOwnProperty'](_0xa35a('0x38'))){_0x5e4f66[_0xa35a('0x21')]=qs[_0xa35a('0x21')](_0x2bba00[_0xa35a('0x34')]['limit']);_0x5e4f66['offset']=qs[_0xa35a('0x20')](_0x2bba00['query']['offset']);}_0x5e4f66[_0xa35a('0x39')]=qs[_0xa35a('0x3a')](_0x2bba00[_0xa35a('0x34')][_0xa35a('0x3a')]);_0x5e4f66['where']=qs[_0xa35a('0x3b')](_['pick'](_0x2bba00[_0xa35a('0x34')],_0x2acaeb[_0xa35a('0x3b')]),_0x1c844f);if(_0x2bba00[_0xa35a('0x34')]['filter']){_0x5e4f66[_0xa35a('0x3c')]=_[_0xa35a('0x3d')](_0x5e4f66[_0xa35a('0x3c')],{'$or':_[_0xa35a('0x32')](_0x1c844f,function(_0x3f88ef){if(_0x3f88ef['type']!==_0xa35a('0x3e')){var _0x4db7ca={};_0x4db7ca[_0x3f88ef['name']]={'$like':'%'+_0x2bba00[_0xa35a('0x34')][_0xa35a('0x3f')]+'%'};return _0x4db7ca;}})});}_0x5e4f66=_[_0xa35a('0x3d')]({},_0x5e4f66,_0x2bba00[_0xa35a('0x40')]);var _0x4fc155={'where':_0x5e4f66[_0xa35a('0x3c')]};return db[_0xa35a('0x2f')]['count'](_0x4fc155)[_0xa35a('0x25')](function(_0x5c135a){_0x54548c[_0xa35a('0x1f')]=_0x5c135a;if(_0x2bba00['query'][_0xa35a('0x41')]){_0x5e4f66['include']=[{'all':!![]}];}return db[_0xa35a('0x2f')][_0xa35a('0x42')](_0x5e4f66);})[_0xa35a('0x25')](function(_0x44377a){_0x54548c[_0xa35a('0x43')]=_0x44377a;return _0x54548c;})[_0xa35a('0x25')](respondWithFilteredResult(_0x556260,_0x5e4f66))[_0xa35a('0x44')](handleError(_0x556260,null));};exports[_0xa35a('0x45')]=function(_0x496cf4,_0x1ead1e){var _0x48f2b4={'raw':!![],'where':{'id':_0x496cf4[_0xa35a('0x46')]['id']}},_0x57a608={};_0x57a608[_0xa35a('0x36')]=_['keys'](db[_0xa35a('0x2f')][_0xa35a('0x47')]);_0x57a608[_0xa35a('0x34')]=_['keys'](_0x496cf4[_0xa35a('0x34')]);_0x57a608[_0xa35a('0x3b')]=_['intersection'](_0x57a608['model'],_0x57a608['query']);_0x48f2b4[_0xa35a('0x48')]=_[_0xa35a('0x35')](_0x57a608['model'],qs[_0xa35a('0x49')](_0x496cf4[_0xa35a('0x34')][_0xa35a('0x49')]));_0x48f2b4[_0xa35a('0x48')]=_0x48f2b4[_0xa35a('0x48')][_0xa35a('0x37')]?_0x48f2b4[_0xa35a('0x48')]:_0x57a608['model'];if(_0x496cf4[_0xa35a('0x34')]['includeAll']){_0x48f2b4[_0xa35a('0x4a')]=[{'all':!![]}];}_0x48f2b4=_['merge']({},_0x48f2b4,_0x496cf4[_0xa35a('0x40')]);return db['OpenchannelQueue'][_0xa35a('0x4b')](_0x48f2b4)[_0xa35a('0x25')](handleEntityNotFound(_0x1ead1e,null))['then'](respondWithResult(_0x1ead1e,null))['catch'](handleError(_0x1ead1e,null));};exports[_0xa35a('0x4c')]=function(_0x7cba7c,_0x480281){return db[_0xa35a('0x2f')][_0xa35a('0x4c')](_0x7cba7c[_0xa35a('0x4d')],{})[_0xa35a('0x25')](function(_0x442606){var _0x5dc611=_0x7cba7c[_0xa35a('0x4e')][_0xa35a('0x26')]({'plain':!![]});if(!_0x5dc611)throw new Error(_0xa35a('0x4f'));if(_0x5dc611['role']===_0xa35a('0x4e')){var _0x1ab270=_0x442606[_0xa35a('0x26')]({'plain':!![]});var _0x4e1e0b=_0xa35a('0x27');return db[_0xa35a('0x50')][_0xa35a('0x4b')]({'where':{'name':_0x4e1e0b,'userProfileId':_0x5dc611[_0xa35a('0x51')]},'raw':!![]})['then'](function(_0xc217fd){if(_0xc217fd&&_0xc217fd[_0xa35a('0x52')]===0x0){return db[_0xa35a('0x53')][_0xa35a('0x4c')]({'name':_0x1ab270[_0xa35a('0x2c')],'resourceId':_0x1ab270['id'],'type':_0xc217fd[_0xa35a('0x2c')],'sectionId':_0xc217fd['id']},{})[_0xa35a('0x25')](function(){return _0x442606;});}else{return _0x442606;}})[_0xa35a('0x44')](function(_0x50c0ae){logger[_0xa35a('0x54')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x50c0ae);throw _0x50c0ae;});}return _0x442606;})[_0xa35a('0x25')](respondWithResult(_0x480281,0xc9))[_0xa35a('0x44')](handleError(_0x480281,null));};exports[_0xa35a('0x55')]=function(_0x3da24c,_0x1ea425){if(_0x3da24c[_0xa35a('0x4d')]['id']){delete _0x3da24c[_0xa35a('0x4d')]['id'];}return db[_0xa35a('0x2f')][_0xa35a('0x4b')]({'where':{'id':_0x3da24c[_0xa35a('0x46')]['id']}})[_0xa35a('0x25')](handleEntityNotFound(_0x1ea425,null))['then'](saveUpdates(_0x3da24c[_0xa35a('0x4d')],null))[_0xa35a('0x25')](respondWithResult(_0x1ea425,null))[_0xa35a('0x44')](handleError(_0x1ea425,null));};exports[_0xa35a('0x28')]=function(_0x3cd28c,_0x1c02b8){return db[_0xa35a('0x2f')][_0xa35a('0x4b')]({'where':{'id':_0x3cd28c['params']['id']}})[_0xa35a('0x25')](handleEntityNotFound(_0x1c02b8,null))[_0xa35a('0x25')](removeEntity(_0x1c02b8,null))[_0xa35a('0x44')](handleError(_0x1c02b8,null));};exports[_0xa35a('0x56')]=function(_0x5d59a2,_0x122c2a){return db[_0xa35a('0x2f')]['describe']()[_0xa35a('0x25')](respondWithResult(_0x122c2a,null))[_0xa35a('0x44')](handleError(_0x122c2a,null));};exports[_0xa35a('0x57')]=function(_0x43d137,_0x56a747,_0x41f7f1){var _0x1d39ec={'raw':!![],'where':{}},_0x455f8c={},_0x312403;return db[_0xa35a('0x2f')][_0xa35a('0x58')]({'where':{'id':_0x43d137['params']['id']}})[_0xa35a('0x25')](handleEntityNotFound(_0x56a747,null))[_0xa35a('0x25')](function(_0x4f617c){if(_0x4f617c){_0x312403=_0x4f617c[_0xa35a('0x26')]({'plain':!![]});_0x455f8c[_0xa35a('0x36')]=_[_0xa35a('0x33')](db['UserOpenchannelQueue']['rawAttributes']);_0x455f8c[_0xa35a('0x34')]=_[_0xa35a('0x33')](_0x43d137[_0xa35a('0x34')]);_0x455f8c[_0xa35a('0x3b')]=_[_0xa35a('0x35')](_0x455f8c['model'],_0x455f8c[_0xa35a('0x34')]);_0x1d39ec[_0xa35a('0x48')]=_[_0xa35a('0x35')](_0x455f8c[_0xa35a('0x36')],qs[_0xa35a('0x49')](_0x43d137['query']['fields']));_0x1d39ec['attributes']=_0x1d39ec[_0xa35a('0x48')]['length']?_0x1d39ec[_0xa35a('0x48')]:_0x455f8c['model'];if(!_0x43d137[_0xa35a('0x34')][_0xa35a('0x59')]('nolimit')){_0x1d39ec[_0xa35a('0x21')]=qs[_0xa35a('0x21')](_0x43d137[_0xa35a('0x34')][_0xa35a('0x21')]);_0x1d39ec[_0xa35a('0x20')]=qs[_0xa35a('0x20')](_0x43d137[_0xa35a('0x34')]['offset']);}_0x1d39ec[_0xa35a('0x39')]=qs[_0xa35a('0x3a')](_0x43d137[_0xa35a('0x34')][_0xa35a('0x3a')]);_0x1d39ec['where']=qs[_0xa35a('0x3b')](_[_0xa35a('0x5a')](_0x43d137['query'],_0x455f8c[_0xa35a('0x3b')]));_0x1d39ec[_0xa35a('0x3c')][_0xa35a('0x5b')]=_0x4f617c['id'];if(_0x43d137[_0xa35a('0x34')][_0xa35a('0x3f')]){_0x1d39ec[_0xa35a('0x3c')]=_[_0xa35a('0x3d')](_0x1d39ec[_0xa35a('0x3c')],{'$or':_[_0xa35a('0x32')](_0x1d39ec['attributes'],function(_0x2c9ab4){var _0x4933b6={};_0x4933b6[_0x2c9ab4]={'$like':'%'+_0x43d137['query'][_0xa35a('0x3f')]+'%'};return _0x4933b6;})});}_0x1d39ec=_['merge']({},_0x1d39ec,_0x43d137[_0xa35a('0x40')]);return db[_0xa35a('0x5c')][_0xa35a('0x42')](_0x1d39ec);}})['then'](function(_0x56d29b){if(_0x56d29b){return db[_0xa35a('0x5d')]['findAndCountAll']({'where':{'id':_['map'](_0x56d29b,'UserId'),'role':_0xa35a('0x5e')},'attributes':['id',_0xa35a('0x2c'),_0xa35a('0x5f'),_0xa35a('0x60'),_0xa35a('0x61')]});}})[_0xa35a('0x25')](function(_0x4c6531){if(_0x4c6531){return{'count':_0x4c6531[_0xa35a('0x1f')],'rows':_[_0xa35a('0x32')](_0x4c6531[_0xa35a('0x43')],function(_0x1639e4){return{'membername':_0x1639e4[_0xa35a('0x2c')],'UserId':_0x1639e4['id'],'queue_name':_0x312403['name'],'OpenchannelQueueId':_0x312403['id'],'interface':util[_0xa35a('0x62')](_0xa35a('0x63'),_0xa35a('0x64'),_0x1639e4[_0xa35a('0x2c')]),'penalty':0x0,'paused':_0x1639e4['openchannelPause'],'createdAt':_0x1639e4['createdAt'],'updatedAt':_0x1639e4[_0xa35a('0x60')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xa35a('0x25')](respondWithFilteredResult(_0x56a747,_0x1d39ec))[_0xa35a('0x44')](handleError(_0x56a747,null));};exports['getTeams']=function(_0x216676,_0x105593,_0x5163f6){var _0x41f962={};var _0x33abf3={};var _0x1ca2ee;var _0x45997c;return db[_0xa35a('0x2f')]['findOne']({'where':{'id':_0x216676[_0xa35a('0x46')]['id']}})[_0xa35a('0x25')](handleEntityNotFound(_0x105593,null))['then'](function(_0x4b1c91){if(_0x4b1c91){_0x1ca2ee=_0x4b1c91;_0x33abf3[_0xa35a('0x36')]=_[_0xa35a('0x33')](db[_0xa35a('0x65')][_0xa35a('0x47')]);_0x33abf3[_0xa35a('0x34')]=_[_0xa35a('0x33')](_0x216676[_0xa35a('0x34')]);_0x33abf3[_0xa35a('0x3b')]=_['intersection'](_0x33abf3[_0xa35a('0x36')],_0x33abf3[_0xa35a('0x34')]);_0x41f962['attributes']=_['intersection'](_0x33abf3[_0xa35a('0x36')],qs[_0xa35a('0x49')](_0x216676[_0xa35a('0x34')][_0xa35a('0x49')]));_0x41f962['attributes']=_0x41f962[_0xa35a('0x48')][_0xa35a('0x37')]?_0x41f962[_0xa35a('0x48')]:_0x33abf3[_0xa35a('0x36')];_0x41f962['order']=qs[_0xa35a('0x3a')](_0x216676['query'][_0xa35a('0x3a')]);_0x41f962[_0xa35a('0x3c')]=qs[_0xa35a('0x3b')](_[_0xa35a('0x5a')](_0x216676[_0xa35a('0x34')],_0x33abf3['filters']));if(_0x216676[_0xa35a('0x34')]['filter']){_0x41f962['where']=_['merge'](_0x41f962['where'],{'$or':_['map'](_0x41f962[_0xa35a('0x48')],function(_0x285c0a){var _0x1b4a83={};_0x1b4a83[_0x285c0a]={'$like':'%'+_0x216676['query'][_0xa35a('0x3f')]+'%'};return _0x1b4a83;})});}_0x41f962=_[_0xa35a('0x3d')]({},_0x41f962,_0x216676[_0xa35a('0x40')]);return _0x1ca2ee[_0xa35a('0x66')](_0x41f962);}})[_0xa35a('0x25')](function(_0x23801c){if(_0x23801c){_0x45997c=_0x23801c[_0xa35a('0x37')];if(!_0x216676[_0xa35a('0x34')][_0xa35a('0x59')](_0xa35a('0x38'))){_0x41f962['limit']=qs[_0xa35a('0x21')](_0x216676[_0xa35a('0x34')][_0xa35a('0x21')]);_0x41f962[_0xa35a('0x20')]=qs[_0xa35a('0x20')](_0x216676[_0xa35a('0x34')][_0xa35a('0x20')]);}return _0x1ca2ee[_0xa35a('0x66')](_0x41f962);}})['then'](function(_0x5db7c4){if(_0x5db7c4){return _0x5db7c4?{'count':_0x45997c,'rows':_0x5db7c4}:null;}})['then'](respondWithResult(_0x105593,null))[_0xa35a('0x44')](handleError(_0x105593,null));};exports[_0xa35a('0x67')]=function(_0x2d2c80,_0x40592a,_0x1a6636){var _0x5a3465=_0x2d2c80[_0xa35a('0x4d')][_0xa35a('0x68')];return db[_0xa35a('0x65')]['findAll']({'where':{'id':_0x5a3465},'attributes':['id'],'include':[{'model':db[_0xa35a('0x5d')],'as':_0xa35a('0x69'),'attributes':['id',_0xa35a('0x2c'),_0xa35a('0x6a'),_0xa35a('0x6b'),'interface'],'raw':!![]}]})[_0xa35a('0x25')](function(_0x242092){if(_0x242092){var _0xf840bd=_[_0xa35a('0x6c')](_0x242092,function(_0x20fca0){var _0x4ec466=_0x20fca0[_0xa35a('0x26')]({'plain':!![]});return _0x4ec466[_0xa35a('0x69')];});return db[_0xa35a('0x2f')][_0xa35a('0x4b')]({'where':{'id':_0x2d2c80[_0xa35a('0x46')]['id']}})[_0xa35a('0x25')](function(_0x4140d1){return db[_0xa35a('0x6d')]['transaction'](function(_0x616383){return _0x4140d1[_0xa35a('0x67')](_0x5a3465,{'transaction':_0x616383})[_0xa35a('0x25')](function(){return BPromise[_0xa35a('0x6e')](_0xf840bd,function(_0x38abf0){return db[_0xa35a('0x5c')][_0xa35a('0x6f')]({'where':{'UserId':_0x38abf0['id'],'OpenchannelQueueId':_0x2d2c80[_0xa35a('0x46')]['id']},'transaction':_0x616383});});})['then'](function(){_0xf840bd['forEach'](function(_0x3db89e){socket['emit'](_0xa35a('0x70'),{'UserId':_0x3db89e['id'],'OpenchannelQueueId':_0x4140d1['id']});});});});});}})[_0xa35a('0x25')](respondWithStatusCode(_0x40592a,null))[_0xa35a('0x44')](handleError(_0x40592a,null));};exports['removeTeams']=function(_0xf04df5,_0x2acaca,_0x2cac83){return db[_0xa35a('0x65')][_0xa35a('0x42')]({'where':{'id':_0xf04df5[_0xa35a('0x34')][_0xa35a('0x68')]},'attributes':['id'],'include':[{'model':db[_0xa35a('0x5d')],'as':_0xa35a('0x69'),'attributes':['id'],'raw':!![]}]})[_0xa35a('0x25')](handleEntityNotFound(_0x2acaca,null))['then'](function(_0xd6d1ee){var _0x787506=_['map'](_0xd6d1ee,'id');var _0x11c437=[];var _0x579af0=[];var _0x126bf7=squel[_0xa35a('0x71')]();_0x126bf7[_0xa35a('0x72')]('tq.TeamId')[_0xa35a('0x73')](_0xa35a('0x74'),'tq')[_0xa35a('0x75')](_0xa35a('0x76'),'ut',_0xa35a('0x77'))[_0xa35a('0x3c')]('OpenchannelQueueId\x20=\x20?',_0xf04df5['params']['id']);for(var _0x106b1=0x0;_0x106b1<_0xd6d1ee[_0xa35a('0x37')];_0x106b1+=0x1){let _0x3c9da6=_0xd6d1ee[_0x106b1];for(var _0x4726a4=0x0;_0x4726a4<_0x3c9da6['Agents'][_0xa35a('0x37')];_0x4726a4+=0x1){let _0x4fc270=_0x3c9da6[_0xa35a('0x69')][_0x4726a4];var _0x516ed0=_0x126bf7['clone']();_0x516ed0[_0xa35a('0x3c')](_0xa35a('0x78'),_0x4fc270['id']);_0x579af0['push'](db[_0xa35a('0x6d')][_0xa35a('0x34')](_0x516ed0['toString'](),{'type':db['sequelize'][_0xa35a('0x79')][_0xa35a('0x7a')]})[_0xa35a('0x25')](function(_0x200c88){if(_0x200c88[_0xa35a('0x37')]===0x1){return _0x4fc270['id'];}else{var _0x13ef84=_[_0xa35a('0x7b')](_[_0xa35a('0x32')](_0x200c88,'TeamId'),function(_0x44f331){return _[_0xa35a('0x7c')](_0x787506,_0x44f331);});if(_0x13ef84){return _0x4fc270['id'];}}}));}}return BPromise[_0xa35a('0x7d')](_0x579af0)['then'](function(_0x2b2c4b){_0x11c437=_(_0x11c437)[_0xa35a('0x7e')](_0x2b2c4b)[_0xa35a('0x7f')]()[_0xa35a('0x80')]();return db['OpenchannelQueue'][_0xa35a('0x4b')]({'where':{'id':_0xf04df5['params']['id']}})[_0xa35a('0x25')](function(_0x1580e1){return db[_0xa35a('0x6d')][_0xa35a('0x81')](function(_0xa2fbfd){return _0x1580e1[_0xa35a('0x82')](_0xf04df5[_0xa35a('0x34')][_0xa35a('0x68')],{'transaction':_0xa2fbfd})[_0xa35a('0x25')](function(){if(!_['isEmpty'](_0x11c437)){return _0x1580e1[_0xa35a('0x83')](_0x11c437,{'transaction':_0xa2fbfd});}})[_0xa35a('0x25')](function(){_0x11c437['forEach'](function(_0x2b622a){socket[_0xa35a('0x84')](_0xa35a('0x85'),{'UserId':_0x2b622a,'OpenchannelQueueId':_0x1580e1['id']});});});});});});})[_0xa35a('0x25')](respondWithStatusCode(_0x2acaca,null))[_0xa35a('0x44')](handleError(_0x2acaca,null));};exports['addAgents']=function(_0x5f3147,_0x3ee75d,_0xd9d806){return db[_0xa35a('0x2f')][_0xa35a('0x4b')]({'where':{'id':_0x5f3147[_0xa35a('0x46')]['id']}})[_0xa35a('0x25')](handleEntityNotFound(_0x3ee75d,null))[_0xa35a('0x25')](function(_0x198c2f){if(_0x198c2f){return _0x198c2f['addAgents'](_0x5f3147[_0xa35a('0x4d')][_0xa35a('0x68')],_[_0xa35a('0x86')](_0x5f3147[_0xa35a('0x4d')],[_0xa35a('0x68'),'id'])||{})[_0xa35a('0x87')](function(_0x1c363b){for(var _0x3ac43c=0x0;_0x3ac43c<_0x5f3147[_0xa35a('0x4d')][_0xa35a('0x68')][_0xa35a('0x37')];_0x3ac43c+=0x1){socket[_0xa35a('0x84')](_0xa35a('0x70'),{'UserId':Number(_0x5f3147[_0xa35a('0x4d')][_0xa35a('0x68')][_0x3ac43c]),'OpenchannelQueueId':Number(_0x5f3147[_0xa35a('0x46')]['id'])});}return _0x1c363b;});}})[_0xa35a('0x25')](respondWithResult(_0x3ee75d,null))[_0xa35a('0x44')](handleError(_0x3ee75d,null));};exports[_0xa35a('0x83')]=function(_0x4a54d8,_0x523294,_0x446387){return db[_0xa35a('0x2f')][_0xa35a('0x4b')]({'where':{'id':_0x4a54d8['params']['id']}})[_0xa35a('0x25')](handleEntityNotFound(_0x523294,null))[_0xa35a('0x25')](function(_0x3008bb){if(_0x3008bb){return _0x3008bb[_0xa35a('0x83')](_0x4a54d8[_0xa35a('0x34')][_0xa35a('0x68')])['then'](function(){if(_['isArray'](_0x4a54d8[_0xa35a('0x34')][_0xa35a('0x68')])){for(var _0x1541f0=0x0;_0x1541f0<_0x4a54d8[_0xa35a('0x34')][_0xa35a('0x68')][_0xa35a('0x37')];_0x1541f0+=0x1){socket[_0xa35a('0x84')](_0xa35a('0x85'),{'UserId':Number(_0x4a54d8[_0xa35a('0x34')][_0xa35a('0x68')][_0x1541f0]),'OpenchannelQueueId':Number(_0x4a54d8[_0xa35a('0x46')]['id'])});}}else{socket[_0xa35a('0x84')](_0xa35a('0x85'),{'UserId':Number(_0x4a54d8[_0xa35a('0x34')][_0xa35a('0x68')]),'OpenchannelQueueId':Number(_0x4a54d8[_0xa35a('0x46')]['id'])});}});}})[_0xa35a('0x25')](respondWithStatusCode(_0x523294,null))['catch'](handleError(_0x523294,null));};exports[_0xa35a('0x88')]=function(_0x3a3f7e,_0x57832e,_0x4a20d2){var _0x3d490f={};var _0xdbaa87={};var _0x3fb774;var _0x28ad06;return db[_0xa35a('0x2f')]['findOne']({'where':{'id':_0x3a3f7e[_0xa35a('0x46')]['id']}})[_0xa35a('0x25')](handleEntityNotFound(_0x57832e,null))[_0xa35a('0x25')](function(_0x513a53){if(_0x513a53){_0x3fb774=_0x513a53;_0xdbaa87[_0xa35a('0x36')]=_['keys'](db[_0xa35a('0x5d')][_0xa35a('0x47')]);_0xdbaa87[_0xa35a('0x34')]=_[_0xa35a('0x33')](_0x3a3f7e[_0xa35a('0x34')]);_0xdbaa87[_0xa35a('0x3b')]=_[_0xa35a('0x35')](_0xdbaa87[_0xa35a('0x36')],_0xdbaa87[_0xa35a('0x34')]);_0x3d490f['attributes']=_[_0xa35a('0x35')](_0xdbaa87[_0xa35a('0x36')],qs[_0xa35a('0x49')](_0x3a3f7e[_0xa35a('0x34')]['fields']));_0x3d490f[_0xa35a('0x48')]=_0x3d490f[_0xa35a('0x48')][_0xa35a('0x37')]?_0x3d490f[_0xa35a('0x48')]:_0xdbaa87[_0xa35a('0x36')];_0x3d490f['order']=qs[_0xa35a('0x3a')](_0x3a3f7e[_0xa35a('0x34')][_0xa35a('0x3a')]);_0x3d490f[_0xa35a('0x3c')]=qs[_0xa35a('0x3b')](_[_0xa35a('0x5a')](_0x3a3f7e[_0xa35a('0x34')],_0xdbaa87[_0xa35a('0x3b')]));if(_0x3a3f7e[_0xa35a('0x34')][_0xa35a('0x3f')]){_0x3d490f[_0xa35a('0x3c')]=_[_0xa35a('0x3d')](_0x3d490f[_0xa35a('0x3c')],{'$or':_[_0xa35a('0x32')](_0x3d490f['attributes'],function(_0x5ece5a){var _0x530701={};_0x530701[_0x5ece5a]={'$like':'%'+_0x3a3f7e[_0xa35a('0x34')][_0xa35a('0x3f')]+'%'};return _0x530701;})});}_0x3d490f=_[_0xa35a('0x3d')]({},_0x3d490f,_0x3a3f7e[_0xa35a('0x40')]);return _0x3fb774[_0xa35a('0x88')](_0x3d490f);}})[_0xa35a('0x25')](function(_0x4f13a5){if(_0x4f13a5){_0x28ad06=_0x4f13a5[_0xa35a('0x37')];if(!_0x3a3f7e[_0xa35a('0x34')]['hasOwnProperty']('nolimit')){_0x3d490f[_0xa35a('0x21')]=qs[_0xa35a('0x21')](_0x3a3f7e[_0xa35a('0x34')][_0xa35a('0x21')]);_0x3d490f[_0xa35a('0x20')]=qs[_0xa35a('0x20')](_0x3a3f7e[_0xa35a('0x34')][_0xa35a('0x20')]);}return _0x3fb774[_0xa35a('0x88')](_0x3d490f);}})[_0xa35a('0x25')](function(_0x361a9b){if(_0x361a9b){return _0x361a9b?{'count':_0x28ad06,'rows':_0x361a9b}:null;}})[_0xa35a('0x25')](respondWithResult(_0x57832e,null))[_0xa35a('0x44')](handleError(_0x57832e,null));};
\ No newline at end of file