Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index 4707d85..f2cdb4e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0ecd=['role','OpenchannelQueues','UserProfileSection','userProfileId','autoAssociation','update','describe','findOne','UserOpenchannelQueue','nolimit','OpenchannelQueueId','findAndCountAll','UserId','agent','openchannelPause','createdAt','format','%s/%s','SIP','updatedAt','getTeams','Team','ids','User','online','voicePause','interface','Agents','transaction','addTeams','each','removeTeams','field','tq.TeamId','team_has_openchannel_queues','join','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','removeAgents','forEach','emit','userOpenchannelQueue:remove','addAgents','omit','spread','userOpenchannelQueue:save','isArray','getAgents','rimraf','zip-dir','fast-json-patch','moment','mustache','util','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','./openchannelQueue.socket','register','sendStatus','end','status','json','offset','undefined','count','limit','set','apply','reject','save','destroy','get','then','error','stack','name','index','OpenchannelQueue','rawAttributes','fieldName','type','key','map','query','keys','filters','attributes','intersection','fields','length','model','hasOwnProperty','order','sort','where','pick','filter','merge','options','includeAll','findAll','rows','catch','show','params','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user'];(function(_0xa4928c,_0x16b89c){var _0x27cc29=function(_0x14b819){while(--_0x14b819){_0xa4928c['push'](_0xa4928c['shift']());}};_0x27cc29(++_0x16b89c);}(_0x0ecd,0xcb));var _0xd0ec=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x0ecd[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xd0ec('0x0'));var zipdir=require(_0xd0ec('0x1'));var jsonpatch=require(_0xd0ec('0x2'));var rp=require('request-promise');var moment=require(_0xd0ec('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xd0ec('0x4'));var util=require(_0xd0ec('0x5'));var path=require('path');var sox=require(_0xd0ec('0x6'));var csv=require(_0xd0ec('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xd0ec('0x8'));var crypto=require(_0xd0ec('0x9'));var jsforce=require(_0xd0ec('0xa'));var deskjs=require(_0xd0ec('0xb'));var toCsv=require('to-csv');var querystring=require(_0xd0ec('0xc'));var Papa=require(_0xd0ec('0xd'));var Redis=require('ioredis');var authService=require(_0xd0ec('0xe'));var qs=require(_0xd0ec('0xf'));var as=require(_0xd0ec('0x10'));var hardwareService=require(_0xd0ec('0x11'));var logger=require(_0xd0ec('0x12'))(_0xd0ec('0x13'));var utils=require(_0xd0ec('0x14'));var config=require(_0xd0ec('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xd0ec('0x16'))['db'];config[_0xd0ec('0x17')]=_[_0xd0ec('0x18')](config[_0xd0ec('0x17')],{'host':_0xd0ec('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xd0ec('0x17')]));require(_0xd0ec('0x1a'))[_0xd0ec('0x1b')](socket);function respondWithStatusCode(_0x4c607c,_0x1fd896){_0x1fd896=_0x1fd896||0xcc;return function(_0x544f4a){if(_0x544f4a){return _0x4c607c[_0xd0ec('0x1c')](_0x1fd896);}return _0x4c607c['status'](_0x1fd896)[_0xd0ec('0x1d')]();};}function respondWithResult(_0x1d2780,_0x4f2ea9){_0x4f2ea9=_0x4f2ea9||0xc8;return function(_0x591833){if(_0x591833){return _0x1d2780[_0xd0ec('0x1e')](_0x4f2ea9)[_0xd0ec('0x1f')](_0x591833);}};}function respondWithFilteredResult(_0x58f4a9,_0x34be64){return function(_0x13e1ef){if(_0x13e1ef){var _0xfa0515=typeof _0x34be64[_0xd0ec('0x20')]===_0xd0ec('0x21')&&typeof _0x34be64['limit']===_0xd0ec('0x21');var _0x4fc037=_0x13e1ef[_0xd0ec('0x22')];var _0x658d94=_0xfa0515?0x0:_0x34be64['offset'];var _0xc8fe2c=_0xfa0515?_0x13e1ef[_0xd0ec('0x22')]:_0x34be64[_0xd0ec('0x20')]+_0x34be64[_0xd0ec('0x23')];var _0xa26906;if(_0xc8fe2c>=_0x4fc037){_0xc8fe2c=_0x4fc037;_0xa26906=0xc8;}else{_0xa26906=0xce;}_0x58f4a9[_0xd0ec('0x1e')](_0xa26906);return _0x58f4a9[_0xd0ec('0x24')]('Content-Range',_0x658d94+'-'+_0xc8fe2c+'/'+_0x4fc037)[_0xd0ec('0x1f')](_0x13e1ef);}return null;};}function patchUpdates(_0x92396e){return function(_0x41dca1){try{jsonpatch[_0xd0ec('0x25')](_0x41dca1,_0x92396e,!![]);}catch(_0x958bf5){return BPromise[_0xd0ec('0x26')](_0x958bf5);}return _0x41dca1[_0xd0ec('0x27')]();};}function saveUpdates(_0x3a2156,_0x66a0ae){return function(_0x283706){if(_0x283706){return _0x283706['update'](_0x3a2156)['then'](function(_0x41897a){return _0x41897a;});}return null;};}function removeEntity(_0xa5e918,_0x1d7b29){return function(_0x21dfb1){if(_0x21dfb1){return _0x21dfb1[_0xd0ec('0x28')]()['then'](function(){var _0x4d9ee5=_0x21dfb1[_0xd0ec('0x29')]({'plain':!![]});var _0x5006a8='OpenchannelQueues';return db['UserProfileResource']['destroy']({'where':{'type':_0x5006a8,'resourceId':_0x4d9ee5['id']}})[_0xd0ec('0x2a')](function(){return _0x21dfb1;});})[_0xd0ec('0x2a')](function(){_0xa5e918[_0xd0ec('0x1e')](0xcc)[_0xd0ec('0x1d')]();});}};}function handleEntityNotFound(_0xc887ee,_0x33a851){return function(_0x210992){if(!_0x210992){_0xc887ee[_0xd0ec('0x1c')](0x194);}return _0x210992;};}function handleError(_0xffeeb8,_0x44d802){_0x44d802=_0x44d802||0x1f4;return function(_0x420675){logger[_0xd0ec('0x2b')](_0x420675[_0xd0ec('0x2c')]);if(_0x420675[_0xd0ec('0x2d')]){delete _0x420675[_0xd0ec('0x2d')];}_0xffeeb8[_0xd0ec('0x1e')](_0x44d802)['send'](_0x420675);};}exports[_0xd0ec('0x2e')]=function(_0x54fe67,_0x3fb125){var _0x1af390={},_0x425473={},_0x417053={'count':0x0,'rows':[]};var _0x487f68=_['map'](db[_0xd0ec('0x2f')][_0xd0ec('0x30')],function(_0x1b8250){return{'name':_0x1b8250[_0xd0ec('0x31')],'type':_0x1b8250[_0xd0ec('0x32')][_0xd0ec('0x33')]};});_0x425473['model']=_[_0xd0ec('0x34')](_0x487f68,_0xd0ec('0x2d'));_0x425473[_0xd0ec('0x35')]=_[_0xd0ec('0x36')](_0x54fe67[_0xd0ec('0x35')]);_0x425473[_0xd0ec('0x37')]=_['intersection'](_0x425473['model'],_0x425473['query']);_0x1af390[_0xd0ec('0x38')]=_[_0xd0ec('0x39')](_0x425473['model'],qs[_0xd0ec('0x3a')](_0x54fe67[_0xd0ec('0x35')][_0xd0ec('0x3a')]));_0x1af390['attributes']=_0x1af390[_0xd0ec('0x38')][_0xd0ec('0x3b')]?_0x1af390[_0xd0ec('0x38')]:_0x425473[_0xd0ec('0x3c')];if(!_0x54fe67[_0xd0ec('0x35')][_0xd0ec('0x3d')]('nolimit')){_0x1af390['limit']=qs[_0xd0ec('0x23')](_0x54fe67[_0xd0ec('0x35')][_0xd0ec('0x23')]);_0x1af390[_0xd0ec('0x20')]=qs[_0xd0ec('0x20')](_0x54fe67[_0xd0ec('0x35')][_0xd0ec('0x20')]);}_0x1af390[_0xd0ec('0x3e')]=qs[_0xd0ec('0x3f')](_0x54fe67['query'][_0xd0ec('0x3f')]);_0x1af390[_0xd0ec('0x40')]=qs[_0xd0ec('0x37')](_[_0xd0ec('0x41')](_0x54fe67[_0xd0ec('0x35')],_0x425473[_0xd0ec('0x37')]),_0x487f68);if(_0x54fe67[_0xd0ec('0x35')][_0xd0ec('0x42')]){_0x1af390[_0xd0ec('0x40')]=_[_0xd0ec('0x43')](_0x1af390[_0xd0ec('0x40')],{'$or':_[_0xd0ec('0x34')](_0x487f68,function(_0x26d006){if(_0x26d006[_0xd0ec('0x32')]!=='VIRTUAL'){var _0x4d7aa1={};_0x4d7aa1[_0x26d006[_0xd0ec('0x2d')]]={'$like':'%'+_0x54fe67['query'][_0xd0ec('0x42')]+'%'};return _0x4d7aa1;}})});}_0x1af390=_[_0xd0ec('0x43')]({},_0x1af390,_0x54fe67[_0xd0ec('0x44')]);var _0x5eae27={'where':_0x1af390[_0xd0ec('0x40')]};return db[_0xd0ec('0x2f')][_0xd0ec('0x22')](_0x5eae27)[_0xd0ec('0x2a')](function(_0x134685){_0x417053[_0xd0ec('0x22')]=_0x134685;if(_0x54fe67['query'][_0xd0ec('0x45')]){_0x1af390['include']=[{'all':!![]}];}return db['OpenchannelQueue'][_0xd0ec('0x46')](_0x1af390);})[_0xd0ec('0x2a')](function(_0x50a1b2){_0x417053[_0xd0ec('0x47')]=_0x50a1b2;return _0x417053;})[_0xd0ec('0x2a')](respondWithFilteredResult(_0x3fb125,_0x1af390))[_0xd0ec('0x48')](handleError(_0x3fb125,null));};exports[_0xd0ec('0x49')]=function(_0x47747e,_0x1afbd2){var _0xc9f1d9={'raw':!![],'where':{'id':_0x47747e[_0xd0ec('0x4a')]['id']}},_0x162a54={};_0x162a54['model']=_['keys'](db[_0xd0ec('0x2f')]['rawAttributes']);_0x162a54['query']=_['keys'](_0x47747e[_0xd0ec('0x35')]);_0x162a54[_0xd0ec('0x37')]=_[_0xd0ec('0x39')](_0x162a54[_0xd0ec('0x3c')],_0x162a54['query']);_0xc9f1d9['attributes']=_[_0xd0ec('0x39')](_0x162a54[_0xd0ec('0x3c')],qs[_0xd0ec('0x3a')](_0x47747e[_0xd0ec('0x35')][_0xd0ec('0x3a')]));_0xc9f1d9[_0xd0ec('0x38')]=_0xc9f1d9[_0xd0ec('0x38')][_0xd0ec('0x3b')]?_0xc9f1d9['attributes']:_0x162a54[_0xd0ec('0x3c')];if(_0x47747e[_0xd0ec('0x35')][_0xd0ec('0x45')]){_0xc9f1d9[_0xd0ec('0x4b')]=[{'all':!![]}];}_0xc9f1d9=_[_0xd0ec('0x43')]({},_0xc9f1d9,_0x47747e[_0xd0ec('0x44')]);return db['OpenchannelQueue'][_0xd0ec('0x4c')](_0xc9f1d9)['then'](handleEntityNotFound(_0x1afbd2,null))[_0xd0ec('0x2a')](respondWithResult(_0x1afbd2,null))[_0xd0ec('0x48')](handleError(_0x1afbd2,null));};exports['create']=function(_0x5a19a9,_0x467957){return db['OpenchannelQueue'][_0xd0ec('0x4d')](_0x5a19a9[_0xd0ec('0x4e')],{})[_0xd0ec('0x2a')](function(_0x866b30){var _0x441b75=_0x5a19a9[_0xd0ec('0x4f')][_0xd0ec('0x29')]({'plain':!![]});if(!_0x441b75)throw new Error(_0xd0ec('0x50'));if(_0x441b75[_0xd0ec('0x51')]===_0xd0ec('0x4f')){var _0x17a4e0=_0x866b30['get']({'plain':!![]});var _0x3f2e32=_0xd0ec('0x52');return db[_0xd0ec('0x53')][_0xd0ec('0x4c')]({'where':{'name':_0x3f2e32,'userProfileId':_0x441b75[_0xd0ec('0x54')]},'raw':!![]})[_0xd0ec('0x2a')](function(_0x498f13){if(_0x498f13&&_0x498f13[_0xd0ec('0x55')]===0x0){return db['UserProfileResource']['create']({'name':_0x17a4e0['name'],'resourceId':_0x17a4e0['id'],'type':_0x498f13[_0xd0ec('0x2d')],'sectionId':_0x498f13['id']},{})[_0xd0ec('0x2a')](function(){return _0x866b30;});}else{return _0x866b30;}})[_0xd0ec('0x48')](function(_0x46bf71){logger[_0xd0ec('0x2b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x46bf71);throw _0x46bf71;});}return _0x866b30;})[_0xd0ec('0x2a')](respondWithResult(_0x467957,0xc9))[_0xd0ec('0x48')](handleError(_0x467957,null));};exports[_0xd0ec('0x56')]=function(_0x21e768,_0x37e435){if(_0x21e768['body']['id']){delete _0x21e768['body']['id'];}return db[_0xd0ec('0x2f')][_0xd0ec('0x4c')]({'where':{'id':_0x21e768[_0xd0ec('0x4a')]['id']}})[_0xd0ec('0x2a')](handleEntityNotFound(_0x37e435,null))[_0xd0ec('0x2a')](saveUpdates(_0x21e768[_0xd0ec('0x4e')],null))[_0xd0ec('0x2a')](respondWithResult(_0x37e435,null))[_0xd0ec('0x48')](handleError(_0x37e435,null));};exports[_0xd0ec('0x28')]=function(_0x234283,_0x5146cc){return db[_0xd0ec('0x2f')][_0xd0ec('0x4c')]({'where':{'id':_0x234283[_0xd0ec('0x4a')]['id']}})[_0xd0ec('0x2a')](handleEntityNotFound(_0x5146cc,null))['then'](removeEntity(_0x5146cc,null))['catch'](handleError(_0x5146cc,null));};exports[_0xd0ec('0x57')]=function(_0xacaa0d,_0x1348df){return db['OpenchannelQueue']['describe']()[_0xd0ec('0x2a')](respondWithResult(_0x1348df,null))[_0xd0ec('0x48')](handleError(_0x1348df,null));};exports['getMembers']=function(_0x1736ee,_0x2b487e,_0x392063){var _0x6dba88={'raw':!![],'where':{}},_0x56e605={},_0x2fe6de;return db[_0xd0ec('0x2f')][_0xd0ec('0x58')]({'where':{'id':_0x1736ee[_0xd0ec('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2b487e,null))[_0xd0ec('0x2a')](function(_0x463a9e){if(_0x463a9e){_0x2fe6de=_0x463a9e['get']({'plain':!![]});_0x56e605[_0xd0ec('0x3c')]=_['keys'](db[_0xd0ec('0x59')][_0xd0ec('0x30')]);_0x56e605[_0xd0ec('0x35')]=_['keys'](_0x1736ee[_0xd0ec('0x35')]);_0x56e605['filters']=_[_0xd0ec('0x39')](_0x56e605[_0xd0ec('0x3c')],_0x56e605['query']);_0x6dba88[_0xd0ec('0x38')]=_[_0xd0ec('0x39')](_0x56e605[_0xd0ec('0x3c')],qs[_0xd0ec('0x3a')](_0x1736ee[_0xd0ec('0x35')][_0xd0ec('0x3a')]));_0x6dba88[_0xd0ec('0x38')]=_0x6dba88[_0xd0ec('0x38')][_0xd0ec('0x3b')]?_0x6dba88[_0xd0ec('0x38')]:_0x56e605[_0xd0ec('0x3c')];if(!_0x1736ee[_0xd0ec('0x35')][_0xd0ec('0x3d')](_0xd0ec('0x5a'))){_0x6dba88[_0xd0ec('0x23')]=qs['limit'](_0x1736ee[_0xd0ec('0x35')][_0xd0ec('0x23')]);_0x6dba88['offset']=qs['offset'](_0x1736ee['query'][_0xd0ec('0x20')]);}_0x6dba88[_0xd0ec('0x3e')]=qs[_0xd0ec('0x3f')](_0x1736ee['query'][_0xd0ec('0x3f')]);_0x6dba88[_0xd0ec('0x40')]=qs[_0xd0ec('0x37')](_[_0xd0ec('0x41')](_0x1736ee['query'],_0x56e605[_0xd0ec('0x37')]));_0x6dba88[_0xd0ec('0x40')][_0xd0ec('0x5b')]=_0x463a9e['id'];if(_0x1736ee[_0xd0ec('0x35')][_0xd0ec('0x42')]){_0x6dba88[_0xd0ec('0x40')]=_[_0xd0ec('0x43')](_0x6dba88[_0xd0ec('0x40')],{'$or':_[_0xd0ec('0x34')](_0x6dba88['attributes'],function(_0x1dd178){var _0x1f4502={};_0x1f4502[_0x1dd178]={'$like':'%'+_0x1736ee[_0xd0ec('0x35')][_0xd0ec('0x42')]+'%'};return _0x1f4502;})});}_0x6dba88=_[_0xd0ec('0x43')]({},_0x6dba88,_0x1736ee[_0xd0ec('0x44')]);return db[_0xd0ec('0x59')]['findAll'](_0x6dba88);}})[_0xd0ec('0x2a')](function(_0x32a6e1){if(_0x32a6e1){return db['User'][_0xd0ec('0x5c')]({'where':{'id':_[_0xd0ec('0x34')](_0x32a6e1,_0xd0ec('0x5d')),'role':_0xd0ec('0x5e')},'attributes':['id',_0xd0ec('0x2d'),_0xd0ec('0x5f'),'updatedAt',_0xd0ec('0x60')]});}})['then'](function(_0x201a7e){if(_0x201a7e){return{'count':_0x201a7e['count'],'rows':_[_0xd0ec('0x34')](_0x201a7e[_0xd0ec('0x47')],function(_0xf2e3f9){return{'membername':_0xf2e3f9[_0xd0ec('0x2d')],'UserId':_0xf2e3f9['id'],'queue_name':_0x2fe6de[_0xd0ec('0x2d')],'OpenchannelQueueId':_0x2fe6de['id'],'interface':util[_0xd0ec('0x61')](_0xd0ec('0x62'),_0xd0ec('0x63'),_0xf2e3f9['name']),'penalty':0x0,'paused':_0xf2e3f9[_0xd0ec('0x5f')],'createdAt':_0xf2e3f9['createdAt'],'updatedAt':_0xf2e3f9[_0xd0ec('0x64')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xd0ec('0x2a')](respondWithFilteredResult(_0x2b487e,_0x6dba88))[_0xd0ec('0x48')](handleError(_0x2b487e,null));};exports[_0xd0ec('0x65')]=function(_0x18df2a,_0x483344,_0x13ab1a){var _0x545e0e={};var _0x58c05c={};var _0x49eb19;var _0x41d4ee;return db[_0xd0ec('0x2f')][_0xd0ec('0x58')]({'where':{'id':_0x18df2a[_0xd0ec('0x4a')]['id']}})[_0xd0ec('0x2a')](handleEntityNotFound(_0x483344,null))[_0xd0ec('0x2a')](function(_0x522f37){if(_0x522f37){_0x49eb19=_0x522f37;_0x58c05c[_0xd0ec('0x3c')]=_['keys'](db[_0xd0ec('0x66')][_0xd0ec('0x30')]);_0x58c05c[_0xd0ec('0x35')]=_[_0xd0ec('0x36')](_0x18df2a['query']);_0x58c05c['filters']=_['intersection'](_0x58c05c['model'],_0x58c05c[_0xd0ec('0x35')]);_0x545e0e['attributes']=_[_0xd0ec('0x39')](_0x58c05c[_0xd0ec('0x3c')],qs['fields'](_0x18df2a[_0xd0ec('0x35')][_0xd0ec('0x3a')]));_0x545e0e[_0xd0ec('0x38')]=_0x545e0e['attributes']['length']?_0x545e0e[_0xd0ec('0x38')]:_0x58c05c[_0xd0ec('0x3c')];_0x545e0e[_0xd0ec('0x3e')]=qs[_0xd0ec('0x3f')](_0x18df2a[_0xd0ec('0x35')][_0xd0ec('0x3f')]);_0x545e0e[_0xd0ec('0x40')]=qs[_0xd0ec('0x37')](_['pick'](_0x18df2a[_0xd0ec('0x35')],_0x58c05c[_0xd0ec('0x37')]));if(_0x18df2a[_0xd0ec('0x35')]['filter']){_0x545e0e[_0xd0ec('0x40')]=_[_0xd0ec('0x43')](_0x545e0e['where'],{'$or':_['map'](_0x545e0e[_0xd0ec('0x38')],function(_0x4a5469){var _0x5e39d8={};_0x5e39d8[_0x4a5469]={'$like':'%'+_0x18df2a[_0xd0ec('0x35')]['filter']+'%'};return _0x5e39d8;})});}_0x545e0e=_[_0xd0ec('0x43')]({},_0x545e0e,_0x18df2a[_0xd0ec('0x44')]);return _0x49eb19['getTeams'](_0x545e0e);}})[_0xd0ec('0x2a')](function(_0x35fba9){if(_0x35fba9){_0x41d4ee=_0x35fba9['length'];if(!_0x18df2a[_0xd0ec('0x35')][_0xd0ec('0x3d')](_0xd0ec('0x5a'))){_0x545e0e[_0xd0ec('0x23')]=qs[_0xd0ec('0x23')](_0x18df2a[_0xd0ec('0x35')]['limit']);_0x545e0e[_0xd0ec('0x20')]=qs['offset'](_0x18df2a[_0xd0ec('0x35')][_0xd0ec('0x20')]);}return _0x49eb19[_0xd0ec('0x65')](_0x545e0e);}})['then'](function(_0x198b88){if(_0x198b88){return _0x198b88?{'count':_0x41d4ee,'rows':_0x198b88}:null;}})[_0xd0ec('0x2a')](respondWithResult(_0x483344,null))[_0xd0ec('0x48')](handleError(_0x483344,null));};exports['addTeams']=function(_0x1fbb61,_0x2e090d,_0x15d2a2){var _0x50963e=_0x1fbb61[_0xd0ec('0x4e')][_0xd0ec('0x67')];return db[_0xd0ec('0x66')][_0xd0ec('0x46')]({'where':{'id':_0x50963e},'attributes':['id'],'include':[{'model':db[_0xd0ec('0x68')],'as':'Agents','attributes':['id','name',_0xd0ec('0x69'),_0xd0ec('0x6a'),_0xd0ec('0x6b')],'raw':!![]}]})[_0xd0ec('0x2a')](function(_0x1a85ba){if(_0x1a85ba){var _0x34b032=_['flatMap'](_0x1a85ba,function(_0x42c1b0){var _0x57d95a=_0x42c1b0[_0xd0ec('0x29')]({'plain':!![]});return _0x57d95a[_0xd0ec('0x6c')];});return db[_0xd0ec('0x2f')][_0xd0ec('0x4c')]({'where':{'id':_0x1fbb61[_0xd0ec('0x4a')]['id']}})[_0xd0ec('0x2a')](function(_0x56ac4d){return db['sequelize'][_0xd0ec('0x6d')](function(_0x2a3115){return _0x56ac4d[_0xd0ec('0x6e')](_0x50963e,{'transaction':_0x2a3115})['then'](function(){return BPromise[_0xd0ec('0x6f')](_0x34b032,function(_0x321e42){return db[_0xd0ec('0x59')]['findOrCreate']({'where':{'UserId':_0x321e42['id'],'OpenchannelQueueId':_0x1fbb61['params']['id']},'transaction':_0x2a3115});});})['then'](function(){_0x34b032['forEach'](function(_0x5e97bd){socket['emit']('userOpenchannelQueue:save',{'UserId':_0x5e97bd['id'],'OpenchannelQueueId':_0x56ac4d['id']});});});});});}})[_0xd0ec('0x2a')](respondWithStatusCode(_0x2e090d,null))[_0xd0ec('0x48')](handleError(_0x2e090d,null));};exports[_0xd0ec('0x70')]=function(_0x85e41d,_0x384048,_0x30af4a){return db[_0xd0ec('0x66')][_0xd0ec('0x46')]({'where':{'id':_0x85e41d['query']['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0xd0ec('0x6c'),'attributes':['id'],'raw':!![]}]})[_0xd0ec('0x2a')](handleEntityNotFound(_0x384048,null))[_0xd0ec('0x2a')](function(_0x508f5b){var _0x1fc1fa=_[_0xd0ec('0x34')](_0x508f5b,'id');var _0x5b05b9=[];var _0x34be40=[];var _0x283708=squel['select']();_0x283708[_0xd0ec('0x71')](_0xd0ec('0x72'))['from'](_0xd0ec('0x73'),'tq')[_0xd0ec('0x74')]('user_has_teams','ut',_0xd0ec('0x75'))['where'](_0xd0ec('0x76'),_0x85e41d['params']['id']);for(var _0x8cfcbd=0x0;_0x8cfcbd<_0x508f5b[_0xd0ec('0x3b')];_0x8cfcbd+=0x1){let _0x4bc022=_0x508f5b[_0x8cfcbd];for(var _0x2fe008=0x0;_0x2fe008<_0x4bc022[_0xd0ec('0x6c')][_0xd0ec('0x3b')];_0x2fe008+=0x1){let _0x3d0402=_0x4bc022[_0xd0ec('0x6c')][_0x2fe008];var _0x558130=_0x283708[_0xd0ec('0x77')]();_0x558130['where'](_0xd0ec('0x78'),_0x3d0402['id']);_0x34be40[_0xd0ec('0x79')](db[_0xd0ec('0x7a')][_0xd0ec('0x35')](_0x558130['toString'](),{'type':db[_0xd0ec('0x7a')]['QueryTypes'][_0xd0ec('0x7b')]})['then'](function(_0x182624){if(_0x182624[_0xd0ec('0x3b')]===0x1){return _0x3d0402['id'];}else{var _0x11e20a=_[_0xd0ec('0x7c')](_['map'](_0x182624,_0xd0ec('0x7d')),function(_0x44afd6){return _[_0xd0ec('0x7e')](_0x1fc1fa,_0x44afd6);});if(_0x11e20a){return _0x3d0402['id'];}}}));}}return BPromise[_0xd0ec('0x7f')](_0x34be40)['then'](function(_0x1d37cd){_0x5b05b9=_(_0x5b05b9)[_0xd0ec('0x80')](_0x1d37cd)[_0xd0ec('0x81')]()[_0xd0ec('0x82')]();return db[_0xd0ec('0x2f')][_0xd0ec('0x4c')]({'where':{'id':_0x85e41d[_0xd0ec('0x4a')]['id']}})[_0xd0ec('0x2a')](function(_0x47dfe2){return db['sequelize'][_0xd0ec('0x6d')](function(_0x5aa913){return _0x47dfe2[_0xd0ec('0x70')](_0x85e41d[_0xd0ec('0x35')][_0xd0ec('0x67')],{'transaction':_0x5aa913})['then'](function(){if(!_[_0xd0ec('0x83')](_0x5b05b9)){return _0x47dfe2[_0xd0ec('0x84')](_0x5b05b9,{'transaction':_0x5aa913});}})[_0xd0ec('0x2a')](function(){_0x5b05b9[_0xd0ec('0x85')](function(_0x29a5c4){socket[_0xd0ec('0x86')](_0xd0ec('0x87'),{'UserId':_0x29a5c4,'OpenchannelQueueId':_0x47dfe2['id']});});});});});});})['then'](respondWithStatusCode(_0x384048,null))['catch'](handleError(_0x384048,null));};exports[_0xd0ec('0x88')]=function(_0x2a47e1,_0xbc9469,_0xddad9d){return db[_0xd0ec('0x2f')][_0xd0ec('0x4c')]({'where':{'id':_0x2a47e1[_0xd0ec('0x4a')]['id']}})['then'](handleEntityNotFound(_0xbc9469,null))['then'](function(_0x3adc7f){if(_0x3adc7f){return _0x3adc7f[_0xd0ec('0x88')](_0x2a47e1[_0xd0ec('0x4e')][_0xd0ec('0x67')],_[_0xd0ec('0x89')](_0x2a47e1[_0xd0ec('0x4e')],[_0xd0ec('0x67'),'id'])||{})[_0xd0ec('0x8a')](function(_0x4272b5){for(var _0x275d3a=0x0;_0x275d3a<_0x2a47e1[_0xd0ec('0x4e')][_0xd0ec('0x67')][_0xd0ec('0x3b')];_0x275d3a+=0x1){socket[_0xd0ec('0x86')](_0xd0ec('0x8b'),{'UserId':Number(_0x2a47e1[_0xd0ec('0x4e')][_0xd0ec('0x67')][_0x275d3a]),'OpenchannelQueueId':Number(_0x2a47e1['params']['id'])});}return _0x4272b5;});}})[_0xd0ec('0x2a')](respondWithResult(_0xbc9469,null))[_0xd0ec('0x48')](handleError(_0xbc9469,null));};exports[_0xd0ec('0x84')]=function(_0x38fa5b,_0x456620,_0x30c133){return db[_0xd0ec('0x2f')][_0xd0ec('0x4c')]({'where':{'id':_0x38fa5b[_0xd0ec('0x4a')]['id']}})[_0xd0ec('0x2a')](handleEntityNotFound(_0x456620,null))[_0xd0ec('0x2a')](function(_0x5b5a4b){if(_0x5b5a4b){return _0x5b5a4b[_0xd0ec('0x84')](_0x38fa5b[_0xd0ec('0x35')][_0xd0ec('0x67')])['then'](function(){if(_[_0xd0ec('0x8c')](_0x38fa5b[_0xd0ec('0x35')][_0xd0ec('0x67')])){for(var _0x1f401a=0x0;_0x1f401a<_0x38fa5b[_0xd0ec('0x35')]['ids'][_0xd0ec('0x3b')];_0x1f401a+=0x1){socket[_0xd0ec('0x86')](_0xd0ec('0x87'),{'UserId':Number(_0x38fa5b[_0xd0ec('0x35')][_0xd0ec('0x67')][_0x1f401a]),'OpenchannelQueueId':Number(_0x38fa5b[_0xd0ec('0x4a')]['id'])});}}else{socket[_0xd0ec('0x86')](_0xd0ec('0x87'),{'UserId':Number(_0x38fa5b[_0xd0ec('0x35')][_0xd0ec('0x67')]),'OpenchannelQueueId':Number(_0x38fa5b['params']['id'])});}});}})[_0xd0ec('0x2a')](respondWithStatusCode(_0x456620,null))[_0xd0ec('0x48')](handleError(_0x456620,null));};exports[_0xd0ec('0x8d')]=function(_0x1ae85c,_0x5c25b9,_0x4ebf31){var _0x4bceb2={};var _0x5b8712={};var _0x520821;var _0x45ebdf;return db[_0xd0ec('0x2f')][_0xd0ec('0x58')]({'where':{'id':_0x1ae85c[_0xd0ec('0x4a')]['id']}})[_0xd0ec('0x2a')](handleEntityNotFound(_0x5c25b9,null))[_0xd0ec('0x2a')](function(_0xade3ed){if(_0xade3ed){_0x520821=_0xade3ed;_0x5b8712[_0xd0ec('0x3c')]=_['keys'](db[_0xd0ec('0x68')][_0xd0ec('0x30')]);_0x5b8712[_0xd0ec('0x35')]=_['keys'](_0x1ae85c[_0xd0ec('0x35')]);_0x5b8712['filters']=_['intersection'](_0x5b8712['model'],_0x5b8712[_0xd0ec('0x35')]);_0x4bceb2[_0xd0ec('0x38')]=_[_0xd0ec('0x39')](_0x5b8712[_0xd0ec('0x3c')],qs['fields'](_0x1ae85c[_0xd0ec('0x35')][_0xd0ec('0x3a')]));_0x4bceb2[_0xd0ec('0x38')]=_0x4bceb2[_0xd0ec('0x38')][_0xd0ec('0x3b')]?_0x4bceb2[_0xd0ec('0x38')]:_0x5b8712[_0xd0ec('0x3c')];_0x4bceb2[_0xd0ec('0x3e')]=qs[_0xd0ec('0x3f')](_0x1ae85c['query'][_0xd0ec('0x3f')]);_0x4bceb2['where']=qs[_0xd0ec('0x37')](_['pick'](_0x1ae85c[_0xd0ec('0x35')],_0x5b8712[_0xd0ec('0x37')]));if(_0x1ae85c[_0xd0ec('0x35')][_0xd0ec('0x42')]){_0x4bceb2[_0xd0ec('0x40')]=_[_0xd0ec('0x43')](_0x4bceb2[_0xd0ec('0x40')],{'$or':_[_0xd0ec('0x34')](_0x4bceb2['attributes'],function(_0xc08d5e){var _0x4112eb={};_0x4112eb[_0xc08d5e]={'$like':'%'+_0x1ae85c[_0xd0ec('0x35')][_0xd0ec('0x42')]+'%'};return _0x4112eb;})});}_0x4bceb2=_[_0xd0ec('0x43')]({},_0x4bceb2,_0x1ae85c['options']);return _0x520821['getAgents'](_0x4bceb2);}})['then'](function(_0x571450){if(_0x571450){_0x45ebdf=_0x571450[_0xd0ec('0x3b')];if(!_0x1ae85c[_0xd0ec('0x35')][_0xd0ec('0x3d')](_0xd0ec('0x5a'))){_0x4bceb2[_0xd0ec('0x23')]=qs['limit'](_0x1ae85c[_0xd0ec('0x35')][_0xd0ec('0x23')]);_0x4bceb2[_0xd0ec('0x20')]=qs[_0xd0ec('0x20')](_0x1ae85c[_0xd0ec('0x35')]['offset']);}return _0x520821['getAgents'](_0x4bceb2);}})[_0xd0ec('0x2a')](function(_0x9db987){if(_0x9db987){return _0x9db987?{'count':_0x45ebdf,'rows':_0x9db987}:null;}})[_0xd0ec('0x2a')](respondWithResult(_0x5c25b9,null))[_0xd0ec('0x48')](handleError(_0x5c25b9,null));};
\ No newline at end of file
+var _0xa129=['tq.TeamId','from','team_has_openchannel_queues','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','toString','sequelize','QueryTypes','SELECT','every','union','compact','value','isEmpty','removeAgents','emit','userOpenchannelQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','rimraf','fast-json-patch','request-promise','mustache','util','path','ejs','fs-extra','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','register','status','json','offset','limit','undefined','count','set','Content-Range','apply','save','update','destroy','OpenchannelQueues','UserProfileResource','then','end','sendStatus','error','stack','name','send','index','map','OpenchannelQueue','rawAttributes','fieldName','key','model','query','keys','filters','attributes','fields','length','nolimit','order','sort','filter','where','merge','VIRTUAL','options','include','findAll','rows','catch','show','params','intersection','includeAll','find','create','body','user','get','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserOpenchannelQueue','pick','OpenchannelQueueId','findAndCountAll','UserId','agent','openchannelPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','hasOwnProperty','addTeams','ids','Agents','online','voicePause','interface','flatMap','transaction','each','forEach','removeTeams','User','select'];(function(_0xa9c870,_0x111b20){var _0x2d13a3=function(_0x2e41f4){while(--_0x2e41f4){_0xa9c870['push'](_0xa9c870['shift']());}};_0x2d13a3(++_0x111b20);}(_0xa129,0x136));var _0x9a12=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xa129[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0x9a12('0x0'));var rimraf=require(_0x9a12('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x9a12('0x2'));var rp=require(_0x9a12('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x9a12('0x4'));var util=require(_0x9a12('0x5'));var path=require(_0x9a12('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x9a12('0x7'));var fs=require('fs');var fs_extra=require(_0x9a12('0x8'));var _=require('lodash');var squel=require(_0x9a12('0x9'));var crypto=require('crypto');var jsforce=require(_0x9a12('0xa'));var deskjs=require(_0x9a12('0xb'));var toCsv=require(_0x9a12('0xc'));var querystring=require(_0x9a12('0xd'));var Papa=require(_0x9a12('0xe'));var Redis=require(_0x9a12('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x9a12('0x10'));var as=require(_0x9a12('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9a12('0x12'))(_0x9a12('0x13'));var utils=require(_0x9a12('0x14'));var config=require(_0x9a12('0x15'));var licenseUtil=require(_0x9a12('0x16'));var db=require(_0x9a12('0x17'))['db'];config[_0x9a12('0x18')]=_[_0x9a12('0x19')](config[_0x9a12('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0x9a12('0x1a'))(new Redis(config[_0x9a12('0x18')]));require('./openchannelQueue.socket')[_0x9a12('0x1b')](socket);function respondWithStatusCode(_0x2e7ffb,_0x295142){_0x295142=_0x295142||0xcc;return function(_0x3839b5){if(_0x3839b5){return _0x2e7ffb['sendStatus'](_0x295142);}return _0x2e7ffb['status'](_0x295142)['end']();};}function respondWithResult(_0x28fd5a,_0x5c2292){_0x5c2292=_0x5c2292||0xc8;return function(_0x34c7b9){if(_0x34c7b9){return _0x28fd5a[_0x9a12('0x1c')](_0x5c2292)[_0x9a12('0x1d')](_0x34c7b9);}};}function respondWithFilteredResult(_0x4a0bbb,_0x59e296){return function(_0x2bd764){if(_0x2bd764){var _0x3c9e16=typeof _0x59e296[_0x9a12('0x1e')]==='undefined'&&typeof _0x59e296[_0x9a12('0x1f')]===_0x9a12('0x20');var _0x102255=_0x2bd764[_0x9a12('0x21')];var _0x5e1aba=_0x3c9e16?0x0:_0x59e296[_0x9a12('0x1e')];var _0x386285=_0x3c9e16?_0x2bd764[_0x9a12('0x21')]:_0x59e296[_0x9a12('0x1e')]+_0x59e296[_0x9a12('0x1f')];var _0x31273e;if(_0x386285>=_0x102255){_0x386285=_0x102255;_0x31273e=0xc8;}else{_0x31273e=0xce;}_0x4a0bbb[_0x9a12('0x1c')](_0x31273e);return _0x4a0bbb[_0x9a12('0x22')](_0x9a12('0x23'),_0x5e1aba+'-'+_0x386285+'/'+_0x102255)[_0x9a12('0x1d')](_0x2bd764);}return null;};}function patchUpdates(_0x3b8e3b){return function(_0x454387){try{jsonpatch[_0x9a12('0x24')](_0x454387,_0x3b8e3b,!![]);}catch(_0xf39560){return BPromise['reject'](_0xf39560);}return _0x454387[_0x9a12('0x25')]();};}function saveUpdates(_0x49e094,_0x2e8e7c){return function(_0x1f1f89){if(_0x1f1f89){return _0x1f1f89[_0x9a12('0x26')](_0x49e094)['then'](function(_0x5a0f33){return _0x5a0f33;});}return null;};}function removeEntity(_0x597e97,_0x470a7b){return function(_0x44781a){if(_0x44781a){return _0x44781a[_0x9a12('0x27')]()['then'](function(){var _0x1f2227=_0x44781a['get']({'plain':!![]});var _0x2fc555=_0x9a12('0x28');return db[_0x9a12('0x29')][_0x9a12('0x27')]({'where':{'type':_0x2fc555,'resourceId':_0x1f2227['id']}})[_0x9a12('0x2a')](function(){return _0x44781a;});})['then'](function(){_0x597e97[_0x9a12('0x1c')](0xcc)[_0x9a12('0x2b')]();});}};}function handleEntityNotFound(_0x3680cd,_0x2678ee){return function(_0x2da584){if(!_0x2da584){_0x3680cd[_0x9a12('0x2c')](0x194);}return _0x2da584;};}function handleError(_0x431773,_0x5859ec){_0x5859ec=_0x5859ec||0x1f4;return function(_0x38bdea){logger[_0x9a12('0x2d')](_0x38bdea[_0x9a12('0x2e')]);if(_0x38bdea[_0x9a12('0x2f')]){delete _0x38bdea[_0x9a12('0x2f')];}_0x431773[_0x9a12('0x1c')](_0x5859ec)[_0x9a12('0x30')](_0x38bdea);};}exports[_0x9a12('0x31')]=function(_0x3ec84d,_0x534580){var _0x44f877={},_0x4b978d={},_0x406727={'count':0x0,'rows':[]};var _0x279f7d=_[_0x9a12('0x32')](db[_0x9a12('0x33')][_0x9a12('0x34')],function(_0x27b14e){return{'name':_0x27b14e[_0x9a12('0x35')],'type':_0x27b14e['type'][_0x9a12('0x36')]};});_0x4b978d[_0x9a12('0x37')]=_[_0x9a12('0x32')](_0x279f7d,_0x9a12('0x2f'));_0x4b978d[_0x9a12('0x38')]=_[_0x9a12('0x39')](_0x3ec84d['query']);_0x4b978d[_0x9a12('0x3a')]=_['intersection'](_0x4b978d[_0x9a12('0x37')],_0x4b978d[_0x9a12('0x38')]);_0x44f877[_0x9a12('0x3b')]=_['intersection'](_0x4b978d[_0x9a12('0x37')],qs[_0x9a12('0x3c')](_0x3ec84d['query'][_0x9a12('0x3c')]));_0x44f877['attributes']=_0x44f877[_0x9a12('0x3b')][_0x9a12('0x3d')]?_0x44f877[_0x9a12('0x3b')]:_0x4b978d[_0x9a12('0x37')];if(!_0x3ec84d[_0x9a12('0x38')]['hasOwnProperty'](_0x9a12('0x3e'))){_0x44f877['limit']=qs[_0x9a12('0x1f')](_0x3ec84d['query']['limit']);_0x44f877[_0x9a12('0x1e')]=qs[_0x9a12('0x1e')](_0x3ec84d['query'][_0x9a12('0x1e')]);}_0x44f877[_0x9a12('0x3f')]=qs[_0x9a12('0x40')](_0x3ec84d[_0x9a12('0x38')][_0x9a12('0x40')]);_0x44f877['where']=qs[_0x9a12('0x3a')](_['pick'](_0x3ec84d[_0x9a12('0x38')],_0x4b978d[_0x9a12('0x3a')]),_0x279f7d);if(_0x3ec84d[_0x9a12('0x38')][_0x9a12('0x41')]){_0x44f877[_0x9a12('0x42')]=_[_0x9a12('0x43')](_0x44f877['where'],{'$or':_[_0x9a12('0x32')](_0x279f7d,function(_0x56803c){if(_0x56803c['type']!==_0x9a12('0x44')){var _0x527e71={};_0x527e71[_0x56803c[_0x9a12('0x2f')]]={'$like':'%'+_0x3ec84d[_0x9a12('0x38')][_0x9a12('0x41')]+'%'};return _0x527e71;}})});}_0x44f877=_[_0x9a12('0x43')]({},_0x44f877,_0x3ec84d[_0x9a12('0x45')]);var _0x1fb8d1={'where':_0x44f877[_0x9a12('0x42')]};return db[_0x9a12('0x33')][_0x9a12('0x21')](_0x1fb8d1)[_0x9a12('0x2a')](function(_0x4d40dd){_0x406727['count']=_0x4d40dd;if(_0x3ec84d['query']['includeAll']){_0x44f877[_0x9a12('0x46')]=[{'all':!![]}];}return db['OpenchannelQueue'][_0x9a12('0x47')](_0x44f877);})[_0x9a12('0x2a')](function(_0x1d4d05){_0x406727[_0x9a12('0x48')]=_0x1d4d05;return _0x406727;})[_0x9a12('0x2a')](respondWithFilteredResult(_0x534580,_0x44f877))[_0x9a12('0x49')](handleError(_0x534580,null));};exports[_0x9a12('0x4a')]=function(_0x4df50e,_0x210b4d){var _0x24664d={'raw':!![],'where':{'id':_0x4df50e[_0x9a12('0x4b')]['id']}},_0x4f5917={};_0x4f5917[_0x9a12('0x37')]=_[_0x9a12('0x39')](db[_0x9a12('0x33')]['rawAttributes']);_0x4f5917['query']=_[_0x9a12('0x39')](_0x4df50e[_0x9a12('0x38')]);_0x4f5917[_0x9a12('0x3a')]=_['intersection'](_0x4f5917[_0x9a12('0x37')],_0x4f5917['query']);_0x24664d[_0x9a12('0x3b')]=_[_0x9a12('0x4c')](_0x4f5917[_0x9a12('0x37')],qs[_0x9a12('0x3c')](_0x4df50e[_0x9a12('0x38')][_0x9a12('0x3c')]));_0x24664d[_0x9a12('0x3b')]=_0x24664d[_0x9a12('0x3b')][_0x9a12('0x3d')]?_0x24664d[_0x9a12('0x3b')]:_0x4f5917[_0x9a12('0x37')];if(_0x4df50e[_0x9a12('0x38')][_0x9a12('0x4d')]){_0x24664d[_0x9a12('0x46')]=[{'all':!![]}];}_0x24664d=_[_0x9a12('0x43')]({},_0x24664d,_0x4df50e['options']);return db[_0x9a12('0x33')][_0x9a12('0x4e')](_0x24664d)[_0x9a12('0x2a')](handleEntityNotFound(_0x210b4d,null))['then'](respondWithResult(_0x210b4d,null))[_0x9a12('0x49')](handleError(_0x210b4d,null));};exports[_0x9a12('0x4f')]=function(_0x346830,_0x4e6b0b){return db['OpenchannelQueue'][_0x9a12('0x4f')](_0x346830[_0x9a12('0x50')],{})['then'](function(_0x47d7fb){var _0xf9386=_0x346830[_0x9a12('0x51')][_0x9a12('0x52')]({'plain':!![]});if(!_0xf9386)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xf9386[_0x9a12('0x53')]===_0x9a12('0x51')){var _0x3e0f71=_0x47d7fb['get']({'plain':!![]});var _0x90e1ea='OpenchannelQueues';return db[_0x9a12('0x54')]['find']({'where':{'name':_0x90e1ea,'userProfileId':_0xf9386[_0x9a12('0x55')]},'raw':!![]})[_0x9a12('0x2a')](function(_0x2c0c0e){if(_0x2c0c0e&&_0x2c0c0e[_0x9a12('0x56')]===0x0){return db[_0x9a12('0x29')][_0x9a12('0x4f')]({'name':_0x3e0f71[_0x9a12('0x2f')],'resourceId':_0x3e0f71['id'],'type':_0x2c0c0e[_0x9a12('0x2f')],'sectionId':_0x2c0c0e['id']},{})['then'](function(){return _0x47d7fb;});}else{return _0x47d7fb;}})[_0x9a12('0x49')](function(_0x3a9be2){logger['error'](_0x9a12('0x57'),_0x3a9be2);throw _0x3a9be2;});}return _0x47d7fb;})['then'](respondWithResult(_0x4e6b0b,0xc9))[_0x9a12('0x49')](handleError(_0x4e6b0b,null));};exports['update']=function(_0x13b2a7,_0x4a4555){if(_0x13b2a7[_0x9a12('0x50')]['id']){delete _0x13b2a7['body']['id'];}return db['OpenchannelQueue']['find']({'where':{'id':_0x13b2a7[_0x9a12('0x4b')]['id']}})[_0x9a12('0x2a')](handleEntityNotFound(_0x4a4555,null))['then'](saveUpdates(_0x13b2a7['body'],null))[_0x9a12('0x2a')](respondWithResult(_0x4a4555,null))[_0x9a12('0x49')](handleError(_0x4a4555,null));};exports[_0x9a12('0x27')]=function(_0x3d88e8,_0x61d2a0){return db[_0x9a12('0x33')][_0x9a12('0x4e')]({'where':{'id':_0x3d88e8['params']['id']}})[_0x9a12('0x2a')](handleEntityNotFound(_0x61d2a0,null))[_0x9a12('0x2a')](removeEntity(_0x61d2a0,null))[_0x9a12('0x49')](handleError(_0x61d2a0,null));};exports[_0x9a12('0x58')]=function(_0x4b7145,_0x172ac3){return db[_0x9a12('0x33')][_0x9a12('0x58')]()[_0x9a12('0x2a')](respondWithResult(_0x172ac3,null))[_0x9a12('0x49')](handleError(_0x172ac3,null));};exports[_0x9a12('0x59')]=function(_0x4945f5,_0x3c31e5,_0x58df8a){var _0x30a1a4={'raw':!![],'where':{}},_0x428df7={},_0x441cbb;return db[_0x9a12('0x33')][_0x9a12('0x5a')]({'where':{'id':_0x4945f5[_0x9a12('0x4b')]['id']}})[_0x9a12('0x2a')](handleEntityNotFound(_0x3c31e5,null))[_0x9a12('0x2a')](function(_0x5f3bc5){if(_0x5f3bc5){_0x441cbb=_0x5f3bc5[_0x9a12('0x52')]({'plain':!![]});_0x428df7['model']=_[_0x9a12('0x39')](db[_0x9a12('0x5b')][_0x9a12('0x34')]);_0x428df7['query']=_['keys'](_0x4945f5[_0x9a12('0x38')]);_0x428df7[_0x9a12('0x3a')]=_[_0x9a12('0x4c')](_0x428df7[_0x9a12('0x37')],_0x428df7['query']);_0x30a1a4['attributes']=_[_0x9a12('0x4c')](_0x428df7[_0x9a12('0x37')],qs[_0x9a12('0x3c')](_0x4945f5[_0x9a12('0x38')][_0x9a12('0x3c')]));_0x30a1a4[_0x9a12('0x3b')]=_0x30a1a4['attributes']['length']?_0x30a1a4[_0x9a12('0x3b')]:_0x428df7[_0x9a12('0x37')];if(!_0x4945f5[_0x9a12('0x38')]['hasOwnProperty'](_0x9a12('0x3e'))){_0x30a1a4[_0x9a12('0x1f')]=qs[_0x9a12('0x1f')](_0x4945f5[_0x9a12('0x38')][_0x9a12('0x1f')]);_0x30a1a4['offset']=qs['offset'](_0x4945f5[_0x9a12('0x38')][_0x9a12('0x1e')]);}_0x30a1a4[_0x9a12('0x3f')]=qs[_0x9a12('0x40')](_0x4945f5[_0x9a12('0x38')][_0x9a12('0x40')]);_0x30a1a4[_0x9a12('0x42')]=qs[_0x9a12('0x3a')](_[_0x9a12('0x5c')](_0x4945f5[_0x9a12('0x38')],_0x428df7[_0x9a12('0x3a')]));_0x30a1a4[_0x9a12('0x42')][_0x9a12('0x5d')]=_0x5f3bc5['id'];if(_0x4945f5['query']['filter']){_0x30a1a4[_0x9a12('0x42')]=_[_0x9a12('0x43')](_0x30a1a4[_0x9a12('0x42')],{'$or':_[_0x9a12('0x32')](_0x30a1a4[_0x9a12('0x3b')],function(_0x30fafa){var _0x1b8512={};_0x1b8512[_0x30fafa]={'$like':'%'+_0x4945f5[_0x9a12('0x38')][_0x9a12('0x41')]+'%'};return _0x1b8512;})});}_0x30a1a4=_['merge']({},_0x30a1a4,_0x4945f5[_0x9a12('0x45')]);return db[_0x9a12('0x5b')][_0x9a12('0x47')](_0x30a1a4);}})[_0x9a12('0x2a')](function(_0x552bb4){if(_0x552bb4){return db['User'][_0x9a12('0x5e')]({'where':{'id':_[_0x9a12('0x32')](_0x552bb4,_0x9a12('0x5f')),'role':_0x9a12('0x60')},'attributes':['id',_0x9a12('0x2f'),_0x9a12('0x61'),_0x9a12('0x62'),_0x9a12('0x63')]});}})[_0x9a12('0x2a')](function(_0x1b72a1){if(_0x1b72a1){return{'count':_0x1b72a1[_0x9a12('0x21')],'rows':_[_0x9a12('0x32')](_0x1b72a1[_0x9a12('0x48')],function(_0x38820c){return{'membername':_0x38820c[_0x9a12('0x2f')],'UserId':_0x38820c['id'],'queue_name':_0x441cbb[_0x9a12('0x2f')],'OpenchannelQueueId':_0x441cbb['id'],'interface':util[_0x9a12('0x64')](_0x9a12('0x65'),_0x9a12('0x66'),_0x38820c['name']),'penalty':0x0,'paused':_0x38820c[_0x9a12('0x61')],'createdAt':_0x38820c['createdAt'],'updatedAt':_0x38820c[_0x9a12('0x62')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x3c31e5,_0x30a1a4))['catch'](handleError(_0x3c31e5,null));};exports[_0x9a12('0x67')]=function(_0x591af5,_0xdfef8f,_0x44d8d9){var _0x57b967={};var _0x4431f6={};var _0x4acbcf;var _0x297941;return db[_0x9a12('0x33')][_0x9a12('0x5a')]({'where':{'id':_0x591af5[_0x9a12('0x4b')]['id']}})[_0x9a12('0x2a')](handleEntityNotFound(_0xdfef8f,null))['then'](function(_0x2597fd){if(_0x2597fd){_0x4acbcf=_0x2597fd;_0x4431f6[_0x9a12('0x37')]=_['keys'](db[_0x9a12('0x68')][_0x9a12('0x34')]);_0x4431f6['query']=_[_0x9a12('0x39')](_0x591af5[_0x9a12('0x38')]);_0x4431f6[_0x9a12('0x3a')]=_[_0x9a12('0x4c')](_0x4431f6[_0x9a12('0x37')],_0x4431f6[_0x9a12('0x38')]);_0x57b967['attributes']=_[_0x9a12('0x4c')](_0x4431f6[_0x9a12('0x37')],qs['fields'](_0x591af5[_0x9a12('0x38')][_0x9a12('0x3c')]));_0x57b967[_0x9a12('0x3b')]=_0x57b967[_0x9a12('0x3b')][_0x9a12('0x3d')]?_0x57b967[_0x9a12('0x3b')]:_0x4431f6[_0x9a12('0x37')];_0x57b967[_0x9a12('0x3f')]=qs['sort'](_0x591af5['query'][_0x9a12('0x40')]);_0x57b967[_0x9a12('0x42')]=qs[_0x9a12('0x3a')](_[_0x9a12('0x5c')](_0x591af5[_0x9a12('0x38')],_0x4431f6[_0x9a12('0x3a')]));if(_0x591af5[_0x9a12('0x38')][_0x9a12('0x41')]){_0x57b967[_0x9a12('0x42')]=_['merge'](_0x57b967['where'],{'$or':_['map'](_0x57b967[_0x9a12('0x3b')],function(_0x1adbec){var _0x36c745={};_0x36c745[_0x1adbec]={'$like':'%'+_0x591af5[_0x9a12('0x38')][_0x9a12('0x41')]+'%'};return _0x36c745;})});}_0x57b967=_[_0x9a12('0x43')]({},_0x57b967,_0x591af5[_0x9a12('0x45')]);return _0x4acbcf[_0x9a12('0x67')](_0x57b967);}})['then'](function(_0x15d1c3){if(_0x15d1c3){_0x297941=_0x15d1c3['length'];if(!_0x591af5['query'][_0x9a12('0x69')](_0x9a12('0x3e'))){_0x57b967[_0x9a12('0x1f')]=qs[_0x9a12('0x1f')](_0x591af5['query'][_0x9a12('0x1f')]);_0x57b967['offset']=qs['offset'](_0x591af5[_0x9a12('0x38')][_0x9a12('0x1e')]);}return _0x4acbcf[_0x9a12('0x67')](_0x57b967);}})[_0x9a12('0x2a')](function(_0x1b9c9c){if(_0x1b9c9c){return _0x1b9c9c?{'count':_0x297941,'rows':_0x1b9c9c}:null;}})[_0x9a12('0x2a')](respondWithResult(_0xdfef8f,null))['catch'](handleError(_0xdfef8f,null));};exports[_0x9a12('0x6a')]=function(_0x4f6588,_0x58bb41,_0x15ba32){var _0x2709de=_0x4f6588[_0x9a12('0x50')][_0x9a12('0x6b')];return db[_0x9a12('0x68')]['findAll']({'where':{'id':_0x2709de},'attributes':['id'],'include':[{'model':db['User'],'as':_0x9a12('0x6c'),'attributes':['id',_0x9a12('0x2f'),_0x9a12('0x6d'),_0x9a12('0x6e'),_0x9a12('0x6f')],'raw':!![]}]})['then'](function(_0x48e5fd){if(_0x48e5fd){var _0x413daf=_[_0x9a12('0x70')](_0x48e5fd,function(_0x40353f){var _0x4c68cd=_0x40353f[_0x9a12('0x52')]({'plain':!![]});return _0x4c68cd['Agents'];});return db[_0x9a12('0x33')][_0x9a12('0x4e')]({'where':{'id':_0x4f6588[_0x9a12('0x4b')]['id']}})[_0x9a12('0x2a')](function(_0x2a17a7){return db['sequelize'][_0x9a12('0x71')](function(_0x13be59){return _0x2a17a7[_0x9a12('0x6a')](_0x2709de,{'transaction':_0x13be59})[_0x9a12('0x2a')](function(){return BPromise[_0x9a12('0x72')](_0x413daf,function(_0x532d15){return db[_0x9a12('0x5b')]['findOrCreate']({'where':{'UserId':_0x532d15['id'],'OpenchannelQueueId':_0x4f6588[_0x9a12('0x4b')]['id']},'transaction':_0x13be59});});})['then'](function(){_0x413daf[_0x9a12('0x73')](function(_0x112ad4){socket['emit']('userOpenchannelQueue:save',{'UserId':_0x112ad4['id'],'OpenchannelQueueId':_0x2a17a7['id']});});});});});}})['then'](respondWithStatusCode(_0x58bb41,null))[_0x9a12('0x49')](handleError(_0x58bb41,null));};exports[_0x9a12('0x74')]=function(_0x2e2398,_0x4d2f08,_0x41cfed){return db[_0x9a12('0x68')]['findAll']({'where':{'id':_0x2e2398[_0x9a12('0x38')][_0x9a12('0x6b')]},'attributes':['id'],'include':[{'model':db[_0x9a12('0x75')],'as':_0x9a12('0x6c'),'attributes':['id'],'raw':!![]}]})[_0x9a12('0x2a')](handleEntityNotFound(_0x4d2f08,null))['then'](function(_0x12b790){var _0x2072a3=_[_0x9a12('0x32')](_0x12b790,'id');var _0x417cfe=[];var _0xd73e08=[];var _0x12222f=squel[_0x9a12('0x76')]();_0x12222f['field'](_0x9a12('0x77'))[_0x9a12('0x78')](_0x9a12('0x79'),'tq')['join']('user_has_teams','ut',_0x9a12('0x7a'))['where']('OpenchannelQueueId\x20=\x20?',_0x2e2398[_0x9a12('0x4b')]['id']);for(var _0x547f03=0x0;_0x547f03<_0x12b790['length'];_0x547f03+=0x1){let _0xeb740=_0x12b790[_0x547f03];for(var _0x3fe5f8=0x0;_0x3fe5f8<_0xeb740[_0x9a12('0x6c')][_0x9a12('0x3d')];_0x3fe5f8+=0x1){let _0x4933e0=_0xeb740[_0x9a12('0x6c')][_0x3fe5f8];var _0x5254e3=_0x12222f[_0x9a12('0x7b')]();_0x5254e3[_0x9a12('0x42')](_0x9a12('0x7c'),_0x4933e0['id']);_0xd73e08[_0x9a12('0x7d')](db['sequelize']['query'](_0x5254e3[_0x9a12('0x7e')](),{'type':db[_0x9a12('0x7f')][_0x9a12('0x80')][_0x9a12('0x81')]})['then'](function(_0x4be8d7){if(_0x4be8d7[_0x9a12('0x3d')]===0x1){return _0x4933e0['id'];}else{var _0x49c7d0=_[_0x9a12('0x82')](_['map'](_0x4be8d7,'TeamId'),function(_0x1e3495){return _['includes'](_0x2072a3,_0x1e3495);});if(_0x49c7d0){return _0x4933e0['id'];}}}));}}return BPromise['all'](_0xd73e08)[_0x9a12('0x2a')](function(_0x979181){_0x417cfe=_(_0x417cfe)[_0x9a12('0x83')](_0x979181)[_0x9a12('0x84')]()[_0x9a12('0x85')]();return db[_0x9a12('0x33')][_0x9a12('0x4e')]({'where':{'id':_0x2e2398[_0x9a12('0x4b')]['id']}})[_0x9a12('0x2a')](function(_0x272cfc){return db[_0x9a12('0x7f')][_0x9a12('0x71')](function(_0x4d79a9){return _0x272cfc[_0x9a12('0x74')](_0x2e2398[_0x9a12('0x38')]['ids'],{'transaction':_0x4d79a9})[_0x9a12('0x2a')](function(){if(!_[_0x9a12('0x86')](_0x417cfe)){return _0x272cfc[_0x9a12('0x87')](_0x417cfe,{'transaction':_0x4d79a9});}})[_0x9a12('0x2a')](function(){_0x417cfe[_0x9a12('0x73')](function(_0x3ad260){socket[_0x9a12('0x88')](_0x9a12('0x89'),{'UserId':_0x3ad260,'OpenchannelQueueId':_0x272cfc['id']});});});});});});})[_0x9a12('0x2a')](respondWithStatusCode(_0x4d2f08,null))[_0x9a12('0x49')](handleError(_0x4d2f08,null));};exports[_0x9a12('0x8a')]=function(_0x48ea7e,_0x48a918,_0x6f53b4){return db[_0x9a12('0x33')]['find']({'where':{'id':_0x48ea7e[_0x9a12('0x4b')]['id']}})[_0x9a12('0x2a')](handleEntityNotFound(_0x48a918,null))[_0x9a12('0x2a')](function(_0x76a53b){if(_0x76a53b){return _0x76a53b[_0x9a12('0x8a')](_0x48ea7e[_0x9a12('0x50')][_0x9a12('0x6b')],_[_0x9a12('0x8b')](_0x48ea7e[_0x9a12('0x50')],['ids','id'])||{})[_0x9a12('0x8c')](function(_0x169ada){for(var _0x46197e=0x0;_0x46197e<_0x48ea7e['body'][_0x9a12('0x6b')][_0x9a12('0x3d')];_0x46197e+=0x1){socket[_0x9a12('0x88')]('userOpenchannelQueue:save',{'UserId':Number(_0x48ea7e['body'][_0x9a12('0x6b')][_0x46197e]),'OpenchannelQueueId':Number(_0x48ea7e[_0x9a12('0x4b')]['id'])});}return _0x169ada;});}})[_0x9a12('0x2a')](respondWithResult(_0x48a918,null))[_0x9a12('0x49')](handleError(_0x48a918,null));};exports[_0x9a12('0x87')]=function(_0x192259,_0x4e736b,_0x244e7a){return db['OpenchannelQueue'][_0x9a12('0x4e')]({'where':{'id':_0x192259[_0x9a12('0x4b')]['id']}})['then'](handleEntityNotFound(_0x4e736b,null))[_0x9a12('0x2a')](function(_0x34ac05){if(_0x34ac05){return _0x34ac05[_0x9a12('0x87')](_0x192259[_0x9a12('0x38')]['ids'])['then'](function(){if(_[_0x9a12('0x8d')](_0x192259[_0x9a12('0x38')][_0x9a12('0x6b')])){for(var _0x643939=0x0;_0x643939<_0x192259[_0x9a12('0x38')][_0x9a12('0x6b')][_0x9a12('0x3d')];_0x643939+=0x1){socket[_0x9a12('0x88')]('userOpenchannelQueue:remove',{'UserId':Number(_0x192259['query'][_0x9a12('0x6b')][_0x643939]),'OpenchannelQueueId':Number(_0x192259[_0x9a12('0x4b')]['id'])});}}else{socket[_0x9a12('0x88')](_0x9a12('0x89'),{'UserId':Number(_0x192259[_0x9a12('0x38')]['ids']),'OpenchannelQueueId':Number(_0x192259[_0x9a12('0x4b')]['id'])});}});}})[_0x9a12('0x2a')](respondWithStatusCode(_0x4e736b,null))[_0x9a12('0x49')](handleError(_0x4e736b,null));};exports[_0x9a12('0x8e')]=function(_0x56344d,_0x47609f,_0x374fde){var _0xa362={};var _0x1e7900={};var _0x114cbd;var _0xe83d1c;return db[_0x9a12('0x33')][_0x9a12('0x5a')]({'where':{'id':_0x56344d['params']['id']}})['then'](handleEntityNotFound(_0x47609f,null))[_0x9a12('0x2a')](function(_0x413f3e){if(_0x413f3e){_0x114cbd=_0x413f3e;_0x1e7900['model']=_[_0x9a12('0x39')](db[_0x9a12('0x75')]['rawAttributes']);_0x1e7900[_0x9a12('0x38')]=_[_0x9a12('0x39')](_0x56344d['query']);_0x1e7900[_0x9a12('0x3a')]=_[_0x9a12('0x4c')](_0x1e7900['model'],_0x1e7900[_0x9a12('0x38')]);_0xa362[_0x9a12('0x3b')]=_[_0x9a12('0x4c')](_0x1e7900[_0x9a12('0x37')],qs['fields'](_0x56344d['query']['fields']));_0xa362['attributes']=_0xa362[_0x9a12('0x3b')]['length']?_0xa362['attributes']:_0x1e7900[_0x9a12('0x37')];_0xa362[_0x9a12('0x3f')]=qs[_0x9a12('0x40')](_0x56344d[_0x9a12('0x38')][_0x9a12('0x40')]);_0xa362[_0x9a12('0x42')]=qs[_0x9a12('0x3a')](_[_0x9a12('0x5c')](_0x56344d[_0x9a12('0x38')],_0x1e7900[_0x9a12('0x3a')]));if(_0x56344d['query'][_0x9a12('0x41')]){_0xa362[_0x9a12('0x42')]=_['merge'](_0xa362[_0x9a12('0x42')],{'$or':_[_0x9a12('0x32')](_0xa362[_0x9a12('0x3b')],function(_0x37de47){var _0xa009={};_0xa009[_0x37de47]={'$like':'%'+_0x56344d[_0x9a12('0x38')]['filter']+'%'};return _0xa009;})});}_0xa362=_['merge']({},_0xa362,_0x56344d[_0x9a12('0x45')]);return _0x114cbd[_0x9a12('0x8e')](_0xa362);}})[_0x9a12('0x2a')](function(_0x4eeb0c){if(_0x4eeb0c){_0xe83d1c=_0x4eeb0c[_0x9a12('0x3d')];if(!_0x56344d[_0x9a12('0x38')][_0x9a12('0x69')](_0x9a12('0x3e'))){_0xa362[_0x9a12('0x1f')]=qs[_0x9a12('0x1f')](_0x56344d['query'][_0x9a12('0x1f')]);_0xa362['offset']=qs[_0x9a12('0x1e')](_0x56344d[_0x9a12('0x38')][_0x9a12('0x1e')]);}return _0x114cbd[_0x9a12('0x8e')](_0xa362);}})[_0x9a12('0x2a')](function(_0x5b56ba){if(_0x5b56ba){return _0x5b56ba?{'count':_0xe83d1c,'rows':_0x5b56ba}:null;}})[_0x9a12('0x2a')](respondWithResult(_0x47609f,null))[_0x9a12('0x49')](handleError(_0x47609f,null));};
\ No newline at end of file