Built motion from commit (unavailable).|2.5.9
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index d260a80..f1133b5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7bfb=['online','interface','flatMap','Agents','sequelize','transaction','each','forEach','emit','userChatQueue:save','removeTeams','select','tq.TeamId','from','join','user_has_teams','ChatQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','every','includes','all','union','compact','isEmpty','userChatQueue:remove','addAgents','omit','spread','removeAgents','getAgents','html-pdf','zip-dir','fast-json-patch','bluebird','mustache','util','path','to-csv','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','socket.io-emitter','register','http','request','info','ChatQueue,\x20%s,\x20%s','request\x20sent','error','message','sendStatus','status','end','count','offset','limit','set','apply','reject','update','then','destroy','get','ChatQueues','UserProfileResource','name','send','map','ChatQueue','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','params','rawAttributes','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','autoAssociation','describe','getMembers','findOne','UserChatQueue','hasOwnProperty','ChatQueueId','User','agent','chatPause','updatedAt','format','%s/%s','SIP','createdAt','getTeams','Team','addTeams','ids'];(function(_0x4bd13b,_0x157a13){var _0x5d1e33=function(_0x39e0a6){while(--_0x39e0a6){_0x4bd13b['push'](_0x4bd13b['shift']());}};_0x5d1e33(++_0x157a13);}(_0x7bfb,0x1b6));var _0xb7bf=function(_0x2b2fb9,_0x26a504){_0x2b2fb9=_0x2b2fb9-0x0;var _0x539499=_0x7bfb[_0x2b2fb9];return _0x539499;};'use strict';var pdf=require(_0xb7bf('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xb7bf('0x1'));var jsonpatch=require(_0xb7bf('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xb7bf('0x3'));var Mustache=require(_0xb7bf('0x4'));var util=require(_0xb7bf('0x5'));var path=require(_0xb7bf('0x6'));var sox=require('sox');var csv=require(_0xb7bf('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xb7bf('0x8'));var squel=require(_0xb7bf('0x9'));var crypto=require(_0xb7bf('0xa'));var jsforce=require(_0xb7bf('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xb7bf('0x7'));var querystring=require(_0xb7bf('0xc'));var Papa=require('papaparse');var Redis=require(_0xb7bf('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xb7bf('0xe'));var as=require(_0xb7bf('0xf'));var hardwareService=require(_0xb7bf('0x10'));var logger=require(_0xb7bf('0x11'))(_0xb7bf('0x12'));var utils=require(_0xb7bf('0x13'));var config=require(_0xb7bf('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0xb7bf('0x15')]=_[_0xb7bf('0x16')](config[_0xb7bf('0x15')],{'host':'localhost','port':0x18eb});var socket=require(_0xb7bf('0x17'))(new Redis(config['redis']));require('./chatQueue.socket')[_0xb7bf('0x18')](socket);var jayson=require('jayson/promise');var client=jayson['client'][_0xb7bf('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x18ff4d,_0x93cb0a,_0x5aa4e7,_0x21f9b8){return new BPromise(function(_0x11827e,_0x2131aa){var _0x27587b=_0x21f9b8||client;return _0x27587b[_0xb7bf('0x1a')](_0x18ff4d,_0x5aa4e7)['then'](function(_0x351770){logger[_0xb7bf('0x1b')](_0xb7bf('0x1c'),_0x93cb0a,_0xb7bf('0x1d'));logger['debug']('ChatQueue,\x20%s,\x20%s,\x20%s',_0x93cb0a,_0xb7bf('0x1d'),JSON['stringify'](_0x351770));if(_0x351770['error']){if(_0x351770[_0xb7bf('0x1e')]['code']===0x1f4){logger['error'](_0xb7bf('0x1c'),_0x93cb0a,_0x351770[_0xb7bf('0x1e')]['message']);return _0x2131aa(_0x351770[_0xb7bf('0x1e')]['message']);}logger[_0xb7bf('0x1e')](_0xb7bf('0x1c'),_0x93cb0a,_0x351770[_0xb7bf('0x1e')][_0xb7bf('0x1f')]);return _0x11827e(_0x351770[_0xb7bf('0x1e')][_0xb7bf('0x1f')]);}else{logger['info'](_0xb7bf('0x1c'),_0x93cb0a,_0xb7bf('0x1d'));_0x11827e(_0x351770['result']['message']);}})['catch'](function(_0x8e3206){logger['error'](_0xb7bf('0x1c'),_0x93cb0a,_0x8e3206);_0x2131aa(_0x8e3206);});});}function respondWithStatusCode(_0xc3c02f,_0x17fc00){_0x17fc00=_0x17fc00||0xcc;return function(_0x160ff3){if(_0x160ff3){return _0xc3c02f[_0xb7bf('0x20')](_0x17fc00);}return _0xc3c02f[_0xb7bf('0x21')](_0x17fc00)[_0xb7bf('0x22')]();};}function respondWithResult(_0x5e33bc,_0x537767){_0x537767=_0x537767||0xc8;return function(_0x43b496){if(_0x43b496){return _0x5e33bc[_0xb7bf('0x21')](_0x537767)['json'](_0x43b496);}};}function respondWithFilteredResult(_0x5545da,_0x30e17e){return function(_0x310a95){if(_0x310a95){var _0xd42c69=_0x310a95[_0xb7bf('0x23')],_0x5ac612=_0x30e17e[_0xb7bf('0x24')],_0x189b50=_0x30e17e[_0xb7bf('0x24')]+_0x30e17e[_0xb7bf('0x25')],_0x29b4d4;if(_0x189b50>=_0xd42c69){_0x189b50=_0xd42c69;_0x29b4d4=0xc8;}else{_0x29b4d4=0xce;}_0x5545da[_0xb7bf('0x21')](_0x29b4d4);return _0x5545da[_0xb7bf('0x26')]('Content-Range',_0x5ac612+'-'+_0x189b50+'/'+_0xd42c69)['json'](_0x310a95);}return null;};}function patchUpdates(_0x3aa287){return function(_0x547e91){try{jsonpatch[_0xb7bf('0x27')](_0x547e91,_0x3aa287,!![]);}catch(_0x1c2d8c){return BPromise[_0xb7bf('0x28')](_0x1c2d8c);}return _0x547e91['save']();};}function saveUpdates(_0x4b07ea,_0x455000){return function(_0x3d0672){if(_0x3d0672){return _0x3d0672[_0xb7bf('0x29')](_0x4b07ea)[_0xb7bf('0x2a')](function(_0x150f61){return _0x150f61;});}return null;};}function removeEntity(_0x4d396e,_0x21813b){return function(_0xc1c7e1){if(_0xc1c7e1){return _0xc1c7e1[_0xb7bf('0x2b')]()['then'](function(){var _0x52d787=_0xc1c7e1[_0xb7bf('0x2c')]({'plain':!![]});var _0x19e707=_0xb7bf('0x2d');return db[_0xb7bf('0x2e')][_0xb7bf('0x2b')]({'where':{'type':_0x19e707,'resourceId':_0x52d787['id']}})['then'](function(){return _0xc1c7e1;});})['then'](function(){_0x4d396e['status'](0xcc)[_0xb7bf('0x22')]();});}};}function handleEntityNotFound(_0x354ac6,_0x487510){return function(_0x5cb2fd){if(!_0x5cb2fd){_0x354ac6[_0xb7bf('0x20')](0x194);}return _0x5cb2fd;};}function handleError(_0x391ebe,_0x1ea289){_0x1ea289=_0x1ea289||0x1f4;return function(_0x3d0daf){logger['error'](_0x3d0daf['stack']);if(_0x3d0daf[_0xb7bf('0x2f')]){delete _0x3d0daf[_0xb7bf('0x2f')];}_0x391ebe[_0xb7bf('0x21')](_0x1ea289)[_0xb7bf('0x30')](_0x3d0daf);};}exports['index']=function(_0x5af703,_0x45c9bc){var _0x4d7306={},_0x585d6d={},_0x303d08={'count':0x0,'rows':[]};var _0x418a85=_[_0xb7bf('0x31')](db[_0xb7bf('0x32')]['rawAttributes'],function(_0x479f89){return{'name':_0x479f89['fieldName'],'type':_0x479f89[_0xb7bf('0x33')][_0xb7bf('0x34')]};});_0x585d6d[_0xb7bf('0x35')]=_[_0xb7bf('0x31')](_0x418a85,_0xb7bf('0x2f'));_0x585d6d[_0xb7bf('0x36')]=_[_0xb7bf('0x37')](_0x5af703[_0xb7bf('0x36')]);_0x585d6d[_0xb7bf('0x38')]=_[_0xb7bf('0x39')](_0x585d6d[_0xb7bf('0x35')],_0x585d6d['query']);_0x4d7306[_0xb7bf('0x3a')]=_[_0xb7bf('0x39')](_0x585d6d[_0xb7bf('0x35')],qs[_0xb7bf('0x3b')](_0x5af703[_0xb7bf('0x36')][_0xb7bf('0x3b')]));_0x4d7306[_0xb7bf('0x3a')]=_0x4d7306['attributes'][_0xb7bf('0x3c')]?_0x4d7306['attributes']:_0x585d6d[_0xb7bf('0x35')];if(!_0x5af703[_0xb7bf('0x36')]['hasOwnProperty'](_0xb7bf('0x3d'))){_0x4d7306[_0xb7bf('0x25')]=qs[_0xb7bf('0x25')](_0x5af703[_0xb7bf('0x36')][_0xb7bf('0x25')]);_0x4d7306[_0xb7bf('0x24')]=qs[_0xb7bf('0x24')](_0x5af703['query']['offset']);}_0x4d7306[_0xb7bf('0x3e')]=qs[_0xb7bf('0x3f')](_0x5af703[_0xb7bf('0x36')][_0xb7bf('0x3f')]);_0x4d7306[_0xb7bf('0x40')]=qs[_0xb7bf('0x38')](_[_0xb7bf('0x41')](_0x5af703['query'],_0x585d6d[_0xb7bf('0x38')]),_0x418a85);if(_0x5af703['query'][_0xb7bf('0x42')]){_0x4d7306[_0xb7bf('0x40')]=_['merge'](_0x4d7306[_0xb7bf('0x40')],{'$or':_[_0xb7bf('0x31')](_0x418a85,function(_0x3828f){if(_0x3828f[_0xb7bf('0x33')]!==_0xb7bf('0x43')){var _0x507a49={};_0x507a49[_0x3828f[_0xb7bf('0x2f')]]={'$like':'%'+_0x5af703['query'][_0xb7bf('0x42')]+'%'};return _0x507a49;}})});}_0x4d7306=_[_0xb7bf('0x44')]({},_0x4d7306,_0x5af703[_0xb7bf('0x45')]);var _0x45de06={'where':_0x4d7306['where']};return db['ChatQueue'][_0xb7bf('0x23')](_0x45de06)[_0xb7bf('0x2a')](function(_0x589e19){_0x303d08['count']=_0x589e19;if(_0x5af703[_0xb7bf('0x36')][_0xb7bf('0x46')]){_0x4d7306[_0xb7bf('0x47')]=[{'all':!![]}];}return db[_0xb7bf('0x32')][_0xb7bf('0x48')](_0x4d7306);})[_0xb7bf('0x2a')](function(_0x15e17b){_0x303d08[_0xb7bf('0x49')]=_0x15e17b;return _0x303d08;})[_0xb7bf('0x2a')](respondWithFilteredResult(_0x45c9bc,_0x4d7306))[_0xb7bf('0x4a')](handleError(_0x45c9bc,null));};exports['show']=function(_0x46b4a4,_0x3b3eb1){var _0x3a2a6a={'raw':!![],'where':{'id':_0x46b4a4[_0xb7bf('0x4b')]['id']}},_0x52198c={};_0x52198c[_0xb7bf('0x35')]=_[_0xb7bf('0x37')](db[_0xb7bf('0x32')][_0xb7bf('0x4c')]);_0x52198c[_0xb7bf('0x36')]=_[_0xb7bf('0x37')](_0x46b4a4[_0xb7bf('0x36')]);_0x52198c[_0xb7bf('0x38')]=_[_0xb7bf('0x39')](_0x52198c['model'],_0x52198c[_0xb7bf('0x36')]);_0x3a2a6a[_0xb7bf('0x3a')]=_[_0xb7bf('0x39')](_0x52198c['model'],qs['fields'](_0x46b4a4[_0xb7bf('0x36')][_0xb7bf('0x3b')]));_0x3a2a6a[_0xb7bf('0x3a')]=_0x3a2a6a[_0xb7bf('0x3a')][_0xb7bf('0x3c')]?_0x3a2a6a[_0xb7bf('0x3a')]:_0x52198c['model'];if(_0x46b4a4[_0xb7bf('0x36')][_0xb7bf('0x46')]){_0x3a2a6a['include']=[{'all':!![]}];}_0x3a2a6a=_[_0xb7bf('0x44')]({},_0x3a2a6a,_0x46b4a4[_0xb7bf('0x45')]);return db[_0xb7bf('0x32')][_0xb7bf('0x4d')](_0x3a2a6a)[_0xb7bf('0x2a')](handleEntityNotFound(_0x3b3eb1,null))[_0xb7bf('0x2a')](respondWithResult(_0x3b3eb1,null))[_0xb7bf('0x4a')](handleError(_0x3b3eb1,null));};exports[_0xb7bf('0x4e')]=function(_0x5aca5d,_0x2c5de6){return db[_0xb7bf('0x32')]['create'](_0x5aca5d[_0xb7bf('0x4f')],{})[_0xb7bf('0x2a')](function(_0x3a4039){var _0x2e24fa=_0x5aca5d[_0xb7bf('0x50')][_0xb7bf('0x2c')]({'plain':!![]});if(!_0x2e24fa)throw new Error(_0xb7bf('0x51'));if(_0x2e24fa['role']===_0xb7bf('0x50')){var _0x5cb136=_0x3a4039[_0xb7bf('0x2c')]({'plain':!![]});var _0x23154f='ChatQueues';return db[_0xb7bf('0x52')][_0xb7bf('0x4d')]({'where':{'name':_0x23154f,'userProfileId':_0x2e24fa['userProfileId']},'raw':!![]})[_0xb7bf('0x2a')](function(_0x209030){if(_0x209030&&_0x209030[_0xb7bf('0x53')]===0x0){return db['UserProfileResource'][_0xb7bf('0x4e')]({'name':_0x5cb136[_0xb7bf('0x2f')],'resourceId':_0x5cb136['id'],'type':_0x209030[_0xb7bf('0x2f')],'sectionId':_0x209030['id']},{})[_0xb7bf('0x2a')](function(){return _0x3a4039;});}else{return _0x3a4039;}})[_0xb7bf('0x4a')](function(_0x56752e){logger[_0xb7bf('0x1e')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x56752e);throw _0x56752e;});}return _0x3a4039;})[_0xb7bf('0x2a')](respondWithResult(_0x2c5de6,0xc9))[_0xb7bf('0x4a')](handleError(_0x2c5de6,null));};exports['update']=function(_0x5aaa9f,_0x30afdd){if(_0x5aaa9f[_0xb7bf('0x4f')]['id']){delete _0x5aaa9f['body']['id'];}return db[_0xb7bf('0x32')][_0xb7bf('0x4d')]({'where':{'id':_0x5aaa9f[_0xb7bf('0x4b')]['id']}})[_0xb7bf('0x2a')](handleEntityNotFound(_0x30afdd,null))[_0xb7bf('0x2a')](saveUpdates(_0x5aaa9f[_0xb7bf('0x4f')],null))[_0xb7bf('0x2a')](respondWithResult(_0x30afdd,null))[_0xb7bf('0x4a')](handleError(_0x30afdd,null));};exports[_0xb7bf('0x2b')]=function(_0x248cb2,_0x493359){return db[_0xb7bf('0x32')][_0xb7bf('0x4d')]({'where':{'id':_0x248cb2[_0xb7bf('0x4b')]['id']}})[_0xb7bf('0x2a')](handleEntityNotFound(_0x493359,null))[_0xb7bf('0x2a')](removeEntity(_0x493359,null))['catch'](handleError(_0x493359,null));};exports[_0xb7bf('0x54')]=function(_0x3e271a,_0x280319){return db[_0xb7bf('0x32')]['describe']()[_0xb7bf('0x2a')](respondWithResult(_0x280319,null))[_0xb7bf('0x4a')](handleError(_0x280319,null));};exports[_0xb7bf('0x55')]=function(_0x5454bf,_0x387f72,_0xf8ad59){var _0x4f6a50={'raw':!![],'where':{}},_0x532319={},_0x32e245;return db['ChatQueue'][_0xb7bf('0x56')]({'where':{'id':_0x5454bf['params']['id']}})[_0xb7bf('0x2a')](handleEntityNotFound(_0x387f72,null))[_0xb7bf('0x2a')](function(_0x431956){if(_0x431956){_0x32e245=_0x431956[_0xb7bf('0x2c')]({'plain':!![]});_0x532319[_0xb7bf('0x35')]=_[_0xb7bf('0x37')](db[_0xb7bf('0x57')][_0xb7bf('0x4c')]);_0x532319[_0xb7bf('0x36')]=_[_0xb7bf('0x37')](_0x5454bf[_0xb7bf('0x36')]);_0x532319[_0xb7bf('0x38')]=_[_0xb7bf('0x39')](_0x532319['model'],_0x532319[_0xb7bf('0x36')]);_0x4f6a50[_0xb7bf('0x3a')]=_[_0xb7bf('0x39')](_0x532319[_0xb7bf('0x35')],qs[_0xb7bf('0x3b')](_0x5454bf['query']['fields']));_0x4f6a50['attributes']=_0x4f6a50['attributes']['length']?_0x4f6a50[_0xb7bf('0x3a')]:_0x532319[_0xb7bf('0x35')];if(!_0x5454bf[_0xb7bf('0x36')][_0xb7bf('0x58')](_0xb7bf('0x3d'))){_0x4f6a50[_0xb7bf('0x25')]=qs[_0xb7bf('0x25')](_0x5454bf[_0xb7bf('0x36')]['limit']);_0x4f6a50['offset']=qs['offset'](_0x5454bf[_0xb7bf('0x36')][_0xb7bf('0x24')]);}_0x4f6a50[_0xb7bf('0x3e')]=qs[_0xb7bf('0x3f')](_0x5454bf[_0xb7bf('0x36')][_0xb7bf('0x3f')]);_0x4f6a50[_0xb7bf('0x40')]=qs['filters'](_[_0xb7bf('0x41')](_0x5454bf[_0xb7bf('0x36')],_0x532319['filters']));_0x4f6a50[_0xb7bf('0x40')][_0xb7bf('0x59')]=_0x431956['id'];if(_0x5454bf[_0xb7bf('0x36')][_0xb7bf('0x42')]){_0x4f6a50[_0xb7bf('0x40')]=_[_0xb7bf('0x44')](_0x4f6a50[_0xb7bf('0x40')],{'$or':_[_0xb7bf('0x31')](_0x4f6a50[_0xb7bf('0x3a')],function(_0x495f97){var _0x4c0cc7={};_0x4c0cc7[_0x495f97]={'$like':'%'+_0x5454bf[_0xb7bf('0x36')][_0xb7bf('0x42')]+'%'};return _0x4c0cc7;})});}_0x4f6a50=_[_0xb7bf('0x44')]({},_0x4f6a50,_0x5454bf[_0xb7bf('0x45')]);return db[_0xb7bf('0x57')][_0xb7bf('0x48')](_0x4f6a50);}})['then'](function(_0x20008f){if(_0x20008f){return db[_0xb7bf('0x5a')]['findAndCountAll']({'where':{'id':_[_0xb7bf('0x31')](_0x20008f,'UserId'),'role':_0xb7bf('0x5b')},'attributes':['id',_0xb7bf('0x2f'),_0xb7bf('0x5c'),_0xb7bf('0x5d'),'createdAt']});}})[_0xb7bf('0x2a')](function(_0x42f1da){if(_0x42f1da){return{'count':_0x42f1da[_0xb7bf('0x23')],'rows':_[_0xb7bf('0x31')](_0x42f1da['rows'],function(_0x253cde){return{'membername':_0x253cde[_0xb7bf('0x2f')],'UserId':_0x253cde['id'],'queue_name':_0x32e245[_0xb7bf('0x2f')],'ChatQueueId':_0x32e245['id'],'interface':util[_0xb7bf('0x5e')](_0xb7bf('0x5f'),_0xb7bf('0x60'),_0x253cde[_0xb7bf('0x2f')]),'penalty':0x0,'paused':_0x253cde[_0xb7bf('0x5c')],'createdAt':_0x253cde[_0xb7bf('0x61')],'updatedAt':_0x253cde[_0xb7bf('0x5d')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xb7bf('0x2a')](respondWithFilteredResult(_0x387f72,_0x4f6a50))[_0xb7bf('0x4a')](handleError(_0x387f72,null));};exports[_0xb7bf('0x62')]=function(_0x583d54,_0x339c81,_0x4c9332){var _0x11ef0d={};var _0x474e6f={};var _0xdfb9dd;var _0x506905;return db[_0xb7bf('0x32')][_0xb7bf('0x56')]({'where':{'id':_0x583d54[_0xb7bf('0x4b')]['id']}})[_0xb7bf('0x2a')](handleEntityNotFound(_0x339c81,null))[_0xb7bf('0x2a')](function(_0x806ffd){if(_0x806ffd){_0xdfb9dd=_0x806ffd;_0x474e6f[_0xb7bf('0x35')]=_[_0xb7bf('0x37')](db[_0xb7bf('0x63')]['rawAttributes']);_0x474e6f[_0xb7bf('0x36')]=_[_0xb7bf('0x37')](_0x583d54[_0xb7bf('0x36')]);_0x474e6f[_0xb7bf('0x38')]=_[_0xb7bf('0x39')](_0x474e6f['model'],_0x474e6f[_0xb7bf('0x36')]);_0x11ef0d[_0xb7bf('0x3a')]=_[_0xb7bf('0x39')](_0x474e6f[_0xb7bf('0x35')],qs[_0xb7bf('0x3b')](_0x583d54[_0xb7bf('0x36')][_0xb7bf('0x3b')]));_0x11ef0d['attributes']=_0x11ef0d[_0xb7bf('0x3a')][_0xb7bf('0x3c')]?_0x11ef0d['attributes']:_0x474e6f[_0xb7bf('0x35')];_0x11ef0d[_0xb7bf('0x3e')]=qs['sort'](_0x583d54[_0xb7bf('0x36')]['sort']);_0x11ef0d[_0xb7bf('0x40')]=qs[_0xb7bf('0x38')](_[_0xb7bf('0x41')](_0x583d54[_0xb7bf('0x36')],_0x474e6f['filters']));if(_0x583d54[_0xb7bf('0x36')]['filter']){_0x11ef0d['where']=_['merge'](_0x11ef0d[_0xb7bf('0x40')],{'$or':_[_0xb7bf('0x31')](_0x11ef0d[_0xb7bf('0x3a')],function(_0x310227){var _0x26eac4={};_0x26eac4[_0x310227]={'$like':'%'+_0x583d54[_0xb7bf('0x36')][_0xb7bf('0x42')]+'%'};return _0x26eac4;})});}_0x11ef0d=_[_0xb7bf('0x44')]({},_0x11ef0d,_0x583d54[_0xb7bf('0x45')]);return _0xdfb9dd['getTeams'](_0x11ef0d);}})[_0xb7bf('0x2a')](function(_0x5096fd){if(_0x5096fd){_0x506905=_0x5096fd['length'];if(!_0x583d54[_0xb7bf('0x36')][_0xb7bf('0x58')](_0xb7bf('0x3d'))){_0x11ef0d[_0xb7bf('0x25')]=qs[_0xb7bf('0x25')](_0x583d54[_0xb7bf('0x36')][_0xb7bf('0x25')]);_0x11ef0d[_0xb7bf('0x24')]=qs[_0xb7bf('0x24')](_0x583d54[_0xb7bf('0x36')][_0xb7bf('0x24')]);}return _0xdfb9dd[_0xb7bf('0x62')](_0x11ef0d);}})['then'](function(_0x4d5b86){if(_0x4d5b86){return _0x4d5b86?{'count':_0x506905,'rows':_0x4d5b86}:null;}})[_0xb7bf('0x2a')](respondWithResult(_0x339c81,null))[_0xb7bf('0x4a')](handleError(_0x339c81,null));};exports[_0xb7bf('0x64')]=function(_0xe3e149,_0x2d0c10,_0x31786b){var _0x3677fd=_0xe3e149[_0xb7bf('0x4f')][_0xb7bf('0x65')];return db[_0xb7bf('0x63')]['findAll']({'where':{'id':_0x3677fd},'attributes':['id'],'include':[{'model':db[_0xb7bf('0x5a')],'as':'Agents','attributes':['id','name',_0xb7bf('0x66'),'voicePause',_0xb7bf('0x67')],'raw':!![]}]})[_0xb7bf('0x2a')](function(_0x210ebe){if(_0x210ebe){var _0xbf51d7=_[_0xb7bf('0x68')](_0x210ebe,function(_0x513d57){var _0x55f7c1=_0x513d57[_0xb7bf('0x2c')]({'plain':!![]});return _0x55f7c1[_0xb7bf('0x69')];});return db[_0xb7bf('0x32')]['find']({'where':{'id':_0xe3e149[_0xb7bf('0x4b')]['id']}})[_0xb7bf('0x2a')](function(_0x2221e3){return db[_0xb7bf('0x6a')][_0xb7bf('0x6b')](function(_0x5e51ad){return _0x2221e3['addTeams'](_0x3677fd,{'transaction':_0x5e51ad})[_0xb7bf('0x2a')](function(){return BPromise[_0xb7bf('0x6c')](_0xbf51d7,function(_0x498a8b){return db['UserChatQueue']['findOrCreate']({'where':{'UserId':_0x498a8b['id'],'ChatQueueId':_0xe3e149[_0xb7bf('0x4b')]['id']},'transaction':_0x5e51ad});});})[_0xb7bf('0x2a')](function(){_0xbf51d7[_0xb7bf('0x6d')](function(_0x526e62){socket[_0xb7bf('0x6e')](_0xb7bf('0x6f'),{'UserId':_0x526e62['id'],'ChatQueueId':_0x2221e3['id']});});});});});}})[_0xb7bf('0x2a')](respondWithStatusCode(_0x2d0c10,null))[_0xb7bf('0x4a')](handleError(_0x2d0c10,null));};exports[_0xb7bf('0x70')]=function(_0x420365,_0x4e132c,_0x16ea74){return db['Team'][_0xb7bf('0x48')]({'where':{'id':_0x420365[_0xb7bf('0x36')]['ids']},'attributes':['id'],'include':[{'model':db[_0xb7bf('0x5a')],'as':_0xb7bf('0x69'),'attributes':['id'],'raw':!![]}]})[_0xb7bf('0x2a')](handleEntityNotFound(_0x4e132c,null))['then'](function(_0x177224){var _0x43cf9f=_['map'](_0x177224,'id');var _0x209356=[];var _0x27a484=[];var _0x4af1e5=squel[_0xb7bf('0x71')]();_0x4af1e5['field'](_0xb7bf('0x72'))[_0xb7bf('0x73')]('team_has_chat_queues','tq')[_0xb7bf('0x74')](_0xb7bf('0x75'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0xb7bf('0x76'),_0x420365[_0xb7bf('0x4b')]['id']);for(var _0x3d3b44=0x0;_0x3d3b44<_0x177224[_0xb7bf('0x3c')];_0x3d3b44+=0x1){let _0xf0f7a0=_0x177224[_0x3d3b44];for(var _0x40571d=0x0;_0x40571d<_0xf0f7a0['Agents'][_0xb7bf('0x3c')];_0x40571d+=0x1){let _0x222a14=_0xf0f7a0['Agents'][_0x40571d];var _0x5aa3d5=_0x4af1e5['clone']();_0x5aa3d5[_0xb7bf('0x40')](_0xb7bf('0x77'),_0x222a14['id']);_0x27a484[_0xb7bf('0x78')](db[_0xb7bf('0x6a')]['query'](_0x5aa3d5['toString'](),{'type':db[_0xb7bf('0x6a')][_0xb7bf('0x79')][_0xb7bf('0x7a')]})[_0xb7bf('0x2a')](function(_0xa2b7e6){if(_0xa2b7e6['length']===0x1){return _0x222a14['id'];}else{var _0x5401cb=_[_0xb7bf('0x7b')](_['map'](_0xa2b7e6,'TeamId'),function(_0x38683a){return _[_0xb7bf('0x7c')](_0x43cf9f,_0x38683a);});if(_0x5401cb){return _0x222a14['id'];}}}));}}return BPromise[_0xb7bf('0x7d')](_0x27a484)[_0xb7bf('0x2a')](function(_0x51d897){_0x209356=_(_0x209356)[_0xb7bf('0x7e')](_0x51d897)[_0xb7bf('0x7f')]()['value']();return db[_0xb7bf('0x32')][_0xb7bf('0x4d')]({'where':{'id':_0x420365[_0xb7bf('0x4b')]['id']}})[_0xb7bf('0x2a')](function(_0x13e60f){return db['sequelize'][_0xb7bf('0x6b')](function(_0x1749a5){return _0x13e60f[_0xb7bf('0x70')](_0x420365[_0xb7bf('0x36')][_0xb7bf('0x65')],{'transaction':_0x1749a5})['then'](function(){if(!_[_0xb7bf('0x80')](_0x209356)){return _0x13e60f['removeAgents'](_0x209356,{'transaction':_0x1749a5});}})['then'](function(){_0x209356[_0xb7bf('0x6d')](function(_0xa14684){socket[_0xb7bf('0x6e')](_0xb7bf('0x81'),{'UserId':_0xa14684,'ChatQueueId':_0x13e60f['id']});});});});});});})[_0xb7bf('0x2a')](respondWithStatusCode(_0x4e132c,null))['catch'](handleError(_0x4e132c,null));};exports[_0xb7bf('0x82')]=function(_0x55ceb0,_0xa98989,_0x23ba42){return db[_0xb7bf('0x32')]['find']({'where':{'id':_0x55ceb0[_0xb7bf('0x4b')]['id']}})['then'](handleEntityNotFound(_0xa98989,null))[_0xb7bf('0x2a')](function(_0x87bf9f){if(_0x87bf9f){return _0x87bf9f[_0xb7bf('0x82')](_0x55ceb0['body'][_0xb7bf('0x65')],_[_0xb7bf('0x83')](_0x55ceb0[_0xb7bf('0x4f')],[_0xb7bf('0x65'),'id'])||{})[_0xb7bf('0x84')](function(_0x12f860){for(var _0x4ab724=0x0;_0x4ab724<_0x55ceb0['body'][_0xb7bf('0x65')]['length'];_0x4ab724+=0x1){socket[_0xb7bf('0x6e')](_0xb7bf('0x6f'),{'UserId':_0x55ceb0[_0xb7bf('0x4f')][_0xb7bf('0x65')][_0x4ab724],'ChatQueueId':_0x55ceb0[_0xb7bf('0x4b')]['id']});}return _0x12f860;});}})[_0xb7bf('0x2a')](respondWithResult(_0xa98989,null))[_0xb7bf('0x4a')](handleError(_0xa98989,null));};exports[_0xb7bf('0x85')]=function(_0x39c74d,_0x1090f8,_0x2aaebe){return db[_0xb7bf('0x32')][_0xb7bf('0x4d')]({'where':{'id':_0x39c74d[_0xb7bf('0x4b')]['id']}})[_0xb7bf('0x2a')](handleEntityNotFound(_0x1090f8,null))['then'](function(_0x3ed6f7){if(_0x3ed6f7){return _0x3ed6f7[_0xb7bf('0x85')](_0x39c74d[_0xb7bf('0x36')][_0xb7bf('0x65')])['then'](function(){if(_['isArray'](_0x39c74d[_0xb7bf('0x36')]['ids'])){for(var _0x532bbb=0x0;_0x532bbb<_0x39c74d[_0xb7bf('0x36')]['ids'][_0xb7bf('0x3c')];_0x532bbb+=0x1){socket[_0xb7bf('0x6e')](_0xb7bf('0x81'),{'UserId':Number(_0x39c74d[_0xb7bf('0x36')][_0xb7bf('0x65')][_0x532bbb]),'ChatQueueId':Number(_0x39c74d[_0xb7bf('0x4b')]['id'])});}}else{socket[_0xb7bf('0x6e')](_0xb7bf('0x81'),{'UserId':Number(_0x39c74d[_0xb7bf('0x36')][_0xb7bf('0x65')]),'ChatQueueId':Number(_0x39c74d[_0xb7bf('0x4b')]['id'])});}});}})[_0xb7bf('0x2a')](respondWithStatusCode(_0x1090f8,null))[_0xb7bf('0x4a')](handleError(_0x1090f8,null));};exports[_0xb7bf('0x86')]=function(_0x3651a2,_0x2da204,_0x2398ee){var _0x463b02={};var _0x500698={};var _0x19761c;var _0x6b028b;return db[_0xb7bf('0x32')][_0xb7bf('0x56')]({'where':{'id':_0x3651a2[_0xb7bf('0x4b')]['id']}})[_0xb7bf('0x2a')](handleEntityNotFound(_0x2da204,null))[_0xb7bf('0x2a')](function(_0x1dfec3){if(_0x1dfec3){_0x19761c=_0x1dfec3;_0x500698[_0xb7bf('0x35')]=_[_0xb7bf('0x37')](db[_0xb7bf('0x5a')]['rawAttributes']);_0x500698[_0xb7bf('0x36')]=_[_0xb7bf('0x37')](_0x3651a2[_0xb7bf('0x36')]);_0x500698['filters']=_[_0xb7bf('0x39')](_0x500698[_0xb7bf('0x35')],_0x500698[_0xb7bf('0x36')]);_0x463b02[_0xb7bf('0x3a')]=_[_0xb7bf('0x39')](_0x500698['model'],qs['fields'](_0x3651a2[_0xb7bf('0x36')][_0xb7bf('0x3b')]));_0x463b02[_0xb7bf('0x3a')]=_0x463b02[_0xb7bf('0x3a')]['length']?_0x463b02['attributes']:_0x500698[_0xb7bf('0x35')];_0x463b02['order']=qs['sort'](_0x3651a2[_0xb7bf('0x36')][_0xb7bf('0x3f')]);_0x463b02['where']=qs[_0xb7bf('0x38')](_['pick'](_0x3651a2[_0xb7bf('0x36')],_0x500698[_0xb7bf('0x38')]));if(_0x3651a2[_0xb7bf('0x36')][_0xb7bf('0x42')]){_0x463b02[_0xb7bf('0x40')]=_[_0xb7bf('0x44')](_0x463b02['where'],{'$or':_[_0xb7bf('0x31')](_0x463b02[_0xb7bf('0x3a')],function(_0x34e31c){var _0x2ac962={};_0x2ac962[_0x34e31c]={'$like':'%'+_0x3651a2['query'][_0xb7bf('0x42')]+'%'};return _0x2ac962;})});}_0x463b02=_[_0xb7bf('0x44')]({},_0x463b02,_0x3651a2[_0xb7bf('0x45')]);return _0x19761c['getAgents'](_0x463b02);}})['then'](function(_0x44f6da){if(_0x44f6da){_0x6b028b=_0x44f6da['length'];if(!_0x3651a2[_0xb7bf('0x36')][_0xb7bf('0x58')](_0xb7bf('0x3d'))){_0x463b02[_0xb7bf('0x25')]=qs[_0xb7bf('0x25')](_0x3651a2[_0xb7bf('0x36')][_0xb7bf('0x25')]);_0x463b02['offset']=qs[_0xb7bf('0x24')](_0x3651a2[_0xb7bf('0x36')][_0xb7bf('0x24')]);}return _0x19761c[_0xb7bf('0x86')](_0x463b02);}})[_0xb7bf('0x2a')](function(_0x38f057){if(_0x38f057){return _0x38f057?{'count':_0x6b028b,'rows':_0x38f057}:null;}})[_0xb7bf('0x2a')](respondWithResult(_0x2da204,null))[_0xb7bf('0x4a')](handleError(_0x2da204,null));};
\ No newline at end of file
+var _0x3dbd=['attributes','fields','length','hasOwnProperty','nolimit','limit','order','where','pick','filter','merge','VIRTUAL','options','ChatQueue','includeAll','findAll','rows','show','params','include','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','UserChatQueue','intersection','sort','ChatQueueId','User','findAndCountAll','UserId','chatPause','createdAt','SIP','updatedAt','findOne','Team','getTeams','addTeams','ids','Agents','online','flatMap','sequelize','transaction','findOrCreate','emit','removeTeams','select','field','tq.TeamId','team_has_chat_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','removeAgents','forEach','addAgents','omit','spread','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../mysqldb','redis','localhost','socket.io-emitter','./chatQueue.socket','register','http','then','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','catch','status','end','json','count','offset','set','apply','reject','save','update','destroy','get','ChatQueues','UserProfileResource','sendStatus','stack','name','send','map','rawAttributes','fieldName','type','key','model','keys','query','filters'];(function(_0x3c858f,_0x235201){var _0x198090=function(_0xc4c406){while(--_0xc4c406){_0x3c858f['push'](_0x3c858f['shift']());}};_0x198090(++_0x235201);}(_0x3dbd,0xe0));var _0xd3db=function(_0x692515,_0x546384){_0x692515=_0x692515-0x0;var _0x231069=_0x3dbd[_0x692515];return _0x231069;};'use strict';var pdf=require(_0xd3db('0x0'));var emlformat=require(_0xd3db('0x1'));var rimraf=require(_0xd3db('0x2'));var zipdir=require(_0xd3db('0x3'));var jsonpatch=require(_0xd3db('0x4'));var rp=require(_0xd3db('0x5'));var moment=require('moment');var BPromise=require(_0xd3db('0x6'));var Mustache=require(_0xd3db('0x7'));var util=require(_0xd3db('0x8'));var path=require(_0xd3db('0x9'));var sox=require(_0xd3db('0xa'));var csv=require('to-csv');var ejs=require(_0xd3db('0xb'));var fs=require('fs');var _=require(_0xd3db('0xc'));var squel=require(_0xd3db('0xd'));var crypto=require(_0xd3db('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xd3db('0xf'));var Papa=require(_0xd3db('0x10'));var Redis=require(_0xd3db('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xd3db('0x12'));var as=require(_0xd3db('0x13'));var hardwareService=require(_0xd3db('0x14'));var logger=require('../../config/logger')(_0xd3db('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xd3db('0x16'))['db'];config[_0xd3db('0x17')]=_['defaults'](config[_0xd3db('0x17')],{'host':_0xd3db('0x18'),'port':0x18eb});var socket=require(_0xd3db('0x19'))(new Redis(config['redis']));require(_0xd3db('0x1a'))[_0xd3db('0x1b')](socket);var jayson=require('jayson/promise');var client=jayson['client'][_0xd3db('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x35ac07,_0x3b2270,_0x28d459,_0x1a3589){return new BPromise(function(_0x2bbd44,_0x3e1f1e){var _0x10436c=_0x1a3589||client;return _0x10436c['request'](_0x35ac07,_0x28d459)[_0xd3db('0x1d')](function(_0x4cd30f){logger['info'](_0xd3db('0x1e'),_0x3b2270,_0xd3db('0x1f'));logger[_0xd3db('0x20')]('ChatQueue,\x20%s,\x20%s,\x20%s',_0x3b2270,_0xd3db('0x1f'),JSON[_0xd3db('0x21')](_0x4cd30f));if(_0x4cd30f[_0xd3db('0x22')]){if(_0x4cd30f[_0xd3db('0x22')]['code']===0x1f4){logger[_0xd3db('0x22')](_0xd3db('0x1e'),_0x3b2270,_0x4cd30f[_0xd3db('0x22')][_0xd3db('0x23')]);return _0x3e1f1e(_0x4cd30f[_0xd3db('0x22')][_0xd3db('0x23')]);}logger[_0xd3db('0x22')](_0xd3db('0x1e'),_0x3b2270,_0x4cd30f['error']['message']);return _0x2bbd44(_0x4cd30f[_0xd3db('0x22')]['message']);}else{logger['info']('ChatQueue,\x20%s,\x20%s',_0x3b2270,_0xd3db('0x1f'));_0x2bbd44(_0x4cd30f['result'][_0xd3db('0x23')]);}})[_0xd3db('0x24')](function(_0x315940){logger[_0xd3db('0x22')]('ChatQueue,\x20%s,\x20%s',_0x3b2270,_0x315940);_0x3e1f1e(_0x315940);});});}function respondWithStatusCode(_0x384852,_0x1471a6){_0x1471a6=_0x1471a6||0xcc;return function(_0x3c8e39){if(_0x3c8e39){return _0x384852['sendStatus'](_0x1471a6);}return _0x384852[_0xd3db('0x25')](_0x1471a6)[_0xd3db('0x26')]();};}function respondWithResult(_0x4d3c89,_0x3bc3c9){_0x3bc3c9=_0x3bc3c9||0xc8;return function(_0x22a32e){if(_0x22a32e){return _0x4d3c89[_0xd3db('0x25')](_0x3bc3c9)[_0xd3db('0x27')](_0x22a32e);}};}function respondWithFilteredResult(_0x1d06bc,_0x4ce46c){return function(_0xfbf0e0){if(_0xfbf0e0){var _0x510677=_0xfbf0e0[_0xd3db('0x28')],_0x31d01b=_0x4ce46c[_0xd3db('0x29')],_0x1e8b0c=_0x4ce46c['offset']+_0x4ce46c['limit'],_0x48ea5c;if(_0x1e8b0c>=_0x510677){_0x1e8b0c=_0x510677;_0x48ea5c=0xc8;}else{_0x48ea5c=0xce;}_0x1d06bc[_0xd3db('0x25')](_0x48ea5c);return _0x1d06bc[_0xd3db('0x2a')]('Content-Range',_0x31d01b+'-'+_0x1e8b0c+'/'+_0x510677)[_0xd3db('0x27')](_0xfbf0e0);}return null;};}function patchUpdates(_0x5e72f7){return function(_0x8fb7f6){try{jsonpatch[_0xd3db('0x2b')](_0x8fb7f6,_0x5e72f7,!![]);}catch(_0x1fa7ef){return BPromise[_0xd3db('0x2c')](_0x1fa7ef);}return _0x8fb7f6[_0xd3db('0x2d')]();};}function saveUpdates(_0x3d8852,_0x12b625){return function(_0x214482){if(_0x214482){return _0x214482[_0xd3db('0x2e')](_0x3d8852)[_0xd3db('0x1d')](function(_0x3d6b0e){return _0x3d6b0e;});}return null;};}function removeEntity(_0x4d6be3,_0xe484b6){return function(_0x1da369){if(_0x1da369){return _0x1da369[_0xd3db('0x2f')]()[_0xd3db('0x1d')](function(){var _0x4e86b2=_0x1da369[_0xd3db('0x30')]({'plain':!![]});var _0x18802e=_0xd3db('0x31');return db[_0xd3db('0x32')][_0xd3db('0x2f')]({'where':{'type':_0x18802e,'resourceId':_0x4e86b2['id']}})[_0xd3db('0x1d')](function(){return _0x1da369;});})[_0xd3db('0x1d')](function(){_0x4d6be3[_0xd3db('0x25')](0xcc)[_0xd3db('0x26')]();});}};}function handleEntityNotFound(_0x23f59e,_0x1d1a68){return function(_0x289e12){if(!_0x289e12){_0x23f59e[_0xd3db('0x33')](0x194);}return _0x289e12;};}function handleError(_0x506698,_0x4af5d9){_0x4af5d9=_0x4af5d9||0x1f4;return function(_0xc13810){logger[_0xd3db('0x22')](_0xc13810[_0xd3db('0x34')]);if(_0xc13810['name']){delete _0xc13810[_0xd3db('0x35')];}_0x506698['status'](_0x4af5d9)[_0xd3db('0x36')](_0xc13810);};}exports['index']=function(_0x13e3b9,_0x38d675){var _0x543f4e={},_0x82f99d={},_0x3bb27a={'count':0x0,'rows':[]};var _0x2c2a21=_[_0xd3db('0x37')](db['ChatQueue'][_0xd3db('0x38')],function(_0xce397b){return{'name':_0xce397b[_0xd3db('0x39')],'type':_0xce397b[_0xd3db('0x3a')][_0xd3db('0x3b')]};});_0x82f99d[_0xd3db('0x3c')]=_[_0xd3db('0x37')](_0x2c2a21,_0xd3db('0x35'));_0x82f99d['query']=_[_0xd3db('0x3d')](_0x13e3b9[_0xd3db('0x3e')]);_0x82f99d[_0xd3db('0x3f')]=_['intersection'](_0x82f99d[_0xd3db('0x3c')],_0x82f99d[_0xd3db('0x3e')]);_0x543f4e[_0xd3db('0x40')]=_['intersection'](_0x82f99d[_0xd3db('0x3c')],qs[_0xd3db('0x41')](_0x13e3b9[_0xd3db('0x3e')]['fields']));_0x543f4e[_0xd3db('0x40')]=_0x543f4e[_0xd3db('0x40')][_0xd3db('0x42')]?_0x543f4e[_0xd3db('0x40')]:_0x82f99d[_0xd3db('0x3c')];if(!_0x13e3b9[_0xd3db('0x3e')][_0xd3db('0x43')](_0xd3db('0x44'))){_0x543f4e[_0xd3db('0x45')]=qs[_0xd3db('0x45')](_0x13e3b9[_0xd3db('0x3e')]['limit']);_0x543f4e[_0xd3db('0x29')]=qs[_0xd3db('0x29')](_0x13e3b9[_0xd3db('0x3e')][_0xd3db('0x29')]);}_0x543f4e[_0xd3db('0x46')]=qs['sort'](_0x13e3b9[_0xd3db('0x3e')]['sort']);_0x543f4e[_0xd3db('0x47')]=qs['filters'](_[_0xd3db('0x48')](_0x13e3b9['query'],_0x82f99d[_0xd3db('0x3f')]),_0x2c2a21);if(_0x13e3b9[_0xd3db('0x3e')][_0xd3db('0x49')]){_0x543f4e[_0xd3db('0x47')]=_[_0xd3db('0x4a')](_0x543f4e[_0xd3db('0x47')],{'$or':_[_0xd3db('0x37')](_0x2c2a21,function(_0x19ab45){if(_0x19ab45[_0xd3db('0x3a')]!==_0xd3db('0x4b')){var _0x3415e6={};_0x3415e6[_0x19ab45[_0xd3db('0x35')]]={'$like':'%'+_0x13e3b9[_0xd3db('0x3e')][_0xd3db('0x49')]+'%'};return _0x3415e6;}})});}_0x543f4e=_[_0xd3db('0x4a')]({},_0x543f4e,_0x13e3b9[_0xd3db('0x4c')]);var _0x22965c={'where':_0x543f4e[_0xd3db('0x47')]};return db[_0xd3db('0x4d')][_0xd3db('0x28')](_0x22965c)[_0xd3db('0x1d')](function(_0x1f1164){_0x3bb27a[_0xd3db('0x28')]=_0x1f1164;if(_0x13e3b9[_0xd3db('0x3e')][_0xd3db('0x4e')]){_0x543f4e['include']=[{'all':!![]}];}return db['ChatQueue'][_0xd3db('0x4f')](_0x543f4e);})[_0xd3db('0x1d')](function(_0x1e153f){_0x3bb27a[_0xd3db('0x50')]=_0x1e153f;return _0x3bb27a;})[_0xd3db('0x1d')](respondWithFilteredResult(_0x38d675,_0x543f4e))['catch'](handleError(_0x38d675,null));};exports[_0xd3db('0x51')]=function(_0x195534,_0x3800d2){var _0x516be2={'raw':!![],'where':{'id':_0x195534[_0xd3db('0x52')]['id']}},_0x1caf98={};_0x1caf98[_0xd3db('0x3c')]=_[_0xd3db('0x3d')](db['ChatQueue'][_0xd3db('0x38')]);_0x1caf98['query']=_['keys'](_0x195534[_0xd3db('0x3e')]);_0x1caf98['filters']=_['intersection'](_0x1caf98[_0xd3db('0x3c')],_0x1caf98[_0xd3db('0x3e')]);_0x516be2[_0xd3db('0x40')]=_['intersection'](_0x1caf98[_0xd3db('0x3c')],qs[_0xd3db('0x41')](_0x195534[_0xd3db('0x3e')][_0xd3db('0x41')]));_0x516be2['attributes']=_0x516be2[_0xd3db('0x40')][_0xd3db('0x42')]?_0x516be2[_0xd3db('0x40')]:_0x1caf98['model'];if(_0x195534[_0xd3db('0x3e')][_0xd3db('0x4e')]){_0x516be2[_0xd3db('0x53')]=[{'all':!![]}];}_0x516be2=_[_0xd3db('0x4a')]({},_0x516be2,_0x195534[_0xd3db('0x4c')]);return db[_0xd3db('0x4d')][_0xd3db('0x54')](_0x516be2)['then'](handleEntityNotFound(_0x3800d2,null))[_0xd3db('0x1d')](respondWithResult(_0x3800d2,null))[_0xd3db('0x24')](handleError(_0x3800d2,null));};exports[_0xd3db('0x55')]=function(_0x58a94f,_0xcdb07c){return db[_0xd3db('0x4d')][_0xd3db('0x55')](_0x58a94f[_0xd3db('0x56')],{})[_0xd3db('0x1d')](function(_0xcefa9){var _0x1f9524=_0x58a94f['user'][_0xd3db('0x30')]({'plain':!![]});if(!_0x1f9524)throw new Error(_0xd3db('0x57'));if(_0x1f9524['role']==='user'){var _0x4315a1=_0xcefa9['get']({'plain':!![]});var _0x3d48b6=_0xd3db('0x31');return db[_0xd3db('0x58')]['find']({'where':{'name':_0x3d48b6,'userProfileId':_0x1f9524[_0xd3db('0x59')]},'raw':!![]})[_0xd3db('0x1d')](function(_0x18930e){if(_0x18930e&&_0x18930e[_0xd3db('0x5a')]===0x0){return db[_0xd3db('0x32')]['create']({'name':_0x4315a1[_0xd3db('0x35')],'resourceId':_0x4315a1['id'],'type':_0x18930e[_0xd3db('0x35')],'sectionId':_0x18930e['id']},{})['then'](function(){return _0xcefa9;});}else{return _0xcefa9;}})[_0xd3db('0x24')](function(_0x477e2c){logger['error'](_0xd3db('0x5b'),_0x477e2c);throw _0x477e2c;});}return _0xcefa9;})['then'](respondWithResult(_0xcdb07c,0xc9))['catch'](handleError(_0xcdb07c,null));};exports[_0xd3db('0x2e')]=function(_0x34d135,_0x33f66b){if(_0x34d135['body']['id']){delete _0x34d135[_0xd3db('0x56')]['id'];}return db[_0xd3db('0x4d')][_0xd3db('0x54')]({'where':{'id':_0x34d135['params']['id']}})[_0xd3db('0x1d')](handleEntityNotFound(_0x33f66b,null))[_0xd3db('0x1d')](saveUpdates(_0x34d135[_0xd3db('0x56')],null))[_0xd3db('0x1d')](respondWithResult(_0x33f66b,null))[_0xd3db('0x24')](handleError(_0x33f66b,null));};exports[_0xd3db('0x2f')]=function(_0x5bd7d2,_0x1b826b){return db[_0xd3db('0x4d')][_0xd3db('0x54')]({'where':{'id':_0x5bd7d2[_0xd3db('0x52')]['id']}})[_0xd3db('0x1d')](handleEntityNotFound(_0x1b826b,null))['then'](removeEntity(_0x1b826b,null))['catch'](handleError(_0x1b826b,null));};exports[_0xd3db('0x5c')]=function(_0x1d915a,_0x104f46){return db['ChatQueue']['describe']()[_0xd3db('0x1d')](respondWithResult(_0x104f46,null))[_0xd3db('0x24')](handleError(_0x104f46,null));};exports['getMembers']=function(_0x2e6a73,_0xfe8e63,_0x1c7f5c){var _0x2fd974={'raw':!![],'where':{}},_0x1c369d={},_0x219682;return db[_0xd3db('0x4d')]['findOne']({'where':{'id':_0x2e6a73['params']['id']}})[_0xd3db('0x1d')](handleEntityNotFound(_0xfe8e63,null))['then'](function(_0x341a5f){if(_0x341a5f){_0x219682=_0x341a5f[_0xd3db('0x30')]({'plain':!![]});_0x1c369d[_0xd3db('0x3c')]=_[_0xd3db('0x3d')](db[_0xd3db('0x5d')][_0xd3db('0x38')]);_0x1c369d[_0xd3db('0x3e')]=_['keys'](_0x2e6a73[_0xd3db('0x3e')]);_0x1c369d['filters']=_[_0xd3db('0x5e')](_0x1c369d['model'],_0x1c369d[_0xd3db('0x3e')]);_0x2fd974[_0xd3db('0x40')]=_['intersection'](_0x1c369d[_0xd3db('0x3c')],qs[_0xd3db('0x41')](_0x2e6a73[_0xd3db('0x3e')][_0xd3db('0x41')]));_0x2fd974[_0xd3db('0x40')]=_0x2fd974['attributes'][_0xd3db('0x42')]?_0x2fd974[_0xd3db('0x40')]:_0x1c369d['model'];if(!_0x2e6a73['query']['hasOwnProperty'](_0xd3db('0x44'))){_0x2fd974[_0xd3db('0x45')]=qs[_0xd3db('0x45')](_0x2e6a73[_0xd3db('0x3e')][_0xd3db('0x45')]);_0x2fd974['offset']=qs[_0xd3db('0x29')](_0x2e6a73[_0xd3db('0x3e')][_0xd3db('0x29')]);}_0x2fd974[_0xd3db('0x46')]=qs[_0xd3db('0x5f')](_0x2e6a73[_0xd3db('0x3e')][_0xd3db('0x5f')]);_0x2fd974[_0xd3db('0x47')]=qs[_0xd3db('0x3f')](_['pick'](_0x2e6a73[_0xd3db('0x3e')],_0x1c369d[_0xd3db('0x3f')]));_0x2fd974[_0xd3db('0x47')][_0xd3db('0x60')]=_0x341a5f['id'];if(_0x2e6a73['query'][_0xd3db('0x49')]){_0x2fd974['where']=_[_0xd3db('0x4a')](_0x2fd974[_0xd3db('0x47')],{'$or':_['map'](_0x2fd974[_0xd3db('0x40')],function(_0x3c5d35){var _0xfc77eb={};_0xfc77eb[_0x3c5d35]={'$like':'%'+_0x2e6a73[_0xd3db('0x3e')][_0xd3db('0x49')]+'%'};return _0xfc77eb;})});}_0x2fd974=_['merge']({},_0x2fd974,_0x2e6a73['options']);return db['UserChatQueue'][_0xd3db('0x4f')](_0x2fd974);}})['then'](function(_0xdcae48){if(_0xdcae48){return db[_0xd3db('0x61')][_0xd3db('0x62')]({'where':{'id':_[_0xd3db('0x37')](_0xdcae48,_0xd3db('0x63')),'role':'agent'},'attributes':['id',_0xd3db('0x35'),_0xd3db('0x64'),'updatedAt',_0xd3db('0x65')]});}})[_0xd3db('0x1d')](function(_0x2b5e86){if(_0x2b5e86){return{'count':_0x2b5e86[_0xd3db('0x28')],'rows':_['map'](_0x2b5e86[_0xd3db('0x50')],function(_0x1cd1c0){return{'membername':_0x1cd1c0[_0xd3db('0x35')],'UserId':_0x1cd1c0['id'],'queue_name':_0x219682[_0xd3db('0x35')],'ChatQueueId':_0x219682['id'],'interface':util['format']('%s/%s',_0xd3db('0x66'),_0x1cd1c0[_0xd3db('0x35')]),'penalty':0x0,'paused':_0x1cd1c0[_0xd3db('0x64')],'createdAt':_0x1cd1c0[_0xd3db('0x65')],'updatedAt':_0x1cd1c0[_0xd3db('0x67')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xd3db('0x1d')](respondWithFilteredResult(_0xfe8e63,_0x2fd974))[_0xd3db('0x24')](handleError(_0xfe8e63,null));};exports['getTeams']=function(_0x22606f,_0x5598bc,_0x3cba21){var _0x75fc9e={};var _0x245a4d={};var _0x2dd5e4;var _0x133cbb;return db[_0xd3db('0x4d')][_0xd3db('0x68')]({'where':{'id':_0x22606f[_0xd3db('0x52')]['id']}})['then'](handleEntityNotFound(_0x5598bc,null))[_0xd3db('0x1d')](function(_0x360bea){if(_0x360bea){_0x2dd5e4=_0x360bea;_0x245a4d['model']=_['keys'](db[_0xd3db('0x69')][_0xd3db('0x38')]);_0x245a4d[_0xd3db('0x3e')]=_['keys'](_0x22606f[_0xd3db('0x3e')]);_0x245a4d['filters']=_['intersection'](_0x245a4d['model'],_0x245a4d[_0xd3db('0x3e')]);_0x75fc9e[_0xd3db('0x40')]=_[_0xd3db('0x5e')](_0x245a4d[_0xd3db('0x3c')],qs[_0xd3db('0x41')](_0x22606f[_0xd3db('0x3e')]['fields']));_0x75fc9e['attributes']=_0x75fc9e['attributes'][_0xd3db('0x42')]?_0x75fc9e['attributes']:_0x245a4d[_0xd3db('0x3c')];_0x75fc9e[_0xd3db('0x46')]=qs[_0xd3db('0x5f')](_0x22606f[_0xd3db('0x3e')]['sort']);_0x75fc9e['where']=qs[_0xd3db('0x3f')](_['pick'](_0x22606f['query'],_0x245a4d[_0xd3db('0x3f')]));if(_0x22606f['query']['filter']){_0x75fc9e[_0xd3db('0x47')]=_['merge'](_0x75fc9e[_0xd3db('0x47')],{'$or':_[_0xd3db('0x37')](_0x75fc9e[_0xd3db('0x40')],function(_0x3df4e7){var _0x1e7c05={};_0x1e7c05[_0x3df4e7]={'$like':'%'+_0x22606f['query'][_0xd3db('0x49')]+'%'};return _0x1e7c05;})});}_0x75fc9e=_[_0xd3db('0x4a')]({},_0x75fc9e,_0x22606f[_0xd3db('0x4c')]);return _0x2dd5e4[_0xd3db('0x6a')](_0x75fc9e);}})[_0xd3db('0x1d')](function(_0x285033){if(_0x285033){_0x133cbb=_0x285033[_0xd3db('0x42')];if(!_0x22606f[_0xd3db('0x3e')]['hasOwnProperty'](_0xd3db('0x44'))){_0x75fc9e[_0xd3db('0x45')]=qs[_0xd3db('0x45')](_0x22606f[_0xd3db('0x3e')][_0xd3db('0x45')]);_0x75fc9e[_0xd3db('0x29')]=qs['offset'](_0x22606f[_0xd3db('0x3e')][_0xd3db('0x29')]);}return _0x2dd5e4[_0xd3db('0x6a')](_0x75fc9e);}})[_0xd3db('0x1d')](function(_0x4694c2){if(_0x4694c2){return _0x4694c2?{'count':_0x133cbb,'rows':_0x4694c2}:null;}})['then'](respondWithResult(_0x5598bc,null))[_0xd3db('0x24')](handleError(_0x5598bc,null));};exports[_0xd3db('0x6b')]=function(_0xe103f6,_0x3fb302,_0x58b988){var _0x5c7879=_0xe103f6['body'][_0xd3db('0x6c')];return db[_0xd3db('0x69')][_0xd3db('0x4f')]({'where':{'id':_0x5c7879},'attributes':['id'],'include':[{'model':db['User'],'as':_0xd3db('0x6d'),'attributes':['id','name',_0xd3db('0x6e'),'voicePause','interface'],'raw':!![]}]})[_0xd3db('0x1d')](function(_0x1749c5){if(_0x1749c5){var _0xb733f4=_[_0xd3db('0x6f')](_0x1749c5,function(_0x521bcc){var _0x140618=_0x521bcc[_0xd3db('0x30')]({'plain':!![]});return _0x140618[_0xd3db('0x6d')];});return db['ChatQueue']['find']({'where':{'id':_0xe103f6[_0xd3db('0x52')]['id']}})[_0xd3db('0x1d')](function(_0x46a134){return db[_0xd3db('0x70')][_0xd3db('0x71')](function(_0x5c2b94){return _0x46a134['addTeams'](_0x5c7879,{'transaction':_0x5c2b94})['then'](function(){return BPromise['each'](_0xb733f4,function(_0x339bf6){return db[_0xd3db('0x5d')][_0xd3db('0x72')]({'where':{'UserId':_0x339bf6['id'],'ChatQueueId':_0xe103f6['params']['id']},'transaction':_0x5c2b94});});})[_0xd3db('0x1d')](function(){_0xb733f4['forEach'](function(_0x610296){socket[_0xd3db('0x73')]('userChatQueue:save',{'UserId':_0x610296['id'],'ChatQueueId':_0x46a134['id']});});});});});}})['then'](respondWithStatusCode(_0x3fb302,null))['catch'](handleError(_0x3fb302,null));};exports[_0xd3db('0x74')]=function(_0x5b13e5,_0xebe05e,_0xb70a02){return db[_0xd3db('0x69')][_0xd3db('0x4f')]({'where':{'id':_0x5b13e5['query'][_0xd3db('0x6c')]},'attributes':['id'],'include':[{'model':db[_0xd3db('0x61')],'as':_0xd3db('0x6d'),'attributes':['id'],'raw':!![]}]})[_0xd3db('0x1d')](handleEntityNotFound(_0xebe05e,null))[_0xd3db('0x1d')](function(_0xe84dd1){var _0x31aee4=_[_0xd3db('0x37')](_0xe84dd1,'id');var _0x4ec4ea=[];var _0x1507b9=[];var _0x2a0fbd=squel[_0xd3db('0x75')]();_0x2a0fbd[_0xd3db('0x76')](_0xd3db('0x77'))['from'](_0xd3db('0x78'),'tq')['join'](_0xd3db('0x79'),'ut',_0xd3db('0x7a'))[_0xd3db('0x47')](_0xd3db('0x7b'),_0x5b13e5[_0xd3db('0x52')]['id']);for(var _0x5d3b38=0x0;_0x5d3b38<_0xe84dd1[_0xd3db('0x42')];_0x5d3b38+=0x1){let _0x38e7f5=_0xe84dd1[_0x5d3b38];for(var _0x505a01=0x0;_0x505a01<_0x38e7f5['Agents'][_0xd3db('0x42')];_0x505a01+=0x1){let _0x409c3b=_0x38e7f5[_0xd3db('0x6d')][_0x505a01];var _0x3513bd=_0x2a0fbd[_0xd3db('0x7c')]();_0x3513bd[_0xd3db('0x47')](_0xd3db('0x7d'),_0x409c3b['id']);_0x1507b9[_0xd3db('0x7e')](db[_0xd3db('0x70')][_0xd3db('0x3e')](_0x3513bd[_0xd3db('0x7f')](),{'type':db[_0xd3db('0x70')][_0xd3db('0x80')][_0xd3db('0x81')]})[_0xd3db('0x1d')](function(_0x104efc){if(_0x104efc[_0xd3db('0x42')]===0x1){return _0x409c3b['id'];}else{var _0xa77259=_[_0xd3db('0x82')](_[_0xd3db('0x37')](_0x104efc,_0xd3db('0x83')),function(_0x5c6320){return _[_0xd3db('0x84')](_0x31aee4,_0x5c6320);});if(_0xa77259){return _0x409c3b['id'];}}}));}}return BPromise[_0xd3db('0x85')](_0x1507b9)[_0xd3db('0x1d')](function(_0x43d460){_0x4ec4ea=_(_0x4ec4ea)[_0xd3db('0x86')](_0x43d460)[_0xd3db('0x87')]()[_0xd3db('0x88')]();return db[_0xd3db('0x4d')][_0xd3db('0x54')]({'where':{'id':_0x5b13e5[_0xd3db('0x52')]['id']}})[_0xd3db('0x1d')](function(_0x5dcb8c){return db[_0xd3db('0x70')][_0xd3db('0x71')](function(_0x6a66d2){return _0x5dcb8c[_0xd3db('0x74')](_0x5b13e5[_0xd3db('0x3e')][_0xd3db('0x6c')],{'transaction':_0x6a66d2})[_0xd3db('0x1d')](function(){if(!_['isEmpty'](_0x4ec4ea)){return _0x5dcb8c[_0xd3db('0x89')](_0x4ec4ea,{'transaction':_0x6a66d2});}})[_0xd3db('0x1d')](function(){_0x4ec4ea[_0xd3db('0x8a')](function(_0x196dcf){socket[_0xd3db('0x73')]('userChatQueue:remove',{'UserId':_0x196dcf,'ChatQueueId':_0x5dcb8c['id']});});});});});});})['then'](respondWithStatusCode(_0xebe05e,null))[_0xd3db('0x24')](handleError(_0xebe05e,null));};exports[_0xd3db('0x8b')]=function(_0x53dcc5,_0x4ad447,_0x6810c6){return db['ChatQueue']['find']({'where':{'id':_0x53dcc5['params']['id']}})[_0xd3db('0x1d')](handleEntityNotFound(_0x4ad447,null))['then'](function(_0x34c9c7){if(_0x34c9c7){return _0x34c9c7[_0xd3db('0x8b')](_0x53dcc5['body'][_0xd3db('0x6c')],_[_0xd3db('0x8c')](_0x53dcc5[_0xd3db('0x56')],[_0xd3db('0x6c'),'id'])||{})[_0xd3db('0x8d')](function(_0x2c8fb0){for(var _0xe0efb7=0x0;_0xe0efb7<_0x53dcc5['body'][_0xd3db('0x6c')][_0xd3db('0x42')];_0xe0efb7+=0x1){socket[_0xd3db('0x73')]('userChatQueue:save',{'UserId':_0x53dcc5[_0xd3db('0x56')][_0xd3db('0x6c')][_0xe0efb7],'ChatQueueId':_0x53dcc5[_0xd3db('0x52')]['id']});}return _0x2c8fb0;});}})[_0xd3db('0x1d')](respondWithResult(_0x4ad447,null))[_0xd3db('0x24')](handleError(_0x4ad447,null));};exports[_0xd3db('0x89')]=function(_0x1a6c72,_0x3610a1,_0x139c59){return db[_0xd3db('0x4d')]['find']({'where':{'id':_0x1a6c72['params']['id']}})[_0xd3db('0x1d')](handleEntityNotFound(_0x3610a1,null))[_0xd3db('0x1d')](function(_0x3b8f9e){if(_0x3b8f9e){return _0x3b8f9e[_0xd3db('0x89')](_0x1a6c72[_0xd3db('0x3e')]['ids'])['then'](function(){if(_[_0xd3db('0x8e')](_0x1a6c72['query'][_0xd3db('0x6c')])){for(var _0x502942=0x0;_0x502942<_0x1a6c72[_0xd3db('0x3e')][_0xd3db('0x6c')][_0xd3db('0x42')];_0x502942+=0x1){socket[_0xd3db('0x73')]('userChatQueue:remove',{'UserId':Number(_0x1a6c72[_0xd3db('0x3e')][_0xd3db('0x6c')][_0x502942]),'ChatQueueId':Number(_0x1a6c72[_0xd3db('0x52')]['id'])});}}else{socket['emit']('userChatQueue:remove',{'UserId':Number(_0x1a6c72[_0xd3db('0x3e')][_0xd3db('0x6c')]),'ChatQueueId':Number(_0x1a6c72[_0xd3db('0x52')]['id'])});}});}})['then'](respondWithStatusCode(_0x3610a1,null))[_0xd3db('0x24')](handleError(_0x3610a1,null));};exports[_0xd3db('0x8f')]=function(_0x206bca,_0x542e75,_0x1e525b){var _0xca2dd7={};var _0x529630={};var _0x4689fc;var _0x31c1a6;return db[_0xd3db('0x4d')][_0xd3db('0x68')]({'where':{'id':_0x206bca[_0xd3db('0x52')]['id']}})[_0xd3db('0x1d')](handleEntityNotFound(_0x542e75,null))['then'](function(_0x278c36){if(_0x278c36){_0x4689fc=_0x278c36;_0x529630['model']=_[_0xd3db('0x3d')](db['User'][_0xd3db('0x38')]);_0x529630['query']=_[_0xd3db('0x3d')](_0x206bca[_0xd3db('0x3e')]);_0x529630[_0xd3db('0x3f')]=_[_0xd3db('0x5e')](_0x529630['model'],_0x529630[_0xd3db('0x3e')]);_0xca2dd7[_0xd3db('0x40')]=_[_0xd3db('0x5e')](_0x529630[_0xd3db('0x3c')],qs[_0xd3db('0x41')](_0x206bca['query'][_0xd3db('0x41')]));_0xca2dd7[_0xd3db('0x40')]=_0xca2dd7[_0xd3db('0x40')][_0xd3db('0x42')]?_0xca2dd7[_0xd3db('0x40')]:_0x529630['model'];_0xca2dd7[_0xd3db('0x46')]=qs[_0xd3db('0x5f')](_0x206bca['query'][_0xd3db('0x5f')]);_0xca2dd7[_0xd3db('0x47')]=qs[_0xd3db('0x3f')](_[_0xd3db('0x48')](_0x206bca['query'],_0x529630[_0xd3db('0x3f')]));if(_0x206bca[_0xd3db('0x3e')]['filter']){_0xca2dd7[_0xd3db('0x47')]=_[_0xd3db('0x4a')](_0xca2dd7[_0xd3db('0x47')],{'$or':_['map'](_0xca2dd7[_0xd3db('0x40')],function(_0x37ebee){var _0xa5a8e7={};_0xa5a8e7[_0x37ebee]={'$like':'%'+_0x206bca['query'][_0xd3db('0x49')]+'%'};return _0xa5a8e7;})});}_0xca2dd7=_[_0xd3db('0x4a')]({},_0xca2dd7,_0x206bca[_0xd3db('0x4c')]);return _0x4689fc[_0xd3db('0x8f')](_0xca2dd7);}})['then'](function(_0x1bbd09){if(_0x1bbd09){_0x31c1a6=_0x1bbd09[_0xd3db('0x42')];if(!_0x206bca['query'][_0xd3db('0x43')](_0xd3db('0x44'))){_0xca2dd7[_0xd3db('0x45')]=qs[_0xd3db('0x45')](_0x206bca[_0xd3db('0x3e')][_0xd3db('0x45')]);_0xca2dd7[_0xd3db('0x29')]=qs[_0xd3db('0x29')](_0x206bca['query'][_0xd3db('0x29')]);}return _0x4689fc[_0xd3db('0x8f')](_0xca2dd7);}})[_0xd3db('0x1d')](function(_0x5f0ffb){if(_0x5f0ffb){return _0x5f0ffb?{'count':_0x31c1a6,'rows':_0x5f0ffb}:null;}})['then'](respondWithResult(_0x542e75,null))[_0xd3db('0x24')](handleError(_0x542e75,null));};
\ No newline at end of file