Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 1141f60..94b5de3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x434f=['fields','length','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','ChatQueues','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','getMembers','findOne','sort','ChatQueueId','UserChatQueue','findAndCountAll','UserId','chatPause','updatedAt','createdAt','rows','format','%s/%s','SIP','Team','getTeams','addTeams','ids','User','Agents','online','voicePause','interface','flatMap','sequelize','transaction','each','findOrCreate','forEach','emit','userChatQueue:save','select','field','tq.TeamId','team_has_chat_queues','join','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','TeamId','includes','union','compact','value','isEmpty','removeAgents','userChatQueue:remove','addAgents','spread','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','api','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','register','jayson/promise','client','http','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','destroy','get','UserProfileResource','stack','name','map','ChatQueue','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','hasOwnProperty','nolimit','order','where','pick','filter','merge','options','includeAll','findAll','show','params'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x434f,0xdc));var _0xf434=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x434f[_0x321bb2];return _0x9c12ed;};'use strict';var pdf=require(_0xf434('0x0'));var emlformat=require(_0xf434('0x1'));var rimraf=require(_0xf434('0x2'));var zipdir=require(_0xf434('0x3'));var jsonpatch=require(_0xf434('0x4'));var rp=require('request-promise');var moment=require(_0xf434('0x5'));var BPromise=require(_0xf434('0x6'));var Mustache=require(_0xf434('0x7'));var util=require(_0xf434('0x8'));var path=require(_0xf434('0x9'));var sox=require('sox');var csv=require(_0xf434('0xa'));var ejs=require(_0xf434('0xb'));var fs=require('fs');var _=require(_0xf434('0xc'));var squel=require('squel');var crypto=require(_0xf434('0xd'));var jsforce=require(_0xf434('0xe'));var deskjs=require(_0xf434('0xf'));var toCsv=require(_0xf434('0xa'));var querystring=require(_0xf434('0x10'));var Papa=require(_0xf434('0x11'));var Redis=require(_0xf434('0x12'));var authService=require(_0xf434('0x13'));var qs=require(_0xf434('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf434('0x15'));var utils=require('../../config/utils');var config=require(_0xf434('0x16'));var licenseUtil=require(_0xf434('0x17'));var db=require(_0xf434('0x18'))['db'];config['redis']=_[_0xf434('0x19')](config[_0xf434('0x1a')],{'host':'localhost','port':0x18eb});var socket=require(_0xf434('0x1b'))(new Redis(config['redis']));require('./chatQueue.socket')[_0xf434('0x1c')](socket);var jayson=require(_0xf434('0x1d'));var client=jayson[_0xf434('0x1e')][_0xf434('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x3c006a,_0x130742,_0x58cd62,_0xae279c){return new BPromise(function(_0x3710d6,_0x4e1a7c){var _0x397649=_0xae279c||client;return _0x397649[_0xf434('0x20')](_0x3c006a,_0x58cd62)[_0xf434('0x21')](function(_0x53c966){logger[_0xf434('0x22')](_0xf434('0x23'),_0x130742,_0xf434('0x24'));logger[_0xf434('0x25')](_0xf434('0x26'),_0x130742,_0xf434('0x24'),JSON[_0xf434('0x27')](_0x53c966));if(_0x53c966[_0xf434('0x28')]){if(_0x53c966[_0xf434('0x28')][_0xf434('0x29')]===0x1f4){logger[_0xf434('0x28')](_0xf434('0x23'),_0x130742,_0x53c966['error'][_0xf434('0x2a')]);return _0x4e1a7c(_0x53c966['error'][_0xf434('0x2a')]);}logger[_0xf434('0x28')](_0xf434('0x23'),_0x130742,_0x53c966[_0xf434('0x28')]['message']);return _0x3710d6(_0x53c966[_0xf434('0x28')][_0xf434('0x2a')]);}else{logger['info'](_0xf434('0x23'),_0x130742,_0xf434('0x24'));_0x3710d6(_0x53c966[_0xf434('0x2b')][_0xf434('0x2a')]);}})[_0xf434('0x2c')](function(_0xc2bc87){logger[_0xf434('0x28')](_0xf434('0x23'),_0x130742,_0xc2bc87);_0x4e1a7c(_0xc2bc87);});});}function respondWithStatusCode(_0x40f3dd,_0x3d8885){_0x3d8885=_0x3d8885||0xcc;return function(_0x48eaa7){if(_0x48eaa7){return _0x40f3dd[_0xf434('0x2d')](_0x3d8885);}return _0x40f3dd[_0xf434('0x2e')](_0x3d8885)[_0xf434('0x2f')]();};}function respondWithResult(_0x5da21a,_0x1b2498){_0x1b2498=_0x1b2498||0xc8;return function(_0x2da3a4){if(_0x2da3a4){return _0x5da21a[_0xf434('0x2e')](_0x1b2498)[_0xf434('0x30')](_0x2da3a4);}};}function respondWithFilteredResult(_0x11375b,_0x318087){return function(_0x35979d){if(_0x35979d){var _0x497fdd=_0x35979d[_0xf434('0x31')],_0x3796ab=_0x318087['offset'],_0x323267=_0x318087[_0xf434('0x32')]+_0x318087[_0xf434('0x33')],_0x202e29;if(_0x323267>=_0x497fdd){_0x323267=_0x497fdd;_0x202e29=0xc8;}else{_0x202e29=0xce;}_0x11375b[_0xf434('0x2e')](_0x202e29);return _0x11375b[_0xf434('0x34')](_0xf434('0x35'),_0x3796ab+'-'+_0x323267+'/'+_0x497fdd)[_0xf434('0x30')](_0x35979d);}return null;};}function patchUpdates(_0x15cf76){return function(_0x60da61){try{jsonpatch[_0xf434('0x36')](_0x60da61,_0x15cf76,!![]);}catch(_0xb2d525){return BPromise[_0xf434('0x37')](_0xb2d525);}return _0x60da61[_0xf434('0x38')]();};}function saveUpdates(_0x2d4b72,_0x2a97e7){return function(_0x50b9fa){if(_0x50b9fa){return _0x50b9fa['update'](_0x2d4b72)[_0xf434('0x21')](function(_0xb9d15f){return _0xb9d15f;});}return null;};}function removeEntity(_0x5d74f4,_0x4318a8){return function(_0x344728){if(_0x344728){return _0x344728[_0xf434('0x39')]()[_0xf434('0x21')](function(){var _0x282d38=_0x344728[_0xf434('0x3a')]({'plain':!![]});var _0x242c09='ChatQueues';return db[_0xf434('0x3b')][_0xf434('0x39')]({'where':{'type':_0x242c09,'resourceId':_0x282d38['id']}})['then'](function(){return _0x344728;});})[_0xf434('0x21')](function(){_0x5d74f4[_0xf434('0x2e')](0xcc)[_0xf434('0x2f')]();});}};}function handleEntityNotFound(_0x340d7d,_0x59861a){return function(_0x281e08){if(!_0x281e08){_0x340d7d[_0xf434('0x2d')](0x194);}return _0x281e08;};}function handleError(_0x326b98,_0x22f3e3){_0x22f3e3=_0x22f3e3||0x1f4;return function(_0x541fd8){logger[_0xf434('0x28')](_0x541fd8[_0xf434('0x3c')]);if(_0x541fd8['name']){delete _0x541fd8[_0xf434('0x3d')];}_0x326b98['status'](_0x22f3e3)['send'](_0x541fd8);};}exports['index']=function(_0x496535,_0x28f7d3){var _0x172c03={},_0x2415f9={},_0x1c49d6={'count':0x0,'rows':[]};var _0x5afab1=_[_0xf434('0x3e')](db[_0xf434('0x3f')][_0xf434('0x40')],function(_0x48644a){return{'name':_0x48644a[_0xf434('0x41')],'type':_0x48644a[_0xf434('0x42')][_0xf434('0x43')]};});_0x2415f9[_0xf434('0x44')]=_['map'](_0x5afab1,_0xf434('0x3d'));_0x2415f9[_0xf434('0x45')]=_[_0xf434('0x46')](_0x496535[_0xf434('0x45')]);_0x2415f9[_0xf434('0x47')]=_[_0xf434('0x48')](_0x2415f9[_0xf434('0x44')],_0x2415f9[_0xf434('0x45')]);_0x172c03[_0xf434('0x49')]=_[_0xf434('0x48')](_0x2415f9['model'],qs['fields'](_0x496535[_0xf434('0x45')]['fields']));_0x172c03['attributes']=_0x172c03[_0xf434('0x49')]['length']?_0x172c03['attributes']:_0x2415f9['model'];if(!_0x496535[_0xf434('0x45')][_0xf434('0x4a')](_0xf434('0x4b'))){_0x172c03[_0xf434('0x33')]=qs[_0xf434('0x33')](_0x496535[_0xf434('0x45')][_0xf434('0x33')]);_0x172c03['offset']=qs[_0xf434('0x32')](_0x496535[_0xf434('0x45')]['offset']);}_0x172c03[_0xf434('0x4c')]=qs['sort'](_0x496535[_0xf434('0x45')]['sort']);_0x172c03[_0xf434('0x4d')]=qs['filters'](_[_0xf434('0x4e')](_0x496535[_0xf434('0x45')],_0x2415f9[_0xf434('0x47')]),_0x5afab1);if(_0x496535[_0xf434('0x45')][_0xf434('0x4f')]){_0x172c03['where']=_[_0xf434('0x50')](_0x172c03[_0xf434('0x4d')],{'$or':_['map'](_0x5afab1,function(_0x18bef5){if(_0x18bef5[_0xf434('0x42')]!=='VIRTUAL'){var _0x3daf27={};_0x3daf27[_0x18bef5['name']]={'$like':'%'+_0x496535['query'][_0xf434('0x4f')]+'%'};return _0x3daf27;}})});}_0x172c03=_[_0xf434('0x50')]({},_0x172c03,_0x496535[_0xf434('0x51')]);var _0x2b880b={'where':_0x172c03[_0xf434('0x4d')]};return db[_0xf434('0x3f')][_0xf434('0x31')](_0x2b880b)[_0xf434('0x21')](function(_0x2e9485){_0x1c49d6[_0xf434('0x31')]=_0x2e9485;if(_0x496535[_0xf434('0x45')][_0xf434('0x52')]){_0x172c03['include']=[{'all':!![]}];}return db[_0xf434('0x3f')][_0xf434('0x53')](_0x172c03);})['then'](function(_0x150e15){_0x1c49d6['rows']=_0x150e15;return _0x1c49d6;})[_0xf434('0x21')](respondWithFilteredResult(_0x28f7d3,_0x172c03))['catch'](handleError(_0x28f7d3,null));};exports[_0xf434('0x54')]=function(_0x4abf95,_0x2248d4){var _0xa1e973={'raw':!![],'where':{'id':_0x4abf95[_0xf434('0x55')]['id']}},_0x354239={};_0x354239[_0xf434('0x44')]=_[_0xf434('0x46')](db[_0xf434('0x3f')][_0xf434('0x40')]);_0x354239[_0xf434('0x45')]=_[_0xf434('0x46')](_0x4abf95[_0xf434('0x45')]);_0x354239['filters']=_[_0xf434('0x48')](_0x354239[_0xf434('0x44')],_0x354239['query']);_0xa1e973['attributes']=_[_0xf434('0x48')](_0x354239[_0xf434('0x44')],qs[_0xf434('0x56')](_0x4abf95[_0xf434('0x45')][_0xf434('0x56')]));_0xa1e973['attributes']=_0xa1e973[_0xf434('0x49')][_0xf434('0x57')]?_0xa1e973[_0xf434('0x49')]:_0x354239[_0xf434('0x44')];if(_0x4abf95['query'][_0xf434('0x52')]){_0xa1e973['include']=[{'all':!![]}];}_0xa1e973=_[_0xf434('0x50')]({},_0xa1e973,_0x4abf95[_0xf434('0x51')]);return db[_0xf434('0x3f')][_0xf434('0x58')](_0xa1e973)[_0xf434('0x21')](handleEntityNotFound(_0x2248d4,null))[_0xf434('0x21')](respondWithResult(_0x2248d4,null))[_0xf434('0x2c')](handleError(_0x2248d4,null));};exports[_0xf434('0x59')]=function(_0x2bf220,_0x449a3d){return db['ChatQueue'][_0xf434('0x59')](_0x2bf220['body'],{})[_0xf434('0x21')](function(_0x618d7d){var _0xd0cb71=_0x2bf220[_0xf434('0x5a')][_0xf434('0x3a')]({'plain':!![]});if(!_0xd0cb71)throw new Error(_0xf434('0x5b'));if(_0xd0cb71['role']===_0xf434('0x5a')){var _0x30f81d=_0x618d7d[_0xf434('0x3a')]({'plain':!![]});var _0x1fee48=_0xf434('0x5c');return db[_0xf434('0x5d')][_0xf434('0x58')]({'where':{'name':_0x1fee48,'userProfileId':_0xd0cb71['userProfileId']},'raw':!![]})[_0xf434('0x21')](function(_0x2b3069){if(_0x2b3069&&_0x2b3069[_0xf434('0x5e')]===0x0){return db[_0xf434('0x3b')][_0xf434('0x59')]({'name':_0x30f81d[_0xf434('0x3d')],'resourceId':_0x30f81d['id'],'type':_0x2b3069[_0xf434('0x3d')],'sectionId':_0x2b3069['id']},{})[_0xf434('0x21')](function(){return _0x618d7d;});}else{return _0x618d7d;}})[_0xf434('0x2c')](function(_0x4cb72a){logger[_0xf434('0x28')](_0xf434('0x5f'),_0x4cb72a);throw _0x4cb72a;});}return _0x618d7d;})[_0xf434('0x21')](respondWithResult(_0x449a3d,0xc9))[_0xf434('0x2c')](handleError(_0x449a3d,null));};exports['update']=function(_0x22fbc3,_0x3a5c67){if(_0x22fbc3[_0xf434('0x60')]['id']){delete _0x22fbc3[_0xf434('0x60')]['id'];}return db['ChatQueue'][_0xf434('0x58')]({'where':{'id':_0x22fbc3['params']['id']}})[_0xf434('0x21')](handleEntityNotFound(_0x3a5c67,null))['then'](saveUpdates(_0x22fbc3[_0xf434('0x60')],null))['then'](respondWithResult(_0x3a5c67,null))['catch'](handleError(_0x3a5c67,null));};exports[_0xf434('0x39')]=function(_0x353744,_0x16571e){return db[_0xf434('0x3f')][_0xf434('0x58')]({'where':{'id':_0x353744[_0xf434('0x55')]['id']}})['then'](handleEntityNotFound(_0x16571e,null))[_0xf434('0x21')](removeEntity(_0x16571e,null))[_0xf434('0x2c')](handleError(_0x16571e,null));};exports[_0xf434('0x61')]=function(_0x61805d,_0x1108f5){return db['ChatQueue'][_0xf434('0x61')]()[_0xf434('0x21')](respondWithResult(_0x1108f5,null))['catch'](handleError(_0x1108f5,null));};exports[_0xf434('0x62')]=function(_0x45a9da,_0x5c7381,_0x4c556d){var _0x3cb3e9={'raw':!![],'where':{}},_0x274f9d={},_0x563ee6;return db[_0xf434('0x3f')][_0xf434('0x63')]({'where':{'id':_0x45a9da['params']['id']}})[_0xf434('0x21')](handleEntityNotFound(_0x5c7381,null))[_0xf434('0x21')](function(_0x1de1f4){if(_0x1de1f4){_0x563ee6=_0x1de1f4[_0xf434('0x3a')]({'plain':!![]});_0x274f9d[_0xf434('0x44')]=_[_0xf434('0x46')](db['UserChatQueue'][_0xf434('0x40')]);_0x274f9d['query']=_[_0xf434('0x46')](_0x45a9da[_0xf434('0x45')]);_0x274f9d['filters']=_['intersection'](_0x274f9d[_0xf434('0x44')],_0x274f9d['query']);_0x3cb3e9[_0xf434('0x49')]=_[_0xf434('0x48')](_0x274f9d[_0xf434('0x44')],qs[_0xf434('0x56')](_0x45a9da['query'][_0xf434('0x56')]));_0x3cb3e9[_0xf434('0x49')]=_0x3cb3e9[_0xf434('0x49')][_0xf434('0x57')]?_0x3cb3e9[_0xf434('0x49')]:_0x274f9d[_0xf434('0x44')];if(!_0x45a9da['query'][_0xf434('0x4a')](_0xf434('0x4b'))){_0x3cb3e9['limit']=qs[_0xf434('0x33')](_0x45a9da[_0xf434('0x45')][_0xf434('0x33')]);_0x3cb3e9[_0xf434('0x32')]=qs['offset'](_0x45a9da[_0xf434('0x45')][_0xf434('0x32')]);}_0x3cb3e9[_0xf434('0x4c')]=qs[_0xf434('0x64')](_0x45a9da[_0xf434('0x45')][_0xf434('0x64')]);_0x3cb3e9[_0xf434('0x4d')]=qs[_0xf434('0x47')](_[_0xf434('0x4e')](_0x45a9da[_0xf434('0x45')],_0x274f9d[_0xf434('0x47')]));_0x3cb3e9[_0xf434('0x4d')][_0xf434('0x65')]=_0x1de1f4['id'];if(_0x45a9da[_0xf434('0x45')][_0xf434('0x4f')]){_0x3cb3e9[_0xf434('0x4d')]=_[_0xf434('0x50')](_0x3cb3e9[_0xf434('0x4d')],{'$or':_['map'](_0x3cb3e9[_0xf434('0x49')],function(_0x56f1e8){var _0x3f6e5f={};_0x3f6e5f[_0x56f1e8]={'$like':'%'+_0x45a9da[_0xf434('0x45')]['filter']+'%'};return _0x3f6e5f;})});}_0x3cb3e9=_[_0xf434('0x50')]({},_0x3cb3e9,_0x45a9da[_0xf434('0x51')]);return db[_0xf434('0x66')][_0xf434('0x53')](_0x3cb3e9);}})[_0xf434('0x21')](function(_0x86dfc8){if(_0x86dfc8){return db['User'][_0xf434('0x67')]({'where':{'id':_[_0xf434('0x3e')](_0x86dfc8,_0xf434('0x68')),'role':'agent'},'attributes':['id',_0xf434('0x3d'),_0xf434('0x69'),_0xf434('0x6a'),_0xf434('0x6b')]});}})[_0xf434('0x21')](function(_0x51aaa5){if(_0x51aaa5){return{'count':_0x51aaa5[_0xf434('0x31')],'rows':_[_0xf434('0x3e')](_0x51aaa5[_0xf434('0x6c')],function(_0x1d4971){return{'membername':_0x1d4971[_0xf434('0x3d')],'UserId':_0x1d4971['id'],'queue_name':_0x563ee6[_0xf434('0x3d')],'ChatQueueId':_0x563ee6['id'],'interface':util[_0xf434('0x6d')](_0xf434('0x6e'),_0xf434('0x6f'),_0x1d4971[_0xf434('0x3d')]),'penalty':0x0,'paused':_0x1d4971[_0xf434('0x69')],'createdAt':_0x1d4971['createdAt'],'updatedAt':_0x1d4971[_0xf434('0x6a')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xf434('0x21')](respondWithFilteredResult(_0x5c7381,_0x3cb3e9))[_0xf434('0x2c')](handleError(_0x5c7381,null));};exports['getTeams']=function(_0x28d089,_0x31b6dd,_0x5817c9){var _0x212c56={};var _0x1ce895={};var _0x2e01b6;var _0x311e08;return db[_0xf434('0x3f')][_0xf434('0x63')]({'where':{'id':_0x28d089[_0xf434('0x55')]['id']}})[_0xf434('0x21')](handleEntityNotFound(_0x31b6dd,null))['then'](function(_0x1d77d7){if(_0x1d77d7){_0x2e01b6=_0x1d77d7;_0x1ce895[_0xf434('0x44')]=_[_0xf434('0x46')](db[_0xf434('0x70')][_0xf434('0x40')]);_0x1ce895['query']=_['keys'](_0x28d089[_0xf434('0x45')]);_0x1ce895[_0xf434('0x47')]=_['intersection'](_0x1ce895['model'],_0x1ce895['query']);_0x212c56['attributes']=_[_0xf434('0x48')](_0x1ce895[_0xf434('0x44')],qs[_0xf434('0x56')](_0x28d089[_0xf434('0x45')]['fields']));_0x212c56[_0xf434('0x49')]=_0x212c56[_0xf434('0x49')]['length']?_0x212c56[_0xf434('0x49')]:_0x1ce895[_0xf434('0x44')];_0x212c56[_0xf434('0x4c')]=qs[_0xf434('0x64')](_0x28d089['query'][_0xf434('0x64')]);_0x212c56[_0xf434('0x4d')]=qs[_0xf434('0x47')](_[_0xf434('0x4e')](_0x28d089[_0xf434('0x45')],_0x1ce895[_0xf434('0x47')]));if(_0x28d089[_0xf434('0x45')][_0xf434('0x4f')]){_0x212c56[_0xf434('0x4d')]=_[_0xf434('0x50')](_0x212c56['where'],{'$or':_[_0xf434('0x3e')](_0x212c56[_0xf434('0x49')],function(_0x5e28ed){var _0x27b65d={};_0x27b65d[_0x5e28ed]={'$like':'%'+_0x28d089[_0xf434('0x45')]['filter']+'%'};return _0x27b65d;})});}_0x212c56=_[_0xf434('0x50')]({},_0x212c56,_0x28d089['options']);return _0x2e01b6[_0xf434('0x71')](_0x212c56);}})[_0xf434('0x21')](function(_0x3bf439){if(_0x3bf439){_0x311e08=_0x3bf439[_0xf434('0x57')];if(!_0x28d089[_0xf434('0x45')]['hasOwnProperty']('nolimit')){_0x212c56[_0xf434('0x33')]=qs[_0xf434('0x33')](_0x28d089[_0xf434('0x45')]['limit']);_0x212c56[_0xf434('0x32')]=qs[_0xf434('0x32')](_0x28d089[_0xf434('0x45')][_0xf434('0x32')]);}return _0x2e01b6[_0xf434('0x71')](_0x212c56);}})[_0xf434('0x21')](function(_0x1091a9){if(_0x1091a9){return _0x1091a9?{'count':_0x311e08,'rows':_0x1091a9}:null;}})['then'](respondWithResult(_0x31b6dd,null))['catch'](handleError(_0x31b6dd,null));};exports[_0xf434('0x72')]=function(_0x26d269,_0xe6811a,_0x27a4d9){var _0x5b2f65=_0x26d269[_0xf434('0x60')][_0xf434('0x73')];return db[_0xf434('0x70')][_0xf434('0x53')]({'where':{'id':_0x5b2f65},'attributes':['id'],'include':[{'model':db[_0xf434('0x74')],'as':_0xf434('0x75'),'attributes':['id','name',_0xf434('0x76'),_0xf434('0x77'),_0xf434('0x78')],'raw':!![]}]})[_0xf434('0x21')](function(_0x1922e0){if(_0x1922e0){var _0x30ae15=_[_0xf434('0x79')](_0x1922e0,function(_0x2f1298){var _0x2e8f05=_0x2f1298[_0xf434('0x3a')]({'plain':!![]});return _0x2e8f05[_0xf434('0x75')];});return db[_0xf434('0x3f')][_0xf434('0x58')]({'where':{'id':_0x26d269[_0xf434('0x55')]['id']}})[_0xf434('0x21')](function(_0x41d694){return db[_0xf434('0x7a')][_0xf434('0x7b')](function(_0x183319){return _0x41d694[_0xf434('0x72')](_0x5b2f65,{'transaction':_0x183319})[_0xf434('0x21')](function(){return BPromise[_0xf434('0x7c')](_0x30ae15,function(_0x7e423f){return db[_0xf434('0x66')][_0xf434('0x7d')]({'where':{'UserId':_0x7e423f['id'],'ChatQueueId':_0x26d269[_0xf434('0x55')]['id']},'transaction':_0x183319});});})[_0xf434('0x21')](function(){_0x30ae15[_0xf434('0x7e')](function(_0x4c3f72){socket[_0xf434('0x7f')](_0xf434('0x80'),{'UserId':_0x4c3f72['id'],'ChatQueueId':_0x41d694['id']});});});});});}})[_0xf434('0x21')](respondWithStatusCode(_0xe6811a,null))[_0xf434('0x2c')](handleError(_0xe6811a,null));};exports['removeTeams']=function(_0x220275,_0x330cd2,_0x5c0b7a){return db[_0xf434('0x70')][_0xf434('0x53')]({'where':{'id':_0x220275[_0xf434('0x45')]['ids']},'attributes':['id'],'include':[{'model':db[_0xf434('0x74')],'as':_0xf434('0x75'),'attributes':['id'],'raw':!![]}]})[_0xf434('0x21')](handleEntityNotFound(_0x330cd2,null))[_0xf434('0x21')](function(_0x3033e8){var _0x20a35d=_[_0xf434('0x3e')](_0x3033e8,'id');var _0x4b0c67=[];var _0x1e6ab1=[];var _0x191899=squel[_0xf434('0x81')]();_0x191899[_0xf434('0x82')](_0xf434('0x83'))['from'](_0xf434('0x84'),'tq')[_0xf434('0x85')]('user_has_teams','ut',_0xf434('0x86'))[_0xf434('0x4d')](_0xf434('0x87'),_0x220275[_0xf434('0x55')]['id']);for(var _0x2d5068=0x0;_0x2d5068<_0x3033e8['length'];_0x2d5068+=0x1){let _0x39a3fa=_0x3033e8[_0x2d5068];for(var _0xf1a98c=0x0;_0xf1a98c<_0x39a3fa[_0xf434('0x75')][_0xf434('0x57')];_0xf1a98c+=0x1){let _0x5b6f72=_0x39a3fa[_0xf434('0x75')][_0xf1a98c];var _0x1726d1=_0x191899[_0xf434('0x88')]();_0x1726d1[_0xf434('0x4d')](_0xf434('0x89'),_0x5b6f72['id']);_0x1e6ab1[_0xf434('0x8a')](db[_0xf434('0x7a')]['query'](_0x1726d1['toString'](),{'type':db[_0xf434('0x7a')][_0xf434('0x8b')][_0xf434('0x8c')]})['then'](function(_0x208ce8){if(_0x208ce8[_0xf434('0x57')]===0x1){return _0x5b6f72['id'];}else{var _0x4b92ff=_['every'](_['map'](_0x208ce8,_0xf434('0x8d')),function(_0xf593b5){return _[_0xf434('0x8e')](_0x20a35d,_0xf593b5);});if(_0x4b92ff){return _0x5b6f72['id'];}}}));}}return BPromise['all'](_0x1e6ab1)[_0xf434('0x21')](function(_0x2d5831){_0x4b0c67=_(_0x4b0c67)[_0xf434('0x8f')](_0x2d5831)[_0xf434('0x90')]()[_0xf434('0x91')]();return db['ChatQueue']['find']({'where':{'id':_0x220275[_0xf434('0x55')]['id']}})['then'](function(_0x389778){return db[_0xf434('0x7a')]['transaction'](function(_0x41f7f0){return _0x389778['removeTeams'](_0x220275[_0xf434('0x45')][_0xf434('0x73')],{'transaction':_0x41f7f0})[_0xf434('0x21')](function(){if(!_[_0xf434('0x92')](_0x4b0c67)){return _0x389778[_0xf434('0x93')](_0x4b0c67,{'transaction':_0x41f7f0});}})['then'](function(){_0x4b0c67[_0xf434('0x7e')](function(_0x33e609){socket['emit'](_0xf434('0x94'),{'UserId':_0x33e609,'ChatQueueId':_0x389778['id']});});});});});});})[_0xf434('0x21')](respondWithStatusCode(_0x330cd2,null))[_0xf434('0x2c')](handleError(_0x330cd2,null));};exports[_0xf434('0x95')]=function(_0xb896a,_0x5ca34e,_0x1a96bd){return db[_0xf434('0x3f')][_0xf434('0x58')]({'where':{'id':_0xb896a[_0xf434('0x55')]['id']}})['then'](handleEntityNotFound(_0x5ca34e,null))[_0xf434('0x21')](function(_0x4a8853){if(_0x4a8853){return _0x4a8853[_0xf434('0x95')](_0xb896a[_0xf434('0x60')][_0xf434('0x73')],_['omit'](_0xb896a['body'],[_0xf434('0x73'),'id'])||{})[_0xf434('0x96')](function(_0x1835d1){for(var _0x14275f=0x0;_0x14275f<_0xb896a['body']['ids'][_0xf434('0x57')];_0x14275f+=0x1){socket['emit']('userChatQueue:save',{'UserId':_0xb896a['body'][_0xf434('0x73')][_0x14275f],'ChatQueueId':_0xb896a[_0xf434('0x55')]['id']});}return _0x1835d1;});}})['then'](respondWithResult(_0x5ca34e,null))[_0xf434('0x2c')](handleError(_0x5ca34e,null));};exports[_0xf434('0x93')]=function(_0x4b0a2e,_0x4853af,_0x61173c){return db[_0xf434('0x3f')][_0xf434('0x58')]({'where':{'id':_0x4b0a2e[_0xf434('0x55')]['id']}})['then'](handleEntityNotFound(_0x4853af,null))[_0xf434('0x21')](function(_0x2d01f6){if(_0x2d01f6){return _0x2d01f6[_0xf434('0x93')](_0x4b0a2e[_0xf434('0x45')][_0xf434('0x73')])[_0xf434('0x21')](function(){if(_[_0xf434('0x97')](_0x4b0a2e['query'][_0xf434('0x73')])){for(var _0x128b36=0x0;_0x128b36<_0x4b0a2e[_0xf434('0x45')][_0xf434('0x73')]['length'];_0x128b36+=0x1){socket['emit'](_0xf434('0x94'),{'UserId':Number(_0x4b0a2e[_0xf434('0x45')][_0xf434('0x73')][_0x128b36]),'ChatQueueId':Number(_0x4b0a2e[_0xf434('0x55')]['id'])});}}else{socket[_0xf434('0x7f')](_0xf434('0x94'),{'UserId':Number(_0x4b0a2e['query'][_0xf434('0x73')]),'ChatQueueId':Number(_0x4b0a2e['params']['id'])});}});}})[_0xf434('0x21')](respondWithStatusCode(_0x4853af,null))[_0xf434('0x2c')](handleError(_0x4853af,null));};exports['getAgents']=function(_0x3c0cea,_0x4b88fd,_0x51d940){var _0x3244d7={};var _0xb5cab={};var _0x2abf0b;var _0x2ce9ec;return db['ChatQueue'][_0xf434('0x63')]({'where':{'id':_0x3c0cea[_0xf434('0x55')]['id']}})['then'](handleEntityNotFound(_0x4b88fd,null))['then'](function(_0x1825a0){if(_0x1825a0){_0x2abf0b=_0x1825a0;_0xb5cab[_0xf434('0x44')]=_[_0xf434('0x46')](db[_0xf434('0x74')][_0xf434('0x40')]);_0xb5cab['query']=_[_0xf434('0x46')](_0x3c0cea[_0xf434('0x45')]);_0xb5cab['filters']=_[_0xf434('0x48')](_0xb5cab[_0xf434('0x44')],_0xb5cab[_0xf434('0x45')]);_0x3244d7[_0xf434('0x49')]=_[_0xf434('0x48')](_0xb5cab[_0xf434('0x44')],qs[_0xf434('0x56')](_0x3c0cea[_0xf434('0x45')]['fields']));_0x3244d7[_0xf434('0x49')]=_0x3244d7['attributes'][_0xf434('0x57')]?_0x3244d7['attributes']:_0xb5cab[_0xf434('0x44')];_0x3244d7[_0xf434('0x4c')]=qs[_0xf434('0x64')](_0x3c0cea[_0xf434('0x45')][_0xf434('0x64')]);_0x3244d7['where']=qs['filters'](_[_0xf434('0x4e')](_0x3c0cea[_0xf434('0x45')],_0xb5cab[_0xf434('0x47')]));if(_0x3c0cea['query'][_0xf434('0x4f')]){_0x3244d7['where']=_[_0xf434('0x50')](_0x3244d7[_0xf434('0x4d')],{'$or':_[_0xf434('0x3e')](_0x3244d7[_0xf434('0x49')],function(_0x257da4){var _0x4f55dc={};_0x4f55dc[_0x257da4]={'$like':'%'+_0x3c0cea[_0xf434('0x45')][_0xf434('0x4f')]+'%'};return _0x4f55dc;})});}_0x3244d7=_[_0xf434('0x50')]({},_0x3244d7,_0x3c0cea[_0xf434('0x51')]);return _0x2abf0b[_0xf434('0x98')](_0x3244d7);}})[_0xf434('0x21')](function(_0x21ac88){if(_0x21ac88){_0x2ce9ec=_0x21ac88['length'];if(!_0x3c0cea[_0xf434('0x45')]['hasOwnProperty'](_0xf434('0x4b'))){_0x3244d7['limit']=qs[_0xf434('0x33')](_0x3c0cea[_0xf434('0x45')]['limit']);_0x3244d7[_0xf434('0x32')]=qs[_0xf434('0x32')](_0x3c0cea['query'][_0xf434('0x32')]);}return _0x2abf0b['getAgents'](_0x3244d7);}})[_0xf434('0x21')](function(_0x400c2a){if(_0x400c2a){return _0x400c2a?{'count':_0x2ce9ec,'rows':_0x400c2a}:null;}})[_0xf434('0x21')](respondWithResult(_0x4b88fd,null))[_0xf434('0x2c')](handleError(_0x4b88fd,null));};
\ No newline at end of file
+var _0x7b3b=['voicePause','flatMap','sequelize','transaction','forEach','emit','removeTeams','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','removeAgents','addAgents','spread','userChatQueue:save','getAgents','hasOwnProperty','bluebird','util','lodash','squel','ioredis','../../components/parsers/qs','api','../../config/environment','redis','defaults','localhost','socket.io-emitter','register','status','end','json','offset','undefined','limit','count','set','Content-Range','update','destroy','then','get','ChatQueues','error','stack','name','send','index','map','ChatQueue','rawAttributes','type','key','getOptions','where','include','query','catch','params','model','keys','filters','intersection','attributes','length','merge','options','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','UserChatQueue','fields','nolimit','order','sort','pick','ChatQueueId','filter','findAll','User','UserId','agent','chatPause','updatedAt','createdAt','rows','format','%s/%s','SIP','getTeams','Team','addTeams','ids','Agents','online'];(function(_0x24d8ec,_0x5f1552){var _0x409280=function(_0x3d085b){while(--_0x3d085b){_0x24d8ec['push'](_0x24d8ec['shift']());}};_0x409280(++_0x5f1552);}(_0x7b3b,0x92));var _0xb7b3=function(_0x23fa2a,_0x3816a3){_0x23fa2a=_0x23fa2a-0x0;var _0x783fba=_0x7b3b[_0x23fa2a];return _0x783fba;};'use strict';var BPromise=require(_0xb7b3('0x0'));var util=require(_0xb7b3('0x1'));var _=require(_0xb7b3('0x2'));var squel=require(_0xb7b3('0x3'));var Redis=require(_0xb7b3('0x4'));var qs=require(_0xb7b3('0x5'));var logger=require('../../config/logger')(_0xb7b3('0x6'));var config=require(_0xb7b3('0x7'));var db=require('../../mysqldb')['db'];config[_0xb7b3('0x8')]=_[_0xb7b3('0x9')](config[_0xb7b3('0x8')],{'host':_0xb7b3('0xa'),'port':0x18eb});var socket=require(_0xb7b3('0xb'))(new Redis(config[_0xb7b3('0x8')]));require('./chatQueue.socket')[_0xb7b3('0xc')](socket);function respondWithStatusCode(_0x187639,_0x202d7e){_0x202d7e=_0x202d7e||0xcc;return function(_0x4a000a){if(_0x4a000a){return _0x187639['sendStatus'](_0x202d7e);}return _0x187639[_0xb7b3('0xd')](_0x202d7e)[_0xb7b3('0xe')]();};}function respondWithResult(_0x58ad4c,_0x46a558){_0x46a558=_0x46a558||0xc8;return function(_0x2e1acd){if(_0x2e1acd){return _0x58ad4c[_0xb7b3('0xd')](_0x46a558)[_0xb7b3('0xf')](_0x2e1acd);}};}function respondWithFilteredResult(_0x281146,_0x4ce771){return function(_0x5e950e){if(_0x5e950e){var _0x2650fc=typeof _0x4ce771[_0xb7b3('0x10')]===_0xb7b3('0x11')&&typeof _0x4ce771[_0xb7b3('0x12')]==='undefined';var _0x21b5fe=_0x5e950e['count'];var _0x2bee56=_0x2650fc?0x0:_0x4ce771[_0xb7b3('0x10')];var _0x5780ec=_0x2650fc?_0x5e950e[_0xb7b3('0x13')]:_0x4ce771[_0xb7b3('0x10')]+_0x4ce771['limit'];var _0x279a15;if(_0x5780ec>=_0x21b5fe){_0x5780ec=_0x21b5fe;_0x279a15=0xc8;}else{_0x279a15=0xce;}_0x281146['status'](_0x279a15);return _0x281146[_0xb7b3('0x14')](_0xb7b3('0x15'),_0x2bee56+'-'+_0x5780ec+'/'+_0x21b5fe)[_0xb7b3('0xf')](_0x5e950e);}return null;};}function saveUpdates(_0x22f42e){return function(_0x3e85ce){if(_0x3e85ce){return _0x3e85ce[_0xb7b3('0x16')](_0x22f42e)['then'](function(_0x2086c3){return _0x2086c3;});}return null;};}function removeEntity(_0x381d18){return function(_0x28c4be){if(_0x28c4be){return _0x28c4be[_0xb7b3('0x17')]()[_0xb7b3('0x18')](function(){var _0x3ebfea=_0x28c4be[_0xb7b3('0x19')]({'plain':!![]});var _0xc0e079=_0xb7b3('0x1a');return db['UserProfileResource'][_0xb7b3('0x17')]({'where':{'type':_0xc0e079,'resourceId':_0x3ebfea['id']}})[_0xb7b3('0x18')](function(){return _0x28c4be;});})[_0xb7b3('0x18')](function(){_0x381d18[_0xb7b3('0xd')](0xcc)[_0xb7b3('0xe')]();});}};}function handleEntityNotFound(_0xae4788){return function(_0x524e72){if(!_0x524e72){_0xae4788['sendStatus'](0x194);}return _0x524e72;};}function handleError(_0x2271ad,_0x18cba1){_0x18cba1=_0x18cba1||0x1f4;return function(_0x261634){logger[_0xb7b3('0x1b')](_0x261634[_0xb7b3('0x1c')]);if(_0x261634[_0xb7b3('0x1d')]){delete _0x261634[_0xb7b3('0x1d')];}_0x2271ad[_0xb7b3('0xd')](_0x18cba1)[_0xb7b3('0x1e')](_0x261634);};}exports[_0xb7b3('0x1f')]=function(_0x27fd41,_0x1b5ce5){var _0x4e8ccb={};var _0x2dc648={'count':0x0,'rows':[]};var _0x58222a=_[_0xb7b3('0x20')](db[_0xb7b3('0x21')][_0xb7b3('0x22')],function(_0xd0bea4){return{'name':_0xd0bea4['fieldName'],'type':_0xd0bea4[_0xb7b3('0x23')][_0xb7b3('0x24')]};});_0x4e8ccb=qs[_0xb7b3('0x25')](_0x58222a,_0x27fd41);var _0x18b938={'where':_0x4e8ccb[_0xb7b3('0x26')]};return db[_0xb7b3('0x21')]['count'](_0x18b938)['then'](function(_0x5612b8){_0x2dc648[_0xb7b3('0x13')]=_0x5612b8;_0x4e8ccb['include']=qs[_0xb7b3('0x27')](_0x27fd41[_0xb7b3('0x28')]);return db['ChatQueue']['findAll'](_0x4e8ccb);})[_0xb7b3('0x18')](function(_0x5f19cc){_0x2dc648['rows']=_0x5f19cc;return _0x2dc648;})[_0xb7b3('0x18')](respondWithFilteredResult(_0x1b5ce5,_0x4e8ccb))[_0xb7b3('0x29')](handleError(_0x1b5ce5,null));};exports['show']=function(_0x102c7f,_0xef5975){var _0x3d858e={'raw':!![],'where':{'id':_0x102c7f[_0xb7b3('0x2a')]['id']}},_0x53d006={};_0x53d006[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db['ChatQueue'][_0xb7b3('0x22')]);_0x53d006[_0xb7b3('0x28')]=_[_0xb7b3('0x2c')](_0x102c7f[_0xb7b3('0x28')]);_0x53d006[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x53d006[_0xb7b3('0x2b')],_0x53d006[_0xb7b3('0x28')]);_0x3d858e[_0xb7b3('0x2f')]=_[_0xb7b3('0x2e')](_0x53d006['model'],qs['fields'](_0x102c7f['query']['fields']));_0x3d858e[_0xb7b3('0x2f')]=_0x3d858e[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x3d858e[_0xb7b3('0x2f')]:_0x53d006[_0xb7b3('0x2b')];if(_0x102c7f[_0xb7b3('0x28')]['includeAll']){_0x3d858e[_0xb7b3('0x27')]=[{'all':!![]}];}_0x3d858e=_[_0xb7b3('0x31')]({},_0x3d858e,_0x102c7f[_0xb7b3('0x32')]);return db[_0xb7b3('0x21')][_0xb7b3('0x33')](_0x3d858e)['then'](handleEntityNotFound(_0xef5975,null))[_0xb7b3('0x18')](respondWithResult(_0xef5975,null))[_0xb7b3('0x29')](handleError(_0xef5975,null));};exports['create']=function(_0xa6615c,_0x6c473e){return db[_0xb7b3('0x21')][_0xb7b3('0x34')](_0xa6615c[_0xb7b3('0x35')],{})[_0xb7b3('0x18')](function(_0x24c940){var _0x3e4cd5=_0xa6615c['user']['get']({'plain':!![]});if(!_0x3e4cd5)throw new Error(_0xb7b3('0x36'));if(_0x3e4cd5[_0xb7b3('0x37')]===_0xb7b3('0x38')){var _0x5a2075=_0x24c940[_0xb7b3('0x19')]({'plain':!![]});var _0xe7f5a8='ChatQueues';return db['UserProfileSection']['find']({'where':{'name':_0xe7f5a8,'userProfileId':_0x3e4cd5[_0xb7b3('0x39')]},'raw':!![]})[_0xb7b3('0x18')](function(_0x446fc7){if(_0x446fc7&&_0x446fc7[_0xb7b3('0x3a')]===0x0){return db[_0xb7b3('0x3b')][_0xb7b3('0x34')]({'name':_0x5a2075[_0xb7b3('0x1d')],'resourceId':_0x5a2075['id'],'type':_0x446fc7[_0xb7b3('0x1d')],'sectionId':_0x446fc7['id']},{})[_0xb7b3('0x18')](function(){return _0x24c940;});}else{return _0x24c940;}})['catch'](function(_0x4219a4){logger[_0xb7b3('0x1b')](_0xb7b3('0x3c'),_0x4219a4);throw _0x4219a4;});}return _0x24c940;})['then'](respondWithResult(_0x6c473e,0xc9))[_0xb7b3('0x29')](handleError(_0x6c473e,null));};exports['update']=function(_0x45ee14,_0x27d95f){if(_0x45ee14[_0xb7b3('0x35')]['id']){delete _0x45ee14[_0xb7b3('0x35')]['id'];}return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x45ee14['params']['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x27d95f,null))[_0xb7b3('0x18')](saveUpdates(_0x45ee14[_0xb7b3('0x35')],null))['then'](respondWithResult(_0x27d95f,null))['catch'](handleError(_0x27d95f,null));};exports[_0xb7b3('0x17')]=function(_0x273c2d,_0x4aa25a){return db['ChatQueue'][_0xb7b3('0x33')]({'where':{'id':_0x273c2d[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x4aa25a,null))[_0xb7b3('0x18')](removeEntity(_0x4aa25a,null))[_0xb7b3('0x29')](handleError(_0x4aa25a,null));};exports[_0xb7b3('0x3d')]=function(_0x53454d,_0x1b1936){return db[_0xb7b3('0x21')][_0xb7b3('0x3d')]()[_0xb7b3('0x18')](respondWithResult(_0x1b1936,null))[_0xb7b3('0x29')](handleError(_0x1b1936,null));};exports['getMembers']=function(_0x300009,_0x16ad16){var _0x9899cf={'raw':!![],'where':{}},_0x5b429a={},_0x355b7f;return db[_0xb7b3('0x21')][_0xb7b3('0x3e')]({'where':{'id':_0x300009[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x16ad16,null))[_0xb7b3('0x18')](function(_0x56c874){if(_0x56c874){_0x355b7f=_0x56c874['get']({'plain':!![]});_0x5b429a[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db[_0xb7b3('0x3f')][_0xb7b3('0x22')]);_0x5b429a['query']=_['keys'](_0x300009[_0xb7b3('0x28')]);_0x5b429a[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x5b429a[_0xb7b3('0x2b')],_0x5b429a[_0xb7b3('0x28')]);_0x9899cf[_0xb7b3('0x2f')]=_['intersection'](_0x5b429a[_0xb7b3('0x2b')],qs[_0xb7b3('0x40')](_0x300009[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x9899cf[_0xb7b3('0x2f')]=_0x9899cf[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x9899cf[_0xb7b3('0x2f')]:_0x5b429a[_0xb7b3('0x2b')];if(!_0x300009['query']['hasOwnProperty'](_0xb7b3('0x41'))){_0x9899cf['limit']=qs['limit'](_0x300009[_0xb7b3('0x28')]['limit']);_0x9899cf[_0xb7b3('0x10')]=qs[_0xb7b3('0x10')](_0x300009['query'][_0xb7b3('0x10')]);}_0x9899cf[_0xb7b3('0x42')]=qs[_0xb7b3('0x43')](_0x300009[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x9899cf[_0xb7b3('0x26')]=qs[_0xb7b3('0x2d')](_[_0xb7b3('0x44')](_0x300009[_0xb7b3('0x28')],_0x5b429a[_0xb7b3('0x2d')]));_0x9899cf['where'][_0xb7b3('0x45')]=_0x56c874['id'];if(_0x300009['query'][_0xb7b3('0x46')]){_0x9899cf[_0xb7b3('0x26')]=_[_0xb7b3('0x31')](_0x9899cf['where'],{'$or':_[_0xb7b3('0x20')](_0x9899cf['attributes'],function(_0x370392){var _0x5d9e2c={};_0x5d9e2c[_0x370392]={'$like':'%'+_0x300009[_0xb7b3('0x28')][_0xb7b3('0x46')]+'%'};return _0x5d9e2c;})});}_0x9899cf=_[_0xb7b3('0x31')]({},_0x9899cf,_0x300009[_0xb7b3('0x32')]);return db[_0xb7b3('0x3f')][_0xb7b3('0x47')](_0x9899cf);}})[_0xb7b3('0x18')](function(_0x552415){if(_0x552415){return db[_0xb7b3('0x48')]['findAndCountAll']({'where':{'id':_['map'](_0x552415,_0xb7b3('0x49')),'role':_0xb7b3('0x4a')},'attributes':['id',_0xb7b3('0x1d'),_0xb7b3('0x4b'),_0xb7b3('0x4c'),_0xb7b3('0x4d')]});}})[_0xb7b3('0x18')](function(_0x1c6797){if(_0x1c6797){return{'count':_0x1c6797[_0xb7b3('0x13')],'rows':_['map'](_0x1c6797[_0xb7b3('0x4e')],function(_0x2bb5b1){return{'membername':_0x2bb5b1[_0xb7b3('0x1d')],'UserId':_0x2bb5b1['id'],'queue_name':_0x355b7f[_0xb7b3('0x1d')],'ChatQueueId':_0x355b7f['id'],'interface':util[_0xb7b3('0x4f')](_0xb7b3('0x50'),_0xb7b3('0x51'),_0x2bb5b1[_0xb7b3('0x1d')]),'penalty':0x0,'paused':_0x2bb5b1[_0xb7b3('0x4b')],'createdAt':_0x2bb5b1[_0xb7b3('0x4d')],'updatedAt':_0x2bb5b1[_0xb7b3('0x4c')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xb7b3('0x18')](respondWithFilteredResult(_0x16ad16,_0x9899cf))[_0xb7b3('0x29')](handleError(_0x16ad16,null));};exports[_0xb7b3('0x52')]=function(_0x44bc4b,_0x40a7f9){var _0x2fdbe5={};var _0x3d9ce5={};var _0x293c83;var _0x633055;return db['ChatQueue'][_0xb7b3('0x3e')]({'where':{'id':_0x44bc4b[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x40a7f9,null))[_0xb7b3('0x18')](function(_0x2ca86d){if(_0x2ca86d){_0x293c83=_0x2ca86d;_0x3d9ce5[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db[_0xb7b3('0x53')]['rawAttributes']);_0x3d9ce5['query']=_[_0xb7b3('0x2c')](_0x44bc4b[_0xb7b3('0x28')]);_0x3d9ce5[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x3d9ce5['model'],_0x3d9ce5[_0xb7b3('0x28')]);_0x2fdbe5['attributes']=_['intersection'](_0x3d9ce5[_0xb7b3('0x2b')],qs[_0xb7b3('0x40')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x2fdbe5[_0xb7b3('0x2f')]=_0x2fdbe5[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x2fdbe5[_0xb7b3('0x2f')]:_0x3d9ce5['model'];_0x2fdbe5['order']=qs[_0xb7b3('0x43')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x2fdbe5['where']=qs['filters'](_[_0xb7b3('0x44')](_0x44bc4b[_0xb7b3('0x28')],_0x3d9ce5[_0xb7b3('0x2d')]));if(_0x44bc4b[_0xb7b3('0x28')]['filter']){_0x2fdbe5[_0xb7b3('0x26')]=_['merge'](_0x2fdbe5['where'],{'$or':_['map'](_0x2fdbe5[_0xb7b3('0x2f')],function(_0x3c05a6){var _0x5f6362={};_0x5f6362[_0x3c05a6]={'$like':'%'+_0x44bc4b['query'][_0xb7b3('0x46')]+'%'};return _0x5f6362;})});}_0x2fdbe5=_[_0xb7b3('0x31')]({},_0x2fdbe5,_0x44bc4b[_0xb7b3('0x32')]);return _0x293c83[_0xb7b3('0x52')](_0x2fdbe5);}})[_0xb7b3('0x18')](function(_0x4ad27d){if(_0x4ad27d){_0x633055=_0x4ad27d[_0xb7b3('0x30')];if(!_0x44bc4b[_0xb7b3('0x28')]['hasOwnProperty']('nolimit')){_0x2fdbe5[_0xb7b3('0x12')]=qs['limit'](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x12')]);_0x2fdbe5['offset']=qs[_0xb7b3('0x10')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x10')]);}return _0x293c83['getTeams'](_0x2fdbe5);}})[_0xb7b3('0x18')](function(_0x10df96){if(_0x10df96){return _0x10df96?{'count':_0x633055,'rows':_0x10df96}:null;}})[_0xb7b3('0x18')](respondWithResult(_0x40a7f9,null))[_0xb7b3('0x29')](handleError(_0x40a7f9,null));};exports[_0xb7b3('0x54')]=function(_0x44cb51,_0x2afb57){var _0x19006a=_0x44cb51['body'][_0xb7b3('0x55')];return db[_0xb7b3('0x53')][_0xb7b3('0x47')]({'where':{'id':_0x19006a},'attributes':['id'],'include':[{'model':db[_0xb7b3('0x48')],'as':_0xb7b3('0x56'),'attributes':['id',_0xb7b3('0x1d'),_0xb7b3('0x57'),_0xb7b3('0x58'),'interface'],'raw':!![]}]})['then'](function(_0x2618ea){if(_0x2618ea){var _0x4fa4d5=_[_0xb7b3('0x59')](_0x2618ea,function(_0x270be7){var _0x367418=_0x270be7[_0xb7b3('0x19')]({'plain':!![]});return _0x367418[_0xb7b3('0x56')];});return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x44cb51[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](function(_0x1d4f86){return db[_0xb7b3('0x5a')][_0xb7b3('0x5b')](function(_0x265bfd){return _0x1d4f86['addTeams'](_0x19006a,{'transaction':_0x265bfd})[_0xb7b3('0x18')](function(){return BPromise['each'](_0x4fa4d5,function(_0x39de53){return db[_0xb7b3('0x3f')]['findOrCreate']({'where':{'UserId':_0x39de53['id'],'ChatQueueId':_0x44cb51[_0xb7b3('0x2a')]['id']},'transaction':_0x265bfd});});})[_0xb7b3('0x18')](function(){_0x4fa4d5[_0xb7b3('0x5c')](function(_0x5e2943){socket[_0xb7b3('0x5d')]('userChatQueue:save',{'UserId':_0x5e2943['id'],'ChatQueueId':_0x1d4f86['id']});});});});});}})[_0xb7b3('0x18')](respondWithStatusCode(_0x2afb57,null))[_0xb7b3('0x29')](handleError(_0x2afb57,null));};exports[_0xb7b3('0x5e')]=function(_0x4f7461,_0xd56f49){return db['Team'][_0xb7b3('0x47')]({'where':{'id':_0x4f7461[_0xb7b3('0x28')]['ids']},'attributes':['id'],'include':[{'model':db[_0xb7b3('0x48')],'as':_0xb7b3('0x56'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0xd56f49,null))[_0xb7b3('0x18')](function(_0x389fac){var _0x23bf90=_[_0xb7b3('0x20')](_0x389fac,'id');var _0x4e7f24=[];var _0x5c6b27=[];var _0x2e383c=squel['select']();_0x2e383c[_0xb7b3('0x5f')](_0xb7b3('0x60'))[_0xb7b3('0x61')](_0xb7b3('0x62'),'tq')[_0xb7b3('0x63')](_0xb7b3('0x64'),'ut',_0xb7b3('0x65'))[_0xb7b3('0x26')](_0xb7b3('0x66'),_0x4f7461['params']['id']);for(var _0x4b46f5=0x0;_0x4b46f5<_0x389fac['length'];_0x4b46f5+=0x1){let _0x2e1ae3=_0x389fac[_0x4b46f5];for(var _0x4dec0a=0x0;_0x4dec0a<_0x2e1ae3[_0xb7b3('0x56')]['length'];_0x4dec0a+=0x1){let _0x17ffee=_0x2e1ae3['Agents'][_0x4dec0a];var _0x41eb65=_0x2e383c['clone']();_0x41eb65[_0xb7b3('0x26')]('ut.UserId\x20=\x20?',_0x17ffee['id']);_0x5c6b27[_0xb7b3('0x67')](db[_0xb7b3('0x5a')][_0xb7b3('0x28')](_0x41eb65[_0xb7b3('0x68')](),{'type':db[_0xb7b3('0x5a')][_0xb7b3('0x69')][_0xb7b3('0x6a')]})['then'](function(_0x47a65a){if(_0x47a65a[_0xb7b3('0x30')]===0x1){return _0x17ffee['id'];}else{var _0x2be45a=_[_0xb7b3('0x6b')](_[_0xb7b3('0x20')](_0x47a65a,_0xb7b3('0x6c')),function(_0x3583b2){return _[_0xb7b3('0x6d')](_0x23bf90,_0x3583b2);});if(_0x2be45a){return _0x17ffee['id'];}}}));}}return BPromise[_0xb7b3('0x6e')](_0x5c6b27)[_0xb7b3('0x18')](function(_0x25d8bd){_0x4e7f24=_(_0x4e7f24)['union'](_0x25d8bd)['compact']()['value']();return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x4f7461[_0xb7b3('0x2a')]['id']}})['then'](function(_0x20f337){return db['sequelize'][_0xb7b3('0x5b')](function(_0x400032){return _0x20f337[_0xb7b3('0x5e')](_0x4f7461[_0xb7b3('0x28')][_0xb7b3('0x55')],{'transaction':_0x400032})[_0xb7b3('0x18')](function(){if(!_['isEmpty'](_0x4e7f24)){return _0x20f337[_0xb7b3('0x6f')](_0x4e7f24,{'transaction':_0x400032});}})[_0xb7b3('0x18')](function(){_0x4e7f24[_0xb7b3('0x5c')](function(_0x43a2bf){socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':_0x43a2bf,'ChatQueueId':_0x20f337['id']});});});});});});})[_0xb7b3('0x18')](respondWithStatusCode(_0xd56f49,null))[_0xb7b3('0x29')](handleError(_0xd56f49,null));};exports['addAgents']=function(_0x4f2e10,_0x17332d){return db[_0xb7b3('0x21')]['find']({'where':{'id':_0x4f2e10[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x17332d,null))[_0xb7b3('0x18')](function(_0x2d23d6){if(_0x2d23d6){return _0x2d23d6[_0xb7b3('0x70')](_0x4f2e10['body']['ids'],_['omit'](_0x4f2e10['body'],['ids','id'])||{})[_0xb7b3('0x71')](function(_0x31d5d9){for(var _0x13cd15=0x0;_0x13cd15<_0x4f2e10[_0xb7b3('0x35')][_0xb7b3('0x55')][_0xb7b3('0x30')];_0x13cd15+=0x1){socket[_0xb7b3('0x5d')](_0xb7b3('0x72'),{'UserId':Number(_0x4f2e10[_0xb7b3('0x35')]['ids'][_0x13cd15]),'ChatQueueId':Number(_0x4f2e10['params']['id'])});}return _0x31d5d9;});}})['then'](respondWithResult(_0x17332d,null))['catch'](handleError(_0x17332d,null));};exports[_0xb7b3('0x6f')]=function(_0x239445,_0x5ed5e5){return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x239445[_0xb7b3('0x2a')]['id']}})['then'](handleEntityNotFound(_0x5ed5e5,null))[_0xb7b3('0x18')](function(_0x292b07){if(_0x292b07){return _0x292b07[_0xb7b3('0x6f')](_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')])['then'](function(){if(_['isArray'](_0x239445['query'][_0xb7b3('0x55')])){for(var _0x4f7ec3=0x0;_0x4f7ec3<_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')][_0xb7b3('0x30')];_0x4f7ec3+=0x1){socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':Number(_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')][_0x4f7ec3]),'ChatQueueId':Number(_0x239445['params']['id'])});}}else{socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':Number(_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')]),'ChatQueueId':Number(_0x239445['params']['id'])});}});}})['then'](respondWithStatusCode(_0x5ed5e5,null))[_0xb7b3('0x29')](handleError(_0x5ed5e5,null));};exports[_0xb7b3('0x73')]=function(_0x525e23,_0xb37a68){var _0x54adff={};var _0x1b4f42={};var _0x576079;var _0xea55b;return db[_0xb7b3('0x21')]['findOne']({'where':{'id':_0x525e23[_0xb7b3('0x2a')]['id']}})['then'](handleEntityNotFound(_0xb37a68,null))[_0xb7b3('0x18')](function(_0x12b4c5){if(_0x12b4c5){_0x576079=_0x12b4c5;_0x1b4f42['model']=_[_0xb7b3('0x2c')](db['User'][_0xb7b3('0x22')]);_0x1b4f42[_0xb7b3('0x28')]=_[_0xb7b3('0x2c')](_0x525e23['query']);_0x1b4f42[_0xb7b3('0x2d')]=_['intersection'](_0x1b4f42[_0xb7b3('0x2b')],_0x1b4f42[_0xb7b3('0x28')]);_0x54adff[_0xb7b3('0x2f')]=_[_0xb7b3('0x2e')](_0x1b4f42[_0xb7b3('0x2b')],qs['fields'](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x54adff[_0xb7b3('0x2f')]=_0x54adff['attributes'][_0xb7b3('0x30')]?_0x54adff[_0xb7b3('0x2f')]:_0x1b4f42['model'];_0x54adff['order']=qs[_0xb7b3('0x43')](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x54adff[_0xb7b3('0x26')]=qs[_0xb7b3('0x2d')](_[_0xb7b3('0x44')](_0x525e23[_0xb7b3('0x28')],_0x1b4f42[_0xb7b3('0x2d')]));if(_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x46')]){_0x54adff[_0xb7b3('0x26')]=_[_0xb7b3('0x31')](_0x54adff['where'],{'$or':_['map'](_0x54adff[_0xb7b3('0x2f')],function(_0x4696c7){var _0x6e3f63={};_0x6e3f63[_0x4696c7]={'$like':'%'+_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x46')]+'%'};return _0x6e3f63;})});}_0x54adff=_['merge']({},_0x54adff,_0x525e23['options']);return _0x576079[_0xb7b3('0x73')](_0x54adff);}})[_0xb7b3('0x18')](function(_0x19c3d3){if(_0x19c3d3){_0xea55b=_0x19c3d3[_0xb7b3('0x30')];if(!_0x525e23['query'][_0xb7b3('0x74')]('nolimit')){_0x54adff['limit']=qs[_0xb7b3('0x12')](_0x525e23[_0xb7b3('0x28')]['limit']);_0x54adff[_0xb7b3('0x10')]=qs['offset'](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x10')]);}return _0x576079['getAgents'](_0x54adff);}})[_0xb7b3('0x18')](function(_0xf97ab8){if(_0xf97ab8){return _0xf97ab8?{'count':_0xea55b,'rows':_0xf97ab8}:null;}})[_0xb7b3('0x18')](respondWithResult(_0xb37a68,null))[_0xb7b3('0x29')](handleError(_0xb37a68,null));};
\ No newline at end of file