Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 735607d..98f8a7d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1bf5=['clone','push','toString','QueryTypes','SELECT','includes','all','union','compact','value','transaction','isEmpty','removeAgents','userChatQueue:remove','addAgents','omit','spread','userChatQueue:save','getAgents','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./chatQueue.socket','register','jayson/promise','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','sendStatus','status','json','offset','limit','set','Content-Range','apply','reject','destroy','get','ChatQueues','UserProfileResource','stack','name','send','ChatQueue','rawAttributes','fieldName','type','model','map','keys','query','intersection','attributes','fields','length','nolimit','sort','filters','pick','filter','where','merge','VIRTUAL','options','count','includeAll','rows','catch','show','params','find','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','describe','getMembers','UserChatQueue','hasOwnProperty','order','ChatQueueId','findAll','User','findAndCountAll','UserId','agent','chatPause','updatedAt','format','%s/%s','SIP','createdAt','findOne','Team','getTeams','addTeams','ids','Agents','online','voicePause','sequelize','each','forEach','emit','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?'];(function(_0x4e676e,_0x2a7c6d){var _0x336a3c=function(_0x4767c4){while(--_0x4767c4){_0x4e676e['push'](_0x4e676e['shift']());}};_0x336a3c(++_0x2a7c6d);}(_0x1bf5,0x13b));var _0x51bf=function(_0x413c32,_0x1e79a4){_0x413c32=_0x413c32-0x0;var _0x37de17=_0x1bf5[_0x413c32];return _0x37de17;};'use strict';var pdf=require(_0x51bf('0x0'));var emlformat=require(_0x51bf('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x51bf('0x2'));var jsonpatch=require(_0x51bf('0x3'));var rp=require(_0x51bf('0x4'));var moment=require(_0x51bf('0x5'));var BPromise=require(_0x51bf('0x6'));var Mustache=require(_0x51bf('0x7'));var util=require(_0x51bf('0x8'));var path=require(_0x51bf('0x9'));var sox=require('sox');var csv=require(_0x51bf('0xa'));var ejs=require(_0x51bf('0xb'));var fs=require('fs');var _=require(_0x51bf('0xc'));var squel=require(_0x51bf('0xd'));var crypto=require('crypto');var jsforce=require(_0x51bf('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x51bf('0xa'));var querystring=require(_0x51bf('0xf'));var Papa=require('papaparse');var Redis=require(_0x51bf('0x10'));var authService=require(_0x51bf('0x11'));var qs=require(_0x51bf('0x12'));var as=require(_0x51bf('0x13'));var hardwareService=require(_0x51bf('0x14'));var logger=require(_0x51bf('0x15'))('api');var utils=require(_0x51bf('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x51bf('0x17'));var db=require(_0x51bf('0x18'))['db'];config['redis']=_[_0x51bf('0x19')](config['redis'],{'host':_0x51bf('0x1a'),'port':0x18eb});var socket=require(_0x51bf('0x1b'))(new Redis(config[_0x51bf('0x1c')]));require(_0x51bf('0x1d'))[_0x51bf('0x1e')](socket);var jayson=require(_0x51bf('0x1f'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x2e43b7,_0x31ebb4,_0x233a47,_0x5c8854){return new BPromise(function(_0x27c85c,_0x51c629){var _0x5efbdc=_0x5c8854||client;return _0x5efbdc[_0x51bf('0x20')](_0x2e43b7,_0x233a47)[_0x51bf('0x21')](function(_0x42333b){logger[_0x51bf('0x22')](_0x51bf('0x23'),_0x31ebb4,_0x51bf('0x24'));logger['debug'](_0x51bf('0x25'),_0x31ebb4,_0x51bf('0x24'),JSON[_0x51bf('0x26')](_0x42333b));if(_0x42333b['error']){if(_0x42333b[_0x51bf('0x27')][_0x51bf('0x28')]===0x1f4){logger[_0x51bf('0x27')]('ChatQueue,\x20%s,\x20%s',_0x31ebb4,_0x42333b[_0x51bf('0x27')][_0x51bf('0x29')]);return _0x51c629(_0x42333b['error']['message']);}logger[_0x51bf('0x27')](_0x51bf('0x23'),_0x31ebb4,_0x42333b[_0x51bf('0x27')][_0x51bf('0x29')]);return _0x27c85c(_0x42333b['error'][_0x51bf('0x29')]);}else{logger[_0x51bf('0x22')]('ChatQueue,\x20%s,\x20%s',_0x31ebb4,_0x51bf('0x24'));_0x27c85c(_0x42333b[_0x51bf('0x2a')][_0x51bf('0x29')]);}})['catch'](function(_0x2562a0){logger[_0x51bf('0x27')](_0x51bf('0x23'),_0x31ebb4,_0x2562a0);_0x51c629(_0x2562a0);});});}function respondWithStatusCode(_0x5a30b2,_0x3caab3){_0x3caab3=_0x3caab3||0xcc;return function(_0x738cff){if(_0x738cff){return _0x5a30b2[_0x51bf('0x2b')](_0x3caab3);}return _0x5a30b2[_0x51bf('0x2c')](_0x3caab3)['end']();};}function respondWithResult(_0x30d08b,_0x19e889){_0x19e889=_0x19e889||0xc8;return function(_0x6fa167){if(_0x6fa167){return _0x30d08b[_0x51bf('0x2c')](_0x19e889)[_0x51bf('0x2d')](_0x6fa167);}};}function respondWithFilteredResult(_0x1f9898,_0x1f45a2){return function(_0x40b857){if(_0x40b857){var _0x4936c0=_0x40b857['count'],_0x468ed3=_0x1f45a2[_0x51bf('0x2e')],_0x392bb1=_0x1f45a2[_0x51bf('0x2e')]+_0x1f45a2[_0x51bf('0x2f')],_0x582f4a;if(_0x392bb1>=_0x4936c0){_0x392bb1=_0x4936c0;_0x582f4a=0xc8;}else{_0x582f4a=0xce;}_0x1f9898[_0x51bf('0x2c')](_0x582f4a);return _0x1f9898[_0x51bf('0x30')](_0x51bf('0x31'),_0x468ed3+'-'+_0x392bb1+'/'+_0x4936c0)[_0x51bf('0x2d')](_0x40b857);}return null;};}function patchUpdates(_0xec0484){return function(_0x3bcebe){try{jsonpatch[_0x51bf('0x32')](_0x3bcebe,_0xec0484,!![]);}catch(_0x5df15e){return BPromise[_0x51bf('0x33')](_0x5df15e);}return _0x3bcebe['save']();};}function saveUpdates(_0xaa3766,_0x59f52d){return function(_0x552d61){if(_0x552d61){return _0x552d61['update'](_0xaa3766)['then'](function(_0x5938f2){return _0x5938f2;});}return null;};}function removeEntity(_0x6d4e2e,_0x188ad4){return function(_0x403192){if(_0x403192){return _0x403192[_0x51bf('0x34')]()[_0x51bf('0x21')](function(){var _0x3f6b74=_0x403192[_0x51bf('0x35')]({'plain':!![]});var _0x58f917=_0x51bf('0x36');return db[_0x51bf('0x37')][_0x51bf('0x34')]({'where':{'type':_0x58f917,'resourceId':_0x3f6b74['id']}})[_0x51bf('0x21')](function(){return _0x403192;});})['then'](function(){_0x6d4e2e['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x736acf,_0x56d99e){return function(_0x28f4a2){if(!_0x28f4a2){_0x736acf[_0x51bf('0x2b')](0x194);}return _0x28f4a2;};}function handleError(_0x14a2a4,_0x5a0043){_0x5a0043=_0x5a0043||0x1f4;return function(_0x20630e){logger['error'](_0x20630e[_0x51bf('0x38')]);if(_0x20630e[_0x51bf('0x39')]){delete _0x20630e[_0x51bf('0x39')];}_0x14a2a4[_0x51bf('0x2c')](_0x5a0043)[_0x51bf('0x3a')](_0x20630e);};}exports['index']=function(_0x39417c,_0x52f61e){var _0x15348f={},_0x17f3e4={},_0x3f0a4d={'count':0x0,'rows':[]};var _0xb98bb4=_['map'](db[_0x51bf('0x3b')][_0x51bf('0x3c')],function(_0x3d34e1){return{'name':_0x3d34e1[_0x51bf('0x3d')],'type':_0x3d34e1[_0x51bf('0x3e')]['key']};});_0x17f3e4[_0x51bf('0x3f')]=_[_0x51bf('0x40')](_0xb98bb4,'name');_0x17f3e4['query']=_[_0x51bf('0x41')](_0x39417c[_0x51bf('0x42')]);_0x17f3e4['filters']=_[_0x51bf('0x43')](_0x17f3e4['model'],_0x17f3e4[_0x51bf('0x42')]);_0x15348f[_0x51bf('0x44')]=_[_0x51bf('0x43')](_0x17f3e4['model'],qs[_0x51bf('0x45')](_0x39417c['query'][_0x51bf('0x45')]));_0x15348f[_0x51bf('0x44')]=_0x15348f[_0x51bf('0x44')][_0x51bf('0x46')]?_0x15348f['attributes']:_0x17f3e4[_0x51bf('0x3f')];if(!_0x39417c[_0x51bf('0x42')]['hasOwnProperty'](_0x51bf('0x47'))){_0x15348f[_0x51bf('0x2f')]=qs[_0x51bf('0x2f')](_0x39417c[_0x51bf('0x42')][_0x51bf('0x2f')]);_0x15348f[_0x51bf('0x2e')]=qs['offset'](_0x39417c[_0x51bf('0x42')][_0x51bf('0x2e')]);}_0x15348f['order']=qs['sort'](_0x39417c[_0x51bf('0x42')][_0x51bf('0x48')]);_0x15348f['where']=qs[_0x51bf('0x49')](_[_0x51bf('0x4a')](_0x39417c[_0x51bf('0x42')],_0x17f3e4[_0x51bf('0x49')]),_0xb98bb4);if(_0x39417c['query'][_0x51bf('0x4b')]){_0x15348f[_0x51bf('0x4c')]=_[_0x51bf('0x4d')](_0x15348f[_0x51bf('0x4c')],{'$or':_[_0x51bf('0x40')](_0xb98bb4,function(_0x43dbe1){if(_0x43dbe1[_0x51bf('0x3e')]!==_0x51bf('0x4e')){var _0x5a71d4={};_0x5a71d4[_0x43dbe1[_0x51bf('0x39')]]={'$like':'%'+_0x39417c[_0x51bf('0x42')]['filter']+'%'};return _0x5a71d4;}})});}_0x15348f=_[_0x51bf('0x4d')]({},_0x15348f,_0x39417c[_0x51bf('0x4f')]);var _0x2a7b8b={'where':_0x15348f[_0x51bf('0x4c')]};return db[_0x51bf('0x3b')][_0x51bf('0x50')](_0x2a7b8b)['then'](function(_0x5d1e49){_0x3f0a4d['count']=_0x5d1e49;if(_0x39417c['query'][_0x51bf('0x51')]){_0x15348f['include']=[{'all':!![]}];}return db[_0x51bf('0x3b')]['findAll'](_0x15348f);})['then'](function(_0x3aef92){_0x3f0a4d[_0x51bf('0x52')]=_0x3aef92;return _0x3f0a4d;})[_0x51bf('0x21')](respondWithFilteredResult(_0x52f61e,_0x15348f))[_0x51bf('0x53')](handleError(_0x52f61e,null));};exports[_0x51bf('0x54')]=function(_0x14c361,_0x297b5f){var _0x2bec7c={'raw':!![],'where':{'id':_0x14c361[_0x51bf('0x55')]['id']}},_0x52c99d={};_0x52c99d[_0x51bf('0x3f')]=_[_0x51bf('0x41')](db[_0x51bf('0x3b')][_0x51bf('0x3c')]);_0x52c99d[_0x51bf('0x42')]=_[_0x51bf('0x41')](_0x14c361[_0x51bf('0x42')]);_0x52c99d['filters']=_['intersection'](_0x52c99d[_0x51bf('0x3f')],_0x52c99d[_0x51bf('0x42')]);_0x2bec7c[_0x51bf('0x44')]=_[_0x51bf('0x43')](_0x52c99d[_0x51bf('0x3f')],qs[_0x51bf('0x45')](_0x14c361[_0x51bf('0x42')][_0x51bf('0x45')]));_0x2bec7c[_0x51bf('0x44')]=_0x2bec7c['attributes']['length']?_0x2bec7c['attributes']:_0x52c99d[_0x51bf('0x3f')];if(_0x14c361[_0x51bf('0x42')][_0x51bf('0x51')]){_0x2bec7c['include']=[{'all':!![]}];}_0x2bec7c=_[_0x51bf('0x4d')]({},_0x2bec7c,_0x14c361['options']);return db['ChatQueue'][_0x51bf('0x56')](_0x2bec7c)['then'](handleEntityNotFound(_0x297b5f,null))[_0x51bf('0x21')](respondWithResult(_0x297b5f,null))[_0x51bf('0x53')](handleError(_0x297b5f,null));};exports[_0x51bf('0x57')]=function(_0x1fb31f,_0x22c53b){return db[_0x51bf('0x3b')][_0x51bf('0x57')](_0x1fb31f['body'],{})[_0x51bf('0x21')](function(_0x76114){var _0x45fc09=_0x1fb31f['user'][_0x51bf('0x35')]({'plain':!![]});if(!_0x45fc09)throw new Error(_0x51bf('0x58'));if(_0x45fc09[_0x51bf('0x59')]==='user'){var _0x315b13=_0x76114['get']({'plain':!![]});var _0x7da5db='ChatQueues';return db['UserProfileSection'][_0x51bf('0x56')]({'where':{'name':_0x7da5db,'userProfileId':_0x45fc09['userProfileId']},'raw':!![]})['then'](function(_0x49b189){if(_0x49b189&&_0x49b189['autoAssociation']===0x0){return db['UserProfileResource'][_0x51bf('0x57')]({'name':_0x315b13[_0x51bf('0x39')],'resourceId':_0x315b13['id'],'type':_0x49b189[_0x51bf('0x39')],'sectionId':_0x49b189['id']},{})[_0x51bf('0x21')](function(){return _0x76114;});}else{return _0x76114;}})['catch'](function(_0x39a8c6){logger['error'](_0x51bf('0x5a'),_0x39a8c6);throw _0x39a8c6;});}return _0x76114;})[_0x51bf('0x21')](respondWithResult(_0x22c53b,0xc9))[_0x51bf('0x53')](handleError(_0x22c53b,null));};exports[_0x51bf('0x5b')]=function(_0x1dbf5e,_0x47bb29){if(_0x1dbf5e['body']['id']){delete _0x1dbf5e[_0x51bf('0x5c')]['id'];}return db[_0x51bf('0x3b')][_0x51bf('0x56')]({'where':{'id':_0x1dbf5e['params']['id']}})['then'](handleEntityNotFound(_0x47bb29,null))[_0x51bf('0x21')](saveUpdates(_0x1dbf5e[_0x51bf('0x5c')],null))[_0x51bf('0x21')](respondWithResult(_0x47bb29,null))[_0x51bf('0x53')](handleError(_0x47bb29,null));};exports[_0x51bf('0x34')]=function(_0x33d2d2,_0xfb7560){return db[_0x51bf('0x3b')]['find']({'where':{'id':_0x33d2d2[_0x51bf('0x55')]['id']}})[_0x51bf('0x21')](handleEntityNotFound(_0xfb7560,null))[_0x51bf('0x21')](removeEntity(_0xfb7560,null))[_0x51bf('0x53')](handleError(_0xfb7560,null));};exports[_0x51bf('0x5d')]=function(_0x2149e3,_0x54dfcb){return db['ChatQueue'][_0x51bf('0x5d')]()[_0x51bf('0x21')](respondWithResult(_0x54dfcb,null))[_0x51bf('0x53')](handleError(_0x54dfcb,null));};exports[_0x51bf('0x5e')]=function(_0x222533,_0x3a8808,_0x1fabc2){var _0x2ff63d={'raw':!![],'where':{}},_0xb580b0={},_0x341696;return db[_0x51bf('0x3b')]['findOne']({'where':{'id':_0x222533[_0x51bf('0x55')]['id']}})[_0x51bf('0x21')](handleEntityNotFound(_0x3a8808,null))[_0x51bf('0x21')](function(_0x46ff53){if(_0x46ff53){_0x341696=_0x46ff53[_0x51bf('0x35')]({'plain':!![]});_0xb580b0[_0x51bf('0x3f')]=_['keys'](db[_0x51bf('0x5f')][_0x51bf('0x3c')]);_0xb580b0['query']=_[_0x51bf('0x41')](_0x222533['query']);_0xb580b0[_0x51bf('0x49')]=_['intersection'](_0xb580b0[_0x51bf('0x3f')],_0xb580b0[_0x51bf('0x42')]);_0x2ff63d[_0x51bf('0x44')]=_[_0x51bf('0x43')](_0xb580b0[_0x51bf('0x3f')],qs[_0x51bf('0x45')](_0x222533[_0x51bf('0x42')][_0x51bf('0x45')]));_0x2ff63d[_0x51bf('0x44')]=_0x2ff63d['attributes'][_0x51bf('0x46')]?_0x2ff63d[_0x51bf('0x44')]:_0xb580b0[_0x51bf('0x3f')];if(!_0x222533['query'][_0x51bf('0x60')](_0x51bf('0x47'))){_0x2ff63d['limit']=qs[_0x51bf('0x2f')](_0x222533[_0x51bf('0x42')]['limit']);_0x2ff63d[_0x51bf('0x2e')]=qs[_0x51bf('0x2e')](_0x222533[_0x51bf('0x42')]['offset']);}_0x2ff63d[_0x51bf('0x61')]=qs[_0x51bf('0x48')](_0x222533[_0x51bf('0x42')][_0x51bf('0x48')]);_0x2ff63d[_0x51bf('0x4c')]=qs[_0x51bf('0x49')](_[_0x51bf('0x4a')](_0x222533[_0x51bf('0x42')],_0xb580b0['filters']));_0x2ff63d['where'][_0x51bf('0x62')]=_0x46ff53['id'];if(_0x222533[_0x51bf('0x42')][_0x51bf('0x4b')]){_0x2ff63d[_0x51bf('0x4c')]=_['merge'](_0x2ff63d[_0x51bf('0x4c')],{'$or':_[_0x51bf('0x40')](_0x2ff63d[_0x51bf('0x44')],function(_0xa49246){var _0x376855={};_0x376855[_0xa49246]={'$like':'%'+_0x222533[_0x51bf('0x42')][_0x51bf('0x4b')]+'%'};return _0x376855;})});}_0x2ff63d=_[_0x51bf('0x4d')]({},_0x2ff63d,_0x222533[_0x51bf('0x4f')]);return db['UserChatQueue'][_0x51bf('0x63')](_0x2ff63d);}})[_0x51bf('0x21')](function(_0x58a885){if(_0x58a885){return db[_0x51bf('0x64')][_0x51bf('0x65')]({'where':{'id':_[_0x51bf('0x40')](_0x58a885,_0x51bf('0x66')),'role':_0x51bf('0x67')},'attributes':['id',_0x51bf('0x39'),_0x51bf('0x68'),_0x51bf('0x69'),'createdAt']});}})[_0x51bf('0x21')](function(_0x4c5123){if(_0x4c5123){return{'count':_0x4c5123['count'],'rows':_['map'](_0x4c5123[_0x51bf('0x52')],function(_0xc3acbb){return{'membername':_0xc3acbb['name'],'UserId':_0xc3acbb['id'],'queue_name':_0x341696[_0x51bf('0x39')],'ChatQueueId':_0x341696['id'],'interface':util[_0x51bf('0x6a')](_0x51bf('0x6b'),_0x51bf('0x6c'),_0xc3acbb[_0x51bf('0x39')]),'penalty':0x0,'paused':_0xc3acbb[_0x51bf('0x68')],'createdAt':_0xc3acbb[_0x51bf('0x6d')],'updatedAt':_0xc3acbb[_0x51bf('0x69')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x3a8808,_0x2ff63d))[_0x51bf('0x53')](handleError(_0x3a8808,null));};exports['getTeams']=function(_0x17db26,_0x221642,_0x36c53c){var _0x4fe1f6={};var _0x37c87a={};var _0x47db23;var _0x4cb195;return db[_0x51bf('0x3b')][_0x51bf('0x6e')]({'where':{'id':_0x17db26[_0x51bf('0x55')]['id']}})[_0x51bf('0x21')](handleEntityNotFound(_0x221642,null))[_0x51bf('0x21')](function(_0xe3125b){if(_0xe3125b){_0x47db23=_0xe3125b;_0x37c87a[_0x51bf('0x3f')]=_['keys'](db[_0x51bf('0x6f')][_0x51bf('0x3c')]);_0x37c87a[_0x51bf('0x42')]=_[_0x51bf('0x41')](_0x17db26[_0x51bf('0x42')]);_0x37c87a[_0x51bf('0x49')]=_[_0x51bf('0x43')](_0x37c87a['model'],_0x37c87a[_0x51bf('0x42')]);_0x4fe1f6[_0x51bf('0x44')]=_[_0x51bf('0x43')](_0x37c87a[_0x51bf('0x3f')],qs[_0x51bf('0x45')](_0x17db26['query'][_0x51bf('0x45')]));_0x4fe1f6[_0x51bf('0x44')]=_0x4fe1f6['attributes'][_0x51bf('0x46')]?_0x4fe1f6[_0x51bf('0x44')]:_0x37c87a[_0x51bf('0x3f')];_0x4fe1f6['order']=qs[_0x51bf('0x48')](_0x17db26['query']['sort']);_0x4fe1f6[_0x51bf('0x4c')]=qs[_0x51bf('0x49')](_[_0x51bf('0x4a')](_0x17db26['query'],_0x37c87a['filters']));if(_0x17db26[_0x51bf('0x42')]['filter']){_0x4fe1f6[_0x51bf('0x4c')]=_[_0x51bf('0x4d')](_0x4fe1f6[_0x51bf('0x4c')],{'$or':_[_0x51bf('0x40')](_0x4fe1f6['attributes'],function(_0x19d50d){var _0x442388={};_0x442388[_0x19d50d]={'$like':'%'+_0x17db26[_0x51bf('0x42')]['filter']+'%'};return _0x442388;})});}_0x4fe1f6=_[_0x51bf('0x4d')]({},_0x4fe1f6,_0x17db26[_0x51bf('0x4f')]);return _0x47db23[_0x51bf('0x70')](_0x4fe1f6);}})['then'](function(_0x56dd70){if(_0x56dd70){_0x4cb195=_0x56dd70[_0x51bf('0x46')];if(!_0x17db26[_0x51bf('0x42')][_0x51bf('0x60')](_0x51bf('0x47'))){_0x4fe1f6[_0x51bf('0x2f')]=qs['limit'](_0x17db26['query']['limit']);_0x4fe1f6[_0x51bf('0x2e')]=qs['offset'](_0x17db26[_0x51bf('0x42')][_0x51bf('0x2e')]);}return _0x47db23['getTeams'](_0x4fe1f6);}})[_0x51bf('0x21')](function(_0x229627){if(_0x229627){return _0x229627?{'count':_0x4cb195,'rows':_0x229627}:null;}})['then'](respondWithResult(_0x221642,null))[_0x51bf('0x53')](handleError(_0x221642,null));};exports[_0x51bf('0x71')]=function(_0x3609d5,_0x406e98,_0x170de5){var _0x1acb31=_0x3609d5['body'][_0x51bf('0x72')];return db[_0x51bf('0x6f')][_0x51bf('0x63')]({'where':{'id':_0x1acb31},'attributes':['id'],'include':[{'model':db[_0x51bf('0x64')],'as':_0x51bf('0x73'),'attributes':['id',_0x51bf('0x39'),_0x51bf('0x74'),_0x51bf('0x75'),'interface'],'raw':!![]}]})['then'](function(_0x479f91){if(_0x479f91){var _0x3c1670=_['flatMap'](_0x479f91,function(_0x13d2dd){var _0x3b7de4=_0x13d2dd[_0x51bf('0x35')]({'plain':!![]});return _0x3b7de4['Agents'];});return db[_0x51bf('0x3b')]['find']({'where':{'id':_0x3609d5['params']['id']}})[_0x51bf('0x21')](function(_0x53b89a){return db[_0x51bf('0x76')]['transaction'](function(_0x2693a0){return _0x53b89a[_0x51bf('0x71')](_0x1acb31,{'transaction':_0x2693a0})[_0x51bf('0x21')](function(){return BPromise[_0x51bf('0x77')](_0x3c1670,function(_0x5c6643){return db[_0x51bf('0x5f')]['findOrCreate']({'where':{'UserId':_0x5c6643['id'],'ChatQueueId':_0x3609d5[_0x51bf('0x55')]['id']},'transaction':_0x2693a0});});})[_0x51bf('0x21')](function(){_0x3c1670[_0x51bf('0x78')](function(_0x25c430){socket[_0x51bf('0x79')]('userChatQueue:save',{'UserId':_0x25c430['id'],'ChatQueueId':_0x53b89a['id']});});});});});}})[_0x51bf('0x21')](respondWithStatusCode(_0x406e98,null))[_0x51bf('0x53')](handleError(_0x406e98,null));};exports['removeTeams']=function(_0x3e6fdd,_0x92825,_0x520437){return db[_0x51bf('0x6f')][_0x51bf('0x63')]({'where':{'id':_0x3e6fdd[_0x51bf('0x42')]['ids']},'attributes':['id'],'include':[{'model':db[_0x51bf('0x64')],'as':_0x51bf('0x73'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x92825,null))[_0x51bf('0x21')](function(_0x33de7f){var _0x53a3cd=_[_0x51bf('0x40')](_0x33de7f,'id');var _0x53850f=[];var _0x42f78f=[];var _0x541481=squel['select']();_0x541481['field'](_0x51bf('0x7a'))[_0x51bf('0x7b')](_0x51bf('0x7c'),'tq')[_0x51bf('0x7d')](_0x51bf('0x7e'),'ut',_0x51bf('0x7f'))[_0x51bf('0x4c')](_0x51bf('0x80'),_0x3e6fdd[_0x51bf('0x55')]['id']);for(var _0x15b73f=0x0;_0x15b73f<_0x33de7f[_0x51bf('0x46')];_0x15b73f+=0x1){let _0x225a7e=_0x33de7f[_0x15b73f];for(var _0x163c34=0x0;_0x163c34<_0x225a7e[_0x51bf('0x73')][_0x51bf('0x46')];_0x163c34+=0x1){let _0x51754d=_0x225a7e[_0x51bf('0x73')][_0x163c34];var _0x1d1f1b=_0x541481[_0x51bf('0x81')]();_0x1d1f1b[_0x51bf('0x4c')]('ut.UserId\x20=\x20?',_0x51754d['id']);_0x42f78f[_0x51bf('0x82')](db[_0x51bf('0x76')][_0x51bf('0x42')](_0x1d1f1b[_0x51bf('0x83')](),{'type':db[_0x51bf('0x76')][_0x51bf('0x84')][_0x51bf('0x85')]})[_0x51bf('0x21')](function(_0x5c3e1e){if(_0x5c3e1e[_0x51bf('0x46')]===0x1){return _0x51754d['id'];}else{var _0x37d9b6=_['every'](_[_0x51bf('0x40')](_0x5c3e1e,'TeamId'),function(_0x1717bf){return _[_0x51bf('0x86')](_0x53a3cd,_0x1717bf);});if(_0x37d9b6){return _0x51754d['id'];}}}));}}return BPromise[_0x51bf('0x87')](_0x42f78f)[_0x51bf('0x21')](function(_0x134936){_0x53850f=_(_0x53850f)[_0x51bf('0x88')](_0x134936)[_0x51bf('0x89')]()[_0x51bf('0x8a')]();return db[_0x51bf('0x3b')][_0x51bf('0x56')]({'where':{'id':_0x3e6fdd[_0x51bf('0x55')]['id']}})['then'](function(_0x558f98){return db[_0x51bf('0x76')][_0x51bf('0x8b')](function(_0x1c9fc6){return _0x558f98['removeTeams'](_0x3e6fdd[_0x51bf('0x42')][_0x51bf('0x72')],{'transaction':_0x1c9fc6})[_0x51bf('0x21')](function(){if(!_[_0x51bf('0x8c')](_0x53850f)){return _0x558f98[_0x51bf('0x8d')](_0x53850f,{'transaction':_0x1c9fc6});}})[_0x51bf('0x21')](function(){_0x53850f[_0x51bf('0x78')](function(_0x2930a2){socket[_0x51bf('0x79')](_0x51bf('0x8e'),{'UserId':_0x2930a2,'ChatQueueId':_0x558f98['id']});});});});});});})[_0x51bf('0x21')](respondWithStatusCode(_0x92825,null))['catch'](handleError(_0x92825,null));};exports[_0x51bf('0x8f')]=function(_0x216d70,_0x3553e6,_0x194f93){return db['ChatQueue'][_0x51bf('0x56')]({'where':{'id':_0x216d70[_0x51bf('0x55')]['id']}})[_0x51bf('0x21')](handleEntityNotFound(_0x3553e6,null))[_0x51bf('0x21')](function(_0x30f865){if(_0x30f865){return _0x30f865[_0x51bf('0x8f')](_0x216d70[_0x51bf('0x5c')][_0x51bf('0x72')],_[_0x51bf('0x90')](_0x216d70[_0x51bf('0x5c')],[_0x51bf('0x72'),'id'])||{})[_0x51bf('0x91')](function(_0xb01c78){for(var _0x176ed8=0x0;_0x176ed8<_0x216d70['body'][_0x51bf('0x72')][_0x51bf('0x46')];_0x176ed8+=0x1){socket[_0x51bf('0x79')](_0x51bf('0x92'),{'UserId':_0x216d70['body']['ids'][_0x176ed8],'ChatQueueId':_0x216d70[_0x51bf('0x55')]['id']});}return _0xb01c78;});}})[_0x51bf('0x21')](respondWithResult(_0x3553e6,null))[_0x51bf('0x53')](handleError(_0x3553e6,null));};exports[_0x51bf('0x8d')]=function(_0x41b7ef,_0x698055,_0x235c93){return db[_0x51bf('0x3b')][_0x51bf('0x56')]({'where':{'id':_0x41b7ef[_0x51bf('0x55')]['id']}})[_0x51bf('0x21')](handleEntityNotFound(_0x698055,null))[_0x51bf('0x21')](function(_0x3cf1a0){if(_0x3cf1a0){return _0x3cf1a0[_0x51bf('0x8d')](_0x41b7ef[_0x51bf('0x42')]['ids'])[_0x51bf('0x21')](function(){if(_['isArray'](_0x41b7ef[_0x51bf('0x42')][_0x51bf('0x72')])){for(var _0x1ba012=0x0;_0x1ba012<_0x41b7ef[_0x51bf('0x42')][_0x51bf('0x72')]['length'];_0x1ba012+=0x1){socket[_0x51bf('0x79')](_0x51bf('0x8e'),{'UserId':Number(_0x41b7ef[_0x51bf('0x42')][_0x51bf('0x72')][_0x1ba012]),'ChatQueueId':Number(_0x41b7ef[_0x51bf('0x55')]['id'])});}}else{socket['emit'](_0x51bf('0x8e'),{'UserId':Number(_0x41b7ef['query'][_0x51bf('0x72')]),'ChatQueueId':Number(_0x41b7ef[_0x51bf('0x55')]['id'])});}});}})[_0x51bf('0x21')](respondWithStatusCode(_0x698055,null))['catch'](handleError(_0x698055,null));};exports[_0x51bf('0x93')]=function(_0x7a2566,_0xc52188,_0x2f900f){var _0x28e89e={};var _0x1a85d3={};var _0x34a90b;var _0x1f08fd;return db['ChatQueue'][_0x51bf('0x6e')]({'where':{'id':_0x7a2566[_0x51bf('0x55')]['id']}})[_0x51bf('0x21')](handleEntityNotFound(_0xc52188,null))[_0x51bf('0x21')](function(_0x204c28){if(_0x204c28){_0x34a90b=_0x204c28;_0x1a85d3['model']=_[_0x51bf('0x41')](db['User'][_0x51bf('0x3c')]);_0x1a85d3[_0x51bf('0x42')]=_[_0x51bf('0x41')](_0x7a2566['query']);_0x1a85d3[_0x51bf('0x49')]=_[_0x51bf('0x43')](_0x1a85d3[_0x51bf('0x3f')],_0x1a85d3[_0x51bf('0x42')]);_0x28e89e[_0x51bf('0x44')]=_[_0x51bf('0x43')](_0x1a85d3[_0x51bf('0x3f')],qs['fields'](_0x7a2566[_0x51bf('0x42')][_0x51bf('0x45')]));_0x28e89e[_0x51bf('0x44')]=_0x28e89e[_0x51bf('0x44')][_0x51bf('0x46')]?_0x28e89e[_0x51bf('0x44')]:_0x1a85d3['model'];_0x28e89e[_0x51bf('0x61')]=qs[_0x51bf('0x48')](_0x7a2566[_0x51bf('0x42')][_0x51bf('0x48')]);_0x28e89e[_0x51bf('0x4c')]=qs[_0x51bf('0x49')](_[_0x51bf('0x4a')](_0x7a2566[_0x51bf('0x42')],_0x1a85d3['filters']));if(_0x7a2566[_0x51bf('0x42')][_0x51bf('0x4b')]){_0x28e89e['where']=_[_0x51bf('0x4d')](_0x28e89e[_0x51bf('0x4c')],{'$or':_[_0x51bf('0x40')](_0x28e89e[_0x51bf('0x44')],function(_0x3fd4e2){var _0x4a4829={};_0x4a4829[_0x3fd4e2]={'$like':'%'+_0x7a2566['query'][_0x51bf('0x4b')]+'%'};return _0x4a4829;})});}_0x28e89e=_[_0x51bf('0x4d')]({},_0x28e89e,_0x7a2566['options']);return _0x34a90b[_0x51bf('0x93')](_0x28e89e);}})['then'](function(_0x322f9d){if(_0x322f9d){_0x1f08fd=_0x322f9d[_0x51bf('0x46')];if(!_0x7a2566[_0x51bf('0x42')]['hasOwnProperty'](_0x51bf('0x47'))){_0x28e89e[_0x51bf('0x2f')]=qs[_0x51bf('0x2f')](_0x7a2566['query']['limit']);_0x28e89e['offset']=qs[_0x51bf('0x2e')](_0x7a2566[_0x51bf('0x42')][_0x51bf('0x2e')]);}return _0x34a90b[_0x51bf('0x93')](_0x28e89e);}})[_0x51bf('0x21')](function(_0x36cdcb){if(_0x36cdcb){return _0x36cdcb?{'count':_0x1f08fd,'rows':_0x36cdcb}:null;}})[_0x51bf('0x21')](respondWithResult(_0xc52188,null))[_0x51bf('0x53')](handleError(_0xc52188,null));};
\ No newline at end of file
+var _0x4017=['interface','flatMap','sequelize','transaction','UserChatQueue','findOrCreate','forEach','emit','userChatQueue:save','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','push','toString','QueryTypes','every','includes','union','compact','value','isEmpty','removeAgents','userChatQueue:remove','addAgents','omit','spread','isArray','getAgents','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./chatQueue.socket','register','client','http','then','info','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatQueue,\x20%s,\x20%s','message','result','catch','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','get','ChatQueues','UserProfileResource','destroy','end','name','send','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','nolimit','order','sort','where','filter','map','VIRTUAL','ChatQueue','includeAll','include','rows','show','params','keys','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','hasOwnProperty','ChatQueueId','findAll','User','findAndCountAll','UserId','chatPause','updatedAt','createdAt','format','%s/%s','SIP','Team','pick','getTeams','addTeams','ids','Agents','online','voicePause'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x4017,0x157));var _0x7401=function(_0x378255,_0xe7ea62){_0x378255=_0x378255-0x0;var _0x458d4e=_0x4017[_0x378255];return _0x458d4e;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7401('0x0'));var zipdir=require(_0x7401('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7401('0x2'));var moment=require(_0x7401('0x3'));var BPromise=require(_0x7401('0x4'));var Mustache=require(_0x7401('0x5'));var util=require('util');var path=require(_0x7401('0x6'));var sox=require(_0x7401('0x7'));var csv=require(_0x7401('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x7401('0x9'));var _=require(_0x7401('0xa'));var squel=require(_0x7401('0xb'));var crypto=require(_0x7401('0xc'));var jsforce=require(_0x7401('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x7401('0xe'));var Papa=require('papaparse');var Redis=require(_0x7401('0xf'));var authService=require(_0x7401('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x7401('0x11'));var hardwareService=require(_0x7401('0x12'));var logger=require(_0x7401('0x13'))('api');var utils=require(_0x7401('0x14'));var config=require(_0x7401('0x15'));var licenseUtil=require(_0x7401('0x16'));var db=require(_0x7401('0x17'))['db'];config[_0x7401('0x18')]=_[_0x7401('0x19')](config[_0x7401('0x18')],{'host':_0x7401('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x7401('0x18')]));require(_0x7401('0x1b'))[_0x7401('0x1c')](socket);var jayson=require('jayson/promise');var client=jayson[_0x7401('0x1d')][_0x7401('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x35e75a,_0x2d0b84,_0x2a5c89,_0x2bef9f){return new BPromise(function(_0x372f79,_0x228fc8){var _0x3baa03=_0x2bef9f||client;return _0x3baa03['request'](_0x35e75a,_0x2a5c89)[_0x7401('0x1f')](function(_0x5ab2ca){logger[_0x7401('0x20')]('ChatQueue,\x20%s,\x20%s',_0x2d0b84,_0x7401('0x21'));logger[_0x7401('0x22')](_0x7401('0x23'),_0x2d0b84,'request\x20sent',JSON[_0x7401('0x24')](_0x5ab2ca));if(_0x5ab2ca['error']){if(_0x5ab2ca[_0x7401('0x25')][_0x7401('0x26')]===0x1f4){logger[_0x7401('0x25')](_0x7401('0x27'),_0x2d0b84,_0x5ab2ca[_0x7401('0x25')][_0x7401('0x28')]);return _0x228fc8(_0x5ab2ca['error'][_0x7401('0x28')]);}logger[_0x7401('0x25')](_0x7401('0x27'),_0x2d0b84,_0x5ab2ca[_0x7401('0x25')][_0x7401('0x28')]);return _0x372f79(_0x5ab2ca[_0x7401('0x25')]['message']);}else{logger[_0x7401('0x20')]('ChatQueue,\x20%s,\x20%s',_0x2d0b84,'request\x20sent');_0x372f79(_0x5ab2ca[_0x7401('0x29')][_0x7401('0x28')]);}})[_0x7401('0x2a')](function(_0x444dfd){logger['error'](_0x7401('0x27'),_0x2d0b84,_0x444dfd);_0x228fc8(_0x444dfd);});});}function respondWithStatusCode(_0x478b4c,_0x5c46f4){_0x5c46f4=_0x5c46f4||0xcc;return function(_0x249e7f){if(_0x249e7f){return _0x478b4c[_0x7401('0x2b')](_0x5c46f4);}return _0x478b4c[_0x7401('0x2c')](_0x5c46f4)['end']();};}function respondWithResult(_0x5e355d,_0x162555){_0x162555=_0x162555||0xc8;return function(_0x30aac8){if(_0x30aac8){return _0x5e355d[_0x7401('0x2c')](_0x162555)[_0x7401('0x2d')](_0x30aac8);}};}function respondWithFilteredResult(_0x21eb44,_0x424eb7){return function(_0x230e27){if(_0x230e27){var _0x582f1c=typeof _0x424eb7[_0x7401('0x2e')]===_0x7401('0x2f')&&typeof _0x424eb7[_0x7401('0x30')]===_0x7401('0x2f');var _0xa04d89=_0x230e27[_0x7401('0x31')];var _0x5c4f52=_0x582f1c?0x0:_0x424eb7[_0x7401('0x2e')];var _0x3aac1d=_0x582f1c?_0x230e27[_0x7401('0x31')]:_0x424eb7['offset']+_0x424eb7[_0x7401('0x30')];var _0x5c4546;if(_0x3aac1d>=_0xa04d89){_0x3aac1d=_0xa04d89;_0x5c4546=0xc8;}else{_0x5c4546=0xce;}_0x21eb44[_0x7401('0x2c')](_0x5c4546);return _0x21eb44[_0x7401('0x32')](_0x7401('0x33'),_0x5c4f52+'-'+_0x3aac1d+'/'+_0xa04d89)[_0x7401('0x2d')](_0x230e27);}return null;};}function patchUpdates(_0x46239c){return function(_0x17e650){try{jsonpatch[_0x7401('0x34')](_0x17e650,_0x46239c,!![]);}catch(_0x3f878c){return BPromise[_0x7401('0x35')](_0x3f878c);}return _0x17e650['save']();};}function saveUpdates(_0x1764de,_0x4e3845){return function(_0x4c4c5b){if(_0x4c4c5b){return _0x4c4c5b[_0x7401('0x36')](_0x1764de)[_0x7401('0x1f')](function(_0x234e31){return _0x234e31;});}return null;};}function removeEntity(_0x1d9bee,_0x82a32a){return function(_0x387a95){if(_0x387a95){return _0x387a95['destroy']()['then'](function(){var _0x10be54=_0x387a95[_0x7401('0x37')]({'plain':!![]});var _0x4316b2=_0x7401('0x38');return db[_0x7401('0x39')][_0x7401('0x3a')]({'where':{'type':_0x4316b2,'resourceId':_0x10be54['id']}})[_0x7401('0x1f')](function(){return _0x387a95;});})[_0x7401('0x1f')](function(){_0x1d9bee[_0x7401('0x2c')](0xcc)[_0x7401('0x3b')]();});}};}function handleEntityNotFound(_0x30abc4,_0x2c71db){return function(_0x39fff8){if(!_0x39fff8){_0x30abc4[_0x7401('0x2b')](0x194);}return _0x39fff8;};}function handleError(_0x473291,_0xe71f84){_0xe71f84=_0xe71f84||0x1f4;return function(_0x2e2e6b){logger['error'](_0x2e2e6b['stack']);if(_0x2e2e6b['name']){delete _0x2e2e6b[_0x7401('0x3c')];}_0x473291[_0x7401('0x2c')](_0xe71f84)[_0x7401('0x3d')](_0x2e2e6b);};}exports['index']=function(_0x5400fe,_0x5af08f){var _0x4926c3={},_0x195fdd={},_0x2032d9={'count':0x0,'rows':[]};var _0xb5f6fb=_['map'](db['ChatQueue'][_0x7401('0x3e')],function(_0x28032d){return{'name':_0x28032d[_0x7401('0x3f')],'type':_0x28032d[_0x7401('0x40')][_0x7401('0x41')]};});_0x195fdd[_0x7401('0x42')]=_['map'](_0xb5f6fb,'name');_0x195fdd[_0x7401('0x43')]=_['keys'](_0x5400fe['query']);_0x195fdd[_0x7401('0x44')]=_[_0x7401('0x45')](_0x195fdd[_0x7401('0x42')],_0x195fdd[_0x7401('0x43')]);_0x4926c3['attributes']=_[_0x7401('0x45')](_0x195fdd[_0x7401('0x42')],qs['fields'](_0x5400fe['query'][_0x7401('0x46')]));_0x4926c3[_0x7401('0x47')]=_0x4926c3[_0x7401('0x47')][_0x7401('0x48')]?_0x4926c3[_0x7401('0x47')]:_0x195fdd[_0x7401('0x42')];if(!_0x5400fe[_0x7401('0x43')]['hasOwnProperty'](_0x7401('0x49'))){_0x4926c3[_0x7401('0x30')]=qs[_0x7401('0x30')](_0x5400fe[_0x7401('0x43')]['limit']);_0x4926c3[_0x7401('0x2e')]=qs[_0x7401('0x2e')](_0x5400fe[_0x7401('0x43')]['offset']);}_0x4926c3[_0x7401('0x4a')]=qs[_0x7401('0x4b')](_0x5400fe['query'][_0x7401('0x4b')]);_0x4926c3[_0x7401('0x4c')]=qs[_0x7401('0x44')](_['pick'](_0x5400fe[_0x7401('0x43')],_0x195fdd['filters']),_0xb5f6fb);if(_0x5400fe['query'][_0x7401('0x4d')]){_0x4926c3[_0x7401('0x4c')]=_['merge'](_0x4926c3[_0x7401('0x4c')],{'$or':_[_0x7401('0x4e')](_0xb5f6fb,function(_0x41ddc5){if(_0x41ddc5['type']!==_0x7401('0x4f')){var _0x12136a={};_0x12136a[_0x41ddc5[_0x7401('0x3c')]]={'$like':'%'+_0x5400fe['query'][_0x7401('0x4d')]+'%'};return _0x12136a;}})});}_0x4926c3=_['merge']({},_0x4926c3,_0x5400fe['options']);var _0xb7268f={'where':_0x4926c3[_0x7401('0x4c')]};return db[_0x7401('0x50')][_0x7401('0x31')](_0xb7268f)[_0x7401('0x1f')](function(_0x18e29e){_0x2032d9[_0x7401('0x31')]=_0x18e29e;if(_0x5400fe['query'][_0x7401('0x51')]){_0x4926c3[_0x7401('0x52')]=[{'all':!![]}];}return db[_0x7401('0x50')]['findAll'](_0x4926c3);})[_0x7401('0x1f')](function(_0x4ac35d){_0x2032d9[_0x7401('0x53')]=_0x4ac35d;return _0x2032d9;})['then'](respondWithFilteredResult(_0x5af08f,_0x4926c3))[_0x7401('0x2a')](handleError(_0x5af08f,null));};exports[_0x7401('0x54')]=function(_0x2bbeea,_0x280c73){var _0x45a878={'raw':!![],'where':{'id':_0x2bbeea[_0x7401('0x55')]['id']}},_0x2591d2={};_0x2591d2[_0x7401('0x42')]=_[_0x7401('0x56')](db[_0x7401('0x50')]['rawAttributes']);_0x2591d2[_0x7401('0x43')]=_[_0x7401('0x56')](_0x2bbeea[_0x7401('0x43')]);_0x2591d2['filters']=_[_0x7401('0x45')](_0x2591d2[_0x7401('0x42')],_0x2591d2[_0x7401('0x43')]);_0x45a878[_0x7401('0x47')]=_['intersection'](_0x2591d2[_0x7401('0x42')],qs['fields'](_0x2bbeea['query']['fields']));_0x45a878[_0x7401('0x47')]=_0x45a878[_0x7401('0x47')][_0x7401('0x48')]?_0x45a878[_0x7401('0x47')]:_0x2591d2['model'];if(_0x2bbeea['query'][_0x7401('0x51')]){_0x45a878['include']=[{'all':!![]}];}_0x45a878=_[_0x7401('0x57')]({},_0x45a878,_0x2bbeea[_0x7401('0x58')]);return db['ChatQueue'][_0x7401('0x59')](_0x45a878)[_0x7401('0x1f')](handleEntityNotFound(_0x280c73,null))[_0x7401('0x1f')](respondWithResult(_0x280c73,null))['catch'](handleError(_0x280c73,null));};exports['create']=function(_0x4036bf,_0x142a6e){return db[_0x7401('0x50')][_0x7401('0x5a')](_0x4036bf[_0x7401('0x5b')],{})['then'](function(_0x204817){var _0x242d1c=_0x4036bf[_0x7401('0x5c')][_0x7401('0x37')]({'plain':!![]});if(!_0x242d1c)throw new Error(_0x7401('0x5d'));if(_0x242d1c[_0x7401('0x5e')]===_0x7401('0x5c')){var _0x3224cb=_0x204817[_0x7401('0x37')]({'plain':!![]});var _0x144d76='ChatQueues';return db['UserProfileSection'][_0x7401('0x59')]({'where':{'name':_0x144d76,'userProfileId':_0x242d1c['userProfileId']},'raw':!![]})[_0x7401('0x1f')](function(_0x1e9f8e){if(_0x1e9f8e&&_0x1e9f8e[_0x7401('0x5f')]===0x0){return db[_0x7401('0x39')][_0x7401('0x5a')]({'name':_0x3224cb['name'],'resourceId':_0x3224cb['id'],'type':_0x1e9f8e[_0x7401('0x3c')],'sectionId':_0x1e9f8e['id']},{})[_0x7401('0x1f')](function(){return _0x204817;});}else{return _0x204817;}})['catch'](function(_0x55fdb8){logger[_0x7401('0x25')](_0x7401('0x60'),_0x55fdb8);throw _0x55fdb8;});}return _0x204817;})[_0x7401('0x1f')](respondWithResult(_0x142a6e,0xc9))[_0x7401('0x2a')](handleError(_0x142a6e,null));};exports[_0x7401('0x36')]=function(_0x2f7bd9,_0x25cfa7){if(_0x2f7bd9[_0x7401('0x5b')]['id']){delete _0x2f7bd9[_0x7401('0x5b')]['id'];}return db[_0x7401('0x50')][_0x7401('0x59')]({'where':{'id':_0x2f7bd9['params']['id']}})[_0x7401('0x1f')](handleEntityNotFound(_0x25cfa7,null))[_0x7401('0x1f')](saveUpdates(_0x2f7bd9[_0x7401('0x5b')],null))['then'](respondWithResult(_0x25cfa7,null))[_0x7401('0x2a')](handleError(_0x25cfa7,null));};exports[_0x7401('0x3a')]=function(_0x3d639e,_0xb4313){return db[_0x7401('0x50')][_0x7401('0x59')]({'where':{'id':_0x3d639e[_0x7401('0x55')]['id']}})[_0x7401('0x1f')](handleEntityNotFound(_0xb4313,null))[_0x7401('0x1f')](removeEntity(_0xb4313,null))['catch'](handleError(_0xb4313,null));};exports[_0x7401('0x61')]=function(_0x7e7cb,_0x552ddc){return db[_0x7401('0x50')][_0x7401('0x61')]()['then'](respondWithResult(_0x552ddc,null))[_0x7401('0x2a')](handleError(_0x552ddc,null));};exports['getMembers']=function(_0x57eb39,_0x59251b,_0x2d6808){var _0x33c18c={'raw':!![],'where':{}},_0x495e3f={},_0x2d0d3f;return db[_0x7401('0x50')][_0x7401('0x62')]({'where':{'id':_0x57eb39['params']['id']}})[_0x7401('0x1f')](handleEntityNotFound(_0x59251b,null))[_0x7401('0x1f')](function(_0x51e19e){if(_0x51e19e){_0x2d0d3f=_0x51e19e[_0x7401('0x37')]({'plain':!![]});_0x495e3f[_0x7401('0x42')]=_[_0x7401('0x56')](db['UserChatQueue'][_0x7401('0x3e')]);_0x495e3f[_0x7401('0x43')]=_[_0x7401('0x56')](_0x57eb39['query']);_0x495e3f[_0x7401('0x44')]=_['intersection'](_0x495e3f[_0x7401('0x42')],_0x495e3f[_0x7401('0x43')]);_0x33c18c[_0x7401('0x47')]=_['intersection'](_0x495e3f[_0x7401('0x42')],qs[_0x7401('0x46')](_0x57eb39['query'][_0x7401('0x46')]));_0x33c18c['attributes']=_0x33c18c[_0x7401('0x47')][_0x7401('0x48')]?_0x33c18c['attributes']:_0x495e3f[_0x7401('0x42')];if(!_0x57eb39['query'][_0x7401('0x63')](_0x7401('0x49'))){_0x33c18c['limit']=qs[_0x7401('0x30')](_0x57eb39[_0x7401('0x43')]['limit']);_0x33c18c[_0x7401('0x2e')]=qs[_0x7401('0x2e')](_0x57eb39[_0x7401('0x43')][_0x7401('0x2e')]);}_0x33c18c[_0x7401('0x4a')]=qs[_0x7401('0x4b')](_0x57eb39[_0x7401('0x43')][_0x7401('0x4b')]);_0x33c18c[_0x7401('0x4c')]=qs['filters'](_['pick'](_0x57eb39['query'],_0x495e3f[_0x7401('0x44')]));_0x33c18c[_0x7401('0x4c')][_0x7401('0x64')]=_0x51e19e['id'];if(_0x57eb39['query'][_0x7401('0x4d')]){_0x33c18c[_0x7401('0x4c')]=_[_0x7401('0x57')](_0x33c18c[_0x7401('0x4c')],{'$or':_[_0x7401('0x4e')](_0x33c18c[_0x7401('0x47')],function(_0xfa8954){var _0x398975={};_0x398975[_0xfa8954]={'$like':'%'+_0x57eb39[_0x7401('0x43')][_0x7401('0x4d')]+'%'};return _0x398975;})});}_0x33c18c=_[_0x7401('0x57')]({},_0x33c18c,_0x57eb39[_0x7401('0x58')]);return db['UserChatQueue'][_0x7401('0x65')](_0x33c18c);}})[_0x7401('0x1f')](function(_0x3756f9){if(_0x3756f9){return db[_0x7401('0x66')][_0x7401('0x67')]({'where':{'id':_[_0x7401('0x4e')](_0x3756f9,_0x7401('0x68')),'role':'agent'},'attributes':['id',_0x7401('0x3c'),_0x7401('0x69'),_0x7401('0x6a'),_0x7401('0x6b')]});}})[_0x7401('0x1f')](function(_0x254779){if(_0x254779){return{'count':_0x254779[_0x7401('0x31')],'rows':_[_0x7401('0x4e')](_0x254779[_0x7401('0x53')],function(_0x35ef09){return{'membername':_0x35ef09['name'],'UserId':_0x35ef09['id'],'queue_name':_0x2d0d3f[_0x7401('0x3c')],'ChatQueueId':_0x2d0d3f['id'],'interface':util[_0x7401('0x6c')](_0x7401('0x6d'),_0x7401('0x6e'),_0x35ef09[_0x7401('0x3c')]),'penalty':0x0,'paused':_0x35ef09[_0x7401('0x69')],'createdAt':_0x35ef09[_0x7401('0x6b')],'updatedAt':_0x35ef09['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x7401('0x1f')](respondWithFilteredResult(_0x59251b,_0x33c18c))[_0x7401('0x2a')](handleError(_0x59251b,null));};exports['getTeams']=function(_0x4a47a2,_0x16860c,_0x2e547a){var _0x4b99ff={};var _0x10cc28={};var _0x3a4826;var _0x5534a4;return db['ChatQueue'][_0x7401('0x62')]({'where':{'id':_0x4a47a2[_0x7401('0x55')]['id']}})[_0x7401('0x1f')](handleEntityNotFound(_0x16860c,null))[_0x7401('0x1f')](function(_0x132ffe){if(_0x132ffe){_0x3a4826=_0x132ffe;_0x10cc28['model']=_[_0x7401('0x56')](db[_0x7401('0x6f')][_0x7401('0x3e')]);_0x10cc28[_0x7401('0x43')]=_[_0x7401('0x56')](_0x4a47a2[_0x7401('0x43')]);_0x10cc28[_0x7401('0x44')]=_[_0x7401('0x45')](_0x10cc28[_0x7401('0x42')],_0x10cc28[_0x7401('0x43')]);_0x4b99ff['attributes']=_[_0x7401('0x45')](_0x10cc28['model'],qs[_0x7401('0x46')](_0x4a47a2[_0x7401('0x43')][_0x7401('0x46')]));_0x4b99ff[_0x7401('0x47')]=_0x4b99ff[_0x7401('0x47')]['length']?_0x4b99ff[_0x7401('0x47')]:_0x10cc28[_0x7401('0x42')];_0x4b99ff[_0x7401('0x4a')]=qs[_0x7401('0x4b')](_0x4a47a2[_0x7401('0x43')][_0x7401('0x4b')]);_0x4b99ff['where']=qs[_0x7401('0x44')](_[_0x7401('0x70')](_0x4a47a2['query'],_0x10cc28[_0x7401('0x44')]));if(_0x4a47a2['query'][_0x7401('0x4d')]){_0x4b99ff[_0x7401('0x4c')]=_['merge'](_0x4b99ff[_0x7401('0x4c')],{'$or':_[_0x7401('0x4e')](_0x4b99ff[_0x7401('0x47')],function(_0x3e0e6c){var _0x1e190f={};_0x1e190f[_0x3e0e6c]={'$like':'%'+_0x4a47a2[_0x7401('0x43')][_0x7401('0x4d')]+'%'};return _0x1e190f;})});}_0x4b99ff=_[_0x7401('0x57')]({},_0x4b99ff,_0x4a47a2['options']);return _0x3a4826[_0x7401('0x71')](_0x4b99ff);}})['then'](function(_0x1624e0){if(_0x1624e0){_0x5534a4=_0x1624e0[_0x7401('0x48')];if(!_0x4a47a2[_0x7401('0x43')][_0x7401('0x63')](_0x7401('0x49'))){_0x4b99ff[_0x7401('0x30')]=qs[_0x7401('0x30')](_0x4a47a2['query'][_0x7401('0x30')]);_0x4b99ff[_0x7401('0x2e')]=qs[_0x7401('0x2e')](_0x4a47a2[_0x7401('0x43')]['offset']);}return _0x3a4826[_0x7401('0x71')](_0x4b99ff);}})[_0x7401('0x1f')](function(_0x1d0bb5){if(_0x1d0bb5){return _0x1d0bb5?{'count':_0x5534a4,'rows':_0x1d0bb5}:null;}})[_0x7401('0x1f')](respondWithResult(_0x16860c,null))[_0x7401('0x2a')](handleError(_0x16860c,null));};exports[_0x7401('0x72')]=function(_0x1883e3,_0x1c65d0,_0x429a08){var _0x850df3=_0x1883e3[_0x7401('0x5b')][_0x7401('0x73')];return db[_0x7401('0x6f')][_0x7401('0x65')]({'where':{'id':_0x850df3},'attributes':['id'],'include':[{'model':db[_0x7401('0x66')],'as':_0x7401('0x74'),'attributes':['id',_0x7401('0x3c'),_0x7401('0x75'),_0x7401('0x76'),_0x7401('0x77')],'raw':!![]}]})[_0x7401('0x1f')](function(_0x2d3f6a){if(_0x2d3f6a){var _0x2a160d=_[_0x7401('0x78')](_0x2d3f6a,function(_0x4f2df5){var _0x4e7cdd=_0x4f2df5['get']({'plain':!![]});return _0x4e7cdd[_0x7401('0x74')];});return db['ChatQueue'][_0x7401('0x59')]({'where':{'id':_0x1883e3[_0x7401('0x55')]['id']}})['then'](function(_0x2d780c){return db[_0x7401('0x79')][_0x7401('0x7a')](function(_0x30b1de){return _0x2d780c[_0x7401('0x72')](_0x850df3,{'transaction':_0x30b1de})[_0x7401('0x1f')](function(){return BPromise['each'](_0x2a160d,function(_0x23ebac){return db[_0x7401('0x7b')][_0x7401('0x7c')]({'where':{'UserId':_0x23ebac['id'],'ChatQueueId':_0x1883e3[_0x7401('0x55')]['id']},'transaction':_0x30b1de});});})[_0x7401('0x1f')](function(){_0x2a160d[_0x7401('0x7d')](function(_0x18b769){socket[_0x7401('0x7e')](_0x7401('0x7f'),{'UserId':_0x18b769['id'],'ChatQueueId':_0x2d780c['id']});});});});});}})[_0x7401('0x1f')](respondWithStatusCode(_0x1c65d0,null))['catch'](handleError(_0x1c65d0,null));};exports['removeTeams']=function(_0x513d21,_0x2f61f3,_0x765f93){return db[_0x7401('0x6f')]['findAll']({'where':{'id':_0x513d21['query']['ids']},'attributes':['id'],'include':[{'model':db[_0x7401('0x66')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x7401('0x1f')](handleEntityNotFound(_0x2f61f3,null))[_0x7401('0x1f')](function(_0x323bf8){var _0x1091ef=_[_0x7401('0x4e')](_0x323bf8,'id');var _0x95c568=[];var _0x1c249a=[];var _0x81c489=squel[_0x7401('0x80')]();_0x81c489[_0x7401('0x81')](_0x7401('0x82'))[_0x7401('0x83')](_0x7401('0x84'),'tq')[_0x7401('0x85')](_0x7401('0x86'),'ut',_0x7401('0x87'))[_0x7401('0x4c')](_0x7401('0x88'),_0x513d21[_0x7401('0x55')]['id']);for(var _0x3f0e75=0x0;_0x3f0e75<_0x323bf8[_0x7401('0x48')];_0x3f0e75+=0x1){let _0xbe432f=_0x323bf8[_0x3f0e75];for(var _0x211ac9=0x0;_0x211ac9<_0xbe432f[_0x7401('0x74')][_0x7401('0x48')];_0x211ac9+=0x1){let _0x3662a0=_0xbe432f['Agents'][_0x211ac9];var _0x21cfbe=_0x81c489[_0x7401('0x89')]();_0x21cfbe[_0x7401('0x4c')]('ut.UserId\x20=\x20?',_0x3662a0['id']);_0x1c249a[_0x7401('0x8a')](db['sequelize'][_0x7401('0x43')](_0x21cfbe[_0x7401('0x8b')](),{'type':db[_0x7401('0x79')][_0x7401('0x8c')]['SELECT']})[_0x7401('0x1f')](function(_0xf9f31f){if(_0xf9f31f['length']===0x1){return _0x3662a0['id'];}else{var _0x1f34fe=_[_0x7401('0x8d')](_['map'](_0xf9f31f,'TeamId'),function(_0x471b1e){return _[_0x7401('0x8e')](_0x1091ef,_0x471b1e);});if(_0x1f34fe){return _0x3662a0['id'];}}}));}}return BPromise['all'](_0x1c249a)[_0x7401('0x1f')](function(_0x566049){_0x95c568=_(_0x95c568)[_0x7401('0x8f')](_0x566049)[_0x7401('0x90')]()[_0x7401('0x91')]();return db[_0x7401('0x50')][_0x7401('0x59')]({'where':{'id':_0x513d21[_0x7401('0x55')]['id']}})[_0x7401('0x1f')](function(_0x2b9f87){return db['sequelize'][_0x7401('0x7a')](function(_0x2d0609){return _0x2b9f87['removeTeams'](_0x513d21['query'][_0x7401('0x73')],{'transaction':_0x2d0609})[_0x7401('0x1f')](function(){if(!_[_0x7401('0x92')](_0x95c568)){return _0x2b9f87[_0x7401('0x93')](_0x95c568,{'transaction':_0x2d0609});}})[_0x7401('0x1f')](function(){_0x95c568[_0x7401('0x7d')](function(_0x5e5c79){socket['emit'](_0x7401('0x94'),{'UserId':_0x5e5c79,'ChatQueueId':_0x2b9f87['id']});});});});});});})[_0x7401('0x1f')](respondWithStatusCode(_0x2f61f3,null))[_0x7401('0x2a')](handleError(_0x2f61f3,null));};exports[_0x7401('0x95')]=function(_0xc4a8e4,_0x264a24,_0x461e64){return db['ChatQueue'][_0x7401('0x59')]({'where':{'id':_0xc4a8e4[_0x7401('0x55')]['id']}})[_0x7401('0x1f')](handleEntityNotFound(_0x264a24,null))[_0x7401('0x1f')](function(_0x1c4dbd){if(_0x1c4dbd){return _0x1c4dbd[_0x7401('0x95')](_0xc4a8e4[_0x7401('0x5b')]['ids'],_[_0x7401('0x96')](_0xc4a8e4[_0x7401('0x5b')],[_0x7401('0x73'),'id'])||{})[_0x7401('0x97')](function(_0x3ab0ab){for(var _0x3c3571=0x0;_0x3c3571<_0xc4a8e4[_0x7401('0x5b')]['ids'][_0x7401('0x48')];_0x3c3571+=0x1){socket['emit']('userChatQueue:save',{'UserId':Number(_0xc4a8e4[_0x7401('0x5b')]['ids'][_0x3c3571]),'ChatQueueId':Number(_0xc4a8e4[_0x7401('0x55')]['id'])});}return _0x3ab0ab;});}})[_0x7401('0x1f')](respondWithResult(_0x264a24,null))[_0x7401('0x2a')](handleError(_0x264a24,null));};exports[_0x7401('0x93')]=function(_0x1e11d5,_0x168dfd,_0x58e072){return db[_0x7401('0x50')]['find']({'where':{'id':_0x1e11d5[_0x7401('0x55')]['id']}})[_0x7401('0x1f')](handleEntityNotFound(_0x168dfd,null))['then'](function(_0x31e082){if(_0x31e082){return _0x31e082[_0x7401('0x93')](_0x1e11d5[_0x7401('0x43')][_0x7401('0x73')])[_0x7401('0x1f')](function(){if(_[_0x7401('0x98')](_0x1e11d5[_0x7401('0x43')][_0x7401('0x73')])){for(var _0x2bf4ef=0x0;_0x2bf4ef<_0x1e11d5[_0x7401('0x43')][_0x7401('0x73')]['length'];_0x2bf4ef+=0x1){socket[_0x7401('0x7e')](_0x7401('0x94'),{'UserId':Number(_0x1e11d5[_0x7401('0x43')][_0x7401('0x73')][_0x2bf4ef]),'ChatQueueId':Number(_0x1e11d5['params']['id'])});}}else{socket[_0x7401('0x7e')](_0x7401('0x94'),{'UserId':Number(_0x1e11d5[_0x7401('0x43')][_0x7401('0x73')]),'ChatQueueId':Number(_0x1e11d5[_0x7401('0x55')]['id'])});}});}})[_0x7401('0x1f')](respondWithStatusCode(_0x168dfd,null))[_0x7401('0x2a')](handleError(_0x168dfd,null));};exports[_0x7401('0x99')]=function(_0x2b104a,_0x584e10,_0x3b0f41){var _0x133699={};var _0x5d5aa3={};var _0x25ae14;var _0x368fe5;return db[_0x7401('0x50')][_0x7401('0x62')]({'where':{'id':_0x2b104a[_0x7401('0x55')]['id']}})['then'](handleEntityNotFound(_0x584e10,null))[_0x7401('0x1f')](function(_0x37e477){if(_0x37e477){_0x25ae14=_0x37e477;_0x5d5aa3[_0x7401('0x42')]=_['keys'](db[_0x7401('0x66')]['rawAttributes']);_0x5d5aa3['query']=_[_0x7401('0x56')](_0x2b104a[_0x7401('0x43')]);_0x5d5aa3[_0x7401('0x44')]=_[_0x7401('0x45')](_0x5d5aa3[_0x7401('0x42')],_0x5d5aa3[_0x7401('0x43')]);_0x133699[_0x7401('0x47')]=_[_0x7401('0x45')](_0x5d5aa3[_0x7401('0x42')],qs[_0x7401('0x46')](_0x2b104a[_0x7401('0x43')][_0x7401('0x46')]));_0x133699[_0x7401('0x47')]=_0x133699['attributes'][_0x7401('0x48')]?_0x133699['attributes']:_0x5d5aa3['model'];_0x133699[_0x7401('0x4a')]=qs[_0x7401('0x4b')](_0x2b104a[_0x7401('0x43')][_0x7401('0x4b')]);_0x133699[_0x7401('0x4c')]=qs[_0x7401('0x44')](_[_0x7401('0x70')](_0x2b104a[_0x7401('0x43')],_0x5d5aa3[_0x7401('0x44')]));if(_0x2b104a['query'][_0x7401('0x4d')]){_0x133699[_0x7401('0x4c')]=_[_0x7401('0x57')](_0x133699[_0x7401('0x4c')],{'$or':_[_0x7401('0x4e')](_0x133699[_0x7401('0x47')],function(_0x92b6ae){var _0x1646a6={};_0x1646a6[_0x92b6ae]={'$like':'%'+_0x2b104a[_0x7401('0x43')][_0x7401('0x4d')]+'%'};return _0x1646a6;})});}_0x133699=_['merge']({},_0x133699,_0x2b104a[_0x7401('0x58')]);return _0x25ae14[_0x7401('0x99')](_0x133699);}})[_0x7401('0x1f')](function(_0x3925d4){if(_0x3925d4){_0x368fe5=_0x3925d4[_0x7401('0x48')];if(!_0x2b104a[_0x7401('0x43')]['hasOwnProperty'](_0x7401('0x49'))){_0x133699[_0x7401('0x30')]=qs[_0x7401('0x30')](_0x2b104a[_0x7401('0x43')][_0x7401('0x30')]);_0x133699[_0x7401('0x2e')]=qs[_0x7401('0x2e')](_0x2b104a[_0x7401('0x43')][_0x7401('0x2e')]);}return _0x25ae14[_0x7401('0x99')](_0x133699);}})[_0x7401('0x1f')](function(_0x14091f){if(_0x14091f){return _0x14091f?{'count':_0x368fe5,'rows':_0x14091f}:null;}})[_0x7401('0x1f')](respondWithResult(_0x584e10,null))[_0x7401('0x2a')](handleError(_0x584e10,null));};
\ No newline at end of file