Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 6f80fa8..8b07b65 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 _0x130d=['filters','intersection','attributes','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','count','includeAll','include','ChatQueue','findAll','rows','show','params','fields','length','options','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getMembers','findOne','UserChatQueue','ChatQueueId','User','findAndCountAll','UserId','agent','format','%s/%s','SIP','chatPause','createdAt','updatedAt','Team','getTeams','hasOwnProperty','addTeams','ids','flatMap','Agents','find','sequelize','transaction','each','forEach','emit','userChatQueue:save','removeTeams','select','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','push','toString','SELECT','every','TeamId','includes','union','compact','value','removeAgents','addAgents','omit','spread','isArray','userChatQueue:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','ejs','crypto','jsforce','desk.js','querystring','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./chatQueue.socket','register','jayson/promise','client','http','request','then','info','ChatQueue,\x20%s,\x20%s','debug','ChatQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','status','end','json','offset','Content-Range','apply','ChatQueues','UserProfileResource','destroy','stack','name','send','rawAttributes','fieldName','type','key','model','map','query','keys'];(function(_0x10d4f3,_0x4f7f00){var _0x435369=function(_0x54b36a){while(--_0x54b36a){_0x10d4f3['push'](_0x10d4f3['shift']());}};_0x435369(++_0x4f7f00);}(_0x130d,0x17d));var _0xd130=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x130d[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xd130('0x0'));var emlformat=require(_0xd130('0x1'));var rimraf=require(_0xd130('0x2'));var zipdir=require(_0xd130('0x3'));var jsonpatch=require(_0xd130('0x4'));var rp=require(_0xd130('0x5'));var moment=require('moment');var BPromise=require(_0xd130('0x6'));var Mustache=require('mustache');var util=require(_0xd130('0x7'));var path=require(_0xd130('0x8'));var sox=require(_0xd130('0x9'));var csv=require(_0xd130('0xa'));var ejs=require(_0xd130('0xb'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xd130('0xc'));var jsforce=require(_0xd130('0xd'));var deskjs=require(_0xd130('0xe'));var toCsv=require('to-csv');var querystring=require(_0xd130('0xf'));var Papa=require('papaparse');var Redis=require(_0xd130('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xd130('0x11'));var hardwareService=require(_0xd130('0x12'));var logger=require(_0xd130('0x13'))('api');var utils=require(_0xd130('0x14'));var config=require(_0xd130('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xd130('0x16'))['db'];config['redis']=_[_0xd130('0x17')](config[_0xd130('0x18')],{'host':_0xd130('0x19'),'port':0x18eb});var socket=require(_0xd130('0x1a'))(new Redis(config[_0xd130('0x18')]));require(_0xd130('0x1b'))[_0xd130('0x1c')](socket);var jayson=require(_0xd130('0x1d'));var client=jayson[_0xd130('0x1e')][_0xd130('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x4f619a,_0x2c9913,_0x216f8f,_0x3ee6f4){return new BPromise(function(_0x55ef9a,_0x2bb84f){var _0x21066a=_0x3ee6f4||client;return _0x21066a[_0xd130('0x20')](_0x4f619a,_0x216f8f)[_0xd130('0x21')](function(_0x30debe){logger[_0xd130('0x22')](_0xd130('0x23'),_0x2c9913,'request\x20sent');logger[_0xd130('0x24')](_0xd130('0x25'),_0x2c9913,_0xd130('0x26'),JSON[_0xd130('0x27')](_0x30debe));if(_0x30debe[_0xd130('0x28')]){if(_0x30debe['error'][_0xd130('0x29')]===0x1f4){logger[_0xd130('0x28')]('ChatQueue,\x20%s,\x20%s',_0x2c9913,_0x30debe[_0xd130('0x28')][_0xd130('0x2a')]);return _0x2bb84f(_0x30debe[_0xd130('0x28')]['message']);}logger[_0xd130('0x28')]('ChatQueue,\x20%s,\x20%s',_0x2c9913,_0x30debe['error']['message']);return _0x55ef9a(_0x30debe['error'][_0xd130('0x2a')]);}else{logger['info'](_0xd130('0x23'),_0x2c9913,_0xd130('0x26'));_0x55ef9a(_0x30debe['result'][_0xd130('0x2a')]);}})['catch'](function(_0x218bea){logger[_0xd130('0x28')](_0xd130('0x23'),_0x2c9913,_0x218bea);_0x2bb84f(_0x218bea);});});}function respondWithStatusCode(_0x1ce2b1,_0x583f32){_0x583f32=_0x583f32||0xcc;return function(_0x467424){if(_0x467424){return _0x1ce2b1['sendStatus'](_0x583f32);}return _0x1ce2b1[_0xd130('0x2b')](_0x583f32)[_0xd130('0x2c')]();};}function respondWithResult(_0x280f2d,_0x236403){_0x236403=_0x236403||0xc8;return function(_0x64582){if(_0x64582){return _0x280f2d[_0xd130('0x2b')](_0x236403)[_0xd130('0x2d')](_0x64582);}};}function respondWithFilteredResult(_0x39ff76,_0x13c7a5){return function(_0xb5faf4){if(_0xb5faf4){var _0x49d5d7=_0xb5faf4['count'],_0x162ff5=_0x13c7a5[_0xd130('0x2e')],_0x42fa35=_0x13c7a5['offset']+_0x13c7a5['limit'],_0x1a4283;if(_0x42fa35>=_0x49d5d7){_0x42fa35=_0x49d5d7;_0x1a4283=0xc8;}else{_0x1a4283=0xce;}_0x39ff76[_0xd130('0x2b')](_0x1a4283);return _0x39ff76['set'](_0xd130('0x2f'),_0x162ff5+'-'+_0x42fa35+'/'+_0x49d5d7)[_0xd130('0x2d')](_0xb5faf4);}return null;};}function patchUpdates(_0x33e378){return function(_0x11ae1f){try{jsonpatch[_0xd130('0x30')](_0x11ae1f,_0x33e378,!![]);}catch(_0xf2c68d){return BPromise['reject'](_0xf2c68d);}return _0x11ae1f['save']();};}function saveUpdates(_0x2e375a,_0x3484ab){return function(_0x5abf86){if(_0x5abf86){return _0x5abf86['update'](_0x2e375a)[_0xd130('0x21')](function(_0x43af77){return _0x43af77;});}return null;};}function removeEntity(_0x5e63e8,_0x7e1bc4){return function(_0x25c4ce){if(_0x25c4ce){return _0x25c4ce['destroy']()['then'](function(){var _0x4e237e=_0x25c4ce['get']({'plain':!![]});var _0x566bae=_0xd130('0x31');return db[_0xd130('0x32')][_0xd130('0x33')]({'where':{'type':_0x566bae,'resourceId':_0x4e237e['id']}})[_0xd130('0x21')](function(){return _0x25c4ce;});})[_0xd130('0x21')](function(){_0x5e63e8[_0xd130('0x2b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x11fbc8,_0x3c9221){return function(_0x485109){if(!_0x485109){_0x11fbc8['sendStatus'](0x194);}return _0x485109;};}function handleError(_0x32dde5,_0x20a584){_0x20a584=_0x20a584||0x1f4;return function(_0x1d4a7a){logger[_0xd130('0x28')](_0x1d4a7a[_0xd130('0x34')]);if(_0x1d4a7a[_0xd130('0x35')]){delete _0x1d4a7a[_0xd130('0x35')];}_0x32dde5[_0xd130('0x2b')](_0x20a584)[_0xd130('0x36')](_0x1d4a7a);};}exports['index']=function(_0xabd088,_0xf4eb74){var _0x1609a0={},_0x29860e={},_0x38ecce={'count':0x0,'rows':[]};var _0x19615f=_['map'](db['ChatQueue'][_0xd130('0x37')],function(_0x54b84c){return{'name':_0x54b84c[_0xd130('0x38')],'type':_0x54b84c[_0xd130('0x39')][_0xd130('0x3a')]};});_0x29860e[_0xd130('0x3b')]=_[_0xd130('0x3c')](_0x19615f,'name');_0x29860e[_0xd130('0x3d')]=_[_0xd130('0x3e')](_0xabd088[_0xd130('0x3d')]);_0x29860e[_0xd130('0x3f')]=_[_0xd130('0x40')](_0x29860e['model'],_0x29860e['query']);_0x1609a0[_0xd130('0x41')]=_['intersection'](_0x29860e[_0xd130('0x3b')],qs['fields'](_0xabd088['query']['fields']));_0x1609a0['attributes']=_0x1609a0[_0xd130('0x41')]['length']?_0x1609a0[_0xd130('0x41')]:_0x29860e['model'];if(!_0xabd088['query']['hasOwnProperty'](_0xd130('0x42'))){_0x1609a0[_0xd130('0x43')]=qs[_0xd130('0x43')](_0xabd088['query']['limit']);_0x1609a0['offset']=qs[_0xd130('0x2e')](_0xabd088[_0xd130('0x3d')][_0xd130('0x2e')]);}_0x1609a0[_0xd130('0x44')]=qs['sort'](_0xabd088['query'][_0xd130('0x45')]);_0x1609a0[_0xd130('0x46')]=qs[_0xd130('0x3f')](_[_0xd130('0x47')](_0xabd088['query'],_0x29860e[_0xd130('0x3f')]),_0x19615f);if(_0xabd088['query'][_0xd130('0x48')]){_0x1609a0['where']=_[_0xd130('0x49')](_0x1609a0['where'],{'$or':_['map'](_0x19615f,function(_0x32a55d){if(_0x32a55d[_0xd130('0x39')]!==_0xd130('0x4a')){var _0x11169d={};_0x11169d[_0x32a55d[_0xd130('0x35')]]={'$like':'%'+_0xabd088[_0xd130('0x3d')][_0xd130('0x48')]+'%'};return _0x11169d;}})});}_0x1609a0=_[_0xd130('0x49')]({},_0x1609a0,_0xabd088['options']);var _0x551f2c={'where':_0x1609a0['where']};return db['ChatQueue'][_0xd130('0x4b')](_0x551f2c)[_0xd130('0x21')](function(_0x58fa56){_0x38ecce['count']=_0x58fa56;if(_0xabd088[_0xd130('0x3d')][_0xd130('0x4c')]){_0x1609a0[_0xd130('0x4d')]=[{'all':!![]}];}return db[_0xd130('0x4e')][_0xd130('0x4f')](_0x1609a0);})[_0xd130('0x21')](function(_0x2c2205){_0x38ecce[_0xd130('0x50')]=_0x2c2205;return _0x38ecce;})['then'](respondWithFilteredResult(_0xf4eb74,_0x1609a0))['catch'](handleError(_0xf4eb74,null));};exports[_0xd130('0x51')]=function(_0x3661a9,_0xd7c4b){var _0x440488={'raw':!![],'where':{'id':_0x3661a9[_0xd130('0x52')]['id']}},_0x3e8449={};_0x3e8449[_0xd130('0x3b')]=_[_0xd130('0x3e')](db[_0xd130('0x4e')][_0xd130('0x37')]);_0x3e8449[_0xd130('0x3d')]=_[_0xd130('0x3e')](_0x3661a9['query']);_0x3e8449['filters']=_[_0xd130('0x40')](_0x3e8449['model'],_0x3e8449[_0xd130('0x3d')]);_0x440488[_0xd130('0x41')]=_[_0xd130('0x40')](_0x3e8449[_0xd130('0x3b')],qs[_0xd130('0x53')](_0x3661a9['query'][_0xd130('0x53')]));_0x440488[_0xd130('0x41')]=_0x440488['attributes'][_0xd130('0x54')]?_0x440488[_0xd130('0x41')]:_0x3e8449['model'];if(_0x3661a9[_0xd130('0x3d')]['includeAll']){_0x440488['include']=[{'all':!![]}];}_0x440488=_[_0xd130('0x49')]({},_0x440488,_0x3661a9[_0xd130('0x55')]);return db[_0xd130('0x4e')]['find'](_0x440488)[_0xd130('0x21')](handleEntityNotFound(_0xd7c4b,null))['then'](respondWithResult(_0xd7c4b,null))[_0xd130('0x56')](handleError(_0xd7c4b,null));};exports[_0xd130('0x57')]=function(_0x14f389,_0x3acc11){return db[_0xd130('0x4e')]['create'](_0x14f389[_0xd130('0x58')],{})[_0xd130('0x21')](function(_0x32413a){var _0x5cc188=_0x14f389[_0xd130('0x59')][_0xd130('0x5a')]({'plain':!![]});if(!_0x5cc188)throw new Error(_0xd130('0x5b'));if(_0x5cc188['role']===_0xd130('0x59')){var _0x338824=_0x32413a[_0xd130('0x5a')]({'plain':!![]});var _0x212ea6=_0xd130('0x31');return db['UserProfileSection']['find']({'where':{'name':_0x212ea6,'userProfileId':_0x5cc188[_0xd130('0x5c')]},'raw':!![]})[_0xd130('0x21')](function(_0x1dbd94){if(_0x1dbd94&&_0x1dbd94['autoAssociation']===0x0){return db[_0xd130('0x32')]['create']({'name':_0x338824[_0xd130('0x35')],'resourceId':_0x338824['id'],'type':_0x1dbd94[_0xd130('0x35')],'sectionId':_0x1dbd94['id']},{})[_0xd130('0x21')](function(){return _0x32413a;});}else{return _0x32413a;}})['catch'](function(_0x18cdf8){logger['error'](_0xd130('0x5d'),_0x18cdf8);throw _0x18cdf8;});}return _0x32413a;})[_0xd130('0x21')](respondWithResult(_0x3acc11,0xc9))[_0xd130('0x56')](handleError(_0x3acc11,null));};exports['update']=function(_0x30f284,_0x3d394b){if(_0x30f284[_0xd130('0x58')]['id']){delete _0x30f284[_0xd130('0x58')]['id'];}return db[_0xd130('0x4e')]['find']({'where':{'id':_0x30f284[_0xd130('0x52')]['id']}})[_0xd130('0x21')](handleEntityNotFound(_0x3d394b,null))[_0xd130('0x21')](saveUpdates(_0x30f284[_0xd130('0x58')],null))['then'](respondWithResult(_0x3d394b,null))[_0xd130('0x56')](handleError(_0x3d394b,null));};exports[_0xd130('0x33')]=function(_0x1ef150,_0x4fbb5b){return db[_0xd130('0x4e')]['find']({'where':{'id':_0x1ef150[_0xd130('0x52')]['id']}})[_0xd130('0x21')](handleEntityNotFound(_0x4fbb5b,null))[_0xd130('0x21')](removeEntity(_0x4fbb5b,null))[_0xd130('0x56')](handleError(_0x4fbb5b,null));};exports['describe']=function(_0x47eac9,_0x42c626){return db[_0xd130('0x4e')]['describe']()[_0xd130('0x21')](respondWithResult(_0x42c626,null))['catch'](handleError(_0x42c626,null));};exports[_0xd130('0x5e')]=function(_0x31640c,_0x1b446c,_0x5ccb2f){var _0x4afbcd={'raw':!![],'where':{}},_0x4e2d3e={},_0x211d25;return db[_0xd130('0x4e')][_0xd130('0x5f')]({'where':{'id':_0x31640c[_0xd130('0x52')]['id']}})[_0xd130('0x21')](handleEntityNotFound(_0x1b446c,null))[_0xd130('0x21')](function(_0x3fc329){if(_0x3fc329){_0x211d25=_0x3fc329[_0xd130('0x5a')]({'plain':!![]});_0x4e2d3e['model']=_['keys'](db[_0xd130('0x60')][_0xd130('0x37')]);_0x4e2d3e[_0xd130('0x3d')]=_[_0xd130('0x3e')](_0x31640c[_0xd130('0x3d')]);_0x4e2d3e[_0xd130('0x3f')]=_['intersection'](_0x4e2d3e[_0xd130('0x3b')],_0x4e2d3e[_0xd130('0x3d')]);_0x4afbcd['attributes']=_[_0xd130('0x40')](_0x4e2d3e[_0xd130('0x3b')],qs[_0xd130('0x53')](_0x31640c[_0xd130('0x3d')][_0xd130('0x53')]));_0x4afbcd[_0xd130('0x41')]=_0x4afbcd[_0xd130('0x41')][_0xd130('0x54')]?_0x4afbcd[_0xd130('0x41')]:_0x4e2d3e[_0xd130('0x3b')];if(!_0x31640c[_0xd130('0x3d')]['hasOwnProperty'](_0xd130('0x42'))){_0x4afbcd['limit']=qs['limit'](_0x31640c[_0xd130('0x3d')][_0xd130('0x43')]);_0x4afbcd[_0xd130('0x2e')]=qs[_0xd130('0x2e')](_0x31640c['query']['offset']);}_0x4afbcd[_0xd130('0x44')]=qs[_0xd130('0x45')](_0x31640c['query'][_0xd130('0x45')]);_0x4afbcd[_0xd130('0x46')]=qs[_0xd130('0x3f')](_[_0xd130('0x47')](_0x31640c[_0xd130('0x3d')],_0x4e2d3e[_0xd130('0x3f')]));_0x4afbcd[_0xd130('0x46')][_0xd130('0x61')]=_0x3fc329['id'];if(_0x31640c[_0xd130('0x3d')]['filter']){_0x4afbcd['where']=_[_0xd130('0x49')](_0x4afbcd[_0xd130('0x46')],{'$or':_[_0xd130('0x3c')](_0x4afbcd[_0xd130('0x41')],function(_0x8e93db){var _0x404d19={};_0x404d19[_0x8e93db]={'$like':'%'+_0x31640c[_0xd130('0x3d')]['filter']+'%'};return _0x404d19;})});}_0x4afbcd=_[_0xd130('0x49')]({},_0x4afbcd,_0x31640c[_0xd130('0x55')]);return db[_0xd130('0x60')][_0xd130('0x4f')](_0x4afbcd);}})[_0xd130('0x21')](function(_0x203458){if(_0x203458){return db[_0xd130('0x62')][_0xd130('0x63')]({'where':{'id':_[_0xd130('0x3c')](_0x203458,_0xd130('0x64')),'role':_0xd130('0x65')},'attributes':['id',_0xd130('0x35'),'chatPause','updatedAt','createdAt']});}})['then'](function(_0x3ac557){if(_0x3ac557){return{'count':_0x3ac557[_0xd130('0x4b')],'rows':_[_0xd130('0x3c')](_0x3ac557[_0xd130('0x50')],function(_0x5ad2b2){return{'membername':_0x5ad2b2[_0xd130('0x35')],'UserId':_0x5ad2b2['id'],'queue_name':_0x211d25[_0xd130('0x35')],'ChatQueueId':_0x211d25['id'],'interface':util[_0xd130('0x66')](_0xd130('0x67'),_0xd130('0x68'),_0x5ad2b2[_0xd130('0x35')]),'penalty':0x0,'paused':_0x5ad2b2[_0xd130('0x69')],'createdAt':_0x5ad2b2[_0xd130('0x6a')],'updatedAt':_0x5ad2b2[_0xd130('0x6b')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x1b446c,_0x4afbcd))[_0xd130('0x56')](handleError(_0x1b446c,null));};exports['getTeams']=function(_0x52c615,_0x37d5fc,_0x3105c5){var _0x5ac6c2={};var _0x542aa6={};var _0x2b4695;var _0x319d9a;return db[_0xd130('0x4e')]['findOne']({'where':{'id':_0x52c615[_0xd130('0x52')]['id']}})[_0xd130('0x21')](handleEntityNotFound(_0x37d5fc,null))['then'](function(_0x167904){if(_0x167904){_0x2b4695=_0x167904;_0x542aa6[_0xd130('0x3b')]=_[_0xd130('0x3e')](db[_0xd130('0x6c')][_0xd130('0x37')]);_0x542aa6[_0xd130('0x3d')]=_['keys'](_0x52c615['query']);_0x542aa6[_0xd130('0x3f')]=_['intersection'](_0x542aa6['model'],_0x542aa6[_0xd130('0x3d')]);_0x5ac6c2[_0xd130('0x41')]=_[_0xd130('0x40')](_0x542aa6[_0xd130('0x3b')],qs[_0xd130('0x53')](_0x52c615[_0xd130('0x3d')]['fields']));_0x5ac6c2[_0xd130('0x41')]=_0x5ac6c2[_0xd130('0x41')][_0xd130('0x54')]?_0x5ac6c2[_0xd130('0x41')]:_0x542aa6[_0xd130('0x3b')];_0x5ac6c2[_0xd130('0x44')]=qs[_0xd130('0x45')](_0x52c615[_0xd130('0x3d')][_0xd130('0x45')]);_0x5ac6c2['where']=qs[_0xd130('0x3f')](_[_0xd130('0x47')](_0x52c615[_0xd130('0x3d')],_0x542aa6['filters']));if(_0x52c615[_0xd130('0x3d')]['filter']){_0x5ac6c2[_0xd130('0x46')]=_[_0xd130('0x49')](_0x5ac6c2[_0xd130('0x46')],{'$or':_['map'](_0x5ac6c2[_0xd130('0x41')],function(_0x583e41){var _0x25aedf={};_0x25aedf[_0x583e41]={'$like':'%'+_0x52c615[_0xd130('0x3d')]['filter']+'%'};return _0x25aedf;})});}_0x5ac6c2=_[_0xd130('0x49')]({},_0x5ac6c2,_0x52c615[_0xd130('0x55')]);return _0x2b4695[_0xd130('0x6d')](_0x5ac6c2);}})[_0xd130('0x21')](function(_0x19b8d5){if(_0x19b8d5){_0x319d9a=_0x19b8d5['length'];if(!_0x52c615['query'][_0xd130('0x6e')](_0xd130('0x42'))){_0x5ac6c2['limit']=qs[_0xd130('0x43')](_0x52c615[_0xd130('0x3d')][_0xd130('0x43')]);_0x5ac6c2[_0xd130('0x2e')]=qs['offset'](_0x52c615[_0xd130('0x3d')][_0xd130('0x2e')]);}return _0x2b4695['getTeams'](_0x5ac6c2);}})[_0xd130('0x21')](function(_0x5819f7){if(_0x5819f7){return _0x5819f7?{'count':_0x319d9a,'rows':_0x5819f7}:null;}})['then'](respondWithResult(_0x37d5fc,null))[_0xd130('0x56')](handleError(_0x37d5fc,null));};exports[_0xd130('0x6f')]=function(_0x4fe7f3,_0x46102f,_0x170e19){var _0x5cdc2d=_0x4fe7f3[_0xd130('0x58')][_0xd130('0x70')];return db[_0xd130('0x6c')][_0xd130('0x4f')]({'where':{'id':_0x5cdc2d},'attributes':['id'],'include':[{'model':db[_0xd130('0x62')],'as':'Agents','attributes':['id',_0xd130('0x35'),'online','voicePause','interface'],'raw':!![]}]})['then'](function(_0xe8d87d){if(_0xe8d87d){var _0xcfb616=_[_0xd130('0x71')](_0xe8d87d,function(_0x226f74){var _0x432a7f=_0x226f74[_0xd130('0x5a')]({'plain':!![]});return _0x432a7f[_0xd130('0x72')];});return db[_0xd130('0x4e')][_0xd130('0x73')]({'where':{'id':_0x4fe7f3[_0xd130('0x52')]['id']}})[_0xd130('0x21')](function(_0x5783ce){return db[_0xd130('0x74')][_0xd130('0x75')](function(_0x58404f){return _0x5783ce[_0xd130('0x6f')](_0x5cdc2d,{'transaction':_0x58404f})['then'](function(){return BPromise[_0xd130('0x76')](_0xcfb616,function(_0x2f0bad){return db[_0xd130('0x60')]['findOrCreate']({'where':{'UserId':_0x2f0bad['id'],'ChatQueueId':_0x4fe7f3[_0xd130('0x52')]['id']},'transaction':_0x58404f});});})[_0xd130('0x21')](function(){_0xcfb616[_0xd130('0x77')](function(_0x397c77){socket[_0xd130('0x78')](_0xd130('0x79'),{'UserId':_0x397c77['id'],'ChatQueueId':_0x5783ce['id']});});});});});}})[_0xd130('0x21')](respondWithStatusCode(_0x46102f,null))[_0xd130('0x56')](handleError(_0x46102f,null));};exports[_0xd130('0x7a')]=function(_0x3479bc,_0x5dd4bc,_0x596140){return db[_0xd130('0x6c')][_0xd130('0x4f')]({'where':{'id':_0x3479bc[_0xd130('0x3d')]['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0xd130('0x72'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x5dd4bc,null))[_0xd130('0x21')](function(_0x3a87f7){var _0xa83110=_[_0xd130('0x3c')](_0x3a87f7,'id');var _0x36f8c1=[];var _0x24ae8d=[];var _0x4e0163=squel[_0xd130('0x7b')]();_0x4e0163['field'](_0xd130('0x7c'))[_0xd130('0x7d')](_0xd130('0x7e'),'tq')[_0xd130('0x7f')](_0xd130('0x80'),'ut',_0xd130('0x81'))['where'](_0xd130('0x82'),_0x3479bc[_0xd130('0x52')]['id']);for(var _0xd9506a=0x0;_0xd9506a<_0x3a87f7[_0xd130('0x54')];_0xd9506a+=0x1){let _0x3f9b5a=_0x3a87f7[_0xd9506a];for(var _0x81eaf5=0x0;_0x81eaf5<_0x3f9b5a['Agents'][_0xd130('0x54')];_0x81eaf5+=0x1){let _0x5ee29e=_0x3f9b5a['Agents'][_0x81eaf5];var _0x219791=_0x4e0163[_0xd130('0x83')]();_0x219791[_0xd130('0x46')]('ut.UserId\x20=\x20?',_0x5ee29e['id']);_0x24ae8d[_0xd130('0x84')](db['sequelize'][_0xd130('0x3d')](_0x219791[_0xd130('0x85')](),{'type':db[_0xd130('0x74')]['QueryTypes'][_0xd130('0x86')]})[_0xd130('0x21')](function(_0x309208){if(_0x309208[_0xd130('0x54')]===0x1){return _0x5ee29e['id'];}else{var _0x4e26e7=_[_0xd130('0x87')](_['map'](_0x309208,_0xd130('0x88')),function(_0x217571){return _[_0xd130('0x89')](_0xa83110,_0x217571);});if(_0x4e26e7){return _0x5ee29e['id'];}}}));}}return BPromise['all'](_0x24ae8d)[_0xd130('0x21')](function(_0x10893f){_0x36f8c1=_(_0x36f8c1)[_0xd130('0x8a')](_0x10893f)[_0xd130('0x8b')]()[_0xd130('0x8c')]();return db[_0xd130('0x4e')]['find']({'where':{'id':_0x3479bc[_0xd130('0x52')]['id']}})[_0xd130('0x21')](function(_0x2f1b55){return db[_0xd130('0x74')][_0xd130('0x75')](function(_0x9e84de){return _0x2f1b55[_0xd130('0x7a')](_0x3479bc[_0xd130('0x3d')][_0xd130('0x70')],{'transaction':_0x9e84de})['then'](function(){if(!_['isEmpty'](_0x36f8c1)){return _0x2f1b55[_0xd130('0x8d')](_0x36f8c1,{'transaction':_0x9e84de});}})[_0xd130('0x21')](function(){_0x36f8c1[_0xd130('0x77')](function(_0x561f64){socket[_0xd130('0x78')]('userChatQueue:remove',{'UserId':_0x561f64,'ChatQueueId':_0x2f1b55['id']});});});});});});})[_0xd130('0x21')](respondWithStatusCode(_0x5dd4bc,null))['catch'](handleError(_0x5dd4bc,null));};exports['addAgents']=function(_0x3ca569,_0x569ca3,_0x465927){return db[_0xd130('0x4e')][_0xd130('0x73')]({'where':{'id':_0x3ca569[_0xd130('0x52')]['id']}})[_0xd130('0x21')](handleEntityNotFound(_0x569ca3,null))[_0xd130('0x21')](function(_0x112117){if(_0x112117){return _0x112117[_0xd130('0x8e')](_0x3ca569[_0xd130('0x58')][_0xd130('0x70')],_[_0xd130('0x8f')](_0x3ca569[_0xd130('0x58')],[_0xd130('0x70'),'id'])||{})[_0xd130('0x90')](function(_0x29138d){for(var _0xb0eac7=0x0;_0xb0eac7<_0x3ca569['body'][_0xd130('0x70')][_0xd130('0x54')];_0xb0eac7+=0x1){socket[_0xd130('0x78')](_0xd130('0x79'),{'UserId':_0x3ca569[_0xd130('0x58')][_0xd130('0x70')][_0xb0eac7],'ChatQueueId':_0x3ca569['params']['id']});}return _0x29138d;});}})[_0xd130('0x21')](respondWithResult(_0x569ca3,null))[_0xd130('0x56')](handleError(_0x569ca3,null));};exports[_0xd130('0x8d')]=function(_0x6b2177,_0x202b4b,_0x242db5){return db['ChatQueue']['find']({'where':{'id':_0x6b2177[_0xd130('0x52')]['id']}})[_0xd130('0x21')](handleEntityNotFound(_0x202b4b,null))[_0xd130('0x21')](function(_0x32fe24){if(_0x32fe24){return _0x32fe24[_0xd130('0x8d')](_0x6b2177[_0xd130('0x3d')][_0xd130('0x70')])[_0xd130('0x21')](function(){if(_[_0xd130('0x91')](_0x6b2177[_0xd130('0x3d')]['ids'])){for(var _0x40d523=0x0;_0x40d523<_0x6b2177[_0xd130('0x3d')][_0xd130('0x70')]['length'];_0x40d523+=0x1){socket[_0xd130('0x78')](_0xd130('0x92'),{'UserId':Number(_0x6b2177['query'][_0xd130('0x70')][_0x40d523]),'ChatQueueId':Number(_0x6b2177['params']['id'])});}}else{socket[_0xd130('0x78')]('userChatQueue:remove',{'UserId':Number(_0x6b2177[_0xd130('0x3d')][_0xd130('0x70')]),'ChatQueueId':Number(_0x6b2177[_0xd130('0x52')]['id'])});}});}})[_0xd130('0x21')](respondWithStatusCode(_0x202b4b,null))[_0xd130('0x56')](handleError(_0x202b4b,null));};exports[_0xd130('0x93')]=function(_0x646738,_0x2fd982,_0x2e4b77){var _0x46e7d7={};var _0x310ce6={};var _0x50d31b;var _0x866e;return db[_0xd130('0x4e')]['findOne']({'where':{'id':_0x646738[_0xd130('0x52')]['id']}})[_0xd130('0x21')](handleEntityNotFound(_0x2fd982,null))[_0xd130('0x21')](function(_0xdf165d){if(_0xdf165d){_0x50d31b=_0xdf165d;_0x310ce6['model']=_[_0xd130('0x3e')](db[_0xd130('0x62')][_0xd130('0x37')]);_0x310ce6['query']=_[_0xd130('0x3e')](_0x646738[_0xd130('0x3d')]);_0x310ce6['filters']=_[_0xd130('0x40')](_0x310ce6[_0xd130('0x3b')],_0x310ce6[_0xd130('0x3d')]);_0x46e7d7['attributes']=_[_0xd130('0x40')](_0x310ce6[_0xd130('0x3b')],qs[_0xd130('0x53')](_0x646738[_0xd130('0x3d')]['fields']));_0x46e7d7[_0xd130('0x41')]=_0x46e7d7['attributes'][_0xd130('0x54')]?_0x46e7d7[_0xd130('0x41')]:_0x310ce6['model'];_0x46e7d7['order']=qs[_0xd130('0x45')](_0x646738[_0xd130('0x3d')][_0xd130('0x45')]);_0x46e7d7[_0xd130('0x46')]=qs[_0xd130('0x3f')](_[_0xd130('0x47')](_0x646738[_0xd130('0x3d')],_0x310ce6[_0xd130('0x3f')]));if(_0x646738['query'][_0xd130('0x48')]){_0x46e7d7[_0xd130('0x46')]=_[_0xd130('0x49')](_0x46e7d7[_0xd130('0x46')],{'$or':_[_0xd130('0x3c')](_0x46e7d7['attributes'],function(_0x329ab9){var _0x249580={};_0x249580[_0x329ab9]={'$like':'%'+_0x646738[_0xd130('0x3d')][_0xd130('0x48')]+'%'};return _0x249580;})});}_0x46e7d7=_[_0xd130('0x49')]({},_0x46e7d7,_0x646738[_0xd130('0x55')]);return _0x50d31b[_0xd130('0x93')](_0x46e7d7);}})[_0xd130('0x21')](function(_0x239b9b){if(_0x239b9b){_0x866e=_0x239b9b[_0xd130('0x54')];if(!_0x646738[_0xd130('0x3d')][_0xd130('0x6e')](_0xd130('0x42'))){_0x46e7d7[_0xd130('0x43')]=qs[_0xd130('0x43')](_0x646738[_0xd130('0x3d')][_0xd130('0x43')]);_0x46e7d7[_0xd130('0x2e')]=qs['offset'](_0x646738[_0xd130('0x3d')][_0xd130('0x2e')]);}return _0x50d31b[_0xd130('0x93')](_0x46e7d7);}})[_0xd130('0x21')](function(_0x1be4c2){if(_0x1be4c2){return _0x1be4c2?{'count':_0x866e,'rows':_0x1be4c2}:null;}})[_0xd130('0x21')](respondWithResult(_0x2fd982,null))[_0xd130('0x56')](handleError(_0x2fd982,null));};
\ No newline at end of file