Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 95ab76f..2477b0c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2621=['UserChatQueue','findAll','User','findAndCountAll','UserId','agent','chatPause','updatedAt','createdAt','format','SIP','getTeams','Team','pick','nolimit','addTeams','ids','Agents','online','voicePause','interface','flatMap','transaction','each','forEach','emit','userChatQueue:save','removeTeams','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','sequelize','toString','QueryTypes','every','TeamId','all','union','compact','value','removeAgents','addAgents','omit','spread','isArray','userChatQueue:remove','getAgents','bluebird','util','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./chatQueue.socket','register','sendStatus','status','end','undefined','limit','offset','count','set','Content-Range','json','update','then','destroy','get','ChatQueues','UserProfileResource','stack','name','send','index','map','rawAttributes','fieldName','getOptions','where','ChatQueue','include','query','rows','catch','show','params','model','keys','filters','intersection','fields','attributes','length','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','hasOwnProperty','order','sort','ChatQueueId','filter','merge','options'];(function(_0xbec196,_0x1e46a6){var _0x10972b=function(_0x4da5f5){while(--_0x4da5f5){_0xbec196['push'](_0xbec196['shift']());}};_0x10972b(++_0x1e46a6);}(_0x2621,0x1ae));var _0x1262=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x2621[_0x14add3];return _0x4a174f;};'use strict';var BPromise=require(_0x1262('0x0'));var util=require(_0x1262('0x1'));var _=require(_0x1262('0x2'));var squel=require('squel');var Redis=require(_0x1262('0x3'));var qs=require(_0x1262('0x4'));var logger=require(_0x1262('0x5'))(_0x1262('0x6'));var config=require(_0x1262('0x7'));var db=require(_0x1262('0x8'))['db'];config['redis']=_[_0x1262('0x9')](config[_0x1262('0xa')],{'host':_0x1262('0xb'),'port':0x18eb});var socket=require(_0x1262('0xc'))(new Redis(config[_0x1262('0xa')]));require(_0x1262('0xd'))[_0x1262('0xe')](socket);function respondWithStatusCode(_0x22a42c,_0x11dbc7){_0x11dbc7=_0x11dbc7||0xcc;return function(_0x5d94e1){if(_0x5d94e1){return _0x22a42c[_0x1262('0xf')](_0x11dbc7);}return _0x22a42c[_0x1262('0x10')](_0x11dbc7)[_0x1262('0x11')]();};}function respondWithResult(_0x42fa86,_0x2c5bb){_0x2c5bb=_0x2c5bb||0xc8;return function(_0x2b461e){if(_0x2b461e){return _0x42fa86[_0x1262('0x10')](_0x2c5bb)['json'](_0x2b461e);}};}function respondWithFilteredResult(_0x527a0b,_0xabf2f2){return function(_0x3658ba){if(_0x3658ba){var _0x346da9=typeof _0xabf2f2['offset']===_0x1262('0x12')&&typeof _0xabf2f2[_0x1262('0x13')]===_0x1262('0x12');var _0x464da8=_0x3658ba['count'];var _0x37df81=_0x346da9?0x0:_0xabf2f2[_0x1262('0x14')];var _0x25303d=_0x346da9?_0x3658ba[_0x1262('0x15')]:_0xabf2f2[_0x1262('0x14')]+_0xabf2f2['limit'];var _0x1ddea8;if(_0x25303d>=_0x464da8){_0x25303d=_0x464da8;_0x1ddea8=0xc8;}else{_0x1ddea8=0xce;}_0x527a0b['status'](_0x1ddea8);return _0x527a0b[_0x1262('0x16')](_0x1262('0x17'),_0x37df81+'-'+_0x25303d+'/'+_0x464da8)[_0x1262('0x18')](_0x3658ba);}return null;};}function saveUpdates(_0x58ecfe){return function(_0x40aa28){if(_0x40aa28){return _0x40aa28[_0x1262('0x19')](_0x58ecfe)[_0x1262('0x1a')](function(_0x552de1){return _0x552de1;});}return null;};}function removeEntity(_0x456016){return function(_0x237364){if(_0x237364){return _0x237364[_0x1262('0x1b')]()[_0x1262('0x1a')](function(){var _0x165514=_0x237364[_0x1262('0x1c')]({'plain':!![]});var _0x501710=_0x1262('0x1d');return db[_0x1262('0x1e')][_0x1262('0x1b')]({'where':{'type':_0x501710,'resourceId':_0x165514['id']}})['then'](function(){return _0x237364;});})['then'](function(){_0x456016[_0x1262('0x10')](0xcc)[_0x1262('0x11')]();});}};}function handleEntityNotFound(_0x3416dc){return function(_0x35ea8f){if(!_0x35ea8f){_0x3416dc['sendStatus'](0x194);}return _0x35ea8f;};}function handleError(_0x3a6c0f,_0x5aa7b){_0x5aa7b=_0x5aa7b||0x1f4;return function(_0x3e36b2){logger['error'](_0x3e36b2[_0x1262('0x1f')]);if(_0x3e36b2[_0x1262('0x20')]){delete _0x3e36b2[_0x1262('0x20')];}_0x3a6c0f[_0x1262('0x10')](_0x5aa7b)[_0x1262('0x21')](_0x3e36b2);};}exports[_0x1262('0x22')]=function(_0x1cd854,_0x5323b5){var _0x17e1bb={};var _0x1d9663={'count':0x0,'rows':[]};var _0xfa6d05=_[_0x1262('0x23')](db['ChatQueue'][_0x1262('0x24')],function(_0x2d0f55){return{'name':_0x2d0f55[_0x1262('0x25')],'type':_0x2d0f55['type']['key']};});_0x17e1bb=qs[_0x1262('0x26')](_0xfa6d05,_0x1cd854);var _0x5827cd={'where':_0x17e1bb[_0x1262('0x27')]};return db[_0x1262('0x28')][_0x1262('0x15')](_0x5827cd)[_0x1262('0x1a')](function(_0x1547a5){_0x1d9663[_0x1262('0x15')]=_0x1547a5;_0x17e1bb[_0x1262('0x29')]=qs[_0x1262('0x29')](_0x1cd854[_0x1262('0x2a')]);return db[_0x1262('0x28')]['findAll'](_0x17e1bb);})['then'](function(_0xe4191e){_0x1d9663[_0x1262('0x2b')]=_0xe4191e;return _0x1d9663;})[_0x1262('0x1a')](respondWithFilteredResult(_0x5323b5,_0x17e1bb))[_0x1262('0x2c')](handleError(_0x5323b5,null));};exports[_0x1262('0x2d')]=function(_0x22d240,_0x5aee9c){var _0x30d359={'raw':!![],'where':{'id':_0x22d240[_0x1262('0x2e')]['id']}},_0x22bc32={};_0x22bc32[_0x1262('0x2f')]=_[_0x1262('0x30')](db['ChatQueue'][_0x1262('0x24')]);_0x22bc32[_0x1262('0x2a')]=_[_0x1262('0x30')](_0x22d240[_0x1262('0x2a')]);_0x22bc32[_0x1262('0x31')]=_[_0x1262('0x32')](_0x22bc32[_0x1262('0x2f')],_0x22bc32[_0x1262('0x2a')]);_0x30d359['attributes']=_['intersection'](_0x22bc32[_0x1262('0x2f')],qs[_0x1262('0x33')](_0x22d240[_0x1262('0x2a')][_0x1262('0x33')]));_0x30d359[_0x1262('0x34')]=_0x30d359[_0x1262('0x34')][_0x1262('0x35')]?_0x30d359['attributes']:_0x22bc32['model'];if(_0x22d240[_0x1262('0x2a')][_0x1262('0x36')]){_0x30d359[_0x1262('0x29')]=[{'all':!![]}];}_0x30d359=_['merge']({},_0x30d359,_0x22d240['options']);return db[_0x1262('0x28')][_0x1262('0x37')](_0x30d359)[_0x1262('0x1a')](handleEntityNotFound(_0x5aee9c,null))[_0x1262('0x1a')](respondWithResult(_0x5aee9c,null))['catch'](handleError(_0x5aee9c,null));};exports[_0x1262('0x38')]=function(_0x47e35b,_0x104cb3){return db[_0x1262('0x28')][_0x1262('0x38')](_0x47e35b[_0x1262('0x39')],{})[_0x1262('0x1a')](function(_0x17323c){var _0x11da5e=_0x47e35b[_0x1262('0x3a')]['get']({'plain':!![]});if(!_0x11da5e)throw new Error(_0x1262('0x3b'));if(_0x11da5e['role']===_0x1262('0x3a')){var _0x20edd7=_0x17323c[_0x1262('0x1c')]({'plain':!![]});var _0xd61cf='ChatQueues';return db[_0x1262('0x3c')]['find']({'where':{'name':_0xd61cf,'userProfileId':_0x11da5e[_0x1262('0x3d')]},'raw':!![]})[_0x1262('0x1a')](function(_0x1d8a6c){if(_0x1d8a6c&&_0x1d8a6c['autoAssociation']===0x0){return db[_0x1262('0x1e')][_0x1262('0x38')]({'name':_0x20edd7[_0x1262('0x20')],'resourceId':_0x20edd7['id'],'type':_0x1d8a6c[_0x1262('0x20')],'sectionId':_0x1d8a6c['id']},{})[_0x1262('0x1a')](function(){return _0x17323c;});}else{return _0x17323c;}})[_0x1262('0x2c')](function(_0x4dd62a){logger[_0x1262('0x3e')](_0x1262('0x3f'),_0x4dd62a);throw _0x4dd62a;});}return _0x17323c;})[_0x1262('0x1a')](respondWithResult(_0x104cb3,0xc9))[_0x1262('0x2c')](handleError(_0x104cb3,null));};exports[_0x1262('0x19')]=function(_0x414739,_0xe7f9f4){if(_0x414739[_0x1262('0x39')]['id']){delete _0x414739['body']['id'];}return db[_0x1262('0x28')][_0x1262('0x37')]({'where':{'id':_0x414739[_0x1262('0x2e')]['id']}})['then'](handleEntityNotFound(_0xe7f9f4,null))[_0x1262('0x1a')](saveUpdates(_0x414739[_0x1262('0x39')],null))[_0x1262('0x1a')](respondWithResult(_0xe7f9f4,null))[_0x1262('0x2c')](handleError(_0xe7f9f4,null));};exports[_0x1262('0x1b')]=function(_0x5c20c0,_0xfe19e4){return db[_0x1262('0x28')][_0x1262('0x37')]({'where':{'id':_0x5c20c0[_0x1262('0x2e')]['id']}})[_0x1262('0x1a')](handleEntityNotFound(_0xfe19e4,null))[_0x1262('0x1a')](removeEntity(_0xfe19e4,null))[_0x1262('0x2c')](handleError(_0xfe19e4,null));};exports[_0x1262('0x40')]=function(_0x564c13,_0xde2a6c){return db[_0x1262('0x28')][_0x1262('0x40')]()['then'](respondWithResult(_0xde2a6c,null))[_0x1262('0x2c')](handleError(_0xde2a6c,null));};exports[_0x1262('0x41')]=function(_0x5a647f,_0x1a6b88){var _0xa832bc={'raw':!![],'where':{}},_0x5d0be3={},_0x3f0f25;return db[_0x1262('0x28')][_0x1262('0x42')]({'where':{'id':_0x5a647f[_0x1262('0x2e')]['id']}})[_0x1262('0x1a')](handleEntityNotFound(_0x1a6b88,null))[_0x1262('0x1a')](function(_0x5afcbc){if(_0x5afcbc){_0x3f0f25=_0x5afcbc[_0x1262('0x1c')]({'plain':!![]});_0x5d0be3[_0x1262('0x2f')]=_[_0x1262('0x30')](db['UserChatQueue'][_0x1262('0x24')]);_0x5d0be3[_0x1262('0x2a')]=_[_0x1262('0x30')](_0x5a647f['query']);_0x5d0be3[_0x1262('0x31')]=_[_0x1262('0x32')](_0x5d0be3[_0x1262('0x2f')],_0x5d0be3[_0x1262('0x2a')]);_0xa832bc['attributes']=_[_0x1262('0x32')](_0x5d0be3[_0x1262('0x2f')],qs['fields'](_0x5a647f[_0x1262('0x2a')]['fields']));_0xa832bc['attributes']=_0xa832bc['attributes'][_0x1262('0x35')]?_0xa832bc[_0x1262('0x34')]:_0x5d0be3[_0x1262('0x2f')];if(!_0x5a647f[_0x1262('0x2a')][_0x1262('0x43')]('nolimit')){_0xa832bc[_0x1262('0x13')]=qs[_0x1262('0x13')](_0x5a647f['query'][_0x1262('0x13')]);_0xa832bc[_0x1262('0x14')]=qs[_0x1262('0x14')](_0x5a647f['query'][_0x1262('0x14')]);}_0xa832bc[_0x1262('0x44')]=qs[_0x1262('0x45')](_0x5a647f[_0x1262('0x2a')][_0x1262('0x45')]);_0xa832bc[_0x1262('0x27')]=qs[_0x1262('0x31')](_['pick'](_0x5a647f[_0x1262('0x2a')],_0x5d0be3[_0x1262('0x31')]));_0xa832bc[_0x1262('0x27')][_0x1262('0x46')]=_0x5afcbc['id'];if(_0x5a647f[_0x1262('0x2a')][_0x1262('0x47')]){_0xa832bc[_0x1262('0x27')]=_['merge'](_0xa832bc[_0x1262('0x27')],{'$or':_[_0x1262('0x23')](_0xa832bc[_0x1262('0x34')],function(_0x32e6db){var _0x2f5c9f={};_0x2f5c9f[_0x32e6db]={'$like':'%'+_0x5a647f[_0x1262('0x2a')]['filter']+'%'};return _0x2f5c9f;})});}_0xa832bc=_[_0x1262('0x48')]({},_0xa832bc,_0x5a647f[_0x1262('0x49')]);return db[_0x1262('0x4a')][_0x1262('0x4b')](_0xa832bc);}})[_0x1262('0x1a')](function(_0x42611d){if(_0x42611d){return db[_0x1262('0x4c')][_0x1262('0x4d')]({'where':{'id':_[_0x1262('0x23')](_0x42611d,_0x1262('0x4e')),'role':_0x1262('0x4f')},'attributes':['id','name',_0x1262('0x50'),_0x1262('0x51'),_0x1262('0x52')]});}})[_0x1262('0x1a')](function(_0x4f6c9c){if(_0x4f6c9c){return{'count':_0x4f6c9c['count'],'rows':_[_0x1262('0x23')](_0x4f6c9c[_0x1262('0x2b')],function(_0x3c03d9){return{'membername':_0x3c03d9[_0x1262('0x20')],'UserId':_0x3c03d9['id'],'queue_name':_0x3f0f25[_0x1262('0x20')],'ChatQueueId':_0x3f0f25['id'],'interface':util[_0x1262('0x53')]('%s/%s',_0x1262('0x54'),_0x3c03d9[_0x1262('0x20')]),'penalty':0x0,'paused':_0x3c03d9[_0x1262('0x50')],'createdAt':_0x3c03d9[_0x1262('0x52')],'updatedAt':_0x3c03d9['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x1262('0x1a')](respondWithFilteredResult(_0x1a6b88,_0xa832bc))['catch'](handleError(_0x1a6b88,null));};exports[_0x1262('0x55')]=function(_0x3843e2,_0x5bdc87){var _0x40bd54={};var _0x825a42={};var _0x320490;var _0x5607f1;return db['ChatQueue'][_0x1262('0x42')]({'where':{'id':_0x3843e2['params']['id']}})['then'](handleEntityNotFound(_0x5bdc87,null))[_0x1262('0x1a')](function(_0x1733e6){if(_0x1733e6){_0x320490=_0x1733e6;_0x825a42[_0x1262('0x2f')]=_[_0x1262('0x30')](db[_0x1262('0x56')][_0x1262('0x24')]);_0x825a42[_0x1262('0x2a')]=_[_0x1262('0x30')](_0x3843e2[_0x1262('0x2a')]);_0x825a42[_0x1262('0x31')]=_[_0x1262('0x32')](_0x825a42[_0x1262('0x2f')],_0x825a42['query']);_0x40bd54[_0x1262('0x34')]=_[_0x1262('0x32')](_0x825a42['model'],qs[_0x1262('0x33')](_0x3843e2[_0x1262('0x2a')][_0x1262('0x33')]));_0x40bd54[_0x1262('0x34')]=_0x40bd54[_0x1262('0x34')][_0x1262('0x35')]?_0x40bd54['attributes']:_0x825a42['model'];_0x40bd54[_0x1262('0x44')]=qs[_0x1262('0x45')](_0x3843e2[_0x1262('0x2a')]['sort']);_0x40bd54[_0x1262('0x27')]=qs[_0x1262('0x31')](_[_0x1262('0x57')](_0x3843e2['query'],_0x825a42[_0x1262('0x31')]));if(_0x3843e2['query'][_0x1262('0x47')]){_0x40bd54[_0x1262('0x27')]=_['merge'](_0x40bd54[_0x1262('0x27')],{'$or':_[_0x1262('0x23')](_0x40bd54[_0x1262('0x34')],function(_0x836849){var _0x2194a3={};_0x2194a3[_0x836849]={'$like':'%'+_0x3843e2[_0x1262('0x2a')][_0x1262('0x47')]+'%'};return _0x2194a3;})});}_0x40bd54=_[_0x1262('0x48')]({},_0x40bd54,_0x3843e2[_0x1262('0x49')]);return _0x320490[_0x1262('0x55')](_0x40bd54);}})['then'](function(_0x47c3da){if(_0x47c3da){_0x5607f1=_0x47c3da[_0x1262('0x35')];if(!_0x3843e2['query'][_0x1262('0x43')](_0x1262('0x58'))){_0x40bd54['limit']=qs['limit'](_0x3843e2[_0x1262('0x2a')][_0x1262('0x13')]);_0x40bd54[_0x1262('0x14')]=qs[_0x1262('0x14')](_0x3843e2[_0x1262('0x2a')][_0x1262('0x14')]);}return _0x320490[_0x1262('0x55')](_0x40bd54);}})['then'](function(_0x3e178f){if(_0x3e178f){return _0x3e178f?{'count':_0x5607f1,'rows':_0x3e178f}:null;}})[_0x1262('0x1a')](respondWithResult(_0x5bdc87,null))[_0x1262('0x2c')](handleError(_0x5bdc87,null));};exports[_0x1262('0x59')]=function(_0x3a8309,_0x248e4b){var _0x4363c2=_0x3a8309[_0x1262('0x39')][_0x1262('0x5a')];return db[_0x1262('0x56')][_0x1262('0x4b')]({'where':{'id':_0x4363c2},'attributes':['id'],'include':[{'model':db[_0x1262('0x4c')],'as':_0x1262('0x5b'),'attributes':['id',_0x1262('0x20'),_0x1262('0x5c'),_0x1262('0x5d'),_0x1262('0x5e')],'raw':!![]}]})[_0x1262('0x1a')](function(_0x242367){if(_0x242367){var _0x534fd9=_[_0x1262('0x5f')](_0x242367,function(_0x54fb80){var _0x142b6d=_0x54fb80[_0x1262('0x1c')]({'plain':!![]});return _0x142b6d[_0x1262('0x5b')];});return db[_0x1262('0x28')]['find']({'where':{'id':_0x3a8309[_0x1262('0x2e')]['id']}})['then'](function(_0x583cf1){return db['sequelize'][_0x1262('0x60')](function(_0x526835){return _0x583cf1[_0x1262('0x59')](_0x4363c2,{'transaction':_0x526835})[_0x1262('0x1a')](function(){return BPromise[_0x1262('0x61')](_0x534fd9,function(_0x474c7f){return db[_0x1262('0x4a')]['findOrCreate']({'where':{'UserId':_0x474c7f['id'],'ChatQueueId':_0x3a8309['params']['id']},'transaction':_0x526835});});})[_0x1262('0x1a')](function(){_0x534fd9[_0x1262('0x62')](function(_0x46d148){socket[_0x1262('0x63')](_0x1262('0x64'),{'UserId':_0x46d148['id'],'ChatQueueId':_0x583cf1['id']});});});});});}})['then'](respondWithStatusCode(_0x248e4b,null))[_0x1262('0x2c')](handleError(_0x248e4b,null));};exports[_0x1262('0x65')]=function(_0x54b0b6,_0x2ca424){return db['Team'][_0x1262('0x4b')]({'where':{'id':_0x54b0b6['query'][_0x1262('0x5a')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x1262('0x5b'),'attributes':['id'],'raw':!![]}]})[_0x1262('0x1a')](handleEntityNotFound(_0x2ca424,null))['then'](function(_0x1c83d0){var _0x4b21cf=_[_0x1262('0x23')](_0x1c83d0,'id');var _0x2bacf9=[];var _0x24393d=[];var _0x456f06=squel['select']();_0x456f06[_0x1262('0x66')](_0x1262('0x67'))[_0x1262('0x68')](_0x1262('0x69'),'tq')[_0x1262('0x6a')](_0x1262('0x6b'),'ut',_0x1262('0x6c'))[_0x1262('0x27')](_0x1262('0x6d'),_0x54b0b6['params']['id']);for(var _0x459cef=0x0;_0x459cef<_0x1c83d0['length'];_0x459cef+=0x1){let _0x52fc1f=_0x1c83d0[_0x459cef];for(var _0x2e461d=0x0;_0x2e461d<_0x52fc1f['Agents']['length'];_0x2e461d+=0x1){let _0x32bb46=_0x52fc1f['Agents'][_0x2e461d];var _0x3e94b0=_0x456f06['clone']();_0x3e94b0[_0x1262('0x27')]('ut.UserId\x20=\x20?',_0x32bb46['id']);_0x24393d['push'](db[_0x1262('0x6e')][_0x1262('0x2a')](_0x3e94b0[_0x1262('0x6f')](),{'type':db['sequelize'][_0x1262('0x70')]['SELECT']})[_0x1262('0x1a')](function(_0x330919){if(_0x330919[_0x1262('0x35')]===0x1){return _0x32bb46['id'];}else{var _0x59030f=_[_0x1262('0x71')](_[_0x1262('0x23')](_0x330919,_0x1262('0x72')),function(_0x507885){return _['includes'](_0x4b21cf,_0x507885);});if(_0x59030f){return _0x32bb46['id'];}}}));}}return BPromise[_0x1262('0x73')](_0x24393d)[_0x1262('0x1a')](function(_0x3fa698){_0x2bacf9=_(_0x2bacf9)[_0x1262('0x74')](_0x3fa698)[_0x1262('0x75')]()[_0x1262('0x76')]();return db[_0x1262('0x28')][_0x1262('0x37')]({'where':{'id':_0x54b0b6[_0x1262('0x2e')]['id']}})[_0x1262('0x1a')](function(_0xb7dae){return db[_0x1262('0x6e')]['transaction'](function(_0x70943d){return _0xb7dae['removeTeams'](_0x54b0b6[_0x1262('0x2a')]['ids'],{'transaction':_0x70943d})[_0x1262('0x1a')](function(){if(!_['isEmpty'](_0x2bacf9)){return _0xb7dae[_0x1262('0x77')](_0x2bacf9,{'transaction':_0x70943d});}})[_0x1262('0x1a')](function(){_0x2bacf9['forEach'](function(_0xa5dff4){socket[_0x1262('0x63')]('userChatQueue:remove',{'UserId':_0xa5dff4,'ChatQueueId':_0xb7dae['id']});});});});});});})[_0x1262('0x1a')](respondWithStatusCode(_0x2ca424,null))[_0x1262('0x2c')](handleError(_0x2ca424,null));};exports[_0x1262('0x78')]=function(_0x36282b,_0x4c44b9){return db['ChatQueue'][_0x1262('0x37')]({'where':{'id':_0x36282b[_0x1262('0x2e')]['id']}})[_0x1262('0x1a')](handleEntityNotFound(_0x4c44b9,null))[_0x1262('0x1a')](function(_0x17c42c){if(_0x17c42c){return _0x17c42c[_0x1262('0x78')](_0x36282b[_0x1262('0x39')]['ids'],_[_0x1262('0x79')](_0x36282b['body'],[_0x1262('0x5a'),'id'])||{})[_0x1262('0x7a')](function(_0x4beb67){for(var _0x335118=0x0;_0x335118<_0x36282b['body']['ids']['length'];_0x335118+=0x1){socket[_0x1262('0x63')](_0x1262('0x64'),{'UserId':Number(_0x36282b['body']['ids'][_0x335118]),'ChatQueueId':Number(_0x36282b['params']['id'])});}return _0x4beb67;});}})[_0x1262('0x1a')](respondWithResult(_0x4c44b9,null))[_0x1262('0x2c')](handleError(_0x4c44b9,null));};exports['removeAgents']=function(_0x175dce,_0x165f9e){return db[_0x1262('0x28')]['find']({'where':{'id':_0x175dce[_0x1262('0x2e')]['id']}})['then'](handleEntityNotFound(_0x165f9e,null))['then'](function(_0x412919){if(_0x412919){return _0x412919[_0x1262('0x77')](_0x175dce[_0x1262('0x2a')][_0x1262('0x5a')])[_0x1262('0x1a')](function(){if(_[_0x1262('0x7b')](_0x175dce['query'][_0x1262('0x5a')])){for(var _0xad0de2=0x0;_0xad0de2<_0x175dce[_0x1262('0x2a')][_0x1262('0x5a')][_0x1262('0x35')];_0xad0de2+=0x1){socket[_0x1262('0x63')]('userChatQueue:remove',{'UserId':Number(_0x175dce['query'][_0x1262('0x5a')][_0xad0de2]),'ChatQueueId':Number(_0x175dce['params']['id'])});}}else{socket[_0x1262('0x63')](_0x1262('0x7c'),{'UserId':Number(_0x175dce[_0x1262('0x2a')][_0x1262('0x5a')]),'ChatQueueId':Number(_0x175dce[_0x1262('0x2e')]['id'])});}});}})[_0x1262('0x1a')](respondWithStatusCode(_0x165f9e,null))[_0x1262('0x2c')](handleError(_0x165f9e,null));};exports[_0x1262('0x7d')]=function(_0x30fd12,_0x4c4805){var _0x7bb51a={};var _0x4513c8={};var _0x248308;var _0x520e77;return db[_0x1262('0x28')][_0x1262('0x42')]({'where':{'id':_0x30fd12[_0x1262('0x2e')]['id']}})['then'](handleEntityNotFound(_0x4c4805,null))[_0x1262('0x1a')](function(_0x220b80){if(_0x220b80){_0x248308=_0x220b80;_0x4513c8[_0x1262('0x2f')]=_[_0x1262('0x30')](db[_0x1262('0x4c')][_0x1262('0x24')]);_0x4513c8[_0x1262('0x2a')]=_['keys'](_0x30fd12[_0x1262('0x2a')]);_0x4513c8[_0x1262('0x31')]=_[_0x1262('0x32')](_0x4513c8[_0x1262('0x2f')],_0x4513c8['query']);_0x7bb51a[_0x1262('0x34')]=_[_0x1262('0x32')](_0x4513c8[_0x1262('0x2f')],qs['fields'](_0x30fd12[_0x1262('0x2a')][_0x1262('0x33')]));_0x7bb51a['attributes']=_0x7bb51a[_0x1262('0x34')][_0x1262('0x35')]?_0x7bb51a[_0x1262('0x34')]:_0x4513c8['model'];_0x7bb51a[_0x1262('0x44')]=qs['sort'](_0x30fd12[_0x1262('0x2a')]['sort']);_0x7bb51a['where']=qs[_0x1262('0x31')](_['pick'](_0x30fd12[_0x1262('0x2a')],_0x4513c8[_0x1262('0x31')]));if(_0x30fd12[_0x1262('0x2a')][_0x1262('0x47')]){_0x7bb51a[_0x1262('0x27')]=_['merge'](_0x7bb51a[_0x1262('0x27')],{'$or':_[_0x1262('0x23')](_0x7bb51a['attributes'],function(_0x50fcb7){var _0x44e70b={};_0x44e70b[_0x50fcb7]={'$like':'%'+_0x30fd12['query'][_0x1262('0x47')]+'%'};return _0x44e70b;})});}_0x7bb51a=_['merge']({},_0x7bb51a,_0x30fd12[_0x1262('0x49')]);return _0x248308[_0x1262('0x7d')](_0x7bb51a);}})[_0x1262('0x1a')](function(_0x59f6ca){if(_0x59f6ca){_0x520e77=_0x59f6ca[_0x1262('0x35')];if(!_0x30fd12[_0x1262('0x2a')]['hasOwnProperty'](_0x1262('0x58'))){_0x7bb51a[_0x1262('0x13')]=qs[_0x1262('0x13')](_0x30fd12[_0x1262('0x2a')][_0x1262('0x13')]);_0x7bb51a[_0x1262('0x14')]=qs['offset'](_0x30fd12[_0x1262('0x2a')][_0x1262('0x14')]);}return _0x248308[_0x1262('0x7d')](_0x7bb51a);}})['then'](function(_0x3b4928){if(_0x3b4928){return _0x3b4928?{'count':_0x520e77,'rows':_0x3b4928}:null;}})['then'](respondWithResult(_0x4c4805,null))['catch'](handleError(_0x4c4805,null));};
\ No newline at end of file
+var _0x01f1=['updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','Agents','online','interface','flatMap','sequelize','forEach','userChatQueue:save','ids','select','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','TeamId','all','union','compact','transaction','removeTeams','isEmpty','removeAgents','emit','addAgents','userChatQueue:remove','getAgents','order','bluebird','lodash','squel','ioredis','../../components/parsers/qs','api','../../config/environment','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','json','offset','undefined','limit','count','set','update','then','get','error','stack','name','send','map','ChatQueue','fieldName','type','getOptions','where','findAll','catch','show','model','rawAttributes','query','keys','filters','fields','length','attributes','includeAll','include','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','ChatQueues','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','params','describe','getMembers','findOne','UserChatQueue','intersection','hasOwnProperty','nolimit','sort','pick','ChatQueueId','filter','User','UserId','agent','chatPause'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x01f1,0x114));var _0x101f=function(_0x3ff2f9,_0x544ba1){_0x3ff2f9=_0x3ff2f9-0x0;var _0x3b0913=_0x01f1[_0x3ff2f9];return _0x3b0913;};'use strict';var BPromise=require(_0x101f('0x0'));var util=require('util');var _=require(_0x101f('0x1'));var squel=require(_0x101f('0x2'));var Redis=require(_0x101f('0x3'));var qs=require(_0x101f('0x4'));var logger=require('../../config/logger')(_0x101f('0x5'));var config=require(_0x101f('0x6'));var db=require('../../mysqldb')['db'];config[_0x101f('0x7')]=_[_0x101f('0x8')](config[_0x101f('0x7')],{'host':_0x101f('0x9'),'port':0x18eb});var socket=require(_0x101f('0xa'))(new Redis(config[_0x101f('0x7')]));require('./chatQueue.socket')[_0x101f('0xb')](socket);function respondWithStatusCode(_0x53b4fe,_0x17388f){_0x17388f=_0x17388f||0xcc;return function(_0x250b19){if(_0x250b19){return _0x53b4fe[_0x101f('0xc')](_0x17388f);}return _0x53b4fe[_0x101f('0xd')](_0x17388f)['end']();};}function respondWithResult(_0x513695,_0x1ecc5c){_0x1ecc5c=_0x1ecc5c||0xc8;return function(_0x56d6dc){if(_0x56d6dc){return _0x513695[_0x101f('0xd')](_0x1ecc5c)[_0x101f('0xe')](_0x56d6dc);}};}function respondWithFilteredResult(_0x243808,_0x43b920){return function(_0x5cab52){if(_0x5cab52){var _0xf4cb95=typeof _0x43b920[_0x101f('0xf')]===_0x101f('0x10')&&typeof _0x43b920[_0x101f('0x11')]==='undefined';var _0x14ceea=_0x5cab52[_0x101f('0x12')];var _0x5df555=_0xf4cb95?0x0:_0x43b920[_0x101f('0xf')];var _0x5dbba4=_0xf4cb95?_0x5cab52[_0x101f('0x12')]:_0x43b920['offset']+_0x43b920[_0x101f('0x11')];var _0x598e90;if(_0x5dbba4>=_0x14ceea){_0x5dbba4=_0x14ceea;_0x598e90=0xc8;}else{_0x598e90=0xce;}_0x243808['status'](_0x598e90);return _0x243808[_0x101f('0x13')]('Content-Range',_0x5df555+'-'+_0x5dbba4+'/'+_0x14ceea)[_0x101f('0xe')](_0x5cab52);}return null;};}function saveUpdates(_0x2efa9f){return function(_0x4d4643){if(_0x4d4643){return _0x4d4643[_0x101f('0x14')](_0x2efa9f)[_0x101f('0x15')](function(_0x52fc68){return _0x52fc68;});}return null;};}function removeEntity(_0x1e10ad){return function(_0x464429){if(_0x464429){return _0x464429['destroy']()[_0x101f('0x15')](function(){var _0x30254=_0x464429[_0x101f('0x16')]({'plain':!![]});var _0x412b59='ChatQueues';return db['UserProfileResource']['destroy']({'where':{'type':_0x412b59,'resourceId':_0x30254['id']}})['then'](function(){return _0x464429;});})[_0x101f('0x15')](function(){_0x1e10ad[_0x101f('0xd')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2d9cee){return function(_0x14088d){if(!_0x14088d){_0x2d9cee[_0x101f('0xc')](0x194);}return _0x14088d;};}function handleError(_0x52061a,_0x29d638){_0x29d638=_0x29d638||0x1f4;return function(_0x1d7dd9){logger[_0x101f('0x17')](_0x1d7dd9[_0x101f('0x18')]);if(_0x1d7dd9['name']){delete _0x1d7dd9[_0x101f('0x19')];}_0x52061a[_0x101f('0xd')](_0x29d638)[_0x101f('0x1a')](_0x1d7dd9);};}exports['index']=function(_0x387b0c,_0x5460de){var _0x30fd4f={};var _0x5dea3d={'count':0x0,'rows':[]};var _0x441c4c=_[_0x101f('0x1b')](db[_0x101f('0x1c')]['rawAttributes'],function(_0x2930f){return{'name':_0x2930f[_0x101f('0x1d')],'type':_0x2930f[_0x101f('0x1e')]['key']};});_0x30fd4f=qs[_0x101f('0x1f')](_0x441c4c,_0x387b0c);var _0x1945b4={'where':_0x30fd4f[_0x101f('0x20')]};return db['ChatQueue']['count'](_0x1945b4)[_0x101f('0x15')](function(_0x5bf754){_0x5dea3d[_0x101f('0x12')]=_0x5bf754;_0x30fd4f['include']=qs['include'](_0x387b0c['query']);return db[_0x101f('0x1c')][_0x101f('0x21')](_0x30fd4f);})['then'](function(_0x1e4111){_0x5dea3d['rows']=_0x1e4111;return _0x5dea3d;})['then'](respondWithFilteredResult(_0x5460de,_0x30fd4f))[_0x101f('0x22')](handleError(_0x5460de,null));};exports[_0x101f('0x23')]=function(_0x2cfa66,_0x1bb2db){var _0x4bd791={'raw':!![],'where':{'id':_0x2cfa66['params']['id']}},_0x17127a={};_0x17127a[_0x101f('0x24')]=_['keys'](db[_0x101f('0x1c')][_0x101f('0x25')]);_0x17127a[_0x101f('0x26')]=_[_0x101f('0x27')](_0x2cfa66['query']);_0x17127a[_0x101f('0x28')]=_['intersection'](_0x17127a[_0x101f('0x24')],_0x17127a[_0x101f('0x26')]);_0x4bd791['attributes']=_['intersection'](_0x17127a[_0x101f('0x24')],qs[_0x101f('0x29')](_0x2cfa66[_0x101f('0x26')][_0x101f('0x29')]));_0x4bd791['attributes']=_0x4bd791['attributes'][_0x101f('0x2a')]?_0x4bd791[_0x101f('0x2b')]:_0x17127a[_0x101f('0x24')];if(_0x2cfa66[_0x101f('0x26')][_0x101f('0x2c')]){_0x4bd791[_0x101f('0x2d')]=[{'all':!![]}];}_0x4bd791=_[_0x101f('0x2e')]({},_0x4bd791,_0x2cfa66[_0x101f('0x2f')]);return db[_0x101f('0x1c')][_0x101f('0x30')](_0x4bd791)[_0x101f('0x15')](handleEntityNotFound(_0x1bb2db,null))[_0x101f('0x15')](respondWithResult(_0x1bb2db,null))['catch'](handleError(_0x1bb2db,null));};exports[_0x101f('0x31')]=function(_0x5385fd,_0x10beea){return db[_0x101f('0x1c')][_0x101f('0x31')](_0x5385fd[_0x101f('0x32')],{})[_0x101f('0x15')](function(_0x5a7d34){var _0xa4d4fb=_0x5385fd[_0x101f('0x33')][_0x101f('0x16')]({'plain':!![]});if(!_0xa4d4fb)throw new Error(_0x101f('0x34'));if(_0xa4d4fb['role']===_0x101f('0x33')){var _0x505433=_0x5a7d34[_0x101f('0x16')]({'plain':!![]});var _0x55290e=_0x101f('0x35');return db['UserProfileSection']['find']({'where':{'name':_0x55290e,'userProfileId':_0xa4d4fb[_0x101f('0x36')]},'raw':!![]})['then'](function(_0x2770b6){if(_0x2770b6&&_0x2770b6[_0x101f('0x37')]===0x0){return db[_0x101f('0x38')]['create']({'name':_0x505433[_0x101f('0x19')],'resourceId':_0x505433['id'],'type':_0x2770b6[_0x101f('0x19')],'sectionId':_0x2770b6['id']},{})[_0x101f('0x15')](function(){return _0x5a7d34;});}else{return _0x5a7d34;}})[_0x101f('0x22')](function(_0x5dcc14){logger[_0x101f('0x17')](_0x101f('0x39'),_0x5dcc14);throw _0x5dcc14;});}return _0x5a7d34;})[_0x101f('0x15')](respondWithResult(_0x10beea,0xc9))[_0x101f('0x22')](handleError(_0x10beea,null));};exports[_0x101f('0x14')]=function(_0x4f0bba,_0x26d86f){if(_0x4f0bba['body']['id']){delete _0x4f0bba[_0x101f('0x32')]['id'];}return db[_0x101f('0x1c')]['find']({'where':{'id':_0x4f0bba['params']['id']}})[_0x101f('0x15')](handleEntityNotFound(_0x26d86f,null))['then'](saveUpdates(_0x4f0bba[_0x101f('0x32')],null))['then'](respondWithResult(_0x26d86f,null))[_0x101f('0x22')](handleError(_0x26d86f,null));};exports[_0x101f('0x3a')]=function(_0x51ac53,_0x57a17a){return db[_0x101f('0x1c')][_0x101f('0x30')]({'where':{'id':_0x51ac53[_0x101f('0x3b')]['id']}})[_0x101f('0x15')](handleEntityNotFound(_0x57a17a,null))[_0x101f('0x15')](removeEntity(_0x57a17a,null))[_0x101f('0x22')](handleError(_0x57a17a,null));};exports[_0x101f('0x3c')]=function(_0x23c78e,_0x5af813){return db[_0x101f('0x1c')][_0x101f('0x3c')]()[_0x101f('0x15')](respondWithResult(_0x5af813,null))[_0x101f('0x22')](handleError(_0x5af813,null));};exports[_0x101f('0x3d')]=function(_0x67dfdb,_0x354ddc){var _0x71a761={'raw':!![],'where':{}},_0x30200b={},_0xbaeb1d;return db[_0x101f('0x1c')][_0x101f('0x3e')]({'where':{'id':_0x67dfdb[_0x101f('0x3b')]['id']}})[_0x101f('0x15')](handleEntityNotFound(_0x354ddc,null))[_0x101f('0x15')](function(_0x4c23b2){if(_0x4c23b2){_0xbaeb1d=_0x4c23b2[_0x101f('0x16')]({'plain':!![]});_0x30200b[_0x101f('0x24')]=_['keys'](db[_0x101f('0x3f')]['rawAttributes']);_0x30200b[_0x101f('0x26')]=_['keys'](_0x67dfdb[_0x101f('0x26')]);_0x30200b[_0x101f('0x28')]=_[_0x101f('0x40')](_0x30200b[_0x101f('0x24')],_0x30200b[_0x101f('0x26')]);_0x71a761[_0x101f('0x2b')]=_[_0x101f('0x40')](_0x30200b['model'],qs['fields'](_0x67dfdb['query'][_0x101f('0x29')]));_0x71a761[_0x101f('0x2b')]=_0x71a761['attributes']['length']?_0x71a761['attributes']:_0x30200b[_0x101f('0x24')];if(!_0x67dfdb[_0x101f('0x26')][_0x101f('0x41')](_0x101f('0x42'))){_0x71a761[_0x101f('0x11')]=qs['limit'](_0x67dfdb['query'][_0x101f('0x11')]);_0x71a761[_0x101f('0xf')]=qs['offset'](_0x67dfdb['query'][_0x101f('0xf')]);}_0x71a761['order']=qs[_0x101f('0x43')](_0x67dfdb[_0x101f('0x26')][_0x101f('0x43')]);_0x71a761[_0x101f('0x20')]=qs[_0x101f('0x28')](_[_0x101f('0x44')](_0x67dfdb['query'],_0x30200b[_0x101f('0x28')]));_0x71a761[_0x101f('0x20')][_0x101f('0x45')]=_0x4c23b2['id'];if(_0x67dfdb[_0x101f('0x26')][_0x101f('0x46')]){_0x71a761[_0x101f('0x20')]=_['merge'](_0x71a761[_0x101f('0x20')],{'$or':_[_0x101f('0x1b')](_0x71a761[_0x101f('0x2b')],function(_0x243741){var _0x5ad259={};_0x5ad259[_0x243741]={'$like':'%'+_0x67dfdb[_0x101f('0x26')][_0x101f('0x46')]+'%'};return _0x5ad259;})});}_0x71a761=_[_0x101f('0x2e')]({},_0x71a761,_0x67dfdb[_0x101f('0x2f')]);return db[_0x101f('0x3f')][_0x101f('0x21')](_0x71a761);}})[_0x101f('0x15')](function(_0x4c81da){if(_0x4c81da){return db[_0x101f('0x47')]['findAndCountAll']({'where':{'id':_['map'](_0x4c81da,_0x101f('0x48')),'role':_0x101f('0x49')},'attributes':['id',_0x101f('0x19'),_0x101f('0x4a'),_0x101f('0x4b'),_0x101f('0x4c')]});}})[_0x101f('0x15')](function(_0x2e5c82){if(_0x2e5c82){return{'count':_0x2e5c82[_0x101f('0x12')],'rows':_[_0x101f('0x1b')](_0x2e5c82['rows'],function(_0x444315){return{'membername':_0x444315['name'],'UserId':_0x444315['id'],'queue_name':_0xbaeb1d[_0x101f('0x19')],'ChatQueueId':_0xbaeb1d['id'],'interface':util[_0x101f('0x4d')](_0x101f('0x4e'),_0x101f('0x4f'),_0x444315[_0x101f('0x19')]),'penalty':0x0,'paused':_0x444315[_0x101f('0x4a')],'createdAt':_0x444315['createdAt'],'updatedAt':_0x444315[_0x101f('0x4b')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x354ddc,_0x71a761))[_0x101f('0x22')](handleError(_0x354ddc,null));};exports[_0x101f('0x50')]=function(_0x40b82f,_0xb7db8d){var _0x3cc5a1={};var _0x7470e3={};var _0x4dad0e;var _0x432652;return db[_0x101f('0x1c')][_0x101f('0x3e')]({'where':{'id':_0x40b82f[_0x101f('0x3b')]['id']}})[_0x101f('0x15')](handleEntityNotFound(_0xb7db8d,null))[_0x101f('0x15')](function(_0x1d20e2){if(_0x1d20e2){_0x4dad0e=_0x1d20e2;_0x7470e3['model']=_['keys'](db[_0x101f('0x51')][_0x101f('0x25')]);_0x7470e3['query']=_[_0x101f('0x27')](_0x40b82f['query']);_0x7470e3['filters']=_[_0x101f('0x40')](_0x7470e3[_0x101f('0x24')],_0x7470e3[_0x101f('0x26')]);_0x3cc5a1[_0x101f('0x2b')]=_['intersection'](_0x7470e3[_0x101f('0x24')],qs[_0x101f('0x29')](_0x40b82f[_0x101f('0x26')][_0x101f('0x29')]));_0x3cc5a1[_0x101f('0x2b')]=_0x3cc5a1[_0x101f('0x2b')]['length']?_0x3cc5a1[_0x101f('0x2b')]:_0x7470e3[_0x101f('0x24')];_0x3cc5a1['order']=qs[_0x101f('0x43')](_0x40b82f[_0x101f('0x26')][_0x101f('0x43')]);_0x3cc5a1[_0x101f('0x20')]=qs['filters'](_[_0x101f('0x44')](_0x40b82f[_0x101f('0x26')],_0x7470e3[_0x101f('0x28')]));if(_0x40b82f[_0x101f('0x26')][_0x101f('0x46')]){_0x3cc5a1[_0x101f('0x20')]=_[_0x101f('0x2e')](_0x3cc5a1['where'],{'$or':_[_0x101f('0x1b')](_0x3cc5a1[_0x101f('0x2b')],function(_0x2d9fae){var _0x3b179e={};_0x3b179e[_0x2d9fae]={'$like':'%'+_0x40b82f[_0x101f('0x26')][_0x101f('0x46')]+'%'};return _0x3b179e;})});}_0x3cc5a1=_[_0x101f('0x2e')]({},_0x3cc5a1,_0x40b82f[_0x101f('0x2f')]);return _0x4dad0e['getTeams'](_0x3cc5a1);}})[_0x101f('0x15')](function(_0xb69fff){if(_0xb69fff){_0x432652=_0xb69fff[_0x101f('0x2a')];if(!_0x40b82f[_0x101f('0x26')][_0x101f('0x41')](_0x101f('0x42'))){_0x3cc5a1[_0x101f('0x11')]=qs[_0x101f('0x11')](_0x40b82f['query'][_0x101f('0x11')]);_0x3cc5a1['offset']=qs['offset'](_0x40b82f[_0x101f('0x26')][_0x101f('0xf')]);}return _0x4dad0e['getTeams'](_0x3cc5a1);}})[_0x101f('0x15')](function(_0x1f4cf2){if(_0x1f4cf2){return _0x1f4cf2?{'count':_0x432652,'rows':_0x1f4cf2}:null;}})[_0x101f('0x15')](respondWithResult(_0xb7db8d,null))[_0x101f('0x22')](handleError(_0xb7db8d,null));};exports[_0x101f('0x52')]=function(_0x1415e9,_0x2e7a88){var _0x382fc6=_0x1415e9['body']['ids'];return db[_0x101f('0x51')][_0x101f('0x21')]({'where':{'id':_0x382fc6},'attributes':['id'],'include':[{'model':db['User'],'as':_0x101f('0x53'),'attributes':['id',_0x101f('0x19'),_0x101f('0x54'),'voicePause',_0x101f('0x55')],'raw':!![]}]})['then'](function(_0x183a58){if(_0x183a58){var _0x47b292=_[_0x101f('0x56')](_0x183a58,function(_0xd3e3a8){var _0x431955=_0xd3e3a8[_0x101f('0x16')]({'plain':!![]});return _0x431955[_0x101f('0x53')];});return db['ChatQueue'][_0x101f('0x30')]({'where':{'id':_0x1415e9[_0x101f('0x3b')]['id']}})[_0x101f('0x15')](function(_0x360ba8){return db[_0x101f('0x57')]['transaction'](function(_0x2c44e8){return _0x360ba8[_0x101f('0x52')](_0x382fc6,{'transaction':_0x2c44e8})[_0x101f('0x15')](function(){return BPromise['each'](_0x47b292,function(_0x4b38fc){return db[_0x101f('0x3f')]['findOrCreate']({'where':{'UserId':_0x4b38fc['id'],'ChatQueueId':_0x1415e9[_0x101f('0x3b')]['id']},'transaction':_0x2c44e8});});})[_0x101f('0x15')](function(){_0x47b292[_0x101f('0x58')](function(_0x4f4ca0){socket['emit'](_0x101f('0x59'),{'UserId':_0x4f4ca0['id'],'ChatQueueId':_0x360ba8['id']});});});});});}})['then'](respondWithStatusCode(_0x2e7a88,null))['catch'](handleError(_0x2e7a88,null));};exports['removeTeams']=function(_0x37c5d0,_0x2b3cb9){return db[_0x101f('0x51')][_0x101f('0x21')]({'where':{'id':_0x37c5d0['query'][_0x101f('0x5a')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x101f('0x53'),'attributes':['id'],'raw':!![]}]})[_0x101f('0x15')](handleEntityNotFound(_0x2b3cb9,null))['then'](function(_0x2f803f){var _0x129e43=_[_0x101f('0x1b')](_0x2f803f,'id');var _0x5b9995=[];var _0x3ef2cd=[];var _0x1365f1=squel[_0x101f('0x5b')]();_0x1365f1['field']('tq.TeamId')['from'](_0x101f('0x5c'),'tq')[_0x101f('0x5d')](_0x101f('0x5e'),'ut',_0x101f('0x5f'))[_0x101f('0x20')](_0x101f('0x60'),_0x37c5d0['params']['id']);for(var _0x3856c9=0x0;_0x3856c9<_0x2f803f[_0x101f('0x2a')];_0x3856c9+=0x1){let _0x255e49=_0x2f803f[_0x3856c9];for(var _0x3894dc=0x0;_0x3894dc<_0x255e49[_0x101f('0x53')][_0x101f('0x2a')];_0x3894dc+=0x1){let _0x4e4fd0=_0x255e49[_0x101f('0x53')][_0x3894dc];var _0x5133dd=_0x1365f1[_0x101f('0x61')]();_0x5133dd[_0x101f('0x20')](_0x101f('0x62'),_0x4e4fd0['id']);_0x3ef2cd[_0x101f('0x63')](db['sequelize']['query'](_0x5133dd[_0x101f('0x64')](),{'type':db[_0x101f('0x57')][_0x101f('0x65')][_0x101f('0x66')]})[_0x101f('0x15')](function(_0x2a8123){if(_0x2a8123[_0x101f('0x2a')]===0x1){return _0x4e4fd0['id'];}else{var _0xd5ee2=_[_0x101f('0x67')](_[_0x101f('0x1b')](_0x2a8123,_0x101f('0x68')),function(_0x203347){return _['includes'](_0x129e43,_0x203347);});if(_0xd5ee2){return _0x4e4fd0['id'];}}}));}}return BPromise[_0x101f('0x69')](_0x3ef2cd)[_0x101f('0x15')](function(_0x53e7ca){_0x5b9995=_(_0x5b9995)[_0x101f('0x6a')](_0x53e7ca)[_0x101f('0x6b')]()['value']();return db[_0x101f('0x1c')]['find']({'where':{'id':_0x37c5d0[_0x101f('0x3b')]['id']}})[_0x101f('0x15')](function(_0x1e3d08){return db[_0x101f('0x57')][_0x101f('0x6c')](function(_0x115cd9){return _0x1e3d08[_0x101f('0x6d')](_0x37c5d0['query']['ids'],{'transaction':_0x115cd9})[_0x101f('0x15')](function(){if(!_[_0x101f('0x6e')](_0x5b9995)){return _0x1e3d08[_0x101f('0x6f')](_0x5b9995,{'transaction':_0x115cd9});}})[_0x101f('0x15')](function(){_0x5b9995[_0x101f('0x58')](function(_0x44d8ee){socket[_0x101f('0x70')]('userChatQueue:remove',{'UserId':_0x44d8ee,'ChatQueueId':_0x1e3d08['id']});});});});});});})[_0x101f('0x15')](respondWithStatusCode(_0x2b3cb9,null))[_0x101f('0x22')](handleError(_0x2b3cb9,null));};exports[_0x101f('0x71')]=function(_0x26cb19,_0xbc177a){return db['ChatQueue'][_0x101f('0x30')]({'where':{'id':_0x26cb19[_0x101f('0x3b')]['id']}})[_0x101f('0x15')](handleEntityNotFound(_0xbc177a,null))['then'](function(_0x16d8b7){if(_0x16d8b7){return _0x16d8b7[_0x101f('0x71')](_0x26cb19[_0x101f('0x32')][_0x101f('0x5a')],_['omit'](_0x26cb19[_0x101f('0x32')],[_0x101f('0x5a'),'id'])||{})['spread'](function(_0x16f83c){for(var _0x546be6=0x0;_0x546be6<_0x26cb19[_0x101f('0x32')][_0x101f('0x5a')][_0x101f('0x2a')];_0x546be6+=0x1){socket[_0x101f('0x70')](_0x101f('0x59'),{'UserId':Number(_0x26cb19[_0x101f('0x32')][_0x101f('0x5a')][_0x546be6]),'ChatQueueId':Number(_0x26cb19[_0x101f('0x3b')]['id'])});}return _0x16f83c;});}})[_0x101f('0x15')](respondWithResult(_0xbc177a,null))[_0x101f('0x22')](handleError(_0xbc177a,null));};exports['removeAgents']=function(_0x4382d,_0x135150){return db[_0x101f('0x1c')][_0x101f('0x30')]({'where':{'id':_0x4382d[_0x101f('0x3b')]['id']}})['then'](handleEntityNotFound(_0x135150,null))[_0x101f('0x15')](function(_0x2d441a){if(_0x2d441a){return _0x2d441a[_0x101f('0x6f')](_0x4382d[_0x101f('0x26')][_0x101f('0x5a')])[_0x101f('0x15')](function(){if(_['isArray'](_0x4382d[_0x101f('0x26')][_0x101f('0x5a')])){for(var _0x184964=0x0;_0x184964<_0x4382d['query'][_0x101f('0x5a')][_0x101f('0x2a')];_0x184964+=0x1){socket[_0x101f('0x70')](_0x101f('0x72'),{'UserId':Number(_0x4382d[_0x101f('0x26')][_0x101f('0x5a')][_0x184964]),'ChatQueueId':Number(_0x4382d[_0x101f('0x3b')]['id'])});}}else{socket[_0x101f('0x70')](_0x101f('0x72'),{'UserId':Number(_0x4382d['query'][_0x101f('0x5a')]),'ChatQueueId':Number(_0x4382d['params']['id'])});}});}})[_0x101f('0x15')](respondWithStatusCode(_0x135150,null))['catch'](handleError(_0x135150,null));};exports[_0x101f('0x73')]=function(_0x12234f,_0x2b1131){var _0x1a90ac={};var _0x42c31e={};var _0x2596c3;var _0x48b2c0;return db[_0x101f('0x1c')][_0x101f('0x3e')]({'where':{'id':_0x12234f[_0x101f('0x3b')]['id']}})['then'](handleEntityNotFound(_0x2b1131,null))[_0x101f('0x15')](function(_0x439378){if(_0x439378){_0x2596c3=_0x439378;_0x42c31e[_0x101f('0x24')]=_[_0x101f('0x27')](db[_0x101f('0x47')][_0x101f('0x25')]);_0x42c31e[_0x101f('0x26')]=_[_0x101f('0x27')](_0x12234f[_0x101f('0x26')]);_0x42c31e['filters']=_['intersection'](_0x42c31e[_0x101f('0x24')],_0x42c31e[_0x101f('0x26')]);_0x1a90ac[_0x101f('0x2b')]=_['intersection'](_0x42c31e['model'],qs[_0x101f('0x29')](_0x12234f[_0x101f('0x26')][_0x101f('0x29')]));_0x1a90ac[_0x101f('0x2b')]=_0x1a90ac[_0x101f('0x2b')]['length']?_0x1a90ac[_0x101f('0x2b')]:_0x42c31e[_0x101f('0x24')];_0x1a90ac[_0x101f('0x74')]=qs['sort'](_0x12234f[_0x101f('0x26')][_0x101f('0x43')]);_0x1a90ac[_0x101f('0x20')]=qs[_0x101f('0x28')](_[_0x101f('0x44')](_0x12234f[_0x101f('0x26')],_0x42c31e[_0x101f('0x28')]));if(_0x12234f[_0x101f('0x26')]['filter']){_0x1a90ac[_0x101f('0x20')]=_[_0x101f('0x2e')](_0x1a90ac['where'],{'$or':_[_0x101f('0x1b')](_0x1a90ac[_0x101f('0x2b')],function(_0x2492f7){var _0x42c465={};_0x42c465[_0x2492f7]={'$like':'%'+_0x12234f[_0x101f('0x26')][_0x101f('0x46')]+'%'};return _0x42c465;})});}_0x1a90ac=_[_0x101f('0x2e')]({},_0x1a90ac,_0x12234f[_0x101f('0x2f')]);return _0x2596c3['getAgents'](_0x1a90ac);}})[_0x101f('0x15')](function(_0x562951){if(_0x562951){_0x48b2c0=_0x562951[_0x101f('0x2a')];if(!_0x12234f[_0x101f('0x26')][_0x101f('0x41')](_0x101f('0x42'))){_0x1a90ac[_0x101f('0x11')]=qs['limit'](_0x12234f['query']['limit']);_0x1a90ac['offset']=qs[_0x101f('0xf')](_0x12234f[_0x101f('0x26')][_0x101f('0xf')]);}return _0x2596c3['getAgents'](_0x1a90ac);}})[_0x101f('0x15')](function(_0xba2d3f){if(_0xba2d3f){return _0xba2d3f?{'count':_0x48b2c0,'rows':_0xba2d3f}:null;}})['then'](respondWithResult(_0x2b1131,null))[_0x101f('0x22')](handleError(_0x2b1131,null));};
\ No newline at end of file