Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 735607d..c86dd3e 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 _0x446d=['hasOwnProperty','nolimit','order','sort','pick','where','merge','options','count','includeAll','include','rows','show','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','UserProfileResource','update','body','params','describe','findOne','UserChatQueue','filter','findAll','User','findAndCountAll','UserId','createdAt','format','SIP','chatPause','updatedAt','getTeams','Team','ids','Agents','online','voicePause','interface','flatMap','sequelize','transaction','each','forEach','emit','removeTeams','field','tq.TeamId','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','every','TeamId','all','union','compact','value','addAgents','omit','userChatQueue:save','removeAgents','isArray','userChatQueue:remove','getAgents','eml-format','rimraf','zip-dir','request-promise','bluebird','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/license/util','redis','localhost','socket.io-emitter','./chatQueue.socket','register','jayson/promise','http','then','ChatQueue,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','info','result','catch','sendStatus','status','end','json','offset','undefined','limit','set','Content-Range','apply','reject','save','destroy','get','stack','name','send','index','map','ChatQueue','rawAttributes','fieldName','type','key','query','keys','filters','intersection','attributes','fields','length','model'];(function(_0x223139,_0x41038f){var _0x35f2a5=function(_0x2f1595){while(--_0x2f1595){_0x223139['push'](_0x223139['shift']());}};_0x35f2a5(++_0x41038f);}(_0x446d,0xdb));var _0xd446=function(_0x4a9d73,_0x404b5f){_0x4a9d73=_0x4a9d73-0x0;var _0x2544c1=_0x446d[_0x4a9d73];return _0x2544c1;};'use strict';var emlformat=require(_0xd446('0x0'));var rimraf=require(_0xd446('0x1'));var zipdir=require(_0xd446('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xd446('0x3'));var moment=require('moment');var BPromise=require(_0xd446('0x4'));var Mustache=require('mustache');var util=require(_0xd446('0x5'));var path=require(_0xd446('0x6'));var sox=require(_0xd446('0x7'));var csv=require(_0xd446('0x8'));var ejs=require(_0xd446('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xd446('0xa'));var squel=require('squel');var crypto=require(_0xd446('0xb'));var jsforce=require(_0xd446('0xc'));var deskjs=require(_0xd446('0xd'));var toCsv=require(_0xd446('0x8'));var querystring=require(_0xd446('0xe'));var Papa=require(_0xd446('0xf'));var Redis=require(_0xd446('0x10'));var authService=require(_0xd446('0x11'));var qs=require(_0xd446('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xd446('0x13'))(_0xd446('0x14'));var utils=require(_0xd446('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xd446('0x16'));var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config[_0xd446('0x17')],{'host':_0xd446('0x18'),'port':0x18eb});var socket=require(_0xd446('0x19'))(new Redis(config[_0xd446('0x17')]));require(_0xd446('0x1a'))[_0xd446('0x1b')](socket);var jayson=require(_0xd446('0x1c'));var client=jayson['client'][_0xd446('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x12b006,_0x54a37f,_0x545768,_0x5f51cd){return new BPromise(function(_0x80c5b7,_0x53ff43){var _0x101a56=_0x5f51cd||client;return _0x101a56['request'](_0x12b006,_0x545768)[_0xd446('0x1e')](function(_0x1d0473){logger['info'](_0xd446('0x1f'),_0x54a37f,'request\x20sent');logger[_0xd446('0x20')]('ChatQueue,\x20%s,\x20%s,\x20%s',_0x54a37f,_0xd446('0x21'),JSON[_0xd446('0x22')](_0x1d0473));if(_0x1d0473[_0xd446('0x23')]){if(_0x1d0473['error'][_0xd446('0x24')]===0x1f4){logger[_0xd446('0x23')]('ChatQueue,\x20%s,\x20%s',_0x54a37f,_0x1d0473[_0xd446('0x23')][_0xd446('0x25')]);return _0x53ff43(_0x1d0473[_0xd446('0x23')][_0xd446('0x25')]);}logger['error']('ChatQueue,\x20%s,\x20%s',_0x54a37f,_0x1d0473[_0xd446('0x23')]['message']);return _0x80c5b7(_0x1d0473[_0xd446('0x23')][_0xd446('0x25')]);}else{logger[_0xd446('0x26')](_0xd446('0x1f'),_0x54a37f,_0xd446('0x21'));_0x80c5b7(_0x1d0473[_0xd446('0x27')][_0xd446('0x25')]);}})[_0xd446('0x28')](function(_0x44d3b0){logger[_0xd446('0x23')]('ChatQueue,\x20%s,\x20%s',_0x54a37f,_0x44d3b0);_0x53ff43(_0x44d3b0);});});}function respondWithStatusCode(_0x3e7cc5,_0x4d5a07){_0x4d5a07=_0x4d5a07||0xcc;return function(_0x918821){if(_0x918821){return _0x3e7cc5[_0xd446('0x29')](_0x4d5a07);}return _0x3e7cc5[_0xd446('0x2a')](_0x4d5a07)[_0xd446('0x2b')]();};}function respondWithResult(_0x50b447,_0x245a25){_0x245a25=_0x245a25||0xc8;return function(_0x5b0277){if(_0x5b0277){return _0x50b447['status'](_0x245a25)[_0xd446('0x2c')](_0x5b0277);}};}function respondWithFilteredResult(_0x38dbcb,_0x2f50b5){return function(_0x34f78b){if(_0x34f78b){var _0x8bb393=typeof _0x2f50b5[_0xd446('0x2d')]===_0xd446('0x2e')&&typeof _0x2f50b5['limit']===_0xd446('0x2e');var _0x52139d=_0x34f78b['count'];var _0x322aaa=_0x8bb393?0x0:_0x2f50b5[_0xd446('0x2d')];var _0x57b6e8=_0x8bb393?_0x34f78b['count']:_0x2f50b5[_0xd446('0x2d')]+_0x2f50b5[_0xd446('0x2f')];var _0x4a6fcc;if(_0x57b6e8>=_0x52139d){_0x57b6e8=_0x52139d;_0x4a6fcc=0xc8;}else{_0x4a6fcc=0xce;}_0x38dbcb[_0xd446('0x2a')](_0x4a6fcc);return _0x38dbcb[_0xd446('0x30')](_0xd446('0x31'),_0x322aaa+'-'+_0x57b6e8+'/'+_0x52139d)[_0xd446('0x2c')](_0x34f78b);}return null;};}function patchUpdates(_0x5f55d2){return function(_0x14c3f1){try{jsonpatch[_0xd446('0x32')](_0x14c3f1,_0x5f55d2,!![]);}catch(_0x5a81c7){return BPromise[_0xd446('0x33')](_0x5a81c7);}return _0x14c3f1[_0xd446('0x34')]();};}function saveUpdates(_0xa4e1ab,_0x268eb9){return function(_0x5a40ea){if(_0x5a40ea){return _0x5a40ea['update'](_0xa4e1ab)['then'](function(_0x321c72){return _0x321c72;});}return null;};}function removeEntity(_0x555af1,_0x4c1e48){return function(_0x3ee7b7){if(_0x3ee7b7){return _0x3ee7b7[_0xd446('0x35')]()['then'](function(){var _0x269fc6=_0x3ee7b7[_0xd446('0x36')]({'plain':!![]});var _0x80f749='ChatQueues';return db['UserProfileResource']['destroy']({'where':{'type':_0x80f749,'resourceId':_0x269fc6['id']}})[_0xd446('0x1e')](function(){return _0x3ee7b7;});})[_0xd446('0x1e')](function(){_0x555af1[_0xd446('0x2a')](0xcc)[_0xd446('0x2b')]();});}};}function handleEntityNotFound(_0x17a7dc,_0xbfe78a){return function(_0x2ccb13){if(!_0x2ccb13){_0x17a7dc[_0xd446('0x29')](0x194);}return _0x2ccb13;};}function handleError(_0x1e648e,_0x46dbe5){_0x46dbe5=_0x46dbe5||0x1f4;return function(_0x30902c){logger[_0xd446('0x23')](_0x30902c[_0xd446('0x37')]);if(_0x30902c[_0xd446('0x38')]){delete _0x30902c[_0xd446('0x38')];}_0x1e648e[_0xd446('0x2a')](_0x46dbe5)[_0xd446('0x39')](_0x30902c);};}exports[_0xd446('0x3a')]=function(_0x42fa18,_0x3873f4){var _0x84028={},_0x18198d={},_0x3e8b71={'count':0x0,'rows':[]};var _0x1d01f2=_[_0xd446('0x3b')](db[_0xd446('0x3c')][_0xd446('0x3d')],function(_0x1ae66a){return{'name':_0x1ae66a[_0xd446('0x3e')],'type':_0x1ae66a[_0xd446('0x3f')][_0xd446('0x40')]};});_0x18198d['model']=_[_0xd446('0x3b')](_0x1d01f2,_0xd446('0x38'));_0x18198d[_0xd446('0x41')]=_[_0xd446('0x42')](_0x42fa18[_0xd446('0x41')]);_0x18198d[_0xd446('0x43')]=_[_0xd446('0x44')](_0x18198d['model'],_0x18198d[_0xd446('0x41')]);_0x84028[_0xd446('0x45')]=_[_0xd446('0x44')](_0x18198d['model'],qs[_0xd446('0x46')](_0x42fa18[_0xd446('0x41')][_0xd446('0x46')]));_0x84028[_0xd446('0x45')]=_0x84028[_0xd446('0x45')][_0xd446('0x47')]?_0x84028[_0xd446('0x45')]:_0x18198d[_0xd446('0x48')];if(!_0x42fa18['query'][_0xd446('0x49')](_0xd446('0x4a'))){_0x84028[_0xd446('0x2f')]=qs[_0xd446('0x2f')](_0x42fa18['query'][_0xd446('0x2f')]);_0x84028['offset']=qs[_0xd446('0x2d')](_0x42fa18[_0xd446('0x41')]['offset']);}_0x84028[_0xd446('0x4b')]=qs[_0xd446('0x4c')](_0x42fa18[_0xd446('0x41')][_0xd446('0x4c')]);_0x84028['where']=qs[_0xd446('0x43')](_[_0xd446('0x4d')](_0x42fa18['query'],_0x18198d[_0xd446('0x43')]),_0x1d01f2);if(_0x42fa18['query']['filter']){_0x84028[_0xd446('0x4e')]=_['merge'](_0x84028[_0xd446('0x4e')],{'$or':_['map'](_0x1d01f2,function(_0x1f5cc4){if(_0x1f5cc4[_0xd446('0x3f')]!=='VIRTUAL'){var _0x1cd214={};_0x1cd214[_0x1f5cc4[_0xd446('0x38')]]={'$like':'%'+_0x42fa18[_0xd446('0x41')]['filter']+'%'};return _0x1cd214;}})});}_0x84028=_[_0xd446('0x4f')]({},_0x84028,_0x42fa18[_0xd446('0x50')]);var _0x39f3e4={'where':_0x84028[_0xd446('0x4e')]};return db[_0xd446('0x3c')]['count'](_0x39f3e4)[_0xd446('0x1e')](function(_0x315789){_0x3e8b71[_0xd446('0x51')]=_0x315789;if(_0x42fa18['query'][_0xd446('0x52')]){_0x84028[_0xd446('0x53')]=[{'all':!![]}];}return db[_0xd446('0x3c')]['findAll'](_0x84028);})[_0xd446('0x1e')](function(_0x3deed4){_0x3e8b71[_0xd446('0x54')]=_0x3deed4;return _0x3e8b71;})['then'](respondWithFilteredResult(_0x3873f4,_0x84028))[_0xd446('0x28')](handleError(_0x3873f4,null));};exports[_0xd446('0x55')]=function(_0x364286,_0x4500ba){var _0x1feb66={'raw':!![],'where':{'id':_0x364286['params']['id']}},_0x436d82={};_0x436d82[_0xd446('0x48')]=_[_0xd446('0x42')](db[_0xd446('0x3c')][_0xd446('0x3d')]);_0x436d82[_0xd446('0x41')]=_[_0xd446('0x42')](_0x364286['query']);_0x436d82[_0xd446('0x43')]=_['intersection'](_0x436d82[_0xd446('0x48')],_0x436d82[_0xd446('0x41')]);_0x1feb66[_0xd446('0x45')]=_[_0xd446('0x44')](_0x436d82['model'],qs['fields'](_0x364286['query'][_0xd446('0x46')]));_0x1feb66[_0xd446('0x45')]=_0x1feb66['attributes']['length']?_0x1feb66[_0xd446('0x45')]:_0x436d82[_0xd446('0x48')];if(_0x364286[_0xd446('0x41')][_0xd446('0x52')]){_0x1feb66['include']=[{'all':!![]}];}_0x1feb66=_[_0xd446('0x4f')]({},_0x1feb66,_0x364286[_0xd446('0x50')]);return db[_0xd446('0x3c')][_0xd446('0x56')](_0x1feb66)[_0xd446('0x1e')](handleEntityNotFound(_0x4500ba,null))['then'](respondWithResult(_0x4500ba,null))[_0xd446('0x28')](handleError(_0x4500ba,null));};exports[_0xd446('0x57')]=function(_0x3e911b,_0x4b116b){return db[_0xd446('0x3c')][_0xd446('0x57')](_0x3e911b['body'],{})[_0xd446('0x1e')](function(_0x11f213){var _0x286f47=_0x3e911b[_0xd446('0x58')][_0xd446('0x36')]({'plain':!![]});if(!_0x286f47)throw new Error(_0xd446('0x59'));if(_0x286f47['role']===_0xd446('0x58')){var _0x54e108=_0x11f213['get']({'plain':!![]});var _0x36a95f='ChatQueues';return db[_0xd446('0x5a')][_0xd446('0x56')]({'where':{'name':_0x36a95f,'userProfileId':_0x286f47['userProfileId']},'raw':!![]})['then'](function(_0x80d565){if(_0x80d565&&_0x80d565['autoAssociation']===0x0){return db[_0xd446('0x5b')][_0xd446('0x57')]({'name':_0x54e108[_0xd446('0x38')],'resourceId':_0x54e108['id'],'type':_0x80d565[_0xd446('0x38')],'sectionId':_0x80d565['id']},{})[_0xd446('0x1e')](function(){return _0x11f213;});}else{return _0x11f213;}})[_0xd446('0x28')](function(_0x2f12e3){logger[_0xd446('0x23')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2f12e3);throw _0x2f12e3;});}return _0x11f213;})['then'](respondWithResult(_0x4b116b,0xc9))[_0xd446('0x28')](handleError(_0x4b116b,null));};exports[_0xd446('0x5c')]=function(_0x3f807d,_0x4f38a5){if(_0x3f807d[_0xd446('0x5d')]['id']){delete _0x3f807d[_0xd446('0x5d')]['id'];}return db[_0xd446('0x3c')][_0xd446('0x56')]({'where':{'id':_0x3f807d[_0xd446('0x5e')]['id']}})[_0xd446('0x1e')](handleEntityNotFound(_0x4f38a5,null))[_0xd446('0x1e')](saveUpdates(_0x3f807d['body'],null))['then'](respondWithResult(_0x4f38a5,null))[_0xd446('0x28')](handleError(_0x4f38a5,null));};exports[_0xd446('0x35')]=function(_0x18d56d,_0x5634a1){return db['ChatQueue'][_0xd446('0x56')]({'where':{'id':_0x18d56d['params']['id']}})[_0xd446('0x1e')](handleEntityNotFound(_0x5634a1,null))[_0xd446('0x1e')](removeEntity(_0x5634a1,null))['catch'](handleError(_0x5634a1,null));};exports[_0xd446('0x5f')]=function(_0x467c09,_0x2d4764){return db[_0xd446('0x3c')][_0xd446('0x5f')]()['then'](respondWithResult(_0x2d4764,null))[_0xd446('0x28')](handleError(_0x2d4764,null));};exports['getMembers']=function(_0x4ef72c,_0x1e76d4,_0x23fcbf){var _0x37f945={'raw':!![],'where':{}},_0x46f687={},_0x4f578c;return db[_0xd446('0x3c')][_0xd446('0x60')]({'where':{'id':_0x4ef72c[_0xd446('0x5e')]['id']}})[_0xd446('0x1e')](handleEntityNotFound(_0x1e76d4,null))[_0xd446('0x1e')](function(_0x39d732){if(_0x39d732){_0x4f578c=_0x39d732[_0xd446('0x36')]({'plain':!![]});_0x46f687[_0xd446('0x48')]=_[_0xd446('0x42')](db[_0xd446('0x61')][_0xd446('0x3d')]);_0x46f687[_0xd446('0x41')]=_['keys'](_0x4ef72c[_0xd446('0x41')]);_0x46f687[_0xd446('0x43')]=_[_0xd446('0x44')](_0x46f687['model'],_0x46f687[_0xd446('0x41')]);_0x37f945[_0xd446('0x45')]=_[_0xd446('0x44')](_0x46f687['model'],qs[_0xd446('0x46')](_0x4ef72c[_0xd446('0x41')][_0xd446('0x46')]));_0x37f945[_0xd446('0x45')]=_0x37f945[_0xd446('0x45')][_0xd446('0x47')]?_0x37f945[_0xd446('0x45')]:_0x46f687[_0xd446('0x48')];if(!_0x4ef72c['query'][_0xd446('0x49')]('nolimit')){_0x37f945[_0xd446('0x2f')]=qs[_0xd446('0x2f')](_0x4ef72c[_0xd446('0x41')][_0xd446('0x2f')]);_0x37f945[_0xd446('0x2d')]=qs[_0xd446('0x2d')](_0x4ef72c[_0xd446('0x41')][_0xd446('0x2d')]);}_0x37f945[_0xd446('0x4b')]=qs[_0xd446('0x4c')](_0x4ef72c[_0xd446('0x41')][_0xd446('0x4c')]);_0x37f945[_0xd446('0x4e')]=qs['filters'](_['pick'](_0x4ef72c['query'],_0x46f687[_0xd446('0x43')]));_0x37f945[_0xd446('0x4e')]['ChatQueueId']=_0x39d732['id'];if(_0x4ef72c['query'][_0xd446('0x62')]){_0x37f945[_0xd446('0x4e')]=_[_0xd446('0x4f')](_0x37f945[_0xd446('0x4e')],{'$or':_[_0xd446('0x3b')](_0x37f945[_0xd446('0x45')],function(_0x2f5f9c){var _0x74b7e0={};_0x74b7e0[_0x2f5f9c]={'$like':'%'+_0x4ef72c[_0xd446('0x41')][_0xd446('0x62')]+'%'};return _0x74b7e0;})});}_0x37f945=_[_0xd446('0x4f')]({},_0x37f945,_0x4ef72c['options']);return db[_0xd446('0x61')][_0xd446('0x63')](_0x37f945);}})[_0xd446('0x1e')](function(_0x39cfd2){if(_0x39cfd2){return db[_0xd446('0x64')][_0xd446('0x65')]({'where':{'id':_[_0xd446('0x3b')](_0x39cfd2,_0xd446('0x66')),'role':'agent'},'attributes':['id',_0xd446('0x38'),'chatPause','updatedAt',_0xd446('0x67')]});}})[_0xd446('0x1e')](function(_0x56f7ac){if(_0x56f7ac){return{'count':_0x56f7ac[_0xd446('0x51')],'rows':_['map'](_0x56f7ac[_0xd446('0x54')],function(_0x4e03cb){return{'membername':_0x4e03cb[_0xd446('0x38')],'UserId':_0x4e03cb['id'],'queue_name':_0x4f578c['name'],'ChatQueueId':_0x4f578c['id'],'interface':util[_0xd446('0x68')]('%s/%s',_0xd446('0x69'),_0x4e03cb[_0xd446('0x38')]),'penalty':0x0,'paused':_0x4e03cb[_0xd446('0x6a')],'createdAt':_0x4e03cb[_0xd446('0x67')],'updatedAt':_0x4e03cb[_0xd446('0x6b')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xd446('0x1e')](respondWithFilteredResult(_0x1e76d4,_0x37f945))[_0xd446('0x28')](handleError(_0x1e76d4,null));};exports[_0xd446('0x6c')]=function(_0x56e59f,_0x8eec2,_0x41b5e7){var _0xfece70={};var _0x208824={};var _0x552500;var _0xdf125e;return db['ChatQueue'][_0xd446('0x60')]({'where':{'id':_0x56e59f[_0xd446('0x5e')]['id']}})['then'](handleEntityNotFound(_0x8eec2,null))[_0xd446('0x1e')](function(_0x25b181){if(_0x25b181){_0x552500=_0x25b181;_0x208824[_0xd446('0x48')]=_[_0xd446('0x42')](db[_0xd446('0x6d')]['rawAttributes']);_0x208824[_0xd446('0x41')]=_[_0xd446('0x42')](_0x56e59f['query']);_0x208824['filters']=_[_0xd446('0x44')](_0x208824[_0xd446('0x48')],_0x208824[_0xd446('0x41')]);_0xfece70[_0xd446('0x45')]=_[_0xd446('0x44')](_0x208824[_0xd446('0x48')],qs[_0xd446('0x46')](_0x56e59f[_0xd446('0x41')][_0xd446('0x46')]));_0xfece70[_0xd446('0x45')]=_0xfece70[_0xd446('0x45')][_0xd446('0x47')]?_0xfece70[_0xd446('0x45')]:_0x208824[_0xd446('0x48')];_0xfece70[_0xd446('0x4b')]=qs[_0xd446('0x4c')](_0x56e59f[_0xd446('0x41')]['sort']);_0xfece70['where']=qs['filters'](_[_0xd446('0x4d')](_0x56e59f[_0xd446('0x41')],_0x208824['filters']));if(_0x56e59f[_0xd446('0x41')]['filter']){_0xfece70[_0xd446('0x4e')]=_[_0xd446('0x4f')](_0xfece70[_0xd446('0x4e')],{'$or':_[_0xd446('0x3b')](_0xfece70[_0xd446('0x45')],function(_0x336a01){var _0x1a9931={};_0x1a9931[_0x336a01]={'$like':'%'+_0x56e59f[_0xd446('0x41')][_0xd446('0x62')]+'%'};return _0x1a9931;})});}_0xfece70=_['merge']({},_0xfece70,_0x56e59f[_0xd446('0x50')]);return _0x552500[_0xd446('0x6c')](_0xfece70);}})['then'](function(_0x15c3f4){if(_0x15c3f4){_0xdf125e=_0x15c3f4[_0xd446('0x47')];if(!_0x56e59f[_0xd446('0x41')][_0xd446('0x49')](_0xd446('0x4a'))){_0xfece70['limit']=qs['limit'](_0x56e59f[_0xd446('0x41')][_0xd446('0x2f')]);_0xfece70[_0xd446('0x2d')]=qs[_0xd446('0x2d')](_0x56e59f[_0xd446('0x41')]['offset']);}return _0x552500[_0xd446('0x6c')](_0xfece70);}})[_0xd446('0x1e')](function(_0x1aa8b3){if(_0x1aa8b3){return _0x1aa8b3?{'count':_0xdf125e,'rows':_0x1aa8b3}:null;}})[_0xd446('0x1e')](respondWithResult(_0x8eec2,null))[_0xd446('0x28')](handleError(_0x8eec2,null));};exports['addTeams']=function(_0x26b2ed,_0x3ea147,_0xdfa4ae){var _0x53132e=_0x26b2ed['body'][_0xd446('0x6e')];return db['Team']['findAll']({'where':{'id':_0x53132e},'attributes':['id'],'include':[{'model':db[_0xd446('0x64')],'as':_0xd446('0x6f'),'attributes':['id','name',_0xd446('0x70'),_0xd446('0x71'),_0xd446('0x72')],'raw':!![]}]})[_0xd446('0x1e')](function(_0x4126a3){if(_0x4126a3){var _0x35d594=_[_0xd446('0x73')](_0x4126a3,function(_0x31f941){var _0x4b6eb3=_0x31f941[_0xd446('0x36')]({'plain':!![]});return _0x4b6eb3[_0xd446('0x6f')];});return db['ChatQueue']['find']({'where':{'id':_0x26b2ed['params']['id']}})['then'](function(_0x1d7c2b){return db[_0xd446('0x74')][_0xd446('0x75')](function(_0x5275ab){return _0x1d7c2b['addTeams'](_0x53132e,{'transaction':_0x5275ab})['then'](function(){return BPromise[_0xd446('0x76')](_0x35d594,function(_0x567655){return db[_0xd446('0x61')]['findOrCreate']({'where':{'UserId':_0x567655['id'],'ChatQueueId':_0x26b2ed[_0xd446('0x5e')]['id']},'transaction':_0x5275ab});});})[_0xd446('0x1e')](function(){_0x35d594[_0xd446('0x77')](function(_0x24f9c7){socket[_0xd446('0x78')]('userChatQueue:save',{'UserId':_0x24f9c7['id'],'ChatQueueId':_0x1d7c2b['id']});});});});});}})[_0xd446('0x1e')](respondWithStatusCode(_0x3ea147,null))['catch'](handleError(_0x3ea147,null));};exports[_0xd446('0x79')]=function(_0x165071,_0x1e6d29,_0x248bf2){return db[_0xd446('0x6d')]['findAll']({'where':{'id':_0x165071[_0xd446('0x41')][_0xd446('0x6e')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0xd446('0x6f'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x1e6d29,null))['then'](function(_0x56ce20){var _0x1dd1f1=_[_0xd446('0x3b')](_0x56ce20,'id');var _0x522107=[];var _0x23d281=[];var _0x3a2fad=squel['select']();_0x3a2fad[_0xd446('0x7a')](_0xd446('0x7b'))['from'](_0xd446('0x7c'),'tq')[_0xd446('0x7d')](_0xd446('0x7e'),'ut',_0xd446('0x7f'))[_0xd446('0x4e')]('ChatQueueId\x20=\x20?',_0x165071[_0xd446('0x5e')]['id']);for(var _0x5896e4=0x0;_0x5896e4<_0x56ce20[_0xd446('0x47')];_0x5896e4+=0x1){let _0x42a045=_0x56ce20[_0x5896e4];for(var _0x43e3ef=0x0;_0x43e3ef<_0x42a045[_0xd446('0x6f')][_0xd446('0x47')];_0x43e3ef+=0x1){let _0x303886=_0x42a045['Agents'][_0x43e3ef];var _0x271a5d=_0x3a2fad[_0xd446('0x80')]();_0x271a5d[_0xd446('0x4e')](_0xd446('0x81'),_0x303886['id']);_0x23d281[_0xd446('0x82')](db[_0xd446('0x74')][_0xd446('0x41')](_0x271a5d[_0xd446('0x83')](),{'type':db['sequelize'][_0xd446('0x84')]['SELECT']})['then'](function(_0x3ae90b){if(_0x3ae90b[_0xd446('0x47')]===0x1){return _0x303886['id'];}else{var _0x1a1a53=_[_0xd446('0x85')](_[_0xd446('0x3b')](_0x3ae90b,_0xd446('0x86')),function(_0x211dbe){return _['includes'](_0x1dd1f1,_0x211dbe);});if(_0x1a1a53){return _0x303886['id'];}}}));}}return BPromise[_0xd446('0x87')](_0x23d281)[_0xd446('0x1e')](function(_0x3cf059){_0x522107=_(_0x522107)[_0xd446('0x88')](_0x3cf059)[_0xd446('0x89')]()[_0xd446('0x8a')]();return db[_0xd446('0x3c')]['find']({'where':{'id':_0x165071[_0xd446('0x5e')]['id']}})[_0xd446('0x1e')](function(_0x537816){return db[_0xd446('0x74')]['transaction'](function(_0x455866){return _0x537816['removeTeams'](_0x165071[_0xd446('0x41')][_0xd446('0x6e')],{'transaction':_0x455866})['then'](function(){if(!_['isEmpty'](_0x522107)){return _0x537816['removeAgents'](_0x522107,{'transaction':_0x455866});}})['then'](function(){_0x522107['forEach'](function(_0x3a3529){socket[_0xd446('0x78')]('userChatQueue:remove',{'UserId':_0x3a3529,'ChatQueueId':_0x537816['id']});});});});});});})[_0xd446('0x1e')](respondWithStatusCode(_0x1e6d29,null))['catch'](handleError(_0x1e6d29,null));};exports[_0xd446('0x8b')]=function(_0x3ad5de,_0x25e441,_0x18e1a9){return db['ChatQueue'][_0xd446('0x56')]({'where':{'id':_0x3ad5de['params']['id']}})[_0xd446('0x1e')](handleEntityNotFound(_0x25e441,null))['then'](function(_0x133d7f){if(_0x133d7f){return _0x133d7f[_0xd446('0x8b')](_0x3ad5de['body']['ids'],_[_0xd446('0x8c')](_0x3ad5de[_0xd446('0x5d')],['ids','id'])||{})['spread'](function(_0x948228){for(var _0x2d3cce=0x0;_0x2d3cce<_0x3ad5de[_0xd446('0x5d')][_0xd446('0x6e')]['length'];_0x2d3cce+=0x1){socket[_0xd446('0x78')](_0xd446('0x8d'),{'UserId':Number(_0x3ad5de[_0xd446('0x5d')][_0xd446('0x6e')][_0x2d3cce]),'ChatQueueId':Number(_0x3ad5de[_0xd446('0x5e')]['id'])});}return _0x948228;});}})[_0xd446('0x1e')](respondWithResult(_0x25e441,null))['catch'](handleError(_0x25e441,null));};exports[_0xd446('0x8e')]=function(_0x4803be,_0x5df0ae,_0x476cb6){return db[_0xd446('0x3c')]['find']({'where':{'id':_0x4803be[_0xd446('0x5e')]['id']}})['then'](handleEntityNotFound(_0x5df0ae,null))['then'](function(_0x1db4b5){if(_0x1db4b5){return _0x1db4b5['removeAgents'](_0x4803be[_0xd446('0x41')]['ids'])[_0xd446('0x1e')](function(){if(_[_0xd446('0x8f')](_0x4803be[_0xd446('0x41')][_0xd446('0x6e')])){for(var _0x29c137=0x0;_0x29c137<_0x4803be[_0xd446('0x41')][_0xd446('0x6e')][_0xd446('0x47')];_0x29c137+=0x1){socket['emit'](_0xd446('0x90'),{'UserId':Number(_0x4803be['query'][_0xd446('0x6e')][_0x29c137]),'ChatQueueId':Number(_0x4803be[_0xd446('0x5e')]['id'])});}}else{socket['emit'](_0xd446('0x90'),{'UserId':Number(_0x4803be[_0xd446('0x41')][_0xd446('0x6e')]),'ChatQueueId':Number(_0x4803be[_0xd446('0x5e')]['id'])});}});}})[_0xd446('0x1e')](respondWithStatusCode(_0x5df0ae,null))[_0xd446('0x28')](handleError(_0x5df0ae,null));};exports[_0xd446('0x91')]=function(_0x14ada0,_0x4a2043,_0x3accaa){var _0x287199={};var _0x29717b={};var _0x809e5e;var _0x11f1cb;return db[_0xd446('0x3c')][_0xd446('0x60')]({'where':{'id':_0x14ada0[_0xd446('0x5e')]['id']}})[_0xd446('0x1e')](handleEntityNotFound(_0x4a2043,null))[_0xd446('0x1e')](function(_0x1f293d){if(_0x1f293d){_0x809e5e=_0x1f293d;_0x29717b['model']=_['keys'](db['User']['rawAttributes']);_0x29717b['query']=_[_0xd446('0x42')](_0x14ada0[_0xd446('0x41')]);_0x29717b[_0xd446('0x43')]=_[_0xd446('0x44')](_0x29717b[_0xd446('0x48')],_0x29717b[_0xd446('0x41')]);_0x287199[_0xd446('0x45')]=_[_0xd446('0x44')](_0x29717b[_0xd446('0x48')],qs[_0xd446('0x46')](_0x14ada0[_0xd446('0x41')][_0xd446('0x46')]));_0x287199['attributes']=_0x287199[_0xd446('0x45')][_0xd446('0x47')]?_0x287199['attributes']:_0x29717b[_0xd446('0x48')];_0x287199['order']=qs['sort'](_0x14ada0[_0xd446('0x41')][_0xd446('0x4c')]);_0x287199[_0xd446('0x4e')]=qs[_0xd446('0x43')](_['pick'](_0x14ada0[_0xd446('0x41')],_0x29717b[_0xd446('0x43')]));if(_0x14ada0[_0xd446('0x41')][_0xd446('0x62')]){_0x287199[_0xd446('0x4e')]=_[_0xd446('0x4f')](_0x287199['where'],{'$or':_[_0xd446('0x3b')](_0x287199['attributes'],function(_0x50ac71){var _0x3b2f50={};_0x3b2f50[_0x50ac71]={'$like':'%'+_0x14ada0[_0xd446('0x41')][_0xd446('0x62')]+'%'};return _0x3b2f50;})});}_0x287199=_[_0xd446('0x4f')]({},_0x287199,_0x14ada0[_0xd446('0x50')]);return _0x809e5e[_0xd446('0x91')](_0x287199);}})[_0xd446('0x1e')](function(_0x2fdc9f){if(_0x2fdc9f){_0x11f1cb=_0x2fdc9f[_0xd446('0x47')];if(!_0x14ada0[_0xd446('0x41')]['hasOwnProperty'](_0xd446('0x4a'))){_0x287199[_0xd446('0x2f')]=qs[_0xd446('0x2f')](_0x14ada0['query'][_0xd446('0x2f')]);_0x287199[_0xd446('0x2d')]=qs['offset'](_0x14ada0['query'][_0xd446('0x2d')]);}return _0x809e5e[_0xd446('0x91')](_0x287199);}})[_0xd446('0x1e')](function(_0x35ec7e){if(_0x35ec7e){return _0x35ec7e?{'count':_0x11f1cb,'rows':_0x35ec7e}:null;}})[_0xd446('0x1e')](respondWithResult(_0x4a2043,null))[_0xd446('0x28')](handleError(_0x4a2043,null));};
\ No newline at end of file