Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 0790e49..94b5de3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x318f=['model','map','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filter','options','include','findAll','params','includeAll','find','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','ChatQueues','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserChatQueue','rawAttributes','nolimit','ChatQueueId','merge','User','findAndCountAll','UserId','chatPause','updatedAt','rows','format','%s/%s','SIP','createdAt','getTeams','Team','addTeams','Agents','voicePause','flatMap','sequelize','transaction','emit','removeTeams','ids','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','removeAgents','forEach','userChatQueue:remove','addAgents','spread','userChatQueue:save','isArray','findOne','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatQueue.socket','jayson/promise','client','request','then','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','end','status','json','offset','limit','undefined','count','set','Content-Range','reject','update','destroy','UserProfileResource','name','send','ChatQueue','type','key'];(function(_0x31cb5f,_0x2df766){var _0x586042=function(_0x53c807){while(--_0x53c807){_0x31cb5f['push'](_0x31cb5f['shift']());}};_0x586042(++_0x2df766);}(_0x318f,0x191));var _0xf318=function(_0x48908f,_0x3d091d){_0x48908f=_0x48908f-0x0;var _0x4f90f7=_0x318f[_0x48908f];return _0x4f90f7;};'use strict';var emlformat=require(_0xf318('0x0'));var rimraf=require(_0xf318('0x1'));var zipdir=require(_0xf318('0x2'));var jsonpatch=require(_0xf318('0x3'));var rp=require('request-promise');var moment=require(_0xf318('0x4'));var BPromise=require(_0xf318('0x5'));var Mustache=require(_0xf318('0x6'));var util=require('util');var path=require(_0xf318('0x7'));var sox=require(_0xf318('0x8'));var csv=require(_0xf318('0x9'));var ejs=require(_0xf318('0xa'));var fs=require('fs');var fs_extra=require(_0xf318('0xb'));var _=require(_0xf318('0xc'));var squel=require(_0xf318('0xd'));var crypto=require(_0xf318('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xf318('0xf'));var toCsv=require(_0xf318('0x9'));var querystring=require('querystring');var Papa=require(_0xf318('0x10'));var Redis=require(_0xf318('0x11'));var authService=require(_0xf318('0x12'));var qs=require(_0xf318('0x13'));var as=require(_0xf318('0x14'));var hardwareService=require(_0xf318('0x15'));var logger=require(_0xf318('0x16'))(_0xf318('0x17'));var utils=require(_0xf318('0x18'));var config=require(_0xf318('0x19'));var licenseUtil=require(_0xf318('0x1a'));var db=require(_0xf318('0x1b'))['db'];config[_0xf318('0x1c')]=_[_0xf318('0x1d')](config[_0xf318('0x1c')],{'host':_0xf318('0x1e'),'port':0x18eb});var socket=require(_0xf318('0x1f'))(new Redis(config[_0xf318('0x1c')]));require(_0xf318('0x20'))['register'](socket);var jayson=require(_0xf318('0x21'));var client=jayson[_0xf318('0x22')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3f4554,_0x27182e,_0x43f2d2,_0x30757b){return new BPromise(function(_0x7590a4,_0x26e98f){var _0x9f53e5=_0x30757b||client;return _0x9f53e5[_0xf318('0x23')](_0x3f4554,_0x43f2d2)[_0xf318('0x24')](function(_0x141ec9){logger['info'](_0xf318('0x25'),_0x27182e,_0xf318('0x26'));logger[_0xf318('0x27')](_0xf318('0x28'),_0x27182e,_0xf318('0x26'),JSON[_0xf318('0x29')](_0x141ec9));if(_0x141ec9['error']){if(_0x141ec9[_0xf318('0x2a')][_0xf318('0x2b')]===0x1f4){logger['error']('ChatQueue,\x20%s,\x20%s',_0x27182e,_0x141ec9[_0xf318('0x2a')][_0xf318('0x2c')]);return _0x26e98f(_0x141ec9[_0xf318('0x2a')][_0xf318('0x2c')]);}logger[_0xf318('0x2a')](_0xf318('0x25'),_0x27182e,_0x141ec9['error'][_0xf318('0x2c')]);return _0x7590a4(_0x141ec9['error'][_0xf318('0x2c')]);}else{logger[_0xf318('0x2d')](_0xf318('0x25'),_0x27182e,_0xf318('0x26'));_0x7590a4(_0x141ec9[_0xf318('0x2e')][_0xf318('0x2c')]);}})[_0xf318('0x2f')](function(_0x2649d8){logger[_0xf318('0x2a')](_0xf318('0x25'),_0x27182e,_0x2649d8);_0x26e98f(_0x2649d8);});});}function respondWithStatusCode(_0x39dfb8,_0xdd99a3){_0xdd99a3=_0xdd99a3||0xcc;return function(_0x482bb9){if(_0x482bb9){return _0x39dfb8[_0xf318('0x30')](_0xdd99a3);}return _0x39dfb8['status'](_0xdd99a3)[_0xf318('0x31')]();};}function respondWithResult(_0x42aaee,_0x26cead){_0x26cead=_0x26cead||0xc8;return function(_0x5f3465){if(_0x5f3465){return _0x42aaee[_0xf318('0x32')](_0x26cead)[_0xf318('0x33')](_0x5f3465);}};}function respondWithFilteredResult(_0x513af2,_0x3c190b){return function(_0x297467){if(_0x297467){var _0x207c65=typeof _0x3c190b[_0xf318('0x34')]==='undefined'&&typeof _0x3c190b[_0xf318('0x35')]===_0xf318('0x36');var _0x578a2e=_0x297467[_0xf318('0x37')];var _0x889baa=_0x207c65?0x0:_0x3c190b[_0xf318('0x34')];var _0x28e912=_0x207c65?_0x297467[_0xf318('0x37')]:_0x3c190b['offset']+_0x3c190b['limit'];var _0x37cd88;if(_0x28e912>=_0x578a2e){_0x28e912=_0x578a2e;_0x37cd88=0xc8;}else{_0x37cd88=0xce;}_0x513af2[_0xf318('0x32')](_0x37cd88);return _0x513af2[_0xf318('0x38')](_0xf318('0x39'),_0x889baa+'-'+_0x28e912+'/'+_0x578a2e)['json'](_0x297467);}return null;};}function patchUpdates(_0x37d65a){return function(_0x16d063){try{jsonpatch['apply'](_0x16d063,_0x37d65a,!![]);}catch(_0x425a66){return BPromise[_0xf318('0x3a')](_0x425a66);}return _0x16d063['save']();};}function saveUpdates(_0x430b5e,_0x32f843){return function(_0x218771){if(_0x218771){return _0x218771[_0xf318('0x3b')](_0x430b5e)['then'](function(_0x415de8){return _0x415de8;});}return null;};}function removeEntity(_0x27c3e8,_0x2f2fc3){return function(_0x216f71){if(_0x216f71){return _0x216f71[_0xf318('0x3c')]()['then'](function(){var _0x3a2090=_0x216f71['get']({'plain':!![]});var _0xd0f654='ChatQueues';return db[_0xf318('0x3d')]['destroy']({'where':{'type':_0xd0f654,'resourceId':_0x3a2090['id']}})[_0xf318('0x24')](function(){return _0x216f71;});})[_0xf318('0x24')](function(){_0x27c3e8[_0xf318('0x32')](0xcc)[_0xf318('0x31')]();});}};}function handleEntityNotFound(_0x1cec26,_0x3b951c){return function(_0x5d9d35){if(!_0x5d9d35){_0x1cec26[_0xf318('0x30')](0x194);}return _0x5d9d35;};}function handleError(_0x21dec4,_0x56d9ce){_0x56d9ce=_0x56d9ce||0x1f4;return function(_0x26dd81){logger['error'](_0x26dd81['stack']);if(_0x26dd81[_0xf318('0x3e')]){delete _0x26dd81['name'];}_0x21dec4['status'](_0x56d9ce)[_0xf318('0x3f')](_0x26dd81);};}exports['index']=function(_0x316557,_0x27cdb6){var _0x394bef={},_0x5e93bc={},_0x41d3e9={'count':0x0,'rows':[]};var _0x21031d=_['map'](db[_0xf318('0x40')]['rawAttributes'],function(_0x43f2e0){return{'name':_0x43f2e0['fieldName'],'type':_0x43f2e0[_0xf318('0x41')][_0xf318('0x42')]};});_0x5e93bc[_0xf318('0x43')]=_[_0xf318('0x44')](_0x21031d,_0xf318('0x3e'));_0x5e93bc['query']=_[_0xf318('0x45')](_0x316557[_0xf318('0x46')]);_0x5e93bc[_0xf318('0x47')]=_[_0xf318('0x48')](_0x5e93bc['model'],_0x5e93bc[_0xf318('0x46')]);_0x394bef['attributes']=_[_0xf318('0x48')](_0x5e93bc[_0xf318('0x43')],qs[_0xf318('0x49')](_0x316557[_0xf318('0x46')][_0xf318('0x49')]));_0x394bef['attributes']=_0x394bef[_0xf318('0x4a')][_0xf318('0x4b')]?_0x394bef[_0xf318('0x4a')]:_0x5e93bc[_0xf318('0x43')];if(!_0x316557[_0xf318('0x46')][_0xf318('0x4c')]('nolimit')){_0x394bef[_0xf318('0x35')]=qs['limit'](_0x316557[_0xf318('0x46')][_0xf318('0x35')]);_0x394bef[_0xf318('0x34')]=qs[_0xf318('0x34')](_0x316557[_0xf318('0x46')][_0xf318('0x34')]);}_0x394bef[_0xf318('0x4d')]=qs[_0xf318('0x4e')](_0x316557[_0xf318('0x46')][_0xf318('0x4e')]);_0x394bef[_0xf318('0x4f')]=qs[_0xf318('0x47')](_[_0xf318('0x50')](_0x316557[_0xf318('0x46')],_0x5e93bc[_0xf318('0x47')]),_0x21031d);if(_0x316557[_0xf318('0x46')][_0xf318('0x51')]){_0x394bef[_0xf318('0x4f')]=_['merge'](_0x394bef[_0xf318('0x4f')],{'$or':_[_0xf318('0x44')](_0x21031d,function(_0x375afa){if(_0x375afa[_0xf318('0x41')]!=='VIRTUAL'){var _0x29028d={};_0x29028d[_0x375afa['name']]={'$like':'%'+_0x316557[_0xf318('0x46')][_0xf318('0x51')]+'%'};return _0x29028d;}})});}_0x394bef=_['merge']({},_0x394bef,_0x316557[_0xf318('0x52')]);var _0x1c0ebe={'where':_0x394bef[_0xf318('0x4f')]};return db[_0xf318('0x40')]['count'](_0x1c0ebe)[_0xf318('0x24')](function(_0x11311a){_0x41d3e9['count']=_0x11311a;if(_0x316557[_0xf318('0x46')]['includeAll']){_0x394bef[_0xf318('0x53')]=[{'all':!![]}];}return db[_0xf318('0x40')][_0xf318('0x54')](_0x394bef);})[_0xf318('0x24')](function(_0x34abc3){_0x41d3e9['rows']=_0x34abc3;return _0x41d3e9;})[_0xf318('0x24')](respondWithFilteredResult(_0x27cdb6,_0x394bef))[_0xf318('0x2f')](handleError(_0x27cdb6,null));};exports['show']=function(_0xdfa9f6,_0x30a31c){var _0x537d9e={'raw':!![],'where':{'id':_0xdfa9f6[_0xf318('0x55')]['id']}},_0x446aa9={};_0x446aa9[_0xf318('0x43')]=_[_0xf318('0x45')](db[_0xf318('0x40')]['rawAttributes']);_0x446aa9[_0xf318('0x46')]=_[_0xf318('0x45')](_0xdfa9f6['query']);_0x446aa9[_0xf318('0x47')]=_['intersection'](_0x446aa9[_0xf318('0x43')],_0x446aa9[_0xf318('0x46')]);_0x537d9e[_0xf318('0x4a')]=_['intersection'](_0x446aa9[_0xf318('0x43')],qs['fields'](_0xdfa9f6[_0xf318('0x46')][_0xf318('0x49')]));_0x537d9e[_0xf318('0x4a')]=_0x537d9e['attributes'][_0xf318('0x4b')]?_0x537d9e[_0xf318('0x4a')]:_0x446aa9[_0xf318('0x43')];if(_0xdfa9f6[_0xf318('0x46')][_0xf318('0x56')]){_0x537d9e[_0xf318('0x53')]=[{'all':!![]}];}_0x537d9e=_['merge']({},_0x537d9e,_0xdfa9f6['options']);return db[_0xf318('0x40')][_0xf318('0x57')](_0x537d9e)[_0xf318('0x24')](handleEntityNotFound(_0x30a31c,null))[_0xf318('0x24')](respondWithResult(_0x30a31c,null))[_0xf318('0x2f')](handleError(_0x30a31c,null));};exports[_0xf318('0x58')]=function(_0x5582f5,_0x4f7fc1){return db[_0xf318('0x40')]['create'](_0x5582f5[_0xf318('0x59')],{})['then'](function(_0x11fa45){var _0x238421=_0x5582f5['user'][_0xf318('0x5a')]({'plain':!![]});if(!_0x238421)throw new Error(_0xf318('0x5b'));if(_0x238421[_0xf318('0x5c')]==='user'){var _0x425a2f=_0x11fa45[_0xf318('0x5a')]({'plain':!![]});var _0x45ebd4=_0xf318('0x5d');return db[_0xf318('0x5e')][_0xf318('0x57')]({'where':{'name':_0x45ebd4,'userProfileId':_0x238421[_0xf318('0x5f')]},'raw':!![]})[_0xf318('0x24')](function(_0x156f6e){if(_0x156f6e&&_0x156f6e[_0xf318('0x60')]===0x0){return db[_0xf318('0x3d')][_0xf318('0x58')]({'name':_0x425a2f[_0xf318('0x3e')],'resourceId':_0x425a2f['id'],'type':_0x156f6e[_0xf318('0x3e')],'sectionId':_0x156f6e['id']},{})[_0xf318('0x24')](function(){return _0x11fa45;});}else{return _0x11fa45;}})['catch'](function(_0x2a5a07){logger['error'](_0xf318('0x61'),_0x2a5a07);throw _0x2a5a07;});}return _0x11fa45;})[_0xf318('0x24')](respondWithResult(_0x4f7fc1,0xc9))[_0xf318('0x2f')](handleError(_0x4f7fc1,null));};exports[_0xf318('0x3b')]=function(_0x4500ca,_0x1b8493){if(_0x4500ca[_0xf318('0x59')]['id']){delete _0x4500ca[_0xf318('0x59')]['id'];}return db[_0xf318('0x40')][_0xf318('0x57')]({'where':{'id':_0x4500ca[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x1b8493,null))[_0xf318('0x24')](saveUpdates(_0x4500ca[_0xf318('0x59')],null))[_0xf318('0x24')](respondWithResult(_0x1b8493,null))[_0xf318('0x2f')](handleError(_0x1b8493,null));};exports['destroy']=function(_0xe2ab02,_0x1d518a){return db[_0xf318('0x40')][_0xf318('0x57')]({'where':{'id':_0xe2ab02['params']['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x1d518a,null))[_0xf318('0x24')](removeEntity(_0x1d518a,null))['catch'](handleError(_0x1d518a,null));};exports[_0xf318('0x62')]=function(_0x180bca,_0x51b9ad){return db[_0xf318('0x40')][_0xf318('0x62')]()[_0xf318('0x24')](respondWithResult(_0x51b9ad,null))[_0xf318('0x2f')](handleError(_0x51b9ad,null));};exports[_0xf318('0x63')]=function(_0x11b75e,_0x2ba8a7,_0x173498){var _0x347925={'raw':!![],'where':{}},_0x4c62cc={},_0x4dcd37;return db[_0xf318('0x40')]['findOne']({'where':{'id':_0x11b75e[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x2ba8a7,null))['then'](function(_0xc7fc28){if(_0xc7fc28){_0x4dcd37=_0xc7fc28['get']({'plain':!![]});_0x4c62cc[_0xf318('0x43')]=_[_0xf318('0x45')](db[_0xf318('0x64')][_0xf318('0x65')]);_0x4c62cc[_0xf318('0x46')]=_[_0xf318('0x45')](_0x11b75e[_0xf318('0x46')]);_0x4c62cc[_0xf318('0x47')]=_['intersection'](_0x4c62cc[_0xf318('0x43')],_0x4c62cc['query']);_0x347925[_0xf318('0x4a')]=_[_0xf318('0x48')](_0x4c62cc[_0xf318('0x43')],qs[_0xf318('0x49')](_0x11b75e[_0xf318('0x46')][_0xf318('0x49')]));_0x347925[_0xf318('0x4a')]=_0x347925[_0xf318('0x4a')][_0xf318('0x4b')]?_0x347925[_0xf318('0x4a')]:_0x4c62cc[_0xf318('0x43')];if(!_0x11b75e[_0xf318('0x46')]['hasOwnProperty'](_0xf318('0x66'))){_0x347925[_0xf318('0x35')]=qs['limit'](_0x11b75e[_0xf318('0x46')][_0xf318('0x35')]);_0x347925[_0xf318('0x34')]=qs[_0xf318('0x34')](_0x11b75e[_0xf318('0x46')]['offset']);}_0x347925[_0xf318('0x4d')]=qs[_0xf318('0x4e')](_0x11b75e[_0xf318('0x46')][_0xf318('0x4e')]);_0x347925[_0xf318('0x4f')]=qs['filters'](_[_0xf318('0x50')](_0x11b75e[_0xf318('0x46')],_0x4c62cc[_0xf318('0x47')]));_0x347925['where'][_0xf318('0x67')]=_0xc7fc28['id'];if(_0x11b75e[_0xf318('0x46')]['filter']){_0x347925[_0xf318('0x4f')]=_[_0xf318('0x68')](_0x347925[_0xf318('0x4f')],{'$or':_[_0xf318('0x44')](_0x347925[_0xf318('0x4a')],function(_0x25aa9d){var _0x38be15={};_0x38be15[_0x25aa9d]={'$like':'%'+_0x11b75e[_0xf318('0x46')][_0xf318('0x51')]+'%'};return _0x38be15;})});}_0x347925=_[_0xf318('0x68')]({},_0x347925,_0x11b75e[_0xf318('0x52')]);return db[_0xf318('0x64')][_0xf318('0x54')](_0x347925);}})[_0xf318('0x24')](function(_0x22723b){if(_0x22723b){return db[_0xf318('0x69')][_0xf318('0x6a')]({'where':{'id':_[_0xf318('0x44')](_0x22723b,_0xf318('0x6b')),'role':'agent'},'attributes':['id',_0xf318('0x3e'),_0xf318('0x6c'),_0xf318('0x6d'),'createdAt']});}})['then'](function(_0x1ce4cc){if(_0x1ce4cc){return{'count':_0x1ce4cc[_0xf318('0x37')],'rows':_[_0xf318('0x44')](_0x1ce4cc[_0xf318('0x6e')],function(_0xb62589){return{'membername':_0xb62589[_0xf318('0x3e')],'UserId':_0xb62589['id'],'queue_name':_0x4dcd37[_0xf318('0x3e')],'ChatQueueId':_0x4dcd37['id'],'interface':util[_0xf318('0x6f')](_0xf318('0x70'),_0xf318('0x71'),_0xb62589['name']),'penalty':0x0,'paused':_0xb62589[_0xf318('0x6c')],'createdAt':_0xb62589[_0xf318('0x72')],'updatedAt':_0xb62589['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xf318('0x24')](respondWithFilteredResult(_0x2ba8a7,_0x347925))[_0xf318('0x2f')](handleError(_0x2ba8a7,null));};exports[_0xf318('0x73')]=function(_0x1c161f,_0x2852f7,_0x28ad8c){var _0x21e12e={};var _0x429210={};var _0x57fef5;var _0xd905cb;return db[_0xf318('0x40')]['findOne']({'where':{'id':_0x1c161f[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x2852f7,null))['then'](function(_0x561793){if(_0x561793){_0x57fef5=_0x561793;_0x429210[_0xf318('0x43')]=_[_0xf318('0x45')](db[_0xf318('0x74')][_0xf318('0x65')]);_0x429210['query']=_[_0xf318('0x45')](_0x1c161f[_0xf318('0x46')]);_0x429210[_0xf318('0x47')]=_['intersection'](_0x429210[_0xf318('0x43')],_0x429210[_0xf318('0x46')]);_0x21e12e[_0xf318('0x4a')]=_[_0xf318('0x48')](_0x429210[_0xf318('0x43')],qs['fields'](_0x1c161f[_0xf318('0x46')][_0xf318('0x49')]));_0x21e12e['attributes']=_0x21e12e[_0xf318('0x4a')][_0xf318('0x4b')]?_0x21e12e[_0xf318('0x4a')]:_0x429210[_0xf318('0x43')];_0x21e12e[_0xf318('0x4d')]=qs['sort'](_0x1c161f[_0xf318('0x46')][_0xf318('0x4e')]);_0x21e12e[_0xf318('0x4f')]=qs['filters'](_[_0xf318('0x50')](_0x1c161f[_0xf318('0x46')],_0x429210[_0xf318('0x47')]));if(_0x1c161f[_0xf318('0x46')]['filter']){_0x21e12e['where']=_[_0xf318('0x68')](_0x21e12e[_0xf318('0x4f')],{'$or':_[_0xf318('0x44')](_0x21e12e[_0xf318('0x4a')],function(_0x4e1d1b){var _0x269daa={};_0x269daa[_0x4e1d1b]={'$like':'%'+_0x1c161f['query'][_0xf318('0x51')]+'%'};return _0x269daa;})});}_0x21e12e=_[_0xf318('0x68')]({},_0x21e12e,_0x1c161f[_0xf318('0x52')]);return _0x57fef5[_0xf318('0x73')](_0x21e12e);}})[_0xf318('0x24')](function(_0x3dd4ec){if(_0x3dd4ec){_0xd905cb=_0x3dd4ec[_0xf318('0x4b')];if(!_0x1c161f['query'][_0xf318('0x4c')](_0xf318('0x66'))){_0x21e12e['limit']=qs[_0xf318('0x35')](_0x1c161f['query']['limit']);_0x21e12e['offset']=qs[_0xf318('0x34')](_0x1c161f[_0xf318('0x46')][_0xf318('0x34')]);}return _0x57fef5[_0xf318('0x73')](_0x21e12e);}})[_0xf318('0x24')](function(_0x550350){if(_0x550350){return _0x550350?{'count':_0xd905cb,'rows':_0x550350}:null;}})[_0xf318('0x24')](respondWithResult(_0x2852f7,null))['catch'](handleError(_0x2852f7,null));};exports[_0xf318('0x75')]=function(_0x2ec2c2,_0x1fdba4,_0xcc065b){var _0x1fbc03=_0x2ec2c2[_0xf318('0x59')]['ids'];return db[_0xf318('0x74')][_0xf318('0x54')]({'where':{'id':_0x1fbc03},'attributes':['id'],'include':[{'model':db['User'],'as':_0xf318('0x76'),'attributes':['id',_0xf318('0x3e'),'online',_0xf318('0x77'),'interface'],'raw':!![]}]})[_0xf318('0x24')](function(_0x2287c8){if(_0x2287c8){var _0x15ad5a=_[_0xf318('0x78')](_0x2287c8,function(_0x14098f){var _0x1cc7dd=_0x14098f[_0xf318('0x5a')]({'plain':!![]});return _0x1cc7dd[_0xf318('0x76')];});return db[_0xf318('0x40')][_0xf318('0x57')]({'where':{'id':_0x2ec2c2[_0xf318('0x55')]['id']}})[_0xf318('0x24')](function(_0x309a52){return db[_0xf318('0x79')][_0xf318('0x7a')](function(_0xfc6367){return _0x309a52[_0xf318('0x75')](_0x1fbc03,{'transaction':_0xfc6367})[_0xf318('0x24')](function(){return BPromise['each'](_0x15ad5a,function(_0x1da840){return db[_0xf318('0x64')]['findOrCreate']({'where':{'UserId':_0x1da840['id'],'ChatQueueId':_0x2ec2c2[_0xf318('0x55')]['id']},'transaction':_0xfc6367});});})[_0xf318('0x24')](function(){_0x15ad5a['forEach'](function(_0x562b48){socket[_0xf318('0x7b')]('userChatQueue:save',{'UserId':_0x562b48['id'],'ChatQueueId':_0x309a52['id']});});});});});}})[_0xf318('0x24')](respondWithStatusCode(_0x1fdba4,null))['catch'](handleError(_0x1fdba4,null));};exports[_0xf318('0x7c')]=function(_0xef60ae,_0x42ab7c,_0x3cccb6){return db[_0xf318('0x74')][_0xf318('0x54')]({'where':{'id':_0xef60ae[_0xf318('0x46')][_0xf318('0x7d')]},'attributes':['id'],'include':[{'model':db[_0xf318('0x69')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xf318('0x24')](handleEntityNotFound(_0x42ab7c,null))[_0xf318('0x24')](function(_0x4e03e2){var _0x4e4a44=_['map'](_0x4e03e2,'id');var _0x70c0fa=[];var _0x49027e=[];var _0x5c31dd=squel[_0xf318('0x7e')]();_0x5c31dd[_0xf318('0x7f')](_0xf318('0x80'))[_0xf318('0x81')](_0xf318('0x82'),'tq')[_0xf318('0x83')](_0xf318('0x84'),'ut',_0xf318('0x85'))[_0xf318('0x4f')](_0xf318('0x86'),_0xef60ae[_0xf318('0x55')]['id']);for(var _0x40eedc=0x0;_0x40eedc<_0x4e03e2[_0xf318('0x4b')];_0x40eedc+=0x1){let _0x72d822=_0x4e03e2[_0x40eedc];for(var _0x2531a0=0x0;_0x2531a0<_0x72d822[_0xf318('0x76')][_0xf318('0x4b')];_0x2531a0+=0x1){let _0x2f94c0=_0x72d822['Agents'][_0x2531a0];var _0x4e6531=_0x5c31dd[_0xf318('0x87')]();_0x4e6531[_0xf318('0x4f')]('ut.UserId\x20=\x20?',_0x2f94c0['id']);_0x49027e[_0xf318('0x88')](db[_0xf318('0x79')][_0xf318('0x46')](_0x4e6531[_0xf318('0x89')](),{'type':db[_0xf318('0x79')][_0xf318('0x8a')][_0xf318('0x8b')]})['then'](function(_0x7e5652){if(_0x7e5652[_0xf318('0x4b')]===0x1){return _0x2f94c0['id'];}else{var _0x15480a=_[_0xf318('0x8c')](_[_0xf318('0x44')](_0x7e5652,_0xf318('0x8d')),function(_0x32ab0f){return _[_0xf318('0x8e')](_0x4e4a44,_0x32ab0f);});if(_0x15480a){return _0x2f94c0['id'];}}}));}}return BPromise[_0xf318('0x8f')](_0x49027e)[_0xf318('0x24')](function(_0x582167){_0x70c0fa=_(_0x70c0fa)[_0xf318('0x90')](_0x582167)[_0xf318('0x91')]()[_0xf318('0x92')]();return db[_0xf318('0x40')]['find']({'where':{'id':_0xef60ae['params']['id']}})[_0xf318('0x24')](function(_0x5b7c90){return db[_0xf318('0x79')][_0xf318('0x7a')](function(_0x27a390){return _0x5b7c90[_0xf318('0x7c')](_0xef60ae[_0xf318('0x46')][_0xf318('0x7d')],{'transaction':_0x27a390})[_0xf318('0x24')](function(){if(!_['isEmpty'](_0x70c0fa)){return _0x5b7c90[_0xf318('0x93')](_0x70c0fa,{'transaction':_0x27a390});}})['then'](function(){_0x70c0fa[_0xf318('0x94')](function(_0x118cce){socket[_0xf318('0x7b')](_0xf318('0x95'),{'UserId':_0x118cce,'ChatQueueId':_0x5b7c90['id']});});});});});});})['then'](respondWithStatusCode(_0x42ab7c,null))['catch'](handleError(_0x42ab7c,null));};exports[_0xf318('0x96')]=function(_0x5ea601,_0x4e9ea8,_0x11b294){return db[_0xf318('0x40')]['find']({'where':{'id':_0x5ea601[_0xf318('0x55')]['id']}})['then'](handleEntityNotFound(_0x4e9ea8,null))[_0xf318('0x24')](function(_0x4b2117){if(_0x4b2117){return _0x4b2117['addAgents'](_0x5ea601[_0xf318('0x59')][_0xf318('0x7d')],_['omit'](_0x5ea601[_0xf318('0x59')],[_0xf318('0x7d'),'id'])||{})[_0xf318('0x97')](function(_0x526b2e){for(var _0x3b997d=0x0;_0x3b997d<_0x5ea601[_0xf318('0x59')][_0xf318('0x7d')][_0xf318('0x4b')];_0x3b997d+=0x1){socket[_0xf318('0x7b')](_0xf318('0x98'),{'UserId':_0x5ea601['body'][_0xf318('0x7d')][_0x3b997d],'ChatQueueId':_0x5ea601[_0xf318('0x55')]['id']});}return _0x526b2e;});}})['then'](respondWithResult(_0x4e9ea8,null))[_0xf318('0x2f')](handleError(_0x4e9ea8,null));};exports[_0xf318('0x93')]=function(_0x330607,_0x3a26e4,_0x3e8606){return db[_0xf318('0x40')][_0xf318('0x57')]({'where':{'id':_0x330607[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x3a26e4,null))[_0xf318('0x24')](function(_0x115fd9){if(_0x115fd9){return _0x115fd9[_0xf318('0x93')](_0x330607[_0xf318('0x46')]['ids'])[_0xf318('0x24')](function(){if(_[_0xf318('0x99')](_0x330607[_0xf318('0x46')][_0xf318('0x7d')])){for(var _0x238f61=0x0;_0x238f61<_0x330607['query'][_0xf318('0x7d')][_0xf318('0x4b')];_0x238f61+=0x1){socket[_0xf318('0x7b')](_0xf318('0x95'),{'UserId':Number(_0x330607[_0xf318('0x46')][_0xf318('0x7d')][_0x238f61]),'ChatQueueId':Number(_0x330607[_0xf318('0x55')]['id'])});}}else{socket[_0xf318('0x7b')](_0xf318('0x95'),{'UserId':Number(_0x330607[_0xf318('0x46')][_0xf318('0x7d')]),'ChatQueueId':Number(_0x330607[_0xf318('0x55')]['id'])});}});}})[_0xf318('0x24')](respondWithStatusCode(_0x3a26e4,null))[_0xf318('0x2f')](handleError(_0x3a26e4,null));};exports['getAgents']=function(_0x522503,_0x5708ac,_0x209125){var _0x133ba0={};var _0x48a5ad={};var _0x27be66;var _0x4ba910;return db[_0xf318('0x40')][_0xf318('0x9a')]({'where':{'id':_0x522503[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x5708ac,null))[_0xf318('0x24')](function(_0x12cae4){if(_0x12cae4){_0x27be66=_0x12cae4;_0x48a5ad[_0xf318('0x43')]=_['keys'](db[_0xf318('0x69')][_0xf318('0x65')]);_0x48a5ad[_0xf318('0x46')]=_[_0xf318('0x45')](_0x522503[_0xf318('0x46')]);_0x48a5ad['filters']=_[_0xf318('0x48')](_0x48a5ad['model'],_0x48a5ad[_0xf318('0x46')]);_0x133ba0[_0xf318('0x4a')]=_[_0xf318('0x48')](_0x48a5ad['model'],qs['fields'](_0x522503[_0xf318('0x46')][_0xf318('0x49')]));_0x133ba0[_0xf318('0x4a')]=_0x133ba0[_0xf318('0x4a')][_0xf318('0x4b')]?_0x133ba0[_0xf318('0x4a')]:_0x48a5ad[_0xf318('0x43')];_0x133ba0['order']=qs[_0xf318('0x4e')](_0x522503['query'][_0xf318('0x4e')]);_0x133ba0['where']=qs[_0xf318('0x47')](_[_0xf318('0x50')](_0x522503['query'],_0x48a5ad['filters']));if(_0x522503[_0xf318('0x46')][_0xf318('0x51')]){_0x133ba0[_0xf318('0x4f')]=_[_0xf318('0x68')](_0x133ba0[_0xf318('0x4f')],{'$or':_[_0xf318('0x44')](_0x133ba0['attributes'],function(_0x3db5da){var _0xc35c5e={};_0xc35c5e[_0x3db5da]={'$like':'%'+_0x522503[_0xf318('0x46')]['filter']+'%'};return _0xc35c5e;})});}_0x133ba0=_['merge']({},_0x133ba0,_0x522503['options']);return _0x27be66[_0xf318('0x9b')](_0x133ba0);}})[_0xf318('0x24')](function(_0x2a5b9d){if(_0x2a5b9d){_0x4ba910=_0x2a5b9d['length'];if(!_0x522503['query'][_0xf318('0x4c')](_0xf318('0x66'))){_0x133ba0[_0xf318('0x35')]=qs[_0xf318('0x35')](_0x522503[_0xf318('0x46')][_0xf318('0x35')]);_0x133ba0[_0xf318('0x34')]=qs[_0xf318('0x34')](_0x522503[_0xf318('0x46')][_0xf318('0x34')]);}return _0x27be66[_0xf318('0x9b')](_0x133ba0);}})[_0xf318('0x24')](function(_0x36812b){if(_0x36812b){return _0x36812b?{'count':_0x4ba910,'rows':_0x36812b}:null;}})[_0xf318('0x24')](respondWithResult(_0x5708ac,null))['catch'](handleError(_0x5708ac,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