Built motion from commit f7863d46.|2.5.41
[motion2.git] / server / api / openchannelQueue / openchannelQueue.controller.js
index d13dfef..9fe615c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5f75=['hasOwnProperty','nolimit','limit','order','sort','pick','filter','where','type','merge','options','includeAll','include','findAll','catch','show','params','rawAttributes','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','UserProfileResource','describe','getMembers','findOne','UserOpenchannelQueue','length','User','findAndCountAll','UserId','openchannelPause','updatedAt','createdAt','rows','format','%s/%s','SIP','getTeams','Team','ids','Agents','online','voicePause','sequelize','addTeams','findOrCreate','forEach','emit','userOpenchannelQueue:save','select','field','tq.TeamId','from','join','user_has_teams','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','all','union','value','transaction','removeTeams','isEmpty','removeAgents','addAgents','omit','isArray','userOpenchannelQueue:remove','getAgents','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','sendStatus','status','end','json','count','offset','set','Content-Range','apply','reject','save','update','destroy','then','OpenchannelQueues','error','stack','name','send','index','map','OpenchannelQueue','fieldName','key','model','query','keys','filters','intersection','attributes','fields'];(function(_0x5b0d3e,_0x41a931){var _0x47af4a=function(_0x40d400){while(--_0x40d400){_0x5b0d3e['push'](_0x5b0d3e['shift']());}};_0x47af4a(++_0x41a931);}(_0x5f75,0x15f));var _0x55f7=function(_0x3925ff,_0x3fe6e5){_0x3925ff=_0x3925ff-0x0;var _0x1f16d5=_0x5f75[_0x3925ff];return _0x1f16d5;};'use strict';var pdf=require(_0x55f7('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x55f7('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x55f7('0x2'));var rp=require(_0x55f7('0x3'));var moment=require(_0x55f7('0x4'));var BPromise=require(_0x55f7('0x5'));var Mustache=require('mustache');var util=require(_0x55f7('0x6'));var path=require(_0x55f7('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x55f7('0x8'));var crypto=require(_0x55f7('0x9'));var jsforce=require(_0x55f7('0xa'));var deskjs=require(_0x55f7('0xb'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x55f7('0xc'));var Redis=require(_0x55f7('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x55f7('0xe'));var as=require(_0x55f7('0xf'));var hardwareService=require(_0x55f7('0x10'));var logger=require('../../config/logger')(_0x55f7('0x11'));var utils=require(_0x55f7('0x12'));var config=require('../../config/environment');var licenseUtil=require(_0x55f7('0x13'));var db=require('../../mysqldb')['db'];config[_0x55f7('0x14')]=_[_0x55f7('0x15')](config[_0x55f7('0x14')],{'host':_0x55f7('0x16'),'port':0x18eb});var socket=require(_0x55f7('0x17'))(new Redis(config['redis']));require(_0x55f7('0x18'))[_0x55f7('0x19')](socket);function respondWithStatusCode(_0x25a3f5,_0x4f6c10){_0x4f6c10=_0x4f6c10||0xcc;return function(_0x19bf4d){if(_0x19bf4d){return _0x25a3f5[_0x55f7('0x1a')](_0x4f6c10);}return _0x25a3f5[_0x55f7('0x1b')](_0x4f6c10)[_0x55f7('0x1c')]();};}function respondWithResult(_0x49a768,_0x186eb4){_0x186eb4=_0x186eb4||0xc8;return function(_0x3d2139){if(_0x3d2139){return _0x49a768['status'](_0x186eb4)[_0x55f7('0x1d')](_0x3d2139);}};}function respondWithFilteredResult(_0x213523,_0x40fec5){return function(_0x22db54){if(_0x22db54){var _0x26e5d7=_0x22db54[_0x55f7('0x1e')],_0x510138=_0x40fec5[_0x55f7('0x1f')],_0x32cd8d=_0x40fec5[_0x55f7('0x1f')]+_0x40fec5['limit'],_0x1d608c;if(_0x32cd8d>=_0x26e5d7){_0x32cd8d=_0x26e5d7;_0x1d608c=0xc8;}else{_0x1d608c=0xce;}_0x213523['status'](_0x1d608c);return _0x213523[_0x55f7('0x20')](_0x55f7('0x21'),_0x510138+'-'+_0x32cd8d+'/'+_0x26e5d7)['json'](_0x22db54);}return null;};}function patchUpdates(_0x287a00){return function(_0x4d1dea){try{jsonpatch[_0x55f7('0x22')](_0x4d1dea,_0x287a00,!![]);}catch(_0x5f764d){return BPromise[_0x55f7('0x23')](_0x5f764d);}return _0x4d1dea[_0x55f7('0x24')]();};}function saveUpdates(_0x33e26f,_0x1b4d9a){return function(_0x4fc3d5){if(_0x4fc3d5){return _0x4fc3d5[_0x55f7('0x25')](_0x33e26f)['then'](function(_0x64115d){return _0x64115d;});}return null;};}function removeEntity(_0x116b53,_0x30ae51){return function(_0x423fba){if(_0x423fba){return _0x423fba[_0x55f7('0x26')]()[_0x55f7('0x27')](function(){var _0x44ed71=_0x423fba['get']({'plain':!![]});var _0x3866df=_0x55f7('0x28');return db['UserProfileResource'][_0x55f7('0x26')]({'where':{'type':_0x3866df,'resourceId':_0x44ed71['id']}})[_0x55f7('0x27')](function(){return _0x423fba;});})[_0x55f7('0x27')](function(){_0x116b53[_0x55f7('0x1b')](0xcc)[_0x55f7('0x1c')]();});}};}function handleEntityNotFound(_0x4f71a8,_0x49e6b4){return function(_0x2b45ef){if(!_0x2b45ef){_0x4f71a8[_0x55f7('0x1a')](0x194);}return _0x2b45ef;};}function handleError(_0x42049e,_0x56ebb4){_0x56ebb4=_0x56ebb4||0x1f4;return function(_0x170392){logger[_0x55f7('0x29')](_0x170392[_0x55f7('0x2a')]);if(_0x170392['name']){delete _0x170392[_0x55f7('0x2b')];}_0x42049e[_0x55f7('0x1b')](_0x56ebb4)[_0x55f7('0x2c')](_0x170392);};}exports[_0x55f7('0x2d')]=function(_0x343124,_0x490afe){var _0x447a51={},_0xe75f14={},_0x357075={'count':0x0,'rows':[]};var _0x1c05d5=_[_0x55f7('0x2e')](db[_0x55f7('0x2f')]['rawAttributes'],function(_0x54808a){return{'name':_0x54808a[_0x55f7('0x30')],'type':_0x54808a['type'][_0x55f7('0x31')]};});_0xe75f14[_0x55f7('0x32')]=_[_0x55f7('0x2e')](_0x1c05d5,_0x55f7('0x2b'));_0xe75f14[_0x55f7('0x33')]=_[_0x55f7('0x34')](_0x343124['query']);_0xe75f14[_0x55f7('0x35')]=_[_0x55f7('0x36')](_0xe75f14[_0x55f7('0x32')],_0xe75f14[_0x55f7('0x33')]);_0x447a51[_0x55f7('0x37')]=_[_0x55f7('0x36')](_0xe75f14['model'],qs[_0x55f7('0x38')](_0x343124[_0x55f7('0x33')][_0x55f7('0x38')]));_0x447a51[_0x55f7('0x37')]=_0x447a51[_0x55f7('0x37')]['length']?_0x447a51[_0x55f7('0x37')]:_0xe75f14[_0x55f7('0x32')];if(!_0x343124[_0x55f7('0x33')][_0x55f7('0x39')](_0x55f7('0x3a'))){_0x447a51[_0x55f7('0x3b')]=qs[_0x55f7('0x3b')](_0x343124[_0x55f7('0x33')][_0x55f7('0x3b')]);_0x447a51[_0x55f7('0x1f')]=qs[_0x55f7('0x1f')](_0x343124['query']['offset']);}_0x447a51[_0x55f7('0x3c')]=qs[_0x55f7('0x3d')](_0x343124[_0x55f7('0x33')][_0x55f7('0x3d')]);_0x447a51['where']=qs['filters'](_[_0x55f7('0x3e')](_0x343124[_0x55f7('0x33')],_0xe75f14['filters']),_0x1c05d5);if(_0x343124['query'][_0x55f7('0x3f')]){_0x447a51[_0x55f7('0x40')]=_['merge'](_0x447a51['where'],{'$or':_[_0x55f7('0x2e')](_0x1c05d5,function(_0x43f95f){if(_0x43f95f[_0x55f7('0x41')]!=='VIRTUAL'){var _0x34b1b8={};_0x34b1b8[_0x43f95f[_0x55f7('0x2b')]]={'$like':'%'+_0x343124[_0x55f7('0x33')]['filter']+'%'};return _0x34b1b8;}})});}_0x447a51=_[_0x55f7('0x42')]({},_0x447a51,_0x343124[_0x55f7('0x43')]);var _0x1af9ff={'where':_0x447a51['where']};return db['OpenchannelQueue'][_0x55f7('0x1e')](_0x1af9ff)[_0x55f7('0x27')](function(_0x6d2b71){_0x357075[_0x55f7('0x1e')]=_0x6d2b71;if(_0x343124['query'][_0x55f7('0x44')]){_0x447a51[_0x55f7('0x45')]=[{'all':!![]}];}return db[_0x55f7('0x2f')][_0x55f7('0x46')](_0x447a51);})['then'](function(_0x56b07a){_0x357075['rows']=_0x56b07a;return _0x357075;})[_0x55f7('0x27')](respondWithFilteredResult(_0x490afe,_0x447a51))[_0x55f7('0x47')](handleError(_0x490afe,null));};exports[_0x55f7('0x48')]=function(_0x48193d,_0x5c8663){var _0x30b645={'raw':!![],'where':{'id':_0x48193d[_0x55f7('0x49')]['id']}},_0x301056={};_0x301056['model']=_[_0x55f7('0x34')](db[_0x55f7('0x2f')][_0x55f7('0x4a')]);_0x301056[_0x55f7('0x33')]=_[_0x55f7('0x34')](_0x48193d[_0x55f7('0x33')]);_0x301056[_0x55f7('0x35')]=_[_0x55f7('0x36')](_0x301056[_0x55f7('0x32')],_0x301056['query']);_0x30b645[_0x55f7('0x37')]=_[_0x55f7('0x36')](_0x301056[_0x55f7('0x32')],qs[_0x55f7('0x38')](_0x48193d['query'][_0x55f7('0x38')]));_0x30b645['attributes']=_0x30b645[_0x55f7('0x37')]['length']?_0x30b645[_0x55f7('0x37')]:_0x301056[_0x55f7('0x32')];if(_0x48193d[_0x55f7('0x33')][_0x55f7('0x44')]){_0x30b645[_0x55f7('0x45')]=[{'all':!![]}];}_0x30b645=_[_0x55f7('0x42')]({},_0x30b645,_0x48193d[_0x55f7('0x43')]);return db[_0x55f7('0x2f')]['find'](_0x30b645)['then'](handleEntityNotFound(_0x5c8663,null))[_0x55f7('0x27')](respondWithResult(_0x5c8663,null))[_0x55f7('0x47')](handleError(_0x5c8663,null));};exports['create']=function(_0x34a642,_0x415e82){return db['OpenchannelQueue'][_0x55f7('0x4b')](_0x34a642[_0x55f7('0x4c')],{})[_0x55f7('0x27')](function(_0x5d446d){var _0x51bd04=_0x34a642[_0x55f7('0x4d')][_0x55f7('0x4e')]({'plain':!![]});if(!_0x51bd04)throw new Error(_0x55f7('0x4f'));if(_0x51bd04[_0x55f7('0x50')]==='user'){var _0x47fdba=_0x5d446d[_0x55f7('0x4e')]({'plain':!![]});var _0x2e1de2=_0x55f7('0x28');return db[_0x55f7('0x51')][_0x55f7('0x52')]({'where':{'name':_0x2e1de2,'userProfileId':_0x51bd04[_0x55f7('0x53')]},'raw':!![]})['then'](function(_0x70ff48){if(_0x70ff48&&_0x70ff48['autoAssociation']===0x0){return db[_0x55f7('0x54')][_0x55f7('0x4b')]({'name':_0x47fdba[_0x55f7('0x2b')],'resourceId':_0x47fdba['id'],'type':_0x70ff48[_0x55f7('0x2b')],'sectionId':_0x70ff48['id']},{})[_0x55f7('0x27')](function(){return _0x5d446d;});}else{return _0x5d446d;}})[_0x55f7('0x47')](function(_0xbb92a0){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xbb92a0);throw _0xbb92a0;});}return _0x5d446d;})[_0x55f7('0x27')](respondWithResult(_0x415e82,0xc9))[_0x55f7('0x47')](handleError(_0x415e82,null));};exports[_0x55f7('0x25')]=function(_0x465f3e,_0x2041dd){if(_0x465f3e[_0x55f7('0x4c')]['id']){delete _0x465f3e[_0x55f7('0x4c')]['id'];}return db[_0x55f7('0x2f')][_0x55f7('0x52')]({'where':{'id':_0x465f3e[_0x55f7('0x49')]['id']}})[_0x55f7('0x27')](handleEntityNotFound(_0x2041dd,null))[_0x55f7('0x27')](saveUpdates(_0x465f3e[_0x55f7('0x4c')],null))[_0x55f7('0x27')](respondWithResult(_0x2041dd,null))[_0x55f7('0x47')](handleError(_0x2041dd,null));};exports[_0x55f7('0x26')]=function(_0xabd764,_0x949f26){return db[_0x55f7('0x2f')]['find']({'where':{'id':_0xabd764['params']['id']}})[_0x55f7('0x27')](handleEntityNotFound(_0x949f26,null))['then'](removeEntity(_0x949f26,null))[_0x55f7('0x47')](handleError(_0x949f26,null));};exports['describe']=function(_0x3713c9,_0x1a8b54){return db[_0x55f7('0x2f')][_0x55f7('0x55')]()[_0x55f7('0x27')](respondWithResult(_0x1a8b54,null))[_0x55f7('0x47')](handleError(_0x1a8b54,null));};exports[_0x55f7('0x56')]=function(_0x455aa9,_0x34f156,_0x114731){var _0x20470e={'raw':!![],'where':{}},_0x3db168={},_0x358aeb;return db[_0x55f7('0x2f')][_0x55f7('0x57')]({'where':{'id':_0x455aa9[_0x55f7('0x49')]['id']}})['then'](handleEntityNotFound(_0x34f156,null))[_0x55f7('0x27')](function(_0xdac41f){if(_0xdac41f){_0x358aeb=_0xdac41f[_0x55f7('0x4e')]({'plain':!![]});_0x3db168[_0x55f7('0x32')]=_[_0x55f7('0x34')](db[_0x55f7('0x58')]['rawAttributes']);_0x3db168[_0x55f7('0x33')]=_['keys'](_0x455aa9[_0x55f7('0x33')]);_0x3db168[_0x55f7('0x35')]=_[_0x55f7('0x36')](_0x3db168['model'],_0x3db168[_0x55f7('0x33')]);_0x20470e[_0x55f7('0x37')]=_[_0x55f7('0x36')](_0x3db168[_0x55f7('0x32')],qs[_0x55f7('0x38')](_0x455aa9[_0x55f7('0x33')]['fields']));_0x20470e[_0x55f7('0x37')]=_0x20470e[_0x55f7('0x37')][_0x55f7('0x59')]?_0x20470e['attributes']:_0x3db168[_0x55f7('0x32')];if(!_0x455aa9[_0x55f7('0x33')][_0x55f7('0x39')](_0x55f7('0x3a'))){_0x20470e[_0x55f7('0x3b')]=qs[_0x55f7('0x3b')](_0x455aa9[_0x55f7('0x33')][_0x55f7('0x3b')]);_0x20470e[_0x55f7('0x1f')]=qs[_0x55f7('0x1f')](_0x455aa9[_0x55f7('0x33')][_0x55f7('0x1f')]);}_0x20470e[_0x55f7('0x3c')]=qs[_0x55f7('0x3d')](_0x455aa9['query'][_0x55f7('0x3d')]);_0x20470e[_0x55f7('0x40')]=qs[_0x55f7('0x35')](_['pick'](_0x455aa9[_0x55f7('0x33')],_0x3db168[_0x55f7('0x35')]));_0x20470e[_0x55f7('0x40')]['OpenchannelQueueId']=_0xdac41f['id'];if(_0x455aa9[_0x55f7('0x33')][_0x55f7('0x3f')]){_0x20470e[_0x55f7('0x40')]=_[_0x55f7('0x42')](_0x20470e['where'],{'$or':_[_0x55f7('0x2e')](_0x20470e[_0x55f7('0x37')],function(_0x124d51){var _0x1471a8={};_0x1471a8[_0x124d51]={'$like':'%'+_0x455aa9['query']['filter']+'%'};return _0x1471a8;})});}_0x20470e=_[_0x55f7('0x42')]({},_0x20470e,_0x455aa9[_0x55f7('0x43')]);return db[_0x55f7('0x58')]['findAll'](_0x20470e);}})['then'](function(_0x16ea9b){if(_0x16ea9b){return db[_0x55f7('0x5a')][_0x55f7('0x5b')]({'where':{'id':_[_0x55f7('0x2e')](_0x16ea9b,_0x55f7('0x5c')),'role':'agent'},'attributes':['id','name',_0x55f7('0x5d'),_0x55f7('0x5e'),_0x55f7('0x5f')]});}})[_0x55f7('0x27')](function(_0x41e0f3){if(_0x41e0f3){return{'count':_0x41e0f3[_0x55f7('0x1e')],'rows':_[_0x55f7('0x2e')](_0x41e0f3[_0x55f7('0x60')],function(_0x2cdb4a){return{'membername':_0x2cdb4a['name'],'UserId':_0x2cdb4a['id'],'queue_name':_0x358aeb[_0x55f7('0x2b')],'OpenchannelQueueId':_0x358aeb['id'],'interface':util[_0x55f7('0x61')](_0x55f7('0x62'),_0x55f7('0x63'),_0x2cdb4a['name']),'penalty':0x0,'paused':_0x2cdb4a[_0x55f7('0x5d')],'createdAt':_0x2cdb4a[_0x55f7('0x5f')],'updatedAt':_0x2cdb4a[_0x55f7('0x5e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x55f7('0x27')](respondWithFilteredResult(_0x34f156,_0x20470e))['catch'](handleError(_0x34f156,null));};exports[_0x55f7('0x64')]=function(_0x56139f,_0xf1e7c0,_0x313464){var _0x5d961d={};var _0x2a9b83={};var _0x518170;var _0x177ffc;return db['OpenchannelQueue'][_0x55f7('0x57')]({'where':{'id':_0x56139f[_0x55f7('0x49')]['id']}})[_0x55f7('0x27')](handleEntityNotFound(_0xf1e7c0,null))[_0x55f7('0x27')](function(_0x1f1eb0){if(_0x1f1eb0){_0x518170=_0x1f1eb0;_0x2a9b83[_0x55f7('0x32')]=_['keys'](db[_0x55f7('0x65')][_0x55f7('0x4a')]);_0x2a9b83['query']=_['keys'](_0x56139f[_0x55f7('0x33')]);_0x2a9b83[_0x55f7('0x35')]=_[_0x55f7('0x36')](_0x2a9b83[_0x55f7('0x32')],_0x2a9b83[_0x55f7('0x33')]);_0x5d961d[_0x55f7('0x37')]=_[_0x55f7('0x36')](_0x2a9b83[_0x55f7('0x32')],qs[_0x55f7('0x38')](_0x56139f[_0x55f7('0x33')][_0x55f7('0x38')]));_0x5d961d[_0x55f7('0x37')]=_0x5d961d['attributes'][_0x55f7('0x59')]?_0x5d961d[_0x55f7('0x37')]:_0x2a9b83['model'];_0x5d961d['order']=qs[_0x55f7('0x3d')](_0x56139f[_0x55f7('0x33')]['sort']);_0x5d961d[_0x55f7('0x40')]=qs[_0x55f7('0x35')](_[_0x55f7('0x3e')](_0x56139f['query'],_0x2a9b83[_0x55f7('0x35')]));if(_0x56139f[_0x55f7('0x33')][_0x55f7('0x3f')]){_0x5d961d[_0x55f7('0x40')]=_[_0x55f7('0x42')](_0x5d961d[_0x55f7('0x40')],{'$or':_[_0x55f7('0x2e')](_0x5d961d[_0x55f7('0x37')],function(_0x8f83b4){var _0x2fc911={};_0x2fc911[_0x8f83b4]={'$like':'%'+_0x56139f['query'][_0x55f7('0x3f')]+'%'};return _0x2fc911;})});}_0x5d961d=_['merge']({},_0x5d961d,_0x56139f['options']);return _0x518170[_0x55f7('0x64')](_0x5d961d);}})[_0x55f7('0x27')](function(_0xd242d1){if(_0xd242d1){_0x177ffc=_0xd242d1[_0x55f7('0x59')];if(!_0x56139f[_0x55f7('0x33')][_0x55f7('0x39')](_0x55f7('0x3a'))){_0x5d961d[_0x55f7('0x3b')]=qs['limit'](_0x56139f['query'][_0x55f7('0x3b')]);_0x5d961d[_0x55f7('0x1f')]=qs[_0x55f7('0x1f')](_0x56139f['query']['offset']);}return _0x518170['getTeams'](_0x5d961d);}})['then'](function(_0xc212b4){if(_0xc212b4){return _0xc212b4?{'count':_0x177ffc,'rows':_0xc212b4}:null;}})[_0x55f7('0x27')](respondWithResult(_0xf1e7c0,null))[_0x55f7('0x47')](handleError(_0xf1e7c0,null));};exports['addTeams']=function(_0x392621,_0x22315b,_0x56a8d7){var _0x221fe5=_0x392621[_0x55f7('0x4c')][_0x55f7('0x66')];return db[_0x55f7('0x65')][_0x55f7('0x46')]({'where':{'id':_0x221fe5},'attributes':['id'],'include':[{'model':db[_0x55f7('0x5a')],'as':_0x55f7('0x67'),'attributes':['id',_0x55f7('0x2b'),_0x55f7('0x68'),_0x55f7('0x69'),'interface'],'raw':!![]}]})[_0x55f7('0x27')](function(_0x3ef9c4){if(_0x3ef9c4){var _0xb3faa0=_['flatMap'](_0x3ef9c4,function(_0x10532a){var _0x341338=_0x10532a[_0x55f7('0x4e')]({'plain':!![]});return _0x341338[_0x55f7('0x67')];});return db['OpenchannelQueue'][_0x55f7('0x52')]({'where':{'id':_0x392621[_0x55f7('0x49')]['id']}})[_0x55f7('0x27')](function(_0x3fa238){return db[_0x55f7('0x6a')]['transaction'](function(_0x454c19){return _0x3fa238[_0x55f7('0x6b')](_0x221fe5,{'transaction':_0x454c19})[_0x55f7('0x27')](function(){return BPromise['each'](_0xb3faa0,function(_0x1e793e){return db['UserOpenchannelQueue'][_0x55f7('0x6c')]({'where':{'UserId':_0x1e793e['id'],'OpenchannelQueueId':_0x392621[_0x55f7('0x49')]['id']},'transaction':_0x454c19});});})['then'](function(){_0xb3faa0[_0x55f7('0x6d')](function(_0x4654fd){socket[_0x55f7('0x6e')](_0x55f7('0x6f'),{'UserId':_0x4654fd['id'],'OpenchannelQueueId':_0x3fa238['id']});});});});});}})[_0x55f7('0x27')](respondWithStatusCode(_0x22315b,null))[_0x55f7('0x47')](handleError(_0x22315b,null));};exports['removeTeams']=function(_0x5027ae,_0x105e5f,_0x123102){return db['Team'][_0x55f7('0x46')]({'where':{'id':_0x5027ae[_0x55f7('0x33')][_0x55f7('0x66')]},'attributes':['id'],'include':[{'model':db[_0x55f7('0x5a')],'as':_0x55f7('0x67'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x105e5f,null))['then'](function(_0x1f276c){var _0x20355c=_[_0x55f7('0x2e')](_0x1f276c,'id');var _0x34577b=[];var _0x49c38c=[];var _0x3c1ed3=squel[_0x55f7('0x70')]();_0x3c1ed3[_0x55f7('0x71')](_0x55f7('0x72'))[_0x55f7('0x73')]('team_has_openchannel_queues','tq')[_0x55f7('0x74')](_0x55f7('0x75'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x55f7('0x40')]('OpenchannelQueueId\x20=\x20?',_0x5027ae[_0x55f7('0x49')]['id']);for(var _0x2c4b6c=0x0;_0x2c4b6c<_0x1f276c[_0x55f7('0x59')];_0x2c4b6c+=0x1){let _0xf2e721=_0x1f276c[_0x2c4b6c];for(var _0x1e8b7f=0x0;_0x1e8b7f<_0xf2e721[_0x55f7('0x67')][_0x55f7('0x59')];_0x1e8b7f+=0x1){let _0x5c32da=_0xf2e721[_0x55f7('0x67')][_0x1e8b7f];var _0x217602=_0x3c1ed3['clone']();_0x217602[_0x55f7('0x40')](_0x55f7('0x76'),_0x5c32da['id']);_0x49c38c['push'](db[_0x55f7('0x6a')][_0x55f7('0x33')](_0x217602[_0x55f7('0x77')](),{'type':db[_0x55f7('0x6a')][_0x55f7('0x78')][_0x55f7('0x79')]})[_0x55f7('0x27')](function(_0x31cd85){if(_0x31cd85[_0x55f7('0x59')]===0x1){return _0x5c32da['id'];}else{var _0x5934b0=_[_0x55f7('0x7a')](_['map'](_0x31cd85,_0x55f7('0x7b')),function(_0x6868e3){return _['includes'](_0x20355c,_0x6868e3);});if(_0x5934b0){return _0x5c32da['id'];}}}));}}return BPromise[_0x55f7('0x7c')](_0x49c38c)['then'](function(_0x3036d5){_0x34577b=_(_0x34577b)[_0x55f7('0x7d')](_0x3036d5)['compact']()[_0x55f7('0x7e')]();return db[_0x55f7('0x2f')][_0x55f7('0x52')]({'where':{'id':_0x5027ae[_0x55f7('0x49')]['id']}})['then'](function(_0x12b70d){return db[_0x55f7('0x6a')][_0x55f7('0x7f')](function(_0x3fbb2d){return _0x12b70d[_0x55f7('0x80')](_0x5027ae['query']['ids'],{'transaction':_0x3fbb2d})['then'](function(){if(!_[_0x55f7('0x81')](_0x34577b)){return _0x12b70d[_0x55f7('0x82')](_0x34577b,{'transaction':_0x3fbb2d});}})[_0x55f7('0x27')](function(){_0x34577b['forEach'](function(_0x29165d){socket['emit']('userOpenchannelQueue:remove',{'UserId':_0x29165d,'OpenchannelQueueId':_0x12b70d['id']});});});});});});})['then'](respondWithStatusCode(_0x105e5f,null))[_0x55f7('0x47')](handleError(_0x105e5f,null));};exports[_0x55f7('0x83')]=function(_0x1a40c1,_0xe8ed74,_0x1c849f){return db['OpenchannelQueue']['find']({'where':{'id':_0x1a40c1[_0x55f7('0x49')]['id']}})[_0x55f7('0x27')](handleEntityNotFound(_0xe8ed74,null))[_0x55f7('0x27')](function(_0x58e3b9){if(_0x58e3b9){return _0x58e3b9[_0x55f7('0x83')](_0x1a40c1['body'][_0x55f7('0x66')],_[_0x55f7('0x84')](_0x1a40c1['body'],[_0x55f7('0x66'),'id'])||{})['spread'](function(_0x2e6bf2){for(var _0x537c07=0x0;_0x537c07<_0x1a40c1['body']['ids']['length'];_0x537c07+=0x1){socket[_0x55f7('0x6e')]('userOpenchannelQueue:save',{'UserId':_0x1a40c1[_0x55f7('0x4c')][_0x55f7('0x66')][_0x537c07],'OpenchannelQueueId':_0x1a40c1['params']['id']});}return _0x2e6bf2;});}})['then'](respondWithResult(_0xe8ed74,null))[_0x55f7('0x47')](handleError(_0xe8ed74,null));};exports['removeAgents']=function(_0x3b6b4d,_0xe96bf4,_0x188184){return db[_0x55f7('0x2f')][_0x55f7('0x52')]({'where':{'id':_0x3b6b4d[_0x55f7('0x49')]['id']}})[_0x55f7('0x27')](handleEntityNotFound(_0xe96bf4,null))[_0x55f7('0x27')](function(_0x3a64b9){if(_0x3a64b9){return _0x3a64b9[_0x55f7('0x82')](_0x3b6b4d[_0x55f7('0x33')][_0x55f7('0x66')])[_0x55f7('0x27')](function(){if(_[_0x55f7('0x85')](_0x3b6b4d[_0x55f7('0x33')][_0x55f7('0x66')])){for(var _0x2ac17a=0x0;_0x2ac17a<_0x3b6b4d[_0x55f7('0x33')][_0x55f7('0x66')][_0x55f7('0x59')];_0x2ac17a+=0x1){socket[_0x55f7('0x6e')](_0x55f7('0x86'),{'UserId':Number(_0x3b6b4d[_0x55f7('0x33')][_0x55f7('0x66')][_0x2ac17a]),'OpenchannelQueueId':Number(_0x3b6b4d[_0x55f7('0x49')]['id'])});}}else{socket[_0x55f7('0x6e')](_0x55f7('0x86'),{'UserId':Number(_0x3b6b4d['query']['ids']),'OpenchannelQueueId':Number(_0x3b6b4d['params']['id'])});}});}})[_0x55f7('0x27')](respondWithStatusCode(_0xe96bf4,null))[_0x55f7('0x47')](handleError(_0xe96bf4,null));};exports[_0x55f7('0x87')]=function(_0x2b7dd2,_0x26525c,_0x53548d){var _0x530c09={};var _0x489ffa={};var _0x57e6ac;var _0x33a3f1;return db['OpenchannelQueue'][_0x55f7('0x57')]({'where':{'id':_0x2b7dd2[_0x55f7('0x49')]['id']}})[_0x55f7('0x27')](handleEntityNotFound(_0x26525c,null))[_0x55f7('0x27')](function(_0x3e0234){if(_0x3e0234){_0x57e6ac=_0x3e0234;_0x489ffa['model']=_[_0x55f7('0x34')](db[_0x55f7('0x5a')]['rawAttributes']);_0x489ffa[_0x55f7('0x33')]=_[_0x55f7('0x34')](_0x2b7dd2[_0x55f7('0x33')]);_0x489ffa[_0x55f7('0x35')]=_[_0x55f7('0x36')](_0x489ffa[_0x55f7('0x32')],_0x489ffa[_0x55f7('0x33')]);_0x530c09[_0x55f7('0x37')]=_[_0x55f7('0x36')](_0x489ffa['model'],qs['fields'](_0x2b7dd2[_0x55f7('0x33')]['fields']));_0x530c09[_0x55f7('0x37')]=_0x530c09[_0x55f7('0x37')][_0x55f7('0x59')]?_0x530c09[_0x55f7('0x37')]:_0x489ffa['model'];_0x530c09[_0x55f7('0x3c')]=qs['sort'](_0x2b7dd2[_0x55f7('0x33')]['sort']);_0x530c09['where']=qs[_0x55f7('0x35')](_['pick'](_0x2b7dd2[_0x55f7('0x33')],_0x489ffa[_0x55f7('0x35')]));if(_0x2b7dd2['query'][_0x55f7('0x3f')]){_0x530c09['where']=_[_0x55f7('0x42')](_0x530c09[_0x55f7('0x40')],{'$or':_[_0x55f7('0x2e')](_0x530c09[_0x55f7('0x37')],function(_0x5e9d5d){var _0xfc2924={};_0xfc2924[_0x5e9d5d]={'$like':'%'+_0x2b7dd2[_0x55f7('0x33')][_0x55f7('0x3f')]+'%'};return _0xfc2924;})});}_0x530c09=_[_0x55f7('0x42')]({},_0x530c09,_0x2b7dd2[_0x55f7('0x43')]);return _0x57e6ac[_0x55f7('0x87')](_0x530c09);}})[_0x55f7('0x27')](function(_0x2d4c0d){if(_0x2d4c0d){_0x33a3f1=_0x2d4c0d[_0x55f7('0x59')];if(!_0x2b7dd2[_0x55f7('0x33')][_0x55f7('0x39')](_0x55f7('0x3a'))){_0x530c09[_0x55f7('0x3b')]=qs['limit'](_0x2b7dd2[_0x55f7('0x33')][_0x55f7('0x3b')]);_0x530c09['offset']=qs[_0x55f7('0x1f')](_0x2b7dd2[_0x55f7('0x33')][_0x55f7('0x1f')]);}return _0x57e6ac['getAgents'](_0x530c09);}})['then'](function(_0x3d0563){if(_0x3d0563){return _0x3d0563?{'count':_0x33a3f1,'rows':_0x3d0563}:null;}})[_0x55f7('0x27')](respondWithResult(_0x26525c,null))[_0x55f7('0x47')](handleError(_0x26525c,null));};
\ No newline at end of file
+var _0x49df=['fields','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','then','includeAll','findAll','catch','show','params','length','include','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','name','describe','getMembers','findOne','UserOpenchannelQueue','rawAttributes','nolimit','OpenchannelQueueId','User','findAndCountAll','updatedAt','rows','format','%s/%s','SIP','openchannelPause','createdAt','getTeams','Team','addTeams','ids','Agents','online','voicePause','interface','flatMap','transaction','each','forEach','userOpenchannelQueue:save','removeTeams','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','clone','sequelize','toString','every','all','value','removeAgents','emit','omit','spread','isArray','userOpenchannelQueue:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','ejs','squel','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','status','end','json','offset','count','limit','set','Content-Range','reject','save','update','destroy','OpenchannelQueues','UserProfileResource','stack','index','OpenchannelQueue','fieldName','type','key','model','map','keys','filters','intersection','attributes','query'];(function(_0x441f7a,_0x576321){var _0x4821da=function(_0x5c5b52){while(--_0x5c5b52){_0x441f7a['push'](_0x441f7a['shift']());}};_0x4821da(++_0x576321);}(_0x49df,0x158));var _0xf49d=function(_0x320f22,_0x488293){_0x320f22=_0x320f22-0x0;var _0x281311=_0x49df[_0x320f22];return _0x281311;};'use strict';var emlformat=require(_0xf49d('0x0'));var rimraf=require(_0xf49d('0x1'));var zipdir=require(_0xf49d('0x2'));var jsonpatch=require(_0xf49d('0x3'));var rp=require(_0xf49d('0x4'));var moment=require('moment');var BPromise=require(_0xf49d('0x5'));var Mustache=require(_0xf49d('0x6'));var util=require(_0xf49d('0x7'));var path=require(_0xf49d('0x8'));var sox=require(_0xf49d('0x9'));var csv=require('to-csv');var ejs=require(_0xf49d('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xf49d('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xf49d('0xc'));var querystring=require(_0xf49d('0xd'));var Papa=require(_0xf49d('0xe'));var Redis=require(_0xf49d('0xf'));var authService=require(_0xf49d('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xf49d('0x11'));var hardwareService=require(_0xf49d('0x12'));var logger=require(_0xf49d('0x13'))(_0xf49d('0x14'));var utils=require('../../config/utils');var config=require(_0xf49d('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xf49d('0x16'))['db'];config[_0xf49d('0x17')]=_[_0xf49d('0x18')](config[_0xf49d('0x17')],{'host':_0xf49d('0x19'),'port':0x18eb});var socket=require(_0xf49d('0x1a'))(new Redis(config[_0xf49d('0x17')]));require('./openchannelQueue.socket')['register'](socket);function respondWithStatusCode(_0x6bfab3,_0x42db27){_0x42db27=_0x42db27||0xcc;return function(_0x181d68){if(_0x181d68){return _0x6bfab3[_0xf49d('0x1b')](_0x42db27);}return _0x6bfab3[_0xf49d('0x1c')](_0x42db27)[_0xf49d('0x1d')]();};}function respondWithResult(_0x24f1fd,_0x5a6b38){_0x5a6b38=_0x5a6b38||0xc8;return function(_0x58771f){if(_0x58771f){return _0x24f1fd[_0xf49d('0x1c')](_0x5a6b38)[_0xf49d('0x1e')](_0x58771f);}};}function respondWithFilteredResult(_0x3c9f5e,_0x525027){return function(_0x1069f5){if(_0x1069f5){var _0x20fea9=typeof _0x525027[_0xf49d('0x1f')]==='undefined'&&typeof _0x525027['limit']==='undefined';var _0x57bcf8=_0x1069f5[_0xf49d('0x20')];var _0x2273a3=_0x20fea9?0x0:_0x525027[_0xf49d('0x1f')];var _0x1323c9=_0x20fea9?_0x1069f5[_0xf49d('0x20')]:_0x525027[_0xf49d('0x1f')]+_0x525027[_0xf49d('0x21')];var _0xc121a5;if(_0x1323c9>=_0x57bcf8){_0x1323c9=_0x57bcf8;_0xc121a5=0xc8;}else{_0xc121a5=0xce;}_0x3c9f5e[_0xf49d('0x1c')](_0xc121a5);return _0x3c9f5e[_0xf49d('0x22')](_0xf49d('0x23'),_0x2273a3+'-'+_0x1323c9+'/'+_0x57bcf8)[_0xf49d('0x1e')](_0x1069f5);}return null;};}function patchUpdates(_0x55ead0){return function(_0xed8934){try{jsonpatch['apply'](_0xed8934,_0x55ead0,!![]);}catch(_0x1741a9){return BPromise[_0xf49d('0x24')](_0x1741a9);}return _0xed8934[_0xf49d('0x25')]();};}function saveUpdates(_0x5ce60b,_0x1f4b81){return function(_0xcde0b5){if(_0xcde0b5){return _0xcde0b5[_0xf49d('0x26')](_0x5ce60b)['then'](function(_0x3c5614){return _0x3c5614;});}return null;};}function removeEntity(_0x580e05,_0x102fa6){return function(_0x10f42d){if(_0x10f42d){return _0x10f42d[_0xf49d('0x27')]()['then'](function(){var _0x470a29=_0x10f42d['get']({'plain':!![]});var _0x5cd635=_0xf49d('0x28');return db[_0xf49d('0x29')][_0xf49d('0x27')]({'where':{'type':_0x5cd635,'resourceId':_0x470a29['id']}})['then'](function(){return _0x10f42d;});})['then'](function(){_0x580e05[_0xf49d('0x1c')](0xcc)[_0xf49d('0x1d')]();});}};}function handleEntityNotFound(_0x303f40,_0x3ac9db){return function(_0x4808d7){if(!_0x4808d7){_0x303f40[_0xf49d('0x1b')](0x194);}return _0x4808d7;};}function handleError(_0x8d22b4,_0x1fc496){_0x1fc496=_0x1fc496||0x1f4;return function(_0x2efa82){logger['error'](_0x2efa82[_0xf49d('0x2a')]);if(_0x2efa82['name']){delete _0x2efa82['name'];}_0x8d22b4['status'](_0x1fc496)['send'](_0x2efa82);};}exports[_0xf49d('0x2b')]=function(_0x2843a5,_0x4859f0){var _0x440fba={},_0x1064ba={},_0x2713f8={'count':0x0,'rows':[]};var _0x2b593e=_['map'](db[_0xf49d('0x2c')]['rawAttributes'],function(_0x308889){return{'name':_0x308889[_0xf49d('0x2d')],'type':_0x308889[_0xf49d('0x2e')][_0xf49d('0x2f')]};});_0x1064ba[_0xf49d('0x30')]=_[_0xf49d('0x31')](_0x2b593e,'name');_0x1064ba['query']=_[_0xf49d('0x32')](_0x2843a5['query']);_0x1064ba[_0xf49d('0x33')]=_[_0xf49d('0x34')](_0x1064ba['model'],_0x1064ba['query']);_0x440fba[_0xf49d('0x35')]=_[_0xf49d('0x34')](_0x1064ba['model'],qs['fields'](_0x2843a5[_0xf49d('0x36')][_0xf49d('0x37')]));_0x440fba[_0xf49d('0x35')]=_0x440fba[_0xf49d('0x35')]['length']?_0x440fba[_0xf49d('0x35')]:_0x1064ba[_0xf49d('0x30')];if(!_0x2843a5[_0xf49d('0x36')][_0xf49d('0x38')]('nolimit')){_0x440fba['limit']=qs['limit'](_0x2843a5[_0xf49d('0x36')][_0xf49d('0x21')]);_0x440fba['offset']=qs[_0xf49d('0x1f')](_0x2843a5[_0xf49d('0x36')][_0xf49d('0x1f')]);}_0x440fba[_0xf49d('0x39')]=qs[_0xf49d('0x3a')](_0x2843a5[_0xf49d('0x36')][_0xf49d('0x3a')]);_0x440fba[_0xf49d('0x3b')]=qs['filters'](_[_0xf49d('0x3c')](_0x2843a5['query'],_0x1064ba[_0xf49d('0x33')]),_0x2b593e);if(_0x2843a5[_0xf49d('0x36')][_0xf49d('0x3d')]){_0x440fba['where']=_[_0xf49d('0x3e')](_0x440fba[_0xf49d('0x3b')],{'$or':_[_0xf49d('0x31')](_0x2b593e,function(_0x46001c){if(_0x46001c[_0xf49d('0x2e')]!==_0xf49d('0x3f')){var _0x293d77={};_0x293d77[_0x46001c['name']]={'$like':'%'+_0x2843a5['query'][_0xf49d('0x3d')]+'%'};return _0x293d77;}})});}_0x440fba=_[_0xf49d('0x3e')]({},_0x440fba,_0x2843a5[_0xf49d('0x40')]);var _0x312f01={'where':_0x440fba[_0xf49d('0x3b')]};return db[_0xf49d('0x2c')][_0xf49d('0x20')](_0x312f01)[_0xf49d('0x41')](function(_0x1502c3){_0x2713f8[_0xf49d('0x20')]=_0x1502c3;if(_0x2843a5[_0xf49d('0x36')][_0xf49d('0x42')]){_0x440fba['include']=[{'all':!![]}];}return db[_0xf49d('0x2c')][_0xf49d('0x43')](_0x440fba);})[_0xf49d('0x41')](function(_0x640ed){_0x2713f8['rows']=_0x640ed;return _0x2713f8;})['then'](respondWithFilteredResult(_0x4859f0,_0x440fba))[_0xf49d('0x44')](handleError(_0x4859f0,null));};exports[_0xf49d('0x45')]=function(_0xc73d21,_0x47b942){var _0x9322b9={'raw':!![],'where':{'id':_0xc73d21[_0xf49d('0x46')]['id']}},_0x1acee0={};_0x1acee0[_0xf49d('0x30')]=_[_0xf49d('0x32')](db[_0xf49d('0x2c')]['rawAttributes']);_0x1acee0[_0xf49d('0x36')]=_[_0xf49d('0x32')](_0xc73d21[_0xf49d('0x36')]);_0x1acee0[_0xf49d('0x33')]=_['intersection'](_0x1acee0[_0xf49d('0x30')],_0x1acee0[_0xf49d('0x36')]);_0x9322b9[_0xf49d('0x35')]=_['intersection'](_0x1acee0[_0xf49d('0x30')],qs['fields'](_0xc73d21[_0xf49d('0x36')]['fields']));_0x9322b9[_0xf49d('0x35')]=_0x9322b9[_0xf49d('0x35')][_0xf49d('0x47')]?_0x9322b9[_0xf49d('0x35')]:_0x1acee0['model'];if(_0xc73d21[_0xf49d('0x36')][_0xf49d('0x42')]){_0x9322b9[_0xf49d('0x48')]=[{'all':!![]}];}_0x9322b9=_[_0xf49d('0x3e')]({},_0x9322b9,_0xc73d21[_0xf49d('0x40')]);return db[_0xf49d('0x2c')][_0xf49d('0x49')](_0x9322b9)[_0xf49d('0x41')](handleEntityNotFound(_0x47b942,null))[_0xf49d('0x41')](respondWithResult(_0x47b942,null))[_0xf49d('0x44')](handleError(_0x47b942,null));};exports[_0xf49d('0x4a')]=function(_0x38ae49,_0xc59f6){return db[_0xf49d('0x2c')][_0xf49d('0x4a')](_0x38ae49[_0xf49d('0x4b')],{})[_0xf49d('0x41')](function(_0xc663b8){var _0x2d0ac5=_0x38ae49[_0xf49d('0x4c')][_0xf49d('0x4d')]({'plain':!![]});if(!_0x2d0ac5)throw new Error(_0xf49d('0x4e'));if(_0x2d0ac5[_0xf49d('0x4f')]===_0xf49d('0x4c')){var _0xae9ee8=_0xc663b8[_0xf49d('0x4d')]({'plain':!![]});var _0x47a04f='OpenchannelQueues';return db[_0xf49d('0x50')]['find']({'where':{'name':_0x47a04f,'userProfileId':_0x2d0ac5[_0xf49d('0x51')]},'raw':!![]})[_0xf49d('0x41')](function(_0x149071){if(_0x149071&&_0x149071['autoAssociation']===0x0){return db['UserProfileResource'][_0xf49d('0x4a')]({'name':_0xae9ee8[_0xf49d('0x52')],'resourceId':_0xae9ee8['id'],'type':_0x149071[_0xf49d('0x52')],'sectionId':_0x149071['id']},{})[_0xf49d('0x41')](function(){return _0xc663b8;});}else{return _0xc663b8;}})[_0xf49d('0x44')](function(_0x2c7cd7){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2c7cd7);throw _0x2c7cd7;});}return _0xc663b8;})[_0xf49d('0x41')](respondWithResult(_0xc59f6,0xc9))[_0xf49d('0x44')](handleError(_0xc59f6,null));};exports[_0xf49d('0x26')]=function(_0x344fe0,_0x4c7dc0){if(_0x344fe0[_0xf49d('0x4b')]['id']){delete _0x344fe0[_0xf49d('0x4b')]['id'];}return db[_0xf49d('0x2c')][_0xf49d('0x49')]({'where':{'id':_0x344fe0[_0xf49d('0x46')]['id']}})[_0xf49d('0x41')](handleEntityNotFound(_0x4c7dc0,null))[_0xf49d('0x41')](saveUpdates(_0x344fe0['body'],null))[_0xf49d('0x41')](respondWithResult(_0x4c7dc0,null))[_0xf49d('0x44')](handleError(_0x4c7dc0,null));};exports[_0xf49d('0x27')]=function(_0x4dbf3e,_0x286459){return db['OpenchannelQueue'][_0xf49d('0x49')]({'where':{'id':_0x4dbf3e[_0xf49d('0x46')]['id']}})['then'](handleEntityNotFound(_0x286459,null))[_0xf49d('0x41')](removeEntity(_0x286459,null))[_0xf49d('0x44')](handleError(_0x286459,null));};exports[_0xf49d('0x53')]=function(_0x132998,_0x28137e){return db['OpenchannelQueue'][_0xf49d('0x53')]()[_0xf49d('0x41')](respondWithResult(_0x28137e,null))[_0xf49d('0x44')](handleError(_0x28137e,null));};exports[_0xf49d('0x54')]=function(_0x5ec7d3,_0x5f3ce3,_0xa09ccb){var _0x1909f8={'raw':!![],'where':{}},_0x53e5e6={},_0x3b10b3;return db[_0xf49d('0x2c')][_0xf49d('0x55')]({'where':{'id':_0x5ec7d3[_0xf49d('0x46')]['id']}})['then'](handleEntityNotFound(_0x5f3ce3,null))[_0xf49d('0x41')](function(_0x2550aa){if(_0x2550aa){_0x3b10b3=_0x2550aa[_0xf49d('0x4d')]({'plain':!![]});_0x53e5e6[_0xf49d('0x30')]=_[_0xf49d('0x32')](db[_0xf49d('0x56')][_0xf49d('0x57')]);_0x53e5e6['query']=_[_0xf49d('0x32')](_0x5ec7d3[_0xf49d('0x36')]);_0x53e5e6[_0xf49d('0x33')]=_[_0xf49d('0x34')](_0x53e5e6['model'],_0x53e5e6[_0xf49d('0x36')]);_0x1909f8[_0xf49d('0x35')]=_['intersection'](_0x53e5e6[_0xf49d('0x30')],qs[_0xf49d('0x37')](_0x5ec7d3[_0xf49d('0x36')]['fields']));_0x1909f8[_0xf49d('0x35')]=_0x1909f8['attributes'][_0xf49d('0x47')]?_0x1909f8[_0xf49d('0x35')]:_0x53e5e6['model'];if(!_0x5ec7d3[_0xf49d('0x36')]['hasOwnProperty'](_0xf49d('0x58'))){_0x1909f8[_0xf49d('0x21')]=qs['limit'](_0x5ec7d3['query'][_0xf49d('0x21')]);_0x1909f8[_0xf49d('0x1f')]=qs[_0xf49d('0x1f')](_0x5ec7d3['query']['offset']);}_0x1909f8[_0xf49d('0x39')]=qs['sort'](_0x5ec7d3['query'][_0xf49d('0x3a')]);_0x1909f8[_0xf49d('0x3b')]=qs[_0xf49d('0x33')](_[_0xf49d('0x3c')](_0x5ec7d3['query'],_0x53e5e6['filters']));_0x1909f8[_0xf49d('0x3b')][_0xf49d('0x59')]=_0x2550aa['id'];if(_0x5ec7d3[_0xf49d('0x36')][_0xf49d('0x3d')]){_0x1909f8[_0xf49d('0x3b')]=_['merge'](_0x1909f8[_0xf49d('0x3b')],{'$or':_[_0xf49d('0x31')](_0x1909f8[_0xf49d('0x35')],function(_0x122528){var _0x5d1cfb={};_0x5d1cfb[_0x122528]={'$like':'%'+_0x5ec7d3[_0xf49d('0x36')]['filter']+'%'};return _0x5d1cfb;})});}_0x1909f8=_[_0xf49d('0x3e')]({},_0x1909f8,_0x5ec7d3['options']);return db[_0xf49d('0x56')][_0xf49d('0x43')](_0x1909f8);}})[_0xf49d('0x41')](function(_0x4e9bd7){if(_0x4e9bd7){return db[_0xf49d('0x5a')][_0xf49d('0x5b')]({'where':{'id':_[_0xf49d('0x31')](_0x4e9bd7,'UserId'),'role':'agent'},'attributes':['id',_0xf49d('0x52'),'openchannelPause',_0xf49d('0x5c'),'createdAt']});}})[_0xf49d('0x41')](function(_0x32abaa){if(_0x32abaa){return{'count':_0x32abaa[_0xf49d('0x20')],'rows':_[_0xf49d('0x31')](_0x32abaa[_0xf49d('0x5d')],function(_0x445893){return{'membername':_0x445893['name'],'UserId':_0x445893['id'],'queue_name':_0x3b10b3['name'],'OpenchannelQueueId':_0x3b10b3['id'],'interface':util[_0xf49d('0x5e')](_0xf49d('0x5f'),_0xf49d('0x60'),_0x445893[_0xf49d('0x52')]),'penalty':0x0,'paused':_0x445893[_0xf49d('0x61')],'createdAt':_0x445893[_0xf49d('0x62')],'updatedAt':_0x445893[_0xf49d('0x5c')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xf49d('0x41')](respondWithFilteredResult(_0x5f3ce3,_0x1909f8))[_0xf49d('0x44')](handleError(_0x5f3ce3,null));};exports[_0xf49d('0x63')]=function(_0xcbd485,_0x3190c6,_0x20e5ce){var _0x4e2616={};var _0x3adb20={};var _0x24cb48;var _0x2ae25e;return db[_0xf49d('0x2c')][_0xf49d('0x55')]({'where':{'id':_0xcbd485[_0xf49d('0x46')]['id']}})[_0xf49d('0x41')](handleEntityNotFound(_0x3190c6,null))['then'](function(_0x3ee00f){if(_0x3ee00f){_0x24cb48=_0x3ee00f;_0x3adb20['model']=_[_0xf49d('0x32')](db[_0xf49d('0x64')][_0xf49d('0x57')]);_0x3adb20['query']=_[_0xf49d('0x32')](_0xcbd485[_0xf49d('0x36')]);_0x3adb20['filters']=_['intersection'](_0x3adb20[_0xf49d('0x30')],_0x3adb20['query']);_0x4e2616['attributes']=_[_0xf49d('0x34')](_0x3adb20[_0xf49d('0x30')],qs[_0xf49d('0x37')](_0xcbd485['query'][_0xf49d('0x37')]));_0x4e2616['attributes']=_0x4e2616[_0xf49d('0x35')]['length']?_0x4e2616['attributes']:_0x3adb20[_0xf49d('0x30')];_0x4e2616[_0xf49d('0x39')]=qs[_0xf49d('0x3a')](_0xcbd485[_0xf49d('0x36')][_0xf49d('0x3a')]);_0x4e2616['where']=qs[_0xf49d('0x33')](_[_0xf49d('0x3c')](_0xcbd485[_0xf49d('0x36')],_0x3adb20[_0xf49d('0x33')]));if(_0xcbd485[_0xf49d('0x36')][_0xf49d('0x3d')]){_0x4e2616[_0xf49d('0x3b')]=_[_0xf49d('0x3e')](_0x4e2616[_0xf49d('0x3b')],{'$or':_[_0xf49d('0x31')](_0x4e2616[_0xf49d('0x35')],function(_0x1ad02a){var _0x593c95={};_0x593c95[_0x1ad02a]={'$like':'%'+_0xcbd485[_0xf49d('0x36')][_0xf49d('0x3d')]+'%'};return _0x593c95;})});}_0x4e2616=_[_0xf49d('0x3e')]({},_0x4e2616,_0xcbd485[_0xf49d('0x40')]);return _0x24cb48[_0xf49d('0x63')](_0x4e2616);}})[_0xf49d('0x41')](function(_0x29f960){if(_0x29f960){_0x2ae25e=_0x29f960['length'];if(!_0xcbd485['query']['hasOwnProperty'](_0xf49d('0x58'))){_0x4e2616['limit']=qs[_0xf49d('0x21')](_0xcbd485['query'][_0xf49d('0x21')]);_0x4e2616['offset']=qs[_0xf49d('0x1f')](_0xcbd485[_0xf49d('0x36')][_0xf49d('0x1f')]);}return _0x24cb48['getTeams'](_0x4e2616);}})[_0xf49d('0x41')](function(_0x53fccf){if(_0x53fccf){return _0x53fccf?{'count':_0x2ae25e,'rows':_0x53fccf}:null;}})[_0xf49d('0x41')](respondWithResult(_0x3190c6,null))['catch'](handleError(_0x3190c6,null));};exports[_0xf49d('0x65')]=function(_0x1054d7,_0x2be946,_0x5959cd){var _0x138665=_0x1054d7[_0xf49d('0x4b')][_0xf49d('0x66')];return db[_0xf49d('0x64')][_0xf49d('0x43')]({'where':{'id':_0x138665},'attributes':['id'],'include':[{'model':db[_0xf49d('0x5a')],'as':_0xf49d('0x67'),'attributes':['id',_0xf49d('0x52'),_0xf49d('0x68'),_0xf49d('0x69'),_0xf49d('0x6a')],'raw':!![]}]})[_0xf49d('0x41')](function(_0x232253){if(_0x232253){var _0x1eba85=_[_0xf49d('0x6b')](_0x232253,function(_0x452828){var _0x4e2bf8=_0x452828[_0xf49d('0x4d')]({'plain':!![]});return _0x4e2bf8['Agents'];});return db[_0xf49d('0x2c')][_0xf49d('0x49')]({'where':{'id':_0x1054d7[_0xf49d('0x46')]['id']}})[_0xf49d('0x41')](function(_0x4754f8){return db['sequelize'][_0xf49d('0x6c')](function(_0x3b18d4){return _0x4754f8['addTeams'](_0x138665,{'transaction':_0x3b18d4})[_0xf49d('0x41')](function(){return BPromise[_0xf49d('0x6d')](_0x1eba85,function(_0x23356d){return db[_0xf49d('0x56')]['findOrCreate']({'where':{'UserId':_0x23356d['id'],'OpenchannelQueueId':_0x1054d7['params']['id']},'transaction':_0x3b18d4});});})[_0xf49d('0x41')](function(){_0x1eba85[_0xf49d('0x6e')](function(_0x20373e){socket['emit'](_0xf49d('0x6f'),{'UserId':_0x20373e['id'],'OpenchannelQueueId':_0x4754f8['id']});});});});});}})['then'](respondWithStatusCode(_0x2be946,null))['catch'](handleError(_0x2be946,null));};exports[_0xf49d('0x70')]=function(_0x20e3f2,_0x3a13fc,_0x5514f9){return db[_0xf49d('0x64')][_0xf49d('0x43')]({'where':{'id':_0x20e3f2['query'][_0xf49d('0x66')]},'attributes':['id'],'include':[{'model':db[_0xf49d('0x5a')],'as':_0xf49d('0x67'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x3a13fc,null))['then'](function(_0x3d9c6e){var _0x1139d4=_['map'](_0x3d9c6e,'id');var _0x4f8a5a=[];var _0x2b4364=[];var _0x31709d=squel['select']();_0x31709d[_0xf49d('0x71')](_0xf49d('0x72'))[_0xf49d('0x73')]('team_has_openchannel_queues','tq')[_0xf49d('0x74')](_0xf49d('0x75'),'ut',_0xf49d('0x76'))[_0xf49d('0x3b')](_0xf49d('0x77'),_0x20e3f2['params']['id']);for(var _0x167089=0x0;_0x167089<_0x3d9c6e[_0xf49d('0x47')];_0x167089+=0x1){let _0x260ed4=_0x3d9c6e[_0x167089];for(var _0x76b72e=0x0;_0x76b72e<_0x260ed4['Agents'][_0xf49d('0x47')];_0x76b72e+=0x1){let _0x2bf4b3=_0x260ed4[_0xf49d('0x67')][_0x76b72e];var _0x27cf32=_0x31709d[_0xf49d('0x78')]();_0x27cf32[_0xf49d('0x3b')]('ut.UserId\x20=\x20?',_0x2bf4b3['id']);_0x2b4364['push'](db[_0xf49d('0x79')]['query'](_0x27cf32[_0xf49d('0x7a')](),{'type':db[_0xf49d('0x79')]['QueryTypes']['SELECT']})[_0xf49d('0x41')](function(_0xa756d1){if(_0xa756d1[_0xf49d('0x47')]===0x1){return _0x2bf4b3['id'];}else{var _0x121133=_[_0xf49d('0x7b')](_[_0xf49d('0x31')](_0xa756d1,'TeamId'),function(_0x4e04dc){return _['includes'](_0x1139d4,_0x4e04dc);});if(_0x121133){return _0x2bf4b3['id'];}}}));}}return BPromise[_0xf49d('0x7c')](_0x2b4364)[_0xf49d('0x41')](function(_0x288640){_0x4f8a5a=_(_0x4f8a5a)['union'](_0x288640)['compact']()[_0xf49d('0x7d')]();return db[_0xf49d('0x2c')][_0xf49d('0x49')]({'where':{'id':_0x20e3f2['params']['id']}})['then'](function(_0xf586ef){return db[_0xf49d('0x79')][_0xf49d('0x6c')](function(_0x22aeba){return _0xf586ef[_0xf49d('0x70')](_0x20e3f2['query'][_0xf49d('0x66')],{'transaction':_0x22aeba})['then'](function(){if(!_['isEmpty'](_0x4f8a5a)){return _0xf586ef[_0xf49d('0x7e')](_0x4f8a5a,{'transaction':_0x22aeba});}})[_0xf49d('0x41')](function(){_0x4f8a5a[_0xf49d('0x6e')](function(_0x2272bd){socket[_0xf49d('0x7f')]('userOpenchannelQueue:remove',{'UserId':_0x2272bd,'OpenchannelQueueId':_0xf586ef['id']});});});});});});})[_0xf49d('0x41')](respondWithStatusCode(_0x3a13fc,null))['catch'](handleError(_0x3a13fc,null));};exports['addAgents']=function(_0x2d69e9,_0x482d04,_0x157f72){return db['OpenchannelQueue'][_0xf49d('0x49')]({'where':{'id':_0x2d69e9[_0xf49d('0x46')]['id']}})['then'](handleEntityNotFound(_0x482d04,null))[_0xf49d('0x41')](function(_0x2d9dad){if(_0x2d9dad){return _0x2d9dad['addAgents'](_0x2d69e9['body'][_0xf49d('0x66')],_[_0xf49d('0x80')](_0x2d69e9[_0xf49d('0x4b')],[_0xf49d('0x66'),'id'])||{})[_0xf49d('0x81')](function(_0x4fa644){for(var _0x2545c1=0x0;_0x2545c1<_0x2d69e9[_0xf49d('0x4b')][_0xf49d('0x66')][_0xf49d('0x47')];_0x2545c1+=0x1){socket['emit'](_0xf49d('0x6f'),{'UserId':Number(_0x2d69e9['body'][_0xf49d('0x66')][_0x2545c1]),'OpenchannelQueueId':Number(_0x2d69e9[_0xf49d('0x46')]['id'])});}return _0x4fa644;});}})[_0xf49d('0x41')](respondWithResult(_0x482d04,null))[_0xf49d('0x44')](handleError(_0x482d04,null));};exports[_0xf49d('0x7e')]=function(_0x83c458,_0x59a089,_0x276325){return db[_0xf49d('0x2c')][_0xf49d('0x49')]({'where':{'id':_0x83c458[_0xf49d('0x46')]['id']}})['then'](handleEntityNotFound(_0x59a089,null))[_0xf49d('0x41')](function(_0x363d33){if(_0x363d33){return _0x363d33[_0xf49d('0x7e')](_0x83c458['query'][_0xf49d('0x66')])[_0xf49d('0x41')](function(){if(_[_0xf49d('0x82')](_0x83c458[_0xf49d('0x36')]['ids'])){for(var _0x138899=0x0;_0x138899<_0x83c458[_0xf49d('0x36')][_0xf49d('0x66')][_0xf49d('0x47')];_0x138899+=0x1){socket[_0xf49d('0x7f')](_0xf49d('0x83'),{'UserId':Number(_0x83c458[_0xf49d('0x36')]['ids'][_0x138899]),'OpenchannelQueueId':Number(_0x83c458[_0xf49d('0x46')]['id'])});}}else{socket[_0xf49d('0x7f')](_0xf49d('0x83'),{'UserId':Number(_0x83c458[_0xf49d('0x36')][_0xf49d('0x66')]),'OpenchannelQueueId':Number(_0x83c458[_0xf49d('0x46')]['id'])});}});}})['then'](respondWithStatusCode(_0x59a089,null))[_0xf49d('0x44')](handleError(_0x59a089,null));};exports[_0xf49d('0x84')]=function(_0x1af301,_0x320b7c,_0x54da97){var _0x38cc8c={};var _0x1f28fd={};var _0x35a01d;var _0x1639a5;return db[_0xf49d('0x2c')][_0xf49d('0x55')]({'where':{'id':_0x1af301[_0xf49d('0x46')]['id']}})[_0xf49d('0x41')](handleEntityNotFound(_0x320b7c,null))[_0xf49d('0x41')](function(_0x2426dd){if(_0x2426dd){_0x35a01d=_0x2426dd;_0x1f28fd[_0xf49d('0x30')]=_[_0xf49d('0x32')](db[_0xf49d('0x5a')][_0xf49d('0x57')]);_0x1f28fd[_0xf49d('0x36')]=_[_0xf49d('0x32')](_0x1af301['query']);_0x1f28fd[_0xf49d('0x33')]=_['intersection'](_0x1f28fd[_0xf49d('0x30')],_0x1f28fd['query']);_0x38cc8c[_0xf49d('0x35')]=_[_0xf49d('0x34')](_0x1f28fd[_0xf49d('0x30')],qs['fields'](_0x1af301[_0xf49d('0x36')]['fields']));_0x38cc8c['attributes']=_0x38cc8c[_0xf49d('0x35')][_0xf49d('0x47')]?_0x38cc8c['attributes']:_0x1f28fd[_0xf49d('0x30')];_0x38cc8c[_0xf49d('0x39')]=qs['sort'](_0x1af301['query'][_0xf49d('0x3a')]);_0x38cc8c[_0xf49d('0x3b')]=qs[_0xf49d('0x33')](_[_0xf49d('0x3c')](_0x1af301['query'],_0x1f28fd[_0xf49d('0x33')]));if(_0x1af301[_0xf49d('0x36')][_0xf49d('0x3d')]){_0x38cc8c[_0xf49d('0x3b')]=_[_0xf49d('0x3e')](_0x38cc8c[_0xf49d('0x3b')],{'$or':_[_0xf49d('0x31')](_0x38cc8c[_0xf49d('0x35')],function(_0x14dc35){var _0x17e76f={};_0x17e76f[_0x14dc35]={'$like':'%'+_0x1af301[_0xf49d('0x36')][_0xf49d('0x3d')]+'%'};return _0x17e76f;})});}_0x38cc8c=_[_0xf49d('0x3e')]({},_0x38cc8c,_0x1af301[_0xf49d('0x40')]);return _0x35a01d[_0xf49d('0x84')](_0x38cc8c);}})[_0xf49d('0x41')](function(_0x3f3793){if(_0x3f3793){_0x1639a5=_0x3f3793[_0xf49d('0x47')];if(!_0x1af301[_0xf49d('0x36')][_0xf49d('0x38')](_0xf49d('0x58'))){_0x38cc8c[_0xf49d('0x21')]=qs[_0xf49d('0x21')](_0x1af301[_0xf49d('0x36')]['limit']);_0x38cc8c[_0xf49d('0x1f')]=qs[_0xf49d('0x1f')](_0x1af301[_0xf49d('0x36')][_0xf49d('0x1f')]);}return _0x35a01d[_0xf49d('0x84')](_0x38cc8c);}})['then'](function(_0xd0a3c9){if(_0xd0a3c9){return _0xd0a3c9?{'count':_0x1639a5,'rows':_0xd0a3c9}:null;}})[_0xf49d('0x41')](respondWithResult(_0x320b7c,null))['catch'](handleError(_0x320b7c,null));};
\ No newline at end of file