Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 20a7675..94b5de3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6b2b=['ChatQueueId','User','findAndCountAll','UserId','chatPause','createdAt','rows','%s/%s','SIP','updatedAt','findOne','Team','getTeams','addTeams','ids','Agents','online','voicePause','interface','flatMap','sequelize','findOrCreate','forEach','userChatQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','all','union','value','transaction','isEmpty','removeAgents','userChatQueue:remove','addAgents','omit','spread','emit','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','util','path','to-csv','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','socket.io-emitter','jayson/promise','client','http','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','get','ChatQueues','UserProfileResource','stack','name','send','map','rawAttributes','type','key','model','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','ChatQueue','findAll','show','params','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserChatQueue','keys','order'];(function(_0x1112d3,_0x166065){var _0x32f07e=function(_0x28b3b4){while(--_0x28b3b4){_0x1112d3['push'](_0x1112d3['shift']());}};_0x32f07e(++_0x166065);}(_0x6b2b,0x169));var _0xb6b2=function(_0xc67528,_0x24e2fb){_0xc67528=_0xc67528-0x0;var _0x38e26d=_0x6b2b[_0xc67528];return _0x38e26d;};'use strict';var emlformat=require(_0xb6b2('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xb6b2('0x1'));var jsonpatch=require(_0xb6b2('0x2'));var rp=require(_0xb6b2('0x3'));var moment=require(_0xb6b2('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xb6b2('0x5'));var path=require(_0xb6b2('0x6'));var sox=require('sox');var csv=require(_0xb6b2('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb6b2('0x8'));var _=require('lodash');var squel=require(_0xb6b2('0x9'));var crypto=require(_0xb6b2('0xa'));var jsforce=require(_0xb6b2('0xb'));var deskjs=require(_0xb6b2('0xc'));var toCsv=require(_0xb6b2('0x7'));var querystring=require(_0xb6b2('0xd'));var Papa=require(_0xb6b2('0xe'));var Redis=require(_0xb6b2('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xb6b2('0x10'));var as=require(_0xb6b2('0x11'));var hardwareService=require(_0xb6b2('0x12'));var logger=require(_0xb6b2('0x13'))(_0xb6b2('0x14'));var utils=require(_0xb6b2('0x15'));var config=require(_0xb6b2('0x16'));var licenseUtil=require(_0xb6b2('0x17'));var db=require('../../mysqldb')['db'];config[_0xb6b2('0x18')]=_[_0xb6b2('0x19')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xb6b2('0x1a'))(new Redis(config['redis']));require('./chatQueue.socket')['register'](socket);var jayson=require(_0xb6b2('0x1b'));var client=jayson[_0xb6b2('0x1c')][_0xb6b2('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x26db37,_0x310cd4,_0x56f63e,_0x211a8f){return new BPromise(function(_0x21ac27,_0x9dc51e){var _0x17578b=_0x211a8f||client;return _0x17578b[_0xb6b2('0x1e')](_0x26db37,_0x56f63e)[_0xb6b2('0x1f')](function(_0xd361c){logger[_0xb6b2('0x20')](_0xb6b2('0x21'),_0x310cd4,_0xb6b2('0x22'));logger['debug'](_0xb6b2('0x23'),_0x310cd4,_0xb6b2('0x22'),JSON[_0xb6b2('0x24')](_0xd361c));if(_0xd361c['error']){if(_0xd361c[_0xb6b2('0x25')]['code']===0x1f4){logger[_0xb6b2('0x25')](_0xb6b2('0x21'),_0x310cd4,_0xd361c['error'][_0xb6b2('0x26')]);return _0x9dc51e(_0xd361c[_0xb6b2('0x25')][_0xb6b2('0x26')]);}logger[_0xb6b2('0x25')](_0xb6b2('0x21'),_0x310cd4,_0xd361c[_0xb6b2('0x25')][_0xb6b2('0x26')]);return _0x21ac27(_0xd361c[_0xb6b2('0x25')]['message']);}else{logger['info'](_0xb6b2('0x21'),_0x310cd4,_0xb6b2('0x22'));_0x21ac27(_0xd361c[_0xb6b2('0x27')]['message']);}})[_0xb6b2('0x28')](function(_0xcf2475){logger[_0xb6b2('0x25')](_0xb6b2('0x21'),_0x310cd4,_0xcf2475);_0x9dc51e(_0xcf2475);});});}function respondWithStatusCode(_0x591bb5,_0x7f02a6){_0x7f02a6=_0x7f02a6||0xcc;return function(_0x230779){if(_0x230779){return _0x591bb5[_0xb6b2('0x29')](_0x7f02a6);}return _0x591bb5[_0xb6b2('0x2a')](_0x7f02a6)['end']();};}function respondWithResult(_0x5bc9f3,_0x596faf){_0x596faf=_0x596faf||0xc8;return function(_0x454a46){if(_0x454a46){return _0x5bc9f3[_0xb6b2('0x2a')](_0x596faf)[_0xb6b2('0x2b')](_0x454a46);}};}function respondWithFilteredResult(_0x5b5e59,_0x5b6bb2){return function(_0x4d887f){if(_0x4d887f){var _0xafc24d=typeof _0x5b6bb2[_0xb6b2('0x2c')]===_0xb6b2('0x2d')&&typeof _0x5b6bb2[_0xb6b2('0x2e')]===_0xb6b2('0x2d');var _0x59b94f=_0x4d887f[_0xb6b2('0x2f')];var _0x3b2983=_0xafc24d?0x0:_0x5b6bb2[_0xb6b2('0x2c')];var _0x1a53db=_0xafc24d?_0x4d887f[_0xb6b2('0x2f')]:_0x5b6bb2[_0xb6b2('0x2c')]+_0x5b6bb2[_0xb6b2('0x2e')];var _0x4382f4;if(_0x1a53db>=_0x59b94f){_0x1a53db=_0x59b94f;_0x4382f4=0xc8;}else{_0x4382f4=0xce;}_0x5b5e59[_0xb6b2('0x2a')](_0x4382f4);return _0x5b5e59[_0xb6b2('0x30')](_0xb6b2('0x31'),_0x3b2983+'-'+_0x1a53db+'/'+_0x59b94f)[_0xb6b2('0x2b')](_0x4d887f);}return null;};}function patchUpdates(_0x1f83b2){return function(_0x2bff3a){try{jsonpatch[_0xb6b2('0x32')](_0x2bff3a,_0x1f83b2,!![]);}catch(_0x1fc8b3){return BPromise[_0xb6b2('0x33')](_0x1fc8b3);}return _0x2bff3a[_0xb6b2('0x34')]();};}function saveUpdates(_0x575a08,_0x384dc6){return function(_0x1a1639){if(_0x1a1639){return _0x1a1639[_0xb6b2('0x35')](_0x575a08)[_0xb6b2('0x1f')](function(_0x19e8f3){return _0x19e8f3;});}return null;};}function removeEntity(_0x187174,_0x215ece){return function(_0x4454d5){if(_0x4454d5){return _0x4454d5[_0xb6b2('0x36')]()[_0xb6b2('0x1f')](function(){var _0x232c03=_0x4454d5[_0xb6b2('0x37')]({'plain':!![]});var _0x495fed=_0xb6b2('0x38');return db[_0xb6b2('0x39')][_0xb6b2('0x36')]({'where':{'type':_0x495fed,'resourceId':_0x232c03['id']}})[_0xb6b2('0x1f')](function(){return _0x4454d5;});})[_0xb6b2('0x1f')](function(){_0x187174[_0xb6b2('0x2a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4af95e,_0x5a1642){return function(_0x41838d){if(!_0x41838d){_0x4af95e[_0xb6b2('0x29')](0x194);}return _0x41838d;};}function handleError(_0x388fe0,_0x5bbafd){_0x5bbafd=_0x5bbafd||0x1f4;return function(_0x477962){logger[_0xb6b2('0x25')](_0x477962[_0xb6b2('0x3a')]);if(_0x477962[_0xb6b2('0x3b')]){delete _0x477962[_0xb6b2('0x3b')];}_0x388fe0[_0xb6b2('0x2a')](_0x5bbafd)[_0xb6b2('0x3c')](_0x477962);};}exports['index']=function(_0xbcc8fe,_0x20d5e4){var _0x5a1b7e={},_0x220fe7={},_0x3cf5b8={'count':0x0,'rows':[]};var _0x122586=_[_0xb6b2('0x3d')](db['ChatQueue'][_0xb6b2('0x3e')],function(_0x5ccbcd){return{'name':_0x5ccbcd['fieldName'],'type':_0x5ccbcd[_0xb6b2('0x3f')][_0xb6b2('0x40')]};});_0x220fe7[_0xb6b2('0x41')]=_[_0xb6b2('0x3d')](_0x122586,_0xb6b2('0x3b'));_0x220fe7[_0xb6b2('0x42')]=_['keys'](_0xbcc8fe[_0xb6b2('0x42')]);_0x220fe7[_0xb6b2('0x43')]=_['intersection'](_0x220fe7['model'],_0x220fe7[_0xb6b2('0x42')]);_0x5a1b7e[_0xb6b2('0x44')]=_[_0xb6b2('0x45')](_0x220fe7['model'],qs[_0xb6b2('0x46')](_0xbcc8fe[_0xb6b2('0x42')]['fields']));_0x5a1b7e[_0xb6b2('0x44')]=_0x5a1b7e[_0xb6b2('0x44')][_0xb6b2('0x47')]?_0x5a1b7e[_0xb6b2('0x44')]:_0x220fe7['model'];if(!_0xbcc8fe['query'][_0xb6b2('0x48')](_0xb6b2('0x49'))){_0x5a1b7e[_0xb6b2('0x2e')]=qs[_0xb6b2('0x2e')](_0xbcc8fe[_0xb6b2('0x42')][_0xb6b2('0x2e')]);_0x5a1b7e[_0xb6b2('0x2c')]=qs[_0xb6b2('0x2c')](_0xbcc8fe[_0xb6b2('0x42')][_0xb6b2('0x2c')]);}_0x5a1b7e['order']=qs[_0xb6b2('0x4a')](_0xbcc8fe[_0xb6b2('0x42')]['sort']);_0x5a1b7e[_0xb6b2('0x4b')]=qs[_0xb6b2('0x43')](_[_0xb6b2('0x4c')](_0xbcc8fe[_0xb6b2('0x42')],_0x220fe7[_0xb6b2('0x43')]),_0x122586);if(_0xbcc8fe[_0xb6b2('0x42')][_0xb6b2('0x4d')]){_0x5a1b7e[_0xb6b2('0x4b')]=_[_0xb6b2('0x4e')](_0x5a1b7e[_0xb6b2('0x4b')],{'$or':_[_0xb6b2('0x3d')](_0x122586,function(_0x4150c0){if(_0x4150c0[_0xb6b2('0x3f')]!==_0xb6b2('0x4f')){var _0x33a28b={};_0x33a28b[_0x4150c0[_0xb6b2('0x3b')]]={'$like':'%'+_0xbcc8fe['query']['filter']+'%'};return _0x33a28b;}})});}_0x5a1b7e=_['merge']({},_0x5a1b7e,_0xbcc8fe[_0xb6b2('0x50')]);var _0x412bc2={'where':_0x5a1b7e[_0xb6b2('0x4b')]};return db['ChatQueue']['count'](_0x412bc2)[_0xb6b2('0x1f')](function(_0x4ffa64){_0x3cf5b8['count']=_0x4ffa64;if(_0xbcc8fe[_0xb6b2('0x42')][_0xb6b2('0x51')]){_0x5a1b7e['include']=[{'all':!![]}];}return db[_0xb6b2('0x52')][_0xb6b2('0x53')](_0x5a1b7e);})['then'](function(_0x255af2){_0x3cf5b8['rows']=_0x255af2;return _0x3cf5b8;})[_0xb6b2('0x1f')](respondWithFilteredResult(_0x20d5e4,_0x5a1b7e))[_0xb6b2('0x28')](handleError(_0x20d5e4,null));};exports[_0xb6b2('0x54')]=function(_0x11f624,_0x2e6da0){var _0x15a403={'raw':!![],'where':{'id':_0x11f624[_0xb6b2('0x55')]['id']}},_0x4c3cd9={};_0x4c3cd9[_0xb6b2('0x41')]=_['keys'](db[_0xb6b2('0x52')][_0xb6b2('0x3e')]);_0x4c3cd9['query']=_['keys'](_0x11f624[_0xb6b2('0x42')]);_0x4c3cd9['filters']=_['intersection'](_0x4c3cd9[_0xb6b2('0x41')],_0x4c3cd9['query']);_0x15a403['attributes']=_[_0xb6b2('0x45')](_0x4c3cd9[_0xb6b2('0x41')],qs[_0xb6b2('0x46')](_0x11f624[_0xb6b2('0x42')][_0xb6b2('0x46')]));_0x15a403[_0xb6b2('0x44')]=_0x15a403['attributes'][_0xb6b2('0x47')]?_0x15a403[_0xb6b2('0x44')]:_0x4c3cd9[_0xb6b2('0x41')];if(_0x11f624[_0xb6b2('0x42')][_0xb6b2('0x51')]){_0x15a403[_0xb6b2('0x56')]=[{'all':!![]}];}_0x15a403=_['merge']({},_0x15a403,_0x11f624['options']);return db[_0xb6b2('0x52')][_0xb6b2('0x57')](_0x15a403)[_0xb6b2('0x1f')](handleEntityNotFound(_0x2e6da0,null))[_0xb6b2('0x1f')](respondWithResult(_0x2e6da0,null))[_0xb6b2('0x28')](handleError(_0x2e6da0,null));};exports[_0xb6b2('0x58')]=function(_0x44cb74,_0x50534a){return db[_0xb6b2('0x52')]['create'](_0x44cb74[_0xb6b2('0x59')],{})[_0xb6b2('0x1f')](function(_0x9b2970){var _0x554402=_0x44cb74[_0xb6b2('0x5a')]['get']({'plain':!![]});if(!_0x554402)throw new Error(_0xb6b2('0x5b'));if(_0x554402[_0xb6b2('0x5c')]===_0xb6b2('0x5a')){var _0x5366ad=_0x9b2970[_0xb6b2('0x37')]({'plain':!![]});var _0x5c09d5='ChatQueues';return db[_0xb6b2('0x5d')][_0xb6b2('0x57')]({'where':{'name':_0x5c09d5,'userProfileId':_0x554402['userProfileId']},'raw':!![]})[_0xb6b2('0x1f')](function(_0x50a9b0){if(_0x50a9b0&&_0x50a9b0[_0xb6b2('0x5e')]===0x0){return db[_0xb6b2('0x39')][_0xb6b2('0x58')]({'name':_0x5366ad[_0xb6b2('0x3b')],'resourceId':_0x5366ad['id'],'type':_0x50a9b0['name'],'sectionId':_0x50a9b0['id']},{})[_0xb6b2('0x1f')](function(){return _0x9b2970;});}else{return _0x9b2970;}})['catch'](function(_0x16fd38){logger['error'](_0xb6b2('0x5f'),_0x16fd38);throw _0x16fd38;});}return _0x9b2970;})[_0xb6b2('0x1f')](respondWithResult(_0x50534a,0xc9))[_0xb6b2('0x28')](handleError(_0x50534a,null));};exports[_0xb6b2('0x35')]=function(_0x335f83,_0x1b5647){if(_0x335f83[_0xb6b2('0x59')]['id']){delete _0x335f83[_0xb6b2('0x59')]['id'];}return db[_0xb6b2('0x52')][_0xb6b2('0x57')]({'where':{'id':_0x335f83[_0xb6b2('0x55')]['id']}})[_0xb6b2('0x1f')](handleEntityNotFound(_0x1b5647,null))['then'](saveUpdates(_0x335f83['body'],null))[_0xb6b2('0x1f')](respondWithResult(_0x1b5647,null))[_0xb6b2('0x28')](handleError(_0x1b5647,null));};exports['destroy']=function(_0x4b7320,_0x4f39f0){return db[_0xb6b2('0x52')][_0xb6b2('0x57')]({'where':{'id':_0x4b7320['params']['id']}})[_0xb6b2('0x1f')](handleEntityNotFound(_0x4f39f0,null))[_0xb6b2('0x1f')](removeEntity(_0x4f39f0,null))[_0xb6b2('0x28')](handleError(_0x4f39f0,null));};exports[_0xb6b2('0x60')]=function(_0x155e8f,_0x3b5fff){return db[_0xb6b2('0x52')][_0xb6b2('0x60')]()[_0xb6b2('0x1f')](respondWithResult(_0x3b5fff,null))[_0xb6b2('0x28')](handleError(_0x3b5fff,null));};exports[_0xb6b2('0x61')]=function(_0x384265,_0x3fa1ac,_0x2b760b){var _0x5bbb16={'raw':!![],'where':{}},_0x4b0338={},_0xfb0a22;return db[_0xb6b2('0x52')]['findOne']({'where':{'id':_0x384265['params']['id']}})[_0xb6b2('0x1f')](handleEntityNotFound(_0x3fa1ac,null))['then'](function(_0x377ce5){if(_0x377ce5){_0xfb0a22=_0x377ce5[_0xb6b2('0x37')]({'plain':!![]});_0x4b0338['model']=_['keys'](db[_0xb6b2('0x62')][_0xb6b2('0x3e')]);_0x4b0338[_0xb6b2('0x42')]=_[_0xb6b2('0x63')](_0x384265[_0xb6b2('0x42')]);_0x4b0338[_0xb6b2('0x43')]=_[_0xb6b2('0x45')](_0x4b0338[_0xb6b2('0x41')],_0x4b0338['query']);_0x5bbb16[_0xb6b2('0x44')]=_['intersection'](_0x4b0338[_0xb6b2('0x41')],qs[_0xb6b2('0x46')](_0x384265['query']['fields']));_0x5bbb16[_0xb6b2('0x44')]=_0x5bbb16[_0xb6b2('0x44')][_0xb6b2('0x47')]?_0x5bbb16[_0xb6b2('0x44')]:_0x4b0338[_0xb6b2('0x41')];if(!_0x384265[_0xb6b2('0x42')][_0xb6b2('0x48')](_0xb6b2('0x49'))){_0x5bbb16[_0xb6b2('0x2e')]=qs[_0xb6b2('0x2e')](_0x384265[_0xb6b2('0x42')][_0xb6b2('0x2e')]);_0x5bbb16[_0xb6b2('0x2c')]=qs[_0xb6b2('0x2c')](_0x384265['query'][_0xb6b2('0x2c')]);}_0x5bbb16[_0xb6b2('0x64')]=qs[_0xb6b2('0x4a')](_0x384265[_0xb6b2('0x42')][_0xb6b2('0x4a')]);_0x5bbb16['where']=qs[_0xb6b2('0x43')](_[_0xb6b2('0x4c')](_0x384265[_0xb6b2('0x42')],_0x4b0338[_0xb6b2('0x43')]));_0x5bbb16[_0xb6b2('0x4b')][_0xb6b2('0x65')]=_0x377ce5['id'];if(_0x384265[_0xb6b2('0x42')]['filter']){_0x5bbb16['where']=_['merge'](_0x5bbb16[_0xb6b2('0x4b')],{'$or':_[_0xb6b2('0x3d')](_0x5bbb16[_0xb6b2('0x44')],function(_0x4302b8){var _0x3973d0={};_0x3973d0[_0x4302b8]={'$like':'%'+_0x384265[_0xb6b2('0x42')][_0xb6b2('0x4d')]+'%'};return _0x3973d0;})});}_0x5bbb16=_[_0xb6b2('0x4e')]({},_0x5bbb16,_0x384265[_0xb6b2('0x50')]);return db[_0xb6b2('0x62')][_0xb6b2('0x53')](_0x5bbb16);}})[_0xb6b2('0x1f')](function(_0x35624a){if(_0x35624a){return db[_0xb6b2('0x66')][_0xb6b2('0x67')]({'where':{'id':_['map'](_0x35624a,_0xb6b2('0x68')),'role':'agent'},'attributes':['id',_0xb6b2('0x3b'),_0xb6b2('0x69'),'updatedAt',_0xb6b2('0x6a')]});}})[_0xb6b2('0x1f')](function(_0x54376f){if(_0x54376f){return{'count':_0x54376f[_0xb6b2('0x2f')],'rows':_[_0xb6b2('0x3d')](_0x54376f[_0xb6b2('0x6b')],function(_0x121343){return{'membername':_0x121343[_0xb6b2('0x3b')],'UserId':_0x121343['id'],'queue_name':_0xfb0a22[_0xb6b2('0x3b')],'ChatQueueId':_0xfb0a22['id'],'interface':util['format'](_0xb6b2('0x6c'),_0xb6b2('0x6d'),_0x121343[_0xb6b2('0x3b')]),'penalty':0x0,'paused':_0x121343[_0xb6b2('0x69')],'createdAt':_0x121343[_0xb6b2('0x6a')],'updatedAt':_0x121343[_0xb6b2('0x6e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xb6b2('0x1f')](respondWithFilteredResult(_0x3fa1ac,_0x5bbb16))[_0xb6b2('0x28')](handleError(_0x3fa1ac,null));};exports['getTeams']=function(_0x130020,_0x41694d,_0x222d72){var _0x28a9aa={};var _0x24a0c2={};var _0x5d7c27;var _0xe11aac;return db[_0xb6b2('0x52')][_0xb6b2('0x6f')]({'where':{'id':_0x130020[_0xb6b2('0x55')]['id']}})[_0xb6b2('0x1f')](handleEntityNotFound(_0x41694d,null))[_0xb6b2('0x1f')](function(_0x30eb1f){if(_0x30eb1f){_0x5d7c27=_0x30eb1f;_0x24a0c2[_0xb6b2('0x41')]=_[_0xb6b2('0x63')](db[_0xb6b2('0x70')][_0xb6b2('0x3e')]);_0x24a0c2[_0xb6b2('0x42')]=_[_0xb6b2('0x63')](_0x130020[_0xb6b2('0x42')]);_0x24a0c2[_0xb6b2('0x43')]=_[_0xb6b2('0x45')](_0x24a0c2[_0xb6b2('0x41')],_0x24a0c2['query']);_0x28a9aa[_0xb6b2('0x44')]=_[_0xb6b2('0x45')](_0x24a0c2[_0xb6b2('0x41')],qs[_0xb6b2('0x46')](_0x130020[_0xb6b2('0x42')][_0xb6b2('0x46')]));_0x28a9aa[_0xb6b2('0x44')]=_0x28a9aa[_0xb6b2('0x44')][_0xb6b2('0x47')]?_0x28a9aa['attributes']:_0x24a0c2['model'];_0x28a9aa['order']=qs[_0xb6b2('0x4a')](_0x130020['query']['sort']);_0x28a9aa['where']=qs[_0xb6b2('0x43')](_[_0xb6b2('0x4c')](_0x130020[_0xb6b2('0x42')],_0x24a0c2[_0xb6b2('0x43')]));if(_0x130020[_0xb6b2('0x42')][_0xb6b2('0x4d')]){_0x28a9aa[_0xb6b2('0x4b')]=_[_0xb6b2('0x4e')](_0x28a9aa[_0xb6b2('0x4b')],{'$or':_[_0xb6b2('0x3d')](_0x28a9aa[_0xb6b2('0x44')],function(_0x3a8069){var _0x5b44c0={};_0x5b44c0[_0x3a8069]={'$like':'%'+_0x130020['query']['filter']+'%'};return _0x5b44c0;})});}_0x28a9aa=_[_0xb6b2('0x4e')]({},_0x28a9aa,_0x130020[_0xb6b2('0x50')]);return _0x5d7c27[_0xb6b2('0x71')](_0x28a9aa);}})[_0xb6b2('0x1f')](function(_0x34effb){if(_0x34effb){_0xe11aac=_0x34effb[_0xb6b2('0x47')];if(!_0x130020[_0xb6b2('0x42')][_0xb6b2('0x48')]('nolimit')){_0x28a9aa[_0xb6b2('0x2e')]=qs[_0xb6b2('0x2e')](_0x130020[_0xb6b2('0x42')][_0xb6b2('0x2e')]);_0x28a9aa[_0xb6b2('0x2c')]=qs[_0xb6b2('0x2c')](_0x130020[_0xb6b2('0x42')][_0xb6b2('0x2c')]);}return _0x5d7c27[_0xb6b2('0x71')](_0x28a9aa);}})[_0xb6b2('0x1f')](function(_0x55f5cb){if(_0x55f5cb){return _0x55f5cb?{'count':_0xe11aac,'rows':_0x55f5cb}:null;}})[_0xb6b2('0x1f')](respondWithResult(_0x41694d,null))[_0xb6b2('0x28')](handleError(_0x41694d,null));};exports[_0xb6b2('0x72')]=function(_0x46dc23,_0x868063,_0x341d11){var _0xde3736=_0x46dc23['body'][_0xb6b2('0x73')];return db['Team']['findAll']({'where':{'id':_0xde3736},'attributes':['id'],'include':[{'model':db[_0xb6b2('0x66')],'as':_0xb6b2('0x74'),'attributes':['id','name',_0xb6b2('0x75'),_0xb6b2('0x76'),_0xb6b2('0x77')],'raw':!![]}]})['then'](function(_0x490b19){if(_0x490b19){var _0x1aeff1=_[_0xb6b2('0x78')](_0x490b19,function(_0x3bf3c2){var _0x2fd3cb=_0x3bf3c2['get']({'plain':!![]});return _0x2fd3cb['Agents'];});return db['ChatQueue'][_0xb6b2('0x57')]({'where':{'id':_0x46dc23[_0xb6b2('0x55')]['id']}})[_0xb6b2('0x1f')](function(_0x121dad){return db[_0xb6b2('0x79')]['transaction'](function(_0x494bab){return _0x121dad[_0xb6b2('0x72')](_0xde3736,{'transaction':_0x494bab})[_0xb6b2('0x1f')](function(){return BPromise['each'](_0x1aeff1,function(_0x343420){return db['UserChatQueue'][_0xb6b2('0x7a')]({'where':{'UserId':_0x343420['id'],'ChatQueueId':_0x46dc23[_0xb6b2('0x55')]['id']},'transaction':_0x494bab});});})['then'](function(){_0x1aeff1[_0xb6b2('0x7b')](function(_0x473b41){socket['emit'](_0xb6b2('0x7c'),{'UserId':_0x473b41['id'],'ChatQueueId':_0x121dad['id']});});});});});}})[_0xb6b2('0x1f')](respondWithStatusCode(_0x868063,null))['catch'](handleError(_0x868063,null));};exports[_0xb6b2('0x7d')]=function(_0x1cab63,_0x4229a6,_0x4c7897){return db['Team'][_0xb6b2('0x53')]({'where':{'id':_0x1cab63[_0xb6b2('0x42')][_0xb6b2('0x73')]},'attributes':['id'],'include':[{'model':db[_0xb6b2('0x66')],'as':_0xb6b2('0x74'),'attributes':['id'],'raw':!![]}]})[_0xb6b2('0x1f')](handleEntityNotFound(_0x4229a6,null))[_0xb6b2('0x1f')](function(_0x48b6b2){var _0x9dfb0a=_[_0xb6b2('0x3d')](_0x48b6b2,'id');var _0x37a13a=[];var _0x2214fc=[];var _0x728507=squel[_0xb6b2('0x7e')]();_0x728507[_0xb6b2('0x7f')](_0xb6b2('0x80'))[_0xb6b2('0x81')](_0xb6b2('0x82'),'tq')[_0xb6b2('0x83')](_0xb6b2('0x84'),'ut',_0xb6b2('0x85'))[_0xb6b2('0x4b')](_0xb6b2('0x86'),_0x1cab63['params']['id']);for(var _0x519c12=0x0;_0x519c12<_0x48b6b2[_0xb6b2('0x47')];_0x519c12+=0x1){let _0x21188b=_0x48b6b2[_0x519c12];for(var _0x1cd6b9=0x0;_0x1cd6b9<_0x21188b['Agents'][_0xb6b2('0x47')];_0x1cd6b9+=0x1){let _0x413086=_0x21188b[_0xb6b2('0x74')][_0x1cd6b9];var _0x14b999=_0x728507['clone']();_0x14b999['where'](_0xb6b2('0x87'),_0x413086['id']);_0x2214fc[_0xb6b2('0x88')](db[_0xb6b2('0x79')][_0xb6b2('0x42')](_0x14b999[_0xb6b2('0x89')](),{'type':db[_0xb6b2('0x79')][_0xb6b2('0x8a')][_0xb6b2('0x8b')]})[_0xb6b2('0x1f')](function(_0x38d3ad){if(_0x38d3ad[_0xb6b2('0x47')]===0x1){return _0x413086['id'];}else{var _0x1ad26d=_[_0xb6b2('0x8c')](_[_0xb6b2('0x3d')](_0x38d3ad,_0xb6b2('0x8d')),function(_0x20529f){return _['includes'](_0x9dfb0a,_0x20529f);});if(_0x1ad26d){return _0x413086['id'];}}}));}}return BPromise[_0xb6b2('0x8e')](_0x2214fc)[_0xb6b2('0x1f')](function(_0x289e6a){_0x37a13a=_(_0x37a13a)[_0xb6b2('0x8f')](_0x289e6a)['compact']()[_0xb6b2('0x90')]();return db[_0xb6b2('0x52')][_0xb6b2('0x57')]({'where':{'id':_0x1cab63[_0xb6b2('0x55')]['id']}})['then'](function(_0x4707e4){return db['sequelize'][_0xb6b2('0x91')](function(_0x39f561){return _0x4707e4[_0xb6b2('0x7d')](_0x1cab63[_0xb6b2('0x42')]['ids'],{'transaction':_0x39f561})['then'](function(){if(!_[_0xb6b2('0x92')](_0x37a13a)){return _0x4707e4[_0xb6b2('0x93')](_0x37a13a,{'transaction':_0x39f561});}})[_0xb6b2('0x1f')](function(){_0x37a13a[_0xb6b2('0x7b')](function(_0x4b6d42){socket['emit'](_0xb6b2('0x94'),{'UserId':_0x4b6d42,'ChatQueueId':_0x4707e4['id']});});});});});});})[_0xb6b2('0x1f')](respondWithStatusCode(_0x4229a6,null))['catch'](handleError(_0x4229a6,null));};exports[_0xb6b2('0x95')]=function(_0xe0e6a,_0x1c3bd7,_0x345545){return db[_0xb6b2('0x52')][_0xb6b2('0x57')]({'where':{'id':_0xe0e6a[_0xb6b2('0x55')]['id']}})[_0xb6b2('0x1f')](handleEntityNotFound(_0x1c3bd7,null))['then'](function(_0x4cdb87){if(_0x4cdb87){return _0x4cdb87[_0xb6b2('0x95')](_0xe0e6a[_0xb6b2('0x59')][_0xb6b2('0x73')],_[_0xb6b2('0x96')](_0xe0e6a[_0xb6b2('0x59')],[_0xb6b2('0x73'),'id'])||{})[_0xb6b2('0x97')](function(_0x18127f){for(var _0x22cba6=0x0;_0x22cba6<_0xe0e6a[_0xb6b2('0x59')][_0xb6b2('0x73')][_0xb6b2('0x47')];_0x22cba6+=0x1){socket[_0xb6b2('0x98')](_0xb6b2('0x7c'),{'UserId':Number(_0xe0e6a[_0xb6b2('0x59')]['ids'][_0x22cba6]),'ChatQueueId':Number(_0xe0e6a[_0xb6b2('0x55')]['id'])});}return _0x18127f;});}})[_0xb6b2('0x1f')](respondWithResult(_0x1c3bd7,null))['catch'](handleError(_0x1c3bd7,null));};exports['removeAgents']=function(_0x416cdd,_0x602cd2,_0x12e491){return db[_0xb6b2('0x52')][_0xb6b2('0x57')]({'where':{'id':_0x416cdd[_0xb6b2('0x55')]['id']}})[_0xb6b2('0x1f')](handleEntityNotFound(_0x602cd2,null))[_0xb6b2('0x1f')](function(_0x5e28fa){if(_0x5e28fa){return _0x5e28fa[_0xb6b2('0x93')](_0x416cdd[_0xb6b2('0x42')]['ids'])[_0xb6b2('0x1f')](function(){if(_['isArray'](_0x416cdd[_0xb6b2('0x42')]['ids'])){for(var _0x203414=0x0;_0x203414<_0x416cdd[_0xb6b2('0x42')][_0xb6b2('0x73')][_0xb6b2('0x47')];_0x203414+=0x1){socket[_0xb6b2('0x98')](_0xb6b2('0x94'),{'UserId':Number(_0x416cdd[_0xb6b2('0x42')][_0xb6b2('0x73')][_0x203414]),'ChatQueueId':Number(_0x416cdd[_0xb6b2('0x55')]['id'])});}}else{socket[_0xb6b2('0x98')](_0xb6b2('0x94'),{'UserId':Number(_0x416cdd[_0xb6b2('0x42')]['ids']),'ChatQueueId':Number(_0x416cdd[_0xb6b2('0x55')]['id'])});}});}})['then'](respondWithStatusCode(_0x602cd2,null))['catch'](handleError(_0x602cd2,null));};exports[_0xb6b2('0x99')]=function(_0x256b39,_0x3d698e,_0x3825aa){var _0x2a9711={};var _0x464a82={};var _0x393b85;var _0x20187c;return db[_0xb6b2('0x52')][_0xb6b2('0x6f')]({'where':{'id':_0x256b39[_0xb6b2('0x55')]['id']}})[_0xb6b2('0x1f')](handleEntityNotFound(_0x3d698e,null))[_0xb6b2('0x1f')](function(_0x2d6704){if(_0x2d6704){_0x393b85=_0x2d6704;_0x464a82[_0xb6b2('0x41')]=_[_0xb6b2('0x63')](db[_0xb6b2('0x66')][_0xb6b2('0x3e')]);_0x464a82[_0xb6b2('0x42')]=_[_0xb6b2('0x63')](_0x256b39['query']);_0x464a82[_0xb6b2('0x43')]=_[_0xb6b2('0x45')](_0x464a82[_0xb6b2('0x41')],_0x464a82[_0xb6b2('0x42')]);_0x2a9711[_0xb6b2('0x44')]=_[_0xb6b2('0x45')](_0x464a82[_0xb6b2('0x41')],qs[_0xb6b2('0x46')](_0x256b39[_0xb6b2('0x42')][_0xb6b2('0x46')]));_0x2a9711[_0xb6b2('0x44')]=_0x2a9711[_0xb6b2('0x44')][_0xb6b2('0x47')]?_0x2a9711[_0xb6b2('0x44')]:_0x464a82[_0xb6b2('0x41')];_0x2a9711[_0xb6b2('0x64')]=qs['sort'](_0x256b39[_0xb6b2('0x42')][_0xb6b2('0x4a')]);_0x2a9711[_0xb6b2('0x4b')]=qs[_0xb6b2('0x43')](_[_0xb6b2('0x4c')](_0x256b39['query'],_0x464a82[_0xb6b2('0x43')]));if(_0x256b39[_0xb6b2('0x42')]['filter']){_0x2a9711[_0xb6b2('0x4b')]=_['merge'](_0x2a9711['where'],{'$or':_[_0xb6b2('0x3d')](_0x2a9711[_0xb6b2('0x44')],function(_0x482207){var _0x35d3e2={};_0x35d3e2[_0x482207]={'$like':'%'+_0x256b39['query']['filter']+'%'};return _0x35d3e2;})});}_0x2a9711=_[_0xb6b2('0x4e')]({},_0x2a9711,_0x256b39[_0xb6b2('0x50')]);return _0x393b85[_0xb6b2('0x99')](_0x2a9711);}})['then'](function(_0x501789){if(_0x501789){_0x20187c=_0x501789[_0xb6b2('0x47')];if(!_0x256b39[_0xb6b2('0x42')]['hasOwnProperty']('nolimit')){_0x2a9711['limit']=qs[_0xb6b2('0x2e')](_0x256b39[_0xb6b2('0x42')][_0xb6b2('0x2e')]);_0x2a9711[_0xb6b2('0x2c')]=qs[_0xb6b2('0x2c')](_0x256b39[_0xb6b2('0x42')][_0xb6b2('0x2c')]);}return _0x393b85[_0xb6b2('0x99')](_0x2a9711);}})[_0xb6b2('0x1f')](function(_0x3e9cbf){if(_0x3e9cbf){return _0x3e9cbf?{'count':_0x20187c,'rows':_0x3e9cbf}:null;}})['then'](respondWithResult(_0x3d698e,null))[_0xb6b2('0x28')](handleError(_0x3d698e,null));};
\ No newline at end of file
+var _0x7b3b=['voicePause','flatMap','sequelize','transaction','forEach','emit','removeTeams','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','removeAgents','addAgents','spread','userChatQueue:save','getAgents','hasOwnProperty','bluebird','util','lodash','squel','ioredis','../../components/parsers/qs','api','../../config/environment','redis','defaults','localhost','socket.io-emitter','register','status','end','json','offset','undefined','limit','count','set','Content-Range','update','destroy','then','get','ChatQueues','error','stack','name','send','index','map','ChatQueue','rawAttributes','type','key','getOptions','where','include','query','catch','params','model','keys','filters','intersection','attributes','length','merge','options','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','UserChatQueue','fields','nolimit','order','sort','pick','ChatQueueId','filter','findAll','User','UserId','agent','chatPause','updatedAt','createdAt','rows','format','%s/%s','SIP','getTeams','Team','addTeams','ids','Agents','online'];(function(_0x24d8ec,_0x5f1552){var _0x409280=function(_0x3d085b){while(--_0x3d085b){_0x24d8ec['push'](_0x24d8ec['shift']());}};_0x409280(++_0x5f1552);}(_0x7b3b,0x92));var _0xb7b3=function(_0x23fa2a,_0x3816a3){_0x23fa2a=_0x23fa2a-0x0;var _0x783fba=_0x7b3b[_0x23fa2a];return _0x783fba;};'use strict';var BPromise=require(_0xb7b3('0x0'));var util=require(_0xb7b3('0x1'));var _=require(_0xb7b3('0x2'));var squel=require(_0xb7b3('0x3'));var Redis=require(_0xb7b3('0x4'));var qs=require(_0xb7b3('0x5'));var logger=require('../../config/logger')(_0xb7b3('0x6'));var config=require(_0xb7b3('0x7'));var db=require('../../mysqldb')['db'];config[_0xb7b3('0x8')]=_[_0xb7b3('0x9')](config[_0xb7b3('0x8')],{'host':_0xb7b3('0xa'),'port':0x18eb});var socket=require(_0xb7b3('0xb'))(new Redis(config[_0xb7b3('0x8')]));require('./chatQueue.socket')[_0xb7b3('0xc')](socket);function respondWithStatusCode(_0x187639,_0x202d7e){_0x202d7e=_0x202d7e||0xcc;return function(_0x4a000a){if(_0x4a000a){return _0x187639['sendStatus'](_0x202d7e);}return _0x187639[_0xb7b3('0xd')](_0x202d7e)[_0xb7b3('0xe')]();};}function respondWithResult(_0x58ad4c,_0x46a558){_0x46a558=_0x46a558||0xc8;return function(_0x2e1acd){if(_0x2e1acd){return _0x58ad4c[_0xb7b3('0xd')](_0x46a558)[_0xb7b3('0xf')](_0x2e1acd);}};}function respondWithFilteredResult(_0x281146,_0x4ce771){return function(_0x5e950e){if(_0x5e950e){var _0x2650fc=typeof _0x4ce771[_0xb7b3('0x10')]===_0xb7b3('0x11')&&typeof _0x4ce771[_0xb7b3('0x12')]==='undefined';var _0x21b5fe=_0x5e950e['count'];var _0x2bee56=_0x2650fc?0x0:_0x4ce771[_0xb7b3('0x10')];var _0x5780ec=_0x2650fc?_0x5e950e[_0xb7b3('0x13')]:_0x4ce771[_0xb7b3('0x10')]+_0x4ce771['limit'];var _0x279a15;if(_0x5780ec>=_0x21b5fe){_0x5780ec=_0x21b5fe;_0x279a15=0xc8;}else{_0x279a15=0xce;}_0x281146['status'](_0x279a15);return _0x281146[_0xb7b3('0x14')](_0xb7b3('0x15'),_0x2bee56+'-'+_0x5780ec+'/'+_0x21b5fe)[_0xb7b3('0xf')](_0x5e950e);}return null;};}function saveUpdates(_0x22f42e){return function(_0x3e85ce){if(_0x3e85ce){return _0x3e85ce[_0xb7b3('0x16')](_0x22f42e)['then'](function(_0x2086c3){return _0x2086c3;});}return null;};}function removeEntity(_0x381d18){return function(_0x28c4be){if(_0x28c4be){return _0x28c4be[_0xb7b3('0x17')]()[_0xb7b3('0x18')](function(){var _0x3ebfea=_0x28c4be[_0xb7b3('0x19')]({'plain':!![]});var _0xc0e079=_0xb7b3('0x1a');return db['UserProfileResource'][_0xb7b3('0x17')]({'where':{'type':_0xc0e079,'resourceId':_0x3ebfea['id']}})[_0xb7b3('0x18')](function(){return _0x28c4be;});})[_0xb7b3('0x18')](function(){_0x381d18[_0xb7b3('0xd')](0xcc)[_0xb7b3('0xe')]();});}};}function handleEntityNotFound(_0xae4788){return function(_0x524e72){if(!_0x524e72){_0xae4788['sendStatus'](0x194);}return _0x524e72;};}function handleError(_0x2271ad,_0x18cba1){_0x18cba1=_0x18cba1||0x1f4;return function(_0x261634){logger[_0xb7b3('0x1b')](_0x261634[_0xb7b3('0x1c')]);if(_0x261634[_0xb7b3('0x1d')]){delete _0x261634[_0xb7b3('0x1d')];}_0x2271ad[_0xb7b3('0xd')](_0x18cba1)[_0xb7b3('0x1e')](_0x261634);};}exports[_0xb7b3('0x1f')]=function(_0x27fd41,_0x1b5ce5){var _0x4e8ccb={};var _0x2dc648={'count':0x0,'rows':[]};var _0x58222a=_[_0xb7b3('0x20')](db[_0xb7b3('0x21')][_0xb7b3('0x22')],function(_0xd0bea4){return{'name':_0xd0bea4['fieldName'],'type':_0xd0bea4[_0xb7b3('0x23')][_0xb7b3('0x24')]};});_0x4e8ccb=qs[_0xb7b3('0x25')](_0x58222a,_0x27fd41);var _0x18b938={'where':_0x4e8ccb[_0xb7b3('0x26')]};return db[_0xb7b3('0x21')]['count'](_0x18b938)['then'](function(_0x5612b8){_0x2dc648[_0xb7b3('0x13')]=_0x5612b8;_0x4e8ccb['include']=qs[_0xb7b3('0x27')](_0x27fd41[_0xb7b3('0x28')]);return db['ChatQueue']['findAll'](_0x4e8ccb);})[_0xb7b3('0x18')](function(_0x5f19cc){_0x2dc648['rows']=_0x5f19cc;return _0x2dc648;})[_0xb7b3('0x18')](respondWithFilteredResult(_0x1b5ce5,_0x4e8ccb))[_0xb7b3('0x29')](handleError(_0x1b5ce5,null));};exports['show']=function(_0x102c7f,_0xef5975){var _0x3d858e={'raw':!![],'where':{'id':_0x102c7f[_0xb7b3('0x2a')]['id']}},_0x53d006={};_0x53d006[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db['ChatQueue'][_0xb7b3('0x22')]);_0x53d006[_0xb7b3('0x28')]=_[_0xb7b3('0x2c')](_0x102c7f[_0xb7b3('0x28')]);_0x53d006[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x53d006[_0xb7b3('0x2b')],_0x53d006[_0xb7b3('0x28')]);_0x3d858e[_0xb7b3('0x2f')]=_[_0xb7b3('0x2e')](_0x53d006['model'],qs['fields'](_0x102c7f['query']['fields']));_0x3d858e[_0xb7b3('0x2f')]=_0x3d858e[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x3d858e[_0xb7b3('0x2f')]:_0x53d006[_0xb7b3('0x2b')];if(_0x102c7f[_0xb7b3('0x28')]['includeAll']){_0x3d858e[_0xb7b3('0x27')]=[{'all':!![]}];}_0x3d858e=_[_0xb7b3('0x31')]({},_0x3d858e,_0x102c7f[_0xb7b3('0x32')]);return db[_0xb7b3('0x21')][_0xb7b3('0x33')](_0x3d858e)['then'](handleEntityNotFound(_0xef5975,null))[_0xb7b3('0x18')](respondWithResult(_0xef5975,null))[_0xb7b3('0x29')](handleError(_0xef5975,null));};exports['create']=function(_0xa6615c,_0x6c473e){return db[_0xb7b3('0x21')][_0xb7b3('0x34')](_0xa6615c[_0xb7b3('0x35')],{})[_0xb7b3('0x18')](function(_0x24c940){var _0x3e4cd5=_0xa6615c['user']['get']({'plain':!![]});if(!_0x3e4cd5)throw new Error(_0xb7b3('0x36'));if(_0x3e4cd5[_0xb7b3('0x37')]===_0xb7b3('0x38')){var _0x5a2075=_0x24c940[_0xb7b3('0x19')]({'plain':!![]});var _0xe7f5a8='ChatQueues';return db['UserProfileSection']['find']({'where':{'name':_0xe7f5a8,'userProfileId':_0x3e4cd5[_0xb7b3('0x39')]},'raw':!![]})[_0xb7b3('0x18')](function(_0x446fc7){if(_0x446fc7&&_0x446fc7[_0xb7b3('0x3a')]===0x0){return db[_0xb7b3('0x3b')][_0xb7b3('0x34')]({'name':_0x5a2075[_0xb7b3('0x1d')],'resourceId':_0x5a2075['id'],'type':_0x446fc7[_0xb7b3('0x1d')],'sectionId':_0x446fc7['id']},{})[_0xb7b3('0x18')](function(){return _0x24c940;});}else{return _0x24c940;}})['catch'](function(_0x4219a4){logger[_0xb7b3('0x1b')](_0xb7b3('0x3c'),_0x4219a4);throw _0x4219a4;});}return _0x24c940;})['then'](respondWithResult(_0x6c473e,0xc9))[_0xb7b3('0x29')](handleError(_0x6c473e,null));};exports['update']=function(_0x45ee14,_0x27d95f){if(_0x45ee14[_0xb7b3('0x35')]['id']){delete _0x45ee14[_0xb7b3('0x35')]['id'];}return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x45ee14['params']['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x27d95f,null))[_0xb7b3('0x18')](saveUpdates(_0x45ee14[_0xb7b3('0x35')],null))['then'](respondWithResult(_0x27d95f,null))['catch'](handleError(_0x27d95f,null));};exports[_0xb7b3('0x17')]=function(_0x273c2d,_0x4aa25a){return db['ChatQueue'][_0xb7b3('0x33')]({'where':{'id':_0x273c2d[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x4aa25a,null))[_0xb7b3('0x18')](removeEntity(_0x4aa25a,null))[_0xb7b3('0x29')](handleError(_0x4aa25a,null));};exports[_0xb7b3('0x3d')]=function(_0x53454d,_0x1b1936){return db[_0xb7b3('0x21')][_0xb7b3('0x3d')]()[_0xb7b3('0x18')](respondWithResult(_0x1b1936,null))[_0xb7b3('0x29')](handleError(_0x1b1936,null));};exports['getMembers']=function(_0x300009,_0x16ad16){var _0x9899cf={'raw':!![],'where':{}},_0x5b429a={},_0x355b7f;return db[_0xb7b3('0x21')][_0xb7b3('0x3e')]({'where':{'id':_0x300009[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x16ad16,null))[_0xb7b3('0x18')](function(_0x56c874){if(_0x56c874){_0x355b7f=_0x56c874['get']({'plain':!![]});_0x5b429a[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db[_0xb7b3('0x3f')][_0xb7b3('0x22')]);_0x5b429a['query']=_['keys'](_0x300009[_0xb7b3('0x28')]);_0x5b429a[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x5b429a[_0xb7b3('0x2b')],_0x5b429a[_0xb7b3('0x28')]);_0x9899cf[_0xb7b3('0x2f')]=_['intersection'](_0x5b429a[_0xb7b3('0x2b')],qs[_0xb7b3('0x40')](_0x300009[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x9899cf[_0xb7b3('0x2f')]=_0x9899cf[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x9899cf[_0xb7b3('0x2f')]:_0x5b429a[_0xb7b3('0x2b')];if(!_0x300009['query']['hasOwnProperty'](_0xb7b3('0x41'))){_0x9899cf['limit']=qs['limit'](_0x300009[_0xb7b3('0x28')]['limit']);_0x9899cf[_0xb7b3('0x10')]=qs[_0xb7b3('0x10')](_0x300009['query'][_0xb7b3('0x10')]);}_0x9899cf[_0xb7b3('0x42')]=qs[_0xb7b3('0x43')](_0x300009[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x9899cf[_0xb7b3('0x26')]=qs[_0xb7b3('0x2d')](_[_0xb7b3('0x44')](_0x300009[_0xb7b3('0x28')],_0x5b429a[_0xb7b3('0x2d')]));_0x9899cf['where'][_0xb7b3('0x45')]=_0x56c874['id'];if(_0x300009['query'][_0xb7b3('0x46')]){_0x9899cf[_0xb7b3('0x26')]=_[_0xb7b3('0x31')](_0x9899cf['where'],{'$or':_[_0xb7b3('0x20')](_0x9899cf['attributes'],function(_0x370392){var _0x5d9e2c={};_0x5d9e2c[_0x370392]={'$like':'%'+_0x300009[_0xb7b3('0x28')][_0xb7b3('0x46')]+'%'};return _0x5d9e2c;})});}_0x9899cf=_[_0xb7b3('0x31')]({},_0x9899cf,_0x300009[_0xb7b3('0x32')]);return db[_0xb7b3('0x3f')][_0xb7b3('0x47')](_0x9899cf);}})[_0xb7b3('0x18')](function(_0x552415){if(_0x552415){return db[_0xb7b3('0x48')]['findAndCountAll']({'where':{'id':_['map'](_0x552415,_0xb7b3('0x49')),'role':_0xb7b3('0x4a')},'attributes':['id',_0xb7b3('0x1d'),_0xb7b3('0x4b'),_0xb7b3('0x4c'),_0xb7b3('0x4d')]});}})[_0xb7b3('0x18')](function(_0x1c6797){if(_0x1c6797){return{'count':_0x1c6797[_0xb7b3('0x13')],'rows':_['map'](_0x1c6797[_0xb7b3('0x4e')],function(_0x2bb5b1){return{'membername':_0x2bb5b1[_0xb7b3('0x1d')],'UserId':_0x2bb5b1['id'],'queue_name':_0x355b7f[_0xb7b3('0x1d')],'ChatQueueId':_0x355b7f['id'],'interface':util[_0xb7b3('0x4f')](_0xb7b3('0x50'),_0xb7b3('0x51'),_0x2bb5b1[_0xb7b3('0x1d')]),'penalty':0x0,'paused':_0x2bb5b1[_0xb7b3('0x4b')],'createdAt':_0x2bb5b1[_0xb7b3('0x4d')],'updatedAt':_0x2bb5b1[_0xb7b3('0x4c')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xb7b3('0x18')](respondWithFilteredResult(_0x16ad16,_0x9899cf))[_0xb7b3('0x29')](handleError(_0x16ad16,null));};exports[_0xb7b3('0x52')]=function(_0x44bc4b,_0x40a7f9){var _0x2fdbe5={};var _0x3d9ce5={};var _0x293c83;var _0x633055;return db['ChatQueue'][_0xb7b3('0x3e')]({'where':{'id':_0x44bc4b[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x40a7f9,null))[_0xb7b3('0x18')](function(_0x2ca86d){if(_0x2ca86d){_0x293c83=_0x2ca86d;_0x3d9ce5[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db[_0xb7b3('0x53')]['rawAttributes']);_0x3d9ce5['query']=_[_0xb7b3('0x2c')](_0x44bc4b[_0xb7b3('0x28')]);_0x3d9ce5[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x3d9ce5['model'],_0x3d9ce5[_0xb7b3('0x28')]);_0x2fdbe5['attributes']=_['intersection'](_0x3d9ce5[_0xb7b3('0x2b')],qs[_0xb7b3('0x40')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x2fdbe5[_0xb7b3('0x2f')]=_0x2fdbe5[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x2fdbe5[_0xb7b3('0x2f')]:_0x3d9ce5['model'];_0x2fdbe5['order']=qs[_0xb7b3('0x43')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x2fdbe5['where']=qs['filters'](_[_0xb7b3('0x44')](_0x44bc4b[_0xb7b3('0x28')],_0x3d9ce5[_0xb7b3('0x2d')]));if(_0x44bc4b[_0xb7b3('0x28')]['filter']){_0x2fdbe5[_0xb7b3('0x26')]=_['merge'](_0x2fdbe5['where'],{'$or':_['map'](_0x2fdbe5[_0xb7b3('0x2f')],function(_0x3c05a6){var _0x5f6362={};_0x5f6362[_0x3c05a6]={'$like':'%'+_0x44bc4b['query'][_0xb7b3('0x46')]+'%'};return _0x5f6362;})});}_0x2fdbe5=_[_0xb7b3('0x31')]({},_0x2fdbe5,_0x44bc4b[_0xb7b3('0x32')]);return _0x293c83[_0xb7b3('0x52')](_0x2fdbe5);}})[_0xb7b3('0x18')](function(_0x4ad27d){if(_0x4ad27d){_0x633055=_0x4ad27d[_0xb7b3('0x30')];if(!_0x44bc4b[_0xb7b3('0x28')]['hasOwnProperty']('nolimit')){_0x2fdbe5[_0xb7b3('0x12')]=qs['limit'](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x12')]);_0x2fdbe5['offset']=qs[_0xb7b3('0x10')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x10')]);}return _0x293c83['getTeams'](_0x2fdbe5);}})[_0xb7b3('0x18')](function(_0x10df96){if(_0x10df96){return _0x10df96?{'count':_0x633055,'rows':_0x10df96}:null;}})[_0xb7b3('0x18')](respondWithResult(_0x40a7f9,null))[_0xb7b3('0x29')](handleError(_0x40a7f9,null));};exports[_0xb7b3('0x54')]=function(_0x44cb51,_0x2afb57){var _0x19006a=_0x44cb51['body'][_0xb7b3('0x55')];return db[_0xb7b3('0x53')][_0xb7b3('0x47')]({'where':{'id':_0x19006a},'attributes':['id'],'include':[{'model':db[_0xb7b3('0x48')],'as':_0xb7b3('0x56'),'attributes':['id',_0xb7b3('0x1d'),_0xb7b3('0x57'),_0xb7b3('0x58'),'interface'],'raw':!![]}]})['then'](function(_0x2618ea){if(_0x2618ea){var _0x4fa4d5=_[_0xb7b3('0x59')](_0x2618ea,function(_0x270be7){var _0x367418=_0x270be7[_0xb7b3('0x19')]({'plain':!![]});return _0x367418[_0xb7b3('0x56')];});return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x44cb51[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](function(_0x1d4f86){return db[_0xb7b3('0x5a')][_0xb7b3('0x5b')](function(_0x265bfd){return _0x1d4f86['addTeams'](_0x19006a,{'transaction':_0x265bfd})[_0xb7b3('0x18')](function(){return BPromise['each'](_0x4fa4d5,function(_0x39de53){return db[_0xb7b3('0x3f')]['findOrCreate']({'where':{'UserId':_0x39de53['id'],'ChatQueueId':_0x44cb51[_0xb7b3('0x2a')]['id']},'transaction':_0x265bfd});});})[_0xb7b3('0x18')](function(){_0x4fa4d5[_0xb7b3('0x5c')](function(_0x5e2943){socket[_0xb7b3('0x5d')]('userChatQueue:save',{'UserId':_0x5e2943['id'],'ChatQueueId':_0x1d4f86['id']});});});});});}})[_0xb7b3('0x18')](respondWithStatusCode(_0x2afb57,null))[_0xb7b3('0x29')](handleError(_0x2afb57,null));};exports[_0xb7b3('0x5e')]=function(_0x4f7461,_0xd56f49){return db['Team'][_0xb7b3('0x47')]({'where':{'id':_0x4f7461[_0xb7b3('0x28')]['ids']},'attributes':['id'],'include':[{'model':db[_0xb7b3('0x48')],'as':_0xb7b3('0x56'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0xd56f49,null))[_0xb7b3('0x18')](function(_0x389fac){var _0x23bf90=_[_0xb7b3('0x20')](_0x389fac,'id');var _0x4e7f24=[];var _0x5c6b27=[];var _0x2e383c=squel['select']();_0x2e383c[_0xb7b3('0x5f')](_0xb7b3('0x60'))[_0xb7b3('0x61')](_0xb7b3('0x62'),'tq')[_0xb7b3('0x63')](_0xb7b3('0x64'),'ut',_0xb7b3('0x65'))[_0xb7b3('0x26')](_0xb7b3('0x66'),_0x4f7461['params']['id']);for(var _0x4b46f5=0x0;_0x4b46f5<_0x389fac['length'];_0x4b46f5+=0x1){let _0x2e1ae3=_0x389fac[_0x4b46f5];for(var _0x4dec0a=0x0;_0x4dec0a<_0x2e1ae3[_0xb7b3('0x56')]['length'];_0x4dec0a+=0x1){let _0x17ffee=_0x2e1ae3['Agents'][_0x4dec0a];var _0x41eb65=_0x2e383c['clone']();_0x41eb65[_0xb7b3('0x26')]('ut.UserId\x20=\x20?',_0x17ffee['id']);_0x5c6b27[_0xb7b3('0x67')](db[_0xb7b3('0x5a')][_0xb7b3('0x28')](_0x41eb65[_0xb7b3('0x68')](),{'type':db[_0xb7b3('0x5a')][_0xb7b3('0x69')][_0xb7b3('0x6a')]})['then'](function(_0x47a65a){if(_0x47a65a[_0xb7b3('0x30')]===0x1){return _0x17ffee['id'];}else{var _0x2be45a=_[_0xb7b3('0x6b')](_[_0xb7b3('0x20')](_0x47a65a,_0xb7b3('0x6c')),function(_0x3583b2){return _[_0xb7b3('0x6d')](_0x23bf90,_0x3583b2);});if(_0x2be45a){return _0x17ffee['id'];}}}));}}return BPromise[_0xb7b3('0x6e')](_0x5c6b27)[_0xb7b3('0x18')](function(_0x25d8bd){_0x4e7f24=_(_0x4e7f24)['union'](_0x25d8bd)['compact']()['value']();return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x4f7461[_0xb7b3('0x2a')]['id']}})['then'](function(_0x20f337){return db['sequelize'][_0xb7b3('0x5b')](function(_0x400032){return _0x20f337[_0xb7b3('0x5e')](_0x4f7461[_0xb7b3('0x28')][_0xb7b3('0x55')],{'transaction':_0x400032})[_0xb7b3('0x18')](function(){if(!_['isEmpty'](_0x4e7f24)){return _0x20f337[_0xb7b3('0x6f')](_0x4e7f24,{'transaction':_0x400032});}})[_0xb7b3('0x18')](function(){_0x4e7f24[_0xb7b3('0x5c')](function(_0x43a2bf){socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':_0x43a2bf,'ChatQueueId':_0x20f337['id']});});});});});});})[_0xb7b3('0x18')](respondWithStatusCode(_0xd56f49,null))[_0xb7b3('0x29')](handleError(_0xd56f49,null));};exports['addAgents']=function(_0x4f2e10,_0x17332d){return db[_0xb7b3('0x21')]['find']({'where':{'id':_0x4f2e10[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x17332d,null))[_0xb7b3('0x18')](function(_0x2d23d6){if(_0x2d23d6){return _0x2d23d6[_0xb7b3('0x70')](_0x4f2e10['body']['ids'],_['omit'](_0x4f2e10['body'],['ids','id'])||{})[_0xb7b3('0x71')](function(_0x31d5d9){for(var _0x13cd15=0x0;_0x13cd15<_0x4f2e10[_0xb7b3('0x35')][_0xb7b3('0x55')][_0xb7b3('0x30')];_0x13cd15+=0x1){socket[_0xb7b3('0x5d')](_0xb7b3('0x72'),{'UserId':Number(_0x4f2e10[_0xb7b3('0x35')]['ids'][_0x13cd15]),'ChatQueueId':Number(_0x4f2e10['params']['id'])});}return _0x31d5d9;});}})['then'](respondWithResult(_0x17332d,null))['catch'](handleError(_0x17332d,null));};exports[_0xb7b3('0x6f')]=function(_0x239445,_0x5ed5e5){return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x239445[_0xb7b3('0x2a')]['id']}})['then'](handleEntityNotFound(_0x5ed5e5,null))[_0xb7b3('0x18')](function(_0x292b07){if(_0x292b07){return _0x292b07[_0xb7b3('0x6f')](_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')])['then'](function(){if(_['isArray'](_0x239445['query'][_0xb7b3('0x55')])){for(var _0x4f7ec3=0x0;_0x4f7ec3<_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')][_0xb7b3('0x30')];_0x4f7ec3+=0x1){socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':Number(_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')][_0x4f7ec3]),'ChatQueueId':Number(_0x239445['params']['id'])});}}else{socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':Number(_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')]),'ChatQueueId':Number(_0x239445['params']['id'])});}});}})['then'](respondWithStatusCode(_0x5ed5e5,null))[_0xb7b3('0x29')](handleError(_0x5ed5e5,null));};exports[_0xb7b3('0x73')]=function(_0x525e23,_0xb37a68){var _0x54adff={};var _0x1b4f42={};var _0x576079;var _0xea55b;return db[_0xb7b3('0x21')]['findOne']({'where':{'id':_0x525e23[_0xb7b3('0x2a')]['id']}})['then'](handleEntityNotFound(_0xb37a68,null))[_0xb7b3('0x18')](function(_0x12b4c5){if(_0x12b4c5){_0x576079=_0x12b4c5;_0x1b4f42['model']=_[_0xb7b3('0x2c')](db['User'][_0xb7b3('0x22')]);_0x1b4f42[_0xb7b3('0x28')]=_[_0xb7b3('0x2c')](_0x525e23['query']);_0x1b4f42[_0xb7b3('0x2d')]=_['intersection'](_0x1b4f42[_0xb7b3('0x2b')],_0x1b4f42[_0xb7b3('0x28')]);_0x54adff[_0xb7b3('0x2f')]=_[_0xb7b3('0x2e')](_0x1b4f42[_0xb7b3('0x2b')],qs['fields'](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x54adff[_0xb7b3('0x2f')]=_0x54adff['attributes'][_0xb7b3('0x30')]?_0x54adff[_0xb7b3('0x2f')]:_0x1b4f42['model'];_0x54adff['order']=qs[_0xb7b3('0x43')](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x54adff[_0xb7b3('0x26')]=qs[_0xb7b3('0x2d')](_[_0xb7b3('0x44')](_0x525e23[_0xb7b3('0x28')],_0x1b4f42[_0xb7b3('0x2d')]));if(_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x46')]){_0x54adff[_0xb7b3('0x26')]=_[_0xb7b3('0x31')](_0x54adff['where'],{'$or':_['map'](_0x54adff[_0xb7b3('0x2f')],function(_0x4696c7){var _0x6e3f63={};_0x6e3f63[_0x4696c7]={'$like':'%'+_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x46')]+'%'};return _0x6e3f63;})});}_0x54adff=_['merge']({},_0x54adff,_0x525e23['options']);return _0x576079[_0xb7b3('0x73')](_0x54adff);}})[_0xb7b3('0x18')](function(_0x19c3d3){if(_0x19c3d3){_0xea55b=_0x19c3d3[_0xb7b3('0x30')];if(!_0x525e23['query'][_0xb7b3('0x74')]('nolimit')){_0x54adff['limit']=qs[_0xb7b3('0x12')](_0x525e23[_0xb7b3('0x28')]['limit']);_0x54adff[_0xb7b3('0x10')]=qs['offset'](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x10')]);}return _0x576079['getAgents'](_0x54adff);}})[_0xb7b3('0x18')](function(_0xf97ab8){if(_0xf97ab8){return _0xf97ab8?{'count':_0xea55b,'rows':_0xf97ab8}:null;}})[_0xb7b3('0x18')](respondWithResult(_0xb37a68,null))[_0xb7b3('0x29')](handleError(_0xb37a68,null));};
\ No newline at end of file