Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index ba5068a..f667863 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbcd1=['Agents','online','interface','flatMap','sequelize','each','findOrCreate','emit','userChatQueue:save','removeTeams','select','field','team_has_chat_queues','ut.TeamId\x20=\x20tq.TeamId','clone','push','toString','SELECT','every','TeamId','includes','all','transaction','isEmpty','removeAgents','forEach','userChatQueue:remove','addAgents','omit','spread','isArray','getAgents','bluebird','util','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','defaults','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','update','then','ChatQueues','destroy','error','name','send','index','ChatQueue','rawAttributes','fieldName','type','where','include','query','findAll','rows','catch','show','params','model','keys','filters','intersection','attributes','fields','length','includeAll','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','UserChatQueue','hasOwnProperty','order','sort','ChatQueueId','filter','merge','map','User','findAndCountAll','UserId','agent','chatPause','createdAt','format','%s/%s','SIP','updatedAt','Team','pick','getTeams','addTeams','ids'];(function(_0x4ca00e,_0x554842){var _0x2c9cb1=function(_0x1cc376){while(--_0x1cc376){_0x4ca00e['push'](_0x4ca00e['shift']());}};_0x2c9cb1(++_0x554842);}(_0xbcd1,0x110));var _0x1bcd=function(_0x5991d7,_0x3ca7f8){_0x5991d7=_0x5991d7-0x0;var _0x5b299d=_0xbcd1[_0x5991d7];return _0x5b299d;};'use strict';var BPromise=require(_0x1bcd('0x0'));var util=require(_0x1bcd('0x1'));var _=require('lodash');var squel=require(_0x1bcd('0x2'));var Redis=require(_0x1bcd('0x3'));var qs=require(_0x1bcd('0x4'));var logger=require(_0x1bcd('0x5'))(_0x1bcd('0x6'));var config=require(_0x1bcd('0x7'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x1bcd('0x8')](config[_0x1bcd('0x9')],{'host':_0x1bcd('0xa'),'port':0x18eb});var socket=require(_0x1bcd('0xb'))(new Redis(config['redis']));require('./chatQueue.socket')[_0x1bcd('0xc')](socket);function respondWithStatusCode(_0x24c715,_0x17e7e3){_0x17e7e3=_0x17e7e3||0xcc;return function(_0x251ea0){if(_0x251ea0){return _0x24c715[_0x1bcd('0xd')](_0x17e7e3);}return _0x24c715[_0x1bcd('0xe')](_0x17e7e3)[_0x1bcd('0xf')]();};}function respondWithResult(_0xd28ec6,_0x5b2ffe){_0x5b2ffe=_0x5b2ffe||0xc8;return function(_0x3dccc5){if(_0x3dccc5){return _0xd28ec6[_0x1bcd('0xe')](_0x5b2ffe)[_0x1bcd('0x10')](_0x3dccc5);}};}function respondWithFilteredResult(_0x592e5f,_0xadc1f7){return function(_0x41b30f){if(_0x41b30f){var _0x4a3d45=typeof _0xadc1f7['offset']===_0x1bcd('0x11')&&typeof _0xadc1f7[_0x1bcd('0x12')]===_0x1bcd('0x11');var _0x533a96=_0x41b30f[_0x1bcd('0x13')];var _0x2107e5=_0x4a3d45?0x0:_0xadc1f7[_0x1bcd('0x14')];var _0x333b1b=_0x4a3d45?_0x41b30f[_0x1bcd('0x13')]:_0xadc1f7[_0x1bcd('0x14')]+_0xadc1f7['limit'];var _0x166349;if(_0x333b1b>=_0x533a96){_0x333b1b=_0x533a96;_0x166349=0xc8;}else{_0x166349=0xce;}_0x592e5f[_0x1bcd('0xe')](_0x166349);return _0x592e5f[_0x1bcd('0x15')](_0x1bcd('0x16'),_0x2107e5+'-'+_0x333b1b+'/'+_0x533a96)[_0x1bcd('0x10')](_0x41b30f);}return null;};}function saveUpdates(_0x32c222){return function(_0x19cb7d){if(_0x19cb7d){return _0x19cb7d[_0x1bcd('0x17')](_0x32c222)[_0x1bcd('0x18')](function(_0x251adc){return _0x251adc;});}return null;};}function removeEntity(_0x88a497){return function(_0x10f845){if(_0x10f845){return _0x10f845['destroy']()[_0x1bcd('0x18')](function(){var _0x9005f3=_0x10f845['get']({'plain':!![]});var _0x1c9a18=_0x1bcd('0x19');return db['UserProfileResource'][_0x1bcd('0x1a')]({'where':{'type':_0x1c9a18,'resourceId':_0x9005f3['id']}})['then'](function(){return _0x10f845;});})['then'](function(){_0x88a497[_0x1bcd('0xe')](0xcc)['end']();});}};}function handleEntityNotFound(_0x36e361){return function(_0x986650){if(!_0x986650){_0x36e361['sendStatus'](0x194);}return _0x986650;};}function handleError(_0x5ce437,_0x1c412f){_0x1c412f=_0x1c412f||0x1f4;return function(_0x2a177d){logger[_0x1bcd('0x1b')](_0x2a177d['stack']);if(_0x2a177d[_0x1bcd('0x1c')]){delete _0x2a177d[_0x1bcd('0x1c')];}_0x5ce437[_0x1bcd('0xe')](_0x1c412f)[_0x1bcd('0x1d')](_0x2a177d);};}exports[_0x1bcd('0x1e')]=function(_0x3977c5,_0x1e693d){var _0x586907={};var _0x1c7e69={'count':0x0,'rows':[]};var _0x3e9939=_['map'](db[_0x1bcd('0x1f')][_0x1bcd('0x20')],function(_0x4468e4){return{'name':_0x4468e4[_0x1bcd('0x21')],'type':_0x4468e4[_0x1bcd('0x22')]['key']};});_0x586907=qs['getOptions'](_0x3e9939,_0x3977c5);var _0x383a0b={'where':_0x586907[_0x1bcd('0x23')]};return db[_0x1bcd('0x1f')][_0x1bcd('0x13')](_0x383a0b)[_0x1bcd('0x18')](function(_0x455466){_0x1c7e69[_0x1bcd('0x13')]=_0x455466;_0x586907[_0x1bcd('0x24')]=qs['include'](_0x3977c5[_0x1bcd('0x25')]);return db[_0x1bcd('0x1f')][_0x1bcd('0x26')](_0x586907);})['then'](function(_0x39cf69){_0x1c7e69[_0x1bcd('0x27')]=_0x39cf69;return _0x1c7e69;})['then'](respondWithFilteredResult(_0x1e693d,_0x586907))[_0x1bcd('0x28')](handleError(_0x1e693d,null));};exports[_0x1bcd('0x29')]=function(_0x4d9d0e,_0x4bcc94){var _0x500d93={'raw':!![],'where':{'id':_0x4d9d0e[_0x1bcd('0x2a')]['id']}},_0x45e7d2={};_0x45e7d2[_0x1bcd('0x2b')]=_['keys'](db['ChatQueue'][_0x1bcd('0x20')]);_0x45e7d2[_0x1bcd('0x25')]=_[_0x1bcd('0x2c')](_0x4d9d0e['query']);_0x45e7d2[_0x1bcd('0x2d')]=_[_0x1bcd('0x2e')](_0x45e7d2[_0x1bcd('0x2b')],_0x45e7d2[_0x1bcd('0x25')]);_0x500d93[_0x1bcd('0x2f')]=_[_0x1bcd('0x2e')](_0x45e7d2[_0x1bcd('0x2b')],qs[_0x1bcd('0x30')](_0x4d9d0e[_0x1bcd('0x25')][_0x1bcd('0x30')]));_0x500d93[_0x1bcd('0x2f')]=_0x500d93['attributes'][_0x1bcd('0x31')]?_0x500d93[_0x1bcd('0x2f')]:_0x45e7d2[_0x1bcd('0x2b')];if(_0x4d9d0e['query'][_0x1bcd('0x32')]){_0x500d93[_0x1bcd('0x24')]=[{'all':!![]}];}_0x500d93=_['merge']({},_0x500d93,_0x4d9d0e[_0x1bcd('0x33')]);return db['ChatQueue'][_0x1bcd('0x34')](_0x500d93)[_0x1bcd('0x18')](handleEntityNotFound(_0x4bcc94,null))['then'](respondWithResult(_0x4bcc94,null))['catch'](handleError(_0x4bcc94,null));};exports[_0x1bcd('0x35')]=function(_0x1b9307,_0x3809a2){return db[_0x1bcd('0x1f')]['create'](_0x1b9307[_0x1bcd('0x36')],{})['then'](function(_0x288bb3){var _0x498937=_0x1b9307[_0x1bcd('0x37')]['get']({'plain':!![]});if(!_0x498937)throw new Error(_0x1bcd('0x38'));if(_0x498937[_0x1bcd('0x39')]===_0x1bcd('0x37')){var _0x35f658=_0x288bb3[_0x1bcd('0x3a')]({'plain':!![]});var _0x1419b1=_0x1bcd('0x19');return db['UserProfileSection'][_0x1bcd('0x34')]({'where':{'name':_0x1419b1,'userProfileId':_0x498937[_0x1bcd('0x3b')]},'raw':!![]})[_0x1bcd('0x18')](function(_0x197251){if(_0x197251&&_0x197251[_0x1bcd('0x3c')]===0x0){return db[_0x1bcd('0x3d')]['create']({'name':_0x35f658[_0x1bcd('0x1c')],'resourceId':_0x35f658['id'],'type':_0x197251[_0x1bcd('0x1c')],'sectionId':_0x197251['id']},{})[_0x1bcd('0x18')](function(){return _0x288bb3;});}else{return _0x288bb3;}})['catch'](function(_0x17c062){logger[_0x1bcd('0x1b')](_0x1bcd('0x3e'),_0x17c062);throw _0x17c062;});}return _0x288bb3;})[_0x1bcd('0x18')](respondWithResult(_0x3809a2,0xc9))[_0x1bcd('0x28')](handleError(_0x3809a2,null));};exports['update']=function(_0x46bd5f,_0xb2f4be){if(_0x46bd5f[_0x1bcd('0x36')]['id']){delete _0x46bd5f[_0x1bcd('0x36')]['id'];}return db[_0x1bcd('0x1f')]['find']({'where':{'id':_0x46bd5f[_0x1bcd('0x2a')]['id']}})[_0x1bcd('0x18')](handleEntityNotFound(_0xb2f4be,null))[_0x1bcd('0x18')](saveUpdates(_0x46bd5f[_0x1bcd('0x36')],null))[_0x1bcd('0x18')](respondWithResult(_0xb2f4be,null))[_0x1bcd('0x28')](handleError(_0xb2f4be,null));};exports['destroy']=function(_0xcb5f,_0x213b4e){return db[_0x1bcd('0x1f')][_0x1bcd('0x34')]({'where':{'id':_0xcb5f[_0x1bcd('0x2a')]['id']}})[_0x1bcd('0x18')](handleEntityNotFound(_0x213b4e,null))['then'](removeEntity(_0x213b4e,null))[_0x1bcd('0x28')](handleError(_0x213b4e,null));};exports['describe']=function(_0x43d425,_0x211435){return db[_0x1bcd('0x1f')][_0x1bcd('0x3f')]()['then'](respondWithResult(_0x211435,null))['catch'](handleError(_0x211435,null));};exports['getMembers']=function(_0x52e110,_0x4ede57){var _0x26d389={'raw':!![],'where':{}},_0x2fd9ed={},_0x21ed02;return db[_0x1bcd('0x1f')][_0x1bcd('0x40')]({'where':{'id':_0x52e110[_0x1bcd('0x2a')]['id']}})[_0x1bcd('0x18')](handleEntityNotFound(_0x4ede57,null))['then'](function(_0x43c9e6){if(_0x43c9e6){_0x21ed02=_0x43c9e6[_0x1bcd('0x3a')]({'plain':!![]});_0x2fd9ed[_0x1bcd('0x2b')]=_[_0x1bcd('0x2c')](db[_0x1bcd('0x41')][_0x1bcd('0x20')]);_0x2fd9ed[_0x1bcd('0x25')]=_['keys'](_0x52e110[_0x1bcd('0x25')]);_0x2fd9ed['filters']=_[_0x1bcd('0x2e')](_0x2fd9ed[_0x1bcd('0x2b')],_0x2fd9ed[_0x1bcd('0x25')]);_0x26d389['attributes']=_[_0x1bcd('0x2e')](_0x2fd9ed[_0x1bcd('0x2b')],qs[_0x1bcd('0x30')](_0x52e110[_0x1bcd('0x25')][_0x1bcd('0x30')]));_0x26d389[_0x1bcd('0x2f')]=_0x26d389[_0x1bcd('0x2f')][_0x1bcd('0x31')]?_0x26d389['attributes']:_0x2fd9ed[_0x1bcd('0x2b')];if(!_0x52e110[_0x1bcd('0x25')][_0x1bcd('0x42')]('nolimit')){_0x26d389['limit']=qs[_0x1bcd('0x12')](_0x52e110[_0x1bcd('0x25')][_0x1bcd('0x12')]);_0x26d389[_0x1bcd('0x14')]=qs[_0x1bcd('0x14')](_0x52e110['query'][_0x1bcd('0x14')]);}_0x26d389[_0x1bcd('0x43')]=qs[_0x1bcd('0x44')](_0x52e110[_0x1bcd('0x25')][_0x1bcd('0x44')]);_0x26d389[_0x1bcd('0x23')]=qs[_0x1bcd('0x2d')](_['pick'](_0x52e110[_0x1bcd('0x25')],_0x2fd9ed[_0x1bcd('0x2d')]));_0x26d389[_0x1bcd('0x23')][_0x1bcd('0x45')]=_0x43c9e6['id'];if(_0x52e110[_0x1bcd('0x25')][_0x1bcd('0x46')]){_0x26d389[_0x1bcd('0x23')]=_[_0x1bcd('0x47')](_0x26d389['where'],{'$or':_[_0x1bcd('0x48')](_0x26d389['attributes'],function(_0x219d22){var _0x314c44={};_0x314c44[_0x219d22]={'$like':'%'+_0x52e110[_0x1bcd('0x25')][_0x1bcd('0x46')]+'%'};return _0x314c44;})});}_0x26d389=_['merge']({},_0x26d389,_0x52e110[_0x1bcd('0x33')]);return db[_0x1bcd('0x41')][_0x1bcd('0x26')](_0x26d389);}})[_0x1bcd('0x18')](function(_0x1c2076){if(_0x1c2076){return db[_0x1bcd('0x49')][_0x1bcd('0x4a')]({'where':{'id':_[_0x1bcd('0x48')](_0x1c2076,_0x1bcd('0x4b')),'role':_0x1bcd('0x4c')},'attributes':['id','name',_0x1bcd('0x4d'),'updatedAt',_0x1bcd('0x4e')]});}})[_0x1bcd('0x18')](function(_0x503e90){if(_0x503e90){return{'count':_0x503e90[_0x1bcd('0x13')],'rows':_[_0x1bcd('0x48')](_0x503e90[_0x1bcd('0x27')],function(_0x463d91){return{'membername':_0x463d91[_0x1bcd('0x1c')],'UserId':_0x463d91['id'],'queue_name':_0x21ed02[_0x1bcd('0x1c')],'ChatQueueId':_0x21ed02['id'],'interface':util[_0x1bcd('0x4f')](_0x1bcd('0x50'),_0x1bcd('0x51'),_0x463d91['name']),'penalty':0x0,'paused':_0x463d91['chatPause'],'createdAt':_0x463d91['createdAt'],'updatedAt':_0x463d91[_0x1bcd('0x52')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x1bcd('0x18')](respondWithFilteredResult(_0x4ede57,_0x26d389))[_0x1bcd('0x28')](handleError(_0x4ede57,null));};exports['getTeams']=function(_0x465df6,_0xd98cc1){var _0x43ba39={};var _0x4cc7c4={};var _0x55cd0b;var _0x53a118;return db[_0x1bcd('0x1f')]['findOne']({'where':{'id':_0x465df6['params']['id']}})[_0x1bcd('0x18')](handleEntityNotFound(_0xd98cc1,null))[_0x1bcd('0x18')](function(_0x5ce2fa){if(_0x5ce2fa){_0x55cd0b=_0x5ce2fa;_0x4cc7c4[_0x1bcd('0x2b')]=_[_0x1bcd('0x2c')](db[_0x1bcd('0x53')][_0x1bcd('0x20')]);_0x4cc7c4[_0x1bcd('0x25')]=_[_0x1bcd('0x2c')](_0x465df6[_0x1bcd('0x25')]);_0x4cc7c4[_0x1bcd('0x2d')]=_[_0x1bcd('0x2e')](_0x4cc7c4[_0x1bcd('0x2b')],_0x4cc7c4[_0x1bcd('0x25')]);_0x43ba39[_0x1bcd('0x2f')]=_['intersection'](_0x4cc7c4[_0x1bcd('0x2b')],qs[_0x1bcd('0x30')](_0x465df6[_0x1bcd('0x25')][_0x1bcd('0x30')]));_0x43ba39[_0x1bcd('0x2f')]=_0x43ba39[_0x1bcd('0x2f')]['length']?_0x43ba39[_0x1bcd('0x2f')]:_0x4cc7c4['model'];_0x43ba39[_0x1bcd('0x43')]=qs['sort'](_0x465df6[_0x1bcd('0x25')][_0x1bcd('0x44')]);_0x43ba39[_0x1bcd('0x23')]=qs['filters'](_[_0x1bcd('0x54')](_0x465df6[_0x1bcd('0x25')],_0x4cc7c4[_0x1bcd('0x2d')]));if(_0x465df6[_0x1bcd('0x25')][_0x1bcd('0x46')]){_0x43ba39[_0x1bcd('0x23')]=_[_0x1bcd('0x47')](_0x43ba39[_0x1bcd('0x23')],{'$or':_['map'](_0x43ba39[_0x1bcd('0x2f')],function(_0x441fd2){var _0x46c3b8={};_0x46c3b8[_0x441fd2]={'$like':'%'+_0x465df6[_0x1bcd('0x25')][_0x1bcd('0x46')]+'%'};return _0x46c3b8;})});}_0x43ba39=_['merge']({},_0x43ba39,_0x465df6[_0x1bcd('0x33')]);return _0x55cd0b[_0x1bcd('0x55')](_0x43ba39);}})[_0x1bcd('0x18')](function(_0x55acaa){if(_0x55acaa){_0x53a118=_0x55acaa['length'];if(!_0x465df6['query'][_0x1bcd('0x42')]('nolimit')){_0x43ba39[_0x1bcd('0x12')]=qs[_0x1bcd('0x12')](_0x465df6[_0x1bcd('0x25')][_0x1bcd('0x12')]);_0x43ba39[_0x1bcd('0x14')]=qs[_0x1bcd('0x14')](_0x465df6[_0x1bcd('0x25')][_0x1bcd('0x14')]);}return _0x55cd0b[_0x1bcd('0x55')](_0x43ba39);}})[_0x1bcd('0x18')](function(_0x4cef1f){if(_0x4cef1f){return _0x4cef1f?{'count':_0x53a118,'rows':_0x4cef1f}:null;}})[_0x1bcd('0x18')](respondWithResult(_0xd98cc1,null))[_0x1bcd('0x28')](handleError(_0xd98cc1,null));};exports[_0x1bcd('0x56')]=function(_0x1c38ad,_0x4f4c63){var _0x42af52=_0x1c38ad[_0x1bcd('0x36')][_0x1bcd('0x57')];return db[_0x1bcd('0x53')][_0x1bcd('0x26')]({'where':{'id':_0x42af52},'attributes':['id'],'include':[{'model':db[_0x1bcd('0x49')],'as':_0x1bcd('0x58'),'attributes':['id',_0x1bcd('0x1c'),_0x1bcd('0x59'),'voicePause',_0x1bcd('0x5a')],'raw':!![]}]})[_0x1bcd('0x18')](function(_0x18dc51){if(_0x18dc51){var _0x210bd2=_[_0x1bcd('0x5b')](_0x18dc51,function(_0x1fcdd3){var _0x22766d=_0x1fcdd3[_0x1bcd('0x3a')]({'plain':!![]});return _0x22766d[_0x1bcd('0x58')];});return db[_0x1bcd('0x1f')][_0x1bcd('0x34')]({'where':{'id':_0x1c38ad[_0x1bcd('0x2a')]['id']}})['then'](function(_0x316499){return db[_0x1bcd('0x5c')]['transaction'](function(_0x4452a0){return _0x316499[_0x1bcd('0x56')](_0x42af52,{'transaction':_0x4452a0})[_0x1bcd('0x18')](function(){return BPromise[_0x1bcd('0x5d')](_0x210bd2,function(_0x3c5caf){return db['UserChatQueue'][_0x1bcd('0x5e')]({'where':{'UserId':_0x3c5caf['id'],'ChatQueueId':_0x1c38ad[_0x1bcd('0x2a')]['id']},'transaction':_0x4452a0});});})[_0x1bcd('0x18')](function(){_0x210bd2['forEach'](function(_0x5f096b){socket[_0x1bcd('0x5f')](_0x1bcd('0x60'),{'UserId':_0x5f096b['id'],'ChatQueueId':_0x316499['id']});});});});});}})[_0x1bcd('0x18')](respondWithStatusCode(_0x4f4c63,null))[_0x1bcd('0x28')](handleError(_0x4f4c63,null));};exports[_0x1bcd('0x61')]=function(_0x2cec0b,_0x19efe6){return db['Team'][_0x1bcd('0x26')]({'where':{'id':_0x2cec0b['query'][_0x1bcd('0x57')]},'attributes':['id'],'include':[{'model':db[_0x1bcd('0x49')],'as':_0x1bcd('0x58'),'attributes':['id'],'raw':!![]}]})[_0x1bcd('0x18')](handleEntityNotFound(_0x19efe6,null))['then'](function(_0x59f453){var _0x4ca366=_[_0x1bcd('0x48')](_0x59f453,'id');var _0x51799e=[];var _0x34c042=[];var _0x152a57=squel[_0x1bcd('0x62')]();_0x152a57[_0x1bcd('0x63')]('tq.TeamId')['from'](_0x1bcd('0x64'),'tq')['join']('user_has_teams','ut',_0x1bcd('0x65'))[_0x1bcd('0x23')]('ChatQueueId\x20=\x20?',_0x2cec0b[_0x1bcd('0x2a')]['id']);for(var _0x42aeee=0x0;_0x42aeee<_0x59f453[_0x1bcd('0x31')];_0x42aeee+=0x1){let _0x1f1ac7=_0x59f453[_0x42aeee];for(var _0x23ef27=0x0;_0x23ef27<_0x1f1ac7[_0x1bcd('0x58')][_0x1bcd('0x31')];_0x23ef27+=0x1){let _0x1ac390=_0x1f1ac7[_0x1bcd('0x58')][_0x23ef27];var _0x27eda8=_0x152a57[_0x1bcd('0x66')]();_0x27eda8[_0x1bcd('0x23')]('ut.UserId\x20=\x20?',_0x1ac390['id']);_0x34c042[_0x1bcd('0x67')](db[_0x1bcd('0x5c')][_0x1bcd('0x25')](_0x27eda8[_0x1bcd('0x68')](),{'type':db['sequelize']['QueryTypes'][_0x1bcd('0x69')]})[_0x1bcd('0x18')](function(_0x268642){if(_0x268642[_0x1bcd('0x31')]===0x1){return _0x1ac390['id'];}else{var _0x42ec6a=_[_0x1bcd('0x6a')](_[_0x1bcd('0x48')](_0x268642,_0x1bcd('0x6b')),function(_0x86f988){return _[_0x1bcd('0x6c')](_0x4ca366,_0x86f988);});if(_0x42ec6a){return _0x1ac390['id'];}}}));}}return BPromise[_0x1bcd('0x6d')](_0x34c042)['then'](function(_0x20670a){_0x51799e=_(_0x51799e)['union'](_0x20670a)['compact']()['value']();return db[_0x1bcd('0x1f')][_0x1bcd('0x34')]({'where':{'id':_0x2cec0b[_0x1bcd('0x2a')]['id']}})[_0x1bcd('0x18')](function(_0x51a20d){return db[_0x1bcd('0x5c')][_0x1bcd('0x6e')](function(_0x311a0b){return _0x51a20d[_0x1bcd('0x61')](_0x2cec0b[_0x1bcd('0x25')][_0x1bcd('0x57')],{'transaction':_0x311a0b})['then'](function(){if(!_[_0x1bcd('0x6f')](_0x51799e)){return _0x51a20d[_0x1bcd('0x70')](_0x51799e,{'transaction':_0x311a0b});}})[_0x1bcd('0x18')](function(){_0x51799e[_0x1bcd('0x71')](function(_0x47e070){socket[_0x1bcd('0x5f')](_0x1bcd('0x72'),{'UserId':_0x47e070,'ChatQueueId':_0x51a20d['id']});});});});});});})[_0x1bcd('0x18')](respondWithStatusCode(_0x19efe6,null))[_0x1bcd('0x28')](handleError(_0x19efe6,null));};exports[_0x1bcd('0x73')]=function(_0x59d138,_0x2ab8b9){return db[_0x1bcd('0x1f')]['find']({'where':{'id':_0x59d138[_0x1bcd('0x2a')]['id']}})[_0x1bcd('0x18')](handleEntityNotFound(_0x2ab8b9,null))[_0x1bcd('0x18')](function(_0x169f87){if(_0x169f87){return _0x169f87['addAgents'](_0x59d138[_0x1bcd('0x36')][_0x1bcd('0x57')],_[_0x1bcd('0x74')](_0x59d138[_0x1bcd('0x36')],[_0x1bcd('0x57'),'id'])||{})[_0x1bcd('0x75')](function(_0x40dd22){for(var _0x10f98e=0x0;_0x10f98e<_0x59d138[_0x1bcd('0x36')][_0x1bcd('0x57')]['length'];_0x10f98e+=0x1){socket[_0x1bcd('0x5f')](_0x1bcd('0x60'),{'UserId':Number(_0x59d138[_0x1bcd('0x36')][_0x1bcd('0x57')][_0x10f98e]),'ChatQueueId':Number(_0x59d138[_0x1bcd('0x2a')]['id'])});}return _0x40dd22;});}})[_0x1bcd('0x18')](respondWithResult(_0x2ab8b9,null))[_0x1bcd('0x28')](handleError(_0x2ab8b9,null));};exports['removeAgents']=function(_0x51ab68,_0x1756ad){return db[_0x1bcd('0x1f')][_0x1bcd('0x34')]({'where':{'id':_0x51ab68['params']['id']}})[_0x1bcd('0x18')](handleEntityNotFound(_0x1756ad,null))[_0x1bcd('0x18')](function(_0x15e8ca){if(_0x15e8ca){return _0x15e8ca[_0x1bcd('0x70')](_0x51ab68['query']['ids'])[_0x1bcd('0x18')](function(){if(_[_0x1bcd('0x76')](_0x51ab68[_0x1bcd('0x25')]['ids'])){for(var _0x54325a=0x0;_0x54325a<_0x51ab68['query'][_0x1bcd('0x57')][_0x1bcd('0x31')];_0x54325a+=0x1){socket[_0x1bcd('0x5f')](_0x1bcd('0x72'),{'UserId':Number(_0x51ab68[_0x1bcd('0x25')][_0x1bcd('0x57')][_0x54325a]),'ChatQueueId':Number(_0x51ab68[_0x1bcd('0x2a')]['id'])});}}else{socket[_0x1bcd('0x5f')]('userChatQueue:remove',{'UserId':Number(_0x51ab68[_0x1bcd('0x25')][_0x1bcd('0x57')]),'ChatQueueId':Number(_0x51ab68[_0x1bcd('0x2a')]['id'])});}});}})[_0x1bcd('0x18')](respondWithStatusCode(_0x1756ad,null))[_0x1bcd('0x28')](handleError(_0x1756ad,null));};exports[_0x1bcd('0x77')]=function(_0x236e8f,_0x480771){var _0x538886={};var _0x400121={};var _0x18d49a;var _0x5e034b;return db[_0x1bcd('0x1f')][_0x1bcd('0x40')]({'where':{'id':_0x236e8f[_0x1bcd('0x2a')]['id']}})['then'](handleEntityNotFound(_0x480771,null))[_0x1bcd('0x18')](function(_0xe296ef){if(_0xe296ef){_0x18d49a=_0xe296ef;_0x400121['model']=_[_0x1bcd('0x2c')](db[_0x1bcd('0x49')][_0x1bcd('0x20')]);_0x400121[_0x1bcd('0x25')]=_[_0x1bcd('0x2c')](_0x236e8f['query']);_0x400121[_0x1bcd('0x2d')]=_[_0x1bcd('0x2e')](_0x400121['model'],_0x400121['query']);_0x538886['attributes']=_['intersection'](_0x400121[_0x1bcd('0x2b')],qs[_0x1bcd('0x30')](_0x236e8f[_0x1bcd('0x25')]['fields']));_0x538886['attributes']=_0x538886[_0x1bcd('0x2f')][_0x1bcd('0x31')]?_0x538886[_0x1bcd('0x2f')]:_0x400121[_0x1bcd('0x2b')];_0x538886[_0x1bcd('0x43')]=qs[_0x1bcd('0x44')](_0x236e8f[_0x1bcd('0x25')][_0x1bcd('0x44')]);_0x538886[_0x1bcd('0x23')]=qs[_0x1bcd('0x2d')](_[_0x1bcd('0x54')](_0x236e8f[_0x1bcd('0x25')],_0x400121[_0x1bcd('0x2d')]));if(_0x236e8f['query']['filter']){_0x538886[_0x1bcd('0x23')]=_[_0x1bcd('0x47')](_0x538886[_0x1bcd('0x23')],{'$or':_[_0x1bcd('0x48')](_0x538886[_0x1bcd('0x2f')],function(_0x10b43c){var _0x3c2b5e={};_0x3c2b5e[_0x10b43c]={'$like':'%'+_0x236e8f[_0x1bcd('0x25')][_0x1bcd('0x46')]+'%'};return _0x3c2b5e;})});}_0x538886=_[_0x1bcd('0x47')]({},_0x538886,_0x236e8f[_0x1bcd('0x33')]);return _0x18d49a[_0x1bcd('0x77')](_0x538886);}})[_0x1bcd('0x18')](function(_0x2f360d){if(_0x2f360d){_0x5e034b=_0x2f360d[_0x1bcd('0x31')];if(!_0x236e8f[_0x1bcd('0x25')][_0x1bcd('0x42')]('nolimit')){_0x538886[_0x1bcd('0x12')]=qs[_0x1bcd('0x12')](_0x236e8f[_0x1bcd('0x25')][_0x1bcd('0x12')]);_0x538886[_0x1bcd('0x14')]=qs[_0x1bcd('0x14')](_0x236e8f[_0x1bcd('0x25')][_0x1bcd('0x14')]);}return _0x18d49a['getAgents'](_0x538886);}})[_0x1bcd('0x18')](function(_0x267440){if(_0x267440){return _0x267440?{'count':_0x5e034b,'rows':_0x267440}:null;}})[_0x1bcd('0x18')](respondWithResult(_0x480771,null))[_0x1bcd('0x28')](handleError(_0x480771,null));};
\ No newline at end of file
+var _0x8bda=['merge','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','describe','findOne','hasOwnProperty','nolimit','sort','pick','ChatQueueId','filter','options','UserChatQueue','User','agent','chatPause','createdAt','%s/%s','SIP','updatedAt','Team','getTeams','addTeams','ids','Agents','voicePause','interface','sequelize','transaction','findOrCreate','emit','userChatQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','includes','all','union','value','isEmpty','removeAgents','forEach','addAgents','omit','spread','isArray','userChatQueue:remove','getAgents','order','lodash','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','redis','localhost','socket.io-emitter','./chatQueue.socket','register','sendStatus','status','json','undefined','count','offset','limit','set','Content-Range','then','destroy','get','ChatQueues','UserProfileResource','error','stack','name','send','map','rawAttributes','fieldName','type','key','getOptions','where','include','query','ChatQueue','findAll','rows','catch','show','params','model','keys','filters','intersection','fields','attributes','length','includeAll'];(function(_0x28d1dc,_0x5a3d14){var _0x4ebcae=function(_0x48e8ec){while(--_0x48e8ec){_0x28d1dc['push'](_0x28d1dc['shift']());}};_0x4ebcae(++_0x5a3d14);}(_0x8bda,0x1b3));var _0xa8bd=function(_0x4d8dc3,_0x585fd1){_0x4d8dc3=_0x4d8dc3-0x0;var _0x9b03d9=_0x8bda[_0x4d8dc3];return _0x9b03d9;};'use strict';var BPromise=require('bluebird');var util=require('util');var _=require(_0xa8bd('0x0'));var squel=require(_0xa8bd('0x1'));var Redis=require(_0xa8bd('0x2'));var qs=require(_0xa8bd('0x3'));var logger=require(_0xa8bd('0x4'))(_0xa8bd('0x5'));var config=require('../../config/environment');var db=require(_0xa8bd('0x6'))['db'];config[_0xa8bd('0x7')]=_['defaults'](config[_0xa8bd('0x7')],{'host':_0xa8bd('0x8'),'port':0x18eb});var socket=require(_0xa8bd('0x9'))(new Redis(config[_0xa8bd('0x7')]));require(_0xa8bd('0xa'))[_0xa8bd('0xb')](socket);function respondWithStatusCode(_0x10fc36,_0x50aa4f){_0x50aa4f=_0x50aa4f||0xcc;return function(_0x2f2e50){if(_0x2f2e50){return _0x10fc36[_0xa8bd('0xc')](_0x50aa4f);}return _0x10fc36[_0xa8bd('0xd')](_0x50aa4f)['end']();};}function respondWithResult(_0x42ba4c,_0x5d1383){_0x5d1383=_0x5d1383||0xc8;return function(_0x490585){if(_0x490585){return _0x42ba4c[_0xa8bd('0xd')](_0x5d1383)[_0xa8bd('0xe')](_0x490585);}};}function respondWithFilteredResult(_0x561655,_0x2042ea){return function(_0x35e6c9){if(_0x35e6c9){var _0x40d3ad=typeof _0x2042ea['offset']==='undefined'&&typeof _0x2042ea['limit']===_0xa8bd('0xf');var _0x2e4bef=_0x35e6c9[_0xa8bd('0x10')];var _0x231bf1=_0x40d3ad?0x0:_0x2042ea[_0xa8bd('0x11')];var _0x40ffc0=_0x40d3ad?_0x35e6c9[_0xa8bd('0x10')]:_0x2042ea['offset']+_0x2042ea[_0xa8bd('0x12')];var _0x51fa8e;if(_0x40ffc0>=_0x2e4bef){_0x40ffc0=_0x2e4bef;_0x51fa8e=0xc8;}else{_0x51fa8e=0xce;}_0x561655['status'](_0x51fa8e);return _0x561655[_0xa8bd('0x13')](_0xa8bd('0x14'),_0x231bf1+'-'+_0x40ffc0+'/'+_0x2e4bef)['json'](_0x35e6c9);}return null;};}function saveUpdates(_0x5f1622){return function(_0x4fc4d9){if(_0x4fc4d9){return _0x4fc4d9['update'](_0x5f1622)[_0xa8bd('0x15')](function(_0x5e5d70){return _0x5e5d70;});}return null;};}function removeEntity(_0x48788f){return function(_0x38b723){if(_0x38b723){return _0x38b723[_0xa8bd('0x16')]()['then'](function(){var _0x5397b2=_0x38b723[_0xa8bd('0x17')]({'plain':!![]});var _0x1729cc=_0xa8bd('0x18');return db[_0xa8bd('0x19')]['destroy']({'where':{'type':_0x1729cc,'resourceId':_0x5397b2['id']}})[_0xa8bd('0x15')](function(){return _0x38b723;});})['then'](function(){_0x48788f[_0xa8bd('0xd')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4efe59){return function(_0x50caf3){if(!_0x50caf3){_0x4efe59[_0xa8bd('0xc')](0x194);}return _0x50caf3;};}function handleError(_0x474071,_0x1596d5){_0x1596d5=_0x1596d5||0x1f4;return function(_0xaf6617){logger[_0xa8bd('0x1a')](_0xaf6617[_0xa8bd('0x1b')]);if(_0xaf6617[_0xa8bd('0x1c')]){delete _0xaf6617['name'];}_0x474071[_0xa8bd('0xd')](_0x1596d5)[_0xa8bd('0x1d')](_0xaf6617);};}exports['index']=function(_0x338bdb,_0x27020c){var _0x36fc92={};var _0x1a2968={'count':0x0,'rows':[]};var _0x287d4b=_[_0xa8bd('0x1e')](db['ChatQueue'][_0xa8bd('0x1f')],function(_0x204941){return{'name':_0x204941[_0xa8bd('0x20')],'type':_0x204941[_0xa8bd('0x21')][_0xa8bd('0x22')]};});_0x36fc92=qs[_0xa8bd('0x23')](_0x287d4b,_0x338bdb);var _0x1d513c={'where':_0x36fc92[_0xa8bd('0x24')]};return db['ChatQueue'][_0xa8bd('0x10')](_0x1d513c)['then'](function(_0x4b22eb){_0x1a2968['count']=_0x4b22eb;_0x36fc92[_0xa8bd('0x25')]=qs['include'](_0x338bdb[_0xa8bd('0x26')]);return db[_0xa8bd('0x27')][_0xa8bd('0x28')](_0x36fc92);})[_0xa8bd('0x15')](function(_0x23c5fb){_0x1a2968[_0xa8bd('0x29')]=_0x23c5fb;return _0x1a2968;})['then'](respondWithFilteredResult(_0x27020c,_0x36fc92))[_0xa8bd('0x2a')](handleError(_0x27020c,null));};exports[_0xa8bd('0x2b')]=function(_0x2024df,_0x2d2c73){var _0x141503={'raw':!![],'where':{'id':_0x2024df[_0xa8bd('0x2c')]['id']}},_0x3517de={};_0x3517de[_0xa8bd('0x2d')]=_['keys'](db['ChatQueue'][_0xa8bd('0x1f')]);_0x3517de[_0xa8bd('0x26')]=_[_0xa8bd('0x2e')](_0x2024df[_0xa8bd('0x26')]);_0x3517de[_0xa8bd('0x2f')]=_[_0xa8bd('0x30')](_0x3517de[_0xa8bd('0x2d')],_0x3517de['query']);_0x141503['attributes']=_[_0xa8bd('0x30')](_0x3517de[_0xa8bd('0x2d')],qs[_0xa8bd('0x31')](_0x2024df['query']['fields']));_0x141503[_0xa8bd('0x32')]=_0x141503['attributes'][_0xa8bd('0x33')]?_0x141503[_0xa8bd('0x32')]:_0x3517de['model'];if(_0x2024df[_0xa8bd('0x26')][_0xa8bd('0x34')]){_0x141503['include']=[{'all':!![]}];}_0x141503=_[_0xa8bd('0x35')]({},_0x141503,_0x2024df['options']);return db[_0xa8bd('0x27')]['find'](_0x141503)[_0xa8bd('0x15')](handleEntityNotFound(_0x2d2c73,null))[_0xa8bd('0x15')](respondWithResult(_0x2d2c73,null))[_0xa8bd('0x2a')](handleError(_0x2d2c73,null));};exports[_0xa8bd('0x36')]=function(_0x573b90,_0x40efa5){return db[_0xa8bd('0x27')][_0xa8bd('0x36')](_0x573b90[_0xa8bd('0x37')],{})['then'](function(_0xdfa0d){var _0x24668d=_0x573b90['user'][_0xa8bd('0x17')]({'plain':!![]});if(!_0x24668d)throw new Error(_0xa8bd('0x38'));if(_0x24668d[_0xa8bd('0x39')]===_0xa8bd('0x3a')){var _0x26c1db=_0xdfa0d[_0xa8bd('0x17')]({'plain':!![]});var _0x2e4c01=_0xa8bd('0x18');return db['UserProfileSection']['find']({'where':{'name':_0x2e4c01,'userProfileId':_0x24668d['userProfileId']},'raw':!![]})[_0xa8bd('0x15')](function(_0x325190){if(_0x325190&&_0x325190[_0xa8bd('0x3b')]===0x0){return db['UserProfileResource']['create']({'name':_0x26c1db[_0xa8bd('0x1c')],'resourceId':_0x26c1db['id'],'type':_0x325190['name'],'sectionId':_0x325190['id']},{})[_0xa8bd('0x15')](function(){return _0xdfa0d;});}else{return _0xdfa0d;}})['catch'](function(_0xaf9c88){logger['error'](_0xa8bd('0x3c'),_0xaf9c88);throw _0xaf9c88;});}return _0xdfa0d;})['then'](respondWithResult(_0x40efa5,0xc9))[_0xa8bd('0x2a')](handleError(_0x40efa5,null));};exports['update']=function(_0x4373dd,_0x1941ae){if(_0x4373dd[_0xa8bd('0x37')]['id']){delete _0x4373dd['body']['id'];}return db[_0xa8bd('0x27')][_0xa8bd('0x3d')]({'where':{'id':_0x4373dd[_0xa8bd('0x2c')]['id']}})[_0xa8bd('0x15')](handleEntityNotFound(_0x1941ae,null))[_0xa8bd('0x15')](saveUpdates(_0x4373dd['body'],null))['then'](respondWithResult(_0x1941ae,null))[_0xa8bd('0x2a')](handleError(_0x1941ae,null));};exports[_0xa8bd('0x16')]=function(_0x1added,_0x2b2a62){return db[_0xa8bd('0x27')][_0xa8bd('0x3d')]({'where':{'id':_0x1added[_0xa8bd('0x2c')]['id']}})[_0xa8bd('0x15')](handleEntityNotFound(_0x2b2a62,null))[_0xa8bd('0x15')](removeEntity(_0x2b2a62,null))['catch'](handleError(_0x2b2a62,null));};exports[_0xa8bd('0x3e')]=function(_0x562397,_0x2a29cb){return db['ChatQueue']['describe']()[_0xa8bd('0x15')](respondWithResult(_0x2a29cb,null))[_0xa8bd('0x2a')](handleError(_0x2a29cb,null));};exports['getMembers']=function(_0x121b73,_0x51bb01){var _0x4c50b0={'raw':!![],'where':{}},_0x5e3f59={},_0x5f12f8;return db[_0xa8bd('0x27')][_0xa8bd('0x3f')]({'where':{'id':_0x121b73[_0xa8bd('0x2c')]['id']}})[_0xa8bd('0x15')](handleEntityNotFound(_0x51bb01,null))[_0xa8bd('0x15')](function(_0x5d8fcb){if(_0x5d8fcb){_0x5f12f8=_0x5d8fcb[_0xa8bd('0x17')]({'plain':!![]});_0x5e3f59[_0xa8bd('0x2d')]=_[_0xa8bd('0x2e')](db['UserChatQueue'][_0xa8bd('0x1f')]);_0x5e3f59[_0xa8bd('0x26')]=_[_0xa8bd('0x2e')](_0x121b73[_0xa8bd('0x26')]);_0x5e3f59[_0xa8bd('0x2f')]=_[_0xa8bd('0x30')](_0x5e3f59['model'],_0x5e3f59[_0xa8bd('0x26')]);_0x4c50b0[_0xa8bd('0x32')]=_['intersection'](_0x5e3f59[_0xa8bd('0x2d')],qs[_0xa8bd('0x31')](_0x121b73[_0xa8bd('0x26')][_0xa8bd('0x31')]));_0x4c50b0['attributes']=_0x4c50b0[_0xa8bd('0x32')][_0xa8bd('0x33')]?_0x4c50b0[_0xa8bd('0x32')]:_0x5e3f59[_0xa8bd('0x2d')];if(!_0x121b73[_0xa8bd('0x26')][_0xa8bd('0x40')](_0xa8bd('0x41'))){_0x4c50b0['limit']=qs[_0xa8bd('0x12')](_0x121b73['query'][_0xa8bd('0x12')]);_0x4c50b0[_0xa8bd('0x11')]=qs[_0xa8bd('0x11')](_0x121b73['query'][_0xa8bd('0x11')]);}_0x4c50b0['order']=qs[_0xa8bd('0x42')](_0x121b73['query'][_0xa8bd('0x42')]);_0x4c50b0[_0xa8bd('0x24')]=qs['filters'](_[_0xa8bd('0x43')](_0x121b73[_0xa8bd('0x26')],_0x5e3f59['filters']));_0x4c50b0[_0xa8bd('0x24')][_0xa8bd('0x44')]=_0x5d8fcb['id'];if(_0x121b73['query']['filter']){_0x4c50b0[_0xa8bd('0x24')]=_[_0xa8bd('0x35')](_0x4c50b0[_0xa8bd('0x24')],{'$or':_['map'](_0x4c50b0[_0xa8bd('0x32')],function(_0x25b3d5){var _0xc81d3f={};_0xc81d3f[_0x25b3d5]={'$like':'%'+_0x121b73['query'][_0xa8bd('0x45')]+'%'};return _0xc81d3f;})});}_0x4c50b0=_['merge']({},_0x4c50b0,_0x121b73[_0xa8bd('0x46')]);return db[_0xa8bd('0x47')][_0xa8bd('0x28')](_0x4c50b0);}})['then'](function(_0x560da6){if(_0x560da6){return db[_0xa8bd('0x48')]['findAndCountAll']({'where':{'id':_[_0xa8bd('0x1e')](_0x560da6,'UserId'),'role':_0xa8bd('0x49')},'attributes':['id','name',_0xa8bd('0x4a'),'updatedAt',_0xa8bd('0x4b')]});}})[_0xa8bd('0x15')](function(_0x2b7fcc){if(_0x2b7fcc){return{'count':_0x2b7fcc[_0xa8bd('0x10')],'rows':_['map'](_0x2b7fcc[_0xa8bd('0x29')],function(_0x27c1cc){return{'membername':_0x27c1cc[_0xa8bd('0x1c')],'UserId':_0x27c1cc['id'],'queue_name':_0x5f12f8[_0xa8bd('0x1c')],'ChatQueueId':_0x5f12f8['id'],'interface':util['format'](_0xa8bd('0x4c'),_0xa8bd('0x4d'),_0x27c1cc[_0xa8bd('0x1c')]),'penalty':0x0,'paused':_0x27c1cc[_0xa8bd('0x4a')],'createdAt':_0x27c1cc[_0xa8bd('0x4b')],'updatedAt':_0x27c1cc[_0xa8bd('0x4e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xa8bd('0x15')](respondWithFilteredResult(_0x51bb01,_0x4c50b0))[_0xa8bd('0x2a')](handleError(_0x51bb01,null));};exports['getTeams']=function(_0x960221,_0xce52c1){var _0x1fadbb={};var _0x53a0f1={};var _0x3804ad;var _0x6cab95;return db[_0xa8bd('0x27')]['findOne']({'where':{'id':_0x960221['params']['id']}})[_0xa8bd('0x15')](handleEntityNotFound(_0xce52c1,null))[_0xa8bd('0x15')](function(_0x19b207){if(_0x19b207){_0x3804ad=_0x19b207;_0x53a0f1[_0xa8bd('0x2d')]=_['keys'](db[_0xa8bd('0x4f')][_0xa8bd('0x1f')]);_0x53a0f1[_0xa8bd('0x26')]=_[_0xa8bd('0x2e')](_0x960221[_0xa8bd('0x26')]);_0x53a0f1['filters']=_['intersection'](_0x53a0f1[_0xa8bd('0x2d')],_0x53a0f1['query']);_0x1fadbb[_0xa8bd('0x32')]=_[_0xa8bd('0x30')](_0x53a0f1[_0xa8bd('0x2d')],qs[_0xa8bd('0x31')](_0x960221[_0xa8bd('0x26')]['fields']));_0x1fadbb[_0xa8bd('0x32')]=_0x1fadbb['attributes'][_0xa8bd('0x33')]?_0x1fadbb[_0xa8bd('0x32')]:_0x53a0f1[_0xa8bd('0x2d')];_0x1fadbb['order']=qs['sort'](_0x960221[_0xa8bd('0x26')]['sort']);_0x1fadbb[_0xa8bd('0x24')]=qs['filters'](_[_0xa8bd('0x43')](_0x960221['query'],_0x53a0f1[_0xa8bd('0x2f')]));if(_0x960221['query'][_0xa8bd('0x45')]){_0x1fadbb[_0xa8bd('0x24')]=_['merge'](_0x1fadbb[_0xa8bd('0x24')],{'$or':_['map'](_0x1fadbb['attributes'],function(_0x474881){var _0x5cad5d={};_0x5cad5d[_0x474881]={'$like':'%'+_0x960221[_0xa8bd('0x26')][_0xa8bd('0x45')]+'%'};return _0x5cad5d;})});}_0x1fadbb=_[_0xa8bd('0x35')]({},_0x1fadbb,_0x960221['options']);return _0x3804ad[_0xa8bd('0x50')](_0x1fadbb);}})[_0xa8bd('0x15')](function(_0x2c30a4){if(_0x2c30a4){_0x6cab95=_0x2c30a4[_0xa8bd('0x33')];if(!_0x960221[_0xa8bd('0x26')][_0xa8bd('0x40')]('nolimit')){_0x1fadbb[_0xa8bd('0x12')]=qs[_0xa8bd('0x12')](_0x960221['query']['limit']);_0x1fadbb[_0xa8bd('0x11')]=qs['offset'](_0x960221['query']['offset']);}return _0x3804ad['getTeams'](_0x1fadbb);}})[_0xa8bd('0x15')](function(_0x4b80ad){if(_0x4b80ad){return _0x4b80ad?{'count':_0x6cab95,'rows':_0x4b80ad}:null;}})[_0xa8bd('0x15')](respondWithResult(_0xce52c1,null))['catch'](handleError(_0xce52c1,null));};exports[_0xa8bd('0x51')]=function(_0x1bb5cf,_0x413d90){var _0x380577=_0x1bb5cf[_0xa8bd('0x37')][_0xa8bd('0x52')];return db[_0xa8bd('0x4f')][_0xa8bd('0x28')]({'where':{'id':_0x380577},'attributes':['id'],'include':[{'model':db['User'],'as':_0xa8bd('0x53'),'attributes':['id','name','online',_0xa8bd('0x54'),_0xa8bd('0x55')],'raw':!![]}]})['then'](function(_0x1096d8){if(_0x1096d8){var _0x22b14e=_['flatMap'](_0x1096d8,function(_0xf6bc15){var _0x83ac75=_0xf6bc15[_0xa8bd('0x17')]({'plain':!![]});return _0x83ac75['Agents'];});return db[_0xa8bd('0x27')][_0xa8bd('0x3d')]({'where':{'id':_0x1bb5cf['params']['id']}})[_0xa8bd('0x15')](function(_0x4eb2eb){return db[_0xa8bd('0x56')][_0xa8bd('0x57')](function(_0x397c47){return _0x4eb2eb[_0xa8bd('0x51')](_0x380577,{'transaction':_0x397c47})['then'](function(){return BPromise['each'](_0x22b14e,function(_0x16ad7d){return db[_0xa8bd('0x47')][_0xa8bd('0x58')]({'where':{'UserId':_0x16ad7d['id'],'ChatQueueId':_0x1bb5cf[_0xa8bd('0x2c')]['id']},'transaction':_0x397c47});});})[_0xa8bd('0x15')](function(){_0x22b14e['forEach'](function(_0x246f34){socket[_0xa8bd('0x59')](_0xa8bd('0x5a'),{'UserId':_0x246f34['id'],'ChatQueueId':_0x4eb2eb['id']});});});});});}})['then'](respondWithStatusCode(_0x413d90,null))[_0xa8bd('0x2a')](handleError(_0x413d90,null));};exports[_0xa8bd('0x5b')]=function(_0x110cd2,_0x714565){return db['Team'][_0xa8bd('0x28')]({'where':{'id':_0x110cd2[_0xa8bd('0x26')]['ids']},'attributes':['id'],'include':[{'model':db[_0xa8bd('0x48')],'as':_0xa8bd('0x53'),'attributes':['id'],'raw':!![]}]})[_0xa8bd('0x15')](handleEntityNotFound(_0x714565,null))[_0xa8bd('0x15')](function(_0x505d3b){var _0x1a76af=_[_0xa8bd('0x1e')](_0x505d3b,'id');var _0x4c9b6a=[];var _0x4c3a47=[];var _0x25d837=squel[_0xa8bd('0x5c')]();_0x25d837[_0xa8bd('0x5d')](_0xa8bd('0x5e'))[_0xa8bd('0x5f')](_0xa8bd('0x60'),'tq')[_0xa8bd('0x61')](_0xa8bd('0x62'),'ut',_0xa8bd('0x63'))[_0xa8bd('0x24')](_0xa8bd('0x64'),_0x110cd2[_0xa8bd('0x2c')]['id']);for(var _0x203a00=0x0;_0x203a00<_0x505d3b['length'];_0x203a00+=0x1){let _0x3777dc=_0x505d3b[_0x203a00];for(var _0xc76191=0x0;_0xc76191<_0x3777dc['Agents'][_0xa8bd('0x33')];_0xc76191+=0x1){let _0x364927=_0x3777dc[_0xa8bd('0x53')][_0xc76191];var _0x44195a=_0x25d837[_0xa8bd('0x65')]();_0x44195a['where'](_0xa8bd('0x66'),_0x364927['id']);_0x4c3a47[_0xa8bd('0x67')](db[_0xa8bd('0x56')][_0xa8bd('0x26')](_0x44195a[_0xa8bd('0x68')](),{'type':db[_0xa8bd('0x56')][_0xa8bd('0x69')][_0xa8bd('0x6a')]})[_0xa8bd('0x15')](function(_0x1ab6e5){if(_0x1ab6e5['length']===0x1){return _0x364927['id'];}else{var _0x11b83e=_[_0xa8bd('0x6b')](_['map'](_0x1ab6e5,'TeamId'),function(_0x42e38b){return _[_0xa8bd('0x6c')](_0x1a76af,_0x42e38b);});if(_0x11b83e){return _0x364927['id'];}}}));}}return BPromise[_0xa8bd('0x6d')](_0x4c3a47)[_0xa8bd('0x15')](function(_0x25b5ad){_0x4c9b6a=_(_0x4c9b6a)[_0xa8bd('0x6e')](_0x25b5ad)['compact']()[_0xa8bd('0x6f')]();return db[_0xa8bd('0x27')][_0xa8bd('0x3d')]({'where':{'id':_0x110cd2['params']['id']}})['then'](function(_0x3fbf5e){return db[_0xa8bd('0x56')][_0xa8bd('0x57')](function(_0x42eeb9){return _0x3fbf5e[_0xa8bd('0x5b')](_0x110cd2['query'][_0xa8bd('0x52')],{'transaction':_0x42eeb9})[_0xa8bd('0x15')](function(){if(!_[_0xa8bd('0x70')](_0x4c9b6a)){return _0x3fbf5e[_0xa8bd('0x71')](_0x4c9b6a,{'transaction':_0x42eeb9});}})['then'](function(){_0x4c9b6a[_0xa8bd('0x72')](function(_0x127436){socket[_0xa8bd('0x59')]('userChatQueue:remove',{'UserId':_0x127436,'ChatQueueId':_0x3fbf5e['id']});});});});});});})[_0xa8bd('0x15')](respondWithStatusCode(_0x714565,null))['catch'](handleError(_0x714565,null));};exports[_0xa8bd('0x73')]=function(_0x4a85c8,_0x276270){return db['ChatQueue'][_0xa8bd('0x3d')]({'where':{'id':_0x4a85c8[_0xa8bd('0x2c')]['id']}})[_0xa8bd('0x15')](handleEntityNotFound(_0x276270,null))[_0xa8bd('0x15')](function(_0x10e116){if(_0x10e116){return _0x10e116['addAgents'](_0x4a85c8[_0xa8bd('0x37')]['ids'],_[_0xa8bd('0x74')](_0x4a85c8[_0xa8bd('0x37')],[_0xa8bd('0x52'),'id'])||{})[_0xa8bd('0x75')](function(_0x3b87d9){for(var _0x31601d=0x0;_0x31601d<_0x4a85c8['body'][_0xa8bd('0x52')]['length'];_0x31601d+=0x1){socket[_0xa8bd('0x59')](_0xa8bd('0x5a'),{'UserId':Number(_0x4a85c8[_0xa8bd('0x37')][_0xa8bd('0x52')][_0x31601d]),'ChatQueueId':Number(_0x4a85c8[_0xa8bd('0x2c')]['id'])});}return _0x3b87d9;});}})[_0xa8bd('0x15')](respondWithResult(_0x276270,null))[_0xa8bd('0x2a')](handleError(_0x276270,null));};exports[_0xa8bd('0x71')]=function(_0x438226,_0x5b971b){return db[_0xa8bd('0x27')][_0xa8bd('0x3d')]({'where':{'id':_0x438226[_0xa8bd('0x2c')]['id']}})[_0xa8bd('0x15')](handleEntityNotFound(_0x5b971b,null))[_0xa8bd('0x15')](function(_0x7a720c){if(_0x7a720c){return _0x7a720c['removeAgents'](_0x438226[_0xa8bd('0x26')]['ids'])[_0xa8bd('0x15')](function(){if(_[_0xa8bd('0x76')](_0x438226[_0xa8bd('0x26')][_0xa8bd('0x52')])){for(var _0x36948d=0x0;_0x36948d<_0x438226['query'][_0xa8bd('0x52')][_0xa8bd('0x33')];_0x36948d+=0x1){socket[_0xa8bd('0x59')](_0xa8bd('0x77'),{'UserId':Number(_0x438226[_0xa8bd('0x26')][_0xa8bd('0x52')][_0x36948d]),'ChatQueueId':Number(_0x438226['params']['id'])});}}else{socket['emit']('userChatQueue:remove',{'UserId':Number(_0x438226['query'][_0xa8bd('0x52')]),'ChatQueueId':Number(_0x438226[_0xa8bd('0x2c')]['id'])});}});}})['then'](respondWithStatusCode(_0x5b971b,null))['catch'](handleError(_0x5b971b,null));};exports[_0xa8bd('0x78')]=function(_0x34161d,_0x5ce157){var _0x532a9c={};var _0x20c2b8={};var _0x51a8ef;var _0x12e446;return db['ChatQueue'][_0xa8bd('0x3f')]({'where':{'id':_0x34161d[_0xa8bd('0x2c')]['id']}})[_0xa8bd('0x15')](handleEntityNotFound(_0x5ce157,null))[_0xa8bd('0x15')](function(_0x431b2a){if(_0x431b2a){_0x51a8ef=_0x431b2a;_0x20c2b8[_0xa8bd('0x2d')]=_['keys'](db[_0xa8bd('0x48')][_0xa8bd('0x1f')]);_0x20c2b8[_0xa8bd('0x26')]=_[_0xa8bd('0x2e')](_0x34161d[_0xa8bd('0x26')]);_0x20c2b8[_0xa8bd('0x2f')]=_[_0xa8bd('0x30')](_0x20c2b8[_0xa8bd('0x2d')],_0x20c2b8[_0xa8bd('0x26')]);_0x532a9c[_0xa8bd('0x32')]=_[_0xa8bd('0x30')](_0x20c2b8[_0xa8bd('0x2d')],qs[_0xa8bd('0x31')](_0x34161d[_0xa8bd('0x26')][_0xa8bd('0x31')]));_0x532a9c[_0xa8bd('0x32')]=_0x532a9c[_0xa8bd('0x32')][_0xa8bd('0x33')]?_0x532a9c[_0xa8bd('0x32')]:_0x20c2b8[_0xa8bd('0x2d')];_0x532a9c[_0xa8bd('0x79')]=qs[_0xa8bd('0x42')](_0x34161d[_0xa8bd('0x26')][_0xa8bd('0x42')]);_0x532a9c[_0xa8bd('0x24')]=qs[_0xa8bd('0x2f')](_[_0xa8bd('0x43')](_0x34161d[_0xa8bd('0x26')],_0x20c2b8['filters']));if(_0x34161d[_0xa8bd('0x26')][_0xa8bd('0x45')]){_0x532a9c['where']=_['merge'](_0x532a9c[_0xa8bd('0x24')],{'$or':_[_0xa8bd('0x1e')](_0x532a9c[_0xa8bd('0x32')],function(_0x49cd57){var _0x28bee2={};_0x28bee2[_0x49cd57]={'$like':'%'+_0x34161d['query'][_0xa8bd('0x45')]+'%'};return _0x28bee2;})});}_0x532a9c=_['merge']({},_0x532a9c,_0x34161d['options']);return _0x51a8ef[_0xa8bd('0x78')](_0x532a9c);}})[_0xa8bd('0x15')](function(_0x8b0457){if(_0x8b0457){_0x12e446=_0x8b0457[_0xa8bd('0x33')];if(!_0x34161d[_0xa8bd('0x26')][_0xa8bd('0x40')](_0xa8bd('0x41'))){_0x532a9c[_0xa8bd('0x12')]=qs[_0xa8bd('0x12')](_0x34161d['query'][_0xa8bd('0x12')]);_0x532a9c[_0xa8bd('0x11')]=qs[_0xa8bd('0x11')](_0x34161d[_0xa8bd('0x26')]['offset']);}return _0x51a8ef[_0xa8bd('0x78')](_0x532a9c);}})['then'](function(_0x437741){if(_0x437741){return _0x437741?{'count':_0x12e446,'rows':_0x437741}:null;}})['then'](respondWithResult(_0x5ce157,null))[_0xa8bd('0x2a')](handleError(_0x5ce157,null));};
\ No newline at end of file