Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 6f80fa8..8d22d5c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbf96=['%s/%s','SIP','getTeams','findOne','ids','Team','Agents','online','interface','flatMap','addTeams','each','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','sequelize','toString','QueryTypes','SELECT','every','TeamId','includes','union','value','removeTeams','isEmpty','userChatQueue:remove','omit','spread','removeAgents','isArray','getAgents','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','register','jayson/promise','client','http','request','then','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','end','status','count','offset','limit','Content-Range','json','apply','save','update','destroy','get','ChatQueues','UserProfileResource','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','keys','filters','attributes','fields','query','nolimit','sort','where','pick','merge','options','ChatQueue','includeAll','findAll','rows','show','params','intersection','length','include','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','hasOwnProperty','order','ChatQueueId','filter','UserChatQueue','User','findAndCountAll','UserId','agent','chatPause','updatedAt','createdAt','format'];(function(_0x19dd7a,_0x2b8d4f){var _0x43b25c=function(_0x1d5d35){while(--_0x1d5d35){_0x19dd7a['push'](_0x19dd7a['shift']());}};_0x43b25c(++_0x2b8d4f);}(_0xbf96,0xc6));var _0x6bf9=function(_0x323a99,_0x4736dc){_0x323a99=_0x323a99-0x0;var _0x29c23f=_0xbf96[_0x323a99];return _0x29c23f;};'use strict';var pdf=require(_0x6bf9('0x0'));var emlformat=require(_0x6bf9('0x1'));var rimraf=require(_0x6bf9('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x6bf9('0x3'));var rp=require(_0x6bf9('0x4'));var moment=require(_0x6bf9('0x5'));var BPromise=require(_0x6bf9('0x6'));var Mustache=require(_0x6bf9('0x7'));var util=require(_0x6bf9('0x8'));var path=require('path');var sox=require(_0x6bf9('0x9'));var csv=require(_0x6bf9('0xa'));var ejs=require(_0x6bf9('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x6bf9('0xc'));var crypto=require(_0x6bf9('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x6bf9('0xe'));var toCsv=require(_0x6bf9('0xa'));var querystring=require(_0x6bf9('0xf'));var Papa=require(_0x6bf9('0x10'));var Redis=require('ioredis');var authService=require(_0x6bf9('0x11'));var qs=require(_0x6bf9('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x6bf9('0x13'))('api');var utils=require('../../config/utils');var config=require(_0x6bf9('0x14'));var licenseUtil=require(_0x6bf9('0x15'));var db=require(_0x6bf9('0x16'))['db'];config[_0x6bf9('0x17')]=_[_0x6bf9('0x18')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6bf9('0x17')]));require('./chatQueue.socket')[_0x6bf9('0x19')](socket);var jayson=require(_0x6bf9('0x1a'));var client=jayson[_0x6bf9('0x1b')][_0x6bf9('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x2a34f1,_0x39e655,_0x36292d,_0x2f6f98){return new BPromise(function(_0x4c2411,_0x2919c2){var _0x1f7d7=_0x2f6f98||client;return _0x1f7d7[_0x6bf9('0x1d')](_0x2a34f1,_0x36292d)[_0x6bf9('0x1e')](function(_0x148485){logger['info'](_0x6bf9('0x1f'),_0x39e655,_0x6bf9('0x20'));logger[_0x6bf9('0x21')](_0x6bf9('0x22'),_0x39e655,_0x6bf9('0x20'),JSON[_0x6bf9('0x23')](_0x148485));if(_0x148485[_0x6bf9('0x24')]){if(_0x148485['error'][_0x6bf9('0x25')]===0x1f4){logger[_0x6bf9('0x24')](_0x6bf9('0x1f'),_0x39e655,_0x148485[_0x6bf9('0x24')][_0x6bf9('0x26')]);return _0x2919c2(_0x148485['error']['message']);}logger[_0x6bf9('0x24')](_0x6bf9('0x1f'),_0x39e655,_0x148485['error'][_0x6bf9('0x26')]);return _0x4c2411(_0x148485[_0x6bf9('0x24')][_0x6bf9('0x26')]);}else{logger[_0x6bf9('0x27')]('ChatQueue,\x20%s,\x20%s',_0x39e655,_0x6bf9('0x20'));_0x4c2411(_0x148485[_0x6bf9('0x28')][_0x6bf9('0x26')]);}})[_0x6bf9('0x29')](function(_0x32ecac){logger[_0x6bf9('0x24')](_0x6bf9('0x1f'),_0x39e655,_0x32ecac);_0x2919c2(_0x32ecac);});});}function respondWithStatusCode(_0x2a6217,_0x43cb77){_0x43cb77=_0x43cb77||0xcc;return function(_0x442f63){if(_0x442f63){return _0x2a6217[_0x6bf9('0x2a')](_0x43cb77);}return _0x2a6217['status'](_0x43cb77)[_0x6bf9('0x2b')]();};}function respondWithResult(_0x20ff55,_0x20baae){_0x20baae=_0x20baae||0xc8;return function(_0xfb049a){if(_0xfb049a){return _0x20ff55[_0x6bf9('0x2c')](_0x20baae)['json'](_0xfb049a);}};}function respondWithFilteredResult(_0x82d4e2,_0x2f312a){return function(_0x9a1445){if(_0x9a1445){var _0xdf34d3=_0x9a1445[_0x6bf9('0x2d')],_0x249d78=_0x2f312a[_0x6bf9('0x2e')],_0x4f2110=_0x2f312a[_0x6bf9('0x2e')]+_0x2f312a[_0x6bf9('0x2f')],_0x1439c2;if(_0x4f2110>=_0xdf34d3){_0x4f2110=_0xdf34d3;_0x1439c2=0xc8;}else{_0x1439c2=0xce;}_0x82d4e2[_0x6bf9('0x2c')](_0x1439c2);return _0x82d4e2['set'](_0x6bf9('0x30'),_0x249d78+'-'+_0x4f2110+'/'+_0xdf34d3)[_0x6bf9('0x31')](_0x9a1445);}return null;};}function patchUpdates(_0x2c8f70){return function(_0x735488){try{jsonpatch[_0x6bf9('0x32')](_0x735488,_0x2c8f70,!![]);}catch(_0x18b268){return BPromise['reject'](_0x18b268);}return _0x735488[_0x6bf9('0x33')]();};}function saveUpdates(_0x326373,_0x49b4c0){return function(_0x3f664d){if(_0x3f664d){return _0x3f664d[_0x6bf9('0x34')](_0x326373)[_0x6bf9('0x1e')](function(_0x26161d){return _0x26161d;});}return null;};}function removeEntity(_0x525878,_0x13b0d0){return function(_0x2853c5){if(_0x2853c5){return _0x2853c5[_0x6bf9('0x35')]()[_0x6bf9('0x1e')](function(){var _0x485796=_0x2853c5[_0x6bf9('0x36')]({'plain':!![]});var _0x298138=_0x6bf9('0x37');return db[_0x6bf9('0x38')][_0x6bf9('0x35')]({'where':{'type':_0x298138,'resourceId':_0x485796['id']}})['then'](function(){return _0x2853c5;});})['then'](function(){_0x525878[_0x6bf9('0x2c')](0xcc)[_0x6bf9('0x2b')]();});}};}function handleEntityNotFound(_0x1216b1,_0x249696){return function(_0xacccc6){if(!_0xacccc6){_0x1216b1[_0x6bf9('0x2a')](0x194);}return _0xacccc6;};}function handleError(_0x3b370d,_0x2718ac){_0x2718ac=_0x2718ac||0x1f4;return function(_0x2b6e0c){logger['error'](_0x2b6e0c[_0x6bf9('0x39')]);if(_0x2b6e0c[_0x6bf9('0x3a')]){delete _0x2b6e0c[_0x6bf9('0x3a')];}_0x3b370d[_0x6bf9('0x2c')](_0x2718ac)[_0x6bf9('0x3b')](_0x2b6e0c);};}exports[_0x6bf9('0x3c')]=function(_0x4dc02f,_0x1a6844){var _0xdb5477={},_0x180b12={},_0x4912f3={'count':0x0,'rows':[]};var _0x14dfa4=_[_0x6bf9('0x3d')](db['ChatQueue'][_0x6bf9('0x3e')],function(_0x4c9f38){return{'name':_0x4c9f38[_0x6bf9('0x3f')],'type':_0x4c9f38[_0x6bf9('0x40')][_0x6bf9('0x41')]};});_0x180b12[_0x6bf9('0x42')]=_[_0x6bf9('0x3d')](_0x14dfa4,_0x6bf9('0x3a'));_0x180b12['query']=_[_0x6bf9('0x43')](_0x4dc02f['query']);_0x180b12[_0x6bf9('0x44')]=_['intersection'](_0x180b12['model'],_0x180b12['query']);_0xdb5477[_0x6bf9('0x45')]=_['intersection'](_0x180b12['model'],qs[_0x6bf9('0x46')](_0x4dc02f['query'][_0x6bf9('0x46')]));_0xdb5477[_0x6bf9('0x45')]=_0xdb5477['attributes']['length']?_0xdb5477[_0x6bf9('0x45')]:_0x180b12[_0x6bf9('0x42')];if(!_0x4dc02f[_0x6bf9('0x47')]['hasOwnProperty'](_0x6bf9('0x48'))){_0xdb5477['limit']=qs[_0x6bf9('0x2f')](_0x4dc02f[_0x6bf9('0x47')][_0x6bf9('0x2f')]);_0xdb5477['offset']=qs[_0x6bf9('0x2e')](_0x4dc02f['query'][_0x6bf9('0x2e')]);}_0xdb5477['order']=qs[_0x6bf9('0x49')](_0x4dc02f['query'][_0x6bf9('0x49')]);_0xdb5477[_0x6bf9('0x4a')]=qs[_0x6bf9('0x44')](_[_0x6bf9('0x4b')](_0x4dc02f['query'],_0x180b12[_0x6bf9('0x44')]),_0x14dfa4);if(_0x4dc02f['query']['filter']){_0xdb5477[_0x6bf9('0x4a')]=_[_0x6bf9('0x4c')](_0xdb5477[_0x6bf9('0x4a')],{'$or':_[_0x6bf9('0x3d')](_0x14dfa4,function(_0x475129){if(_0x475129['type']!=='VIRTUAL'){var _0x4aa413={};_0x4aa413[_0x475129['name']]={'$like':'%'+_0x4dc02f[_0x6bf9('0x47')]['filter']+'%'};return _0x4aa413;}})});}_0xdb5477=_[_0x6bf9('0x4c')]({},_0xdb5477,_0x4dc02f[_0x6bf9('0x4d')]);var _0x3dba15={'where':_0xdb5477[_0x6bf9('0x4a')]};return db[_0x6bf9('0x4e')][_0x6bf9('0x2d')](_0x3dba15)['then'](function(_0x11dd74){_0x4912f3[_0x6bf9('0x2d')]=_0x11dd74;if(_0x4dc02f['query'][_0x6bf9('0x4f')]){_0xdb5477['include']=[{'all':!![]}];}return db[_0x6bf9('0x4e')][_0x6bf9('0x50')](_0xdb5477);})[_0x6bf9('0x1e')](function(_0x2739fc){_0x4912f3[_0x6bf9('0x51')]=_0x2739fc;return _0x4912f3;})['then'](respondWithFilteredResult(_0x1a6844,_0xdb5477))[_0x6bf9('0x29')](handleError(_0x1a6844,null));};exports[_0x6bf9('0x52')]=function(_0x4fe001,_0x1b181b){var _0x5eca26={'raw':!![],'where':{'id':_0x4fe001[_0x6bf9('0x53')]['id']}},_0xae1907={};_0xae1907[_0x6bf9('0x42')]=_[_0x6bf9('0x43')](db['ChatQueue']['rawAttributes']);_0xae1907['query']=_[_0x6bf9('0x43')](_0x4fe001['query']);_0xae1907['filters']=_[_0x6bf9('0x54')](_0xae1907[_0x6bf9('0x42')],_0xae1907['query']);_0x5eca26[_0x6bf9('0x45')]=_['intersection'](_0xae1907['model'],qs[_0x6bf9('0x46')](_0x4fe001[_0x6bf9('0x47')][_0x6bf9('0x46')]));_0x5eca26['attributes']=_0x5eca26['attributes'][_0x6bf9('0x55')]?_0x5eca26[_0x6bf9('0x45')]:_0xae1907[_0x6bf9('0x42')];if(_0x4fe001[_0x6bf9('0x47')][_0x6bf9('0x4f')]){_0x5eca26[_0x6bf9('0x56')]=[{'all':!![]}];}_0x5eca26=_['merge']({},_0x5eca26,_0x4fe001[_0x6bf9('0x4d')]);return db[_0x6bf9('0x4e')][_0x6bf9('0x57')](_0x5eca26)['then'](handleEntityNotFound(_0x1b181b,null))[_0x6bf9('0x1e')](respondWithResult(_0x1b181b,null))['catch'](handleError(_0x1b181b,null));};exports['create']=function(_0x3d95c0,_0x55b811){return db[_0x6bf9('0x4e')][_0x6bf9('0x58')](_0x3d95c0['body'],{})['then'](function(_0x271d75){var _0x43b96a=_0x3d95c0[_0x6bf9('0x59')][_0x6bf9('0x36')]({'plain':!![]});if(!_0x43b96a)throw new Error(_0x6bf9('0x5a'));if(_0x43b96a[_0x6bf9('0x5b')]==='user'){var _0xd9d633=_0x271d75[_0x6bf9('0x36')]({'plain':!![]});var _0x19787c=_0x6bf9('0x37');return db['UserProfileSection'][_0x6bf9('0x57')]({'where':{'name':_0x19787c,'userProfileId':_0x43b96a[_0x6bf9('0x5c')]},'raw':!![]})[_0x6bf9('0x1e')](function(_0x44417b){if(_0x44417b&&_0x44417b[_0x6bf9('0x5d')]===0x0){return db[_0x6bf9('0x38')][_0x6bf9('0x58')]({'name':_0xd9d633['name'],'resourceId':_0xd9d633['id'],'type':_0x44417b[_0x6bf9('0x3a')],'sectionId':_0x44417b['id']},{})[_0x6bf9('0x1e')](function(){return _0x271d75;});}else{return _0x271d75;}})[_0x6bf9('0x29')](function(_0x285438){logger['error'](_0x6bf9('0x5e'),_0x285438);throw _0x285438;});}return _0x271d75;})['then'](respondWithResult(_0x55b811,0xc9))[_0x6bf9('0x29')](handleError(_0x55b811,null));};exports[_0x6bf9('0x34')]=function(_0x4b2374,_0x29f66e){if(_0x4b2374[_0x6bf9('0x5f')]['id']){delete _0x4b2374[_0x6bf9('0x5f')]['id'];}return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0x4b2374[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x29f66e,null))[_0x6bf9('0x1e')](saveUpdates(_0x4b2374[_0x6bf9('0x5f')],null))[_0x6bf9('0x1e')](respondWithResult(_0x29f66e,null))[_0x6bf9('0x29')](handleError(_0x29f66e,null));};exports[_0x6bf9('0x35')]=function(_0x77b3a9,_0x1a808a){return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0x77b3a9[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x1a808a,null))[_0x6bf9('0x1e')](removeEntity(_0x1a808a,null))[_0x6bf9('0x29')](handleError(_0x1a808a,null));};exports[_0x6bf9('0x60')]=function(_0x45e23f,_0x459c44){return db[_0x6bf9('0x4e')]['describe']()[_0x6bf9('0x1e')](respondWithResult(_0x459c44,null))['catch'](handleError(_0x459c44,null));};exports['getMembers']=function(_0x49b03e,_0x5bb2cd,_0x45da6e){var _0x4e2cc8={'raw':!![],'where':{}},_0x685e1b={},_0x5d262b;return db[_0x6bf9('0x4e')]['findOne']({'where':{'id':_0x49b03e['params']['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x5bb2cd,null))[_0x6bf9('0x1e')](function(_0x159e82){if(_0x159e82){_0x5d262b=_0x159e82[_0x6bf9('0x36')]({'plain':!![]});_0x685e1b[_0x6bf9('0x42')]=_[_0x6bf9('0x43')](db['UserChatQueue'][_0x6bf9('0x3e')]);_0x685e1b[_0x6bf9('0x47')]=_[_0x6bf9('0x43')](_0x49b03e[_0x6bf9('0x47')]);_0x685e1b[_0x6bf9('0x44')]=_[_0x6bf9('0x54')](_0x685e1b['model'],_0x685e1b[_0x6bf9('0x47')]);_0x4e2cc8['attributes']=_['intersection'](_0x685e1b['model'],qs[_0x6bf9('0x46')](_0x49b03e[_0x6bf9('0x47')][_0x6bf9('0x46')]));_0x4e2cc8[_0x6bf9('0x45')]=_0x4e2cc8[_0x6bf9('0x45')][_0x6bf9('0x55')]?_0x4e2cc8[_0x6bf9('0x45')]:_0x685e1b[_0x6bf9('0x42')];if(!_0x49b03e[_0x6bf9('0x47')][_0x6bf9('0x61')]('nolimit')){_0x4e2cc8[_0x6bf9('0x2f')]=qs[_0x6bf9('0x2f')](_0x49b03e[_0x6bf9('0x47')][_0x6bf9('0x2f')]);_0x4e2cc8[_0x6bf9('0x2e')]=qs[_0x6bf9('0x2e')](_0x49b03e['query'][_0x6bf9('0x2e')]);}_0x4e2cc8[_0x6bf9('0x62')]=qs['sort'](_0x49b03e['query'][_0x6bf9('0x49')]);_0x4e2cc8[_0x6bf9('0x4a')]=qs['filters'](_[_0x6bf9('0x4b')](_0x49b03e[_0x6bf9('0x47')],_0x685e1b[_0x6bf9('0x44')]));_0x4e2cc8[_0x6bf9('0x4a')][_0x6bf9('0x63')]=_0x159e82['id'];if(_0x49b03e['query'][_0x6bf9('0x64')]){_0x4e2cc8[_0x6bf9('0x4a')]=_[_0x6bf9('0x4c')](_0x4e2cc8[_0x6bf9('0x4a')],{'$or':_[_0x6bf9('0x3d')](_0x4e2cc8[_0x6bf9('0x45')],function(_0x149665){var _0x1a10bb={};_0x1a10bb[_0x149665]={'$like':'%'+_0x49b03e[_0x6bf9('0x47')]['filter']+'%'};return _0x1a10bb;})});}_0x4e2cc8=_['merge']({},_0x4e2cc8,_0x49b03e['options']);return db[_0x6bf9('0x65')][_0x6bf9('0x50')](_0x4e2cc8);}})[_0x6bf9('0x1e')](function(_0xf50a94){if(_0xf50a94){return db[_0x6bf9('0x66')][_0x6bf9('0x67')]({'where':{'id':_[_0x6bf9('0x3d')](_0xf50a94,_0x6bf9('0x68')),'role':_0x6bf9('0x69')},'attributes':['id',_0x6bf9('0x3a'),_0x6bf9('0x6a'),_0x6bf9('0x6b'),_0x6bf9('0x6c')]});}})[_0x6bf9('0x1e')](function(_0x27d70a){if(_0x27d70a){return{'count':_0x27d70a['count'],'rows':_[_0x6bf9('0x3d')](_0x27d70a[_0x6bf9('0x51')],function(_0x7fabee){return{'membername':_0x7fabee[_0x6bf9('0x3a')],'UserId':_0x7fabee['id'],'queue_name':_0x5d262b[_0x6bf9('0x3a')],'ChatQueueId':_0x5d262b['id'],'interface':util[_0x6bf9('0x6d')](_0x6bf9('0x6e'),_0x6bf9('0x6f'),_0x7fabee[_0x6bf9('0x3a')]),'penalty':0x0,'paused':_0x7fabee['chatPause'],'createdAt':_0x7fabee[_0x6bf9('0x6c')],'updatedAt':_0x7fabee[_0x6bf9('0x6b')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x5bb2cd,_0x4e2cc8))[_0x6bf9('0x29')](handleError(_0x5bb2cd,null));};exports[_0x6bf9('0x70')]=function(_0x49534d,_0x54617e,_0x283787){var _0x547afc={};var _0x3e70aa={};var _0x2b2e2e;var _0x3d6795;return db['ChatQueue'][_0x6bf9('0x71')]({'where':{'id':_0x49534d['params']['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x54617e,null))['then'](function(_0x41cda8){if(_0x41cda8){_0x2b2e2e=_0x41cda8;_0x3e70aa['model']=_['keys'](db['Team']['rawAttributes']);_0x3e70aa[_0x6bf9('0x47')]=_['keys'](_0x49534d['query']);_0x3e70aa['filters']=_[_0x6bf9('0x54')](_0x3e70aa[_0x6bf9('0x42')],_0x3e70aa[_0x6bf9('0x47')]);_0x547afc[_0x6bf9('0x45')]=_['intersection'](_0x3e70aa[_0x6bf9('0x42')],qs[_0x6bf9('0x46')](_0x49534d[_0x6bf9('0x47')]['fields']));_0x547afc[_0x6bf9('0x45')]=_0x547afc[_0x6bf9('0x45')][_0x6bf9('0x55')]?_0x547afc[_0x6bf9('0x45')]:_0x3e70aa[_0x6bf9('0x42')];_0x547afc[_0x6bf9('0x62')]=qs[_0x6bf9('0x49')](_0x49534d[_0x6bf9('0x47')][_0x6bf9('0x49')]);_0x547afc['where']=qs[_0x6bf9('0x44')](_[_0x6bf9('0x4b')](_0x49534d['query'],_0x3e70aa[_0x6bf9('0x44')]));if(_0x49534d['query']['filter']){_0x547afc[_0x6bf9('0x4a')]=_['merge'](_0x547afc[_0x6bf9('0x4a')],{'$or':_[_0x6bf9('0x3d')](_0x547afc[_0x6bf9('0x45')],function(_0x470ee4){var _0x53a7bc={};_0x53a7bc[_0x470ee4]={'$like':'%'+_0x49534d[_0x6bf9('0x47')][_0x6bf9('0x64')]+'%'};return _0x53a7bc;})});}_0x547afc=_[_0x6bf9('0x4c')]({},_0x547afc,_0x49534d[_0x6bf9('0x4d')]);return _0x2b2e2e[_0x6bf9('0x70')](_0x547afc);}})[_0x6bf9('0x1e')](function(_0x24e243){if(_0x24e243){_0x3d6795=_0x24e243[_0x6bf9('0x55')];if(!_0x49534d['query'][_0x6bf9('0x61')](_0x6bf9('0x48'))){_0x547afc['limit']=qs[_0x6bf9('0x2f')](_0x49534d['query']['limit']);_0x547afc[_0x6bf9('0x2e')]=qs[_0x6bf9('0x2e')](_0x49534d[_0x6bf9('0x47')][_0x6bf9('0x2e')]);}return _0x2b2e2e['getTeams'](_0x547afc);}})[_0x6bf9('0x1e')](function(_0x2597b0){if(_0x2597b0){return _0x2597b0?{'count':_0x3d6795,'rows':_0x2597b0}:null;}})['then'](respondWithResult(_0x54617e,null))[_0x6bf9('0x29')](handleError(_0x54617e,null));};exports['addTeams']=function(_0xc4b9ea,_0x947642,_0x5456fd){var _0x427891=_0xc4b9ea['body'][_0x6bf9('0x72')];return db[_0x6bf9('0x73')][_0x6bf9('0x50')]({'where':{'id':_0x427891},'attributes':['id'],'include':[{'model':db[_0x6bf9('0x66')],'as':_0x6bf9('0x74'),'attributes':['id',_0x6bf9('0x3a'),_0x6bf9('0x75'),'voicePause',_0x6bf9('0x76')],'raw':!![]}]})['then'](function(_0x191f19){if(_0x191f19){var _0x2f64af=_[_0x6bf9('0x77')](_0x191f19,function(_0x50c3d2){var _0x29483b=_0x50c3d2[_0x6bf9('0x36')]({'plain':!![]});return _0x29483b[_0x6bf9('0x74')];});return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0xc4b9ea['params']['id']}})[_0x6bf9('0x1e')](function(_0x391d95){return db['sequelize']['transaction'](function(_0x448ccd){return _0x391d95[_0x6bf9('0x78')](_0x427891,{'transaction':_0x448ccd})[_0x6bf9('0x1e')](function(){return BPromise[_0x6bf9('0x79')](_0x2f64af,function(_0x20dc45){return db[_0x6bf9('0x65')][_0x6bf9('0x7a')]({'where':{'UserId':_0x20dc45['id'],'ChatQueueId':_0xc4b9ea[_0x6bf9('0x53')]['id']},'transaction':_0x448ccd});});})[_0x6bf9('0x1e')](function(){_0x2f64af[_0x6bf9('0x7b')](function(_0x1f1d8e){socket[_0x6bf9('0x7c')](_0x6bf9('0x7d'),{'UserId':_0x1f1d8e['id'],'ChatQueueId':_0x391d95['id']});});});});});}})[_0x6bf9('0x1e')](respondWithStatusCode(_0x947642,null))[_0x6bf9('0x29')](handleError(_0x947642,null));};exports['removeTeams']=function(_0x3a5d66,_0x2f55c2,_0x31e53a){return db[_0x6bf9('0x73')][_0x6bf9('0x50')]({'where':{'id':_0x3a5d66['query'][_0x6bf9('0x72')]},'attributes':['id'],'include':[{'model':db[_0x6bf9('0x66')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x2f55c2,null))[_0x6bf9('0x1e')](function(_0x5afa18){var _0xf382ad=_[_0x6bf9('0x3d')](_0x5afa18,'id');var _0x2d518f=[];var _0x26256c=[];var _0x16970d=squel[_0x6bf9('0x7e')]();_0x16970d[_0x6bf9('0x7f')](_0x6bf9('0x80'))[_0x6bf9('0x81')](_0x6bf9('0x82'),'tq')[_0x6bf9('0x83')](_0x6bf9('0x84'),'ut',_0x6bf9('0x85'))[_0x6bf9('0x4a')](_0x6bf9('0x86'),_0x3a5d66[_0x6bf9('0x53')]['id']);for(var _0x506b4f=0x0;_0x506b4f<_0x5afa18[_0x6bf9('0x55')];_0x506b4f+=0x1){let _0x270038=_0x5afa18[_0x506b4f];for(var _0x21c17f=0x0;_0x21c17f<_0x270038[_0x6bf9('0x74')][_0x6bf9('0x55')];_0x21c17f+=0x1){let _0x4de11b=_0x270038[_0x6bf9('0x74')][_0x21c17f];var _0x5dc477=_0x16970d[_0x6bf9('0x87')]();_0x5dc477[_0x6bf9('0x4a')]('ut.UserId\x20=\x20?',_0x4de11b['id']);_0x26256c[_0x6bf9('0x88')](db[_0x6bf9('0x89')][_0x6bf9('0x47')](_0x5dc477[_0x6bf9('0x8a')](),{'type':db[_0x6bf9('0x89')][_0x6bf9('0x8b')][_0x6bf9('0x8c')]})[_0x6bf9('0x1e')](function(_0x4aa86d){if(_0x4aa86d[_0x6bf9('0x55')]===0x1){return _0x4de11b['id'];}else{var _0x542fd6=_[_0x6bf9('0x8d')](_[_0x6bf9('0x3d')](_0x4aa86d,_0x6bf9('0x8e')),function(_0x10d8b0){return _[_0x6bf9('0x8f')](_0xf382ad,_0x10d8b0);});if(_0x542fd6){return _0x4de11b['id'];}}}));}}return BPromise['all'](_0x26256c)['then'](function(_0x4a1245){_0x2d518f=_(_0x2d518f)[_0x6bf9('0x90')](_0x4a1245)['compact']()[_0x6bf9('0x91')]();return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0x3a5d66[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](function(_0x39f763){return db[_0x6bf9('0x89')]['transaction'](function(_0x116b39){return _0x39f763[_0x6bf9('0x92')](_0x3a5d66['query']['ids'],{'transaction':_0x116b39})['then'](function(){if(!_[_0x6bf9('0x93')](_0x2d518f)){return _0x39f763['removeAgents'](_0x2d518f,{'transaction':_0x116b39});}})[_0x6bf9('0x1e')](function(){_0x2d518f[_0x6bf9('0x7b')](function(_0x19725e){socket[_0x6bf9('0x7c')](_0x6bf9('0x94'),{'UserId':_0x19725e,'ChatQueueId':_0x39f763['id']});});});});});});})[_0x6bf9('0x1e')](respondWithStatusCode(_0x2f55c2,null))[_0x6bf9('0x29')](handleError(_0x2f55c2,null));};exports['addAgents']=function(_0x4e1149,_0x591ad9,_0xdba0bf){return db[_0x6bf9('0x4e')][_0x6bf9('0x57')]({'where':{'id':_0x4e1149[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x591ad9,null))[_0x6bf9('0x1e')](function(_0x527717){if(_0x527717){return _0x527717['addAgents'](_0x4e1149[_0x6bf9('0x5f')][_0x6bf9('0x72')],_[_0x6bf9('0x95')](_0x4e1149[_0x6bf9('0x5f')],['ids','id'])||{})[_0x6bf9('0x96')](function(_0x288ab4){for(var _0x2ef22e=0x0;_0x2ef22e<_0x4e1149[_0x6bf9('0x5f')][_0x6bf9('0x72')]['length'];_0x2ef22e+=0x1){socket['emit'](_0x6bf9('0x7d'),{'UserId':_0x4e1149[_0x6bf9('0x5f')][_0x6bf9('0x72')][_0x2ef22e],'ChatQueueId':_0x4e1149[_0x6bf9('0x53')]['id']});}return _0x288ab4;});}})['then'](respondWithResult(_0x591ad9,null))[_0x6bf9('0x29')](handleError(_0x591ad9,null));};exports['removeAgents']=function(_0x5a8a8f,_0x57d09c,_0x5d8eab){return db['ChatQueue']['find']({'where':{'id':_0x5a8a8f[_0x6bf9('0x53')]['id']}})[_0x6bf9('0x1e')](handleEntityNotFound(_0x57d09c,null))[_0x6bf9('0x1e')](function(_0x29b547){if(_0x29b547){return _0x29b547[_0x6bf9('0x97')](_0x5a8a8f[_0x6bf9('0x47')][_0x6bf9('0x72')])[_0x6bf9('0x1e')](function(){if(_[_0x6bf9('0x98')](_0x5a8a8f[_0x6bf9('0x47')][_0x6bf9('0x72')])){for(var _0x461343=0x0;_0x461343<_0x5a8a8f[_0x6bf9('0x47')]['ids'][_0x6bf9('0x55')];_0x461343+=0x1){socket[_0x6bf9('0x7c')](_0x6bf9('0x94'),{'UserId':Number(_0x5a8a8f[_0x6bf9('0x47')][_0x6bf9('0x72')][_0x461343]),'ChatQueueId':Number(_0x5a8a8f[_0x6bf9('0x53')]['id'])});}}else{socket['emit']('userChatQueue:remove',{'UserId':Number(_0x5a8a8f['query'][_0x6bf9('0x72')]),'ChatQueueId':Number(_0x5a8a8f[_0x6bf9('0x53')]['id'])});}});}})[_0x6bf9('0x1e')](respondWithStatusCode(_0x57d09c,null))['catch'](handleError(_0x57d09c,null));};exports['getAgents']=function(_0xea80f0,_0x419a30,_0x7eb74d){var _0x1f29d6={};var _0x103321={};var _0xaa287e;var _0x3993be;return db[_0x6bf9('0x4e')][_0x6bf9('0x71')]({'where':{'id':_0xea80f0[_0x6bf9('0x53')]['id']}})['then'](handleEntityNotFound(_0x419a30,null))[_0x6bf9('0x1e')](function(_0xa83045){if(_0xa83045){_0xaa287e=_0xa83045;_0x103321[_0x6bf9('0x42')]=_[_0x6bf9('0x43')](db[_0x6bf9('0x66')][_0x6bf9('0x3e')]);_0x103321[_0x6bf9('0x47')]=_[_0x6bf9('0x43')](_0xea80f0['query']);_0x103321['filters']=_['intersection'](_0x103321['model'],_0x103321[_0x6bf9('0x47')]);_0x1f29d6[_0x6bf9('0x45')]=_[_0x6bf9('0x54')](_0x103321[_0x6bf9('0x42')],qs[_0x6bf9('0x46')](_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x46')]));_0x1f29d6['attributes']=_0x1f29d6[_0x6bf9('0x45')][_0x6bf9('0x55')]?_0x1f29d6[_0x6bf9('0x45')]:_0x103321[_0x6bf9('0x42')];_0x1f29d6[_0x6bf9('0x62')]=qs[_0x6bf9('0x49')](_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x49')]);_0x1f29d6[_0x6bf9('0x4a')]=qs[_0x6bf9('0x44')](_[_0x6bf9('0x4b')](_0xea80f0[_0x6bf9('0x47')],_0x103321['filters']));if(_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x64')]){_0x1f29d6['where']=_[_0x6bf9('0x4c')](_0x1f29d6['where'],{'$or':_[_0x6bf9('0x3d')](_0x1f29d6[_0x6bf9('0x45')],function(_0x26e7bb){var _0x190d5d={};_0x190d5d[_0x26e7bb]={'$like':'%'+_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x64')]+'%'};return _0x190d5d;})});}_0x1f29d6=_[_0x6bf9('0x4c')]({},_0x1f29d6,_0xea80f0[_0x6bf9('0x4d')]);return _0xaa287e[_0x6bf9('0x99')](_0x1f29d6);}})['then'](function(_0x24ab04){if(_0x24ab04){_0x3993be=_0x24ab04['length'];if(!_0xea80f0[_0x6bf9('0x47')]['hasOwnProperty'](_0x6bf9('0x48'))){_0x1f29d6[_0x6bf9('0x2f')]=qs[_0x6bf9('0x2f')](_0xea80f0[_0x6bf9('0x47')][_0x6bf9('0x2f')]);_0x1f29d6[_0x6bf9('0x2e')]=qs[_0x6bf9('0x2e')](_0xea80f0['query'][_0x6bf9('0x2e')]);}return _0xaa287e['getAgents'](_0x1f29d6);}})[_0x6bf9('0x1e')](function(_0x586f48){if(_0x586f48){return _0x586f48?{'count':_0x3993be,'rows':_0x586f48}:null;}})[_0x6bf9('0x1e')](respondWithResult(_0x419a30,null))[_0x6bf9('0x29')](handleError(_0x419a30,null));};
\ No newline at end of file
+var _0x8378=['sequelize','transaction','each','findOrCreate','forEach','emit','userChatQueue:save','ids','select','field','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','all','union','compact','value','isEmpty','removeAgents','userChatQueue:remove','addAgents','omit','spread','getAgents','order','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./chatQueue.socket','register','jayson/promise','client','http','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','sendStatus','status','end','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','get','ChatQueues','UserProfileResource','name','send','fieldName','key','map','keys','query','filters','intersection','model','attributes','fields','length','nolimit','sort','where','pick','filter','type','VIRTUAL','merge','options','ChatQueue','includeAll','include','findAll','show','params','rawAttributes','find','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','getMembers','findOne','UserChatQueue','hasOwnProperty','ChatQueueId','User','findAndCountAll','UserId','agent','chatPause','updatedAt','createdAt','rows','format','%s/%s','getTeams','Team','addTeams','online','voicePause','interface','Agents'];(function(_0xac9c3a,_0x4d6c11){var _0x9bbfa7=function(_0x472649){while(--_0x472649){_0xac9c3a['push'](_0xac9c3a['shift']());}};_0x9bbfa7(++_0x4d6c11);}(_0x8378,0x1f3));var _0x8837=function(_0x4f4e27,_0x38c66e){_0x4f4e27=_0x4f4e27-0x0;var _0x2fe66b=_0x8378[_0x4f4e27];return _0x2fe66b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x8837('0x0'));var zipdir=require(_0x8837('0x1'));var jsonpatch=require(_0x8837('0x2'));var rp=require(_0x8837('0x3'));var moment=require('moment');var BPromise=require(_0x8837('0x4'));var Mustache=require(_0x8837('0x5'));var util=require(_0x8837('0x6'));var path=require(_0x8837('0x7'));var sox=require('sox');var csv=require(_0x8837('0x8'));var ejs=require(_0x8837('0x9'));var fs=require('fs');var fs_extra=require(_0x8837('0xa'));var _=require(_0x8837('0xb'));var squel=require(_0x8837('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x8837('0xd'));var toCsv=require(_0x8837('0x8'));var querystring=require(_0x8837('0xe'));var Papa=require(_0x8837('0xf'));var Redis=require(_0x8837('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x8837('0x11'));var as=require(_0x8837('0x12'));var hardwareService=require(_0x8837('0x13'));var logger=require(_0x8837('0x14'))(_0x8837('0x15'));var utils=require(_0x8837('0x16'));var config=require(_0x8837('0x17'));var licenseUtil=require(_0x8837('0x18'));var db=require(_0x8837('0x19'))['db'];config[_0x8837('0x1a')]=_[_0x8837('0x1b')](config[_0x8837('0x1a')],{'host':'localhost','port':0x18eb});var socket=require(_0x8837('0x1c'))(new Redis(config[_0x8837('0x1a')]));require(_0x8837('0x1d'))[_0x8837('0x1e')](socket);var jayson=require(_0x8837('0x1f'));var client=jayson[_0x8837('0x20')][_0x8837('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x1330b9,_0x3823d4,_0x13b86a,_0x2c46a7){return new BPromise(function(_0x3456e3,_0x10ea5c){var _0x60407=_0x2c46a7||client;return _0x60407['request'](_0x1330b9,_0x13b86a)[_0x8837('0x22')](function(_0x9357b7){logger[_0x8837('0x23')](_0x8837('0x24'),_0x3823d4,_0x8837('0x25'));logger[_0x8837('0x26')]('ChatQueue,\x20%s,\x20%s,\x20%s',_0x3823d4,_0x8837('0x25'),JSON[_0x8837('0x27')](_0x9357b7));if(_0x9357b7[_0x8837('0x28')]){if(_0x9357b7['error'][_0x8837('0x29')]===0x1f4){logger[_0x8837('0x28')](_0x8837('0x24'),_0x3823d4,_0x9357b7[_0x8837('0x28')][_0x8837('0x2a')]);return _0x10ea5c(_0x9357b7[_0x8837('0x28')]['message']);}logger[_0x8837('0x28')](_0x8837('0x24'),_0x3823d4,_0x9357b7[_0x8837('0x28')]['message']);return _0x3456e3(_0x9357b7[_0x8837('0x28')][_0x8837('0x2a')]);}else{logger[_0x8837('0x23')](_0x8837('0x24'),_0x3823d4,'request\x20sent');_0x3456e3(_0x9357b7[_0x8837('0x2b')][_0x8837('0x2a')]);}})[_0x8837('0x2c')](function(_0x3a38f3){logger[_0x8837('0x28')](_0x8837('0x24'),_0x3823d4,_0x3a38f3);_0x10ea5c(_0x3a38f3);});});}function respondWithStatusCode(_0x4ee735,_0x272228){_0x272228=_0x272228||0xcc;return function(_0x54d417){if(_0x54d417){return _0x4ee735[_0x8837('0x2d')](_0x272228);}return _0x4ee735[_0x8837('0x2e')](_0x272228)[_0x8837('0x2f')]();};}function respondWithResult(_0x4c76f1,_0x4be58e){_0x4be58e=_0x4be58e||0xc8;return function(_0xe9ec81){if(_0xe9ec81){return _0x4c76f1[_0x8837('0x2e')](_0x4be58e)['json'](_0xe9ec81);}};}function respondWithFilteredResult(_0x5ec122,_0x561731){return function(_0x397872){if(_0x397872){var _0x2fdf24=_0x397872[_0x8837('0x30')],_0xcaf324=_0x561731['offset'],_0x1dfc44=_0x561731[_0x8837('0x31')]+_0x561731[_0x8837('0x32')],_0x141072;if(_0x1dfc44>=_0x2fdf24){_0x1dfc44=_0x2fdf24;_0x141072=0xc8;}else{_0x141072=0xce;}_0x5ec122[_0x8837('0x2e')](_0x141072);return _0x5ec122[_0x8837('0x33')](_0x8837('0x34'),_0xcaf324+'-'+_0x1dfc44+'/'+_0x2fdf24)['json'](_0x397872);}return null;};}function patchUpdates(_0x37359e){return function(_0x353598){try{jsonpatch[_0x8837('0x35')](_0x353598,_0x37359e,!![]);}catch(_0x25d8b0){return BPromise[_0x8837('0x36')](_0x25d8b0);}return _0x353598[_0x8837('0x37')]();};}function saveUpdates(_0x41a4b7,_0x23f2b2){return function(_0x31281f){if(_0x31281f){return _0x31281f[_0x8837('0x38')](_0x41a4b7)[_0x8837('0x22')](function(_0x2b72a4){return _0x2b72a4;});}return null;};}function removeEntity(_0x4ffde7,_0x49c0bc){return function(_0x2cd9e1){if(_0x2cd9e1){return _0x2cd9e1[_0x8837('0x39')]()[_0x8837('0x22')](function(){var _0x2f95fb=_0x2cd9e1[_0x8837('0x3a')]({'plain':!![]});var _0x27de29=_0x8837('0x3b');return db[_0x8837('0x3c')][_0x8837('0x39')]({'where':{'type':_0x27de29,'resourceId':_0x2f95fb['id']}})[_0x8837('0x22')](function(){return _0x2cd9e1;});})['then'](function(){_0x4ffde7[_0x8837('0x2e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x59cd2d,_0x167459){return function(_0x577d32){if(!_0x577d32){_0x59cd2d[_0x8837('0x2d')](0x194);}return _0x577d32;};}function handleError(_0x462298,_0x52aac9){_0x52aac9=_0x52aac9||0x1f4;return function(_0x2e983b){logger['error'](_0x2e983b['stack']);if(_0x2e983b[_0x8837('0x3d')]){delete _0x2e983b[_0x8837('0x3d')];}_0x462298['status'](_0x52aac9)[_0x8837('0x3e')](_0x2e983b);};}exports['index']=function(_0x36d5b8,_0x5389f1){var _0x132aa8={},_0x28dc6d={},_0x485737={'count':0x0,'rows':[]};var _0x3b8b67=_['map'](db['ChatQueue']['rawAttributes'],function(_0x3736a4){return{'name':_0x3736a4[_0x8837('0x3f')],'type':_0x3736a4['type'][_0x8837('0x40')]};});_0x28dc6d['model']=_[_0x8837('0x41')](_0x3b8b67,_0x8837('0x3d'));_0x28dc6d['query']=_[_0x8837('0x42')](_0x36d5b8[_0x8837('0x43')]);_0x28dc6d[_0x8837('0x44')]=_[_0x8837('0x45')](_0x28dc6d[_0x8837('0x46')],_0x28dc6d[_0x8837('0x43')]);_0x132aa8[_0x8837('0x47')]=_[_0x8837('0x45')](_0x28dc6d[_0x8837('0x46')],qs[_0x8837('0x48')](_0x36d5b8[_0x8837('0x43')][_0x8837('0x48')]));_0x132aa8[_0x8837('0x47')]=_0x132aa8['attributes'][_0x8837('0x49')]?_0x132aa8[_0x8837('0x47')]:_0x28dc6d[_0x8837('0x46')];if(!_0x36d5b8[_0x8837('0x43')]['hasOwnProperty'](_0x8837('0x4a'))){_0x132aa8[_0x8837('0x32')]=qs[_0x8837('0x32')](_0x36d5b8['query']['limit']);_0x132aa8[_0x8837('0x31')]=qs['offset'](_0x36d5b8[_0x8837('0x43')][_0x8837('0x31')]);}_0x132aa8['order']=qs[_0x8837('0x4b')](_0x36d5b8[_0x8837('0x43')][_0x8837('0x4b')]);_0x132aa8[_0x8837('0x4c')]=qs[_0x8837('0x44')](_[_0x8837('0x4d')](_0x36d5b8[_0x8837('0x43')],_0x28dc6d[_0x8837('0x44')]),_0x3b8b67);if(_0x36d5b8[_0x8837('0x43')][_0x8837('0x4e')]){_0x132aa8[_0x8837('0x4c')]=_['merge'](_0x132aa8[_0x8837('0x4c')],{'$or':_[_0x8837('0x41')](_0x3b8b67,function(_0x1e0f3){if(_0x1e0f3[_0x8837('0x4f')]!==_0x8837('0x50')){var _0x302c23={};_0x302c23[_0x1e0f3[_0x8837('0x3d')]]={'$like':'%'+_0x36d5b8[_0x8837('0x43')][_0x8837('0x4e')]+'%'};return _0x302c23;}})});}_0x132aa8=_[_0x8837('0x51')]({},_0x132aa8,_0x36d5b8[_0x8837('0x52')]);var _0x32c56b={'where':_0x132aa8[_0x8837('0x4c')]};return db[_0x8837('0x53')][_0x8837('0x30')](_0x32c56b)[_0x8837('0x22')](function(_0x43eba5){_0x485737['count']=_0x43eba5;if(_0x36d5b8['query'][_0x8837('0x54')]){_0x132aa8[_0x8837('0x55')]=[{'all':!![]}];}return db['ChatQueue'][_0x8837('0x56')](_0x132aa8);})[_0x8837('0x22')](function(_0x3076ff){_0x485737['rows']=_0x3076ff;return _0x485737;})['then'](respondWithFilteredResult(_0x5389f1,_0x132aa8))[_0x8837('0x2c')](handleError(_0x5389f1,null));};exports[_0x8837('0x57')]=function(_0x1296f9,_0x5f3394){var _0x544ad4={'raw':!![],'where':{'id':_0x1296f9[_0x8837('0x58')]['id']}},_0x245e86={};_0x245e86[_0x8837('0x46')]=_[_0x8837('0x42')](db[_0x8837('0x53')][_0x8837('0x59')]);_0x245e86[_0x8837('0x43')]=_[_0x8837('0x42')](_0x1296f9['query']);_0x245e86[_0x8837('0x44')]=_['intersection'](_0x245e86[_0x8837('0x46')],_0x245e86['query']);_0x544ad4['attributes']=_[_0x8837('0x45')](_0x245e86[_0x8837('0x46')],qs[_0x8837('0x48')](_0x1296f9['query'][_0x8837('0x48')]));_0x544ad4[_0x8837('0x47')]=_0x544ad4[_0x8837('0x47')]['length']?_0x544ad4[_0x8837('0x47')]:_0x245e86[_0x8837('0x46')];if(_0x1296f9[_0x8837('0x43')]['includeAll']){_0x544ad4[_0x8837('0x55')]=[{'all':!![]}];}_0x544ad4=_[_0x8837('0x51')]({},_0x544ad4,_0x1296f9[_0x8837('0x52')]);return db['ChatQueue'][_0x8837('0x5a')](_0x544ad4)['then'](handleEntityNotFound(_0x5f3394,null))[_0x8837('0x22')](respondWithResult(_0x5f3394,null))['catch'](handleError(_0x5f3394,null));};exports['create']=function(_0x1dec77,_0x3f620c){return db['ChatQueue']['create'](_0x1dec77['body'],{})[_0x8837('0x22')](function(_0x1a3f4c){var _0x4ac2dc=_0x1dec77[_0x8837('0x5b')][_0x8837('0x3a')]({'plain':!![]});if(!_0x4ac2dc)throw new Error(_0x8837('0x5c'));if(_0x4ac2dc['role']===_0x8837('0x5b')){var _0x2604a2=_0x1a3f4c[_0x8837('0x3a')]({'plain':!![]});var _0x25b656=_0x8837('0x3b');return db[_0x8837('0x5d')]['find']({'where':{'name':_0x25b656,'userProfileId':_0x4ac2dc[_0x8837('0x5e')]},'raw':!![]})[_0x8837('0x22')](function(_0x202c00){if(_0x202c00&&_0x202c00[_0x8837('0x5f')]===0x0){return db[_0x8837('0x3c')]['create']({'name':_0x2604a2[_0x8837('0x3d')],'resourceId':_0x2604a2['id'],'type':_0x202c00[_0x8837('0x3d')],'sectionId':_0x202c00['id']},{})[_0x8837('0x22')](function(){return _0x1a3f4c;});}else{return _0x1a3f4c;}})[_0x8837('0x2c')](function(_0x57bb0f){logger['error'](_0x8837('0x60'),_0x57bb0f);throw _0x57bb0f;});}return _0x1a3f4c;})[_0x8837('0x22')](respondWithResult(_0x3f620c,0xc9))[_0x8837('0x2c')](handleError(_0x3f620c,null));};exports['update']=function(_0xa8e39d,_0x268bea){if(_0xa8e39d['body']['id']){delete _0xa8e39d[_0x8837('0x61')]['id'];}return db['ChatQueue'][_0x8837('0x5a')]({'where':{'id':_0xa8e39d['params']['id']}})['then'](handleEntityNotFound(_0x268bea,null))[_0x8837('0x22')](saveUpdates(_0xa8e39d['body'],null))[_0x8837('0x22')](respondWithResult(_0x268bea,null))['catch'](handleError(_0x268bea,null));};exports[_0x8837('0x39')]=function(_0x283b28,_0x5c1d59){return db[_0x8837('0x53')][_0x8837('0x5a')]({'where':{'id':_0x283b28[_0x8837('0x58')]['id']}})[_0x8837('0x22')](handleEntityNotFound(_0x5c1d59,null))['then'](removeEntity(_0x5c1d59,null))['catch'](handleError(_0x5c1d59,null));};exports[_0x8837('0x62')]=function(_0x57a1e9,_0x245254){return db['ChatQueue'][_0x8837('0x62')]()[_0x8837('0x22')](respondWithResult(_0x245254,null))[_0x8837('0x2c')](handleError(_0x245254,null));};exports[_0x8837('0x63')]=function(_0x1aab1e,_0x3fdb4d,_0x164ddd){var _0x3b7881={'raw':!![],'where':{}},_0x2b7c7d={},_0x271dd0;return db[_0x8837('0x53')][_0x8837('0x64')]({'where':{'id':_0x1aab1e[_0x8837('0x58')]['id']}})[_0x8837('0x22')](handleEntityNotFound(_0x3fdb4d,null))[_0x8837('0x22')](function(_0x12b848){if(_0x12b848){_0x271dd0=_0x12b848[_0x8837('0x3a')]({'plain':!![]});_0x2b7c7d[_0x8837('0x46')]=_['keys'](db[_0x8837('0x65')]['rawAttributes']);_0x2b7c7d[_0x8837('0x43')]=_[_0x8837('0x42')](_0x1aab1e['query']);_0x2b7c7d['filters']=_['intersection'](_0x2b7c7d[_0x8837('0x46')],_0x2b7c7d[_0x8837('0x43')]);_0x3b7881[_0x8837('0x47')]=_[_0x8837('0x45')](_0x2b7c7d[_0x8837('0x46')],qs[_0x8837('0x48')](_0x1aab1e[_0x8837('0x43')]['fields']));_0x3b7881[_0x8837('0x47')]=_0x3b7881['attributes'][_0x8837('0x49')]?_0x3b7881[_0x8837('0x47')]:_0x2b7c7d['model'];if(!_0x1aab1e[_0x8837('0x43')][_0x8837('0x66')]('nolimit')){_0x3b7881['limit']=qs[_0x8837('0x32')](_0x1aab1e['query']['limit']);_0x3b7881['offset']=qs['offset'](_0x1aab1e[_0x8837('0x43')][_0x8837('0x31')]);}_0x3b7881['order']=qs[_0x8837('0x4b')](_0x1aab1e['query'][_0x8837('0x4b')]);_0x3b7881['where']=qs['filters'](_[_0x8837('0x4d')](_0x1aab1e[_0x8837('0x43')],_0x2b7c7d['filters']));_0x3b7881[_0x8837('0x4c')][_0x8837('0x67')]=_0x12b848['id'];if(_0x1aab1e['query']['filter']){_0x3b7881[_0x8837('0x4c')]=_[_0x8837('0x51')](_0x3b7881[_0x8837('0x4c')],{'$or':_[_0x8837('0x41')](_0x3b7881[_0x8837('0x47')],function(_0x1f5668){var _0x820104={};_0x820104[_0x1f5668]={'$like':'%'+_0x1aab1e[_0x8837('0x43')][_0x8837('0x4e')]+'%'};return _0x820104;})});}_0x3b7881=_[_0x8837('0x51')]({},_0x3b7881,_0x1aab1e['options']);return db['UserChatQueue'][_0x8837('0x56')](_0x3b7881);}})['then'](function(_0x527700){if(_0x527700){return db[_0x8837('0x68')][_0x8837('0x69')]({'where':{'id':_['map'](_0x527700,_0x8837('0x6a')),'role':_0x8837('0x6b')},'attributes':['id',_0x8837('0x3d'),_0x8837('0x6c'),_0x8837('0x6d'),_0x8837('0x6e')]});}})[_0x8837('0x22')](function(_0x28fc87){if(_0x28fc87){return{'count':_0x28fc87[_0x8837('0x30')],'rows':_[_0x8837('0x41')](_0x28fc87[_0x8837('0x6f')],function(_0x13778b){return{'membername':_0x13778b[_0x8837('0x3d')],'UserId':_0x13778b['id'],'queue_name':_0x271dd0['name'],'ChatQueueId':_0x271dd0['id'],'interface':util[_0x8837('0x70')](_0x8837('0x71'),'SIP',_0x13778b[_0x8837('0x3d')]),'penalty':0x0,'paused':_0x13778b[_0x8837('0x6c')],'createdAt':_0x13778b[_0x8837('0x6e')],'updatedAt':_0x13778b[_0x8837('0x6d')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x3fdb4d,_0x3b7881))[_0x8837('0x2c')](handleError(_0x3fdb4d,null));};exports[_0x8837('0x72')]=function(_0x1e7978,_0x404fe1,_0x536462){var _0xcd7c27={};var _0x1d367b={};var _0x279fbb;var _0x274c71;return db[_0x8837('0x53')][_0x8837('0x64')]({'where':{'id':_0x1e7978[_0x8837('0x58')]['id']}})['then'](handleEntityNotFound(_0x404fe1,null))[_0x8837('0x22')](function(_0x344965){if(_0x344965){_0x279fbb=_0x344965;_0x1d367b[_0x8837('0x46')]=_[_0x8837('0x42')](db[_0x8837('0x73')][_0x8837('0x59')]);_0x1d367b[_0x8837('0x43')]=_[_0x8837('0x42')](_0x1e7978['query']);_0x1d367b[_0x8837('0x44')]=_[_0x8837('0x45')](_0x1d367b[_0x8837('0x46')],_0x1d367b['query']);_0xcd7c27['attributes']=_['intersection'](_0x1d367b[_0x8837('0x46')],qs[_0x8837('0x48')](_0x1e7978[_0x8837('0x43')][_0x8837('0x48')]));_0xcd7c27[_0x8837('0x47')]=_0xcd7c27[_0x8837('0x47')][_0x8837('0x49')]?_0xcd7c27[_0x8837('0x47')]:_0x1d367b[_0x8837('0x46')];_0xcd7c27['order']=qs[_0x8837('0x4b')](_0x1e7978[_0x8837('0x43')][_0x8837('0x4b')]);_0xcd7c27[_0x8837('0x4c')]=qs[_0x8837('0x44')](_['pick'](_0x1e7978[_0x8837('0x43')],_0x1d367b[_0x8837('0x44')]));if(_0x1e7978['query'][_0x8837('0x4e')]){_0xcd7c27['where']=_[_0x8837('0x51')](_0xcd7c27[_0x8837('0x4c')],{'$or':_[_0x8837('0x41')](_0xcd7c27[_0x8837('0x47')],function(_0x177f41){var _0x34fd6d={};_0x34fd6d[_0x177f41]={'$like':'%'+_0x1e7978['query'][_0x8837('0x4e')]+'%'};return _0x34fd6d;})});}_0xcd7c27=_[_0x8837('0x51')]({},_0xcd7c27,_0x1e7978[_0x8837('0x52')]);return _0x279fbb[_0x8837('0x72')](_0xcd7c27);}})[_0x8837('0x22')](function(_0x534e76){if(_0x534e76){_0x274c71=_0x534e76[_0x8837('0x49')];if(!_0x1e7978[_0x8837('0x43')][_0x8837('0x66')](_0x8837('0x4a'))){_0xcd7c27[_0x8837('0x32')]=qs[_0x8837('0x32')](_0x1e7978['query'][_0x8837('0x32')]);_0xcd7c27['offset']=qs[_0x8837('0x31')](_0x1e7978[_0x8837('0x43')][_0x8837('0x31')]);}return _0x279fbb[_0x8837('0x72')](_0xcd7c27);}})[_0x8837('0x22')](function(_0x1d4f78){if(_0x1d4f78){return _0x1d4f78?{'count':_0x274c71,'rows':_0x1d4f78}:null;}})[_0x8837('0x22')](respondWithResult(_0x404fe1,null))[_0x8837('0x2c')](handleError(_0x404fe1,null));};exports[_0x8837('0x74')]=function(_0x5f5468,_0xe5517e,_0x5789fe){var _0x4199a5=_0x5f5468[_0x8837('0x61')]['ids'];return db[_0x8837('0x73')][_0x8837('0x56')]({'where':{'id':_0x4199a5},'attributes':['id'],'include':[{'model':db[_0x8837('0x68')],'as':'Agents','attributes':['id','name',_0x8837('0x75'),_0x8837('0x76'),_0x8837('0x77')],'raw':!![]}]})[_0x8837('0x22')](function(_0x3a53b9){if(_0x3a53b9){var _0x935807=_['flatMap'](_0x3a53b9,function(_0x53e2d0){var _0x2fcec4=_0x53e2d0[_0x8837('0x3a')]({'plain':!![]});return _0x2fcec4[_0x8837('0x78')];});return db['ChatQueue'][_0x8837('0x5a')]({'where':{'id':_0x5f5468[_0x8837('0x58')]['id']}})[_0x8837('0x22')](function(_0x54287c){return db[_0x8837('0x79')][_0x8837('0x7a')](function(_0x5799d4){return _0x54287c[_0x8837('0x74')](_0x4199a5,{'transaction':_0x5799d4})['then'](function(){return BPromise[_0x8837('0x7b')](_0x935807,function(_0x105367){return db[_0x8837('0x65')][_0x8837('0x7c')]({'where':{'UserId':_0x105367['id'],'ChatQueueId':_0x5f5468[_0x8837('0x58')]['id']},'transaction':_0x5799d4});});})[_0x8837('0x22')](function(){_0x935807[_0x8837('0x7d')](function(_0x4e7b87){socket[_0x8837('0x7e')](_0x8837('0x7f'),{'UserId':_0x4e7b87['id'],'ChatQueueId':_0x54287c['id']});});});});});}})[_0x8837('0x22')](respondWithStatusCode(_0xe5517e,null))[_0x8837('0x2c')](handleError(_0xe5517e,null));};exports['removeTeams']=function(_0x44c7eb,_0x2bd51e,_0x3d5f09){return db[_0x8837('0x73')]['findAll']({'where':{'id':_0x44c7eb['query'][_0x8837('0x80')]},'attributes':['id'],'include':[{'model':db[_0x8837('0x68')],'as':_0x8837('0x78'),'attributes':['id'],'raw':!![]}]})[_0x8837('0x22')](handleEntityNotFound(_0x2bd51e,null))[_0x8837('0x22')](function(_0x22c833){var _0x943e78=_['map'](_0x22c833,'id');var _0x2cee4b=[];var _0x16a56f=[];var _0x5678c3=squel[_0x8837('0x81')]();_0x5678c3[_0x8837('0x82')]('tq.TeamId')[_0x8837('0x83')](_0x8837('0x84'),'tq')[_0x8837('0x85')](_0x8837('0x86'),'ut',_0x8837('0x87'))[_0x8837('0x4c')](_0x8837('0x88'),_0x44c7eb['params']['id']);for(var _0x5d1e56=0x0;_0x5d1e56<_0x22c833[_0x8837('0x49')];_0x5d1e56+=0x1){let _0x1d6743=_0x22c833[_0x5d1e56];for(var _0x453181=0x0;_0x453181<_0x1d6743[_0x8837('0x78')][_0x8837('0x49')];_0x453181+=0x1){let _0x306c37=_0x1d6743[_0x8837('0x78')][_0x453181];var _0x5922e7=_0x5678c3['clone']();_0x5922e7[_0x8837('0x4c')](_0x8837('0x89'),_0x306c37['id']);_0x16a56f['push'](db[_0x8837('0x79')][_0x8837('0x43')](_0x5922e7[_0x8837('0x8a')](),{'type':db[_0x8837('0x79')][_0x8837('0x8b')][_0x8837('0x8c')]})[_0x8837('0x22')](function(_0x1d1f83){if(_0x1d1f83['length']===0x1){return _0x306c37['id'];}else{var _0x583669=_[_0x8837('0x8d')](_['map'](_0x1d1f83,_0x8837('0x8e')),function(_0x39a561){return _['includes'](_0x943e78,_0x39a561);});if(_0x583669){return _0x306c37['id'];}}}));}}return BPromise[_0x8837('0x8f')](_0x16a56f)['then'](function(_0x3931f7){_0x2cee4b=_(_0x2cee4b)[_0x8837('0x90')](_0x3931f7)[_0x8837('0x91')]()[_0x8837('0x92')]();return db[_0x8837('0x53')]['find']({'where':{'id':_0x44c7eb[_0x8837('0x58')]['id']}})[_0x8837('0x22')](function(_0x417c38){return db[_0x8837('0x79')][_0x8837('0x7a')](function(_0x35eccc){return _0x417c38['removeTeams'](_0x44c7eb[_0x8837('0x43')][_0x8837('0x80')],{'transaction':_0x35eccc})['then'](function(){if(!_[_0x8837('0x93')](_0x2cee4b)){return _0x417c38[_0x8837('0x94')](_0x2cee4b,{'transaction':_0x35eccc});}})[_0x8837('0x22')](function(){_0x2cee4b[_0x8837('0x7d')](function(_0x9d0619){socket['emit'](_0x8837('0x95'),{'UserId':_0x9d0619,'ChatQueueId':_0x417c38['id']});});});});});});})['then'](respondWithStatusCode(_0x2bd51e,null))[_0x8837('0x2c')](handleError(_0x2bd51e,null));};exports[_0x8837('0x96')]=function(_0x1f32fe,_0x9369ac,_0x2deee5){return db[_0x8837('0x53')]['find']({'where':{'id':_0x1f32fe['params']['id']}})[_0x8837('0x22')](handleEntityNotFound(_0x9369ac,null))[_0x8837('0x22')](function(_0x3383cf){if(_0x3383cf){return _0x3383cf[_0x8837('0x96')](_0x1f32fe['body'][_0x8837('0x80')],_[_0x8837('0x97')](_0x1f32fe[_0x8837('0x61')],['ids','id'])||{})[_0x8837('0x98')](function(_0xeba9c1){for(var _0x510e9a=0x0;_0x510e9a<_0x1f32fe[_0x8837('0x61')][_0x8837('0x80')][_0x8837('0x49')];_0x510e9a+=0x1){socket[_0x8837('0x7e')](_0x8837('0x7f'),{'UserId':_0x1f32fe[_0x8837('0x61')][_0x8837('0x80')][_0x510e9a],'ChatQueueId':_0x1f32fe[_0x8837('0x58')]['id']});}return _0xeba9c1;});}})[_0x8837('0x22')](respondWithResult(_0x9369ac,null))[_0x8837('0x2c')](handleError(_0x9369ac,null));};exports[_0x8837('0x94')]=function(_0x53fec6,_0x1c2ef8,_0xc937ef){return db[_0x8837('0x53')][_0x8837('0x5a')]({'where':{'id':_0x53fec6[_0x8837('0x58')]['id']}})[_0x8837('0x22')](handleEntityNotFound(_0x1c2ef8,null))[_0x8837('0x22')](function(_0x3dfb10){if(_0x3dfb10){return _0x3dfb10[_0x8837('0x94')](_0x53fec6[_0x8837('0x43')][_0x8837('0x80')])[_0x8837('0x22')](function(){if(_['isArray'](_0x53fec6[_0x8837('0x43')][_0x8837('0x80')])){for(var _0x429c0a=0x0;_0x429c0a<_0x53fec6['query'][_0x8837('0x80')][_0x8837('0x49')];_0x429c0a+=0x1){socket[_0x8837('0x7e')](_0x8837('0x95'),{'UserId':Number(_0x53fec6[_0x8837('0x43')][_0x8837('0x80')][_0x429c0a]),'ChatQueueId':Number(_0x53fec6[_0x8837('0x58')]['id'])});}}else{socket[_0x8837('0x7e')]('userChatQueue:remove',{'UserId':Number(_0x53fec6['query']['ids']),'ChatQueueId':Number(_0x53fec6['params']['id'])});}});}})[_0x8837('0x22')](respondWithStatusCode(_0x1c2ef8,null))[_0x8837('0x2c')](handleError(_0x1c2ef8,null));};exports[_0x8837('0x99')]=function(_0x2451fa,_0x1052d5,_0xed4f06){var _0x1c7cad={};var _0x411431={};var _0x4c1495;var _0x129b66;return db[_0x8837('0x53')][_0x8837('0x64')]({'where':{'id':_0x2451fa['params']['id']}})['then'](handleEntityNotFound(_0x1052d5,null))['then'](function(_0xdac633){if(_0xdac633){_0x4c1495=_0xdac633;_0x411431[_0x8837('0x46')]=_[_0x8837('0x42')](db['User']['rawAttributes']);_0x411431[_0x8837('0x43')]=_['keys'](_0x2451fa[_0x8837('0x43')]);_0x411431['filters']=_[_0x8837('0x45')](_0x411431['model'],_0x411431[_0x8837('0x43')]);_0x1c7cad[_0x8837('0x47')]=_[_0x8837('0x45')](_0x411431['model'],qs[_0x8837('0x48')](_0x2451fa['query'][_0x8837('0x48')]));_0x1c7cad[_0x8837('0x47')]=_0x1c7cad[_0x8837('0x47')][_0x8837('0x49')]?_0x1c7cad[_0x8837('0x47')]:_0x411431['model'];_0x1c7cad[_0x8837('0x9a')]=qs[_0x8837('0x4b')](_0x2451fa[_0x8837('0x43')][_0x8837('0x4b')]);_0x1c7cad[_0x8837('0x4c')]=qs[_0x8837('0x44')](_['pick'](_0x2451fa['query'],_0x411431[_0x8837('0x44')]));if(_0x2451fa[_0x8837('0x43')][_0x8837('0x4e')]){_0x1c7cad['where']=_[_0x8837('0x51')](_0x1c7cad[_0x8837('0x4c')],{'$or':_[_0x8837('0x41')](_0x1c7cad['attributes'],function(_0x1c5f4d){var _0x14de73={};_0x14de73[_0x1c5f4d]={'$like':'%'+_0x2451fa[_0x8837('0x43')][_0x8837('0x4e')]+'%'};return _0x14de73;})});}_0x1c7cad=_['merge']({},_0x1c7cad,_0x2451fa[_0x8837('0x52')]);return _0x4c1495[_0x8837('0x99')](_0x1c7cad);}})['then'](function(_0x29f468){if(_0x29f468){_0x129b66=_0x29f468[_0x8837('0x49')];if(!_0x2451fa[_0x8837('0x43')][_0x8837('0x66')](_0x8837('0x4a'))){_0x1c7cad[_0x8837('0x32')]=qs[_0x8837('0x32')](_0x2451fa['query'][_0x8837('0x32')]);_0x1c7cad[_0x8837('0x31')]=qs[_0x8837('0x31')](_0x2451fa['query'][_0x8837('0x31')]);}return _0x4c1495['getAgents'](_0x1c7cad);}})[_0x8837('0x22')](function(_0x4fd016){if(_0x4fd016){return _0x4fd016?{'count':_0x129b66,'rows':_0x4fd016}:null;}})[_0x8837('0x22')](respondWithResult(_0x1052d5,null))[_0x8837('0x2c')](handleError(_0x1052d5,null));};
\ No newline at end of file