Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 63ee294..e5facc4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xabf4=['redis','defaults','localhost','./chatQueue.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','update','then','destroy','get','ChatQueues','UserProfileResource','error','stack','name','send','index','map','ChatQueue','rawAttributes','type','key','where','include','query','findAll','show','params','model','keys','filters','attributes','intersection','fields','length','includeAll','merge','find','catch','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserChatQueue','hasOwnProperty','nolimit','order','sort','pick','filter','options','findAndCountAll','UserId','agent','chatPause','updatedAt','createdAt','rows','format','%s/%s','SIP','getTeams','findOne','Team','ids','User','Agents','online','voicePause','flatMap','transaction','addTeams','each','findOrCreate','forEach','emit','userChatQueue:save','removeTeams','select','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','sequelize','QueryTypes','every','includes','all','union','value','userChatQueue:remove','addAgents','omit','spread','removeAgents','getAgents','util','lodash','squel','../../components/parsers/qs','../../config/logger','api','../../mysqldb'];(function(_0x3d79ac,_0x222051){var _0x475b30=function(_0x119831){while(--_0x119831){_0x3d79ac['push'](_0x3d79ac['shift']());}};_0x475b30(++_0x222051);}(_0xabf4,0x77));var _0x4abf=function(_0x34f41a,_0x5f1d24){_0x34f41a=_0x34f41a-0x0;var _0x4bfb9b=_0xabf4[_0x34f41a];return _0x4bfb9b;};'use strict';var BPromise=require('bluebird');var util=require(_0x4abf('0x0'));var _=require(_0x4abf('0x1'));var squel=require(_0x4abf('0x2'));var Redis=require('ioredis');var qs=require(_0x4abf('0x3'));var logger=require(_0x4abf('0x4'))(_0x4abf('0x5'));var config=require('../../config/environment');var db=require(_0x4abf('0x6'))['db'];config[_0x4abf('0x7')]=_[_0x4abf('0x8')](config['redis'],{'host':_0x4abf('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4abf('0x7')]));require(_0x4abf('0xa'))[_0x4abf('0xb')](socket);function respondWithStatusCode(_0x53a02a,_0x211221){_0x211221=_0x211221||0xcc;return function(_0x3c47e4){if(_0x3c47e4){return _0x53a02a[_0x4abf('0xc')](_0x211221);}return _0x53a02a[_0x4abf('0xd')](_0x211221)[_0x4abf('0xe')]();};}function respondWithResult(_0x155768,_0xc4914){_0xc4914=_0xc4914||0xc8;return function(_0x473f5a){if(_0x473f5a){return _0x155768['status'](_0xc4914)[_0x4abf('0xf')](_0x473f5a);}};}function respondWithFilteredResult(_0x41b901,_0x2b6cae){return function(_0x2a9487){if(_0x2a9487){var _0x5169cf=typeof _0x2b6cae[_0x4abf('0x10')]===_0x4abf('0x11')&&typeof _0x2b6cae[_0x4abf('0x12')]==='undefined';var _0x2ad0a1=_0x2a9487[_0x4abf('0x13')];var _0x188a43=_0x5169cf?0x0:_0x2b6cae[_0x4abf('0x10')];var _0x5f452f=_0x5169cf?_0x2a9487[_0x4abf('0x13')]:_0x2b6cae[_0x4abf('0x10')]+_0x2b6cae[_0x4abf('0x12')];var _0x470aaa;if(_0x5f452f>=_0x2ad0a1){_0x5f452f=_0x2ad0a1;_0x470aaa=0xc8;}else{_0x470aaa=0xce;}_0x41b901['status'](_0x470aaa);return _0x41b901[_0x4abf('0x14')](_0x4abf('0x15'),_0x188a43+'-'+_0x5f452f+'/'+_0x2ad0a1)[_0x4abf('0xf')](_0x2a9487);}return null;};}function saveUpdates(_0x1f0bce){return function(_0xc2b78d){if(_0xc2b78d){return _0xc2b78d[_0x4abf('0x16')](_0x1f0bce)[_0x4abf('0x17')](function(_0x1d9bfa){return _0x1d9bfa;});}return null;};}function removeEntity(_0x178917){return function(_0x79d84f){if(_0x79d84f){return _0x79d84f[_0x4abf('0x18')]()['then'](function(){var _0x2072f1=_0x79d84f[_0x4abf('0x19')]({'plain':!![]});var _0x3745da=_0x4abf('0x1a');return db[_0x4abf('0x1b')][_0x4abf('0x18')]({'where':{'type':_0x3745da,'resourceId':_0x2072f1['id']}})[_0x4abf('0x17')](function(){return _0x79d84f;});})['then'](function(){_0x178917[_0x4abf('0xd')](0xcc)['end']();});}};}function handleEntityNotFound(_0x11b45b){return function(_0x38768b){if(!_0x38768b){_0x11b45b[_0x4abf('0xc')](0x194);}return _0x38768b;};}function handleError(_0xfa066e,_0x2044f9){_0x2044f9=_0x2044f9||0x1f4;return function(_0x186023){logger[_0x4abf('0x1c')](_0x186023[_0x4abf('0x1d')]);if(_0x186023[_0x4abf('0x1e')]){delete _0x186023[_0x4abf('0x1e')];}_0xfa066e[_0x4abf('0xd')](_0x2044f9)[_0x4abf('0x1f')](_0x186023);};}exports[_0x4abf('0x20')]=function(_0x5cb8dc,_0x58f8d7){var _0x56c923={};var _0x5de50d={'count':0x0,'rows':[]};var _0x42c656=_[_0x4abf('0x21')](db[_0x4abf('0x22')][_0x4abf('0x23')],function(_0x3a3668){return{'name':_0x3a3668['fieldName'],'type':_0x3a3668[_0x4abf('0x24')][_0x4abf('0x25')]};});_0x56c923=qs['getOptions'](_0x42c656,_0x5cb8dc);var _0xd08200={'where':_0x56c923[_0x4abf('0x26')]};return db[_0x4abf('0x22')][_0x4abf('0x13')](_0xd08200)[_0x4abf('0x17')](function(_0xec4417){_0x5de50d[_0x4abf('0x13')]=_0xec4417;_0x56c923[_0x4abf('0x27')]=qs['include'](_0x5cb8dc[_0x4abf('0x28')]);return db['ChatQueue'][_0x4abf('0x29')](_0x56c923);})[_0x4abf('0x17')](function(_0x2c4650){_0x5de50d['rows']=_0x2c4650;return _0x5de50d;})[_0x4abf('0x17')](respondWithFilteredResult(_0x58f8d7,_0x56c923))['catch'](handleError(_0x58f8d7,null));};exports[_0x4abf('0x2a')]=function(_0x231b39,_0x12a277){var _0x34a12f={'raw':!![],'where':{'id':_0x231b39[_0x4abf('0x2b')]['id']}},_0x5d90e9={};_0x5d90e9[_0x4abf('0x2c')]=_[_0x4abf('0x2d')](db['ChatQueue']['rawAttributes']);_0x5d90e9[_0x4abf('0x28')]=_[_0x4abf('0x2d')](_0x231b39[_0x4abf('0x28')]);_0x5d90e9[_0x4abf('0x2e')]=_['intersection'](_0x5d90e9['model'],_0x5d90e9[_0x4abf('0x28')]);_0x34a12f[_0x4abf('0x2f')]=_[_0x4abf('0x30')](_0x5d90e9['model'],qs[_0x4abf('0x31')](_0x231b39[_0x4abf('0x28')]['fields']));_0x34a12f['attributes']=_0x34a12f[_0x4abf('0x2f')][_0x4abf('0x32')]?_0x34a12f[_0x4abf('0x2f')]:_0x5d90e9[_0x4abf('0x2c')];if(_0x231b39['query'][_0x4abf('0x33')]){_0x34a12f[_0x4abf('0x27')]=[{'all':!![]}];}_0x34a12f=_[_0x4abf('0x34')]({},_0x34a12f,_0x231b39['options']);return db[_0x4abf('0x22')][_0x4abf('0x35')](_0x34a12f)[_0x4abf('0x17')](handleEntityNotFound(_0x12a277,null))['then'](respondWithResult(_0x12a277,null))[_0x4abf('0x36')](handleError(_0x12a277,null));};exports[_0x4abf('0x37')]=function(_0x3d78f4,_0x2a243e){return db[_0x4abf('0x22')][_0x4abf('0x37')](_0x3d78f4[_0x4abf('0x38')],{})[_0x4abf('0x17')](function(_0x574548){var _0x1c17cd=_0x3d78f4['user']['get']({'plain':!![]});if(!_0x1c17cd)throw new Error(_0x4abf('0x39'));if(_0x1c17cd[_0x4abf('0x3a')]===_0x4abf('0x3b')){var _0x1e2377=_0x574548[_0x4abf('0x19')]({'plain':!![]});var _0x505339=_0x4abf('0x1a');return db[_0x4abf('0x3c')][_0x4abf('0x35')]({'where':{'name':_0x505339,'userProfileId':_0x1c17cd[_0x4abf('0x3d')]},'raw':!![]})[_0x4abf('0x17')](function(_0x49e4fd){if(_0x49e4fd&&_0x49e4fd[_0x4abf('0x3e')]===0x0){return db[_0x4abf('0x1b')][_0x4abf('0x37')]({'name':_0x1e2377[_0x4abf('0x1e')],'resourceId':_0x1e2377['id'],'type':_0x49e4fd['name'],'sectionId':_0x49e4fd['id']},{})[_0x4abf('0x17')](function(){return _0x574548;});}else{return _0x574548;}})[_0x4abf('0x36')](function(_0x531abe){logger[_0x4abf('0x1c')](_0x4abf('0x3f'),_0x531abe);throw _0x531abe;});}return _0x574548;})[_0x4abf('0x17')](respondWithResult(_0x2a243e,0xc9))[_0x4abf('0x36')](handleError(_0x2a243e,null));};exports[_0x4abf('0x16')]=function(_0x31ac3d,_0x40055d){if(_0x31ac3d[_0x4abf('0x38')]['id']){delete _0x31ac3d[_0x4abf('0x38')]['id'];}return db[_0x4abf('0x22')]['find']({'where':{'id':_0x31ac3d[_0x4abf('0x2b')]['id']}})['then'](handleEntityNotFound(_0x40055d,null))[_0x4abf('0x17')](saveUpdates(_0x31ac3d['body'],null))[_0x4abf('0x17')](respondWithResult(_0x40055d,null))[_0x4abf('0x36')](handleError(_0x40055d,null));};exports[_0x4abf('0x18')]=function(_0x2a90be,_0x2695e3){return db[_0x4abf('0x22')][_0x4abf('0x35')]({'where':{'id':_0x2a90be['params']['id']}})[_0x4abf('0x17')](handleEntityNotFound(_0x2695e3,null))[_0x4abf('0x17')](removeEntity(_0x2695e3,null))[_0x4abf('0x36')](handleError(_0x2695e3,null));};exports['describe']=function(_0x54d590,_0x2c6b76){return db[_0x4abf('0x22')][_0x4abf('0x40')]()['then'](respondWithResult(_0x2c6b76,null))[_0x4abf('0x36')](handleError(_0x2c6b76,null));};exports[_0x4abf('0x41')]=function(_0x28a756,_0xec661a){var _0x1f3a7d={'raw':!![],'where':{}},_0x14ac29={},_0x2fbf68;return db[_0x4abf('0x22')]['findOne']({'where':{'id':_0x28a756['params']['id']}})['then'](handleEntityNotFound(_0xec661a,null))[_0x4abf('0x17')](function(_0xec48ef){if(_0xec48ef){_0x2fbf68=_0xec48ef[_0x4abf('0x19')]({'plain':!![]});_0x14ac29[_0x4abf('0x2c')]=_[_0x4abf('0x2d')](db[_0x4abf('0x42')][_0x4abf('0x23')]);_0x14ac29['query']=_[_0x4abf('0x2d')](_0x28a756[_0x4abf('0x28')]);_0x14ac29[_0x4abf('0x2e')]=_[_0x4abf('0x30')](_0x14ac29[_0x4abf('0x2c')],_0x14ac29[_0x4abf('0x28')]);_0x1f3a7d[_0x4abf('0x2f')]=_[_0x4abf('0x30')](_0x14ac29[_0x4abf('0x2c')],qs[_0x4abf('0x31')](_0x28a756['query'][_0x4abf('0x31')]));_0x1f3a7d['attributes']=_0x1f3a7d[_0x4abf('0x2f')][_0x4abf('0x32')]?_0x1f3a7d[_0x4abf('0x2f')]:_0x14ac29[_0x4abf('0x2c')];if(!_0x28a756[_0x4abf('0x28')][_0x4abf('0x43')](_0x4abf('0x44'))){_0x1f3a7d[_0x4abf('0x12')]=qs[_0x4abf('0x12')](_0x28a756[_0x4abf('0x28')][_0x4abf('0x12')]);_0x1f3a7d['offset']=qs[_0x4abf('0x10')](_0x28a756[_0x4abf('0x28')]['offset']);}_0x1f3a7d[_0x4abf('0x45')]=qs[_0x4abf('0x46')](_0x28a756[_0x4abf('0x28')][_0x4abf('0x46')]);_0x1f3a7d[_0x4abf('0x26')]=qs[_0x4abf('0x2e')](_[_0x4abf('0x47')](_0x28a756[_0x4abf('0x28')],_0x14ac29[_0x4abf('0x2e')]));_0x1f3a7d[_0x4abf('0x26')]['ChatQueueId']=_0xec48ef['id'];if(_0x28a756[_0x4abf('0x28')][_0x4abf('0x48')]){_0x1f3a7d[_0x4abf('0x26')]=_['merge'](_0x1f3a7d[_0x4abf('0x26')],{'$or':_[_0x4abf('0x21')](_0x1f3a7d['attributes'],function(_0x1f531f){var _0x47f0ec={};_0x47f0ec[_0x1f531f]={'$like':'%'+_0x28a756[_0x4abf('0x28')][_0x4abf('0x48')]+'%'};return _0x47f0ec;})});}_0x1f3a7d=_[_0x4abf('0x34')]({},_0x1f3a7d,_0x28a756[_0x4abf('0x49')]);return db[_0x4abf('0x42')]['findAll'](_0x1f3a7d);}})['then'](function(_0x24cff2){if(_0x24cff2){return db['User'][_0x4abf('0x4a')]({'where':{'id':_['map'](_0x24cff2,_0x4abf('0x4b')),'role':_0x4abf('0x4c')},'attributes':['id',_0x4abf('0x1e'),_0x4abf('0x4d'),_0x4abf('0x4e'),_0x4abf('0x4f')]});}})['then'](function(_0xe7383e){if(_0xe7383e){return{'count':_0xe7383e['count'],'rows':_[_0x4abf('0x21')](_0xe7383e[_0x4abf('0x50')],function(_0x185d54){return{'membername':_0x185d54[_0x4abf('0x1e')],'UserId':_0x185d54['id'],'queue_name':_0x2fbf68[_0x4abf('0x1e')],'ChatQueueId':_0x2fbf68['id'],'interface':util[_0x4abf('0x51')](_0x4abf('0x52'),_0x4abf('0x53'),_0x185d54['name']),'penalty':0x0,'paused':_0x185d54['chatPause'],'createdAt':_0x185d54[_0x4abf('0x4f')],'updatedAt':_0x185d54[_0x4abf('0x4e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x4abf('0x17')](respondWithFilteredResult(_0xec661a,_0x1f3a7d))[_0x4abf('0x36')](handleError(_0xec661a,null));};exports[_0x4abf('0x54')]=function(_0x281c85,_0xd468a9){var _0x584084={};var _0x34232e={};var _0x4d89de;var _0xcf48fd;return db[_0x4abf('0x22')][_0x4abf('0x55')]({'where':{'id':_0x281c85['params']['id']}})[_0x4abf('0x17')](handleEntityNotFound(_0xd468a9,null))[_0x4abf('0x17')](function(_0xec860){if(_0xec860){_0x4d89de=_0xec860;_0x34232e[_0x4abf('0x2c')]=_[_0x4abf('0x2d')](db[_0x4abf('0x56')][_0x4abf('0x23')]);_0x34232e[_0x4abf('0x28')]=_['keys'](_0x281c85[_0x4abf('0x28')]);_0x34232e['filters']=_[_0x4abf('0x30')](_0x34232e[_0x4abf('0x2c')],_0x34232e['query']);_0x584084['attributes']=_[_0x4abf('0x30')](_0x34232e['model'],qs['fields'](_0x281c85[_0x4abf('0x28')]['fields']));_0x584084['attributes']=_0x584084['attributes']['length']?_0x584084[_0x4abf('0x2f')]:_0x34232e[_0x4abf('0x2c')];_0x584084['order']=qs['sort'](_0x281c85[_0x4abf('0x28')][_0x4abf('0x46')]);_0x584084['where']=qs['filters'](_[_0x4abf('0x47')](_0x281c85[_0x4abf('0x28')],_0x34232e[_0x4abf('0x2e')]));if(_0x281c85[_0x4abf('0x28')]['filter']){_0x584084['where']=_[_0x4abf('0x34')](_0x584084[_0x4abf('0x26')],{'$or':_[_0x4abf('0x21')](_0x584084['attributes'],function(_0x4937b8){var _0xd6f5e5={};_0xd6f5e5[_0x4937b8]={'$like':'%'+_0x281c85[_0x4abf('0x28')][_0x4abf('0x48')]+'%'};return _0xd6f5e5;})});}_0x584084=_[_0x4abf('0x34')]({},_0x584084,_0x281c85['options']);return _0x4d89de[_0x4abf('0x54')](_0x584084);}})[_0x4abf('0x17')](function(_0x484881){if(_0x484881){_0xcf48fd=_0x484881[_0x4abf('0x32')];if(!_0x281c85[_0x4abf('0x28')]['hasOwnProperty'](_0x4abf('0x44'))){_0x584084[_0x4abf('0x12')]=qs[_0x4abf('0x12')](_0x281c85[_0x4abf('0x28')][_0x4abf('0x12')]);_0x584084[_0x4abf('0x10')]=qs[_0x4abf('0x10')](_0x281c85[_0x4abf('0x28')]['offset']);}return _0x4d89de[_0x4abf('0x54')](_0x584084);}})['then'](function(_0x4012a0){if(_0x4012a0){return _0x4012a0?{'count':_0xcf48fd,'rows':_0x4012a0}:null;}})[_0x4abf('0x17')](respondWithResult(_0xd468a9,null))[_0x4abf('0x36')](handleError(_0xd468a9,null));};exports['addTeams']=function(_0x519fb7,_0x4da9a2){var _0x91f1e4=_0x519fb7['body'][_0x4abf('0x57')];return db[_0x4abf('0x56')][_0x4abf('0x29')]({'where':{'id':_0x91f1e4},'attributes':['id'],'include':[{'model':db[_0x4abf('0x58')],'as':_0x4abf('0x59'),'attributes':['id','name',_0x4abf('0x5a'),_0x4abf('0x5b'),'interface'],'raw':!![]}]})[_0x4abf('0x17')](function(_0x4f9a08){if(_0x4f9a08){var _0x73ebb=_[_0x4abf('0x5c')](_0x4f9a08,function(_0x1284a9){var _0x7d871f=_0x1284a9[_0x4abf('0x19')]({'plain':!![]});return _0x7d871f[_0x4abf('0x59')];});return db[_0x4abf('0x22')][_0x4abf('0x35')]({'where':{'id':_0x519fb7[_0x4abf('0x2b')]['id']}})[_0x4abf('0x17')](function(_0x413c32){return db['sequelize'][_0x4abf('0x5d')](function(_0x545df7){return _0x413c32[_0x4abf('0x5e')](_0x91f1e4,{'transaction':_0x545df7})[_0x4abf('0x17')](function(){return BPromise[_0x4abf('0x5f')](_0x73ebb,function(_0x466fe5){return db[_0x4abf('0x42')][_0x4abf('0x60')]({'where':{'UserId':_0x466fe5['id'],'ChatQueueId':_0x519fb7[_0x4abf('0x2b')]['id']},'transaction':_0x545df7});});})['then'](function(){_0x73ebb[_0x4abf('0x61')](function(_0x23a2d4){socket[_0x4abf('0x62')](_0x4abf('0x63'),{'UserId':_0x23a2d4['id'],'ChatQueueId':_0x413c32['id']});});});});});}})['then'](respondWithStatusCode(_0x4da9a2,null))[_0x4abf('0x36')](handleError(_0x4da9a2,null));};exports[_0x4abf('0x64')]=function(_0x5ea920,_0x25ee71){return db[_0x4abf('0x56')][_0x4abf('0x29')]({'where':{'id':_0x5ea920['query'][_0x4abf('0x57')]},'attributes':['id'],'include':[{'model':db[_0x4abf('0x58')],'as':_0x4abf('0x59'),'attributes':['id'],'raw':!![]}]})[_0x4abf('0x17')](handleEntityNotFound(_0x25ee71,null))[_0x4abf('0x17')](function(_0x115e27){var _0x3809ff=_[_0x4abf('0x21')](_0x115e27,'id');var _0x15b882=[];var _0x5475ca=[];var _0x4ef80d=squel[_0x4abf('0x65')]();_0x4ef80d[_0x4abf('0x66')](_0x4abf('0x67'))[_0x4abf('0x68')]('team_has_chat_queues','tq')[_0x4abf('0x69')](_0x4abf('0x6a'),'ut',_0x4abf('0x6b'))[_0x4abf('0x26')](_0x4abf('0x6c'),_0x5ea920[_0x4abf('0x2b')]['id']);for(var _0x3a056b=0x0;_0x3a056b<_0x115e27[_0x4abf('0x32')];_0x3a056b+=0x1){let _0x305d12=_0x115e27[_0x3a056b];for(var _0x156fdd=0x0;_0x156fdd<_0x305d12[_0x4abf('0x59')][_0x4abf('0x32')];_0x156fdd+=0x1){let _0x4b3e33=_0x305d12[_0x4abf('0x59')][_0x156fdd];var _0x5bf25d=_0x4ef80d[_0x4abf('0x6d')]();_0x5bf25d[_0x4abf('0x26')](_0x4abf('0x6e'),_0x4b3e33['id']);_0x5475ca[_0x4abf('0x6f')](db['sequelize'][_0x4abf('0x28')](_0x5bf25d[_0x4abf('0x70')](),{'type':db[_0x4abf('0x71')][_0x4abf('0x72')]['SELECT']})[_0x4abf('0x17')](function(_0x23aa05){if(_0x23aa05[_0x4abf('0x32')]===0x1){return _0x4b3e33['id'];}else{var _0x4b8da9=_[_0x4abf('0x73')](_[_0x4abf('0x21')](_0x23aa05,'TeamId'),function(_0x4bb8f){return _[_0x4abf('0x74')](_0x3809ff,_0x4bb8f);});if(_0x4b8da9){return _0x4b3e33['id'];}}}));}}return BPromise[_0x4abf('0x75')](_0x5475ca)[_0x4abf('0x17')](function(_0x4a39f6){_0x15b882=_(_0x15b882)[_0x4abf('0x76')](_0x4a39f6)['compact']()[_0x4abf('0x77')]();return db[_0x4abf('0x22')]['find']({'where':{'id':_0x5ea920[_0x4abf('0x2b')]['id']}})[_0x4abf('0x17')](function(_0x1bc6fa){return db[_0x4abf('0x71')][_0x4abf('0x5d')](function(_0x109c52){return _0x1bc6fa[_0x4abf('0x64')](_0x5ea920[_0x4abf('0x28')]['ids'],{'transaction':_0x109c52})[_0x4abf('0x17')](function(){if(!_['isEmpty'](_0x15b882)){return _0x1bc6fa['removeAgents'](_0x15b882,{'transaction':_0x109c52});}})[_0x4abf('0x17')](function(){_0x15b882[_0x4abf('0x61')](function(_0x38a577){socket['emit'](_0x4abf('0x78'),{'UserId':_0x38a577,'ChatQueueId':_0x1bc6fa['id']});});});});});});})[_0x4abf('0x17')](respondWithStatusCode(_0x25ee71,null))[_0x4abf('0x36')](handleError(_0x25ee71,null));};exports[_0x4abf('0x79')]=function(_0x474fdd,_0x1ad492){return db[_0x4abf('0x22')][_0x4abf('0x35')]({'where':{'id':_0x474fdd[_0x4abf('0x2b')]['id']}})[_0x4abf('0x17')](handleEntityNotFound(_0x1ad492,null))['then'](function(_0x371639){if(_0x371639){return _0x371639['addAgents'](_0x474fdd['body'][_0x4abf('0x57')],_[_0x4abf('0x7a')](_0x474fdd[_0x4abf('0x38')],[_0x4abf('0x57'),'id'])||{})[_0x4abf('0x7b')](function(_0x67f9a4){for(var _0x5aef6e=0x0;_0x5aef6e<_0x474fdd[_0x4abf('0x38')]['ids'][_0x4abf('0x32')];_0x5aef6e+=0x1){socket[_0x4abf('0x62')](_0x4abf('0x63'),{'UserId':Number(_0x474fdd[_0x4abf('0x38')][_0x4abf('0x57')][_0x5aef6e]),'ChatQueueId':Number(_0x474fdd['params']['id'])});}return _0x67f9a4;});}})['then'](respondWithResult(_0x1ad492,null))[_0x4abf('0x36')](handleError(_0x1ad492,null));};exports[_0x4abf('0x7c')]=function(_0x56df70,_0x3e70bd){return db['ChatQueue'][_0x4abf('0x35')]({'where':{'id':_0x56df70[_0x4abf('0x2b')]['id']}})['then'](handleEntityNotFound(_0x3e70bd,null))[_0x4abf('0x17')](function(_0x198776){if(_0x198776){return _0x198776[_0x4abf('0x7c')](_0x56df70[_0x4abf('0x28')][_0x4abf('0x57')])[_0x4abf('0x17')](function(){if(_['isArray'](_0x56df70[_0x4abf('0x28')]['ids'])){for(var _0x2d9aeb=0x0;_0x2d9aeb<_0x56df70[_0x4abf('0x28')]['ids'][_0x4abf('0x32')];_0x2d9aeb+=0x1){socket[_0x4abf('0x62')](_0x4abf('0x78'),{'UserId':Number(_0x56df70[_0x4abf('0x28')][_0x4abf('0x57')][_0x2d9aeb]),'ChatQueueId':Number(_0x56df70[_0x4abf('0x2b')]['id'])});}}else{socket[_0x4abf('0x62')]('userChatQueue:remove',{'UserId':Number(_0x56df70[_0x4abf('0x28')][_0x4abf('0x57')]),'ChatQueueId':Number(_0x56df70[_0x4abf('0x2b')]['id'])});}});}})[_0x4abf('0x17')](respondWithStatusCode(_0x3e70bd,null))['catch'](handleError(_0x3e70bd,null));};exports[_0x4abf('0x7d')]=function(_0x36c929,_0x43f626){var _0x235b68={};var _0xb55a4={};var _0x498ceb;var _0x476963;return db['ChatQueue'][_0x4abf('0x55')]({'where':{'id':_0x36c929['params']['id']}})[_0x4abf('0x17')](handleEntityNotFound(_0x43f626,null))[_0x4abf('0x17')](function(_0x1d9ac3){if(_0x1d9ac3){_0x498ceb=_0x1d9ac3;_0xb55a4[_0x4abf('0x2c')]=_['keys'](db[_0x4abf('0x58')][_0x4abf('0x23')]);_0xb55a4['query']=_[_0x4abf('0x2d')](_0x36c929[_0x4abf('0x28')]);_0xb55a4[_0x4abf('0x2e')]=_[_0x4abf('0x30')](_0xb55a4[_0x4abf('0x2c')],_0xb55a4[_0x4abf('0x28')]);_0x235b68[_0x4abf('0x2f')]=_[_0x4abf('0x30')](_0xb55a4[_0x4abf('0x2c')],qs[_0x4abf('0x31')](_0x36c929['query']['fields']));_0x235b68[_0x4abf('0x2f')]=_0x235b68[_0x4abf('0x2f')][_0x4abf('0x32')]?_0x235b68[_0x4abf('0x2f')]:_0xb55a4[_0x4abf('0x2c')];_0x235b68[_0x4abf('0x45')]=qs[_0x4abf('0x46')](_0x36c929[_0x4abf('0x28')][_0x4abf('0x46')]);_0x235b68[_0x4abf('0x26')]=qs[_0x4abf('0x2e')](_[_0x4abf('0x47')](_0x36c929[_0x4abf('0x28')],_0xb55a4['filters']));if(_0x36c929[_0x4abf('0x28')][_0x4abf('0x48')]){_0x235b68[_0x4abf('0x26')]=_[_0x4abf('0x34')](_0x235b68[_0x4abf('0x26')],{'$or':_[_0x4abf('0x21')](_0x235b68['attributes'],function(_0x41c95f){var _0x192c85={};_0x192c85[_0x41c95f]={'$like':'%'+_0x36c929[_0x4abf('0x28')][_0x4abf('0x48')]+'%'};return _0x192c85;})});}_0x235b68=_['merge']({},_0x235b68,_0x36c929[_0x4abf('0x49')]);return _0x498ceb[_0x4abf('0x7d')](_0x235b68);}})[_0x4abf('0x17')](function(_0x2d9546){if(_0x2d9546){_0x476963=_0x2d9546[_0x4abf('0x32')];if(!_0x36c929[_0x4abf('0x28')][_0x4abf('0x43')]('nolimit')){_0x235b68['limit']=qs[_0x4abf('0x12')](_0x36c929[_0x4abf('0x28')][_0x4abf('0x12')]);_0x235b68[_0x4abf('0x10')]=qs[_0x4abf('0x10')](_0x36c929[_0x4abf('0x28')][_0x4abf('0x10')]);}return _0x498ceb[_0x4abf('0x7d')](_0x235b68);}})['then'](function(_0x1063b8){if(_0x1063b8){return _0x1063b8?{'count':_0x476963,'rows':_0x1063b8}:null;}})[_0x4abf('0x17')](respondWithResult(_0x43f626,null))[_0x4abf('0x36')](handleError(_0x43f626,null));};
\ No newline at end of file
+var _0x32ef=['sort','pick','ChatQueueId','findAll','User','findAndCountAll','agent','chatPause','updatedAt','createdAt','format','SIP','getTeams','Team','filter','nolimit','addTeams','ids','online','voicePause','interface','flatMap','Agents','sequelize','transaction','each','forEach','emit','userChatQueue:save','removeTeams','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ChatQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','every','includes','all','value','removeAgents','userChatQueue:remove','addAgents','omit','spread','isArray','util','lodash','squel','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatQueue.socket','register','sendStatus','status','end','offset','undefined','limit','count','json','update','then','destroy','get','ChatQueues','UserProfileResource','error','stack','name','send','index','map','ChatQueue','fieldName','type','key','getOptions','where','query','rows','catch','show','model','keys','filters','attributes','intersection','fields','length','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','UserChatQueue','rawAttributes','hasOwnProperty','order'];(function(_0x5a5f9e,_0x4a89c2){var _0x1bec0c=function(_0xcd2793){while(--_0xcd2793){_0x5a5f9e['push'](_0x5a5f9e['shift']());}};_0x1bec0c(++_0x4a89c2);}(_0x32ef,0x1a5));var _0xf32e=function(_0x5c9d0f,_0x2d0b5f){_0x5c9d0f=_0x5c9d0f-0x0;var _0x39f1d8=_0x32ef[_0x5c9d0f];return _0x39f1d8;};'use strict';var BPromise=require('bluebird');var util=require(_0xf32e('0x0'));var _=require(_0xf32e('0x1'));var squel=require(_0xf32e('0x2'));var Redis=require('ioredis');var qs=require(_0xf32e('0x3'));var logger=require(_0xf32e('0x4'))(_0xf32e('0x5'));var config=require(_0xf32e('0x6'));var db=require(_0xf32e('0x7'))['db'];config[_0xf32e('0x8')]=_[_0xf32e('0x9')](config[_0xf32e('0x8')],{'host':_0xf32e('0xa'),'port':0x18eb});var socket=require(_0xf32e('0xb'))(new Redis(config[_0xf32e('0x8')]));require(_0xf32e('0xc'))[_0xf32e('0xd')](socket);function respondWithStatusCode(_0x53cea4,_0x677c33){_0x677c33=_0x677c33||0xcc;return function(_0x1e4e94){if(_0x1e4e94){return _0x53cea4[_0xf32e('0xe')](_0x677c33);}return _0x53cea4[_0xf32e('0xf')](_0x677c33)[_0xf32e('0x10')]();};}function respondWithResult(_0x45ccac,_0x6727fa){_0x6727fa=_0x6727fa||0xc8;return function(_0x499c38){if(_0x499c38){return _0x45ccac[_0xf32e('0xf')](_0x6727fa)['json'](_0x499c38);}};}function respondWithFilteredResult(_0x26131e,_0x4b2109){return function(_0x451098){if(_0x451098){var _0x2b372d=typeof _0x4b2109[_0xf32e('0x11')]===_0xf32e('0x12')&&typeof _0x4b2109[_0xf32e('0x13')]===_0xf32e('0x12');var _0x262b18=_0x451098[_0xf32e('0x14')];var _0x15041e=_0x2b372d?0x0:_0x4b2109[_0xf32e('0x11')];var _0x22cc4c=_0x2b372d?_0x451098[_0xf32e('0x14')]:_0x4b2109['offset']+_0x4b2109[_0xf32e('0x13')];var _0x1884b4;if(_0x22cc4c>=_0x262b18){_0x22cc4c=_0x262b18;_0x1884b4=0xc8;}else{_0x1884b4=0xce;}_0x26131e[_0xf32e('0xf')](_0x1884b4);return _0x26131e['set']('Content-Range',_0x15041e+'-'+_0x22cc4c+'/'+_0x262b18)[_0xf32e('0x15')](_0x451098);}return null;};}function saveUpdates(_0x2241bc){return function(_0xbcc4c1){if(_0xbcc4c1){return _0xbcc4c1[_0xf32e('0x16')](_0x2241bc)[_0xf32e('0x17')](function(_0x1a8eea){return _0x1a8eea;});}return null;};}function removeEntity(_0x36f9b1){return function(_0x43fe5e){if(_0x43fe5e){return _0x43fe5e[_0xf32e('0x18')]()[_0xf32e('0x17')](function(){var _0x2ff9b9=_0x43fe5e[_0xf32e('0x19')]({'plain':!![]});var _0x5df040=_0xf32e('0x1a');return db[_0xf32e('0x1b')][_0xf32e('0x18')]({'where':{'type':_0x5df040,'resourceId':_0x2ff9b9['id']}})[_0xf32e('0x17')](function(){return _0x43fe5e;});})[_0xf32e('0x17')](function(){_0x36f9b1[_0xf32e('0xf')](0xcc)[_0xf32e('0x10')]();});}};}function handleEntityNotFound(_0x149b9a){return function(_0x2c9f2d){if(!_0x2c9f2d){_0x149b9a[_0xf32e('0xe')](0x194);}return _0x2c9f2d;};}function handleError(_0x5d5c34,_0x236eaa){_0x236eaa=_0x236eaa||0x1f4;return function(_0x471e2e){logger[_0xf32e('0x1c')](_0x471e2e[_0xf32e('0x1d')]);if(_0x471e2e[_0xf32e('0x1e')]){delete _0x471e2e[_0xf32e('0x1e')];}_0x5d5c34[_0xf32e('0xf')](_0x236eaa)[_0xf32e('0x1f')](_0x471e2e);};}exports[_0xf32e('0x20')]=function(_0x2078a9,_0x3ebcb6){var _0x2c1c09={};var _0x50b3c4={'count':0x0,'rows':[]};var _0x4a9cc6=_[_0xf32e('0x21')](db[_0xf32e('0x22')]['rawAttributes'],function(_0x4ef589){return{'name':_0x4ef589[_0xf32e('0x23')],'type':_0x4ef589[_0xf32e('0x24')][_0xf32e('0x25')]};});_0x2c1c09=qs[_0xf32e('0x26')](_0x4a9cc6,_0x2078a9);var _0x4c8c1c={'where':_0x2c1c09[_0xf32e('0x27')]};return db['ChatQueue'][_0xf32e('0x14')](_0x4c8c1c)[_0xf32e('0x17')](function(_0x257026){_0x50b3c4[_0xf32e('0x14')]=_0x257026;_0x2c1c09['include']=qs['include'](_0x2078a9[_0xf32e('0x28')]);return db[_0xf32e('0x22')]['findAll'](_0x2c1c09);})['then'](function(_0x26dd52){_0x50b3c4[_0xf32e('0x29')]=_0x26dd52;return _0x50b3c4;})[_0xf32e('0x17')](respondWithFilteredResult(_0x3ebcb6,_0x2c1c09))[_0xf32e('0x2a')](handleError(_0x3ebcb6,null));};exports[_0xf32e('0x2b')]=function(_0x339172,_0xc1b59e){var _0x444ab3={'raw':!![],'where':{'id':_0x339172['params']['id']}},_0xc5f8e4={};_0xc5f8e4[_0xf32e('0x2c')]=_[_0xf32e('0x2d')](db[_0xf32e('0x22')]['rawAttributes']);_0xc5f8e4[_0xf32e('0x28')]=_[_0xf32e('0x2d')](_0x339172[_0xf32e('0x28')]);_0xc5f8e4[_0xf32e('0x2e')]=_['intersection'](_0xc5f8e4['model'],_0xc5f8e4['query']);_0x444ab3[_0xf32e('0x2f')]=_[_0xf32e('0x30')](_0xc5f8e4['model'],qs[_0xf32e('0x31')](_0x339172[_0xf32e('0x28')][_0xf32e('0x31')]));_0x444ab3[_0xf32e('0x2f')]=_0x444ab3[_0xf32e('0x2f')][_0xf32e('0x32')]?_0x444ab3[_0xf32e('0x2f')]:_0xc5f8e4['model'];if(_0x339172[_0xf32e('0x28')]['includeAll']){_0x444ab3['include']=[{'all':!![]}];}_0x444ab3=_[_0xf32e('0x33')]({},_0x444ab3,_0x339172[_0xf32e('0x34')]);return db[_0xf32e('0x22')][_0xf32e('0x35')](_0x444ab3)[_0xf32e('0x17')](handleEntityNotFound(_0xc1b59e,null))['then'](respondWithResult(_0xc1b59e,null))[_0xf32e('0x2a')](handleError(_0xc1b59e,null));};exports[_0xf32e('0x36')]=function(_0x414386,_0x163900){return db[_0xf32e('0x22')]['create'](_0x414386[_0xf32e('0x37')],{})['then'](function(_0x2a2acf){var _0x425552=_0x414386[_0xf32e('0x38')][_0xf32e('0x19')]({'plain':!![]});if(!_0x425552)throw new Error(_0xf32e('0x39'));if(_0x425552[_0xf32e('0x3a')]===_0xf32e('0x38')){var _0x2ce7d1=_0x2a2acf['get']({'plain':!![]});var _0x1ac158=_0xf32e('0x1a');return db[_0xf32e('0x3b')][_0xf32e('0x35')]({'where':{'name':_0x1ac158,'userProfileId':_0x425552[_0xf32e('0x3c')]},'raw':!![]})['then'](function(_0x2514b6){if(_0x2514b6&&_0x2514b6[_0xf32e('0x3d')]===0x0){return db[_0xf32e('0x1b')][_0xf32e('0x36')]({'name':_0x2ce7d1['name'],'resourceId':_0x2ce7d1['id'],'type':_0x2514b6[_0xf32e('0x1e')],'sectionId':_0x2514b6['id']},{})['then'](function(){return _0x2a2acf;});}else{return _0x2a2acf;}})['catch'](function(_0x239ed7){logger[_0xf32e('0x1c')](_0xf32e('0x3e'),_0x239ed7);throw _0x239ed7;});}return _0x2a2acf;})[_0xf32e('0x17')](respondWithResult(_0x163900,0xc9))[_0xf32e('0x2a')](handleError(_0x163900,null));};exports[_0xf32e('0x16')]=function(_0x2ed32f,_0xe0116c){if(_0x2ed32f[_0xf32e('0x37')]['id']){delete _0x2ed32f[_0xf32e('0x37')]['id'];}return db[_0xf32e('0x22')][_0xf32e('0x35')]({'where':{'id':_0x2ed32f[_0xf32e('0x3f')]['id']}})[_0xf32e('0x17')](handleEntityNotFound(_0xe0116c,null))['then'](saveUpdates(_0x2ed32f[_0xf32e('0x37')],null))['then'](respondWithResult(_0xe0116c,null))['catch'](handleError(_0xe0116c,null));};exports[_0xf32e('0x18')]=function(_0x37da5d,_0x32c2e1){return db[_0xf32e('0x22')][_0xf32e('0x35')]({'where':{'id':_0x37da5d['params']['id']}})[_0xf32e('0x17')](handleEntityNotFound(_0x32c2e1,null))[_0xf32e('0x17')](removeEntity(_0x32c2e1,null))['catch'](handleError(_0x32c2e1,null));};exports[_0xf32e('0x40')]=function(_0x4c4fac,_0x4b109b){return db[_0xf32e('0x22')][_0xf32e('0x40')]()[_0xf32e('0x17')](respondWithResult(_0x4b109b,null))[_0xf32e('0x2a')](handleError(_0x4b109b,null));};exports[_0xf32e('0x41')]=function(_0x350742,_0x3be1f8){var _0x54df6f={'raw':!![],'where':{}},_0x35160e={},_0x4b02bd;return db[_0xf32e('0x22')][_0xf32e('0x42')]({'where':{'id':_0x350742[_0xf32e('0x3f')]['id']}})['then'](handleEntityNotFound(_0x3be1f8,null))[_0xf32e('0x17')](function(_0x5f214f){if(_0x5f214f){_0x4b02bd=_0x5f214f[_0xf32e('0x19')]({'plain':!![]});_0x35160e[_0xf32e('0x2c')]=_[_0xf32e('0x2d')](db[_0xf32e('0x43')][_0xf32e('0x44')]);_0x35160e['query']=_[_0xf32e('0x2d')](_0x350742[_0xf32e('0x28')]);_0x35160e['filters']=_['intersection'](_0x35160e[_0xf32e('0x2c')],_0x35160e['query']);_0x54df6f[_0xf32e('0x2f')]=_['intersection'](_0x35160e[_0xf32e('0x2c')],qs['fields'](_0x350742['query'][_0xf32e('0x31')]));_0x54df6f[_0xf32e('0x2f')]=_0x54df6f[_0xf32e('0x2f')][_0xf32e('0x32')]?_0x54df6f['attributes']:_0x35160e[_0xf32e('0x2c')];if(!_0x350742['query'][_0xf32e('0x45')]('nolimit')){_0x54df6f[_0xf32e('0x13')]=qs['limit'](_0x350742[_0xf32e('0x28')][_0xf32e('0x13')]);_0x54df6f[_0xf32e('0x11')]=qs['offset'](_0x350742[_0xf32e('0x28')][_0xf32e('0x11')]);}_0x54df6f[_0xf32e('0x46')]=qs[_0xf32e('0x47')](_0x350742[_0xf32e('0x28')][_0xf32e('0x47')]);_0x54df6f['where']=qs[_0xf32e('0x2e')](_[_0xf32e('0x48')](_0x350742[_0xf32e('0x28')],_0x35160e['filters']));_0x54df6f[_0xf32e('0x27')][_0xf32e('0x49')]=_0x5f214f['id'];if(_0x350742[_0xf32e('0x28')]['filter']){_0x54df6f['where']=_[_0xf32e('0x33')](_0x54df6f['where'],{'$or':_[_0xf32e('0x21')](_0x54df6f['attributes'],function(_0x198ede){var _0x4ef35e={};_0x4ef35e[_0x198ede]={'$like':'%'+_0x350742[_0xf32e('0x28')]['filter']+'%'};return _0x4ef35e;})});}_0x54df6f=_['merge']({},_0x54df6f,_0x350742[_0xf32e('0x34')]);return db[_0xf32e('0x43')][_0xf32e('0x4a')](_0x54df6f);}})[_0xf32e('0x17')](function(_0x460bec){if(_0x460bec){return db[_0xf32e('0x4b')][_0xf32e('0x4c')]({'where':{'id':_[_0xf32e('0x21')](_0x460bec,'UserId'),'role':_0xf32e('0x4d')},'attributes':['id',_0xf32e('0x1e'),_0xf32e('0x4e'),_0xf32e('0x4f'),_0xf32e('0x50')]});}})[_0xf32e('0x17')](function(_0x4cf107){if(_0x4cf107){return{'count':_0x4cf107['count'],'rows':_[_0xf32e('0x21')](_0x4cf107['rows'],function(_0x52b815){return{'membername':_0x52b815[_0xf32e('0x1e')],'UserId':_0x52b815['id'],'queue_name':_0x4b02bd[_0xf32e('0x1e')],'ChatQueueId':_0x4b02bd['id'],'interface':util[_0xf32e('0x51')]('%s/%s',_0xf32e('0x52'),_0x52b815[_0xf32e('0x1e')]),'penalty':0x0,'paused':_0x52b815[_0xf32e('0x4e')],'createdAt':_0x52b815[_0xf32e('0x50')],'updatedAt':_0x52b815[_0xf32e('0x4f')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x3be1f8,_0x54df6f))[_0xf32e('0x2a')](handleError(_0x3be1f8,null));};exports[_0xf32e('0x53')]=function(_0x86e16b,_0x4f993c){var _0x4b5233={};var _0x3f6268={};var _0x224daf;var _0x354c9b;return db[_0xf32e('0x22')][_0xf32e('0x42')]({'where':{'id':_0x86e16b[_0xf32e('0x3f')]['id']}})[_0xf32e('0x17')](handleEntityNotFound(_0x4f993c,null))[_0xf32e('0x17')](function(_0x37350b){if(_0x37350b){_0x224daf=_0x37350b;_0x3f6268[_0xf32e('0x2c')]=_['keys'](db[_0xf32e('0x54')][_0xf32e('0x44')]);_0x3f6268['query']=_[_0xf32e('0x2d')](_0x86e16b['query']);_0x3f6268['filters']=_[_0xf32e('0x30')](_0x3f6268[_0xf32e('0x2c')],_0x3f6268[_0xf32e('0x28')]);_0x4b5233['attributes']=_[_0xf32e('0x30')](_0x3f6268[_0xf32e('0x2c')],qs[_0xf32e('0x31')](_0x86e16b[_0xf32e('0x28')][_0xf32e('0x31')]));_0x4b5233['attributes']=_0x4b5233['attributes'][_0xf32e('0x32')]?_0x4b5233[_0xf32e('0x2f')]:_0x3f6268['model'];_0x4b5233[_0xf32e('0x46')]=qs[_0xf32e('0x47')](_0x86e16b['query'][_0xf32e('0x47')]);_0x4b5233[_0xf32e('0x27')]=qs[_0xf32e('0x2e')](_[_0xf32e('0x48')](_0x86e16b[_0xf32e('0x28')],_0x3f6268['filters']));if(_0x86e16b['query'][_0xf32e('0x55')]){_0x4b5233[_0xf32e('0x27')]=_['merge'](_0x4b5233['where'],{'$or':_[_0xf32e('0x21')](_0x4b5233[_0xf32e('0x2f')],function(_0xbef504){var _0x513055={};_0x513055[_0xbef504]={'$like':'%'+_0x86e16b[_0xf32e('0x28')][_0xf32e('0x55')]+'%'};return _0x513055;})});}_0x4b5233=_['merge']({},_0x4b5233,_0x86e16b['options']);return _0x224daf[_0xf32e('0x53')](_0x4b5233);}})[_0xf32e('0x17')](function(_0x17399c){if(_0x17399c){_0x354c9b=_0x17399c[_0xf32e('0x32')];if(!_0x86e16b[_0xf32e('0x28')][_0xf32e('0x45')](_0xf32e('0x56'))){_0x4b5233[_0xf32e('0x13')]=qs[_0xf32e('0x13')](_0x86e16b[_0xf32e('0x28')][_0xf32e('0x13')]);_0x4b5233[_0xf32e('0x11')]=qs[_0xf32e('0x11')](_0x86e16b['query'][_0xf32e('0x11')]);}return _0x224daf[_0xf32e('0x53')](_0x4b5233);}})[_0xf32e('0x17')](function(_0x28bdb7){if(_0x28bdb7){return _0x28bdb7?{'count':_0x354c9b,'rows':_0x28bdb7}:null;}})['then'](respondWithResult(_0x4f993c,null))[_0xf32e('0x2a')](handleError(_0x4f993c,null));};exports[_0xf32e('0x57')]=function(_0x5ef81c,_0x5e5711){var _0x15a4f6=_0x5ef81c[_0xf32e('0x37')][_0xf32e('0x58')];return db[_0xf32e('0x54')][_0xf32e('0x4a')]({'where':{'id':_0x15a4f6},'attributes':['id'],'include':[{'model':db[_0xf32e('0x4b')],'as':'Agents','attributes':['id',_0xf32e('0x1e'),_0xf32e('0x59'),_0xf32e('0x5a'),_0xf32e('0x5b')],'raw':!![]}]})['then'](function(_0x32bbe6){if(_0x32bbe6){var _0x3f4aad=_[_0xf32e('0x5c')](_0x32bbe6,function(_0x286041){var _0x2dc004=_0x286041[_0xf32e('0x19')]({'plain':!![]});return _0x2dc004[_0xf32e('0x5d')];});return db[_0xf32e('0x22')][_0xf32e('0x35')]({'where':{'id':_0x5ef81c['params']['id']}})[_0xf32e('0x17')](function(_0x1e0b47){return db[_0xf32e('0x5e')][_0xf32e('0x5f')](function(_0x2cc611){return _0x1e0b47[_0xf32e('0x57')](_0x15a4f6,{'transaction':_0x2cc611})[_0xf32e('0x17')](function(){return BPromise[_0xf32e('0x60')](_0x3f4aad,function(_0x14bdcf){return db[_0xf32e('0x43')]['findOrCreate']({'where':{'UserId':_0x14bdcf['id'],'ChatQueueId':_0x5ef81c['params']['id']},'transaction':_0x2cc611});});})[_0xf32e('0x17')](function(){_0x3f4aad[_0xf32e('0x61')](function(_0x1ce756){socket[_0xf32e('0x62')](_0xf32e('0x63'),{'UserId':_0x1ce756['id'],'ChatQueueId':_0x1e0b47['id']});});});});});}})['then'](respondWithStatusCode(_0x5e5711,null))[_0xf32e('0x2a')](handleError(_0x5e5711,null));};exports[_0xf32e('0x64')]=function(_0x38c419,_0x5dbbc6){return db[_0xf32e('0x54')][_0xf32e('0x4a')]({'where':{'id':_0x38c419['query'][_0xf32e('0x58')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0xf32e('0x5d'),'attributes':['id'],'raw':!![]}]})[_0xf32e('0x17')](handleEntityNotFound(_0x5dbbc6,null))[_0xf32e('0x17')](function(_0x33f3bd){var _0x319c5d=_[_0xf32e('0x21')](_0x33f3bd,'id');var _0x3d1df8=[];var _0xfa1f2a=[];var _0x1ac08b=squel['select']();_0x1ac08b[_0xf32e('0x65')](_0xf32e('0x66'))[_0xf32e('0x67')](_0xf32e('0x68'),'tq')[_0xf32e('0x69')](_0xf32e('0x6a'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0xf32e('0x6b'),_0x38c419[_0xf32e('0x3f')]['id']);for(var _0x3dccf3=0x0;_0x3dccf3<_0x33f3bd[_0xf32e('0x32')];_0x3dccf3+=0x1){let _0x1591b9=_0x33f3bd[_0x3dccf3];for(var _0x504cca=0x0;_0x504cca<_0x1591b9[_0xf32e('0x5d')][_0xf32e('0x32')];_0x504cca+=0x1){let _0x43b7b0=_0x1591b9[_0xf32e('0x5d')][_0x504cca];var _0x29d647=_0x1ac08b[_0xf32e('0x6c')]();_0x29d647[_0xf32e('0x27')](_0xf32e('0x6d'),_0x43b7b0['id']);_0xfa1f2a[_0xf32e('0x6e')](db['sequelize'][_0xf32e('0x28')](_0x29d647['toString'](),{'type':db[_0xf32e('0x5e')][_0xf32e('0x6f')][_0xf32e('0x70')]})[_0xf32e('0x17')](function(_0x1e726a){if(_0x1e726a['length']===0x1){return _0x43b7b0['id'];}else{var _0x53a3e7=_[_0xf32e('0x71')](_[_0xf32e('0x21')](_0x1e726a,'TeamId'),function(_0x7d16e3){return _[_0xf32e('0x72')](_0x319c5d,_0x7d16e3);});if(_0x53a3e7){return _0x43b7b0['id'];}}}));}}return BPromise[_0xf32e('0x73')](_0xfa1f2a)[_0xf32e('0x17')](function(_0x21ee1a){_0x3d1df8=_(_0x3d1df8)['union'](_0x21ee1a)['compact']()[_0xf32e('0x74')]();return db[_0xf32e('0x22')][_0xf32e('0x35')]({'where':{'id':_0x38c419[_0xf32e('0x3f')]['id']}})[_0xf32e('0x17')](function(_0x1b89aa){return db['sequelize'][_0xf32e('0x5f')](function(_0x456241){return _0x1b89aa[_0xf32e('0x64')](_0x38c419[_0xf32e('0x28')][_0xf32e('0x58')],{'transaction':_0x456241})[_0xf32e('0x17')](function(){if(!_['isEmpty'](_0x3d1df8)){return _0x1b89aa[_0xf32e('0x75')](_0x3d1df8,{'transaction':_0x456241});}})[_0xf32e('0x17')](function(){_0x3d1df8[_0xf32e('0x61')](function(_0x11c295){socket[_0xf32e('0x62')](_0xf32e('0x76'),{'UserId':_0x11c295,'ChatQueueId':_0x1b89aa['id']});});});});});});})['then'](respondWithStatusCode(_0x5dbbc6,null))[_0xf32e('0x2a')](handleError(_0x5dbbc6,null));};exports[_0xf32e('0x77')]=function(_0x468fad,_0x4dd0e5){return db[_0xf32e('0x22')][_0xf32e('0x35')]({'where':{'id':_0x468fad['params']['id']}})['then'](handleEntityNotFound(_0x4dd0e5,null))[_0xf32e('0x17')](function(_0x330358){if(_0x330358){return _0x330358[_0xf32e('0x77')](_0x468fad['body'][_0xf32e('0x58')],_[_0xf32e('0x78')](_0x468fad['body'],[_0xf32e('0x58'),'id'])||{})[_0xf32e('0x79')](function(_0x1e7a12){for(var _0x471102=0x0;_0x471102<_0x468fad[_0xf32e('0x37')]['ids'][_0xf32e('0x32')];_0x471102+=0x1){socket['emit'](_0xf32e('0x63'),{'UserId':Number(_0x468fad[_0xf32e('0x37')][_0xf32e('0x58')][_0x471102]),'ChatQueueId':Number(_0x468fad[_0xf32e('0x3f')]['id'])});}return _0x1e7a12;});}})[_0xf32e('0x17')](respondWithResult(_0x4dd0e5,null))[_0xf32e('0x2a')](handleError(_0x4dd0e5,null));};exports[_0xf32e('0x75')]=function(_0x290242,_0x2634ad){return db['ChatQueue'][_0xf32e('0x35')]({'where':{'id':_0x290242[_0xf32e('0x3f')]['id']}})[_0xf32e('0x17')](handleEntityNotFound(_0x2634ad,null))['then'](function(_0x1acdc9){if(_0x1acdc9){return _0x1acdc9['removeAgents'](_0x290242[_0xf32e('0x28')][_0xf32e('0x58')])[_0xf32e('0x17')](function(){if(_[_0xf32e('0x7a')](_0x290242[_0xf32e('0x28')]['ids'])){for(var _0x56fbe4=0x0;_0x56fbe4<_0x290242[_0xf32e('0x28')][_0xf32e('0x58')]['length'];_0x56fbe4+=0x1){socket['emit'](_0xf32e('0x76'),{'UserId':Number(_0x290242[_0xf32e('0x28')][_0xf32e('0x58')][_0x56fbe4]),'ChatQueueId':Number(_0x290242['params']['id'])});}}else{socket['emit'](_0xf32e('0x76'),{'UserId':Number(_0x290242[_0xf32e('0x28')][_0xf32e('0x58')]),'ChatQueueId':Number(_0x290242['params']['id'])});}});}})[_0xf32e('0x17')](respondWithStatusCode(_0x2634ad,null))[_0xf32e('0x2a')](handleError(_0x2634ad,null));};exports['getAgents']=function(_0x3d0406,_0x4edb51){var _0x316058={};var _0x3952ad={};var _0x2c672b;var _0x25fbaa;return db[_0xf32e('0x22')][_0xf32e('0x42')]({'where':{'id':_0x3d0406[_0xf32e('0x3f')]['id']}})[_0xf32e('0x17')](handleEntityNotFound(_0x4edb51,null))[_0xf32e('0x17')](function(_0x579466){if(_0x579466){_0x2c672b=_0x579466;_0x3952ad[_0xf32e('0x2c')]=_['keys'](db['User']['rawAttributes']);_0x3952ad[_0xf32e('0x28')]=_[_0xf32e('0x2d')](_0x3d0406[_0xf32e('0x28')]);_0x3952ad[_0xf32e('0x2e')]=_[_0xf32e('0x30')](_0x3952ad[_0xf32e('0x2c')],_0x3952ad['query']);_0x316058[_0xf32e('0x2f')]=_[_0xf32e('0x30')](_0x3952ad['model'],qs[_0xf32e('0x31')](_0x3d0406[_0xf32e('0x28')]['fields']));_0x316058[_0xf32e('0x2f')]=_0x316058['attributes'][_0xf32e('0x32')]?_0x316058[_0xf32e('0x2f')]:_0x3952ad[_0xf32e('0x2c')];_0x316058[_0xf32e('0x46')]=qs['sort'](_0x3d0406['query']['sort']);_0x316058[_0xf32e('0x27')]=qs[_0xf32e('0x2e')](_[_0xf32e('0x48')](_0x3d0406[_0xf32e('0x28')],_0x3952ad[_0xf32e('0x2e')]));if(_0x3d0406['query'][_0xf32e('0x55')]){_0x316058[_0xf32e('0x27')]=_[_0xf32e('0x33')](_0x316058['where'],{'$or':_['map'](_0x316058[_0xf32e('0x2f')],function(_0x4eb25c){var _0x2a1c2c={};_0x2a1c2c[_0x4eb25c]={'$like':'%'+_0x3d0406[_0xf32e('0x28')][_0xf32e('0x55')]+'%'};return _0x2a1c2c;})});}_0x316058=_[_0xf32e('0x33')]({},_0x316058,_0x3d0406['options']);return _0x2c672b['getAgents'](_0x316058);}})[_0xf32e('0x17')](function(_0x103130){if(_0x103130){_0x25fbaa=_0x103130['length'];if(!_0x3d0406[_0xf32e('0x28')][_0xf32e('0x45')](_0xf32e('0x56'))){_0x316058['limit']=qs[_0xf32e('0x13')](_0x3d0406[_0xf32e('0x28')][_0xf32e('0x13')]);_0x316058[_0xf32e('0x11')]=qs[_0xf32e('0x11')](_0x3d0406[_0xf32e('0x28')][_0xf32e('0x11')]);}return _0x2c672b['getAgents'](_0x316058);}})[_0xf32e('0x17')](function(_0x2fe848){if(_0x2fe848){return _0x2fe848?{'count':_0x25fbaa,'rows':_0x2fe848}:null;}})['then'](respondWithResult(_0x4edb51,null))[_0xf32e('0x2a')](handleError(_0x4edb51,null));};
\ No newline at end of file