Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 19df0e3..edce8d9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4341=['emit','userChatQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_chat_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','TeamId','includes','all','union','value','isEmpty','removeAgents','addAgents','ids','omit','isArray','userChatQueue:remove','getAgents','findOne','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','defaults','redis','socket.io-emitter','register','jayson/promise','client','http','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','sendStatus','status','end','json','undefined','limit','offset','Content-Range','apply','reject','save','update','destroy','get','stack','name','send','index','ChatQueue','rawAttributes','fieldName','model','query','keys','filters','attributes','intersection','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','map','count','includeAll','include','rows','params','fields','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','ChatQueues','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserChatQueue','findAll','chatPause','updatedAt','createdAt','format','%s/%s','Team','getTeams','addTeams','User','Agents','online','voicePause','interface','flatMap','sequelize','transaction','each','forEach'];(function(_0x5966bc,_0x569f43){var _0x5b68f2=function(_0x46aa38){while(--_0x46aa38){_0x5966bc['push'](_0x5966bc['shift']());}};_0x5b68f2(++_0x569f43);}(_0x4341,0x1dc));var _0x1434=function(_0x5ce075,_0x20b649){_0x5ce075=_0x5ce075-0x0;var _0x595e7d=_0x4341[_0x5ce075];return _0x595e7d;};'use strict';var emlformat=require(_0x1434('0x0'));var rimraf=require(_0x1434('0x1'));var zipdir=require(_0x1434('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x1434('0x3'));var moment=require('moment');var BPromise=require(_0x1434('0x4'));var Mustache=require(_0x1434('0x5'));var util=require(_0x1434('0x6'));var path=require(_0x1434('0x7'));var sox=require(_0x1434('0x8'));var csv=require(_0x1434('0x9'));var ejs=require(_0x1434('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x1434('0xb'));var squel=require(_0x1434('0xc'));var crypto=require(_0x1434('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x1434('0xe'));var toCsv=require('to-csv');var querystring=require(_0x1434('0xf'));var Papa=require('papaparse');var Redis=require(_0x1434('0x10'));var authService=require(_0x1434('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x1434('0x12'));var logger=require(_0x1434('0x13'))(_0x1434('0x14'));var utils=require(_0x1434('0x15'));var config=require(_0x1434('0x16'));var licenseUtil=require(_0x1434('0x17'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x1434('0x18')](config[_0x1434('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x1434('0x1a'))(new Redis(config[_0x1434('0x19')]));require('./chatQueue.socket')[_0x1434('0x1b')](socket);var jayson=require(_0x1434('0x1c'));var client=jayson[_0x1434('0x1d')][_0x1434('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x4d1276,_0x1c74c3,_0x293a7b,_0x31a4ca){return new BPromise(function(_0x74693a,_0x53d9d3){var _0x4e24cf=_0x31a4ca||client;return _0x4e24cf[_0x1434('0x1f')](_0x4d1276,_0x293a7b)[_0x1434('0x20')](function(_0xa8b4bd){logger[_0x1434('0x21')](_0x1434('0x22'),_0x1c74c3,_0x1434('0x23'));logger[_0x1434('0x24')]('ChatQueue,\x20%s,\x20%s,\x20%s',_0x1c74c3,_0x1434('0x23'),JSON[_0x1434('0x25')](_0xa8b4bd));if(_0xa8b4bd['error']){if(_0xa8b4bd[_0x1434('0x26')][_0x1434('0x27')]===0x1f4){logger['error'](_0x1434('0x22'),_0x1c74c3,_0xa8b4bd[_0x1434('0x26')][_0x1434('0x28')]);return _0x53d9d3(_0xa8b4bd[_0x1434('0x26')]['message']);}logger['error']('ChatQueue,\x20%s,\x20%s',_0x1c74c3,_0xa8b4bd[_0x1434('0x26')]['message']);return _0x74693a(_0xa8b4bd[_0x1434('0x26')][_0x1434('0x28')]);}else{logger[_0x1434('0x21')](_0x1434('0x22'),_0x1c74c3,_0x1434('0x23'));_0x74693a(_0xa8b4bd[_0x1434('0x29')][_0x1434('0x28')]);}})[_0x1434('0x2a')](function(_0x50ec0a){logger['error'](_0x1434('0x22'),_0x1c74c3,_0x50ec0a);_0x53d9d3(_0x50ec0a);});});}function respondWithStatusCode(_0x48f7b8,_0x44c01b){_0x44c01b=_0x44c01b||0xcc;return function(_0x49a332){if(_0x49a332){return _0x48f7b8[_0x1434('0x2b')](_0x44c01b);}return _0x48f7b8[_0x1434('0x2c')](_0x44c01b)[_0x1434('0x2d')]();};}function respondWithResult(_0x403b41,_0x10cb23){_0x10cb23=_0x10cb23||0xc8;return function(_0x352777){if(_0x352777){return _0x403b41['status'](_0x10cb23)[_0x1434('0x2e')](_0x352777);}};}function respondWithFilteredResult(_0x30febd,_0x279657){return function(_0x36bb53){if(_0x36bb53){var _0x5f5983=typeof _0x279657['offset']===_0x1434('0x2f')&&typeof _0x279657[_0x1434('0x30')]===_0x1434('0x2f');var _0x310316=_0x36bb53['count'];var _0xeb6aa6=_0x5f5983?0x0:_0x279657[_0x1434('0x31')];var _0x2dcfc6=_0x5f5983?_0x36bb53['count']:_0x279657[_0x1434('0x31')]+_0x279657['limit'];var _0x4e0d15;if(_0x2dcfc6>=_0x310316){_0x2dcfc6=_0x310316;_0x4e0d15=0xc8;}else{_0x4e0d15=0xce;}_0x30febd[_0x1434('0x2c')](_0x4e0d15);return _0x30febd['set'](_0x1434('0x32'),_0xeb6aa6+'-'+_0x2dcfc6+'/'+_0x310316)[_0x1434('0x2e')](_0x36bb53);}return null;};}function patchUpdates(_0x42c5fb){return function(_0x386454){try{jsonpatch[_0x1434('0x33')](_0x386454,_0x42c5fb,!![]);}catch(_0x4d8393){return BPromise[_0x1434('0x34')](_0x4d8393);}return _0x386454[_0x1434('0x35')]();};}function saveUpdates(_0xfbc6c3,_0x557e9f){return function(_0x297a25){if(_0x297a25){return _0x297a25[_0x1434('0x36')](_0xfbc6c3)[_0x1434('0x20')](function(_0x2a3044){return _0x2a3044;});}return null;};}function removeEntity(_0x265ec9,_0x1cbce0){return function(_0x3b39e4){if(_0x3b39e4){return _0x3b39e4[_0x1434('0x37')]()[_0x1434('0x20')](function(){var _0x4df9cf=_0x3b39e4[_0x1434('0x38')]({'plain':!![]});var _0x3e8b7f='ChatQueues';return db['UserProfileResource'][_0x1434('0x37')]({'where':{'type':_0x3e8b7f,'resourceId':_0x4df9cf['id']}})['then'](function(){return _0x3b39e4;});})[_0x1434('0x20')](function(){_0x265ec9['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x188ea1,_0xf0eec2){return function(_0x42ed22){if(!_0x42ed22){_0x188ea1[_0x1434('0x2b')](0x194);}return _0x42ed22;};}function handleError(_0x222322,_0x405500){_0x405500=_0x405500||0x1f4;return function(_0x3c1282){logger['error'](_0x3c1282[_0x1434('0x39')]);if(_0x3c1282[_0x1434('0x3a')]){delete _0x3c1282[_0x1434('0x3a')];}_0x222322[_0x1434('0x2c')](_0x405500)[_0x1434('0x3b')](_0x3c1282);};}exports[_0x1434('0x3c')]=function(_0x311cbb,_0x598bb){var _0x80efdd={},_0x463273={},_0x3c33e0={'count':0x0,'rows':[]};var _0x18093f=_['map'](db[_0x1434('0x3d')][_0x1434('0x3e')],function(_0x37a78c){return{'name':_0x37a78c[_0x1434('0x3f')],'type':_0x37a78c['type']['key']};});_0x463273[_0x1434('0x40')]=_['map'](_0x18093f,_0x1434('0x3a'));_0x463273[_0x1434('0x41')]=_[_0x1434('0x42')](_0x311cbb[_0x1434('0x41')]);_0x463273[_0x1434('0x43')]=_['intersection'](_0x463273[_0x1434('0x40')],_0x463273[_0x1434('0x41')]);_0x80efdd[_0x1434('0x44')]=_[_0x1434('0x45')](_0x463273[_0x1434('0x40')],qs['fields'](_0x311cbb[_0x1434('0x41')]['fields']));_0x80efdd[_0x1434('0x44')]=_0x80efdd['attributes'][_0x1434('0x46')]?_0x80efdd[_0x1434('0x44')]:_0x463273[_0x1434('0x40')];if(!_0x311cbb[_0x1434('0x41')][_0x1434('0x47')](_0x1434('0x48'))){_0x80efdd['limit']=qs[_0x1434('0x30')](_0x311cbb[_0x1434('0x41')]['limit']);_0x80efdd[_0x1434('0x31')]=qs[_0x1434('0x31')](_0x311cbb['query']['offset']);}_0x80efdd[_0x1434('0x49')]=qs[_0x1434('0x4a')](_0x311cbb[_0x1434('0x41')][_0x1434('0x4a')]);_0x80efdd[_0x1434('0x4b')]=qs[_0x1434('0x43')](_[_0x1434('0x4c')](_0x311cbb[_0x1434('0x41')],_0x463273['filters']),_0x18093f);if(_0x311cbb[_0x1434('0x41')][_0x1434('0x4d')]){_0x80efdd[_0x1434('0x4b')]=_['merge'](_0x80efdd[_0x1434('0x4b')],{'$or':_[_0x1434('0x4e')](_0x18093f,function(_0x2c5599){if(_0x2c5599['type']!=='VIRTUAL'){var _0x3c7bb3={};_0x3c7bb3[_0x2c5599['name']]={'$like':'%'+_0x311cbb[_0x1434('0x41')][_0x1434('0x4d')]+'%'};return _0x3c7bb3;}})});}_0x80efdd=_['merge']({},_0x80efdd,_0x311cbb['options']);var _0x1a85dd={'where':_0x80efdd[_0x1434('0x4b')]};return db['ChatQueue'][_0x1434('0x4f')](_0x1a85dd)[_0x1434('0x20')](function(_0x9f4cbc){_0x3c33e0[_0x1434('0x4f')]=_0x9f4cbc;if(_0x311cbb[_0x1434('0x41')][_0x1434('0x50')]){_0x80efdd[_0x1434('0x51')]=[{'all':!![]}];}return db['ChatQueue']['findAll'](_0x80efdd);})[_0x1434('0x20')](function(_0x308652){_0x3c33e0[_0x1434('0x52')]=_0x308652;return _0x3c33e0;})[_0x1434('0x20')](respondWithFilteredResult(_0x598bb,_0x80efdd))[_0x1434('0x2a')](handleError(_0x598bb,null));};exports['show']=function(_0x54814e,_0x18d4f8){var _0x233918={'raw':!![],'where':{'id':_0x54814e[_0x1434('0x53')]['id']}},_0x4158ac={};_0x4158ac['model']=_[_0x1434('0x42')](db[_0x1434('0x3d')][_0x1434('0x3e')]);_0x4158ac[_0x1434('0x41')]=_[_0x1434('0x42')](_0x54814e[_0x1434('0x41')]);_0x4158ac[_0x1434('0x43')]=_[_0x1434('0x45')](_0x4158ac['model'],_0x4158ac[_0x1434('0x41')]);_0x233918[_0x1434('0x44')]=_[_0x1434('0x45')](_0x4158ac['model'],qs[_0x1434('0x54')](_0x54814e[_0x1434('0x41')][_0x1434('0x54')]));_0x233918['attributes']=_0x233918[_0x1434('0x44')]['length']?_0x233918[_0x1434('0x44')]:_0x4158ac['model'];if(_0x54814e[_0x1434('0x41')]['includeAll']){_0x233918[_0x1434('0x51')]=[{'all':!![]}];}_0x233918=_[_0x1434('0x55')]({},_0x233918,_0x54814e[_0x1434('0x56')]);return db[_0x1434('0x3d')][_0x1434('0x57')](_0x233918)[_0x1434('0x20')](handleEntityNotFound(_0x18d4f8,null))[_0x1434('0x20')](respondWithResult(_0x18d4f8,null))[_0x1434('0x2a')](handleError(_0x18d4f8,null));};exports[_0x1434('0x58')]=function(_0x3abef3,_0x24fbe1){return db[_0x1434('0x3d')]['create'](_0x3abef3[_0x1434('0x59')],{})['then'](function(_0x1c3d14){var _0x4488f9=_0x3abef3[_0x1434('0x5a')]['get']({'plain':!![]});if(!_0x4488f9)throw new Error(_0x1434('0x5b'));if(_0x4488f9['role']===_0x1434('0x5a')){var _0x32b027=_0x1c3d14[_0x1434('0x38')]({'plain':!![]});var _0x21dd1c=_0x1434('0x5c');return db[_0x1434('0x5d')][_0x1434('0x57')]({'where':{'name':_0x21dd1c,'userProfileId':_0x4488f9[_0x1434('0x5e')]},'raw':!![]})[_0x1434('0x20')](function(_0xf697d){if(_0xf697d&&_0xf697d[_0x1434('0x5f')]===0x0){return db[_0x1434('0x60')][_0x1434('0x58')]({'name':_0x32b027[_0x1434('0x3a')],'resourceId':_0x32b027['id'],'type':_0xf697d[_0x1434('0x3a')],'sectionId':_0xf697d['id']},{})['then'](function(){return _0x1c3d14;});}else{return _0x1c3d14;}})['catch'](function(_0x18f725){logger[_0x1434('0x26')](_0x1434('0x61'),_0x18f725);throw _0x18f725;});}return _0x1c3d14;})[_0x1434('0x20')](respondWithResult(_0x24fbe1,0xc9))[_0x1434('0x2a')](handleError(_0x24fbe1,null));};exports[_0x1434('0x36')]=function(_0x4cf66b,_0x531b08){if(_0x4cf66b['body']['id']){delete _0x4cf66b[_0x1434('0x59')]['id'];}return db[_0x1434('0x3d')][_0x1434('0x57')]({'where':{'id':_0x4cf66b[_0x1434('0x53')]['id']}})['then'](handleEntityNotFound(_0x531b08,null))['then'](saveUpdates(_0x4cf66b[_0x1434('0x59')],null))['then'](respondWithResult(_0x531b08,null))['catch'](handleError(_0x531b08,null));};exports[_0x1434('0x37')]=function(_0x3075b2,_0x32cb40){return db['ChatQueue']['find']({'where':{'id':_0x3075b2[_0x1434('0x53')]['id']}})['then'](handleEntityNotFound(_0x32cb40,null))[_0x1434('0x20')](removeEntity(_0x32cb40,null))[_0x1434('0x2a')](handleError(_0x32cb40,null));};exports[_0x1434('0x62')]=function(_0xd800c3,_0x20a3e8){return db[_0x1434('0x3d')][_0x1434('0x62')]()[_0x1434('0x20')](respondWithResult(_0x20a3e8,null))['catch'](handleError(_0x20a3e8,null));};exports[_0x1434('0x63')]=function(_0x428a4e,_0x307478,_0x31c1b8){var _0x236bbb={'raw':!![],'where':{}},_0x31cd1d={},_0x12916e;return db[_0x1434('0x3d')]['findOne']({'where':{'id':_0x428a4e[_0x1434('0x53')]['id']}})[_0x1434('0x20')](handleEntityNotFound(_0x307478,null))[_0x1434('0x20')](function(_0x2e1971){if(_0x2e1971){_0x12916e=_0x2e1971['get']({'plain':!![]});_0x31cd1d['model']=_[_0x1434('0x42')](db[_0x1434('0x64')]['rawAttributes']);_0x31cd1d[_0x1434('0x41')]=_[_0x1434('0x42')](_0x428a4e['query']);_0x31cd1d[_0x1434('0x43')]=_[_0x1434('0x45')](_0x31cd1d[_0x1434('0x40')],_0x31cd1d[_0x1434('0x41')]);_0x236bbb[_0x1434('0x44')]=_[_0x1434('0x45')](_0x31cd1d[_0x1434('0x40')],qs['fields'](_0x428a4e[_0x1434('0x41')][_0x1434('0x54')]));_0x236bbb[_0x1434('0x44')]=_0x236bbb[_0x1434('0x44')]['length']?_0x236bbb[_0x1434('0x44')]:_0x31cd1d[_0x1434('0x40')];if(!_0x428a4e[_0x1434('0x41')][_0x1434('0x47')](_0x1434('0x48'))){_0x236bbb[_0x1434('0x30')]=qs[_0x1434('0x30')](_0x428a4e[_0x1434('0x41')][_0x1434('0x30')]);_0x236bbb[_0x1434('0x31')]=qs[_0x1434('0x31')](_0x428a4e['query'][_0x1434('0x31')]);}_0x236bbb[_0x1434('0x49')]=qs[_0x1434('0x4a')](_0x428a4e[_0x1434('0x41')][_0x1434('0x4a')]);_0x236bbb[_0x1434('0x4b')]=qs[_0x1434('0x43')](_[_0x1434('0x4c')](_0x428a4e[_0x1434('0x41')],_0x31cd1d[_0x1434('0x43')]));_0x236bbb[_0x1434('0x4b')]['ChatQueueId']=_0x2e1971['id'];if(_0x428a4e[_0x1434('0x41')][_0x1434('0x4d')]){_0x236bbb['where']=_[_0x1434('0x55')](_0x236bbb[_0x1434('0x4b')],{'$or':_['map'](_0x236bbb[_0x1434('0x44')],function(_0x1e246f){var _0x416ca4={};_0x416ca4[_0x1e246f]={'$like':'%'+_0x428a4e[_0x1434('0x41')][_0x1434('0x4d')]+'%'};return _0x416ca4;})});}_0x236bbb=_[_0x1434('0x55')]({},_0x236bbb,_0x428a4e[_0x1434('0x56')]);return db['UserChatQueue'][_0x1434('0x65')](_0x236bbb);}})[_0x1434('0x20')](function(_0x5a8c00){if(_0x5a8c00){return db['User']['findAndCountAll']({'where':{'id':_[_0x1434('0x4e')](_0x5a8c00,'UserId'),'role':'agent'},'attributes':['id','name',_0x1434('0x66'),_0x1434('0x67'),_0x1434('0x68')]});}})[_0x1434('0x20')](function(_0x1049b9){if(_0x1049b9){return{'count':_0x1049b9[_0x1434('0x4f')],'rows':_['map'](_0x1049b9[_0x1434('0x52')],function(_0x84157a){return{'membername':_0x84157a[_0x1434('0x3a')],'UserId':_0x84157a['id'],'queue_name':_0x12916e['name'],'ChatQueueId':_0x12916e['id'],'interface':util[_0x1434('0x69')](_0x1434('0x6a'),'SIP',_0x84157a[_0x1434('0x3a')]),'penalty':0x0,'paused':_0x84157a[_0x1434('0x66')],'createdAt':_0x84157a['createdAt'],'updatedAt':_0x84157a[_0x1434('0x67')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x1434('0x20')](respondWithFilteredResult(_0x307478,_0x236bbb))['catch'](handleError(_0x307478,null));};exports['getTeams']=function(_0x4b4b33,_0x96dea9,_0x481611){var _0x326b0e={};var _0xf887d1={};var _0x230bf8;var _0x69f30f;return db[_0x1434('0x3d')]['findOne']({'where':{'id':_0x4b4b33['params']['id']}})[_0x1434('0x20')](handleEntityNotFound(_0x96dea9,null))[_0x1434('0x20')](function(_0x167658){if(_0x167658){_0x230bf8=_0x167658;_0xf887d1[_0x1434('0x40')]=_[_0x1434('0x42')](db[_0x1434('0x6b')]['rawAttributes']);_0xf887d1[_0x1434('0x41')]=_['keys'](_0x4b4b33[_0x1434('0x41')]);_0xf887d1[_0x1434('0x43')]=_['intersection'](_0xf887d1[_0x1434('0x40')],_0xf887d1[_0x1434('0x41')]);_0x326b0e[_0x1434('0x44')]=_[_0x1434('0x45')](_0xf887d1['model'],qs[_0x1434('0x54')](_0x4b4b33['query'][_0x1434('0x54')]));_0x326b0e['attributes']=_0x326b0e[_0x1434('0x44')][_0x1434('0x46')]?_0x326b0e[_0x1434('0x44')]:_0xf887d1[_0x1434('0x40')];_0x326b0e[_0x1434('0x49')]=qs[_0x1434('0x4a')](_0x4b4b33[_0x1434('0x41')][_0x1434('0x4a')]);_0x326b0e[_0x1434('0x4b')]=qs['filters'](_['pick'](_0x4b4b33[_0x1434('0x41')],_0xf887d1[_0x1434('0x43')]));if(_0x4b4b33[_0x1434('0x41')][_0x1434('0x4d')]){_0x326b0e[_0x1434('0x4b')]=_['merge'](_0x326b0e['where'],{'$or':_[_0x1434('0x4e')](_0x326b0e['attributes'],function(_0x1acf80){var _0x591f86={};_0x591f86[_0x1acf80]={'$like':'%'+_0x4b4b33[_0x1434('0x41')]['filter']+'%'};return _0x591f86;})});}_0x326b0e=_[_0x1434('0x55')]({},_0x326b0e,_0x4b4b33['options']);return _0x230bf8['getTeams'](_0x326b0e);}})['then'](function(_0x556e12){if(_0x556e12){_0x69f30f=_0x556e12[_0x1434('0x46')];if(!_0x4b4b33[_0x1434('0x41')][_0x1434('0x47')](_0x1434('0x48'))){_0x326b0e[_0x1434('0x30')]=qs[_0x1434('0x30')](_0x4b4b33[_0x1434('0x41')]['limit']);_0x326b0e[_0x1434('0x31')]=qs[_0x1434('0x31')](_0x4b4b33[_0x1434('0x41')][_0x1434('0x31')]);}return _0x230bf8[_0x1434('0x6c')](_0x326b0e);}})[_0x1434('0x20')](function(_0x4eed57){if(_0x4eed57){return _0x4eed57?{'count':_0x69f30f,'rows':_0x4eed57}:null;}})[_0x1434('0x20')](respondWithResult(_0x96dea9,null))[_0x1434('0x2a')](handleError(_0x96dea9,null));};exports[_0x1434('0x6d')]=function(_0x500fb6,_0x1f6f73,_0x117e09){var _0x6aacf5=_0x500fb6['body']['ids'];return db['Team'][_0x1434('0x65')]({'where':{'id':_0x6aacf5},'attributes':['id'],'include':[{'model':db[_0x1434('0x6e')],'as':_0x1434('0x6f'),'attributes':['id',_0x1434('0x3a'),_0x1434('0x70'),_0x1434('0x71'),_0x1434('0x72')],'raw':!![]}]})[_0x1434('0x20')](function(_0x63d71){if(_0x63d71){var _0x18edb2=_[_0x1434('0x73')](_0x63d71,function(_0x50d238){var _0x594b39=_0x50d238[_0x1434('0x38')]({'plain':!![]});return _0x594b39['Agents'];});return db[_0x1434('0x3d')][_0x1434('0x57')]({'where':{'id':_0x500fb6[_0x1434('0x53')]['id']}})['then'](function(_0x16435d){return db[_0x1434('0x74')][_0x1434('0x75')](function(_0x22548a){return _0x16435d[_0x1434('0x6d')](_0x6aacf5,{'transaction':_0x22548a})[_0x1434('0x20')](function(){return BPromise[_0x1434('0x76')](_0x18edb2,function(_0x4a6074){return db[_0x1434('0x64')]['findOrCreate']({'where':{'UserId':_0x4a6074['id'],'ChatQueueId':_0x500fb6['params']['id']},'transaction':_0x22548a});});})[_0x1434('0x20')](function(){_0x18edb2[_0x1434('0x77')](function(_0x3da95f){socket[_0x1434('0x78')](_0x1434('0x79'),{'UserId':_0x3da95f['id'],'ChatQueueId':_0x16435d['id']});});});});});}})[_0x1434('0x20')](respondWithStatusCode(_0x1f6f73,null))[_0x1434('0x2a')](handleError(_0x1f6f73,null));};exports[_0x1434('0x7a')]=function(_0x208823,_0x660b96,_0x25dbf0){return db[_0x1434('0x6b')]['findAll']({'where':{'id':_0x208823['query']['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0x1434('0x6f'),'attributes':['id'],'raw':!![]}]})[_0x1434('0x20')](handleEntityNotFound(_0x660b96,null))[_0x1434('0x20')](function(_0x4724e5){var _0x5ca178=_[_0x1434('0x4e')](_0x4724e5,'id');var _0x356b49=[];var _0x40605c=[];var _0xb125df=squel[_0x1434('0x7b')]();_0xb125df[_0x1434('0x7c')](_0x1434('0x7d'))[_0x1434('0x7e')](_0x1434('0x7f'),'tq')['join'](_0x1434('0x80'),'ut',_0x1434('0x81'))[_0x1434('0x4b')]('ChatQueueId\x20=\x20?',_0x208823[_0x1434('0x53')]['id']);for(var _0x43db52=0x0;_0x43db52<_0x4724e5['length'];_0x43db52+=0x1){let _0x2f5c1f=_0x4724e5[_0x43db52];for(var _0x2ff151=0x0;_0x2ff151<_0x2f5c1f['Agents']['length'];_0x2ff151+=0x1){let _0x3a0be=_0x2f5c1f[_0x1434('0x6f')][_0x2ff151];var _0x30692c=_0xb125df['clone']();_0x30692c['where'](_0x1434('0x82'),_0x3a0be['id']);_0x40605c[_0x1434('0x83')](db[_0x1434('0x74')][_0x1434('0x41')](_0x30692c[_0x1434('0x84')](),{'type':db[_0x1434('0x74')][_0x1434('0x85')][_0x1434('0x86')]})[_0x1434('0x20')](function(_0x5c1f16){if(_0x5c1f16[_0x1434('0x46')]===0x1){return _0x3a0be['id'];}else{var _0x5a8b39=_['every'](_[_0x1434('0x4e')](_0x5c1f16,_0x1434('0x87')),function(_0x5d4bc2){return _[_0x1434('0x88')](_0x5ca178,_0x5d4bc2);});if(_0x5a8b39){return _0x3a0be['id'];}}}));}}return BPromise[_0x1434('0x89')](_0x40605c)[_0x1434('0x20')](function(_0x34ad0b){_0x356b49=_(_0x356b49)[_0x1434('0x8a')](_0x34ad0b)['compact']()[_0x1434('0x8b')]();return db[_0x1434('0x3d')][_0x1434('0x57')]({'where':{'id':_0x208823[_0x1434('0x53')]['id']}})['then'](function(_0x26069b){return db['sequelize'][_0x1434('0x75')](function(_0x1abfce){return _0x26069b[_0x1434('0x7a')](_0x208823[_0x1434('0x41')]['ids'],{'transaction':_0x1abfce})['then'](function(){if(!_[_0x1434('0x8c')](_0x356b49)){return _0x26069b[_0x1434('0x8d')](_0x356b49,{'transaction':_0x1abfce});}})['then'](function(){_0x356b49[_0x1434('0x77')](function(_0x3e25e5){socket[_0x1434('0x78')]('userChatQueue:remove',{'UserId':_0x3e25e5,'ChatQueueId':_0x26069b['id']});});});});});});})['then'](respondWithStatusCode(_0x660b96,null))[_0x1434('0x2a')](handleError(_0x660b96,null));};exports[_0x1434('0x8e')]=function(_0x55cfd8,_0x55341f,_0x1eb919){return db[_0x1434('0x3d')][_0x1434('0x57')]({'where':{'id':_0x55cfd8[_0x1434('0x53')]['id']}})[_0x1434('0x20')](handleEntityNotFound(_0x55341f,null))[_0x1434('0x20')](function(_0x18b48b){if(_0x18b48b){return _0x18b48b['addAgents'](_0x55cfd8['body'][_0x1434('0x8f')],_[_0x1434('0x90')](_0x55cfd8[_0x1434('0x59')],[_0x1434('0x8f'),'id'])||{})['spread'](function(_0x24b7ea){for(var _0x5cbd48=0x0;_0x5cbd48<_0x55cfd8[_0x1434('0x59')][_0x1434('0x8f')][_0x1434('0x46')];_0x5cbd48+=0x1){socket[_0x1434('0x78')]('userChatQueue:save',{'UserId':Number(_0x55cfd8['body'][_0x1434('0x8f')][_0x5cbd48]),'ChatQueueId':Number(_0x55cfd8[_0x1434('0x53')]['id'])});}return _0x24b7ea;});}})[_0x1434('0x20')](respondWithResult(_0x55341f,null))['catch'](handleError(_0x55341f,null));};exports[_0x1434('0x8d')]=function(_0x331988,_0x3bbc1a,_0x156b62){return db[_0x1434('0x3d')]['find']({'where':{'id':_0x331988[_0x1434('0x53')]['id']}})[_0x1434('0x20')](handleEntityNotFound(_0x3bbc1a,null))['then'](function(_0x1926de){if(_0x1926de){return _0x1926de[_0x1434('0x8d')](_0x331988['query'][_0x1434('0x8f')])[_0x1434('0x20')](function(){if(_[_0x1434('0x91')](_0x331988[_0x1434('0x41')][_0x1434('0x8f')])){for(var _0x2862ee=0x0;_0x2862ee<_0x331988[_0x1434('0x41')][_0x1434('0x8f')][_0x1434('0x46')];_0x2862ee+=0x1){socket[_0x1434('0x78')](_0x1434('0x92'),{'UserId':Number(_0x331988[_0x1434('0x41')][_0x1434('0x8f')][_0x2862ee]),'ChatQueueId':Number(_0x331988['params']['id'])});}}else{socket[_0x1434('0x78')]('userChatQueue:remove',{'UserId':Number(_0x331988[_0x1434('0x41')]['ids']),'ChatQueueId':Number(_0x331988[_0x1434('0x53')]['id'])});}});}})[_0x1434('0x20')](respondWithStatusCode(_0x3bbc1a,null))[_0x1434('0x2a')](handleError(_0x3bbc1a,null));};exports[_0x1434('0x93')]=function(_0x553b5e,_0x433218,_0x53bf62){var _0x171390={};var _0xaa2471={};var _0x5c6695;var _0x4c9fd2;return db[_0x1434('0x3d')][_0x1434('0x94')]({'where':{'id':_0x553b5e[_0x1434('0x53')]['id']}})[_0x1434('0x20')](handleEntityNotFound(_0x433218,null))[_0x1434('0x20')](function(_0x408aac){if(_0x408aac){_0x5c6695=_0x408aac;_0xaa2471['model']=_[_0x1434('0x42')](db[_0x1434('0x6e')][_0x1434('0x3e')]);_0xaa2471[_0x1434('0x41')]=_[_0x1434('0x42')](_0x553b5e[_0x1434('0x41')]);_0xaa2471[_0x1434('0x43')]=_[_0x1434('0x45')](_0xaa2471['model'],_0xaa2471[_0x1434('0x41')]);_0x171390['attributes']=_['intersection'](_0xaa2471[_0x1434('0x40')],qs['fields'](_0x553b5e[_0x1434('0x41')][_0x1434('0x54')]));_0x171390['attributes']=_0x171390[_0x1434('0x44')]['length']?_0x171390[_0x1434('0x44')]:_0xaa2471['model'];_0x171390[_0x1434('0x49')]=qs['sort'](_0x553b5e[_0x1434('0x41')][_0x1434('0x4a')]);_0x171390[_0x1434('0x4b')]=qs['filters'](_[_0x1434('0x4c')](_0x553b5e[_0x1434('0x41')],_0xaa2471['filters']));if(_0x553b5e[_0x1434('0x41')][_0x1434('0x4d')]){_0x171390['where']=_[_0x1434('0x55')](_0x171390[_0x1434('0x4b')],{'$or':_['map'](_0x171390[_0x1434('0x44')],function(_0x65b9b7){var _0x28d1ce={};_0x28d1ce[_0x65b9b7]={'$like':'%'+_0x553b5e['query']['filter']+'%'};return _0x28d1ce;})});}_0x171390=_[_0x1434('0x55')]({},_0x171390,_0x553b5e[_0x1434('0x56')]);return _0x5c6695[_0x1434('0x93')](_0x171390);}})[_0x1434('0x20')](function(_0xcfb37b){if(_0xcfb37b){_0x4c9fd2=_0xcfb37b[_0x1434('0x46')];if(!_0x553b5e[_0x1434('0x41')][_0x1434('0x47')]('nolimit')){_0x171390[_0x1434('0x30')]=qs[_0x1434('0x30')](_0x553b5e[_0x1434('0x41')]['limit']);_0x171390[_0x1434('0x31')]=qs[_0x1434('0x31')](_0x553b5e[_0x1434('0x41')][_0x1434('0x31')]);}return _0x5c6695[_0x1434('0x93')](_0x171390);}})[_0x1434('0x20')](function(_0x2c8f02){if(_0x2c8f02){return _0x2c8f02?{'count':_0x4c9fd2,'rows':_0x2c8f02}:null;}})['then'](respondWithResult(_0x433218,null))[_0x1434('0x2a')](handleError(_0x433218,null));};
\ No newline at end of file
+var _0x4627=['key','model','query','keys','intersection','attributes','fields','length','nolimit','sort','where','filter','merge','type','VIRTUAL','options','ChatQueue','include','findAll','rows','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','filters','pick','ChatQueueId','UserChatQueue','User','findAndCountAll','agent','chatPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','order','hasOwnProperty','ids','Agents','online','voicePause','interface','flatMap','sequelize','each','findOrCreate','forEach','emit','removeTeams','tq.TeamId','team_has_chat_queues','user_has_teams','ChatQueueId\x20=\x20?','clone','toString','QueryTypes','SELECT','every','TeamId','union','compact','value','isEmpty','removeAgents','userChatQueue:remove','addAgents','omit','spread','userChatQueue:save','isArray','getAgents','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','to-csv','../../components/auth/service','../../components/parsers/advancedSearch','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','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','stringify','error','code','message','request\x20sent','result','catch','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','destroy','get','UserProfileResource','end','stack','name','send','index','map','rawAttributes','fieldName'];(function(_0x4bacdc,_0x5d6cf0){var _0x5dd5cb=function(_0x7ecdbb){while(--_0x7ecdbb){_0x4bacdc['push'](_0x4bacdc['shift']());}};_0x5dd5cb(++_0x5d6cf0);}(_0x4627,0x188));var _0x7462=function(_0x53ccf2,_0x13cb67){_0x53ccf2=_0x53ccf2-0x0;var _0x5a2964=_0x4627[_0x53ccf2];return _0x5a2964;};'use strict';var emlformat=require(_0x7462('0x0'));var rimraf=require(_0x7462('0x1'));var zipdir=require(_0x7462('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7462('0x3'));var moment=require(_0x7462('0x4'));var BPromise=require(_0x7462('0x5'));var Mustache=require(_0x7462('0x6'));var util=require(_0x7462('0x7'));var path=require(_0x7462('0x8'));var sox=require(_0x7462('0x9'));var csv=require('to-csv');var ejs=require(_0x7462('0xa'));var fs=require('fs');var fs_extra=require(_0x7462('0xb'));var _=require(_0x7462('0xc'));var squel=require(_0x7462('0xd'));var crypto=require(_0x7462('0xe'));var jsforce=require(_0x7462('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x7462('0x10'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x7462('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x7462('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x7462('0x13'));var config=require(_0x7462('0x14'));var licenseUtil=require(_0x7462('0x15'));var db=require(_0x7462('0x16'))['db'];config[_0x7462('0x17')]=_[_0x7462('0x18')](config[_0x7462('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0x7462('0x19'))(new Redis(config[_0x7462('0x17')]));require(_0x7462('0x1a'))[_0x7462('0x1b')](socket);var jayson=require(_0x7462('0x1c'));var client=jayson[_0x7462('0x1d')][_0x7462('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x5a283d,_0x4eab87,_0x4bdeea,_0x30e3ce){return new BPromise(function(_0x3a7a32,_0x2c85c3){var _0x1c3e7c=_0x30e3ce||client;return _0x1c3e7c[_0x7462('0x1f')](_0x5a283d,_0x4bdeea)[_0x7462('0x20')](function(_0x5473d5){logger[_0x7462('0x21')](_0x7462('0x22'),_0x4eab87,'request\x20sent');logger[_0x7462('0x23')](_0x7462('0x24'),_0x4eab87,'request\x20sent',JSON[_0x7462('0x25')](_0x5473d5));if(_0x5473d5[_0x7462('0x26')]){if(_0x5473d5[_0x7462('0x26')][_0x7462('0x27')]===0x1f4){logger[_0x7462('0x26')](_0x7462('0x22'),_0x4eab87,_0x5473d5[_0x7462('0x26')][_0x7462('0x28')]);return _0x2c85c3(_0x5473d5[_0x7462('0x26')]['message']);}logger[_0x7462('0x26')](_0x7462('0x22'),_0x4eab87,_0x5473d5['error'][_0x7462('0x28')]);return _0x3a7a32(_0x5473d5['error'][_0x7462('0x28')]);}else{logger[_0x7462('0x21')](_0x7462('0x22'),_0x4eab87,_0x7462('0x29'));_0x3a7a32(_0x5473d5[_0x7462('0x2a')][_0x7462('0x28')]);}})[_0x7462('0x2b')](function(_0x117536){logger[_0x7462('0x26')](_0x7462('0x22'),_0x4eab87,_0x117536);_0x2c85c3(_0x117536);});});}function respondWithStatusCode(_0x38d843,_0xbefb35){_0xbefb35=_0xbefb35||0xcc;return function(_0x967d1){if(_0x967d1){return _0x38d843[_0x7462('0x2c')](_0xbefb35);}return _0x38d843[_0x7462('0x2d')](_0xbefb35)['end']();};}function respondWithResult(_0x184e18,_0x346346){_0x346346=_0x346346||0xc8;return function(_0x55382f){if(_0x55382f){return _0x184e18['status'](_0x346346)[_0x7462('0x2e')](_0x55382f);}};}function respondWithFilteredResult(_0x17c671,_0x37e5a5){return function(_0x4d064f){if(_0x4d064f){var _0x4ff0bb=typeof _0x37e5a5[_0x7462('0x2f')]===_0x7462('0x30')&&typeof _0x37e5a5[_0x7462('0x31')]===_0x7462('0x30');var _0x1aea99=_0x4d064f[_0x7462('0x32')];var _0x557b71=_0x4ff0bb?0x0:_0x37e5a5[_0x7462('0x2f')];var _0x59d968=_0x4ff0bb?_0x4d064f['count']:_0x37e5a5[_0x7462('0x2f')]+_0x37e5a5[_0x7462('0x31')];var _0x1b228f;if(_0x59d968>=_0x1aea99){_0x59d968=_0x1aea99;_0x1b228f=0xc8;}else{_0x1b228f=0xce;}_0x17c671['status'](_0x1b228f);return _0x17c671[_0x7462('0x33')](_0x7462('0x34'),_0x557b71+'-'+_0x59d968+'/'+_0x1aea99)[_0x7462('0x2e')](_0x4d064f);}return null;};}function patchUpdates(_0x18c907){return function(_0x560db8){try{jsonpatch['apply'](_0x560db8,_0x18c907,!![]);}catch(_0x2f47e1){return BPromise[_0x7462('0x35')](_0x2f47e1);}return _0x560db8[_0x7462('0x36')]();};}function saveUpdates(_0x3e622f,_0x48835c){return function(_0x23fb6c){if(_0x23fb6c){return _0x23fb6c[_0x7462('0x37')](_0x3e622f)[_0x7462('0x20')](function(_0x4558fe){return _0x4558fe;});}return null;};}function removeEntity(_0x18fcee,_0x3d48ea){return function(_0x35ccee){if(_0x35ccee){return _0x35ccee[_0x7462('0x38')]()[_0x7462('0x20')](function(){var _0x2d5471=_0x35ccee[_0x7462('0x39')]({'plain':!![]});var _0xe29c8f='ChatQueues';return db[_0x7462('0x3a')][_0x7462('0x38')]({'where':{'type':_0xe29c8f,'resourceId':_0x2d5471['id']}})['then'](function(){return _0x35ccee;});})['then'](function(){_0x18fcee[_0x7462('0x2d')](0xcc)[_0x7462('0x3b')]();});}};}function handleEntityNotFound(_0x8a8a2d,_0x3350a6){return function(_0x3f48a8){if(!_0x3f48a8){_0x8a8a2d[_0x7462('0x2c')](0x194);}return _0x3f48a8;};}function handleError(_0x2f50ee,_0x36e9f7){_0x36e9f7=_0x36e9f7||0x1f4;return function(_0x1c3ede){logger[_0x7462('0x26')](_0x1c3ede[_0x7462('0x3c')]);if(_0x1c3ede[_0x7462('0x3d')]){delete _0x1c3ede[_0x7462('0x3d')];}_0x2f50ee[_0x7462('0x2d')](_0x36e9f7)[_0x7462('0x3e')](_0x1c3ede);};}exports[_0x7462('0x3f')]=function(_0x5b8ced,_0x5af497){var _0x574f50={},_0x446ac3={},_0x52c6be={'count':0x0,'rows':[]};var _0x229077=_[_0x7462('0x40')](db['ChatQueue'][_0x7462('0x41')],function(_0x4abb2c){return{'name':_0x4abb2c[_0x7462('0x42')],'type':_0x4abb2c['type'][_0x7462('0x43')]};});_0x446ac3[_0x7462('0x44')]=_['map'](_0x229077,_0x7462('0x3d'));_0x446ac3[_0x7462('0x45')]=_[_0x7462('0x46')](_0x5b8ced[_0x7462('0x45')]);_0x446ac3['filters']=_[_0x7462('0x47')](_0x446ac3['model'],_0x446ac3['query']);_0x574f50[_0x7462('0x48')]=_['intersection'](_0x446ac3[_0x7462('0x44')],qs[_0x7462('0x49')](_0x5b8ced['query'][_0x7462('0x49')]));_0x574f50[_0x7462('0x48')]=_0x574f50['attributes'][_0x7462('0x4a')]?_0x574f50[_0x7462('0x48')]:_0x446ac3[_0x7462('0x44')];if(!_0x5b8ced[_0x7462('0x45')]['hasOwnProperty'](_0x7462('0x4b'))){_0x574f50[_0x7462('0x31')]=qs[_0x7462('0x31')](_0x5b8ced[_0x7462('0x45')][_0x7462('0x31')]);_0x574f50[_0x7462('0x2f')]=qs[_0x7462('0x2f')](_0x5b8ced['query'][_0x7462('0x2f')]);}_0x574f50['order']=qs[_0x7462('0x4c')](_0x5b8ced[_0x7462('0x45')][_0x7462('0x4c')]);_0x574f50[_0x7462('0x4d')]=qs['filters'](_['pick'](_0x5b8ced[_0x7462('0x45')],_0x446ac3['filters']),_0x229077);if(_0x5b8ced[_0x7462('0x45')][_0x7462('0x4e')]){_0x574f50[_0x7462('0x4d')]=_[_0x7462('0x4f')](_0x574f50[_0x7462('0x4d')],{'$or':_[_0x7462('0x40')](_0x229077,function(_0x32ffe9){if(_0x32ffe9[_0x7462('0x50')]!==_0x7462('0x51')){var _0x2e51c9={};_0x2e51c9[_0x32ffe9[_0x7462('0x3d')]]={'$like':'%'+_0x5b8ced[_0x7462('0x45')][_0x7462('0x4e')]+'%'};return _0x2e51c9;}})});}_0x574f50=_[_0x7462('0x4f')]({},_0x574f50,_0x5b8ced[_0x7462('0x52')]);var _0xac7139={'where':_0x574f50[_0x7462('0x4d')]};return db[_0x7462('0x53')][_0x7462('0x32')](_0xac7139)['then'](function(_0x46d192){_0x52c6be['count']=_0x46d192;if(_0x5b8ced[_0x7462('0x45')]['includeAll']){_0x574f50[_0x7462('0x54')]=[{'all':!![]}];}return db[_0x7462('0x53')][_0x7462('0x55')](_0x574f50);})[_0x7462('0x20')](function(_0x595492){_0x52c6be[_0x7462('0x56')]=_0x595492;return _0x52c6be;})[_0x7462('0x20')](respondWithFilteredResult(_0x5af497,_0x574f50))[_0x7462('0x2b')](handleError(_0x5af497,null));};exports[_0x7462('0x57')]=function(_0x5cd4b7,_0x34f92e){var _0x522e57={'raw':!![],'where':{'id':_0x5cd4b7[_0x7462('0x58')]['id']}},_0x3ce5ac={};_0x3ce5ac[_0x7462('0x44')]=_[_0x7462('0x46')](db[_0x7462('0x53')][_0x7462('0x41')]);_0x3ce5ac[_0x7462('0x45')]=_[_0x7462('0x46')](_0x5cd4b7[_0x7462('0x45')]);_0x3ce5ac['filters']=_['intersection'](_0x3ce5ac[_0x7462('0x44')],_0x3ce5ac['query']);_0x522e57['attributes']=_[_0x7462('0x47')](_0x3ce5ac[_0x7462('0x44')],qs[_0x7462('0x49')](_0x5cd4b7[_0x7462('0x45')][_0x7462('0x49')]));_0x522e57[_0x7462('0x48')]=_0x522e57[_0x7462('0x48')][_0x7462('0x4a')]?_0x522e57[_0x7462('0x48')]:_0x3ce5ac['model'];if(_0x5cd4b7['query']['includeAll']){_0x522e57[_0x7462('0x54')]=[{'all':!![]}];}_0x522e57=_[_0x7462('0x4f')]({},_0x522e57,_0x5cd4b7[_0x7462('0x52')]);return db[_0x7462('0x53')][_0x7462('0x59')](_0x522e57)['then'](handleEntityNotFound(_0x34f92e,null))['then'](respondWithResult(_0x34f92e,null))['catch'](handleError(_0x34f92e,null));};exports[_0x7462('0x5a')]=function(_0x30ab77,_0x2d6662){return db[_0x7462('0x53')][_0x7462('0x5a')](_0x30ab77[_0x7462('0x5b')],{})['then'](function(_0x14371a){var _0x5ccd2c=_0x30ab77[_0x7462('0x5c')][_0x7462('0x39')]({'plain':!![]});if(!_0x5ccd2c)throw new Error(_0x7462('0x5d'));if(_0x5ccd2c[_0x7462('0x5e')]===_0x7462('0x5c')){var _0x4b41b3=_0x14371a[_0x7462('0x39')]({'plain':!![]});var _0x5e29d4='ChatQueues';return db[_0x7462('0x5f')][_0x7462('0x59')]({'where':{'name':_0x5e29d4,'userProfileId':_0x5ccd2c[_0x7462('0x60')]},'raw':!![]})[_0x7462('0x20')](function(_0x253870){if(_0x253870&&_0x253870[_0x7462('0x61')]===0x0){return db[_0x7462('0x3a')][_0x7462('0x5a')]({'name':_0x4b41b3[_0x7462('0x3d')],'resourceId':_0x4b41b3['id'],'type':_0x253870[_0x7462('0x3d')],'sectionId':_0x253870['id']},{})['then'](function(){return _0x14371a;});}else{return _0x14371a;}})[_0x7462('0x2b')](function(_0x2629ea){logger[_0x7462('0x26')](_0x7462('0x62'),_0x2629ea);throw _0x2629ea;});}return _0x14371a;})['then'](respondWithResult(_0x2d6662,0xc9))[_0x7462('0x2b')](handleError(_0x2d6662,null));};exports[_0x7462('0x37')]=function(_0x158d05,_0x1dcd83){if(_0x158d05[_0x7462('0x5b')]['id']){delete _0x158d05['body']['id'];}return db[_0x7462('0x53')]['find']({'where':{'id':_0x158d05[_0x7462('0x58')]['id']}})['then'](handleEntityNotFound(_0x1dcd83,null))['then'](saveUpdates(_0x158d05[_0x7462('0x5b')],null))[_0x7462('0x20')](respondWithResult(_0x1dcd83,null))[_0x7462('0x2b')](handleError(_0x1dcd83,null));};exports['destroy']=function(_0x1468f4,_0x2c8e3d){return db[_0x7462('0x53')][_0x7462('0x59')]({'where':{'id':_0x1468f4['params']['id']}})[_0x7462('0x20')](handleEntityNotFound(_0x2c8e3d,null))[_0x7462('0x20')](removeEntity(_0x2c8e3d,null))[_0x7462('0x2b')](handleError(_0x2c8e3d,null));};exports[_0x7462('0x63')]=function(_0x3f558a,_0x4ddf84){return db[_0x7462('0x53')]['describe']()[_0x7462('0x20')](respondWithResult(_0x4ddf84,null))[_0x7462('0x2b')](handleError(_0x4ddf84,null));};exports[_0x7462('0x64')]=function(_0x4c572e,_0x11ed27,_0x5c7756){var _0x293728={'raw':!![],'where':{}},_0x219b17={},_0xc825bb;return db[_0x7462('0x53')][_0x7462('0x65')]({'where':{'id':_0x4c572e[_0x7462('0x58')]['id']}})[_0x7462('0x20')](handleEntityNotFound(_0x11ed27,null))[_0x7462('0x20')](function(_0x1f1fe6){if(_0x1f1fe6){_0xc825bb=_0x1f1fe6[_0x7462('0x39')]({'plain':!![]});_0x219b17[_0x7462('0x44')]=_[_0x7462('0x46')](db['UserChatQueue'][_0x7462('0x41')]);_0x219b17['query']=_[_0x7462('0x46')](_0x4c572e[_0x7462('0x45')]);_0x219b17[_0x7462('0x66')]=_[_0x7462('0x47')](_0x219b17[_0x7462('0x44')],_0x219b17[_0x7462('0x45')]);_0x293728[_0x7462('0x48')]=_[_0x7462('0x47')](_0x219b17[_0x7462('0x44')],qs[_0x7462('0x49')](_0x4c572e['query'][_0x7462('0x49')]));_0x293728['attributes']=_0x293728[_0x7462('0x48')][_0x7462('0x4a')]?_0x293728[_0x7462('0x48')]:_0x219b17[_0x7462('0x44')];if(!_0x4c572e['query']['hasOwnProperty']('nolimit')){_0x293728['limit']=qs[_0x7462('0x31')](_0x4c572e[_0x7462('0x45')][_0x7462('0x31')]);_0x293728[_0x7462('0x2f')]=qs[_0x7462('0x2f')](_0x4c572e[_0x7462('0x45')][_0x7462('0x2f')]);}_0x293728['order']=qs[_0x7462('0x4c')](_0x4c572e[_0x7462('0x45')][_0x7462('0x4c')]);_0x293728[_0x7462('0x4d')]=qs[_0x7462('0x66')](_[_0x7462('0x67')](_0x4c572e[_0x7462('0x45')],_0x219b17[_0x7462('0x66')]));_0x293728['where'][_0x7462('0x68')]=_0x1f1fe6['id'];if(_0x4c572e[_0x7462('0x45')][_0x7462('0x4e')]){_0x293728[_0x7462('0x4d')]=_['merge'](_0x293728['where'],{'$or':_[_0x7462('0x40')](_0x293728[_0x7462('0x48')],function(_0x173c4e){var _0x3bea61={};_0x3bea61[_0x173c4e]={'$like':'%'+_0x4c572e['query']['filter']+'%'};return _0x3bea61;})});}_0x293728=_[_0x7462('0x4f')]({},_0x293728,_0x4c572e[_0x7462('0x52')]);return db[_0x7462('0x69')][_0x7462('0x55')](_0x293728);}})[_0x7462('0x20')](function(_0x2326f9){if(_0x2326f9){return db[_0x7462('0x6a')][_0x7462('0x6b')]({'where':{'id':_['map'](_0x2326f9,'UserId'),'role':_0x7462('0x6c')},'attributes':['id',_0x7462('0x3d'),_0x7462('0x6d'),_0x7462('0x6e'),_0x7462('0x6f')]});}})['then'](function(_0x1faf99){if(_0x1faf99){return{'count':_0x1faf99['count'],'rows':_['map'](_0x1faf99[_0x7462('0x56')],function(_0x208241){return{'membername':_0x208241[_0x7462('0x3d')],'UserId':_0x208241['id'],'queue_name':_0xc825bb['name'],'ChatQueueId':_0xc825bb['id'],'interface':util[_0x7462('0x70')](_0x7462('0x71'),_0x7462('0x72'),_0x208241[_0x7462('0x3d')]),'penalty':0x0,'paused':_0x208241['chatPause'],'createdAt':_0x208241['createdAt'],'updatedAt':_0x208241[_0x7462('0x6e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x7462('0x20')](respondWithFilteredResult(_0x11ed27,_0x293728))[_0x7462('0x2b')](handleError(_0x11ed27,null));};exports[_0x7462('0x73')]=function(_0x5e07b6,_0x5a0ec4,_0x3797f2){var _0x4118f3={};var _0x52e3aa={};var _0x4e5446;var _0x4eb6ba;return db[_0x7462('0x53')][_0x7462('0x65')]({'where':{'id':_0x5e07b6[_0x7462('0x58')]['id']}})[_0x7462('0x20')](handleEntityNotFound(_0x5a0ec4,null))[_0x7462('0x20')](function(_0x160b14){if(_0x160b14){_0x4e5446=_0x160b14;_0x52e3aa[_0x7462('0x44')]=_[_0x7462('0x46')](db[_0x7462('0x74')]['rawAttributes']);_0x52e3aa[_0x7462('0x45')]=_['keys'](_0x5e07b6['query']);_0x52e3aa['filters']=_['intersection'](_0x52e3aa[_0x7462('0x44')],_0x52e3aa[_0x7462('0x45')]);_0x4118f3[_0x7462('0x48')]=_[_0x7462('0x47')](_0x52e3aa[_0x7462('0x44')],qs[_0x7462('0x49')](_0x5e07b6['query'][_0x7462('0x49')]));_0x4118f3[_0x7462('0x48')]=_0x4118f3['attributes'][_0x7462('0x4a')]?_0x4118f3[_0x7462('0x48')]:_0x52e3aa['model'];_0x4118f3[_0x7462('0x75')]=qs['sort'](_0x5e07b6[_0x7462('0x45')]['sort']);_0x4118f3['where']=qs[_0x7462('0x66')](_[_0x7462('0x67')](_0x5e07b6[_0x7462('0x45')],_0x52e3aa[_0x7462('0x66')]));if(_0x5e07b6[_0x7462('0x45')][_0x7462('0x4e')]){_0x4118f3['where']=_['merge'](_0x4118f3[_0x7462('0x4d')],{'$or':_['map'](_0x4118f3[_0x7462('0x48')],function(_0x19ff56){var _0x3d4ecc={};_0x3d4ecc[_0x19ff56]={'$like':'%'+_0x5e07b6[_0x7462('0x45')][_0x7462('0x4e')]+'%'};return _0x3d4ecc;})});}_0x4118f3=_[_0x7462('0x4f')]({},_0x4118f3,_0x5e07b6[_0x7462('0x52')]);return _0x4e5446[_0x7462('0x73')](_0x4118f3);}})[_0x7462('0x20')](function(_0x3d8265){if(_0x3d8265){_0x4eb6ba=_0x3d8265[_0x7462('0x4a')];if(!_0x5e07b6[_0x7462('0x45')][_0x7462('0x76')](_0x7462('0x4b'))){_0x4118f3[_0x7462('0x31')]=qs[_0x7462('0x31')](_0x5e07b6[_0x7462('0x45')]['limit']);_0x4118f3[_0x7462('0x2f')]=qs[_0x7462('0x2f')](_0x5e07b6['query']['offset']);}return _0x4e5446[_0x7462('0x73')](_0x4118f3);}})[_0x7462('0x20')](function(_0x47acd5){if(_0x47acd5){return _0x47acd5?{'count':_0x4eb6ba,'rows':_0x47acd5}:null;}})['then'](respondWithResult(_0x5a0ec4,null))[_0x7462('0x2b')](handleError(_0x5a0ec4,null));};exports['addTeams']=function(_0x52a7e1,_0x24ef29,_0x2661e0){var _0x4a9ccd=_0x52a7e1[_0x7462('0x5b')][_0x7462('0x77')];return db['Team'][_0x7462('0x55')]({'where':{'id':_0x4a9ccd},'attributes':['id'],'include':[{'model':db['User'],'as':_0x7462('0x78'),'attributes':['id',_0x7462('0x3d'),_0x7462('0x79'),_0x7462('0x7a'),_0x7462('0x7b')],'raw':!![]}]})[_0x7462('0x20')](function(_0x50f150){if(_0x50f150){var _0x2abd0a=_[_0x7462('0x7c')](_0x50f150,function(_0x25e9ac){var _0x518925=_0x25e9ac[_0x7462('0x39')]({'plain':!![]});return _0x518925[_0x7462('0x78')];});return db[_0x7462('0x53')][_0x7462('0x59')]({'where':{'id':_0x52a7e1[_0x7462('0x58')]['id']}})['then'](function(_0x12249f){return db[_0x7462('0x7d')]['transaction'](function(_0x50bb37){return _0x12249f['addTeams'](_0x4a9ccd,{'transaction':_0x50bb37})[_0x7462('0x20')](function(){return BPromise[_0x7462('0x7e')](_0x2abd0a,function(_0x5f144a){return db[_0x7462('0x69')][_0x7462('0x7f')]({'where':{'UserId':_0x5f144a['id'],'ChatQueueId':_0x52a7e1[_0x7462('0x58')]['id']},'transaction':_0x50bb37});});})[_0x7462('0x20')](function(){_0x2abd0a[_0x7462('0x80')](function(_0x1fffa3){socket[_0x7462('0x81')]('userChatQueue:save',{'UserId':_0x1fffa3['id'],'ChatQueueId':_0x12249f['id']});});});});});}})[_0x7462('0x20')](respondWithStatusCode(_0x24ef29,null))[_0x7462('0x2b')](handleError(_0x24ef29,null));};exports[_0x7462('0x82')]=function(_0x40a284,_0x22c16b,_0x277286){return db[_0x7462('0x74')][_0x7462('0x55')]({'where':{'id':_0x40a284['query']['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x7462('0x20')](handleEntityNotFound(_0x22c16b,null))[_0x7462('0x20')](function(_0x29b2eb){var _0x591ab3=_[_0x7462('0x40')](_0x29b2eb,'id');var _0x36334f=[];var _0x54cba9=[];var _0x5ce85f=squel['select']();_0x5ce85f['field'](_0x7462('0x83'))['from'](_0x7462('0x84'),'tq')['join'](_0x7462('0x85'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0x7462('0x86'),_0x40a284['params']['id']);for(var _0x56ee0b=0x0;_0x56ee0b<_0x29b2eb[_0x7462('0x4a')];_0x56ee0b+=0x1){let _0x527c8c=_0x29b2eb[_0x56ee0b];for(var _0x443021=0x0;_0x443021<_0x527c8c['Agents']['length'];_0x443021+=0x1){let _0x25c36c=_0x527c8c[_0x7462('0x78')][_0x443021];var _0x51c097=_0x5ce85f[_0x7462('0x87')]();_0x51c097[_0x7462('0x4d')]('ut.UserId\x20=\x20?',_0x25c36c['id']);_0x54cba9['push'](db[_0x7462('0x7d')][_0x7462('0x45')](_0x51c097[_0x7462('0x88')](),{'type':db[_0x7462('0x7d')][_0x7462('0x89')][_0x7462('0x8a')]})['then'](function(_0x1d1dac){if(_0x1d1dac['length']===0x1){return _0x25c36c['id'];}else{var _0xeabf6=_[_0x7462('0x8b')](_['map'](_0x1d1dac,_0x7462('0x8c')),function(_0x1cc476){return _['includes'](_0x591ab3,_0x1cc476);});if(_0xeabf6){return _0x25c36c['id'];}}}));}}return BPromise['all'](_0x54cba9)[_0x7462('0x20')](function(_0x4d7e92){_0x36334f=_(_0x36334f)[_0x7462('0x8d')](_0x4d7e92)[_0x7462('0x8e')]()[_0x7462('0x8f')]();return db['ChatQueue'][_0x7462('0x59')]({'where':{'id':_0x40a284[_0x7462('0x58')]['id']}})[_0x7462('0x20')](function(_0x4cc675){return db[_0x7462('0x7d')]['transaction'](function(_0x3cca61){return _0x4cc675['removeTeams'](_0x40a284[_0x7462('0x45')][_0x7462('0x77')],{'transaction':_0x3cca61})[_0x7462('0x20')](function(){if(!_[_0x7462('0x90')](_0x36334f)){return _0x4cc675[_0x7462('0x91')](_0x36334f,{'transaction':_0x3cca61});}})[_0x7462('0x20')](function(){_0x36334f[_0x7462('0x80')](function(_0x2095dd){socket[_0x7462('0x81')](_0x7462('0x92'),{'UserId':_0x2095dd,'ChatQueueId':_0x4cc675['id']});});});});});});})[_0x7462('0x20')](respondWithStatusCode(_0x22c16b,null))[_0x7462('0x2b')](handleError(_0x22c16b,null));};exports[_0x7462('0x93')]=function(_0x472213,_0x38cab6,_0x392501){return db[_0x7462('0x53')][_0x7462('0x59')]({'where':{'id':_0x472213['params']['id']}})[_0x7462('0x20')](handleEntityNotFound(_0x38cab6,null))['then'](function(_0x3603a9){if(_0x3603a9){return _0x3603a9[_0x7462('0x93')](_0x472213[_0x7462('0x5b')][_0x7462('0x77')],_[_0x7462('0x94')](_0x472213[_0x7462('0x5b')],[_0x7462('0x77'),'id'])||{})[_0x7462('0x95')](function(_0x5335da){for(var _0xa33f9f=0x0;_0xa33f9f<_0x472213[_0x7462('0x5b')]['ids'][_0x7462('0x4a')];_0xa33f9f+=0x1){socket['emit'](_0x7462('0x96'),{'UserId':Number(_0x472213[_0x7462('0x5b')][_0x7462('0x77')][_0xa33f9f]),'ChatQueueId':Number(_0x472213[_0x7462('0x58')]['id'])});}return _0x5335da;});}})[_0x7462('0x20')](respondWithResult(_0x38cab6,null))[_0x7462('0x2b')](handleError(_0x38cab6,null));};exports[_0x7462('0x91')]=function(_0x376826,_0x5e498e,_0x372e1a){return db[_0x7462('0x53')]['find']({'where':{'id':_0x376826[_0x7462('0x58')]['id']}})[_0x7462('0x20')](handleEntityNotFound(_0x5e498e,null))[_0x7462('0x20')](function(_0x43de00){if(_0x43de00){return _0x43de00[_0x7462('0x91')](_0x376826['query'][_0x7462('0x77')])[_0x7462('0x20')](function(){if(_[_0x7462('0x97')](_0x376826[_0x7462('0x45')][_0x7462('0x77')])){for(var _0x1063ca=0x0;_0x1063ca<_0x376826['query'][_0x7462('0x77')][_0x7462('0x4a')];_0x1063ca+=0x1){socket[_0x7462('0x81')](_0x7462('0x92'),{'UserId':Number(_0x376826[_0x7462('0x45')][_0x7462('0x77')][_0x1063ca]),'ChatQueueId':Number(_0x376826['params']['id'])});}}else{socket['emit'](_0x7462('0x92'),{'UserId':Number(_0x376826[_0x7462('0x45')][_0x7462('0x77')]),'ChatQueueId':Number(_0x376826['params']['id'])});}});}})[_0x7462('0x20')](respondWithStatusCode(_0x5e498e,null))[_0x7462('0x2b')](handleError(_0x5e498e,null));};exports[_0x7462('0x98')]=function(_0x5d0b0f,_0x548a95,_0x35bc6b){var _0x57146c={};var _0x26084b={};var _0x3fb3dc;var _0x223855;return db[_0x7462('0x53')]['findOne']({'where':{'id':_0x5d0b0f[_0x7462('0x58')]['id']}})[_0x7462('0x20')](handleEntityNotFound(_0x548a95,null))['then'](function(_0x2ae572){if(_0x2ae572){_0x3fb3dc=_0x2ae572;_0x26084b[_0x7462('0x44')]=_[_0x7462('0x46')](db[_0x7462('0x6a')][_0x7462('0x41')]);_0x26084b['query']=_[_0x7462('0x46')](_0x5d0b0f[_0x7462('0x45')]);_0x26084b[_0x7462('0x66')]=_[_0x7462('0x47')](_0x26084b[_0x7462('0x44')],_0x26084b['query']);_0x57146c[_0x7462('0x48')]=_[_0x7462('0x47')](_0x26084b['model'],qs[_0x7462('0x49')](_0x5d0b0f[_0x7462('0x45')][_0x7462('0x49')]));_0x57146c[_0x7462('0x48')]=_0x57146c[_0x7462('0x48')][_0x7462('0x4a')]?_0x57146c[_0x7462('0x48')]:_0x26084b['model'];_0x57146c[_0x7462('0x75')]=qs[_0x7462('0x4c')](_0x5d0b0f['query'][_0x7462('0x4c')]);_0x57146c['where']=qs[_0x7462('0x66')](_[_0x7462('0x67')](_0x5d0b0f[_0x7462('0x45')],_0x26084b[_0x7462('0x66')]));if(_0x5d0b0f[_0x7462('0x45')][_0x7462('0x4e')]){_0x57146c['where']=_[_0x7462('0x4f')](_0x57146c[_0x7462('0x4d')],{'$or':_[_0x7462('0x40')](_0x57146c[_0x7462('0x48')],function(_0x43056f){var _0x6a3afc={};_0x6a3afc[_0x43056f]={'$like':'%'+_0x5d0b0f['query'][_0x7462('0x4e')]+'%'};return _0x6a3afc;})});}_0x57146c=_['merge']({},_0x57146c,_0x5d0b0f['options']);return _0x3fb3dc[_0x7462('0x98')](_0x57146c);}})[_0x7462('0x20')](function(_0x22d570){if(_0x22d570){_0x223855=_0x22d570[_0x7462('0x4a')];if(!_0x5d0b0f[_0x7462('0x45')]['hasOwnProperty']('nolimit')){_0x57146c['limit']=qs[_0x7462('0x31')](_0x5d0b0f[_0x7462('0x45')][_0x7462('0x31')]);_0x57146c[_0x7462('0x2f')]=qs[_0x7462('0x2f')](_0x5d0b0f[_0x7462('0x45')][_0x7462('0x2f')]);}return _0x3fb3dc[_0x7462('0x98')](_0x57146c);}})[_0x7462('0x20')](function(_0x25af10){if(_0x25af10){return _0x25af10?{'count':_0x223855,'rows':_0x25af10}:null;}})[_0x7462('0x20')](respondWithResult(_0x548a95,null))[_0x7462('0x2b')](handleError(_0x548a95,null));};
\ No newline at end of file