Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 6f80fa8..8cc8990 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbf96=['%s/%s','SIP','getTeams','findOne','ids','Team','Agents','online','interface','flatMap','addTeams','each','findOrCreate','forEach','emit','userChatQueue:save','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','push','sequelize','toString','QueryTypes','SELECT','every','TeamId','includes','union','value','removeTeams','isEmpty','userChatQueue:remove','omit','spread','removeAgents','isArray','getAgents','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','register','jayson/promise','client','http','request','then','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','end','status','count','offset','limit','Content-Range','json','apply','save','update','destroy','get','ChatQueues','UserProfileResource','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','keys','filters','attributes','fields','query','nolimit','sort','where','pick','merge','options','ChatQueue','includeAll','findAll','rows','show','params','intersection','length','include','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','hasOwnProperty','order','ChatQueueId','filter','UserChatQueue','User','findAndCountAll','UserId','agent','chatPause','updatedAt','createdAt','format'];(function(_0x19dd7a,_0x2b8d4f){var _0x43b25c=function(_0x1d5d35){while(--_0x1d5d35){_0x19dd7a['push'](_0x19dd7a['shift']());}};_0x43b25c(++_0x2b8d4f);}(_0xbf96,0xc6));var _0x6bf9=function(_0x323a99,_0x4736dc){_0x323a99=_0x323a99-0x0;var _0x29c23f=_0xbf96[_0x323a99];return _0x29c23f;};'use strict';var pdf=require(_0x6bf9('0x0'));var emlformat=require(_0x6bf9('0x1'));var rimraf=require(_0x6bf9('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x6bf9('0x3'));var rp=require(_0x6bf9('0x4'));var moment=require(_0x6bf9('0x5'));var BPromise=require(_0x6bf9('0x6'));var Mustache=require(_0x6bf9('0x7'));var util=require(_0x6bf9('0x8'));var path=require('path');var sox=require(_0x6bf9('0x9'));var csv=require(_0x6bf9('0xa'));var ejs=require(_0x6bf9('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x6bf9('0xc'));var crypto=require(_0x6bf9('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x6bf9('0xe'));var toCsv=require(_0x6bf9('0xa'));var querystring=require(_0x6bf9('0xf'));var Papa=require(_0x6bf9('0x10'));var Redis=require('ioredis');var authService=require(_0x6bf9('0x11'));var qs=require(_0x6bf9('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x6bf9('0x13'))('api');var utils=require('../../config/utils');var config=require(_0x6bf9('0x14'));var licenseUtil=require(_0x6bf9('0x15'));var db=require(_0x6bf9('0x16'))['db'];config[_0x6bf9('0x17')]=_[_0x6bf9('0x18')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6bf9('0x17')]));require('./chatQueue.socket')[_0x6bf9('0x19')](socket);var jayson=require(_0x6bf9('0x1a'));var client=jayson[_0x6bf9('0x1b')][_0x6bf9('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x2a34f1,_0x39e655,_0x36292d,_0x2f6f98){return new BPromise(function(_0x4c2411,_0x2919c2){var _0x1f7d7=_0x2f6f98||client;return _0x1f7d7[_0x6bf9('0x1d')](_0x2a34f1,_0x36292d)[_0x6bf9('0x1e')](function(_0x148485){logger['info'](_0x6bf9('0x1f'),_0x39e655,_0x6bf9('0x20'));logger[_0x6bf9('0x21')](_0x6bf9('0x22'),_0x39e655,_0x6bf9('0x20'),JSON[_0x6bf9('0x23')](_0x148485));if(_0x148485[_0x6bf9('0x24')]){if(_0x148485['error'][_0x6bf9('0x25')]===0x1f4){logger[_0x6bf9('0x24')](_0x6bf9('0x1f'),_0x39e655,_0x148485[_0x6bf9('0x24')][_0x6bf9('0x26')]);return _0x2919c2(_0x148485['error']['message']);}logger[_0x6bf9('0x24')](_0x6bf9('0x1f'),_0x39e655,_0x148485['error'][_0x6bf9('0x26')]);return _0x4c2411(_0x148485[_0x6bf9('0x24')][_0x6bf9('0x26')]);}else{logger[_0x6bf9('0x27')]('ChatQueue,\x20%s,\x20%s',_0x39e655,_0x6bf9('0x20'));_0x4c2411(_0x148485[_0x6bf9('0x28')][_0x6bf9('0x26')]);}})[_0x6bf9('0x29')](function(_0x32ecac){logger[_0x6bf9('0x24')](_0x6bf9('0x1f'),_0x39e655,_0x32ecac);_0x2919c2(_0x32ecac);});});}function respondWithStatusCode(_0x2a6217,_0x43cb77){_0x43cb77=_0x43cb77||0xcc;return function(_0x442f63){if(_0x442f63){return _0x2a6217[_0x6bf9('0x2a')](_0x43cb77);}return _0x2a6217['status'](_0x43cb77)[_0x6bf9('0x2b')]();};}function respondWithResult(_0x20ff55,_0x20baae){_0x20baae=_0x20baae||0xc8;return function(_0xfb049a){if(_0xfb049a){return _0x20ff55[_0x6bf9('0x2c')](_0x20baae)['json'](_0xfb049a);}};}function respondWithFilteredResult(_0x82d4e2,_0x2f312a){return function(_0x9a1445){if(_0x9a1445){var _0xdf34d3=_0x9a1445[_0x6bf9('0x2d')],_0x249d78=_0x2f312a[_0x6bf9('0x2e')],_0x4f2110=_0x2f312a[_0x6bf9('0x2e')]+_0x2f312a[_0x6bf9('0x2f')],_0x1439c2;if(_0x4f2110>=_0xdf34d3){_0x4f2110=_0xdf34d3;_0x1439c2=0xc8;}else{_0x1439c2=0xce;}_0x82d4e2[_0x6bf9('0x2c')](_0x1439c2);return _0x82d4e2['set'](_0x6bf9('0x30'),_0x249d78+'-'+_0x4f2110+'/'+_0xdf34d3)[_0x6bf9('0x31')](_0x9a1445);}return null;};}function patchUpdates(_0x2c8f70){return function(_0x735488){try{jsonpatch[_0x6bf9('0x32')](_0x735488,_0x2c8f70,!![]);}catch(_0x18b268){return BPromise['reject'](_0x18b268);}return _0x735488[_0x6bf9('0x33')]();};}function saveUpdates(_0x326373,_0x49b4c0){return function(_0x3f664d){if(_0x3f664d){return _0x3f664d[_0x6bf9('0x34')](_0x326373)[_0x6bf9('0x1e')](function(_0x26161d){return _0x26161d;});}return null;};}function removeEntity(_0x525878,_0x13b0d0){return function(_0x2853c5){if(_0x2853c5){return _0x2853c5[_0x6bf9('0x35')]()[_0x6bf9('0x1e')](function(){var _0x485796=_0x2853c5[_0x6bf9('0x36')]({'plain':!![]});var _0x298138=_0x6bf9('0x37');return db[_0x6bf9('0x38')][_0x6bf9('0x35')]({'where':{'type':_0x298138,'resourceId':_0x485796['id']}})['then'](function(){return _0x2853c5;});})['then'](function(){_0x525878[_0x6bf9('0x2c')](0xcc)[_0x6bf9('0x2b')]();});}};}function handleEntityNotFound(_0x1216b1,_0x249696){return function(_0xacccc6){if(!_0xacccc6){_0x1216b1[_0x6bf9('0x2a')](0x194);}return _0xacccc6;};}function handleError(_0x3b370d,_0x2718ac){_0x2718ac=_0x2718ac||0x1f4;return function(_0x2b6e0c){logger['error'](_0x2b6e0c[_0x6bf9('0x39')]);if(_0x2b6e0c[_0x6bf9('0x3a')]){delete _0x2b6e0c[_0x6bf9('0x3a')];}_0x3b370d[_0x6bf9('0x2c')](_0x2718ac)[_0x6bf9('0x3b')](_0x2b6e0c);};}exports[_0x6bf9('0x3c')]=function(_0x4dc02f,_0x1a6844){var _0xdb5477={},_0x180b12={},_0x4912f3={'count':0x0,'rows':[]};var _0x14dfa4=_[_0x6bf9('0x3d')](db['ChatQueue'][_0x6bf9('0x3e')],function(_0x4c9f38){return{'name':_0x4c9f38[_0x6bf9('0x3f')],'type':_0x4c9f38[_0x6bf9('0x40')][_0x6bf9('0x41')]};});_0x180b12[_0x6bf9('0x42')]=_[_0x6bf9('0x3d')](_0x14dfa4,_0x6bf9('0x3a'));_0x180b12['query']=_[_0x6bf9('0x43')](_0x4dc02f['query']);_0x180b12[_0x6bf9('0x44')]=_['intersection'](_0x180b12['model'],_0x180b12['query']);_0xdb5477[_0x6bf9('0x45')]=_['intersection'](_0x180b12['model'],qs[_0x6bf9('0x46')](_0x4dc02f['query'][_0x6bf9('0x46')]));_0xdb5477[_0x6bf9('0x45')]=_0xdb5477['attributes']['length']?_0xdb5477[_0x6bf9('0x45')]:_0x180b12[_0x6bf9('0x42')];if(!_0x4dc02f[_0x6bf9('0x47')]['hasOwnProperty'](_0x6bf9('0x48'))){_0xdb5477['limit']=qs[_0x6bf9('0x2f')](_0x4dc02f[_0x6bf9('0x47')][_0x6bf9('0x2f')]);_0xdb5477['offset']=qs[_0x6bf9('0x2e')](_0x4dc02f['query'][_0x6bf9('0x2e')]);}_0xdb5477['order']=qs[_0x6bf9('0x49')](_0x4dc02f['query'][_0x6bf9('0x49')]);_0xdb5477[_0x6bf9('0x4a')]=qs[_0x6bf9('0x44')](_[_0x6bf9('0x4b')](_0x4dc02f['query'],_0x180b12[_0x6bf9('0x44')]),_0x14dfa4);if(_0x4dc02f['query']['filter']){_0xdb5477[_0x6bf9('0x4a')]=_[_0x6bf9('0x4c')](_0xdb5477[_0x6bf9('0x4a')],{'$or':_[_0x6bf9('0x3d')](_0x14dfa4,function(_0x475129){if(_0x475129['type']!=='VIRTUAL'){var _0x4aa413={};_0x4aa413[_0x475129['name']]={'$like':'%'+_0x4dc02f[_0x6bf9('0x47')]['filter']+'%'};return _0x4aa413;}})});}_0xdb5477=_[_0x6bf9('0x4c')]({},_0xdb5477,_0x4dc02f[_0x6bf9('0x4d')]);var _0x3dba15={'where':_0xdb5477[_0x6bf9('0x4a')]};return db[_0x6bf9('0x4e')][_0x6bf9('0x2d')](_0x3dba15)['then'](function(_0x11dd74){_0x4912f3[_0x6bf9('0x2d')]=_0x11dd74;if(_0x4dc02f['query'][_0x6bf9('0x4f')]){_0xdb5477['include']=[{'all':!![]}];}return db[_0x6bf9('0x4e')][_0x6bf9('0x50')](_0xdb5477);})[_0x6bf9('0x1e')](function(_0x2739fc){_0x4912f3[_0x6bf9('0x51')]=_0x2739fc;return _0x4912f3;})['then'](respondWithFilteredResult(_0x1a6844,_0xdb5477))[_0x6bf9('0x29')](handleError(_0x1a6844,null));};exports[_0x6bf9('0x52')]=function(_0x4fe001,_0x1b181b){var _0x5eca26={'raw':!![],'where':{'id':_0x4fe001[_0x6bf9('0x53')]['id']}},_0xae1907={};_0xae1907[_0x6bf9('0x42')]=_[_0x6bf9('0x43')](db['ChatQueue']['rawAttributes']);_0xae1907['query']=_[_0x6bf9('0x43')](_0x4fe001['query']);_0xae1907['filters']=_[_0x6bf9('0x54')](_0xae1907[_0x6bf9('0x42')],_0xae1907['query']);_0x5eca26[_0x6bf9('0x45')]=_['intersection'](_0xae1907['model'],qs[_0x6bf9('0x46')](_0x4fe001[_0x6bf9('0x47')][_0x6bf9('0x46')]));_0x5eca26['attributes']=_0x5eca26['attributes'][_0x6bf9('0x55')]?_0x5eca26[_0x6bf9('0x45')]:_0xae1907[_0x6bf9('0x42')];if(_0x4fe001[_0x6bf9('0x47')][_0x6bf9('0x4f')]){_0x5eca26[_0x6bf9('0x56')]=[{'all':!![]}];}_0x5eca26=_['merge']({},_0x5eca26,_0x4fe001[_0x6bf9('0x4d')]);return db[_0x6bf9('0x4e')][_0x6bf9('0x57')](_0x5eca26)['then'](handleEntityNotFound(_0x1b181b,null))[_0x6bf9('0x1e')](respondWithResult(_0x1b181b,null))['catch'](handleError(_0x1b181b,null));};exports['create']=function(_0x3d95c0,_0x55b811){return db[_0x6bf9('0x4e')][_0x6bf9('0x58')](_0x3d95c0['body'],{})['then'](function(_0x271d75){var _0x43b96a=_0x3d95c0[_0x6bf9('0x59')][_0x6bf9('0x36')]({'plain':!![]});if(!_0x43b96a)throw new Error(_0x6bf9('0x5a'));if(_0x43b96a[_0x6bf9('0x5b')]==='user'){var _0xd9d633=_0x271d75[_0x6bf9('0x36')]({'plain':!![]});var _0x19787c=_0x6bf9('0x37');return db['UserProfileSection'][_0x6bf9('0x57')]({'where':{'name':_0x19787c,'userProfileId':_0x43b96a[_0x6bf9('0x5c')]},'raw':!![]})[_0x6bf9('0x1e')](function(_0x44417b){if(_0x44417b&&_0x44417b[_0x6bf9('0x5d')]===0x0){return db[_0x6bf9('0x38')][_0x6bf9('0x58')]({'name':_0xd9d633['name'],'resourceId':_0xd9d633['id'],'type':_0x44417b[_0x6bf9('0x3a')],'sectionId':_0x44417b['id']},{})[_0x6bf9('0x1e')](function(){return _0x271d75;});}else{return _0x271d75;}})[_0x6bf9('0x29')](function(_0x285438){logger['error'](_0x6bf9('0x5e'),_0x285438);throw _0x285438;});}return _0x271d75;})['then'](respondWithResult(_0x55b811,0xc9))[_0x6bf9('0x29')](handleError(_0x55b811,null));};exports[_0x6bf9('0x34')]=function(_0x4b2374,_0x29f66e){if(_0x4b2374[_0x6bf9('0x5f')]['id']){delete _0x4b2374[_0x6bf9('0x5f')]['id'];}return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0x4b2374[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x29f66e,null))[_0x6bf9('0x1e')](saveUpdates(_0x4b2374[_0x6bf9('0x5f')],null))[_0x6bf9('0x1e')](respondWithResult(_0x29f66e,null))[_0x6bf9('0x29')](handleError(_0x29f66e,null));};exports[_0x6bf9('0x35')]=function(_0x77b3a9,_0x1a808a){return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0x77b3a9[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x1a808a,null))[_0x6bf9('0x1e')](removeEntity(_0x1a808a,null))[_0x6bf9('0x29')](handleError(_0x1a808a,null));};exports[_0x6bf9('0x60')]=function(_0x45e23f,_0x459c44){return db[_0x6bf9('0x4e')]['describe']()[_0x6bf9('0x1e')](respondWithResult(_0x459c44,null))['catch'](handleError(_0x459c44,null));};exports['getMembers']=function(_0x49b03e,_0x5bb2cd,_0x45da6e){var _0x4e2cc8={'raw':!![],'where':{}},_0x685e1b={},_0x5d262b;return db[_0x6bf9('0x4e')]['findOne']({'where':{'id':_0x49b03e['params']['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x5bb2cd,null))[_0x6bf9('0x1e')](function(_0x159e82){if(_0x159e82){_0x5d262b=_0x159e82[_0x6bf9('0x36')]({'plain':!![]});_0x685e1b[_0x6bf9('0x42')]=_[_0x6bf9('0x43')](db['UserChatQueue'][_0x6bf9('0x3e')]);_0x685e1b[_0x6bf9('0x47')]=_[_0x6bf9('0x43')](_0x49b03e[_0x6bf9('0x47')]);_0x685e1b[_0x6bf9('0x44')]=_[_0x6bf9('0x54')](_0x685e1b['model'],_0x685e1b[_0x6bf9('0x47')]);_0x4e2cc8['attributes']=_['intersection'](_0x685e1b['model'],qs[_0x6bf9('0x46')](_0x49b03e[_0x6bf9('0x47')][_0x6bf9('0x46')]));_0x4e2cc8[_0x6bf9('0x45')]=_0x4e2cc8[_0x6bf9('0x45')][_0x6bf9('0x55')]?_0x4e2cc8[_0x6bf9('0x45')]:_0x685e1b[_0x6bf9('0x42')];if(!_0x49b03e[_0x6bf9('0x47')][_0x6bf9('0x61')]('nolimit')){_0x4e2cc8[_0x6bf9('0x2f')]=qs[_0x6bf9('0x2f')](_0x49b03e[_0x6bf9('0x47')][_0x6bf9('0x2f')]);_0x4e2cc8[_0x6bf9('0x2e')]=qs[_0x6bf9('0x2e')](_0x49b03e['query'][_0x6bf9('0x2e')]);}_0x4e2cc8[_0x6bf9('0x62')]=qs['sort'](_0x49b03e['query'][_0x6bf9('0x49')]);_0x4e2cc8[_0x6bf9('0x4a')]=qs['filters'](_[_0x6bf9('0x4b')](_0x49b03e[_0x6bf9('0x47')],_0x685e1b[_0x6bf9('0x44')]));_0x4e2cc8[_0x6bf9('0x4a')][_0x6bf9('0x63')]=_0x159e82['id'];if(_0x49b03e['query'][_0x6bf9('0x64')]){_0x4e2cc8[_0x6bf9('0x4a')]=_[_0x6bf9('0x4c')](_0x4e2cc8[_0x6bf9('0x4a')],{'$or':_[_0x6bf9('0x3d')](_0x4e2cc8[_0x6bf9('0x45')],function(_0x149665){var _0x1a10bb={};_0x1a10bb[_0x149665]={'$like':'%'+_0x49b03e[_0x6bf9('0x47')]['filter']+'%'};return _0x1a10bb;})});}_0x4e2cc8=_['merge']({},_0x4e2cc8,_0x49b03e['options']);return db[_0x6bf9('0x65')][_0x6bf9('0x50')](_0x4e2cc8);}})[_0x6bf9('0x1e')](function(_0xf50a94){if(_0xf50a94){return db[_0x6bf9('0x66')][_0x6bf9('0x67')]({'where':{'id':_[_0x6bf9('0x3d')](_0xf50a94,_0x6bf9('0x68')),'role':_0x6bf9('0x69')},'attributes':['id',_0x6bf9('0x3a'),_0x6bf9('0x6a'),_0x6bf9('0x6b'),_0x6bf9('0x6c')]});}})[_0x6bf9('0x1e')](function(_0x27d70a){if(_0x27d70a){return{'count':_0x27d70a['count'],'rows':_[_0x6bf9('0x3d')](_0x27d70a[_0x6bf9('0x51')],function(_0x7fabee){return{'membername':_0x7fabee[_0x6bf9('0x3a')],'UserId':_0x7fabee['id'],'queue_name':_0x5d262b[_0x6bf9('0x3a')],'ChatQueueId':_0x5d262b['id'],'interface':util[_0x6bf9('0x6d')](_0x6bf9('0x6e'),_0x6bf9('0x6f'),_0x7fabee[_0x6bf9('0x3a')]),'penalty':0x0,'paused':_0x7fabee['chatPause'],'createdAt':_0x7fabee[_0x6bf9('0x6c')],'updatedAt':_0x7fabee[_0x6bf9('0x6b')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x5bb2cd,_0x4e2cc8))[_0x6bf9('0x29')](handleError(_0x5bb2cd,null));};exports[_0x6bf9('0x70')]=function(_0x49534d,_0x54617e,_0x283787){var _0x547afc={};var _0x3e70aa={};var _0x2b2e2e;var _0x3d6795;return db['ChatQueue'][_0x6bf9('0x71')]({'where':{'id':_0x49534d['params']['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x54617e,null))['then'](function(_0x41cda8){if(_0x41cda8){_0x2b2e2e=_0x41cda8;_0x3e70aa['model']=_['keys'](db['Team']['rawAttributes']);_0x3e70aa[_0x6bf9('0x47')]=_['keys'](_0x49534d['query']);_0x3e70aa['filters']=_[_0x6bf9('0x54')](_0x3e70aa[_0x6bf9('0x42')],_0x3e70aa[_0x6bf9('0x47')]);_0x547afc[_0x6bf9('0x45')]=_['intersection'](_0x3e70aa[_0x6bf9('0x42')],qs[_0x6bf9('0x46')](_0x49534d[_0x6bf9('0x47')]['fields']));_0x547afc[_0x6bf9('0x45')]=_0x547afc[_0x6bf9('0x45')][_0x6bf9('0x55')]?_0x547afc[_0x6bf9('0x45')]:_0x3e70aa[_0x6bf9('0x42')];_0x547afc[_0x6bf9('0x62')]=qs[_0x6bf9('0x49')](_0x49534d[_0x6bf9('0x47')][_0x6bf9('0x49')]);_0x547afc['where']=qs[_0x6bf9('0x44')](_[_0x6bf9('0x4b')](_0x49534d['query'],_0x3e70aa[_0x6bf9('0x44')]));if(_0x49534d['query']['filter']){_0x547afc[_0x6bf9('0x4a')]=_['merge'](_0x547afc[_0x6bf9('0x4a')],{'$or':_[_0x6bf9('0x3d')](_0x547afc[_0x6bf9('0x45')],function(_0x470ee4){var _0x53a7bc={};_0x53a7bc[_0x470ee4]={'$like':'%'+_0x49534d[_0x6bf9('0x47')][_0x6bf9('0x64')]+'%'};return _0x53a7bc;})});}_0x547afc=_[_0x6bf9('0x4c')]({},_0x547afc,_0x49534d[_0x6bf9('0x4d')]);return _0x2b2e2e[_0x6bf9('0x70')](_0x547afc);}})[_0x6bf9('0x1e')](function(_0x24e243){if(_0x24e243){_0x3d6795=_0x24e243[_0x6bf9('0x55')];if(!_0x49534d['query'][_0x6bf9('0x61')](_0x6bf9('0x48'))){_0x547afc['limit']=qs[_0x6bf9('0x2f')](_0x49534d['query']['limit']);_0x547afc[_0x6bf9('0x2e')]=qs[_0x6bf9('0x2e')](_0x49534d[_0x6bf9('0x47')][_0x6bf9('0x2e')]);}return _0x2b2e2e['getTeams'](_0x547afc);}})[_0x6bf9('0x1e')](function(_0x2597b0){if(_0x2597b0){return _0x2597b0?{'count':_0x3d6795,'rows':_0x2597b0}:null;}})['then'](respondWithResult(_0x54617e,null))[_0x6bf9('0x29')](handleError(_0x54617e,null));};exports['addTeams']=function(_0xc4b9ea,_0x947642,_0x5456fd){var _0x427891=_0xc4b9ea['body'][_0x6bf9('0x72')];return db[_0x6bf9('0x73')][_0x6bf9('0x50')]({'where':{'id':_0x427891},'attributes':['id'],'include':[{'model':db[_0x6bf9('0x66')],'as':_0x6bf9('0x74'),'attributes':['id',_0x6bf9('0x3a'),_0x6bf9('0x75'),'voicePause',_0x6bf9('0x76')],'raw':!![]}]})['then'](function(_0x191f19){if(_0x191f19){var _0x2f64af=_[_0x6bf9('0x77')](_0x191f19,function(_0x50c3d2){var _0x29483b=_0x50c3d2[_0x6bf9('0x36')]({'plain':!![]});return _0x29483b[_0x6bf9('0x74')];});return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0xc4b9ea['params']['id']}})[_0x6bf9('0x1e')](function(_0x391d95){return db['sequelize']['transaction'](function(_0x448ccd){return _0x391d95[_0x6bf9('0x78')](_0x427891,{'transaction':_0x448ccd})[_0x6bf9('0x1e')](function(){return BPromise[_0x6bf9('0x79')](_0x2f64af,function(_0x20dc45){return db[_0x6bf9('0x65')][_0x6bf9('0x7a')]({'where':{'UserId':_0x20dc45['id'],'ChatQueueId':_0xc4b9ea[_0x6bf9('0x53')]['id']},'transaction':_0x448ccd});});})[_0x6bf9('0x1e')](function(){_0x2f64af[_0x6bf9('0x7b')](function(_0x1f1d8e){socket[_0x6bf9('0x7c')](_0x6bf9('0x7d'),{'UserId':_0x1f1d8e['id'],'ChatQueueId':_0x391d95['id']});});});});});}})[_0x6bf9('0x1e')](respondWithStatusCode(_0x947642,null))[_0x6bf9('0x29')](handleError(_0x947642,null));};exports['removeTeams']=function(_0x3a5d66,_0x2f55c2,_0x31e53a){return db[_0x6bf9('0x73')][_0x6bf9('0x50')]({'where':{'id':_0x3a5d66['query'][_0x6bf9('0x72')]},'attributes':['id'],'include':[{'model':db[_0x6bf9('0x66')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x2f55c2,null))[_0x6bf9('0x1e')](function(_0x5afa18){var _0xf382ad=_[_0x6bf9('0x3d')](_0x5afa18,'id');var _0x2d518f=[];var _0x26256c=[];var _0x16970d=squel[_0x6bf9('0x7e')]();_0x16970d[_0x6bf9('0x7f')](_0x6bf9('0x80'))[_0x6bf9('0x81')](_0x6bf9('0x82'),'tq')[_0x6bf9('0x83')](_0x6bf9('0x84'),'ut',_0x6bf9('0x85'))[_0x6bf9('0x4a')](_0x6bf9('0x86'),_0x3a5d66[_0x6bf9('0x53')]['id']);for(var _0x506b4f=0x0;_0x506b4f<_0x5afa18[_0x6bf9('0x55')];_0x506b4f+=0x1){let _0x270038=_0x5afa18[_0x506b4f];for(var _0x21c17f=0x0;_0x21c17f<_0x270038[_0x6bf9('0x74')][_0x6bf9('0x55')];_0x21c17f+=0x1){let _0x4de11b=_0x270038[_0x6bf9('0x74')][_0x21c17f];var _0x5dc477=_0x16970d[_0x6bf9('0x87')]();_0x5dc477[_0x6bf9('0x4a')]('ut.UserId\x20=\x20?',_0x4de11b['id']);_0x26256c[_0x6bf9('0x88')](db[_0x6bf9('0x89')][_0x6bf9('0x47')](_0x5dc477[_0x6bf9('0x8a')](),{'type':db[_0x6bf9('0x89')][_0x6bf9('0x8b')][_0x6bf9('0x8c')]})[_0x6bf9('0x1e')](function(_0x4aa86d){if(_0x4aa86d[_0x6bf9('0x55')]===0x1){return _0x4de11b['id'];}else{var _0x542fd6=_[_0x6bf9('0x8d')](_[_0x6bf9('0x3d')](_0x4aa86d,_0x6bf9('0x8e')),function(_0x10d8b0){return _[_0x6bf9('0x8f')](_0xf382ad,_0x10d8b0);});if(_0x542fd6){return _0x4de11b['id'];}}}));}}return BPromise['all'](_0x26256c)['then'](function(_0x4a1245){_0x2d518f=_(_0x2d518f)[_0x6bf9('0x90')](_0x4a1245)['compact']()[_0x6bf9('0x91')]();return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0x3a5d66[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](function(_0x39f763){return db[_0x6bf9('0x89')]['transaction'](function(_0x116b39){return _0x39f763[_0x6bf9('0x92')](_0x3a5d66['query']['ids'],{'transaction':_0x116b39})['then'](function(){if(!_[_0x6bf9('0x93')](_0x2d518f)){return _0x39f763['removeAgents'](_0x2d518f,{'transaction':_0x116b39});}})[_0x6bf9('0x1e')](function(){_0x2d518f[_0x6bf9('0x7b')](function(_0x19725e){socket[_0x6bf9('0x7c')](_0x6bf9('0x94'),{'UserId':_0x19725e,'ChatQueueId':_0x39f763['id']});});});});});});})[_0x6bf9('0x1e')](respondWithStatusCode(_0x2f55c2,null))[_0x6bf9('0x29')](handleError(_0x2f55c2,null));};exports['addAgents']=function(_0x4e1149,_0x591ad9,_0xdba0bf){return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0x4e1149[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x591ad9,null))[_0x6bf9('0x1e')](function(_0x527717){if(_0x527717){return _0x527717['addAgents'](_0x4e1149[_0x6bf9('0x5f')][_0x6bf9('0x72')],_[_0x6bf9('0x95')](_0x4e1149[_0x6bf9('0x5f')],['ids','id'])||{})[_0x6bf9('0x96')](function(_0x288ab4){for(var _0x2ef22e=0x0;_0x2ef22e<_0x4e1149[_0x6bf9('0x5f')][_0x6bf9('0x72')]['length'];_0x2ef22e+=0x1){socket['emit'](_0x6bf9('0x7d'),{'UserId':_0x4e1149[_0x6bf9('0x5f')][_0x6bf9('0x72')][_0x2ef22e],'ChatQueueId':_0x4e1149[_0x6bf9('0x53')]['id']});}return _0x288ab4;});}})['then'](respondWithResult(_0x591ad9,null))[_0x6bf9('0x29')](handleError(_0x591ad9,null));};exports['removeAgents']=function(_0x5a8a8f,_0x57d09c,_0x5d8eab){return db['ChatQueue']['find']({'where':{'id':_0x5a8a8f[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x57d09c,null))[_0x6bf9('0x1e')](function(_0x29b547){if(_0x29b547){return _0x29b547[_0x6bf9('0x97')](_0x5a8a8f[_0x6bf9('0x47')][_0x6bf9('0x72')])[_0x6bf9('0x1e')](function(){if(_[_0x6bf9('0x98')](_0x5a8a8f[_0x6bf9('0x47')][_0x6bf9('0x72')])){for(var _0x461343=0x0;_0x461343<_0x5a8a8f[_0x6bf9('0x47')]['ids'][_0x6bf9('0x55')];_0x461343+=0x1){socket[_0x6bf9('0x7c')](_0x6bf9('0x94'),{'UserId':Number(_0x5a8a8f[_0x6bf9('0x47')][_0x6bf9('0x72')][_0x461343]),'ChatQueueId':Number(_0x5a8a8f[_0x6bf9('0x53')]['id'])});}}else{socket['emit']('userChatQueue:remove',{'UserId':Number(_0x5a8a8f['query'][_0x6bf9('0x72')]),'ChatQueueId':Number(_0x5a8a8f[_0x6bf9('0x53')]['id'])});}});}})[_0x6bf9('0x1e')](respondWithStatusCode(_0x57d09c,null))['catch'](handleError(_0x57d09c,null));};exports['getAgents']=function(_0xea80f0,_0x419a30,_0x7eb74d){var _0x1f29d6={};var _0x103321={};var _0xaa287e;var _0x3993be;return db[_0x6bf9('0x4e')][_0x6bf9('0x71')]({'where':{'id':_0xea80f0[_0x6bf9('0x53')]['id']}})['then'](handleEntityNotFound(_0x419a30,null))[_0x6bf9('0x1e')](function(_0xa83045){if(_0xa83045){_0xaa287e=_0xa83045;_0x103321[_0x6bf9('0x42')]=_[_0x6bf9('0x43')](db[_0x6bf9('0x66')][_0x6bf9('0x3e')]);_0x103321[_0x6bf9('0x47')]=_[_0x6bf9('0x43')](_0xea80f0['query']);_0x103321['filters']=_['intersection'](_0x103321['model'],_0x103321[_0x6bf9('0x47')]);_0x1f29d6[_0x6bf9('0x45')]=_[_0x6bf9('0x54')](_0x103321[_0x6bf9('0x42')],qs[_0x6bf9('0x46')](_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x46')]));_0x1f29d6['attributes']=_0x1f29d6[_0x6bf9('0x45')][_0x6bf9('0x55')]?_0x1f29d6[_0x6bf9('0x45')]:_0x103321[_0x6bf9('0x42')];_0x1f29d6[_0x6bf9('0x62')]=qs[_0x6bf9('0x49')](_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x49')]);_0x1f29d6[_0x6bf9('0x4a')]=qs[_0x6bf9('0x44')](_[_0x6bf9('0x4b')](_0xea80f0[_0x6bf9('0x47')],_0x103321['filters']));if(_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x64')]){_0x1f29d6['where']=_[_0x6bf9('0x4c')](_0x1f29d6['where'],{'$or':_[_0x6bf9('0x3d')](_0x1f29d6[_0x6bf9('0x45')],function(_0x26e7bb){var _0x190d5d={};_0x190d5d[_0x26e7bb]={'$like':'%'+_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x64')]+'%'};return _0x190d5d;})});}_0x1f29d6=_[_0x6bf9('0x4c')]({},_0x1f29d6,_0xea80f0[_0x6bf9('0x4d')]);return _0xaa287e[_0x6bf9('0x99')](_0x1f29d6);}})['then'](function(_0x24ab04){if(_0x24ab04){_0x3993be=_0x24ab04['length'];if(!_0xea80f0[_0x6bf9('0x47')]['hasOwnProperty'](_0x6bf9('0x48'))){_0x1f29d6[_0x6bf9('0x2f')]=qs[_0x6bf9('0x2f')](_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x2f')]);_0x1f29d6[_0x6bf9('0x2e')]=qs[_0x6bf9('0x2e')](_0xea80f0['query'][_0x6bf9('0x2e')]);}return _0xaa287e['getAgents'](_0x1f29d6);}})[_0x6bf9('0x1e')](function(_0x586f48){if(_0x586f48){return _0x586f48?{'count':_0x3993be,'rows':_0x586f48}:null;}})[_0x6bf9('0x1e')](respondWithResult(_0x419a30,null))[_0x6bf9('0x29')](handleError(_0x419a30,null));};
\ No newline at end of file
+var _0x4312=['then','get','ChatQueues','UserProfileResource','end','error','stack','name','send','ChatQueue','rawAttributes','fieldName','type','key','getOptions','include','query','rows','catch','show','model','keys','filters','attributes','intersection','fields','length','includeAll','merge','options','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','findOne','nolimit','limit','sort','where','ChatQueueId','map','filter','UserChatQueue','findAll','findAndCountAll','agent','chatPause','createdAt','format','updatedAt','getTeams','order','hasOwnProperty','addTeams','ids','Team','Agents','voicePause','interface','flatMap','sequelize','transaction','findOrCreate','forEach','emit','userChatQueue:save','User','select','tq.TeamId','from','team_has_chat_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','includes','union','compact','value','removeTeams','isEmpty','removeAgents','userChatQueue:remove','addAgents','omit','spread','isArray','getAgents','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','localhost','./chatQueue.socket','register','sendStatus','status','json','offset','undefined','count','set','Content-Range','destroy'];(function(_0x5730a9,_0x22d1a5){var _0x25b913=function(_0x559e35){while(--_0x559e35){_0x5730a9['push'](_0x5730a9['shift']());}};_0x25b913(++_0x22d1a5);}(_0x4312,0xdb));var _0x2431=function(_0x593576,_0x8629f2){_0x593576=_0x593576-0x0;var _0x2bcd63=_0x4312[_0x593576];return _0x2bcd63;};'use strict';var BPromise=require('bluebird');var util=require('util');var _=require('lodash');var squel=require('squel');var Redis=require(_0x2431('0x0'));var qs=require(_0x2431('0x1'));var logger=require(_0x2431('0x2'))(_0x2431('0x3'));var config=require(_0x2431('0x4'));var db=require(_0x2431('0x5'))['db'];config[_0x2431('0x6')]=_['defaults'](config[_0x2431('0x6')],{'host':_0x2431('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x2431('0x8'))[_0x2431('0x9')](socket);function respondWithStatusCode(_0x548402,_0xd5b9ef){_0xd5b9ef=_0xd5b9ef||0xcc;return function(_0x4a6c8f){if(_0x4a6c8f){return _0x548402[_0x2431('0xa')](_0xd5b9ef);}return _0x548402[_0x2431('0xb')](_0xd5b9ef)['end']();};}function respondWithResult(_0x530a67,_0x512e1c){_0x512e1c=_0x512e1c||0xc8;return function(_0x8526a7){if(_0x8526a7){return _0x530a67[_0x2431('0xb')](_0x512e1c)[_0x2431('0xc')](_0x8526a7);}};}function respondWithFilteredResult(_0x4e3f21,_0x4497b0){return function(_0x4e1392){if(_0x4e1392){var _0x82fc80=typeof _0x4497b0[_0x2431('0xd')]===_0x2431('0xe')&&typeof _0x4497b0['limit']===_0x2431('0xe');var _0x482fdb=_0x4e1392['count'];var _0x56e4ea=_0x82fc80?0x0:_0x4497b0[_0x2431('0xd')];var _0x557b9a=_0x82fc80?_0x4e1392[_0x2431('0xf')]:_0x4497b0[_0x2431('0xd')]+_0x4497b0['limit'];var _0x162dd6;if(_0x557b9a>=_0x482fdb){_0x557b9a=_0x482fdb;_0x162dd6=0xc8;}else{_0x162dd6=0xce;}_0x4e3f21[_0x2431('0xb')](_0x162dd6);return _0x4e3f21[_0x2431('0x10')](_0x2431('0x11'),_0x56e4ea+'-'+_0x557b9a+'/'+_0x482fdb)['json'](_0x4e1392);}return null;};}function saveUpdates(_0xc8d93e){return function(_0x212914){if(_0x212914){return _0x212914['update'](_0xc8d93e)['then'](function(_0x4d1029){return _0x4d1029;});}return null;};}function removeEntity(_0x1cc458){return function(_0x32ad63){if(_0x32ad63){return _0x32ad63[_0x2431('0x12')]()[_0x2431('0x13')](function(){var _0x59f8fc=_0x32ad63[_0x2431('0x14')]({'plain':!![]});var _0x30ee12=_0x2431('0x15');return db[_0x2431('0x16')]['destroy']({'where':{'type':_0x30ee12,'resourceId':_0x59f8fc['id']}})['then'](function(){return _0x32ad63;});})[_0x2431('0x13')](function(){_0x1cc458[_0x2431('0xb')](0xcc)[_0x2431('0x17')]();});}};}function handleEntityNotFound(_0xc8c754){return function(_0x569550){if(!_0x569550){_0xc8c754[_0x2431('0xa')](0x194);}return _0x569550;};}function handleError(_0x4aab56,_0x27b83f){_0x27b83f=_0x27b83f||0x1f4;return function(_0x4563dd){logger[_0x2431('0x18')](_0x4563dd[_0x2431('0x19')]);if(_0x4563dd[_0x2431('0x1a')]){delete _0x4563dd[_0x2431('0x1a')];}_0x4aab56[_0x2431('0xb')](_0x27b83f)[_0x2431('0x1b')](_0x4563dd);};}exports['index']=function(_0x1f5c8b,_0x5c6231){var _0x2fa64a={};var _0x32ea4d={'count':0x0,'rows':[]};var _0x181b34=_['map'](db[_0x2431('0x1c')][_0x2431('0x1d')],function(_0x3b4884){return{'name':_0x3b4884[_0x2431('0x1e')],'type':_0x3b4884[_0x2431('0x1f')][_0x2431('0x20')]};});_0x2fa64a=qs[_0x2431('0x21')](_0x181b34,_0x1f5c8b);var _0xaeb041={'where':_0x2fa64a['where']};return db[_0x2431('0x1c')]['count'](_0xaeb041)[_0x2431('0x13')](function(_0x4d40e9){_0x32ea4d[_0x2431('0xf')]=_0x4d40e9;_0x2fa64a['include']=qs[_0x2431('0x22')](_0x1f5c8b[_0x2431('0x23')]);return db['ChatQueue']['findAll'](_0x2fa64a);})[_0x2431('0x13')](function(_0x4d721f){_0x32ea4d[_0x2431('0x24')]=_0x4d721f;return _0x32ea4d;})[_0x2431('0x13')](respondWithFilteredResult(_0x5c6231,_0x2fa64a))[_0x2431('0x25')](handleError(_0x5c6231,null));};exports[_0x2431('0x26')]=function(_0x3812e5,_0xb3e3a5){var _0x583efe={'raw':!![],'where':{'id':_0x3812e5['params']['id']}},_0x36584a={};_0x36584a[_0x2431('0x27')]=_[_0x2431('0x28')](db[_0x2431('0x1c')][_0x2431('0x1d')]);_0x36584a[_0x2431('0x23')]=_[_0x2431('0x28')](_0x3812e5[_0x2431('0x23')]);_0x36584a[_0x2431('0x29')]=_['intersection'](_0x36584a[_0x2431('0x27')],_0x36584a[_0x2431('0x23')]);_0x583efe[_0x2431('0x2a')]=_[_0x2431('0x2b')](_0x36584a[_0x2431('0x27')],qs[_0x2431('0x2c')](_0x3812e5['query'][_0x2431('0x2c')]));_0x583efe[_0x2431('0x2a')]=_0x583efe['attributes'][_0x2431('0x2d')]?_0x583efe[_0x2431('0x2a')]:_0x36584a['model'];if(_0x3812e5['query'][_0x2431('0x2e')]){_0x583efe[_0x2431('0x22')]=[{'all':!![]}];}_0x583efe=_[_0x2431('0x2f')]({},_0x583efe,_0x3812e5[_0x2431('0x30')]);return db[_0x2431('0x1c')][_0x2431('0x31')](_0x583efe)[_0x2431('0x13')](handleEntityNotFound(_0xb3e3a5,null))['then'](respondWithResult(_0xb3e3a5,null))[_0x2431('0x25')](handleError(_0xb3e3a5,null));};exports[_0x2431('0x32')]=function(_0x4ed61c,_0x1d7bfc){return db[_0x2431('0x1c')]['create'](_0x4ed61c[_0x2431('0x33')],{})[_0x2431('0x13')](function(_0x31caed){var _0x15d14a=_0x4ed61c[_0x2431('0x34')][_0x2431('0x14')]({'plain':!![]});if(!_0x15d14a)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x15d14a[_0x2431('0x35')]==='user'){var _0x4aba06=_0x31caed[_0x2431('0x14')]({'plain':!![]});var _0x4a87ca='ChatQueues';return db[_0x2431('0x36')][_0x2431('0x31')]({'where':{'name':_0x4a87ca,'userProfileId':_0x15d14a[_0x2431('0x37')]},'raw':!![]})['then'](function(_0x169540){if(_0x169540&&_0x169540[_0x2431('0x38')]===0x0){return db['UserProfileResource'][_0x2431('0x32')]({'name':_0x4aba06[_0x2431('0x1a')],'resourceId':_0x4aba06['id'],'type':_0x169540[_0x2431('0x1a')],'sectionId':_0x169540['id']},{})[_0x2431('0x13')](function(){return _0x31caed;});}else{return _0x31caed;}})[_0x2431('0x25')](function(_0x347ed5){logger[_0x2431('0x18')](_0x2431('0x39'),_0x347ed5);throw _0x347ed5;});}return _0x31caed;})[_0x2431('0x13')](respondWithResult(_0x1d7bfc,0xc9))['catch'](handleError(_0x1d7bfc,null));};exports['update']=function(_0x51551f,_0x55f0c1){if(_0x51551f[_0x2431('0x33')]['id']){delete _0x51551f[_0x2431('0x33')]['id'];}return db[_0x2431('0x1c')]['find']({'where':{'id':_0x51551f[_0x2431('0x3a')]['id']}})[_0x2431('0x13')](handleEntityNotFound(_0x55f0c1,null))[_0x2431('0x13')](saveUpdates(_0x51551f[_0x2431('0x33')],null))[_0x2431('0x13')](respondWithResult(_0x55f0c1,null))[_0x2431('0x25')](handleError(_0x55f0c1,null));};exports[_0x2431('0x12')]=function(_0x32d3e3,_0x593cc8){return db[_0x2431('0x1c')][_0x2431('0x31')]({'where':{'id':_0x32d3e3['params']['id']}})[_0x2431('0x13')](handleEntityNotFound(_0x593cc8,null))[_0x2431('0x13')](removeEntity(_0x593cc8,null))['catch'](handleError(_0x593cc8,null));};exports['describe']=function(_0x1682d4,_0x3c5872){return db['ChatQueue'][_0x2431('0x3b')]()['then'](respondWithResult(_0x3c5872,null))[_0x2431('0x25')](handleError(_0x3c5872,null));};exports['getMembers']=function(_0x2eb8cf,_0x29890f){var _0x3acba4={'raw':!![],'where':{}},_0x38ca00={},_0xca8677;return db[_0x2431('0x1c')][_0x2431('0x3c')]({'where':{'id':_0x2eb8cf['params']['id']}})[_0x2431('0x13')](handleEntityNotFound(_0x29890f,null))['then'](function(_0x3757da){if(_0x3757da){_0xca8677=_0x3757da[_0x2431('0x14')]({'plain':!![]});_0x38ca00[_0x2431('0x27')]=_[_0x2431('0x28')](db['UserChatQueue']['rawAttributes']);_0x38ca00['query']=_[_0x2431('0x28')](_0x2eb8cf[_0x2431('0x23')]);_0x38ca00['filters']=_[_0x2431('0x2b')](_0x38ca00[_0x2431('0x27')],_0x38ca00['query']);_0x3acba4[_0x2431('0x2a')]=_[_0x2431('0x2b')](_0x38ca00[_0x2431('0x27')],qs['fields'](_0x2eb8cf[_0x2431('0x23')][_0x2431('0x2c')]));_0x3acba4['attributes']=_0x3acba4['attributes'][_0x2431('0x2d')]?_0x3acba4[_0x2431('0x2a')]:_0x38ca00[_0x2431('0x27')];if(!_0x2eb8cf[_0x2431('0x23')]['hasOwnProperty'](_0x2431('0x3d'))){_0x3acba4[_0x2431('0x3e')]=qs['limit'](_0x2eb8cf[_0x2431('0x23')][_0x2431('0x3e')]);_0x3acba4[_0x2431('0xd')]=qs[_0x2431('0xd')](_0x2eb8cf[_0x2431('0x23')][_0x2431('0xd')]);}_0x3acba4['order']=qs[_0x2431('0x3f')](_0x2eb8cf[_0x2431('0x23')]['sort']);_0x3acba4['where']=qs[_0x2431('0x29')](_['pick'](_0x2eb8cf[_0x2431('0x23')],_0x38ca00[_0x2431('0x29')]));_0x3acba4[_0x2431('0x40')][_0x2431('0x41')]=_0x3757da['id'];if(_0x2eb8cf[_0x2431('0x23')]['filter']){_0x3acba4[_0x2431('0x40')]=_[_0x2431('0x2f')](_0x3acba4['where'],{'$or':_[_0x2431('0x42')](_0x3acba4[_0x2431('0x2a')],function(_0x43f65f){var _0x271996={};_0x271996[_0x43f65f]={'$like':'%'+_0x2eb8cf['query'][_0x2431('0x43')]+'%'};return _0x271996;})});}_0x3acba4=_[_0x2431('0x2f')]({},_0x3acba4,_0x2eb8cf[_0x2431('0x30')]);return db[_0x2431('0x44')][_0x2431('0x45')](_0x3acba4);}})['then'](function(_0x4fc07b){if(_0x4fc07b){return db['User'][_0x2431('0x46')]({'where':{'id':_[_0x2431('0x42')](_0x4fc07b,'UserId'),'role':_0x2431('0x47')},'attributes':['id',_0x2431('0x1a'),_0x2431('0x48'),'updatedAt',_0x2431('0x49')]});}})[_0x2431('0x13')](function(_0x1ca705){if(_0x1ca705){return{'count':_0x1ca705[_0x2431('0xf')],'rows':_['map'](_0x1ca705[_0x2431('0x24')],function(_0x4ec19e){return{'membername':_0x4ec19e[_0x2431('0x1a')],'UserId':_0x4ec19e['id'],'queue_name':_0xca8677['name'],'ChatQueueId':_0xca8677['id'],'interface':util[_0x2431('0x4a')]('%s/%s','SIP',_0x4ec19e[_0x2431('0x1a')]),'penalty':0x0,'paused':_0x4ec19e[_0x2431('0x48')],'createdAt':_0x4ec19e['createdAt'],'updatedAt':_0x4ec19e[_0x2431('0x4b')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x2431('0x13')](respondWithFilteredResult(_0x29890f,_0x3acba4))[_0x2431('0x25')](handleError(_0x29890f,null));};exports[_0x2431('0x4c')]=function(_0x54ecd8,_0x2d9b61){var _0x396b9b={};var _0x130eb5={};var _0x2852d8;var _0x106ad1;return db['ChatQueue'][_0x2431('0x3c')]({'where':{'id':_0x54ecd8['params']['id']}})[_0x2431('0x13')](handleEntityNotFound(_0x2d9b61,null))[_0x2431('0x13')](function(_0x7e5d33){if(_0x7e5d33){_0x2852d8=_0x7e5d33;_0x130eb5[_0x2431('0x27')]=_[_0x2431('0x28')](db['Team'][_0x2431('0x1d')]);_0x130eb5[_0x2431('0x23')]=_['keys'](_0x54ecd8[_0x2431('0x23')]);_0x130eb5['filters']=_['intersection'](_0x130eb5['model'],_0x130eb5['query']);_0x396b9b[_0x2431('0x2a')]=_[_0x2431('0x2b')](_0x130eb5['model'],qs[_0x2431('0x2c')](_0x54ecd8[_0x2431('0x23')][_0x2431('0x2c')]));_0x396b9b[_0x2431('0x2a')]=_0x396b9b[_0x2431('0x2a')]['length']?_0x396b9b[_0x2431('0x2a')]:_0x130eb5[_0x2431('0x27')];_0x396b9b[_0x2431('0x4d')]=qs[_0x2431('0x3f')](_0x54ecd8[_0x2431('0x23')][_0x2431('0x3f')]);_0x396b9b[_0x2431('0x40')]=qs[_0x2431('0x29')](_['pick'](_0x54ecd8[_0x2431('0x23')],_0x130eb5[_0x2431('0x29')]));if(_0x54ecd8[_0x2431('0x23')][_0x2431('0x43')]){_0x396b9b[_0x2431('0x40')]=_[_0x2431('0x2f')](_0x396b9b[_0x2431('0x40')],{'$or':_[_0x2431('0x42')](_0x396b9b[_0x2431('0x2a')],function(_0x570a19){var _0x3f564f={};_0x3f564f[_0x570a19]={'$like':'%'+_0x54ecd8[_0x2431('0x23')][_0x2431('0x43')]+'%'};return _0x3f564f;})});}_0x396b9b=_[_0x2431('0x2f')]({},_0x396b9b,_0x54ecd8[_0x2431('0x30')]);return _0x2852d8[_0x2431('0x4c')](_0x396b9b);}})[_0x2431('0x13')](function(_0x451b3c){if(_0x451b3c){_0x106ad1=_0x451b3c[_0x2431('0x2d')];if(!_0x54ecd8[_0x2431('0x23')][_0x2431('0x4e')](_0x2431('0x3d'))){_0x396b9b['limit']=qs['limit'](_0x54ecd8[_0x2431('0x23')][_0x2431('0x3e')]);_0x396b9b['offset']=qs[_0x2431('0xd')](_0x54ecd8[_0x2431('0x23')]['offset']);}return _0x2852d8[_0x2431('0x4c')](_0x396b9b);}})['then'](function(_0x2fa746){if(_0x2fa746){return _0x2fa746?{'count':_0x106ad1,'rows':_0x2fa746}:null;}})[_0x2431('0x13')](respondWithResult(_0x2d9b61,null))[_0x2431('0x25')](handleError(_0x2d9b61,null));};exports[_0x2431('0x4f')]=function(_0x989168,_0x49635d){var _0x1ad009=_0x989168[_0x2431('0x33')][_0x2431('0x50')];return db[_0x2431('0x51')][_0x2431('0x45')]({'where':{'id':_0x1ad009},'attributes':['id'],'include':[{'model':db['User'],'as':_0x2431('0x52'),'attributes':['id','name','online',_0x2431('0x53'),_0x2431('0x54')],'raw':!![]}]})[_0x2431('0x13')](function(_0x2a61df){if(_0x2a61df){var _0x322db0=_[_0x2431('0x55')](_0x2a61df,function(_0x110c68){var _0x21a186=_0x110c68['get']({'plain':!![]});return _0x21a186['Agents'];});return db[_0x2431('0x1c')][_0x2431('0x31')]({'where':{'id':_0x989168[_0x2431('0x3a')]['id']}})[_0x2431('0x13')](function(_0x48a7cc){return db[_0x2431('0x56')][_0x2431('0x57')](function(_0x286c8c){return _0x48a7cc[_0x2431('0x4f')](_0x1ad009,{'transaction':_0x286c8c})[_0x2431('0x13')](function(){return BPromise['each'](_0x322db0,function(_0x4bd7e5){return db[_0x2431('0x44')][_0x2431('0x58')]({'where':{'UserId':_0x4bd7e5['id'],'ChatQueueId':_0x989168[_0x2431('0x3a')]['id']},'transaction':_0x286c8c});});})[_0x2431('0x13')](function(){_0x322db0[_0x2431('0x59')](function(_0x556bed){socket[_0x2431('0x5a')](_0x2431('0x5b'),{'UserId':_0x556bed['id'],'ChatQueueId':_0x48a7cc['id']});});});});});}})['then'](respondWithStatusCode(_0x49635d,null))[_0x2431('0x25')](handleError(_0x49635d,null));};exports['removeTeams']=function(_0x105864,_0x16b883){return db[_0x2431('0x51')][_0x2431('0x45')]({'where':{'id':_0x105864['query'][_0x2431('0x50')]},'attributes':['id'],'include':[{'model':db[_0x2431('0x5c')],'as':_0x2431('0x52'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x16b883,null))[_0x2431('0x13')](function(_0x1dcbb7){var _0x32da14=_[_0x2431('0x42')](_0x1dcbb7,'id');var _0x1f3def=[];var _0x23ffc6=[];var _0x4bd2b8=squel[_0x2431('0x5d')]();_0x4bd2b8['field'](_0x2431('0x5e'))[_0x2431('0x5f')](_0x2431('0x60'),'tq')['join'](_0x2431('0x61'),'ut',_0x2431('0x62'))[_0x2431('0x40')](_0x2431('0x63'),_0x105864['params']['id']);for(var _0x1d58a3=0x0;_0x1d58a3<_0x1dcbb7[_0x2431('0x2d')];_0x1d58a3+=0x1){let _0x344a93=_0x1dcbb7[_0x1d58a3];for(var _0x2e0173=0x0;_0x2e0173<_0x344a93[_0x2431('0x52')][_0x2431('0x2d')];_0x2e0173+=0x1){let _0x2d6f3e=_0x344a93['Agents'][_0x2e0173];var _0x5578ab=_0x4bd2b8[_0x2431('0x64')]();_0x5578ab[_0x2431('0x40')](_0x2431('0x65'),_0x2d6f3e['id']);_0x23ffc6[_0x2431('0x66')](db[_0x2431('0x56')][_0x2431('0x23')](_0x5578ab[_0x2431('0x67')](),{'type':db[_0x2431('0x56')][_0x2431('0x68')][_0x2431('0x69')]})[_0x2431('0x13')](function(_0xc5cfa2){if(_0xc5cfa2['length']===0x1){return _0x2d6f3e['id'];}else{var _0x334d0c=_['every'](_[_0x2431('0x42')](_0xc5cfa2,'TeamId'),function(_0x2024ef){return _[_0x2431('0x6a')](_0x32da14,_0x2024ef);});if(_0x334d0c){return _0x2d6f3e['id'];}}}));}}return BPromise['all'](_0x23ffc6)['then'](function(_0x22dca8){_0x1f3def=_(_0x1f3def)[_0x2431('0x6b')](_0x22dca8)[_0x2431('0x6c')]()[_0x2431('0x6d')]();return db[_0x2431('0x1c')][_0x2431('0x31')]({'where':{'id':_0x105864[_0x2431('0x3a')]['id']}})[_0x2431('0x13')](function(_0x55b15e){return db[_0x2431('0x56')]['transaction'](function(_0x4391f2){return _0x55b15e[_0x2431('0x6e')](_0x105864[_0x2431('0x23')]['ids'],{'transaction':_0x4391f2})[_0x2431('0x13')](function(){if(!_[_0x2431('0x6f')](_0x1f3def)){return _0x55b15e[_0x2431('0x70')](_0x1f3def,{'transaction':_0x4391f2});}})[_0x2431('0x13')](function(){_0x1f3def['forEach'](function(_0x2d2586){socket[_0x2431('0x5a')](_0x2431('0x71'),{'UserId':_0x2d2586,'ChatQueueId':_0x55b15e['id']});});});});});});})[_0x2431('0x13')](respondWithStatusCode(_0x16b883,null))[_0x2431('0x25')](handleError(_0x16b883,null));};exports[_0x2431('0x72')]=function(_0x5acfb3,_0x196fd8){return db[_0x2431('0x1c')][_0x2431('0x31')]({'where':{'id':_0x5acfb3[_0x2431('0x3a')]['id']}})[_0x2431('0x13')](handleEntityNotFound(_0x196fd8,null))[_0x2431('0x13')](function(_0x4196ac){if(_0x4196ac){return _0x4196ac[_0x2431('0x72')](_0x5acfb3[_0x2431('0x33')]['ids'],_[_0x2431('0x73')](_0x5acfb3[_0x2431('0x33')],[_0x2431('0x50'),'id'])||{})[_0x2431('0x74')](function(_0x228879){for(var _0x3ac587=0x0;_0x3ac587<_0x5acfb3['body'][_0x2431('0x50')][_0x2431('0x2d')];_0x3ac587+=0x1){socket[_0x2431('0x5a')](_0x2431('0x5b'),{'UserId':Number(_0x5acfb3['body'][_0x2431('0x50')][_0x3ac587]),'ChatQueueId':Number(_0x5acfb3[_0x2431('0x3a')]['id'])});}return _0x228879;});}})['then'](respondWithResult(_0x196fd8,null))[_0x2431('0x25')](handleError(_0x196fd8,null));};exports[_0x2431('0x70')]=function(_0x4d8a18,_0x4e7e47){return db[_0x2431('0x1c')][_0x2431('0x31')]({'where':{'id':_0x4d8a18[_0x2431('0x3a')]['id']}})[_0x2431('0x13')](handleEntityNotFound(_0x4e7e47,null))[_0x2431('0x13')](function(_0x370c38){if(_0x370c38){return _0x370c38[_0x2431('0x70')](_0x4d8a18[_0x2431('0x23')][_0x2431('0x50')])['then'](function(){if(_[_0x2431('0x75')](_0x4d8a18[_0x2431('0x23')][_0x2431('0x50')])){for(var _0x5cbb2d=0x0;_0x5cbb2d<_0x4d8a18[_0x2431('0x23')][_0x2431('0x50')][_0x2431('0x2d')];_0x5cbb2d+=0x1){socket[_0x2431('0x5a')]('userChatQueue:remove',{'UserId':Number(_0x4d8a18[_0x2431('0x23')][_0x2431('0x50')][_0x5cbb2d]),'ChatQueueId':Number(_0x4d8a18[_0x2431('0x3a')]['id'])});}}else{socket[_0x2431('0x5a')](_0x2431('0x71'),{'UserId':Number(_0x4d8a18[_0x2431('0x23')][_0x2431('0x50')]),'ChatQueueId':Number(_0x4d8a18[_0x2431('0x3a')]['id'])});}});}})[_0x2431('0x13')](respondWithStatusCode(_0x4e7e47,null))[_0x2431('0x25')](handleError(_0x4e7e47,null));};exports[_0x2431('0x76')]=function(_0x1d57a2,_0x5977d9){var _0x4998b8={};var _0x1f85fa={};var _0x2b510c;var _0x36e16a;return db[_0x2431('0x1c')][_0x2431('0x3c')]({'where':{'id':_0x1d57a2[_0x2431('0x3a')]['id']}})[_0x2431('0x13')](handleEntityNotFound(_0x5977d9,null))[_0x2431('0x13')](function(_0x1281d5){if(_0x1281d5){_0x2b510c=_0x1281d5;_0x1f85fa['model']=_[_0x2431('0x28')](db['User'][_0x2431('0x1d')]);_0x1f85fa['query']=_[_0x2431('0x28')](_0x1d57a2[_0x2431('0x23')]);_0x1f85fa[_0x2431('0x29')]=_[_0x2431('0x2b')](_0x1f85fa['model'],_0x1f85fa[_0x2431('0x23')]);_0x4998b8['attributes']=_[_0x2431('0x2b')](_0x1f85fa['model'],qs['fields'](_0x1d57a2[_0x2431('0x23')][_0x2431('0x2c')]));_0x4998b8[_0x2431('0x2a')]=_0x4998b8[_0x2431('0x2a')][_0x2431('0x2d')]?_0x4998b8[_0x2431('0x2a')]:_0x1f85fa['model'];_0x4998b8[_0x2431('0x4d')]=qs[_0x2431('0x3f')](_0x1d57a2[_0x2431('0x23')][_0x2431('0x3f')]);_0x4998b8[_0x2431('0x40')]=qs['filters'](_['pick'](_0x1d57a2['query'],_0x1f85fa[_0x2431('0x29')]));if(_0x1d57a2[_0x2431('0x23')]['filter']){_0x4998b8[_0x2431('0x40')]=_['merge'](_0x4998b8['where'],{'$or':_['map'](_0x4998b8[_0x2431('0x2a')],function(_0x7aeba9){var _0x8f9b5b={};_0x8f9b5b[_0x7aeba9]={'$like':'%'+_0x1d57a2[_0x2431('0x23')][_0x2431('0x43')]+'%'};return _0x8f9b5b;})});}_0x4998b8=_['merge']({},_0x4998b8,_0x1d57a2[_0x2431('0x30')]);return _0x2b510c[_0x2431('0x76')](_0x4998b8);}})[_0x2431('0x13')](function(_0x485b65){if(_0x485b65){_0x36e16a=_0x485b65['length'];if(!_0x1d57a2[_0x2431('0x23')][_0x2431('0x4e')](_0x2431('0x3d'))){_0x4998b8[_0x2431('0x3e')]=qs['limit'](_0x1d57a2['query'][_0x2431('0x3e')]);_0x4998b8['offset']=qs[_0x2431('0xd')](_0x1d57a2[_0x2431('0x23')][_0x2431('0xd')]);}return _0x2b510c['getAgents'](_0x4998b8);}})[_0x2431('0x13')](function(_0xb32e92){if(_0xb32e92){return _0xb32e92?{'count':_0x36e16a,'rows':_0xb32e92}:null;}})['then'](respondWithResult(_0x5977d9,null))[_0x2431('0x25')](handleError(_0x5977d9,null));};
\ No newline at end of file