Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 268ce8b..0790e49 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xacd5=['hasOwnProperty','nolimit','order','sort','where','filter','merge','type','options','count','findAll','rows','show','params','rawAttributes','length','include','find','create','body','role','user','ChatQueues','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','pick','UserChatQueue','User','findAndCountAll','UserId','agent','updatedAt','createdAt','format','%s/%s','chatPause','Agents','online','voicePause','interface','sequelize','transaction','addTeams','each','findOrCreate','forEach','emit','userChatQueue:save','Team','ids','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','push','toString','every','includes','all','union','compact','value','removeAgents','userChatQueue:remove','addAgents','spread','isArray','getAgents','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','squel','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./chatQueue.socket','register','jayson/promise','client','http','request','then','info','ChatQueue,\x20%s,\x20%s','debug','ChatQueue,\x20%s,\x20%s,\x20%s','error','code','message','request\x20sent','catch','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','update','get','destroy','stack','name','send','map','ChatQueue','fieldName','key','model','query','keys','filters','attributes','intersection','fields'];(function(_0x389ebe,_0x37984f){var _0xad4009=function(_0x4d67e7){while(--_0x4d67e7){_0x389ebe['push'](_0x389ebe['shift']());}};_0xad4009(++_0x37984f);}(_0xacd5,0x174));var _0x5acd=function(_0x3f9a64,_0x224930){_0x3f9a64=_0x3f9a64-0x0;var _0x353b88=_0xacd5[_0x3f9a64];return _0x353b88;};'use strict';var emlformat=require(_0x5acd('0x0'));var rimraf=require(_0x5acd('0x1'));var zipdir=require(_0x5acd('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5acd('0x3'));var moment=require(_0x5acd('0x4'));var BPromise=require(_0x5acd('0x5'));var Mustache=require(_0x5acd('0x6'));var util=require(_0x5acd('0x7'));var path=require(_0x5acd('0x8'));var sox=require(_0x5acd('0x9'));var csv=require(_0x5acd('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x5acd('0xb'));var crypto=require('crypto');var jsforce=require(_0x5acd('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x5acd('0xd'));var Redis=require(_0x5acd('0xe'));var authService=require(_0x5acd('0xf'));var qs=require(_0x5acd('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5acd('0x11'));var logger=require(_0x5acd('0x12'))('api');var utils=require(_0x5acd('0x13'));var config=require(_0x5acd('0x14'));var licenseUtil=require(_0x5acd('0x15'));var db=require(_0x5acd('0x16'))['db'];config[_0x5acd('0x17')]=_['defaults'](config[_0x5acd('0x17')],{'host':_0x5acd('0x18'),'port':0x18eb});var socket=require(_0x5acd('0x19'))(new Redis(config[_0x5acd('0x17')]));require(_0x5acd('0x1a'))[_0x5acd('0x1b')](socket);var jayson=require(_0x5acd('0x1c'));var client=jayson[_0x5acd('0x1d')][_0x5acd('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x237a36,_0x3018ba,_0x5a0d4e,_0x3a27c4){return new BPromise(function(_0x4968c1,_0x364e2d){var _0x2d8551=_0x3a27c4||client;return _0x2d8551[_0x5acd('0x1f')](_0x237a36,_0x5a0d4e)[_0x5acd('0x20')](function(_0x52f885){logger[_0x5acd('0x21')](_0x5acd('0x22'),_0x3018ba,'request\x20sent');logger[_0x5acd('0x23')](_0x5acd('0x24'),_0x3018ba,'request\x20sent',JSON['stringify'](_0x52f885));if(_0x52f885['error']){if(_0x52f885[_0x5acd('0x25')][_0x5acd('0x26')]===0x1f4){logger[_0x5acd('0x25')](_0x5acd('0x22'),_0x3018ba,_0x52f885['error'][_0x5acd('0x27')]);return _0x364e2d(_0x52f885[_0x5acd('0x25')][_0x5acd('0x27')]);}logger[_0x5acd('0x25')](_0x5acd('0x22'),_0x3018ba,_0x52f885[_0x5acd('0x25')]['message']);return _0x4968c1(_0x52f885[_0x5acd('0x25')]['message']);}else{logger[_0x5acd('0x21')](_0x5acd('0x22'),_0x3018ba,_0x5acd('0x28'));_0x4968c1(_0x52f885['result'][_0x5acd('0x27')]);}})[_0x5acd('0x29')](function(_0x4de296){logger['error']('ChatQueue,\x20%s,\x20%s',_0x3018ba,_0x4de296);_0x364e2d(_0x4de296);});});}function respondWithStatusCode(_0x3ba2ea,_0x175c3c){_0x175c3c=_0x175c3c||0xcc;return function(_0x294d13){if(_0x294d13){return _0x3ba2ea[_0x5acd('0x2a')](_0x175c3c);}return _0x3ba2ea[_0x5acd('0x2b')](_0x175c3c)[_0x5acd('0x2c')]();};}function respondWithResult(_0x10f6f7,_0x1b85c9){_0x1b85c9=_0x1b85c9||0xc8;return function(_0x155625){if(_0x155625){return _0x10f6f7[_0x5acd('0x2b')](_0x1b85c9)[_0x5acd('0x2d')](_0x155625);}};}function respondWithFilteredResult(_0xe0eae4,_0x13fa6b){return function(_0x3ee85c){if(_0x3ee85c){var _0x38bf8b=_0x3ee85c['count'],_0x16b2c1=_0x13fa6b[_0x5acd('0x2e')],_0x11a458=_0x13fa6b[_0x5acd('0x2e')]+_0x13fa6b[_0x5acd('0x2f')],_0x389dcb;if(_0x11a458>=_0x38bf8b){_0x11a458=_0x38bf8b;_0x389dcb=0xc8;}else{_0x389dcb=0xce;}_0xe0eae4['status'](_0x389dcb);return _0xe0eae4[_0x5acd('0x30')](_0x5acd('0x31'),_0x16b2c1+'-'+_0x11a458+'/'+_0x38bf8b)['json'](_0x3ee85c);}return null;};}function patchUpdates(_0x2f10f9){return function(_0x1eccda){try{jsonpatch[_0x5acd('0x32')](_0x1eccda,_0x2f10f9,!![]);}catch(_0x38bdd5){return BPromise[_0x5acd('0x33')](_0x38bdd5);}return _0x1eccda['save']();};}function saveUpdates(_0x22facb,_0x24829f){return function(_0x9141f4){if(_0x9141f4){return _0x9141f4[_0x5acd('0x34')](_0x22facb)[_0x5acd('0x20')](function(_0x4b7d61){return _0x4b7d61;});}return null;};}function removeEntity(_0x11f5b0,_0x105d85){return function(_0x5825eb){if(_0x5825eb){return _0x5825eb['destroy']()[_0x5acd('0x20')](function(){var _0x3f542f=_0x5825eb[_0x5acd('0x35')]({'plain':!![]});var _0xb68d72='ChatQueues';return db['UserProfileResource'][_0x5acd('0x36')]({'where':{'type':_0xb68d72,'resourceId':_0x3f542f['id']}})[_0x5acd('0x20')](function(){return _0x5825eb;});})[_0x5acd('0x20')](function(){_0x11f5b0[_0x5acd('0x2b')](0xcc)[_0x5acd('0x2c')]();});}};}function handleEntityNotFound(_0x4210fb,_0x3b040a){return function(_0x2d6efb){if(!_0x2d6efb){_0x4210fb[_0x5acd('0x2a')](0x194);}return _0x2d6efb;};}function handleError(_0x1bc96a,_0xe647bc){_0xe647bc=_0xe647bc||0x1f4;return function(_0xb4a6c1){logger['error'](_0xb4a6c1[_0x5acd('0x37')]);if(_0xb4a6c1[_0x5acd('0x38')]){delete _0xb4a6c1['name'];}_0x1bc96a['status'](_0xe647bc)[_0x5acd('0x39')](_0xb4a6c1);};}exports['index']=function(_0x3ee921,_0x57d39d){var _0x5ae8d5={},_0x1bb138={},_0x52b445={'count':0x0,'rows':[]};var _0x4d7db5=_[_0x5acd('0x3a')](db[_0x5acd('0x3b')]['rawAttributes'],function(_0x5b015c){return{'name':_0x5b015c[_0x5acd('0x3c')],'type':_0x5b015c['type'][_0x5acd('0x3d')]};});_0x1bb138[_0x5acd('0x3e')]=_[_0x5acd('0x3a')](_0x4d7db5,_0x5acd('0x38'));_0x1bb138[_0x5acd('0x3f')]=_[_0x5acd('0x40')](_0x3ee921['query']);_0x1bb138[_0x5acd('0x41')]=_['intersection'](_0x1bb138[_0x5acd('0x3e')],_0x1bb138[_0x5acd('0x3f')]);_0x5ae8d5[_0x5acd('0x42')]=_[_0x5acd('0x43')](_0x1bb138['model'],qs['fields'](_0x3ee921[_0x5acd('0x3f')][_0x5acd('0x44')]));_0x5ae8d5['attributes']=_0x5ae8d5[_0x5acd('0x42')]['length']?_0x5ae8d5[_0x5acd('0x42')]:_0x1bb138[_0x5acd('0x3e')];if(!_0x3ee921['query'][_0x5acd('0x45')](_0x5acd('0x46'))){_0x5ae8d5[_0x5acd('0x2f')]=qs['limit'](_0x3ee921['query']['limit']);_0x5ae8d5[_0x5acd('0x2e')]=qs[_0x5acd('0x2e')](_0x3ee921[_0x5acd('0x3f')][_0x5acd('0x2e')]);}_0x5ae8d5[_0x5acd('0x47')]=qs['sort'](_0x3ee921[_0x5acd('0x3f')][_0x5acd('0x48')]);_0x5ae8d5[_0x5acd('0x49')]=qs[_0x5acd('0x41')](_['pick'](_0x3ee921[_0x5acd('0x3f')],_0x1bb138[_0x5acd('0x41')]),_0x4d7db5);if(_0x3ee921[_0x5acd('0x3f')][_0x5acd('0x4a')]){_0x5ae8d5[_0x5acd('0x49')]=_[_0x5acd('0x4b')](_0x5ae8d5[_0x5acd('0x49')],{'$or':_['map'](_0x4d7db5,function(_0x30f27b){if(_0x30f27b[_0x5acd('0x4c')]!=='VIRTUAL'){var _0x368b34={};_0x368b34[_0x30f27b[_0x5acd('0x38')]]={'$like':'%'+_0x3ee921[_0x5acd('0x3f')]['filter']+'%'};return _0x368b34;}})});}_0x5ae8d5=_[_0x5acd('0x4b')]({},_0x5ae8d5,_0x3ee921[_0x5acd('0x4d')]);var _0x29a179={'where':_0x5ae8d5[_0x5acd('0x49')]};return db[_0x5acd('0x3b')][_0x5acd('0x4e')](_0x29a179)['then'](function(_0x24611f){_0x52b445['count']=_0x24611f;if(_0x3ee921[_0x5acd('0x3f')]['includeAll']){_0x5ae8d5['include']=[{'all':!![]}];}return db['ChatQueue'][_0x5acd('0x4f')](_0x5ae8d5);})[_0x5acd('0x20')](function(_0x145c0d){_0x52b445[_0x5acd('0x50')]=_0x145c0d;return _0x52b445;})[_0x5acd('0x20')](respondWithFilteredResult(_0x57d39d,_0x5ae8d5))['catch'](handleError(_0x57d39d,null));};exports[_0x5acd('0x51')]=function(_0x38781b,_0x1a58b0){var _0xb49262={'raw':!![],'where':{'id':_0x38781b[_0x5acd('0x52')]['id']}},_0x39f08a={};_0x39f08a[_0x5acd('0x3e')]=_[_0x5acd('0x40')](db['ChatQueue'][_0x5acd('0x53')]);_0x39f08a[_0x5acd('0x3f')]=_[_0x5acd('0x40')](_0x38781b[_0x5acd('0x3f')]);_0x39f08a[_0x5acd('0x41')]=_[_0x5acd('0x43')](_0x39f08a[_0x5acd('0x3e')],_0x39f08a['query']);_0xb49262[_0x5acd('0x42')]=_[_0x5acd('0x43')](_0x39f08a[_0x5acd('0x3e')],qs[_0x5acd('0x44')](_0x38781b[_0x5acd('0x3f')][_0x5acd('0x44')]));_0xb49262['attributes']=_0xb49262[_0x5acd('0x42')][_0x5acd('0x54')]?_0xb49262[_0x5acd('0x42')]:_0x39f08a[_0x5acd('0x3e')];if(_0x38781b[_0x5acd('0x3f')]['includeAll']){_0xb49262[_0x5acd('0x55')]=[{'all':!![]}];}_0xb49262=_[_0x5acd('0x4b')]({},_0xb49262,_0x38781b[_0x5acd('0x4d')]);return db[_0x5acd('0x3b')][_0x5acd('0x56')](_0xb49262)[_0x5acd('0x20')](handleEntityNotFound(_0x1a58b0,null))['then'](respondWithResult(_0x1a58b0,null))[_0x5acd('0x29')](handleError(_0x1a58b0,null));};exports[_0x5acd('0x57')]=function(_0x3ae5de,_0x28fa5e){return db[_0x5acd('0x3b')][_0x5acd('0x57')](_0x3ae5de[_0x5acd('0x58')],{})[_0x5acd('0x20')](function(_0x599859){var _0x306fe6=_0x3ae5de['user'][_0x5acd('0x35')]({'plain':!![]});if(!_0x306fe6)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x306fe6[_0x5acd('0x59')]===_0x5acd('0x5a')){var _0x322fb8=_0x599859[_0x5acd('0x35')]({'plain':!![]});var _0x2f0f3f=_0x5acd('0x5b');return db[_0x5acd('0x5c')]['find']({'where':{'name':_0x2f0f3f,'userProfileId':_0x306fe6[_0x5acd('0x5d')]},'raw':!![]})['then'](function(_0x4261d8){if(_0x4261d8&&_0x4261d8[_0x5acd('0x5e')]===0x0){return db['UserProfileResource']['create']({'name':_0x322fb8[_0x5acd('0x38')],'resourceId':_0x322fb8['id'],'type':_0x4261d8[_0x5acd('0x38')],'sectionId':_0x4261d8['id']},{})[_0x5acd('0x20')](function(){return _0x599859;});}else{return _0x599859;}})[_0x5acd('0x29')](function(_0x1e5d46){logger[_0x5acd('0x25')](_0x5acd('0x5f'),_0x1e5d46);throw _0x1e5d46;});}return _0x599859;})['then'](respondWithResult(_0x28fa5e,0xc9))['catch'](handleError(_0x28fa5e,null));};exports[_0x5acd('0x34')]=function(_0x408e2a,_0x1437e1){if(_0x408e2a['body']['id']){delete _0x408e2a[_0x5acd('0x58')]['id'];}return db[_0x5acd('0x3b')]['find']({'where':{'id':_0x408e2a[_0x5acd('0x52')]['id']}})['then'](handleEntityNotFound(_0x1437e1,null))[_0x5acd('0x20')](saveUpdates(_0x408e2a['body'],null))[_0x5acd('0x20')](respondWithResult(_0x1437e1,null))[_0x5acd('0x29')](handleError(_0x1437e1,null));};exports[_0x5acd('0x36')]=function(_0x36cee1,_0x5c004c){return db[_0x5acd('0x3b')]['find']({'where':{'id':_0x36cee1[_0x5acd('0x52')]['id']}})['then'](handleEntityNotFound(_0x5c004c,null))[_0x5acd('0x20')](removeEntity(_0x5c004c,null))[_0x5acd('0x29')](handleError(_0x5c004c,null));};exports[_0x5acd('0x60')]=function(_0x4d4c7c,_0x905873){return db[_0x5acd('0x3b')]['describe']()[_0x5acd('0x20')](respondWithResult(_0x905873,null))['catch'](handleError(_0x905873,null));};exports[_0x5acd('0x61')]=function(_0x53f964,_0x14eab7,_0xff8039){var _0x27b532={'raw':!![],'where':{}},_0xaa8edb={},_0x28d032;return db['ChatQueue']['findOne']({'where':{'id':_0x53f964[_0x5acd('0x52')]['id']}})['then'](handleEntityNotFound(_0x14eab7,null))['then'](function(_0x49a43e){if(_0x49a43e){_0x28d032=_0x49a43e[_0x5acd('0x35')]({'plain':!![]});_0xaa8edb['model']=_[_0x5acd('0x40')](db['UserChatQueue'][_0x5acd('0x53')]);_0xaa8edb['query']=_[_0x5acd('0x40')](_0x53f964[_0x5acd('0x3f')]);_0xaa8edb['filters']=_[_0x5acd('0x43')](_0xaa8edb['model'],_0xaa8edb[_0x5acd('0x3f')]);_0x27b532[_0x5acd('0x42')]=_[_0x5acd('0x43')](_0xaa8edb[_0x5acd('0x3e')],qs[_0x5acd('0x44')](_0x53f964[_0x5acd('0x3f')]['fields']));_0x27b532[_0x5acd('0x42')]=_0x27b532['attributes'][_0x5acd('0x54')]?_0x27b532[_0x5acd('0x42')]:_0xaa8edb[_0x5acd('0x3e')];if(!_0x53f964[_0x5acd('0x3f')][_0x5acd('0x45')](_0x5acd('0x46'))){_0x27b532[_0x5acd('0x2f')]=qs['limit'](_0x53f964[_0x5acd('0x3f')]['limit']);_0x27b532[_0x5acd('0x2e')]=qs[_0x5acd('0x2e')](_0x53f964[_0x5acd('0x3f')]['offset']);}_0x27b532[_0x5acd('0x47')]=qs[_0x5acd('0x48')](_0x53f964[_0x5acd('0x3f')][_0x5acd('0x48')]);_0x27b532['where']=qs[_0x5acd('0x41')](_[_0x5acd('0x62')](_0x53f964[_0x5acd('0x3f')],_0xaa8edb[_0x5acd('0x41')]));_0x27b532[_0x5acd('0x49')]['ChatQueueId']=_0x49a43e['id'];if(_0x53f964['query'][_0x5acd('0x4a')]){_0x27b532[_0x5acd('0x49')]=_['merge'](_0x27b532[_0x5acd('0x49')],{'$or':_[_0x5acd('0x3a')](_0x27b532['attributes'],function(_0x2523cd){var _0x34d425={};_0x34d425[_0x2523cd]={'$like':'%'+_0x53f964['query'][_0x5acd('0x4a')]+'%'};return _0x34d425;})});}_0x27b532=_[_0x5acd('0x4b')]({},_0x27b532,_0x53f964[_0x5acd('0x4d')]);return db[_0x5acd('0x63')][_0x5acd('0x4f')](_0x27b532);}})[_0x5acd('0x20')](function(_0x253131){if(_0x253131){return db[_0x5acd('0x64')][_0x5acd('0x65')]({'where':{'id':_[_0x5acd('0x3a')](_0x253131,_0x5acd('0x66')),'role':_0x5acd('0x67')},'attributes':['id','name','chatPause',_0x5acd('0x68'),_0x5acd('0x69')]});}})[_0x5acd('0x20')](function(_0x35728d){if(_0x35728d){return{'count':_0x35728d[_0x5acd('0x4e')],'rows':_[_0x5acd('0x3a')](_0x35728d[_0x5acd('0x50')],function(_0x2a667c){return{'membername':_0x2a667c[_0x5acd('0x38')],'UserId':_0x2a667c['id'],'queue_name':_0x28d032[_0x5acd('0x38')],'ChatQueueId':_0x28d032['id'],'interface':util[_0x5acd('0x6a')](_0x5acd('0x6b'),'SIP',_0x2a667c[_0x5acd('0x38')]),'penalty':0x0,'paused':_0x2a667c[_0x5acd('0x6c')],'createdAt':_0x2a667c[_0x5acd('0x69')],'updatedAt':_0x2a667c[_0x5acd('0x68')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x14eab7,_0x27b532))[_0x5acd('0x29')](handleError(_0x14eab7,null));};exports['getTeams']=function(_0x3dcc40,_0x2f2a3e,_0x51d030){var _0x415274={};var _0x3bea72={};var _0x65c19c;var _0x585de7;return db['ChatQueue']['findOne']({'where':{'id':_0x3dcc40[_0x5acd('0x52')]['id']}})['then'](handleEntityNotFound(_0x2f2a3e,null))['then'](function(_0x943fbf){if(_0x943fbf){_0x65c19c=_0x943fbf;_0x3bea72['model']=_[_0x5acd('0x40')](db['Team'][_0x5acd('0x53')]);_0x3bea72['query']=_[_0x5acd('0x40')](_0x3dcc40[_0x5acd('0x3f')]);_0x3bea72[_0x5acd('0x41')]=_[_0x5acd('0x43')](_0x3bea72[_0x5acd('0x3e')],_0x3bea72[_0x5acd('0x3f')]);_0x415274[_0x5acd('0x42')]=_['intersection'](_0x3bea72['model'],qs[_0x5acd('0x44')](_0x3dcc40['query'][_0x5acd('0x44')]));_0x415274[_0x5acd('0x42')]=_0x415274[_0x5acd('0x42')][_0x5acd('0x54')]?_0x415274[_0x5acd('0x42')]:_0x3bea72[_0x5acd('0x3e')];_0x415274['order']=qs[_0x5acd('0x48')](_0x3dcc40[_0x5acd('0x3f')]['sort']);_0x415274['where']=qs[_0x5acd('0x41')](_['pick'](_0x3dcc40[_0x5acd('0x3f')],_0x3bea72['filters']));if(_0x3dcc40[_0x5acd('0x3f')][_0x5acd('0x4a')]){_0x415274[_0x5acd('0x49')]=_['merge'](_0x415274[_0x5acd('0x49')],{'$or':_['map'](_0x415274['attributes'],function(_0xda24a3){var _0x4c0c4d={};_0x4c0c4d[_0xda24a3]={'$like':'%'+_0x3dcc40[_0x5acd('0x3f')][_0x5acd('0x4a')]+'%'};return _0x4c0c4d;})});}_0x415274=_['merge']({},_0x415274,_0x3dcc40[_0x5acd('0x4d')]);return _0x65c19c['getTeams'](_0x415274);}})[_0x5acd('0x20')](function(_0x850061){if(_0x850061){_0x585de7=_0x850061['length'];if(!_0x3dcc40[_0x5acd('0x3f')][_0x5acd('0x45')](_0x5acd('0x46'))){_0x415274[_0x5acd('0x2f')]=qs[_0x5acd('0x2f')](_0x3dcc40[_0x5acd('0x3f')][_0x5acd('0x2f')]);_0x415274['offset']=qs[_0x5acd('0x2e')](_0x3dcc40['query'][_0x5acd('0x2e')]);}return _0x65c19c['getTeams'](_0x415274);}})[_0x5acd('0x20')](function(_0xad905b){if(_0xad905b){return _0xad905b?{'count':_0x585de7,'rows':_0xad905b}:null;}})['then'](respondWithResult(_0x2f2a3e,null))['catch'](handleError(_0x2f2a3e,null));};exports['addTeams']=function(_0x3a52cd,_0x22dfe4,_0x1243fa){var _0x2c17d3=_0x3a52cd['body']['ids'];return db['Team'][_0x5acd('0x4f')]({'where':{'id':_0x2c17d3},'attributes':['id'],'include':[{'model':db['User'],'as':_0x5acd('0x6d'),'attributes':['id','name',_0x5acd('0x6e'),_0x5acd('0x6f'),_0x5acd('0x70')],'raw':!![]}]})['then'](function(_0x2f5335){if(_0x2f5335){var _0x4c1d7d=_['flatMap'](_0x2f5335,function(_0x6d24df){var _0x33c27b=_0x6d24df['get']({'plain':!![]});return _0x33c27b[_0x5acd('0x6d')];});return db['ChatQueue']['find']({'where':{'id':_0x3a52cd[_0x5acd('0x52')]['id']}})[_0x5acd('0x20')](function(_0x3845bf){return db[_0x5acd('0x71')][_0x5acd('0x72')](function(_0x561c8d){return _0x3845bf[_0x5acd('0x73')](_0x2c17d3,{'transaction':_0x561c8d})['then'](function(){return BPromise[_0x5acd('0x74')](_0x4c1d7d,function(_0xec1b1e){return db[_0x5acd('0x63')][_0x5acd('0x75')]({'where':{'UserId':_0xec1b1e['id'],'ChatQueueId':_0x3a52cd['params']['id']},'transaction':_0x561c8d});});})[_0x5acd('0x20')](function(){_0x4c1d7d[_0x5acd('0x76')](function(_0x85af4e){socket[_0x5acd('0x77')](_0x5acd('0x78'),{'UserId':_0x85af4e['id'],'ChatQueueId':_0x3845bf['id']});});});});});}})[_0x5acd('0x20')](respondWithStatusCode(_0x22dfe4,null))[_0x5acd('0x29')](handleError(_0x22dfe4,null));};exports['removeTeams']=function(_0x3687a5,_0x171ff9,_0x1ea327){return db[_0x5acd('0x79')][_0x5acd('0x4f')]({'where':{'id':_0x3687a5[_0x5acd('0x3f')][_0x5acd('0x7a')]},'attributes':['id'],'include':[{'model':db[_0x5acd('0x64')],'as':_0x5acd('0x6d'),'attributes':['id'],'raw':!![]}]})[_0x5acd('0x20')](handleEntityNotFound(_0x171ff9,null))['then'](function(_0x29bca8){var _0x34fa49=_[_0x5acd('0x3a')](_0x29bca8,'id');var _0x3f4b4a=[];var _0x31ab0e=[];var _0x54b0d0=squel[_0x5acd('0x7b')]();_0x54b0d0[_0x5acd('0x7c')](_0x5acd('0x7d'))[_0x5acd('0x7e')](_0x5acd('0x7f'),'tq')[_0x5acd('0x80')](_0x5acd('0x81'),'ut',_0x5acd('0x82'))['where'](_0x5acd('0x83'),_0x3687a5['params']['id']);for(var _0x312e4f=0x0;_0x312e4f<_0x29bca8['length'];_0x312e4f+=0x1){let _0x5524b9=_0x29bca8[_0x312e4f];for(var _0x32183c=0x0;_0x32183c<_0x5524b9[_0x5acd('0x6d')][_0x5acd('0x54')];_0x32183c+=0x1){let _0x86e94b=_0x5524b9['Agents'][_0x32183c];var _0x2fb085=_0x54b0d0[_0x5acd('0x84')]();_0x2fb085[_0x5acd('0x49')]('ut.UserId\x20=\x20?',_0x86e94b['id']);_0x31ab0e[_0x5acd('0x85')](db[_0x5acd('0x71')]['query'](_0x2fb085[_0x5acd('0x86')](),{'type':db[_0x5acd('0x71')]['QueryTypes']['SELECT']})['then'](function(_0x37c639){if(_0x37c639[_0x5acd('0x54')]===0x1){return _0x86e94b['id'];}else{var _0x2364ca=_[_0x5acd('0x87')](_[_0x5acd('0x3a')](_0x37c639,'TeamId'),function(_0x24d596){return _[_0x5acd('0x88')](_0x34fa49,_0x24d596);});if(_0x2364ca){return _0x86e94b['id'];}}}));}}return BPromise[_0x5acd('0x89')](_0x31ab0e)[_0x5acd('0x20')](function(_0x46ee22){_0x3f4b4a=_(_0x3f4b4a)[_0x5acd('0x8a')](_0x46ee22)[_0x5acd('0x8b')]()[_0x5acd('0x8c')]();return db[_0x5acd('0x3b')][_0x5acd('0x56')]({'where':{'id':_0x3687a5[_0x5acd('0x52')]['id']}})[_0x5acd('0x20')](function(_0x2b7540){return db['sequelize'][_0x5acd('0x72')](function(_0x31929a){return _0x2b7540['removeTeams'](_0x3687a5['query']['ids'],{'transaction':_0x31929a})['then'](function(){if(!_['isEmpty'](_0x3f4b4a)){return _0x2b7540[_0x5acd('0x8d')](_0x3f4b4a,{'transaction':_0x31929a});}})[_0x5acd('0x20')](function(){_0x3f4b4a['forEach'](function(_0xf33b19){socket[_0x5acd('0x77')](_0x5acd('0x8e'),{'UserId':_0xf33b19,'ChatQueueId':_0x2b7540['id']});});});});});});})[_0x5acd('0x20')](respondWithStatusCode(_0x171ff9,null))[_0x5acd('0x29')](handleError(_0x171ff9,null));};exports[_0x5acd('0x8f')]=function(_0x2c4690,_0x51cc27,_0x2f2dc5){return db[_0x5acd('0x3b')][_0x5acd('0x56')]({'where':{'id':_0x2c4690['params']['id']}})['then'](handleEntityNotFound(_0x51cc27,null))[_0x5acd('0x20')](function(_0x72607c){if(_0x72607c){return _0x72607c[_0x5acd('0x8f')](_0x2c4690[_0x5acd('0x58')][_0x5acd('0x7a')],_['omit'](_0x2c4690[_0x5acd('0x58')],[_0x5acd('0x7a'),'id'])||{})[_0x5acd('0x90')](function(_0x5c5bde){for(var _0x2ef8e6=0x0;_0x2ef8e6<_0x2c4690[_0x5acd('0x58')][_0x5acd('0x7a')][_0x5acd('0x54')];_0x2ef8e6+=0x1){socket[_0x5acd('0x77')](_0x5acd('0x78'),{'UserId':_0x2c4690['body'][_0x5acd('0x7a')][_0x2ef8e6],'ChatQueueId':_0x2c4690[_0x5acd('0x52')]['id']});}return _0x5c5bde;});}})[_0x5acd('0x20')](respondWithResult(_0x51cc27,null))[_0x5acd('0x29')](handleError(_0x51cc27,null));};exports[_0x5acd('0x8d')]=function(_0x242f83,_0x2168ee,_0x1bd82d){return db[_0x5acd('0x3b')]['find']({'where':{'id':_0x242f83[_0x5acd('0x52')]['id']}})[_0x5acd('0x20')](handleEntityNotFound(_0x2168ee,null))[_0x5acd('0x20')](function(_0x3054d9){if(_0x3054d9){return _0x3054d9[_0x5acd('0x8d')](_0x242f83['query'][_0x5acd('0x7a')])[_0x5acd('0x20')](function(){if(_[_0x5acd('0x91')](_0x242f83[_0x5acd('0x3f')][_0x5acd('0x7a')])){for(var _0x108a41=0x0;_0x108a41<_0x242f83[_0x5acd('0x3f')]['ids'][_0x5acd('0x54')];_0x108a41+=0x1){socket[_0x5acd('0x77')]('userChatQueue:remove',{'UserId':Number(_0x242f83['query'][_0x5acd('0x7a')][_0x108a41]),'ChatQueueId':Number(_0x242f83[_0x5acd('0x52')]['id'])});}}else{socket[_0x5acd('0x77')]('userChatQueue:remove',{'UserId':Number(_0x242f83['query'][_0x5acd('0x7a')]),'ChatQueueId':Number(_0x242f83['params']['id'])});}});}})[_0x5acd('0x20')](respondWithStatusCode(_0x2168ee,null))[_0x5acd('0x29')](handleError(_0x2168ee,null));};exports['getAgents']=function(_0x2ce8fb,_0x2900c9,_0x46ee8b){var _0x32a84c={};var _0xe34c70={};var _0x469294;var _0x58b690;return db[_0x5acd('0x3b')]['findOne']({'where':{'id':_0x2ce8fb[_0x5acd('0x52')]['id']}})[_0x5acd('0x20')](handleEntityNotFound(_0x2900c9,null))['then'](function(_0x5cfbf7){if(_0x5cfbf7){_0x469294=_0x5cfbf7;_0xe34c70['model']=_[_0x5acd('0x40')](db[_0x5acd('0x64')][_0x5acd('0x53')]);_0xe34c70[_0x5acd('0x3f')]=_[_0x5acd('0x40')](_0x2ce8fb['query']);_0xe34c70['filters']=_[_0x5acd('0x43')](_0xe34c70[_0x5acd('0x3e')],_0xe34c70[_0x5acd('0x3f')]);_0x32a84c[_0x5acd('0x42')]=_[_0x5acd('0x43')](_0xe34c70[_0x5acd('0x3e')],qs[_0x5acd('0x44')](_0x2ce8fb['query'][_0x5acd('0x44')]));_0x32a84c[_0x5acd('0x42')]=_0x32a84c['attributes'][_0x5acd('0x54')]?_0x32a84c[_0x5acd('0x42')]:_0xe34c70['model'];_0x32a84c[_0x5acd('0x47')]=qs[_0x5acd('0x48')](_0x2ce8fb['query']['sort']);_0x32a84c['where']=qs[_0x5acd('0x41')](_[_0x5acd('0x62')](_0x2ce8fb[_0x5acd('0x3f')],_0xe34c70[_0x5acd('0x41')]));if(_0x2ce8fb[_0x5acd('0x3f')][_0x5acd('0x4a')]){_0x32a84c[_0x5acd('0x49')]=_[_0x5acd('0x4b')](_0x32a84c[_0x5acd('0x49')],{'$or':_['map'](_0x32a84c[_0x5acd('0x42')],function(_0x1c8959){var _0x46ab74={};_0x46ab74[_0x1c8959]={'$like':'%'+_0x2ce8fb['query'][_0x5acd('0x4a')]+'%'};return _0x46ab74;})});}_0x32a84c=_[_0x5acd('0x4b')]({},_0x32a84c,_0x2ce8fb['options']);return _0x469294['getAgents'](_0x32a84c);}})['then'](function(_0x4f36fa){if(_0x4f36fa){_0x58b690=_0x4f36fa[_0x5acd('0x54')];if(!_0x2ce8fb[_0x5acd('0x3f')]['hasOwnProperty'](_0x5acd('0x46'))){_0x32a84c[_0x5acd('0x2f')]=qs['limit'](_0x2ce8fb['query'][_0x5acd('0x2f')]);_0x32a84c[_0x5acd('0x2e')]=qs[_0x5acd('0x2e')](_0x2ce8fb['query']['offset']);}return _0x469294[_0x5acd('0x92')](_0x32a84c);}})['then'](function(_0x4bba93){if(_0x4bba93){return _0x4bba93?{'count':_0x58b690,'rows':_0x4bba93}:null;}})[_0x5acd('0x20')](respondWithResult(_0x2900c9,null))[_0x5acd('0x29')](handleError(_0x2900c9,null));};
\ No newline at end of file
+var _0x318f=['model','map','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filter','options','include','findAll','params','includeAll','find','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','ChatQueues','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserChatQueue','rawAttributes','nolimit','ChatQueueId','merge','User','findAndCountAll','UserId','chatPause','updatedAt','rows','format','%s/%s','SIP','createdAt','getTeams','Team','addTeams','Agents','voicePause','flatMap','sequelize','transaction','emit','removeTeams','ids','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','removeAgents','forEach','userChatQueue:remove','addAgents','spread','userChatQueue:save','isArray','findOne','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatQueue.socket','jayson/promise','client','request','then','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','end','status','json','offset','limit','undefined','count','set','Content-Range','reject','update','destroy','UserProfileResource','name','send','ChatQueue','type','key'];(function(_0x31cb5f,_0x2df766){var _0x586042=function(_0x53c807){while(--_0x53c807){_0x31cb5f['push'](_0x31cb5f['shift']());}};_0x586042(++_0x2df766);}(_0x318f,0x191));var _0xf318=function(_0x48908f,_0x3d091d){_0x48908f=_0x48908f-0x0;var _0x4f90f7=_0x318f[_0x48908f];return _0x4f90f7;};'use strict';var emlformat=require(_0xf318('0x0'));var rimraf=require(_0xf318('0x1'));var zipdir=require(_0xf318('0x2'));var jsonpatch=require(_0xf318('0x3'));var rp=require('request-promise');var moment=require(_0xf318('0x4'));var BPromise=require(_0xf318('0x5'));var Mustache=require(_0xf318('0x6'));var util=require('util');var path=require(_0xf318('0x7'));var sox=require(_0xf318('0x8'));var csv=require(_0xf318('0x9'));var ejs=require(_0xf318('0xa'));var fs=require('fs');var fs_extra=require(_0xf318('0xb'));var _=require(_0xf318('0xc'));var squel=require(_0xf318('0xd'));var crypto=require(_0xf318('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xf318('0xf'));var toCsv=require(_0xf318('0x9'));var querystring=require('querystring');var Papa=require(_0xf318('0x10'));var Redis=require(_0xf318('0x11'));var authService=require(_0xf318('0x12'));var qs=require(_0xf318('0x13'));var as=require(_0xf318('0x14'));var hardwareService=require(_0xf318('0x15'));var logger=require(_0xf318('0x16'))(_0xf318('0x17'));var utils=require(_0xf318('0x18'));var config=require(_0xf318('0x19'));var licenseUtil=require(_0xf318('0x1a'));var db=require(_0xf318('0x1b'))['db'];config[_0xf318('0x1c')]=_[_0xf318('0x1d')](config[_0xf318('0x1c')],{'host':_0xf318('0x1e'),'port':0x18eb});var socket=require(_0xf318('0x1f'))(new Redis(config[_0xf318('0x1c')]));require(_0xf318('0x20'))['register'](socket);var jayson=require(_0xf318('0x21'));var client=jayson[_0xf318('0x22')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3f4554,_0x27182e,_0x43f2d2,_0x30757b){return new BPromise(function(_0x7590a4,_0x26e98f){var _0x9f53e5=_0x30757b||client;return _0x9f53e5[_0xf318('0x23')](_0x3f4554,_0x43f2d2)[_0xf318('0x24')](function(_0x141ec9){logger['info'](_0xf318('0x25'),_0x27182e,_0xf318('0x26'));logger[_0xf318('0x27')](_0xf318('0x28'),_0x27182e,_0xf318('0x26'),JSON[_0xf318('0x29')](_0x141ec9));if(_0x141ec9['error']){if(_0x141ec9[_0xf318('0x2a')][_0xf318('0x2b')]===0x1f4){logger['error']('ChatQueue,\x20%s,\x20%s',_0x27182e,_0x141ec9[_0xf318('0x2a')][_0xf318('0x2c')]);return _0x26e98f(_0x141ec9[_0xf318('0x2a')][_0xf318('0x2c')]);}logger[_0xf318('0x2a')](_0xf318('0x25'),_0x27182e,_0x141ec9['error'][_0xf318('0x2c')]);return _0x7590a4(_0x141ec9['error'][_0xf318('0x2c')]);}else{logger[_0xf318('0x2d')](_0xf318('0x25'),_0x27182e,_0xf318('0x26'));_0x7590a4(_0x141ec9[_0xf318('0x2e')][_0xf318('0x2c')]);}})[_0xf318('0x2f')](function(_0x2649d8){logger[_0xf318('0x2a')](_0xf318('0x25'),_0x27182e,_0x2649d8);_0x26e98f(_0x2649d8);});});}function respondWithStatusCode(_0x39dfb8,_0xdd99a3){_0xdd99a3=_0xdd99a3||0xcc;return function(_0x482bb9){if(_0x482bb9){return _0x39dfb8[_0xf318('0x30')](_0xdd99a3);}return _0x39dfb8['status'](_0xdd99a3)[_0xf318('0x31')]();};}function respondWithResult(_0x42aaee,_0x26cead){_0x26cead=_0x26cead||0xc8;return function(_0x5f3465){if(_0x5f3465){return _0x42aaee[_0xf318('0x32')](_0x26cead)[_0xf318('0x33')](_0x5f3465);}};}function respondWithFilteredResult(_0x513af2,_0x3c190b){return function(_0x297467){if(_0x297467){var _0x207c65=typeof _0x3c190b[_0xf318('0x34')]==='undefined'&&typeof _0x3c190b[_0xf318('0x35')]===_0xf318('0x36');var _0x578a2e=_0x297467[_0xf318('0x37')];var _0x889baa=_0x207c65?0x0:_0x3c190b[_0xf318('0x34')];var _0x28e912=_0x207c65?_0x297467[_0xf318('0x37')]:_0x3c190b['offset']+_0x3c190b['limit'];var _0x37cd88;if(_0x28e912>=_0x578a2e){_0x28e912=_0x578a2e;_0x37cd88=0xc8;}else{_0x37cd88=0xce;}_0x513af2[_0xf318('0x32')](_0x37cd88);return _0x513af2[_0xf318('0x38')](_0xf318('0x39'),_0x889baa+'-'+_0x28e912+'/'+_0x578a2e)['json'](_0x297467);}return null;};}function patchUpdates(_0x37d65a){return function(_0x16d063){try{jsonpatch['apply'](_0x16d063,_0x37d65a,!![]);}catch(_0x425a66){return BPromise[_0xf318('0x3a')](_0x425a66);}return _0x16d063['save']();};}function saveUpdates(_0x430b5e,_0x32f843){return function(_0x218771){if(_0x218771){return _0x218771[_0xf318('0x3b')](_0x430b5e)['then'](function(_0x415de8){return _0x415de8;});}return null;};}function removeEntity(_0x27c3e8,_0x2f2fc3){return function(_0x216f71){if(_0x216f71){return _0x216f71[_0xf318('0x3c')]()['then'](function(){var _0x3a2090=_0x216f71['get']({'plain':!![]});var _0xd0f654='ChatQueues';return db[_0xf318('0x3d')]['destroy']({'where':{'type':_0xd0f654,'resourceId':_0x3a2090['id']}})[_0xf318('0x24')](function(){return _0x216f71;});})[_0xf318('0x24')](function(){_0x27c3e8[_0xf318('0x32')](0xcc)[_0xf318('0x31')]();});}};}function handleEntityNotFound(_0x1cec26,_0x3b951c){return function(_0x5d9d35){if(!_0x5d9d35){_0x1cec26[_0xf318('0x30')](0x194);}return _0x5d9d35;};}function handleError(_0x21dec4,_0x56d9ce){_0x56d9ce=_0x56d9ce||0x1f4;return function(_0x26dd81){logger['error'](_0x26dd81['stack']);if(_0x26dd81[_0xf318('0x3e')]){delete _0x26dd81['name'];}_0x21dec4['status'](_0x56d9ce)[_0xf318('0x3f')](_0x26dd81);};}exports['index']=function(_0x316557,_0x27cdb6){var _0x394bef={},_0x5e93bc={},_0x41d3e9={'count':0x0,'rows':[]};var _0x21031d=_['map'](db[_0xf318('0x40')]['rawAttributes'],function(_0x43f2e0){return{'name':_0x43f2e0['fieldName'],'type':_0x43f2e0[_0xf318('0x41')][_0xf318('0x42')]};});_0x5e93bc[_0xf318('0x43')]=_[_0xf318('0x44')](_0x21031d,_0xf318('0x3e'));_0x5e93bc['query']=_[_0xf318('0x45')](_0x316557[_0xf318('0x46')]);_0x5e93bc[_0xf318('0x47')]=_[_0xf318('0x48')](_0x5e93bc['model'],_0x5e93bc[_0xf318('0x46')]);_0x394bef['attributes']=_[_0xf318('0x48')](_0x5e93bc[_0xf318('0x43')],qs[_0xf318('0x49')](_0x316557[_0xf318('0x46')][_0xf318('0x49')]));_0x394bef['attributes']=_0x394bef[_0xf318('0x4a')][_0xf318('0x4b')]?_0x394bef[_0xf318('0x4a')]:_0x5e93bc[_0xf318('0x43')];if(!_0x316557[_0xf318('0x46')][_0xf318('0x4c')]('nolimit')){_0x394bef[_0xf318('0x35')]=qs['limit'](_0x316557[_0xf318('0x46')][_0xf318('0x35')]);_0x394bef[_0xf318('0x34')]=qs[_0xf318('0x34')](_0x316557[_0xf318('0x46')][_0xf318('0x34')]);}_0x394bef[_0xf318('0x4d')]=qs[_0xf318('0x4e')](_0x316557[_0xf318('0x46')][_0xf318('0x4e')]);_0x394bef[_0xf318('0x4f')]=qs[_0xf318('0x47')](_[_0xf318('0x50')](_0x316557[_0xf318('0x46')],_0x5e93bc[_0xf318('0x47')]),_0x21031d);if(_0x316557[_0xf318('0x46')][_0xf318('0x51')]){_0x394bef[_0xf318('0x4f')]=_['merge'](_0x394bef[_0xf318('0x4f')],{'$or':_[_0xf318('0x44')](_0x21031d,function(_0x375afa){if(_0x375afa[_0xf318('0x41')]!=='VIRTUAL'){var _0x29028d={};_0x29028d[_0x375afa['name']]={'$like':'%'+_0x316557[_0xf318('0x46')][_0xf318('0x51')]+'%'};return _0x29028d;}})});}_0x394bef=_['merge']({},_0x394bef,_0x316557[_0xf318('0x52')]);var _0x1c0ebe={'where':_0x394bef[_0xf318('0x4f')]};return db[_0xf318('0x40')]['count'](_0x1c0ebe)[_0xf318('0x24')](function(_0x11311a){_0x41d3e9['count']=_0x11311a;if(_0x316557[_0xf318('0x46')]['includeAll']){_0x394bef[_0xf318('0x53')]=[{'all':!![]}];}return db[_0xf318('0x40')][_0xf318('0x54')](_0x394bef);})[_0xf318('0x24')](function(_0x34abc3){_0x41d3e9['rows']=_0x34abc3;return _0x41d3e9;})[_0xf318('0x24')](respondWithFilteredResult(_0x27cdb6,_0x394bef))[_0xf318('0x2f')](handleError(_0x27cdb6,null));};exports['show']=function(_0xdfa9f6,_0x30a31c){var _0x537d9e={'raw':!![],'where':{'id':_0xdfa9f6[_0xf318('0x55')]['id']}},_0x446aa9={};_0x446aa9[_0xf318('0x43')]=_[_0xf318('0x45')](db[_0xf318('0x40')]['rawAttributes']);_0x446aa9[_0xf318('0x46')]=_[_0xf318('0x45')](_0xdfa9f6['query']);_0x446aa9[_0xf318('0x47')]=_['intersection'](_0x446aa9[_0xf318('0x43')],_0x446aa9[_0xf318('0x46')]);_0x537d9e[_0xf318('0x4a')]=_['intersection'](_0x446aa9[_0xf318('0x43')],qs['fields'](_0xdfa9f6[_0xf318('0x46')][_0xf318('0x49')]));_0x537d9e[_0xf318('0x4a')]=_0x537d9e['attributes'][_0xf318('0x4b')]?_0x537d9e[_0xf318('0x4a')]:_0x446aa9[_0xf318('0x43')];if(_0xdfa9f6[_0xf318('0x46')][_0xf318('0x56')]){_0x537d9e[_0xf318('0x53')]=[{'all':!![]}];}_0x537d9e=_['merge']({},_0x537d9e,_0xdfa9f6['options']);return db[_0xf318('0x40')][_0xf318('0x57')](_0x537d9e)[_0xf318('0x24')](handleEntityNotFound(_0x30a31c,null))[_0xf318('0x24')](respondWithResult(_0x30a31c,null))[_0xf318('0x2f')](handleError(_0x30a31c,null));};exports[_0xf318('0x58')]=function(_0x5582f5,_0x4f7fc1){return db[_0xf318('0x40')]['create'](_0x5582f5[_0xf318('0x59')],{})['then'](function(_0x11fa45){var _0x238421=_0x5582f5['user'][_0xf318('0x5a')]({'plain':!![]});if(!_0x238421)throw new Error(_0xf318('0x5b'));if(_0x238421[_0xf318('0x5c')]==='user'){var _0x425a2f=_0x11fa45[_0xf318('0x5a')]({'plain':!![]});var _0x45ebd4=_0xf318('0x5d');return db[_0xf318('0x5e')][_0xf318('0x57')]({'where':{'name':_0x45ebd4,'userProfileId':_0x238421[_0xf318('0x5f')]},'raw':!![]})[_0xf318('0x24')](function(_0x156f6e){if(_0x156f6e&&_0x156f6e[_0xf318('0x60')]===0x0){return db[_0xf318('0x3d')][_0xf318('0x58')]({'name':_0x425a2f[_0xf318('0x3e')],'resourceId':_0x425a2f['id'],'type':_0x156f6e[_0xf318('0x3e')],'sectionId':_0x156f6e['id']},{})[_0xf318('0x24')](function(){return _0x11fa45;});}else{return _0x11fa45;}})['catch'](function(_0x2a5a07){logger['error'](_0xf318('0x61'),_0x2a5a07);throw _0x2a5a07;});}return _0x11fa45;})[_0xf318('0x24')](respondWithResult(_0x4f7fc1,0xc9))[_0xf318('0x2f')](handleError(_0x4f7fc1,null));};exports[_0xf318('0x3b')]=function(_0x4500ca,_0x1b8493){if(_0x4500ca[_0xf318('0x59')]['id']){delete _0x4500ca[_0xf318('0x59')]['id'];}return db[_0xf318('0x40')][_0xf318('0x57')]({'where':{'id':_0x4500ca[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x1b8493,null))[_0xf318('0x24')](saveUpdates(_0x4500ca[_0xf318('0x59')],null))[_0xf318('0x24')](respondWithResult(_0x1b8493,null))[_0xf318('0x2f')](handleError(_0x1b8493,null));};exports['destroy']=function(_0xe2ab02,_0x1d518a){return db[_0xf318('0x40')][_0xf318('0x57')]({'where':{'id':_0xe2ab02['params']['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x1d518a,null))[_0xf318('0x24')](removeEntity(_0x1d518a,null))['catch'](handleError(_0x1d518a,null));};exports[_0xf318('0x62')]=function(_0x180bca,_0x51b9ad){return db[_0xf318('0x40')][_0xf318('0x62')]()[_0xf318('0x24')](respondWithResult(_0x51b9ad,null))[_0xf318('0x2f')](handleError(_0x51b9ad,null));};exports[_0xf318('0x63')]=function(_0x11b75e,_0x2ba8a7,_0x173498){var _0x347925={'raw':!![],'where':{}},_0x4c62cc={},_0x4dcd37;return db[_0xf318('0x40')]['findOne']({'where':{'id':_0x11b75e[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x2ba8a7,null))['then'](function(_0xc7fc28){if(_0xc7fc28){_0x4dcd37=_0xc7fc28['get']({'plain':!![]});_0x4c62cc[_0xf318('0x43')]=_[_0xf318('0x45')](db[_0xf318('0x64')][_0xf318('0x65')]);_0x4c62cc[_0xf318('0x46')]=_[_0xf318('0x45')](_0x11b75e[_0xf318('0x46')]);_0x4c62cc[_0xf318('0x47')]=_['intersection'](_0x4c62cc[_0xf318('0x43')],_0x4c62cc['query']);_0x347925[_0xf318('0x4a')]=_[_0xf318('0x48')](_0x4c62cc[_0xf318('0x43')],qs[_0xf318('0x49')](_0x11b75e[_0xf318('0x46')][_0xf318('0x49')]));_0x347925[_0xf318('0x4a')]=_0x347925[_0xf318('0x4a')][_0xf318('0x4b')]?_0x347925[_0xf318('0x4a')]:_0x4c62cc[_0xf318('0x43')];if(!_0x11b75e[_0xf318('0x46')]['hasOwnProperty'](_0xf318('0x66'))){_0x347925[_0xf318('0x35')]=qs['limit'](_0x11b75e[_0xf318('0x46')][_0xf318('0x35')]);_0x347925[_0xf318('0x34')]=qs[_0xf318('0x34')](_0x11b75e[_0xf318('0x46')]['offset']);}_0x347925[_0xf318('0x4d')]=qs[_0xf318('0x4e')](_0x11b75e[_0xf318('0x46')][_0xf318('0x4e')]);_0x347925[_0xf318('0x4f')]=qs['filters'](_[_0xf318('0x50')](_0x11b75e[_0xf318('0x46')],_0x4c62cc[_0xf318('0x47')]));_0x347925['where'][_0xf318('0x67')]=_0xc7fc28['id'];if(_0x11b75e[_0xf318('0x46')]['filter']){_0x347925[_0xf318('0x4f')]=_[_0xf318('0x68')](_0x347925[_0xf318('0x4f')],{'$or':_[_0xf318('0x44')](_0x347925[_0xf318('0x4a')],function(_0x25aa9d){var _0x38be15={};_0x38be15[_0x25aa9d]={'$like':'%'+_0x11b75e[_0xf318('0x46')][_0xf318('0x51')]+'%'};return _0x38be15;})});}_0x347925=_[_0xf318('0x68')]({},_0x347925,_0x11b75e[_0xf318('0x52')]);return db[_0xf318('0x64')][_0xf318('0x54')](_0x347925);}})[_0xf318('0x24')](function(_0x22723b){if(_0x22723b){return db[_0xf318('0x69')][_0xf318('0x6a')]({'where':{'id':_[_0xf318('0x44')](_0x22723b,_0xf318('0x6b')),'role':'agent'},'attributes':['id',_0xf318('0x3e'),_0xf318('0x6c'),_0xf318('0x6d'),'createdAt']});}})['then'](function(_0x1ce4cc){if(_0x1ce4cc){return{'count':_0x1ce4cc[_0xf318('0x37')],'rows':_[_0xf318('0x44')](_0x1ce4cc[_0xf318('0x6e')],function(_0xb62589){return{'membername':_0xb62589[_0xf318('0x3e')],'UserId':_0xb62589['id'],'queue_name':_0x4dcd37[_0xf318('0x3e')],'ChatQueueId':_0x4dcd37['id'],'interface':util[_0xf318('0x6f')](_0xf318('0x70'),_0xf318('0x71'),_0xb62589['name']),'penalty':0x0,'paused':_0xb62589[_0xf318('0x6c')],'createdAt':_0xb62589[_0xf318('0x72')],'updatedAt':_0xb62589['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xf318('0x24')](respondWithFilteredResult(_0x2ba8a7,_0x347925))[_0xf318('0x2f')](handleError(_0x2ba8a7,null));};exports[_0xf318('0x73')]=function(_0x1c161f,_0x2852f7,_0x28ad8c){var _0x21e12e={};var _0x429210={};var _0x57fef5;var _0xd905cb;return db[_0xf318('0x40')]['findOne']({'where':{'id':_0x1c161f[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x2852f7,null))['then'](function(_0x561793){if(_0x561793){_0x57fef5=_0x561793;_0x429210[_0xf318('0x43')]=_[_0xf318('0x45')](db[_0xf318('0x74')][_0xf318('0x65')]);_0x429210['query']=_[_0xf318('0x45')](_0x1c161f[_0xf318('0x46')]);_0x429210[_0xf318('0x47')]=_['intersection'](_0x429210[_0xf318('0x43')],_0x429210[_0xf318('0x46')]);_0x21e12e[_0xf318('0x4a')]=_[_0xf318('0x48')](_0x429210[_0xf318('0x43')],qs['fields'](_0x1c161f[_0xf318('0x46')][_0xf318('0x49')]));_0x21e12e['attributes']=_0x21e12e[_0xf318('0x4a')][_0xf318('0x4b')]?_0x21e12e[_0xf318('0x4a')]:_0x429210[_0xf318('0x43')];_0x21e12e[_0xf318('0x4d')]=qs['sort'](_0x1c161f[_0xf318('0x46')][_0xf318('0x4e')]);_0x21e12e[_0xf318('0x4f')]=qs['filters'](_[_0xf318('0x50')](_0x1c161f[_0xf318('0x46')],_0x429210[_0xf318('0x47')]));if(_0x1c161f[_0xf318('0x46')]['filter']){_0x21e12e['where']=_[_0xf318('0x68')](_0x21e12e[_0xf318('0x4f')],{'$or':_[_0xf318('0x44')](_0x21e12e[_0xf318('0x4a')],function(_0x4e1d1b){var _0x269daa={};_0x269daa[_0x4e1d1b]={'$like':'%'+_0x1c161f['query'][_0xf318('0x51')]+'%'};return _0x269daa;})});}_0x21e12e=_[_0xf318('0x68')]({},_0x21e12e,_0x1c161f[_0xf318('0x52')]);return _0x57fef5[_0xf318('0x73')](_0x21e12e);}})[_0xf318('0x24')](function(_0x3dd4ec){if(_0x3dd4ec){_0xd905cb=_0x3dd4ec[_0xf318('0x4b')];if(!_0x1c161f['query'][_0xf318('0x4c')](_0xf318('0x66'))){_0x21e12e['limit']=qs[_0xf318('0x35')](_0x1c161f['query']['limit']);_0x21e12e['offset']=qs[_0xf318('0x34')](_0x1c161f[_0xf318('0x46')][_0xf318('0x34')]);}return _0x57fef5[_0xf318('0x73')](_0x21e12e);}})[_0xf318('0x24')](function(_0x550350){if(_0x550350){return _0x550350?{'count':_0xd905cb,'rows':_0x550350}:null;}})[_0xf318('0x24')](respondWithResult(_0x2852f7,null))['catch'](handleError(_0x2852f7,null));};exports[_0xf318('0x75')]=function(_0x2ec2c2,_0x1fdba4,_0xcc065b){var _0x1fbc03=_0x2ec2c2[_0xf318('0x59')]['ids'];return db[_0xf318('0x74')][_0xf318('0x54')]({'where':{'id':_0x1fbc03},'attributes':['id'],'include':[{'model':db['User'],'as':_0xf318('0x76'),'attributes':['id',_0xf318('0x3e'),'online',_0xf318('0x77'),'interface'],'raw':!![]}]})[_0xf318('0x24')](function(_0x2287c8){if(_0x2287c8){var _0x15ad5a=_[_0xf318('0x78')](_0x2287c8,function(_0x14098f){var _0x1cc7dd=_0x14098f[_0xf318('0x5a')]({'plain':!![]});return _0x1cc7dd[_0xf318('0x76')];});return db[_0xf318('0x40')][_0xf318('0x57')]({'where':{'id':_0x2ec2c2[_0xf318('0x55')]['id']}})[_0xf318('0x24')](function(_0x309a52){return db[_0xf318('0x79')][_0xf318('0x7a')](function(_0xfc6367){return _0x309a52[_0xf318('0x75')](_0x1fbc03,{'transaction':_0xfc6367})[_0xf318('0x24')](function(){return BPromise['each'](_0x15ad5a,function(_0x1da840){return db[_0xf318('0x64')]['findOrCreate']({'where':{'UserId':_0x1da840['id'],'ChatQueueId':_0x2ec2c2[_0xf318('0x55')]['id']},'transaction':_0xfc6367});});})[_0xf318('0x24')](function(){_0x15ad5a['forEach'](function(_0x562b48){socket[_0xf318('0x7b')]('userChatQueue:save',{'UserId':_0x562b48['id'],'ChatQueueId':_0x309a52['id']});});});});});}})[_0xf318('0x24')](respondWithStatusCode(_0x1fdba4,null))['catch'](handleError(_0x1fdba4,null));};exports[_0xf318('0x7c')]=function(_0xef60ae,_0x42ab7c,_0x3cccb6){return db[_0xf318('0x74')][_0xf318('0x54')]({'where':{'id':_0xef60ae[_0xf318('0x46')][_0xf318('0x7d')]},'attributes':['id'],'include':[{'model':db[_0xf318('0x69')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xf318('0x24')](handleEntityNotFound(_0x42ab7c,null))[_0xf318('0x24')](function(_0x4e03e2){var _0x4e4a44=_['map'](_0x4e03e2,'id');var _0x70c0fa=[];var _0x49027e=[];var _0x5c31dd=squel[_0xf318('0x7e')]();_0x5c31dd[_0xf318('0x7f')](_0xf318('0x80'))[_0xf318('0x81')](_0xf318('0x82'),'tq')[_0xf318('0x83')](_0xf318('0x84'),'ut',_0xf318('0x85'))[_0xf318('0x4f')](_0xf318('0x86'),_0xef60ae[_0xf318('0x55')]['id']);for(var _0x40eedc=0x0;_0x40eedc<_0x4e03e2[_0xf318('0x4b')];_0x40eedc+=0x1){let _0x72d822=_0x4e03e2[_0x40eedc];for(var _0x2531a0=0x0;_0x2531a0<_0x72d822[_0xf318('0x76')][_0xf318('0x4b')];_0x2531a0+=0x1){let _0x2f94c0=_0x72d822['Agents'][_0x2531a0];var _0x4e6531=_0x5c31dd[_0xf318('0x87')]();_0x4e6531[_0xf318('0x4f')]('ut.UserId\x20=\x20?',_0x2f94c0['id']);_0x49027e[_0xf318('0x88')](db[_0xf318('0x79')][_0xf318('0x46')](_0x4e6531[_0xf318('0x89')](),{'type':db[_0xf318('0x79')][_0xf318('0x8a')][_0xf318('0x8b')]})['then'](function(_0x7e5652){if(_0x7e5652[_0xf318('0x4b')]===0x1){return _0x2f94c0['id'];}else{var _0x15480a=_[_0xf318('0x8c')](_[_0xf318('0x44')](_0x7e5652,_0xf318('0x8d')),function(_0x32ab0f){return _[_0xf318('0x8e')](_0x4e4a44,_0x32ab0f);});if(_0x15480a){return _0x2f94c0['id'];}}}));}}return BPromise[_0xf318('0x8f')](_0x49027e)[_0xf318('0x24')](function(_0x582167){_0x70c0fa=_(_0x70c0fa)[_0xf318('0x90')](_0x582167)[_0xf318('0x91')]()[_0xf318('0x92')]();return db[_0xf318('0x40')]['find']({'where':{'id':_0xef60ae['params']['id']}})[_0xf318('0x24')](function(_0x5b7c90){return db[_0xf318('0x79')][_0xf318('0x7a')](function(_0x27a390){return _0x5b7c90[_0xf318('0x7c')](_0xef60ae[_0xf318('0x46')][_0xf318('0x7d')],{'transaction':_0x27a390})[_0xf318('0x24')](function(){if(!_['isEmpty'](_0x70c0fa)){return _0x5b7c90[_0xf318('0x93')](_0x70c0fa,{'transaction':_0x27a390});}})['then'](function(){_0x70c0fa[_0xf318('0x94')](function(_0x118cce){socket[_0xf318('0x7b')](_0xf318('0x95'),{'UserId':_0x118cce,'ChatQueueId':_0x5b7c90['id']});});});});});});})['then'](respondWithStatusCode(_0x42ab7c,null))['catch'](handleError(_0x42ab7c,null));};exports[_0xf318('0x96')]=function(_0x5ea601,_0x4e9ea8,_0x11b294){return db[_0xf318('0x40')]['find']({'where':{'id':_0x5ea601[_0xf318('0x55')]['id']}})['then'](handleEntityNotFound(_0x4e9ea8,null))[_0xf318('0x24')](function(_0x4b2117){if(_0x4b2117){return _0x4b2117['addAgents'](_0x5ea601[_0xf318('0x59')][_0xf318('0x7d')],_['omit'](_0x5ea601[_0xf318('0x59')],[_0xf318('0x7d'),'id'])||{})[_0xf318('0x97')](function(_0x526b2e){for(var _0x3b997d=0x0;_0x3b997d<_0x5ea601[_0xf318('0x59')][_0xf318('0x7d')][_0xf318('0x4b')];_0x3b997d+=0x1){socket[_0xf318('0x7b')](_0xf318('0x98'),{'UserId':_0x5ea601['body'][_0xf318('0x7d')][_0x3b997d],'ChatQueueId':_0x5ea601[_0xf318('0x55')]['id']});}return _0x526b2e;});}})['then'](respondWithResult(_0x4e9ea8,null))[_0xf318('0x2f')](handleError(_0x4e9ea8,null));};exports[_0xf318('0x93')]=function(_0x330607,_0x3a26e4,_0x3e8606){return db[_0xf318('0x40')][_0xf318('0x57')]({'where':{'id':_0x330607[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x3a26e4,null))[_0xf318('0x24')](function(_0x115fd9){if(_0x115fd9){return _0x115fd9[_0xf318('0x93')](_0x330607[_0xf318('0x46')]['ids'])[_0xf318('0x24')](function(){if(_[_0xf318('0x99')](_0x330607[_0xf318('0x46')][_0xf318('0x7d')])){for(var _0x238f61=0x0;_0x238f61<_0x330607['query'][_0xf318('0x7d')][_0xf318('0x4b')];_0x238f61+=0x1){socket[_0xf318('0x7b')](_0xf318('0x95'),{'UserId':Number(_0x330607[_0xf318('0x46')][_0xf318('0x7d')][_0x238f61]),'ChatQueueId':Number(_0x330607[_0xf318('0x55')]['id'])});}}else{socket[_0xf318('0x7b')](_0xf318('0x95'),{'UserId':Number(_0x330607[_0xf318('0x46')][_0xf318('0x7d')]),'ChatQueueId':Number(_0x330607[_0xf318('0x55')]['id'])});}});}})[_0xf318('0x24')](respondWithStatusCode(_0x3a26e4,null))[_0xf318('0x2f')](handleError(_0x3a26e4,null));};exports['getAgents']=function(_0x522503,_0x5708ac,_0x209125){var _0x133ba0={};var _0x48a5ad={};var _0x27be66;var _0x4ba910;return db[_0xf318('0x40')][_0xf318('0x9a')]({'where':{'id':_0x522503[_0xf318('0x55')]['id']}})[_0xf318('0x24')](handleEntityNotFound(_0x5708ac,null))[_0xf318('0x24')](function(_0x12cae4){if(_0x12cae4){_0x27be66=_0x12cae4;_0x48a5ad[_0xf318('0x43')]=_['keys'](db[_0xf318('0x69')][_0xf318('0x65')]);_0x48a5ad[_0xf318('0x46')]=_[_0xf318('0x45')](_0x522503[_0xf318('0x46')]);_0x48a5ad['filters']=_[_0xf318('0x48')](_0x48a5ad['model'],_0x48a5ad[_0xf318('0x46')]);_0x133ba0[_0xf318('0x4a')]=_[_0xf318('0x48')](_0x48a5ad['model'],qs['fields'](_0x522503[_0xf318('0x46')][_0xf318('0x49')]));_0x133ba0[_0xf318('0x4a')]=_0x133ba0[_0xf318('0x4a')][_0xf318('0x4b')]?_0x133ba0[_0xf318('0x4a')]:_0x48a5ad[_0xf318('0x43')];_0x133ba0['order']=qs[_0xf318('0x4e')](_0x522503['query'][_0xf318('0x4e')]);_0x133ba0['where']=qs[_0xf318('0x47')](_[_0xf318('0x50')](_0x522503['query'],_0x48a5ad['filters']));if(_0x522503[_0xf318('0x46')][_0xf318('0x51')]){_0x133ba0[_0xf318('0x4f')]=_[_0xf318('0x68')](_0x133ba0[_0xf318('0x4f')],{'$or':_[_0xf318('0x44')](_0x133ba0['attributes'],function(_0x3db5da){var _0xc35c5e={};_0xc35c5e[_0x3db5da]={'$like':'%'+_0x522503[_0xf318('0x46')]['filter']+'%'};return _0xc35c5e;})});}_0x133ba0=_['merge']({},_0x133ba0,_0x522503['options']);return _0x27be66[_0xf318('0x9b')](_0x133ba0);}})[_0xf318('0x24')](function(_0x2a5b9d){if(_0x2a5b9d){_0x4ba910=_0x2a5b9d['length'];if(!_0x522503['query'][_0xf318('0x4c')](_0xf318('0x66'))){_0x133ba0[_0xf318('0x35')]=qs[_0xf318('0x35')](_0x522503[_0xf318('0x46')][_0xf318('0x35')]);_0x133ba0[_0xf318('0x34')]=qs[_0xf318('0x34')](_0x522503[_0xf318('0x46')][_0xf318('0x34')]);}return _0x27be66[_0xf318('0x9b')](_0x133ba0);}})[_0xf318('0x24')](function(_0x36812b){if(_0x36812b){return _0x36812b?{'count':_0x4ba910,'rows':_0x36812b}:null;}})[_0xf318('0x24')](respondWithResult(_0x5708ac,null))['catch'](handleError(_0x5708ac,null));};
\ No newline at end of file