Built motion from commit 39adb707.|2.6.14
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index b1f7ebf..2b4d8da 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa70e=['send','index','map','ChatQueue','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','order','sort','where','pick','filter','merge','includeAll','include','findAll','rows','catch','show','params','length','options','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','ChatQueues','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','describe','getMembers','UserChatQueue','nolimit','ChatQueueId','User','findAndCountAll','UserId','chatPause','updatedAt','format','%s/%s','SIP','createdAt','getTeams','Team','addTeams','ids','Agents','online','interface','flatMap','transaction','each','findOrCreate','forEach','field','tq.TeamId','from','team_has_chat_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','sequelize','toString','SELECT','every','TeamId','includes','all','compact','value','removeTeams','removeAgents','userChatQueue:remove','addAgents','omit','spread','userChatQueue:save','isArray','emit','getAgents','rawAttributes','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','socket.io-emitter','./chatQueue.socket','register','jayson/promise','http','request','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','error','code','message','info','result','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','then','get','UserProfileResource','destroy','sendStatus','stack','name'];(function(_0x824626,_0x590cd4){var _0x7247cb=function(_0x18b0b9){while(--_0x18b0b9){_0x824626['push'](_0x824626['shift']());}};_0x7247cb(++_0x590cd4);}(_0xa70e,0xfd));var _0xea70=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xa70e[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xea70('0x0'));var rimraf=require(_0xea70('0x1'));var zipdir=require(_0xea70('0x2'));var jsonpatch=require(_0xea70('0x3'));var rp=require('request-promise');var moment=require(_0xea70('0x4'));var BPromise=require(_0xea70('0x5'));var Mustache=require(_0xea70('0x6'));var util=require(_0xea70('0x7'));var path=require('path');var sox=require(_0xea70('0x8'));var csv=require(_0xea70('0x9'));var ejs=require(_0xea70('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xea70('0xb'));var squel=require(_0xea70('0xc'));var crypto=require('crypto');var jsforce=require(_0xea70('0xd'));var deskjs=require(_0xea70('0xe'));var toCsv=require(_0xea70('0x9'));var querystring=require(_0xea70('0xf'));var Papa=require(_0xea70('0x10'));var Redis=require(_0xea70('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xea70('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xea70('0x13'))(_0xea70('0x14'));var utils=require(_0xea70('0x15'));var config=require(_0xea70('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xea70('0x17'))['db'];config['redis']=_[_0xea70('0x18')](config[_0xea70('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0xea70('0x1a'))(new Redis(config[_0xea70('0x19')]));require(_0xea70('0x1b'))[_0xea70('0x1c')](socket);var jayson=require(_0xea70('0x1d'));var client=jayson['client'][_0xea70('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x3d7fd8,_0x27a68d,_0x4f9a06,_0x543d5f){return new BPromise(function(_0x15283a,_0x133c03){var _0x3bb471=_0x543d5f||client;return _0x3bb471[_0xea70('0x1f')](_0x3d7fd8,_0x4f9a06)['then'](function(_0x24163f){logger['info'](_0xea70('0x20'),_0x27a68d,_0xea70('0x21'));logger[_0xea70('0x22')](_0xea70('0x23'),_0x27a68d,'request\x20sent',JSON['stringify'](_0x24163f));if(_0x24163f[_0xea70('0x24')]){if(_0x24163f[_0xea70('0x24')][_0xea70('0x25')]===0x1f4){logger[_0xea70('0x24')](_0xea70('0x20'),_0x27a68d,_0x24163f[_0xea70('0x24')][_0xea70('0x26')]);return _0x133c03(_0x24163f[_0xea70('0x24')][_0xea70('0x26')]);}logger[_0xea70('0x24')](_0xea70('0x20'),_0x27a68d,_0x24163f[_0xea70('0x24')][_0xea70('0x26')]);return _0x15283a(_0x24163f[_0xea70('0x24')][_0xea70('0x26')]);}else{logger[_0xea70('0x27')](_0xea70('0x20'),_0x27a68d,_0xea70('0x21'));_0x15283a(_0x24163f[_0xea70('0x28')][_0xea70('0x26')]);}})['catch'](function(_0x91347a){logger[_0xea70('0x24')](_0xea70('0x20'),_0x27a68d,_0x91347a);_0x133c03(_0x91347a);});});}function respondWithStatusCode(_0x11698c,_0x42b189){_0x42b189=_0x42b189||0xcc;return function(_0xcd5427){if(_0xcd5427){return _0x11698c['sendStatus'](_0x42b189);}return _0x11698c[_0xea70('0x29')](_0x42b189)[_0xea70('0x2a')]();};}function respondWithResult(_0x257fc9,_0xe438aa){_0xe438aa=_0xe438aa||0xc8;return function(_0x4a4378){if(_0x4a4378){return _0x257fc9[_0xea70('0x29')](_0xe438aa)[_0xea70('0x2b')](_0x4a4378);}};}function respondWithFilteredResult(_0x4083d8,_0x3d24ef){return function(_0x215707){if(_0x215707){var _0x3e1b32=typeof _0x3d24ef[_0xea70('0x2c')]===_0xea70('0x2d')&&typeof _0x3d24ef[_0xea70('0x2e')]===_0xea70('0x2d');var _0xe66be8=_0x215707[_0xea70('0x2f')];var _0x9485f2=_0x3e1b32?0x0:_0x3d24ef[_0xea70('0x2c')];var _0x243087=_0x3e1b32?_0x215707[_0xea70('0x2f')]:_0x3d24ef[_0xea70('0x2c')]+_0x3d24ef[_0xea70('0x2e')];var _0x2919d3;if(_0x243087>=_0xe66be8){_0x243087=_0xe66be8;_0x2919d3=0xc8;}else{_0x2919d3=0xce;}_0x4083d8['status'](_0x2919d3);return _0x4083d8[_0xea70('0x30')](_0xea70('0x31'),_0x9485f2+'-'+_0x243087+'/'+_0xe66be8)['json'](_0x215707);}return null;};}function patchUpdates(_0xfe8c66){return function(_0x332a5d){try{jsonpatch[_0xea70('0x32')](_0x332a5d,_0xfe8c66,!![]);}catch(_0x1a951a){return BPromise[_0xea70('0x33')](_0x1a951a);}return _0x332a5d['save']();};}function saveUpdates(_0x3fe6aa,_0x28b304){return function(_0x42618a){if(_0x42618a){return _0x42618a['update'](_0x3fe6aa)[_0xea70('0x34')](function(_0xdd629e){return _0xdd629e;});}return null;};}function removeEntity(_0x37a8b9,_0x579561){return function(_0x130e7b){if(_0x130e7b){return _0x130e7b['destroy']()[_0xea70('0x34')](function(){var _0x3b350f=_0x130e7b[_0xea70('0x35')]({'plain':!![]});var _0x3ba9e9='ChatQueues';return db[_0xea70('0x36')][_0xea70('0x37')]({'where':{'type':_0x3ba9e9,'resourceId':_0x3b350f['id']}})[_0xea70('0x34')](function(){return _0x130e7b;});})[_0xea70('0x34')](function(){_0x37a8b9[_0xea70('0x29')](0xcc)[_0xea70('0x2a')]();});}};}function handleEntityNotFound(_0x2ad6c2,_0x4bd078){return function(_0x59a7ef){if(!_0x59a7ef){_0x2ad6c2[_0xea70('0x38')](0x194);}return _0x59a7ef;};}function handleError(_0x100118,_0x18e87d){_0x18e87d=_0x18e87d||0x1f4;return function(_0x3ad920){logger[_0xea70('0x24')](_0x3ad920[_0xea70('0x39')]);if(_0x3ad920[_0xea70('0x3a')]){delete _0x3ad920[_0xea70('0x3a')];}_0x100118[_0xea70('0x29')](_0x18e87d)[_0xea70('0x3b')](_0x3ad920);};}exports[_0xea70('0x3c')]=function(_0x21eca2,_0x2c589e){var _0x8b4aca={},_0x40b284={},_0x43ad0c={'count':0x0,'rows':[]};var _0x3ca589=_[_0xea70('0x3d')](db[_0xea70('0x3e')]['rawAttributes'],function(_0x290b6c){return{'name':_0x290b6c[_0xea70('0x3f')],'type':_0x290b6c[_0xea70('0x40')][_0xea70('0x41')]};});_0x40b284[_0xea70('0x42')]=_[_0xea70('0x3d')](_0x3ca589,_0xea70('0x3a'));_0x40b284[_0xea70('0x43')]=_[_0xea70('0x44')](_0x21eca2['query']);_0x40b284[_0xea70('0x45')]=_['intersection'](_0x40b284[_0xea70('0x42')],_0x40b284[_0xea70('0x43')]);_0x8b4aca['attributes']=_[_0xea70('0x46')](_0x40b284['model'],qs['fields'](_0x21eca2['query'][_0xea70('0x47')]));_0x8b4aca['attributes']=_0x8b4aca[_0xea70('0x48')]['length']?_0x8b4aca[_0xea70('0x48')]:_0x40b284['model'];if(!_0x21eca2[_0xea70('0x43')][_0xea70('0x49')]('nolimit')){_0x8b4aca[_0xea70('0x2e')]=qs[_0xea70('0x2e')](_0x21eca2[_0xea70('0x43')][_0xea70('0x2e')]);_0x8b4aca[_0xea70('0x2c')]=qs[_0xea70('0x2c')](_0x21eca2[_0xea70('0x43')][_0xea70('0x2c')]);}_0x8b4aca[_0xea70('0x4a')]=qs[_0xea70('0x4b')](_0x21eca2[_0xea70('0x43')][_0xea70('0x4b')]);_0x8b4aca[_0xea70('0x4c')]=qs[_0xea70('0x45')](_[_0xea70('0x4d')](_0x21eca2['query'],_0x40b284['filters']),_0x3ca589);if(_0x21eca2[_0xea70('0x43')][_0xea70('0x4e')]){_0x8b4aca[_0xea70('0x4c')]=_[_0xea70('0x4f')](_0x8b4aca[_0xea70('0x4c')],{'$or':_[_0xea70('0x3d')](_0x3ca589,function(_0x493322){if(_0x493322[_0xea70('0x40')]!=='VIRTUAL'){var _0x3fcf77={};_0x3fcf77[_0x493322[_0xea70('0x3a')]]={'$like':'%'+_0x21eca2[_0xea70('0x43')]['filter']+'%'};return _0x3fcf77;}})});}_0x8b4aca=_['merge']({},_0x8b4aca,_0x21eca2['options']);var _0x46a23b={'where':_0x8b4aca[_0xea70('0x4c')]};return db['ChatQueue']['count'](_0x46a23b)[_0xea70('0x34')](function(_0x283656){_0x43ad0c[_0xea70('0x2f')]=_0x283656;if(_0x21eca2[_0xea70('0x43')][_0xea70('0x50')]){_0x8b4aca[_0xea70('0x51')]=[{'all':!![]}];}return db[_0xea70('0x3e')][_0xea70('0x52')](_0x8b4aca);})[_0xea70('0x34')](function(_0x575cf7){_0x43ad0c[_0xea70('0x53')]=_0x575cf7;return _0x43ad0c;})[_0xea70('0x34')](respondWithFilteredResult(_0x2c589e,_0x8b4aca))[_0xea70('0x54')](handleError(_0x2c589e,null));};exports[_0xea70('0x55')]=function(_0x340038,_0x2aa83f){var _0x5b99ad={'raw':!![],'where':{'id':_0x340038[_0xea70('0x56')]['id']}},_0x186679={};_0x186679[_0xea70('0x42')]=_[_0xea70('0x44')](db['ChatQueue']['rawAttributes']);_0x186679[_0xea70('0x43')]=_[_0xea70('0x44')](_0x340038['query']);_0x186679['filters']=_['intersection'](_0x186679['model'],_0x186679[_0xea70('0x43')]);_0x5b99ad[_0xea70('0x48')]=_['intersection'](_0x186679['model'],qs[_0xea70('0x47')](_0x340038[_0xea70('0x43')]['fields']));_0x5b99ad[_0xea70('0x48')]=_0x5b99ad['attributes'][_0xea70('0x57')]?_0x5b99ad[_0xea70('0x48')]:_0x186679[_0xea70('0x42')];if(_0x340038[_0xea70('0x43')][_0xea70('0x50')]){_0x5b99ad['include']=[{'all':!![]}];}_0x5b99ad=_[_0xea70('0x4f')]({},_0x5b99ad,_0x340038[_0xea70('0x58')]);return db[_0xea70('0x3e')][_0xea70('0x59')](_0x5b99ad)[_0xea70('0x34')](handleEntityNotFound(_0x2aa83f,null))[_0xea70('0x34')](respondWithResult(_0x2aa83f,null))[_0xea70('0x54')](handleError(_0x2aa83f,null));};exports['create']=function(_0x3eba53,_0x14a55a){return db[_0xea70('0x3e')][_0xea70('0x5a')](_0x3eba53['body'],{})['then'](function(_0x27c6cd){var _0x54d0d1=_0x3eba53[_0xea70('0x5b')][_0xea70('0x35')]({'plain':!![]});if(!_0x54d0d1)throw new Error(_0xea70('0x5c'));if(_0x54d0d1[_0xea70('0x5d')]==='user'){var _0x5d415c=_0x27c6cd['get']({'plain':!![]});var _0x1109f0=_0xea70('0x5e');return db[_0xea70('0x5f')]['find']({'where':{'name':_0x1109f0,'userProfileId':_0x54d0d1[_0xea70('0x60')]},'raw':!![]})[_0xea70('0x34')](function(_0x160c33){if(_0x160c33&&_0x160c33[_0xea70('0x61')]===0x0){return db['UserProfileResource'][_0xea70('0x5a')]({'name':_0x5d415c[_0xea70('0x3a')],'resourceId':_0x5d415c['id'],'type':_0x160c33[_0xea70('0x3a')],'sectionId':_0x160c33['id']},{})[_0xea70('0x34')](function(){return _0x27c6cd;});}else{return _0x27c6cd;}})[_0xea70('0x54')](function(_0x29af5e){logger['error'](_0xea70('0x62'),_0x29af5e);throw _0x29af5e;});}return _0x27c6cd;})[_0xea70('0x34')](respondWithResult(_0x14a55a,0xc9))[_0xea70('0x54')](handleError(_0x14a55a,null));};exports[_0xea70('0x63')]=function(_0x56c453,_0x45cbdc){if(_0x56c453[_0xea70('0x64')]['id']){delete _0x56c453[_0xea70('0x64')]['id'];}return db['ChatQueue'][_0xea70('0x59')]({'where':{'id':_0x56c453[_0xea70('0x56')]['id']}})[_0xea70('0x34')](handleEntityNotFound(_0x45cbdc,null))[_0xea70('0x34')](saveUpdates(_0x56c453[_0xea70('0x64')],null))['then'](respondWithResult(_0x45cbdc,null))[_0xea70('0x54')](handleError(_0x45cbdc,null));};exports[_0xea70('0x37')]=function(_0x28aa68,_0x44950f){return db[_0xea70('0x3e')][_0xea70('0x59')]({'where':{'id':_0x28aa68['params']['id']}})[_0xea70('0x34')](handleEntityNotFound(_0x44950f,null))['then'](removeEntity(_0x44950f,null))[_0xea70('0x54')](handleError(_0x44950f,null));};exports[_0xea70('0x65')]=function(_0x40fb63,_0x244f5d){return db[_0xea70('0x3e')]['describe']()[_0xea70('0x34')](respondWithResult(_0x244f5d,null))[_0xea70('0x54')](handleError(_0x244f5d,null));};exports[_0xea70('0x66')]=function(_0x5e3eaf,_0x55e055,_0x351cb2){var _0x3314f9={'raw':!![],'where':{}},_0x1937ea={},_0x2b20a8;return db[_0xea70('0x3e')]['findOne']({'where':{'id':_0x5e3eaf['params']['id']}})[_0xea70('0x34')](handleEntityNotFound(_0x55e055,null))[_0xea70('0x34')](function(_0x5cf62e){if(_0x5cf62e){_0x2b20a8=_0x5cf62e['get']({'plain':!![]});_0x1937ea['model']=_[_0xea70('0x44')](db[_0xea70('0x67')]['rawAttributes']);_0x1937ea['query']=_['keys'](_0x5e3eaf['query']);_0x1937ea[_0xea70('0x45')]=_[_0xea70('0x46')](_0x1937ea[_0xea70('0x42')],_0x1937ea[_0xea70('0x43')]);_0x3314f9[_0xea70('0x48')]=_['intersection'](_0x1937ea[_0xea70('0x42')],qs[_0xea70('0x47')](_0x5e3eaf['query']['fields']));_0x3314f9['attributes']=_0x3314f9[_0xea70('0x48')][_0xea70('0x57')]?_0x3314f9[_0xea70('0x48')]:_0x1937ea[_0xea70('0x42')];if(!_0x5e3eaf[_0xea70('0x43')][_0xea70('0x49')](_0xea70('0x68'))){_0x3314f9[_0xea70('0x2e')]=qs[_0xea70('0x2e')](_0x5e3eaf[_0xea70('0x43')]['limit']);_0x3314f9[_0xea70('0x2c')]=qs[_0xea70('0x2c')](_0x5e3eaf[_0xea70('0x43')][_0xea70('0x2c')]);}_0x3314f9[_0xea70('0x4a')]=qs['sort'](_0x5e3eaf[_0xea70('0x43')][_0xea70('0x4b')]);_0x3314f9[_0xea70('0x4c')]=qs[_0xea70('0x45')](_['pick'](_0x5e3eaf['query'],_0x1937ea['filters']));_0x3314f9[_0xea70('0x4c')][_0xea70('0x69')]=_0x5cf62e['id'];if(_0x5e3eaf[_0xea70('0x43')][_0xea70('0x4e')]){_0x3314f9[_0xea70('0x4c')]=_['merge'](_0x3314f9[_0xea70('0x4c')],{'$or':_['map'](_0x3314f9[_0xea70('0x48')],function(_0x2a7c51){var _0x230c2a={};_0x230c2a[_0x2a7c51]={'$like':'%'+_0x5e3eaf[_0xea70('0x43')]['filter']+'%'};return _0x230c2a;})});}_0x3314f9=_['merge']({},_0x3314f9,_0x5e3eaf[_0xea70('0x58')]);return db[_0xea70('0x67')][_0xea70('0x52')](_0x3314f9);}})[_0xea70('0x34')](function(_0x2f4d56){if(_0x2f4d56){return db[_0xea70('0x6a')][_0xea70('0x6b')]({'where':{'id':_[_0xea70('0x3d')](_0x2f4d56,_0xea70('0x6c')),'role':'agent'},'attributes':['id',_0xea70('0x3a'),_0xea70('0x6d'),_0xea70('0x6e'),'createdAt']});}})[_0xea70('0x34')](function(_0x41c9d4){if(_0x41c9d4){return{'count':_0x41c9d4['count'],'rows':_[_0xea70('0x3d')](_0x41c9d4[_0xea70('0x53')],function(_0x3245e4){return{'membername':_0x3245e4[_0xea70('0x3a')],'UserId':_0x3245e4['id'],'queue_name':_0x2b20a8[_0xea70('0x3a')],'ChatQueueId':_0x2b20a8['id'],'interface':util[_0xea70('0x6f')](_0xea70('0x70'),_0xea70('0x71'),_0x3245e4['name']),'penalty':0x0,'paused':_0x3245e4[_0xea70('0x6d')],'createdAt':_0x3245e4[_0xea70('0x72')],'updatedAt':_0x3245e4[_0xea70('0x6e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xea70('0x34')](respondWithFilteredResult(_0x55e055,_0x3314f9))[_0xea70('0x54')](handleError(_0x55e055,null));};exports[_0xea70('0x73')]=function(_0x4b3975,_0x377704,_0x1762d1){var _0x120b59={};var _0x3537c6={};var _0x3cea6d;var _0x3623d4;return db[_0xea70('0x3e')]['findOne']({'where':{'id':_0x4b3975['params']['id']}})[_0xea70('0x34')](handleEntityNotFound(_0x377704,null))[_0xea70('0x34')](function(_0x1af8fd){if(_0x1af8fd){_0x3cea6d=_0x1af8fd;_0x3537c6['model']=_[_0xea70('0x44')](db[_0xea70('0x74')]['rawAttributes']);_0x3537c6[_0xea70('0x43')]=_[_0xea70('0x44')](_0x4b3975[_0xea70('0x43')]);_0x3537c6[_0xea70('0x45')]=_[_0xea70('0x46')](_0x3537c6[_0xea70('0x42')],_0x3537c6[_0xea70('0x43')]);_0x120b59[_0xea70('0x48')]=_[_0xea70('0x46')](_0x3537c6['model'],qs[_0xea70('0x47')](_0x4b3975['query'][_0xea70('0x47')]));_0x120b59[_0xea70('0x48')]=_0x120b59[_0xea70('0x48')][_0xea70('0x57')]?_0x120b59[_0xea70('0x48')]:_0x3537c6['model'];_0x120b59['order']=qs[_0xea70('0x4b')](_0x4b3975[_0xea70('0x43')][_0xea70('0x4b')]);_0x120b59['where']=qs[_0xea70('0x45')](_['pick'](_0x4b3975[_0xea70('0x43')],_0x3537c6[_0xea70('0x45')]));if(_0x4b3975['query'][_0xea70('0x4e')]){_0x120b59[_0xea70('0x4c')]=_[_0xea70('0x4f')](_0x120b59[_0xea70('0x4c')],{'$or':_[_0xea70('0x3d')](_0x120b59['attributes'],function(_0x38a7dd){var _0x29e914={};_0x29e914[_0x38a7dd]={'$like':'%'+_0x4b3975['query'][_0xea70('0x4e')]+'%'};return _0x29e914;})});}_0x120b59=_[_0xea70('0x4f')]({},_0x120b59,_0x4b3975[_0xea70('0x58')]);return _0x3cea6d['getTeams'](_0x120b59);}})[_0xea70('0x34')](function(_0x33e60d){if(_0x33e60d){_0x3623d4=_0x33e60d[_0xea70('0x57')];if(!_0x4b3975[_0xea70('0x43')][_0xea70('0x49')](_0xea70('0x68'))){_0x120b59['limit']=qs[_0xea70('0x2e')](_0x4b3975['query'][_0xea70('0x2e')]);_0x120b59['offset']=qs['offset'](_0x4b3975['query'][_0xea70('0x2c')]);}return _0x3cea6d['getTeams'](_0x120b59);}})['then'](function(_0x4ed4b6){if(_0x4ed4b6){return _0x4ed4b6?{'count':_0x3623d4,'rows':_0x4ed4b6}:null;}})[_0xea70('0x34')](respondWithResult(_0x377704,null))[_0xea70('0x54')](handleError(_0x377704,null));};exports[_0xea70('0x75')]=function(_0x2e29c6,_0x5155bd,_0x25c817){var _0xe597a9=_0x2e29c6[_0xea70('0x64')][_0xea70('0x76')];return db[_0xea70('0x74')][_0xea70('0x52')]({'where':{'id':_0xe597a9},'attributes':['id'],'include':[{'model':db[_0xea70('0x6a')],'as':_0xea70('0x77'),'attributes':['id','name',_0xea70('0x78'),'voicePause',_0xea70('0x79')],'raw':!![]}]})[_0xea70('0x34')](function(_0x1095e8){if(_0x1095e8){var _0x52391f=_[_0xea70('0x7a')](_0x1095e8,function(_0x47d1d9){var _0x3b6428=_0x47d1d9[_0xea70('0x35')]({'plain':!![]});return _0x3b6428[_0xea70('0x77')];});return db[_0xea70('0x3e')][_0xea70('0x59')]({'where':{'id':_0x2e29c6[_0xea70('0x56')]['id']}})['then'](function(_0x210302){return db['sequelize'][_0xea70('0x7b')](function(_0x5eb32d){return _0x210302[_0xea70('0x75')](_0xe597a9,{'transaction':_0x5eb32d})[_0xea70('0x34')](function(){return BPromise[_0xea70('0x7c')](_0x52391f,function(_0x1346d8){return db['UserChatQueue'][_0xea70('0x7d')]({'where':{'UserId':_0x1346d8['id'],'ChatQueueId':_0x2e29c6[_0xea70('0x56')]['id']},'transaction':_0x5eb32d});});})[_0xea70('0x34')](function(){_0x52391f[_0xea70('0x7e')](function(_0x55ba65){socket['emit']('userChatQueue:save',{'UserId':_0x55ba65['id'],'ChatQueueId':_0x210302['id']});});});});});}})[_0xea70('0x34')](respondWithStatusCode(_0x5155bd,null))[_0xea70('0x54')](handleError(_0x5155bd,null));};exports['removeTeams']=function(_0x29cf95,_0x59ecb1,_0xcd3ac9){return db['Team'][_0xea70('0x52')]({'where':{'id':_0x29cf95[_0xea70('0x43')][_0xea70('0x76')]},'attributes':['id'],'include':[{'model':db[_0xea70('0x6a')],'as':_0xea70('0x77'),'attributes':['id'],'raw':!![]}]})[_0xea70('0x34')](handleEntityNotFound(_0x59ecb1,null))[_0xea70('0x34')](function(_0x79428d){var _0x3658eb=_['map'](_0x79428d,'id');var _0xb1401e=[];var _0x197087=[];var _0x365921=squel['select']();_0x365921[_0xea70('0x7f')](_0xea70('0x80'))[_0xea70('0x81')](_0xea70('0x82'),'tq')['join'](_0xea70('0x83'),'ut',_0xea70('0x84'))[_0xea70('0x4c')]('ChatQueueId\x20=\x20?',_0x29cf95['params']['id']);for(var _0x12d150=0x0;_0x12d150<_0x79428d[_0xea70('0x57')];_0x12d150+=0x1){let _0x22cc62=_0x79428d[_0x12d150];for(var _0x234523=0x0;_0x234523<_0x22cc62[_0xea70('0x77')][_0xea70('0x57')];_0x234523+=0x1){let _0x144a28=_0x22cc62[_0xea70('0x77')][_0x234523];var _0x1a6380=_0x365921[_0xea70('0x85')]();_0x1a6380[_0xea70('0x4c')](_0xea70('0x86'),_0x144a28['id']);_0x197087[_0xea70('0x87')](db[_0xea70('0x88')][_0xea70('0x43')](_0x1a6380[_0xea70('0x89')](),{'type':db[_0xea70('0x88')]['QueryTypes'][_0xea70('0x8a')]})['then'](function(_0x153fcf){if(_0x153fcf[_0xea70('0x57')]===0x1){return _0x144a28['id'];}else{var _0x20d780=_[_0xea70('0x8b')](_['map'](_0x153fcf,_0xea70('0x8c')),function(_0x455799){return _[_0xea70('0x8d')](_0x3658eb,_0x455799);});if(_0x20d780){return _0x144a28['id'];}}}));}}return BPromise[_0xea70('0x8e')](_0x197087)[_0xea70('0x34')](function(_0x5f4d47){_0xb1401e=_(_0xb1401e)['union'](_0x5f4d47)[_0xea70('0x8f')]()[_0xea70('0x90')]();return db[_0xea70('0x3e')][_0xea70('0x59')]({'where':{'id':_0x29cf95[_0xea70('0x56')]['id']}})[_0xea70('0x34')](function(_0x5a96bb){return db[_0xea70('0x88')][_0xea70('0x7b')](function(_0x5c5fc2){return _0x5a96bb[_0xea70('0x91')](_0x29cf95[_0xea70('0x43')][_0xea70('0x76')],{'transaction':_0x5c5fc2})['then'](function(){if(!_['isEmpty'](_0xb1401e)){return _0x5a96bb[_0xea70('0x92')](_0xb1401e,{'transaction':_0x5c5fc2});}})[_0xea70('0x34')](function(){_0xb1401e[_0xea70('0x7e')](function(_0x41f9f6){socket['emit'](_0xea70('0x93'),{'UserId':_0x41f9f6,'ChatQueueId':_0x5a96bb['id']});});});});});});})[_0xea70('0x34')](respondWithStatusCode(_0x59ecb1,null))[_0xea70('0x54')](handleError(_0x59ecb1,null));};exports['addAgents']=function(_0x208198,_0x23633e,_0x24c266){return db[_0xea70('0x3e')][_0xea70('0x59')]({'where':{'id':_0x208198[_0xea70('0x56')]['id']}})[_0xea70('0x34')](handleEntityNotFound(_0x23633e,null))['then'](function(_0x30fd95){if(_0x30fd95){return _0x30fd95[_0xea70('0x94')](_0x208198[_0xea70('0x64')][_0xea70('0x76')],_[_0xea70('0x95')](_0x208198[_0xea70('0x64')],[_0xea70('0x76'),'id'])||{})[_0xea70('0x96')](function(_0x419f8c){for(var _0x2e5651=0x0;_0x2e5651<_0x208198[_0xea70('0x64')][_0xea70('0x76')]['length'];_0x2e5651+=0x1){socket['emit'](_0xea70('0x97'),{'UserId':Number(_0x208198[_0xea70('0x64')][_0xea70('0x76')][_0x2e5651]),'ChatQueueId':Number(_0x208198[_0xea70('0x56')]['id'])});}return _0x419f8c;});}})[_0xea70('0x34')](respondWithResult(_0x23633e,null))[_0xea70('0x54')](handleError(_0x23633e,null));};exports[_0xea70('0x92')]=function(_0x41c732,_0x226d66,_0x2fa9de){return db[_0xea70('0x3e')][_0xea70('0x59')]({'where':{'id':_0x41c732[_0xea70('0x56')]['id']}})['then'](handleEntityNotFound(_0x226d66,null))[_0xea70('0x34')](function(_0x6955db){if(_0x6955db){return _0x6955db[_0xea70('0x92')](_0x41c732[_0xea70('0x43')][_0xea70('0x76')])[_0xea70('0x34')](function(){if(_[_0xea70('0x98')](_0x41c732['query'][_0xea70('0x76')])){for(var _0x9552a5=0x0;_0x9552a5<_0x41c732[_0xea70('0x43')][_0xea70('0x76')][_0xea70('0x57')];_0x9552a5+=0x1){socket['emit']('userChatQueue:remove',{'UserId':Number(_0x41c732[_0xea70('0x43')][_0xea70('0x76')][_0x9552a5]),'ChatQueueId':Number(_0x41c732[_0xea70('0x56')]['id'])});}}else{socket[_0xea70('0x99')]('userChatQueue:remove',{'UserId':Number(_0x41c732['query'][_0xea70('0x76')]),'ChatQueueId':Number(_0x41c732[_0xea70('0x56')]['id'])});}});}})[_0xea70('0x34')](respondWithStatusCode(_0x226d66,null))[_0xea70('0x54')](handleError(_0x226d66,null));};exports[_0xea70('0x9a')]=function(_0x2fc519,_0x345db7,_0x5d5315){var _0x19623f={};var _0xe4905b={};var _0x524d37;var _0x5799f4;return db[_0xea70('0x3e')]['findOne']({'where':{'id':_0x2fc519[_0xea70('0x56')]['id']}})[_0xea70('0x34')](handleEntityNotFound(_0x345db7,null))[_0xea70('0x34')](function(_0x1eff33){if(_0x1eff33){_0x524d37=_0x1eff33;_0xe4905b['model']=_['keys'](db[_0xea70('0x6a')][_0xea70('0x9b')]);_0xe4905b[_0xea70('0x43')]=_[_0xea70('0x44')](_0x2fc519['query']);_0xe4905b[_0xea70('0x45')]=_[_0xea70('0x46')](_0xe4905b[_0xea70('0x42')],_0xe4905b['query']);_0x19623f[_0xea70('0x48')]=_[_0xea70('0x46')](_0xe4905b[_0xea70('0x42')],qs[_0xea70('0x47')](_0x2fc519['query'][_0xea70('0x47')]));_0x19623f[_0xea70('0x48')]=_0x19623f['attributes']['length']?_0x19623f['attributes']:_0xe4905b[_0xea70('0x42')];_0x19623f[_0xea70('0x4a')]=qs[_0xea70('0x4b')](_0x2fc519[_0xea70('0x43')][_0xea70('0x4b')]);_0x19623f[_0xea70('0x4c')]=qs[_0xea70('0x45')](_['pick'](_0x2fc519[_0xea70('0x43')],_0xe4905b[_0xea70('0x45')]));if(_0x2fc519['query']['filter']){_0x19623f[_0xea70('0x4c')]=_['merge'](_0x19623f[_0xea70('0x4c')],{'$or':_[_0xea70('0x3d')](_0x19623f[_0xea70('0x48')],function(_0x13241c){var _0x18d461={};_0x18d461[_0x13241c]={'$like':'%'+_0x2fc519[_0xea70('0x43')]['filter']+'%'};return _0x18d461;})});}_0x19623f=_['merge']({},_0x19623f,_0x2fc519['options']);return _0x524d37[_0xea70('0x9a')](_0x19623f);}})[_0xea70('0x34')](function(_0x575be3){if(_0x575be3){_0x5799f4=_0x575be3[_0xea70('0x57')];if(!_0x2fc519[_0xea70('0x43')][_0xea70('0x49')](_0xea70('0x68'))){_0x19623f[_0xea70('0x2e')]=qs[_0xea70('0x2e')](_0x2fc519['query'][_0xea70('0x2e')]);_0x19623f[_0xea70('0x2c')]=qs[_0xea70('0x2c')](_0x2fc519[_0xea70('0x43')]['offset']);}return _0x524d37[_0xea70('0x9a')](_0x19623f);}})[_0xea70('0x34')](function(_0x367786){if(_0x367786){return _0x367786?{'count':_0x5799f4,'rows':_0x367786}:null;}})['then'](respondWithResult(_0x345db7,null))[_0xea70('0x54')](handleError(_0x345db7,null));};
\ No newline at end of file
+var _0xf237=['error','code','message','info','result','catch','sendStatus','status','end','json','offset','undefined','limit','apply','reject','save','update','destroy','ChatQueues','UserProfileResource','stack','name','map','ChatQueue','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','sort','where','VIRTUAL','filter','merge','options','count','includeAll','include','rows','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getMembers','findOne','get','UserChatQueue','pick','ChatQueueId','findAll','User','findAndCountAll','UserId','chatPause','updatedAt','createdAt','%s/%s','SIP','Team','order','getTeams','addTeams','ids','online','voicePause','interface','flatMap','Agents','transaction','each','forEach','emit','userChatQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','toString','sequelize','QueryTypes','SELECT','every','TeamId','all','compact','value','isEmpty','userChatQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','rawAttributes','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','ejs','fs-extra','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','defaults','localhost','register','client','http','request','then','ChatQueue,\x20%s,\x20%s','request\x20sent','ChatQueue,\x20%s,\x20%s,\x20%s','stringify'];(function(_0xcf1bab,_0x4916c8){var _0x314ce0=function(_0x4090b7){while(--_0x4090b7){_0xcf1bab['push'](_0xcf1bab['shift']());}};_0x314ce0(++_0x4916c8);}(_0xf237,0x76));var _0x7f23=function(_0x4c2c23,_0x3d8d28){_0x4c2c23=_0x4c2c23-0x0;var _0x5c992e=_0xf237[_0x4c2c23];return _0x5c992e;};'use strict';var emlformat=require(_0x7f23('0x0'));var rimraf=require(_0x7f23('0x1'));var zipdir=require(_0x7f23('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7f23('0x3'));var moment=require(_0x7f23('0x4'));var BPromise=require(_0x7f23('0x5'));var Mustache=require('mustache');var util=require(_0x7f23('0x6'));var path=require(_0x7f23('0x7'));var sox=require(_0x7f23('0x8'));var csv=require('to-csv');var ejs=require(_0x7f23('0x9'));var fs=require('fs');var fs_extra=require(_0x7f23('0xa'));var _=require(_0x7f23('0xb'));var squel=require(_0x7f23('0xc'));var crypto=require('crypto');var jsforce=require(_0x7f23('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x7f23('0xe'));var Papa=require(_0x7f23('0xf'));var Redis=require(_0x7f23('0x10'));var authService=require(_0x7f23('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x7f23('0x12'));var hardwareService=require(_0x7f23('0x13'));var logger=require(_0x7f23('0x14'))(_0x7f23('0x15'));var utils=require(_0x7f23('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x7f23('0x17'))['db'];config[_0x7f23('0x18')]=_[_0x7f23('0x19')](config[_0x7f23('0x18')],{'host':_0x7f23('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x7f23('0x18')]));require('./chatQueue.socket')[_0x7f23('0x1b')](socket);var jayson=require('jayson/promise');var client=jayson[_0x7f23('0x1c')][_0x7f23('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x236a01,_0x1d98c1,_0xc21e43,_0x3b247b){return new BPromise(function(_0x25de3a,_0x58cdbe){var _0x25e57c=_0x3b247b||client;return _0x25e57c[_0x7f23('0x1e')](_0x236a01,_0xc21e43)[_0x7f23('0x1f')](function(_0x2ae9ad){logger['info'](_0x7f23('0x20'),_0x1d98c1,_0x7f23('0x21'));logger['debug'](_0x7f23('0x22'),_0x1d98c1,_0x7f23('0x21'),JSON[_0x7f23('0x23')](_0x2ae9ad));if(_0x2ae9ad['error']){if(_0x2ae9ad[_0x7f23('0x24')][_0x7f23('0x25')]===0x1f4){logger['error'](_0x7f23('0x20'),_0x1d98c1,_0x2ae9ad[_0x7f23('0x24')][_0x7f23('0x26')]);return _0x58cdbe(_0x2ae9ad['error'][_0x7f23('0x26')]);}logger[_0x7f23('0x24')](_0x7f23('0x20'),_0x1d98c1,_0x2ae9ad[_0x7f23('0x24')][_0x7f23('0x26')]);return _0x25de3a(_0x2ae9ad[_0x7f23('0x24')][_0x7f23('0x26')]);}else{logger[_0x7f23('0x27')](_0x7f23('0x20'),_0x1d98c1,'request\x20sent');_0x25de3a(_0x2ae9ad[_0x7f23('0x28')][_0x7f23('0x26')]);}})[_0x7f23('0x29')](function(_0x53fcba){logger[_0x7f23('0x24')]('ChatQueue,\x20%s,\x20%s',_0x1d98c1,_0x53fcba);_0x58cdbe(_0x53fcba);});});}function respondWithStatusCode(_0x5479df,_0x4a5d14){_0x4a5d14=_0x4a5d14||0xcc;return function(_0x1eabfb){if(_0x1eabfb){return _0x5479df[_0x7f23('0x2a')](_0x4a5d14);}return _0x5479df[_0x7f23('0x2b')](_0x4a5d14)[_0x7f23('0x2c')]();};}function respondWithResult(_0x514edc,_0x529636){_0x529636=_0x529636||0xc8;return function(_0x2c2f27){if(_0x2c2f27){return _0x514edc[_0x7f23('0x2b')](_0x529636)[_0x7f23('0x2d')](_0x2c2f27);}};}function respondWithFilteredResult(_0x21b738,_0x2f9e9a){return function(_0x5a12e8){if(_0x5a12e8){var _0x238a47=typeof _0x2f9e9a[_0x7f23('0x2e')]===_0x7f23('0x2f')&&typeof _0x2f9e9a['limit']===_0x7f23('0x2f');var _0x10eee4=_0x5a12e8['count'];var _0x559449=_0x238a47?0x0:_0x2f9e9a[_0x7f23('0x2e')];var _0x420a96=_0x238a47?_0x5a12e8['count']:_0x2f9e9a['offset']+_0x2f9e9a[_0x7f23('0x30')];var _0xcbb601;if(_0x420a96>=_0x10eee4){_0x420a96=_0x10eee4;_0xcbb601=0xc8;}else{_0xcbb601=0xce;}_0x21b738['status'](_0xcbb601);return _0x21b738['set']('Content-Range',_0x559449+'-'+_0x420a96+'/'+_0x10eee4)['json'](_0x5a12e8);}return null;};}function patchUpdates(_0x2af1b2){return function(_0x323675){try{jsonpatch[_0x7f23('0x31')](_0x323675,_0x2af1b2,!![]);}catch(_0x4e0300){return BPromise[_0x7f23('0x32')](_0x4e0300);}return _0x323675[_0x7f23('0x33')]();};}function saveUpdates(_0x32a075,_0x2b2929){return function(_0x20c075){if(_0x20c075){return _0x20c075[_0x7f23('0x34')](_0x32a075)['then'](function(_0x485a6f){return _0x485a6f;});}return null;};}function removeEntity(_0x18ef48,_0x2732f3){return function(_0x153e55){if(_0x153e55){return _0x153e55[_0x7f23('0x35')]()[_0x7f23('0x1f')](function(){var _0x304f7c=_0x153e55['get']({'plain':!![]});var _0x12de40=_0x7f23('0x36');return db[_0x7f23('0x37')][_0x7f23('0x35')]({'where':{'type':_0x12de40,'resourceId':_0x304f7c['id']}})[_0x7f23('0x1f')](function(){return _0x153e55;});})[_0x7f23('0x1f')](function(){_0x18ef48[_0x7f23('0x2b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x24163c,_0x46c0d8){return function(_0x424f5a){if(!_0x424f5a){_0x24163c['sendStatus'](0x194);}return _0x424f5a;};}function handleError(_0x21d6fa,_0x38c09a){_0x38c09a=_0x38c09a||0x1f4;return function(_0x2182ff){logger['error'](_0x2182ff[_0x7f23('0x38')]);if(_0x2182ff[_0x7f23('0x39')]){delete _0x2182ff[_0x7f23('0x39')];}_0x21d6fa[_0x7f23('0x2b')](_0x38c09a)['send'](_0x2182ff);};}exports['index']=function(_0x36d87d,_0x2a4c84){var _0x2da85a={},_0x581fe0={},_0x2bc47e={'count':0x0,'rows':[]};var _0x2cf38d=_[_0x7f23('0x3a')](db[_0x7f23('0x3b')]['rawAttributes'],function(_0x130115){return{'name':_0x130115[_0x7f23('0x3c')],'type':_0x130115[_0x7f23('0x3d')][_0x7f23('0x3e')]};});_0x581fe0['model']=_['map'](_0x2cf38d,_0x7f23('0x39'));_0x581fe0[_0x7f23('0x3f')]=_[_0x7f23('0x40')](_0x36d87d[_0x7f23('0x3f')]);_0x581fe0[_0x7f23('0x41')]=_[_0x7f23('0x42')](_0x581fe0[_0x7f23('0x43')],_0x581fe0[_0x7f23('0x3f')]);_0x2da85a[_0x7f23('0x44')]=_[_0x7f23('0x42')](_0x581fe0['model'],qs[_0x7f23('0x45')](_0x36d87d[_0x7f23('0x3f')]['fields']));_0x2da85a[_0x7f23('0x44')]=_0x2da85a[_0x7f23('0x44')][_0x7f23('0x46')]?_0x2da85a[_0x7f23('0x44')]:_0x581fe0[_0x7f23('0x43')];if(!_0x36d87d[_0x7f23('0x3f')][_0x7f23('0x47')](_0x7f23('0x48'))){_0x2da85a[_0x7f23('0x30')]=qs[_0x7f23('0x30')](_0x36d87d[_0x7f23('0x3f')][_0x7f23('0x30')]);_0x2da85a[_0x7f23('0x2e')]=qs[_0x7f23('0x2e')](_0x36d87d['query'][_0x7f23('0x2e')]);}_0x2da85a['order']=qs['sort'](_0x36d87d[_0x7f23('0x3f')][_0x7f23('0x49')]);_0x2da85a[_0x7f23('0x4a')]=qs['filters'](_['pick'](_0x36d87d[_0x7f23('0x3f')],_0x581fe0[_0x7f23('0x41')]),_0x2cf38d);if(_0x36d87d[_0x7f23('0x3f')]['filter']){_0x2da85a[_0x7f23('0x4a')]=_['merge'](_0x2da85a[_0x7f23('0x4a')],{'$or':_[_0x7f23('0x3a')](_0x2cf38d,function(_0x24024c){if(_0x24024c[_0x7f23('0x3d')]!==_0x7f23('0x4b')){var _0x2fe8a2={};_0x2fe8a2[_0x24024c[_0x7f23('0x39')]]={'$like':'%'+_0x36d87d[_0x7f23('0x3f')][_0x7f23('0x4c')]+'%'};return _0x2fe8a2;}})});}_0x2da85a=_[_0x7f23('0x4d')]({},_0x2da85a,_0x36d87d[_0x7f23('0x4e')]);var _0x16bc31={'where':_0x2da85a[_0x7f23('0x4a')]};return db['ChatQueue'][_0x7f23('0x4f')](_0x16bc31)[_0x7f23('0x1f')](function(_0x2bb565){_0x2bc47e['count']=_0x2bb565;if(_0x36d87d['query'][_0x7f23('0x50')]){_0x2da85a[_0x7f23('0x51')]=[{'all':!![]}];}return db['ChatQueue']['findAll'](_0x2da85a);})[_0x7f23('0x1f')](function(_0x3e092c){_0x2bc47e[_0x7f23('0x52')]=_0x3e092c;return _0x2bc47e;})['then'](respondWithFilteredResult(_0x2a4c84,_0x2da85a))['catch'](handleError(_0x2a4c84,null));};exports[_0x7f23('0x53')]=function(_0x13610e,_0x4af82d){var _0x357ab6={'raw':!![],'where':{'id':_0x13610e[_0x7f23('0x54')]['id']}},_0x47ad03={};_0x47ad03[_0x7f23('0x43')]=_[_0x7f23('0x40')](db[_0x7f23('0x3b')]['rawAttributes']);_0x47ad03['query']=_[_0x7f23('0x40')](_0x13610e[_0x7f23('0x3f')]);_0x47ad03[_0x7f23('0x41')]=_[_0x7f23('0x42')](_0x47ad03[_0x7f23('0x43')],_0x47ad03[_0x7f23('0x3f')]);_0x357ab6[_0x7f23('0x44')]=_[_0x7f23('0x42')](_0x47ad03[_0x7f23('0x43')],qs[_0x7f23('0x45')](_0x13610e[_0x7f23('0x3f')][_0x7f23('0x45')]));_0x357ab6[_0x7f23('0x44')]=_0x357ab6[_0x7f23('0x44')]['length']?_0x357ab6[_0x7f23('0x44')]:_0x47ad03['model'];if(_0x13610e['query']['includeAll']){_0x357ab6[_0x7f23('0x51')]=[{'all':!![]}];}_0x357ab6=_[_0x7f23('0x4d')]({},_0x357ab6,_0x13610e['options']);return db[_0x7f23('0x3b')][_0x7f23('0x55')](_0x357ab6)[_0x7f23('0x1f')](handleEntityNotFound(_0x4af82d,null))[_0x7f23('0x1f')](respondWithResult(_0x4af82d,null))[_0x7f23('0x29')](handleError(_0x4af82d,null));};exports[_0x7f23('0x56')]=function(_0x3f00d6,_0x5f1b9d){return db['ChatQueue'][_0x7f23('0x56')](_0x3f00d6[_0x7f23('0x57')],{})['then'](function(_0x1b25e9){var _0x5f30ea=_0x3f00d6[_0x7f23('0x58')]['get']({'plain':!![]});if(!_0x5f30ea)throw new Error(_0x7f23('0x59'));if(_0x5f30ea['role']==='user'){var _0x543850=_0x1b25e9['get']({'plain':!![]});var _0x4d6347='ChatQueues';return db[_0x7f23('0x5a')][_0x7f23('0x55')]({'where':{'name':_0x4d6347,'userProfileId':_0x5f30ea[_0x7f23('0x5b')]},'raw':!![]})[_0x7f23('0x1f')](function(_0x4b2f96){if(_0x4b2f96&&_0x4b2f96[_0x7f23('0x5c')]===0x0){return db[_0x7f23('0x37')]['create']({'name':_0x543850[_0x7f23('0x39')],'resourceId':_0x543850['id'],'type':_0x4b2f96[_0x7f23('0x39')],'sectionId':_0x4b2f96['id']},{})[_0x7f23('0x1f')](function(){return _0x1b25e9;});}else{return _0x1b25e9;}})[_0x7f23('0x29')](function(_0x82ed06){logger[_0x7f23('0x24')](_0x7f23('0x5d'),_0x82ed06);throw _0x82ed06;});}return _0x1b25e9;})[_0x7f23('0x1f')](respondWithResult(_0x5f1b9d,0xc9))[_0x7f23('0x29')](handleError(_0x5f1b9d,null));};exports[_0x7f23('0x34')]=function(_0x250b4c,_0x217d71){if(_0x250b4c[_0x7f23('0x57')]['id']){delete _0x250b4c[_0x7f23('0x57')]['id'];}return db[_0x7f23('0x3b')][_0x7f23('0x55')]({'where':{'id':_0x250b4c[_0x7f23('0x54')]['id']}})['then'](handleEntityNotFound(_0x217d71,null))[_0x7f23('0x1f')](saveUpdates(_0x250b4c[_0x7f23('0x57')],null))[_0x7f23('0x1f')](respondWithResult(_0x217d71,null))[_0x7f23('0x29')](handleError(_0x217d71,null));};exports[_0x7f23('0x35')]=function(_0x5e3edb,_0x5eed8c){return db[_0x7f23('0x3b')][_0x7f23('0x55')]({'where':{'id':_0x5e3edb['params']['id']}})[_0x7f23('0x1f')](handleEntityNotFound(_0x5eed8c,null))[_0x7f23('0x1f')](removeEntity(_0x5eed8c,null))[_0x7f23('0x29')](handleError(_0x5eed8c,null));};exports['describe']=function(_0x41ff01,_0x1365bd){return db[_0x7f23('0x3b')]['describe']()[_0x7f23('0x1f')](respondWithResult(_0x1365bd,null))['catch'](handleError(_0x1365bd,null));};exports[_0x7f23('0x5e')]=function(_0x219dff,_0x11d539,_0x2d8009){var _0x1c8757={'raw':!![],'where':{}},_0x13a801={},_0x4ebd05;return db[_0x7f23('0x3b')][_0x7f23('0x5f')]({'where':{'id':_0x219dff[_0x7f23('0x54')]['id']}})[_0x7f23('0x1f')](handleEntityNotFound(_0x11d539,null))[_0x7f23('0x1f')](function(_0x955e68){if(_0x955e68){_0x4ebd05=_0x955e68[_0x7f23('0x60')]({'plain':!![]});_0x13a801[_0x7f23('0x43')]=_[_0x7f23('0x40')](db[_0x7f23('0x61')]['rawAttributes']);_0x13a801[_0x7f23('0x3f')]=_['keys'](_0x219dff[_0x7f23('0x3f')]);_0x13a801['filters']=_[_0x7f23('0x42')](_0x13a801['model'],_0x13a801['query']);_0x1c8757[_0x7f23('0x44')]=_[_0x7f23('0x42')](_0x13a801[_0x7f23('0x43')],qs[_0x7f23('0x45')](_0x219dff[_0x7f23('0x3f')][_0x7f23('0x45')]));_0x1c8757['attributes']=_0x1c8757[_0x7f23('0x44')][_0x7f23('0x46')]?_0x1c8757[_0x7f23('0x44')]:_0x13a801[_0x7f23('0x43')];if(!_0x219dff[_0x7f23('0x3f')][_0x7f23('0x47')](_0x7f23('0x48'))){_0x1c8757[_0x7f23('0x30')]=qs[_0x7f23('0x30')](_0x219dff[_0x7f23('0x3f')]['limit']);_0x1c8757[_0x7f23('0x2e')]=qs['offset'](_0x219dff[_0x7f23('0x3f')][_0x7f23('0x2e')]);}_0x1c8757['order']=qs[_0x7f23('0x49')](_0x219dff[_0x7f23('0x3f')]['sort']);_0x1c8757['where']=qs[_0x7f23('0x41')](_[_0x7f23('0x62')](_0x219dff[_0x7f23('0x3f')],_0x13a801[_0x7f23('0x41')]));_0x1c8757['where'][_0x7f23('0x63')]=_0x955e68['id'];if(_0x219dff['query'][_0x7f23('0x4c')]){_0x1c8757['where']=_[_0x7f23('0x4d')](_0x1c8757[_0x7f23('0x4a')],{'$or':_[_0x7f23('0x3a')](_0x1c8757[_0x7f23('0x44')],function(_0x55ea04){var _0x4192c4={};_0x4192c4[_0x55ea04]={'$like':'%'+_0x219dff[_0x7f23('0x3f')]['filter']+'%'};return _0x4192c4;})});}_0x1c8757=_[_0x7f23('0x4d')]({},_0x1c8757,_0x219dff[_0x7f23('0x4e')]);return db['UserChatQueue'][_0x7f23('0x64')](_0x1c8757);}})[_0x7f23('0x1f')](function(_0x17ca93){if(_0x17ca93){return db[_0x7f23('0x65')][_0x7f23('0x66')]({'where':{'id':_[_0x7f23('0x3a')](_0x17ca93,_0x7f23('0x67')),'role':'agent'},'attributes':['id',_0x7f23('0x39'),_0x7f23('0x68'),_0x7f23('0x69'),_0x7f23('0x6a')]});}})['then'](function(_0x4b9027){if(_0x4b9027){return{'count':_0x4b9027[_0x7f23('0x4f')],'rows':_[_0x7f23('0x3a')](_0x4b9027['rows'],function(_0x266240){return{'membername':_0x266240[_0x7f23('0x39')],'UserId':_0x266240['id'],'queue_name':_0x4ebd05[_0x7f23('0x39')],'ChatQueueId':_0x4ebd05['id'],'interface':util['format'](_0x7f23('0x6b'),_0x7f23('0x6c'),_0x266240['name']),'penalty':0x0,'paused':_0x266240['chatPause'],'createdAt':_0x266240['createdAt'],'updatedAt':_0x266240[_0x7f23('0x69')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x7f23('0x1f')](respondWithFilteredResult(_0x11d539,_0x1c8757))[_0x7f23('0x29')](handleError(_0x11d539,null));};exports['getTeams']=function(_0x2a4fed,_0x40ef57,_0x2bee88){var _0x9bf2c0={};var _0x2e066b={};var _0x5abe6b;var _0x2dc1ca;return db[_0x7f23('0x3b')][_0x7f23('0x5f')]({'where':{'id':_0x2a4fed['params']['id']}})['then'](handleEntityNotFound(_0x40ef57,null))[_0x7f23('0x1f')](function(_0x385ee1){if(_0x385ee1){_0x5abe6b=_0x385ee1;_0x2e066b[_0x7f23('0x43')]=_[_0x7f23('0x40')](db[_0x7f23('0x6d')]['rawAttributes']);_0x2e066b['query']=_[_0x7f23('0x40')](_0x2a4fed[_0x7f23('0x3f')]);_0x2e066b[_0x7f23('0x41')]=_[_0x7f23('0x42')](_0x2e066b[_0x7f23('0x43')],_0x2e066b[_0x7f23('0x3f')]);_0x9bf2c0[_0x7f23('0x44')]=_[_0x7f23('0x42')](_0x2e066b[_0x7f23('0x43')],qs[_0x7f23('0x45')](_0x2a4fed[_0x7f23('0x3f')][_0x7f23('0x45')]));_0x9bf2c0['attributes']=_0x9bf2c0[_0x7f23('0x44')][_0x7f23('0x46')]?_0x9bf2c0[_0x7f23('0x44')]:_0x2e066b[_0x7f23('0x43')];_0x9bf2c0[_0x7f23('0x6e')]=qs[_0x7f23('0x49')](_0x2a4fed['query'][_0x7f23('0x49')]);_0x9bf2c0[_0x7f23('0x4a')]=qs[_0x7f23('0x41')](_[_0x7f23('0x62')](_0x2a4fed[_0x7f23('0x3f')],_0x2e066b[_0x7f23('0x41')]));if(_0x2a4fed[_0x7f23('0x3f')]['filter']){_0x9bf2c0[_0x7f23('0x4a')]=_['merge'](_0x9bf2c0[_0x7f23('0x4a')],{'$or':_[_0x7f23('0x3a')](_0x9bf2c0[_0x7f23('0x44')],function(_0x289906){var _0x4efde1={};_0x4efde1[_0x289906]={'$like':'%'+_0x2a4fed[_0x7f23('0x3f')][_0x7f23('0x4c')]+'%'};return _0x4efde1;})});}_0x9bf2c0=_[_0x7f23('0x4d')]({},_0x9bf2c0,_0x2a4fed[_0x7f23('0x4e')]);return _0x5abe6b[_0x7f23('0x6f')](_0x9bf2c0);}})['then'](function(_0x2a541a){if(_0x2a541a){_0x2dc1ca=_0x2a541a[_0x7f23('0x46')];if(!_0x2a4fed[_0x7f23('0x3f')][_0x7f23('0x47')](_0x7f23('0x48'))){_0x9bf2c0['limit']=qs[_0x7f23('0x30')](_0x2a4fed[_0x7f23('0x3f')][_0x7f23('0x30')]);_0x9bf2c0[_0x7f23('0x2e')]=qs[_0x7f23('0x2e')](_0x2a4fed['query'][_0x7f23('0x2e')]);}return _0x5abe6b[_0x7f23('0x6f')](_0x9bf2c0);}})[_0x7f23('0x1f')](function(_0x4d6d08){if(_0x4d6d08){return _0x4d6d08?{'count':_0x2dc1ca,'rows':_0x4d6d08}:null;}})['then'](respondWithResult(_0x40ef57,null))[_0x7f23('0x29')](handleError(_0x40ef57,null));};exports[_0x7f23('0x70')]=function(_0x529ff4,_0xbfe6db,_0x3c1e8e){var _0x51460b=_0x529ff4[_0x7f23('0x57')][_0x7f23('0x71')];return db[_0x7f23('0x6d')][_0x7f23('0x64')]({'where':{'id':_0x51460b},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id','name',_0x7f23('0x72'),_0x7f23('0x73'),_0x7f23('0x74')],'raw':!![]}]})[_0x7f23('0x1f')](function(_0x47a943){if(_0x47a943){var _0x7a3e26=_[_0x7f23('0x75')](_0x47a943,function(_0x2e49f7){var _0x2d6fad=_0x2e49f7[_0x7f23('0x60')]({'plain':!![]});return _0x2d6fad[_0x7f23('0x76')];});return db[_0x7f23('0x3b')][_0x7f23('0x55')]({'where':{'id':_0x529ff4[_0x7f23('0x54')]['id']}})[_0x7f23('0x1f')](function(_0x5f23db){return db['sequelize'][_0x7f23('0x77')](function(_0x5b922e){return _0x5f23db[_0x7f23('0x70')](_0x51460b,{'transaction':_0x5b922e})['then'](function(){return BPromise[_0x7f23('0x78')](_0x7a3e26,function(_0x20e4a2){return db[_0x7f23('0x61')]['findOrCreate']({'where':{'UserId':_0x20e4a2['id'],'ChatQueueId':_0x529ff4['params']['id']},'transaction':_0x5b922e});});})['then'](function(){_0x7a3e26[_0x7f23('0x79')](function(_0x4dc52d){socket[_0x7f23('0x7a')](_0x7f23('0x7b'),{'UserId':_0x4dc52d['id'],'ChatQueueId':_0x5f23db['id']});});});});});}})[_0x7f23('0x1f')](respondWithStatusCode(_0xbfe6db,null))[_0x7f23('0x29')](handleError(_0xbfe6db,null));};exports[_0x7f23('0x7c')]=function(_0x44ab09,_0x4fca6a,_0x6a0221){return db[_0x7f23('0x6d')][_0x7f23('0x64')]({'where':{'id':_0x44ab09['query'][_0x7f23('0x71')]},'attributes':['id'],'include':[{'model':db[_0x7f23('0x65')],'as':_0x7f23('0x76'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x4fca6a,null))[_0x7f23('0x1f')](function(_0x532735){var _0x529c37=_['map'](_0x532735,'id');var _0x51ebb4=[];var _0x2959c9=[];var _0x6ce39e=squel[_0x7f23('0x7d')]();_0x6ce39e[_0x7f23('0x7e')](_0x7f23('0x7f'))[_0x7f23('0x80')](_0x7f23('0x81'),'tq')[_0x7f23('0x82')](_0x7f23('0x83'),'ut',_0x7f23('0x84'))[_0x7f23('0x4a')]('ChatQueueId\x20=\x20?',_0x44ab09[_0x7f23('0x54')]['id']);for(var _0x310b88=0x0;_0x310b88<_0x532735['length'];_0x310b88+=0x1){let _0xbbedb4=_0x532735[_0x310b88];for(var _0x3f4913=0x0;_0x3f4913<_0xbbedb4[_0x7f23('0x76')]['length'];_0x3f4913+=0x1){let _0x284f51=_0xbbedb4[_0x7f23('0x76')][_0x3f4913];var _0x2f7ec5=_0x6ce39e[_0x7f23('0x85')]();_0x2f7ec5[_0x7f23('0x4a')](_0x7f23('0x86'),_0x284f51['id']);_0x2959c9[_0x7f23('0x87')](db['sequelize'][_0x7f23('0x3f')](_0x2f7ec5[_0x7f23('0x88')](),{'type':db[_0x7f23('0x89')][_0x7f23('0x8a')][_0x7f23('0x8b')]})[_0x7f23('0x1f')](function(_0x3ac84){if(_0x3ac84['length']===0x1){return _0x284f51['id'];}else{var _0x28e865=_[_0x7f23('0x8c')](_['map'](_0x3ac84,_0x7f23('0x8d')),function(_0x569b18){return _['includes'](_0x529c37,_0x569b18);});if(_0x28e865){return _0x284f51['id'];}}}));}}return BPromise[_0x7f23('0x8e')](_0x2959c9)[_0x7f23('0x1f')](function(_0x52ff80){_0x51ebb4=_(_0x51ebb4)['union'](_0x52ff80)[_0x7f23('0x8f')]()[_0x7f23('0x90')]();return db[_0x7f23('0x3b')][_0x7f23('0x55')]({'where':{'id':_0x44ab09[_0x7f23('0x54')]['id']}})['then'](function(_0x5c965c){return db[_0x7f23('0x89')]['transaction'](function(_0x435323){return _0x5c965c[_0x7f23('0x7c')](_0x44ab09[_0x7f23('0x3f')][_0x7f23('0x71')],{'transaction':_0x435323})[_0x7f23('0x1f')](function(){if(!_[_0x7f23('0x91')](_0x51ebb4)){return _0x5c965c['removeAgents'](_0x51ebb4,{'transaction':_0x435323});}})[_0x7f23('0x1f')](function(){_0x51ebb4[_0x7f23('0x79')](function(_0x54915f){socket[_0x7f23('0x7a')](_0x7f23('0x92'),{'UserId':_0x54915f,'ChatQueueId':_0x5c965c['id']});});});});});});})[_0x7f23('0x1f')](respondWithStatusCode(_0x4fca6a,null))[_0x7f23('0x29')](handleError(_0x4fca6a,null));};exports[_0x7f23('0x93')]=function(_0x4e400c,_0x4433a1,_0x1a8326){return db[_0x7f23('0x3b')][_0x7f23('0x55')]({'where':{'id':_0x4e400c[_0x7f23('0x54')]['id']}})[_0x7f23('0x1f')](handleEntityNotFound(_0x4433a1,null))[_0x7f23('0x1f')](function(_0x5d0b4f){if(_0x5d0b4f){return _0x5d0b4f['addAgents'](_0x4e400c['body'][_0x7f23('0x71')],_[_0x7f23('0x94')](_0x4e400c[_0x7f23('0x57')],[_0x7f23('0x71'),'id'])||{})[_0x7f23('0x95')](function(_0x158857){for(var _0x1a7e24=0x0;_0x1a7e24<_0x4e400c[_0x7f23('0x57')][_0x7f23('0x71')]['length'];_0x1a7e24+=0x1){socket[_0x7f23('0x7a')](_0x7f23('0x7b'),{'UserId':Number(_0x4e400c[_0x7f23('0x57')]['ids'][_0x1a7e24]),'ChatQueueId':Number(_0x4e400c[_0x7f23('0x54')]['id'])});}return _0x158857;});}})[_0x7f23('0x1f')](respondWithResult(_0x4433a1,null))['catch'](handleError(_0x4433a1,null));};exports[_0x7f23('0x96')]=function(_0x7a7687,_0x243f14,_0x45270d){return db[_0x7f23('0x3b')][_0x7f23('0x55')]({'where':{'id':_0x7a7687[_0x7f23('0x54')]['id']}})['then'](handleEntityNotFound(_0x243f14,null))[_0x7f23('0x1f')](function(_0x18e6c5){if(_0x18e6c5){return _0x18e6c5[_0x7f23('0x96')](_0x7a7687[_0x7f23('0x3f')][_0x7f23('0x71')])[_0x7f23('0x1f')](function(){if(_[_0x7f23('0x97')](_0x7a7687[_0x7f23('0x3f')][_0x7f23('0x71')])){for(var _0x38cccc=0x0;_0x38cccc<_0x7a7687[_0x7f23('0x3f')][_0x7f23('0x71')]['length'];_0x38cccc+=0x1){socket[_0x7f23('0x7a')](_0x7f23('0x92'),{'UserId':Number(_0x7a7687[_0x7f23('0x3f')][_0x7f23('0x71')][_0x38cccc]),'ChatQueueId':Number(_0x7a7687['params']['id'])});}}else{socket[_0x7f23('0x7a')](_0x7f23('0x92'),{'UserId':Number(_0x7a7687[_0x7f23('0x3f')][_0x7f23('0x71')]),'ChatQueueId':Number(_0x7a7687[_0x7f23('0x54')]['id'])});}});}})[_0x7f23('0x1f')](respondWithStatusCode(_0x243f14,null))[_0x7f23('0x29')](handleError(_0x243f14,null));};exports[_0x7f23('0x98')]=function(_0x27cb82,_0x6f35c7,_0x4a0eb1){var _0xeb6be1={};var _0xc79c06={};var _0x49192b;var _0x24e3d9;return db[_0x7f23('0x3b')][_0x7f23('0x5f')]({'where':{'id':_0x27cb82[_0x7f23('0x54')]['id']}})[_0x7f23('0x1f')](handleEntityNotFound(_0x6f35c7,null))[_0x7f23('0x1f')](function(_0x259799){if(_0x259799){_0x49192b=_0x259799;_0xc79c06[_0x7f23('0x43')]=_[_0x7f23('0x40')](db[_0x7f23('0x65')][_0x7f23('0x99')]);_0xc79c06['query']=_[_0x7f23('0x40')](_0x27cb82[_0x7f23('0x3f')]);_0xc79c06[_0x7f23('0x41')]=_['intersection'](_0xc79c06['model'],_0xc79c06[_0x7f23('0x3f')]);_0xeb6be1['attributes']=_[_0x7f23('0x42')](_0xc79c06[_0x7f23('0x43')],qs['fields'](_0x27cb82[_0x7f23('0x3f')]['fields']));_0xeb6be1[_0x7f23('0x44')]=_0xeb6be1[_0x7f23('0x44')][_0x7f23('0x46')]?_0xeb6be1[_0x7f23('0x44')]:_0xc79c06[_0x7f23('0x43')];_0xeb6be1[_0x7f23('0x6e')]=qs['sort'](_0x27cb82['query'][_0x7f23('0x49')]);_0xeb6be1[_0x7f23('0x4a')]=qs['filters'](_[_0x7f23('0x62')](_0x27cb82['query'],_0xc79c06[_0x7f23('0x41')]));if(_0x27cb82[_0x7f23('0x3f')]['filter']){_0xeb6be1[_0x7f23('0x4a')]=_[_0x7f23('0x4d')](_0xeb6be1[_0x7f23('0x4a')],{'$or':_[_0x7f23('0x3a')](_0xeb6be1['attributes'],function(_0x3304d2){var _0x1e3d64={};_0x1e3d64[_0x3304d2]={'$like':'%'+_0x27cb82[_0x7f23('0x3f')][_0x7f23('0x4c')]+'%'};return _0x1e3d64;})});}_0xeb6be1=_[_0x7f23('0x4d')]({},_0xeb6be1,_0x27cb82[_0x7f23('0x4e')]);return _0x49192b['getAgents'](_0xeb6be1);}})[_0x7f23('0x1f')](function(_0x235dcb){if(_0x235dcb){_0x24e3d9=_0x235dcb['length'];if(!_0x27cb82[_0x7f23('0x3f')][_0x7f23('0x47')]('nolimit')){_0xeb6be1[_0x7f23('0x30')]=qs[_0x7f23('0x30')](_0x27cb82[_0x7f23('0x3f')][_0x7f23('0x30')]);_0xeb6be1[_0x7f23('0x2e')]=qs[_0x7f23('0x2e')](_0x27cb82[_0x7f23('0x3f')][_0x7f23('0x2e')]);}return _0x49192b['getAgents'](_0xeb6be1);}})['then'](function(_0x47737a){if(_0x47737a){return _0x47737a?{'count':_0x24e3d9,'rows':_0x47737a}:null;}})['then'](respondWithResult(_0x6f35c7,null))[_0x7f23('0x29')](handleError(_0x6f35c7,null));};
\ No newline at end of file