1752f5e38c324c8ed51b6d4af480b85f2da646e1
[motion2.git] / server / api / team / team.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x2bae=['offset','set','Content-Range','json','apply','reject','save','update','destroy','then','get','Teams','sendStatus','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','attributes','intersection','fields','nolimit','order','sort','where','filters','filter','merge','VIRTUAL','options','Team','count','includeAll','include','findAll','rows','show','params','length','catch','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','getQueues','channel','isValidChannel','Sequelize','ValidationError','Queue','pick','capitalize','toLowerCase','addQueues','findOne','Unknown\x20channel','add','Queues','ids','removeQueues','remove','addAgents','Voice','Sms','Fax','Openchannel','sequelize','transaction','penalty','QueueId','TeamVoiceQueue','User','emit','online','voicePause','interface','UserVoiceQueueRt','upsert','SIP/%s','all','spread','removeAgents','Whatsapp','parse','getAgents','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','./team.socket','end','status','undefined','limit'];(function(_0x5ea51c,_0x37491e){var _0x5a1a38=function(_0x4c3d02){while(--_0x4c3d02){_0x5ea51c['push'](_0x5ea51c['shift']());}};_0x5a1a38(++_0x37491e);}(_0x2bae,0xe2));var _0xe2ba=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2bae[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xe2ba('0x0'));var rimraf=require(_0xe2ba('0x1'));var zipdir=require(_0xe2ba('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe2ba('0x3'));var moment=require(_0xe2ba('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xe2ba('0x5'));var util=require(_0xe2ba('0x6'));var path=require(_0xe2ba('0x7'));var sox=require(_0xe2ba('0x8'));var csv=require('to-csv');var ejs=require(_0xe2ba('0x9'));var fs=require('fs');var fs_extra=require(_0xe2ba('0xa'));var _=require(_0xe2ba('0xb'));var squel=require('squel');var crypto=require(_0xe2ba('0xc'));var jsforce=require(_0xe2ba('0xd'));var deskjs=require(_0xe2ba('0xe'));var toCsv=require(_0xe2ba('0xf'));var querystring=require(_0xe2ba('0x10'));var Papa=require(_0xe2ba('0x11'));var Redis=require(_0xe2ba('0x12'));var authService=require('../../components/auth/service');var qs=require(_0xe2ba('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe2ba('0x14'));var logger=require(_0xe2ba('0x15'))(_0xe2ba('0x16'));var utils=require(_0xe2ba('0x17'));var config=require(_0xe2ba('0x18'));var licenseUtil=require(_0xe2ba('0x19'));var db=require(_0xe2ba('0x1a'))['db'];config[_0xe2ba('0x1b')]=_['defaults'](config[_0xe2ba('0x1b')],{'host':_0xe2ba('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xe2ba('0x1d'))['register'](socket);function respondWithStatusCode(_0x54c341,_0x5a49ca){_0x5a49ca=_0x5a49ca||0xcc;return function(_0x3f8381){if(_0x3f8381){return _0x54c341['sendStatus'](_0x5a49ca);}return _0x54c341['status'](_0x5a49ca)[_0xe2ba('0x1e')]();};}function respondWithResult(_0x2fb4de,_0x1f9065){_0x1f9065=_0x1f9065||0xc8;return function(_0x548064){if(_0x548064){return _0x2fb4de[_0xe2ba('0x1f')](_0x1f9065)['json'](_0x548064);}};}function respondWithFilteredResult(_0x19e80d,_0x5d70e8){return function(_0x337454){if(_0x337454){var _0x2ef082=typeof _0x5d70e8['offset']===_0xe2ba('0x20')&&typeof _0x5d70e8[_0xe2ba('0x21')]===_0xe2ba('0x20');var _0x3c49f3=_0x337454['count'];var _0x1da731=_0x2ef082?0x0:_0x5d70e8[_0xe2ba('0x22')];var _0x3e52b8=_0x2ef082?_0x337454['count']:_0x5d70e8[_0xe2ba('0x22')]+_0x5d70e8[_0xe2ba('0x21')];var _0x4450d5;if(_0x3e52b8>=_0x3c49f3){_0x3e52b8=_0x3c49f3;_0x4450d5=0xc8;}else{_0x4450d5=0xce;}_0x19e80d[_0xe2ba('0x1f')](_0x4450d5);return _0x19e80d[_0xe2ba('0x23')](_0xe2ba('0x24'),_0x1da731+'-'+_0x3e52b8+'/'+_0x3c49f3)[_0xe2ba('0x25')](_0x337454);}return null;};}function patchUpdates(_0x4c9f4a){return function(_0x32c68b){try{jsonpatch[_0xe2ba('0x26')](_0x32c68b,_0x4c9f4a,!![]);}catch(_0x4fb66e){return BPromise[_0xe2ba('0x27')](_0x4fb66e);}return _0x32c68b[_0xe2ba('0x28')]();};}function saveUpdates(_0x21ab82,_0x3b5a5b){return function(_0x1e9a6c){if(_0x1e9a6c){return _0x1e9a6c[_0xe2ba('0x29')](_0x21ab82)['then'](function(_0x4ec4f7){return _0x4ec4f7;});}return null;};}function removeEntity(_0x446e9f,_0xc8fe92){return function(_0x363941){if(_0x363941){return _0x363941[_0xe2ba('0x2a')]()[_0xe2ba('0x2b')](function(){var _0x5d88c7=_0x363941[_0xe2ba('0x2c')]({'plain':!![]});var _0x1e9c32=_0xe2ba('0x2d');return db['UserProfileResource'][_0xe2ba('0x2a')]({'where':{'type':_0x1e9c32,'resourceId':_0x5d88c7['id']}})[_0xe2ba('0x2b')](function(){return _0x363941;});})[_0xe2ba('0x2b')](function(){_0x446e9f[_0xe2ba('0x1f')](0xcc)[_0xe2ba('0x1e')]();});}};}function handleEntityNotFound(_0x2a025d,_0x3535bf){return function(_0x4b213f){if(!_0x4b213f){_0x2a025d[_0xe2ba('0x2e')](0x194);}return _0x4b213f;};}function handleError(_0x3e14a7,_0x209e3a){_0x209e3a=_0x209e3a||0x1f4;return function(_0x5cf866){logger[_0xe2ba('0x2f')](_0x5cf866[_0xe2ba('0x30')]);if(_0x5cf866[_0xe2ba('0x31')]){delete _0x5cf866[_0xe2ba('0x31')];}_0x3e14a7[_0xe2ba('0x1f')](_0x209e3a)[_0xe2ba('0x32')](_0x5cf866);};}exports['index']=function(_0x3f8a4c,_0x9ab83c){var _0x4ae161={},_0x3ff7ab={},_0xe2a3aa={'count':0x0,'rows':[]};var _0x33fb64=_[_0xe2ba('0x33')](db['Team'][_0xe2ba('0x34')],function(_0x28ea48){return{'name':_0x28ea48[_0xe2ba('0x35')],'type':_0x28ea48[_0xe2ba('0x36')][_0xe2ba('0x37')]};});_0x3ff7ab[_0xe2ba('0x38')]=_['map'](_0x33fb64,_0xe2ba('0x31'));_0x3ff7ab[_0xe2ba('0x39')]=_[_0xe2ba('0x3a')](_0x3f8a4c[_0xe2ba('0x39')]);_0x3ff7ab['filters']=_['intersection'](_0x3ff7ab[_0xe2ba('0x38')],_0x3ff7ab[_0xe2ba('0x39')]);_0x4ae161[_0xe2ba('0x3b')]=_[_0xe2ba('0x3c')](_0x3ff7ab[_0xe2ba('0x38')],qs[_0xe2ba('0x3d')](_0x3f8a4c['query'][_0xe2ba('0x3d')]));_0x4ae161[_0xe2ba('0x3b')]=_0x4ae161[_0xe2ba('0x3b')]['length']?_0x4ae161[_0xe2ba('0x3b')]:_0x3ff7ab[_0xe2ba('0x38')];if(!_0x3f8a4c[_0xe2ba('0x39')]['hasOwnProperty'](_0xe2ba('0x3e'))){_0x4ae161[_0xe2ba('0x21')]=qs['limit'](_0x3f8a4c[_0xe2ba('0x39')][_0xe2ba('0x21')]);_0x4ae161['offset']=qs[_0xe2ba('0x22')](_0x3f8a4c[_0xe2ba('0x39')][_0xe2ba('0x22')]);}_0x4ae161[_0xe2ba('0x3f')]=qs[_0xe2ba('0x40')](_0x3f8a4c[_0xe2ba('0x39')][_0xe2ba('0x40')]);_0x4ae161[_0xe2ba('0x41')]=qs['filters'](_['pick'](_0x3f8a4c['query'],_0x3ff7ab[_0xe2ba('0x42')]),_0x33fb64);if(_0x3f8a4c['query'][_0xe2ba('0x43')]){_0x4ae161[_0xe2ba('0x41')]=_[_0xe2ba('0x44')](_0x4ae161[_0xe2ba('0x41')],{'$or':_[_0xe2ba('0x33')](_0x33fb64,function(_0x21a7e5){if(_0x21a7e5['type']!==_0xe2ba('0x45')){var _0x2fded5={};_0x2fded5[_0x21a7e5[_0xe2ba('0x31')]]={'$like':'%'+_0x3f8a4c[_0xe2ba('0x39')][_0xe2ba('0x43')]+'%'};return _0x2fded5;}})});}_0x4ae161=_[_0xe2ba('0x44')]({},_0x4ae161,_0x3f8a4c[_0xe2ba('0x46')]);var _0x54feb2={'where':_0x4ae161[_0xe2ba('0x41')]};return db[_0xe2ba('0x47')][_0xe2ba('0x48')](_0x54feb2)[_0xe2ba('0x2b')](function(_0x51b6e9){_0xe2a3aa['count']=_0x51b6e9;if(_0x3f8a4c[_0xe2ba('0x39')][_0xe2ba('0x49')]){_0x4ae161[_0xe2ba('0x4a')]=[{'all':!![]}];}return db[_0xe2ba('0x47')][_0xe2ba('0x4b')](_0x4ae161);})[_0xe2ba('0x2b')](function(_0x1d70dd){_0xe2a3aa[_0xe2ba('0x4c')]=_0x1d70dd;return _0xe2a3aa;})['then'](respondWithFilteredResult(_0x9ab83c,_0x4ae161))['catch'](handleError(_0x9ab83c,null));};exports[_0xe2ba('0x4d')]=function(_0x1292e7,_0x272fda){var _0x9b6b={'raw':![],'where':{'id':_0x1292e7[_0xe2ba('0x4e')]['id']}},_0x304315={};_0x304315[_0xe2ba('0x38')]=_['keys'](db[_0xe2ba('0x47')][_0xe2ba('0x34')]);_0x304315[_0xe2ba('0x39')]=_[_0xe2ba('0x3a')](_0x1292e7['query']);_0x304315[_0xe2ba('0x42')]=_[_0xe2ba('0x3c')](_0x304315[_0xe2ba('0x38')],_0x304315[_0xe2ba('0x39')]);_0x9b6b['attributes']=_[_0xe2ba('0x3c')](_0x304315[_0xe2ba('0x38')],qs['fields'](_0x1292e7['query'][_0xe2ba('0x3d')]));_0x9b6b[_0xe2ba('0x3b')]=_0x9b6b[_0xe2ba('0x3b')][_0xe2ba('0x4f')]?_0x9b6b['attributes']:_0x304315[_0xe2ba('0x38')];if(_0x1292e7[_0xe2ba('0x39')][_0xe2ba('0x49')]){_0x9b6b[_0xe2ba('0x4a')]=[{'all':!![]}];}_0x9b6b=_[_0xe2ba('0x44')]({},_0x9b6b,_0x1292e7[_0xe2ba('0x46')]);return db[_0xe2ba('0x47')]['find'](_0x9b6b)['then'](handleEntityNotFound(_0x272fda,null))[_0xe2ba('0x2b')](respondWithResult(_0x272fda,null))[_0xe2ba('0x50')](handleError(_0x272fda,null));};exports['create']=function(_0x55bd2e,_0x5cd39c){return db[_0xe2ba('0x47')][_0xe2ba('0x51')](_0x55bd2e['body'],{})[_0xe2ba('0x2b')](function(_0x250ff7){var _0x5016e9=_0x55bd2e[_0xe2ba('0x52')][_0xe2ba('0x2c')]({'plain':!![]});if(!_0x5016e9)throw new Error(_0xe2ba('0x53'));if(_0x5016e9['role']===_0xe2ba('0x52')){var _0x30c6f5=_0x250ff7[_0xe2ba('0x2c')]({'plain':!![]});var _0x5618a0='Teams';return db['UserProfileSection'][_0xe2ba('0x54')]({'where':{'name':_0x5618a0,'userProfileId':_0x5016e9[_0xe2ba('0x55')]},'raw':!![]})[_0xe2ba('0x2b')](function(_0x1b45b1){if(_0x1b45b1&&_0x1b45b1[_0xe2ba('0x56')]===0x0){return db['UserProfileResource'][_0xe2ba('0x51')]({'name':_0x30c6f5['name'],'resourceId':_0x30c6f5['id'],'type':_0x1b45b1[_0xe2ba('0x31')],'sectionId':_0x1b45b1['id']},{})['then'](function(){return _0x250ff7;});}else{return _0x250ff7;}})[_0xe2ba('0x50')](function(_0x1de6ee){logger['error'](_0xe2ba('0x57'),_0x1de6ee);throw _0x1de6ee;});}return _0x250ff7;})[_0xe2ba('0x2b')](respondWithResult(_0x5cd39c,0xc9))[_0xe2ba('0x50')](handleError(_0x5cd39c,null));};exports[_0xe2ba('0x29')]=function(_0x7f80e7,_0x5c7670){if(_0x7f80e7[_0xe2ba('0x58')]['id']){delete _0x7f80e7[_0xe2ba('0x58')]['id'];}return db['Team'][_0xe2ba('0x54')]({'where':{'id':_0x7f80e7[_0xe2ba('0x4e')]['id']}})[_0xe2ba('0x2b')](handleEntityNotFound(_0x5c7670,null))[_0xe2ba('0x2b')](saveUpdates(_0x7f80e7['body'],null))[_0xe2ba('0x2b')](respondWithResult(_0x5c7670,null))[_0xe2ba('0x50')](handleError(_0x5c7670,null));};exports[_0xe2ba('0x2a')]=function(_0x1e8c53,_0x4ce65b){return db['Team']['find']({'where':{'id':_0x1e8c53[_0xe2ba('0x4e')]['id']}})[_0xe2ba('0x2b')](handleEntityNotFound(_0x4ce65b,null))['then'](removeEntity(_0x4ce65b,null))['catch'](handleError(_0x4ce65b,null));};exports[_0xe2ba('0x59')]=function(_0x57cae8,_0x503490,_0x184176){return db['Team']['findOne']({'where':{'id':_0x57cae8[_0xe2ba('0x4e')]['id']}})[_0xe2ba('0x2b')](handleEntityNotFound(_0x503490,null))[_0xe2ba('0x2b')](function(_0x133821){if(!_0x57cae8[_0xe2ba('0x39')][_0xe2ba('0x5a')]||!utils[_0xe2ba('0x5b')](_0x57cae8[_0xe2ba('0x39')][_0xe2ba('0x5a')])){throw new db[(_0xe2ba('0x5c'))][(_0xe2ba('0x5d'))]('Unknown\x20channel');}var _0x5cdf79={};var _0x233ea8={};_0x233ea8[_0xe2ba('0x38')]=_['keys'](db[_['capitalize'](_0x57cae8[_0xe2ba('0x39')][_0xe2ba('0x5a')]['toLowerCase']())+_0xe2ba('0x5e')][_0xe2ba('0x34')]);_0x233ea8[_0xe2ba('0x39')]=_[_0xe2ba('0x3a')](_0x57cae8['query']);_0x233ea8[_0xe2ba('0x42')]=_[_0xe2ba('0x3c')](_0x233ea8[_0xe2ba('0x38')],_0x233ea8['query']);_0x5cdf79[_0xe2ba('0x3b')]=_[_0xe2ba('0x3c')](_0x233ea8[_0xe2ba('0x38')],qs[_0xe2ba('0x3d')](_0x57cae8[_0xe2ba('0x39')][_0xe2ba('0x3d')]));_0x5cdf79['attributes']=_0x5cdf79[_0xe2ba('0x3b')][_0xe2ba('0x4f')]?_0x5cdf79[_0xe2ba('0x3b')]:_0x233ea8[_0xe2ba('0x38')];_0x5cdf79[_0xe2ba('0x21')]=qs[_0xe2ba('0x21')](_0x57cae8[_0xe2ba('0x39')][_0xe2ba('0x21')]);_0x5cdf79['offset']=qs[_0xe2ba('0x22')](_0x57cae8['query'][_0xe2ba('0x22')]);_0x5cdf79[_0xe2ba('0x3f')]=qs[_0xe2ba('0x40')](_0x57cae8['query'][_0xe2ba('0x40')]);_0x5cdf79[_0xe2ba('0x41')]=qs[_0xe2ba('0x42')](_[_0xe2ba('0x5f')](_0x57cae8[_0xe2ba('0x39')],_0x233ea8[_0xe2ba('0x42')]));_0x5cdf79=_['merge']({},_0x5cdf79,_0x57cae8[_0xe2ba('0x46')]);return _0x133821[_0xe2ba('0x2c')+_[_0xe2ba('0x60')](_0x57cae8['query'][_0xe2ba('0x5a')][_0xe2ba('0x61')]())+'Queues'](_0x5cdf79);})[_0xe2ba('0x2b')](respondWithResult(_0x503490,null))[_0xe2ba('0x50')](handleError(_0x503490,null));};exports[_0xe2ba('0x62')]=function(_0x4b92c2,_0x257dd0,_0x133051){return db[_0xe2ba('0x47')][_0xe2ba('0x63')]({'where':{'id':_0x4b92c2[_0xe2ba('0x4e')]['id']}})['then'](function(_0x3be227){if(_0x3be227){if(!_0x4b92c2[_0xe2ba('0x58')]['channel']||!utils[_0xe2ba('0x5b')](_0x4b92c2[_0xe2ba('0x58')][_0xe2ba('0x5a')])){throw new db[(_0xe2ba('0x5c'))][(_0xe2ba('0x5d'))](_0xe2ba('0x64'));}return _0x3be227[_0xe2ba('0x65')+_[_0xe2ba('0x60')](_0x4b92c2['body']['channel'][_0xe2ba('0x61')]())+_0xe2ba('0x66')](_0x4b92c2['body'][_0xe2ba('0x67')]);}return null;})[_0xe2ba('0x2b')](handleEntityNotFound(_0x257dd0,null))[_0xe2ba('0x2b')](respondWithStatusCode(_0x257dd0,null))[_0xe2ba('0x50')](handleError(_0x257dd0,null));};exports[_0xe2ba('0x68')]=function(_0x623ceb,_0x11b27c,_0x94c336){return db[_0xe2ba('0x47')][_0xe2ba('0x63')]({'where':{'id':_0x623ceb[_0xe2ba('0x4e')]['id']}})[_0xe2ba('0x2b')](function(_0x370fd6){if(_0x370fd6){if(!_0x623ceb['query'][_0xe2ba('0x5a')]||!utils[_0xe2ba('0x5b')](_0x623ceb[_0xe2ba('0x39')][_0xe2ba('0x5a')])){throw new db[(_0xe2ba('0x5c'))][(_0xe2ba('0x5d'))](_0xe2ba('0x64'));}return _0x370fd6[_0xe2ba('0x69')+_[_0xe2ba('0x60')](_0x623ceb[_0xe2ba('0x39')][_0xe2ba('0x5a')]['toLowerCase']())+_0xe2ba('0x66')](_0x623ceb['query'][_0xe2ba('0x67')]);}return null;})[_0xe2ba('0x2b')](handleEntityNotFound(_0x11b27c,null))[_0xe2ba('0x2b')](respondWithStatusCode(_0x11b27c,null))[_0xe2ba('0x50')](handleError(_0x11b27c,null));};exports[_0xe2ba('0x6a')]=function(_0x1598bc,_0x3323a9){return db['Team']['find']({'where':{'id':_0x1598bc[_0xe2ba('0x4e')]['id']}})['then'](handleEntityNotFound(_0x3323a9,null))[_0xe2ba('0x2b')](function(_0x227194){if(_0x227194){var _0x5c323d=[_0xe2ba('0x6b'),'Chat','Mail',_0xe2ba('0x6c'),_0xe2ba('0x6d'),_0xe2ba('0x6e'),'Whatsapp'];return db[_0xe2ba('0x6f')][_0xe2ba('0x70')](function(_0x1e7ae0){var _0xd98630=_[_0xe2ba('0x33')](_0x5c323d,function(_0x52782d){var _0x2aa8e1={'attributes':['id',_0xe2ba('0x31')]};if(_0x52782d===_0xe2ba('0x6b')){_0x2aa8e1['through']={'attributes':[_0xe2ba('0x71')]};}return _0x227194[_0xe2ba('0x2c')+_0x52782d+_0xe2ba('0x66')](_0x2aa8e1)[_0xe2ba('0x2b')](function(_0x2c9648){var _0x33691d=_[_0xe2ba('0x33')](_0x2c9648,function(_0x248df9){var _0x572e00=_[_0xe2ba('0x33')](_0x1598bc[_0xe2ba('0x58')][_0xe2ba('0x67')],function(_0x1cfdb2){var _0x1ed69e={'where':{'UserId':_0x1cfdb2,[_0x52782d+_0xe2ba('0x72')]:_0x248df9['id']},'transaction':_0x1e7ae0};if(_0x52782d===_0xe2ba('0x6b')){_0x1ed69e['defaults']={'penalty':_0x248df9[_0xe2ba('0x73')][_0xe2ba('0x71')]};}return db[_0xe2ba('0x74')+_0x52782d+_0xe2ba('0x5e')]['findOrCreate'](_0x1ed69e)[_0xe2ba('0x2b')](function(){socket[_0xe2ba('0x75')](_0xe2ba('0x52')+_0x52782d+'Queue:save',{'UserId':_0x1cfdb2,[_0x52782d+_0xe2ba('0x72')]:_0x248df9['id']});if(_0x52782d!==_0xe2ba('0x6b'))return;return db['User'][_0xe2ba('0x4b')]({'where':{'id':_0x1598bc[_0xe2ba('0x58')][_0xe2ba('0x67')],'online':0x1},'attributes':['id',_0xe2ba('0x31'),_0xe2ba('0x76'),_0xe2ba('0x77'),_0xe2ba('0x78')],'raw':!![]})[_0xe2ba('0x2b')](function(_0x428971){var _0x52e355=_[_0xe2ba('0x33')](_0x428971,function(_0x4c9685){return db[_0xe2ba('0x79')][_0xe2ba('0x7a')]({'membername':_0x4c9685[_0xe2ba('0x31')],'UserId':_0x4c9685['id'],'queue_name':_0x248df9[_0xe2ba('0x31')],'VoiceQueueId':_0x248df9['id'],'interface':_['isNil'](_0x4c9685[_0xe2ba('0x78')])?util['format'](_0xe2ba('0x7b'),_0x4c9685['name']):_0x4c9685[_0xe2ba('0x78')],'paused':_0x4c9685['voicePause']||![],'penalty':_0x248df9['TeamVoiceQueue']['penalty']},{'transaction':_0x1e7ae0});});return Promise[_0xe2ba('0x7c')](_0x52e355);});});});return Promise['all'](_0x572e00);});return Promise[_0xe2ba('0x7c')](_0x33691d);});});return Promise['all'](_0xd98630)[_0xe2ba('0x2b')](function(){return _0x227194[_0xe2ba('0x6a')](_0x1598bc[_0xe2ba('0x58')][_0xe2ba('0x67')],{'transaction':_0x1e7ae0})[_0xe2ba('0x7d')](function(_0xb2618){return _0xb2618;});});});}})[_0xe2ba('0x2b')](respondWithResult(_0x3323a9,null))[_0xe2ba('0x50')](handleError(_0x3323a9,null));};exports[_0xe2ba('0x7e')]=function(_0x6154b5,_0x1f1865){return db[_0xe2ba('0x47')][_0xe2ba('0x54')]({'where':{'id':_0x6154b5['params']['id']}})[_0xe2ba('0x2b')](handleEntityNotFound(_0x1f1865,null))[_0xe2ba('0x2b')](function(_0xe3a7a6){if(_0xe3a7a6){var _0x25f254=[_0xe2ba('0x6b'),'Chat','Mail',_0xe2ba('0x6c'),_0xe2ba('0x6d'),_0xe2ba('0x6e'),_0xe2ba('0x7f')];return db[_0xe2ba('0x6f')][_0xe2ba('0x70')](function(_0x178966){var _0x3a3bfb=_[_0xe2ba('0x33')](_0x25f254,function(_0x5ce7dc){var _0x3fd15b={'attributes':['id','name']};return _0xe3a7a6[_0xe2ba('0x2c')+_0x5ce7dc+_0xe2ba('0x66')](_0x3fd15b)[_0xe2ba('0x2b')](function(_0x13ca9f){var _0x24d6e9=_['map'](_0x13ca9f,function(_0x489b03){return _0x489b03[_0xe2ba('0x7e')](_0x6154b5[_0xe2ba('0x39')][_0xe2ba('0x67')],{'transaction':_0x178966})['then'](function(){var _0xcd8e4d=JSON[_0xe2ba('0x80')]('['+_0x6154b5[_0xe2ba('0x39')][_0xe2ba('0x67')]+']');var _0x418398=_[_0xe2ba('0x33')](_0xcd8e4d,function(_0x336f34){socket['emit'](_0xe2ba('0x52')+_0x5ce7dc+'Queue:remove',{'UserId':Number(_0x336f34),[_0x5ce7dc+_0xe2ba('0x72')]:_0x489b03['id']});if(_0x5ce7dc!==_0xe2ba('0x6b'))return;return db['UserVoiceQueueRt'][_0xe2ba('0x2a')]({'where':{'VoiceQueueId':_0x489b03['id'],'UserId':_0x336f34},'transaction':_0x178966});});return Promise[_0xe2ba('0x7c')](_0x418398);});});return Promise[_0xe2ba('0x7c')](_0x24d6e9);});});return Promise[_0xe2ba('0x7c')](_0x3a3bfb)[_0xe2ba('0x2b')](function(){return _0xe3a7a6[_0xe2ba('0x7e')](_0x6154b5[_0xe2ba('0x39')][_0xe2ba('0x67')],{'transaction':_0x178966});});});}})[_0xe2ba('0x2b')](respondWithStatusCode(_0x1f1865,null))[_0xe2ba('0x50')](handleError(_0x1f1865,null));};exports[_0xe2ba('0x81')]=function(_0x1cedb5,_0x1514d5,_0x56aa46){var _0x4eb069={};var _0x2ad476={};var _0x6847e7;var _0x1d275c;return db[_0xe2ba('0x47')][_0xe2ba('0x63')]({'where':{'id':_0x1cedb5[_0xe2ba('0x4e')]['id']}})[_0xe2ba('0x2b')](handleEntityNotFound(_0x1514d5,null))[_0xe2ba('0x2b')](function(_0x5da097){if(_0x5da097){_0x6847e7=_0x5da097;_0x2ad476[_0xe2ba('0x38')]=_[_0xe2ba('0x3a')](db['User'][_0xe2ba('0x34')]);_0x2ad476[_0xe2ba('0x39')]=_['keys'](_0x1cedb5[_0xe2ba('0x39')]);_0x2ad476[_0xe2ba('0x42')]=_[_0xe2ba('0x3c')](_0x2ad476[_0xe2ba('0x38')],_0x2ad476['query']);_0x4eb069[_0xe2ba('0x3b')]=_['intersection'](_0x2ad476[_0xe2ba('0x38')],qs[_0xe2ba('0x3d')](_0x1cedb5[_0xe2ba('0x39')]['fields']));_0x4eb069[_0xe2ba('0x3b')]=_0x4eb069['attributes']['length']?_0x4eb069[_0xe2ba('0x3b')]:_0x2ad476[_0xe2ba('0x38')];_0x4eb069[_0xe2ba('0x3f')]=qs[_0xe2ba('0x40')](_0x1cedb5[_0xe2ba('0x39')][_0xe2ba('0x40')]);_0x4eb069['where']=qs[_0xe2ba('0x42')](_[_0xe2ba('0x5f')](_0x1cedb5[_0xe2ba('0x39')],_0x2ad476[_0xe2ba('0x42')]));if(_0x1cedb5[_0xe2ba('0x39')][_0xe2ba('0x43')]){_0x4eb069[_0xe2ba('0x41')]=_[_0xe2ba('0x44')](_0x4eb069[_0xe2ba('0x41')],{'$or':_[_0xe2ba('0x33')](_0x4eb069[_0xe2ba('0x3b')],function(_0x342373){var _0x26d494={};_0x26d494[_0x342373]={'$like':'%'+_0x1cedb5['query'][_0xe2ba('0x43')]+'%'};return _0x26d494;})});}_0x4eb069=_[_0xe2ba('0x44')]({},_0x4eb069,_0x1cedb5['options']);return _0x6847e7[_0xe2ba('0x81')](_0x4eb069);}})[_0xe2ba('0x2b')](function(_0x439ec8){if(_0x439ec8){_0x1d275c=_0x439ec8[_0xe2ba('0x4f')];if(!_0x1cedb5[_0xe2ba('0x39')]['hasOwnProperty'](_0xe2ba('0x3e'))){_0x4eb069[_0xe2ba('0x21')]=qs[_0xe2ba('0x21')](_0x1cedb5['query'][_0xe2ba('0x21')]);_0x4eb069[_0xe2ba('0x22')]=qs[_0xe2ba('0x22')](_0x1cedb5[_0xe2ba('0x39')][_0xe2ba('0x22')]);}return _0x6847e7[_0xe2ba('0x81')](_0x4eb069);}})[_0xe2ba('0x2b')](function(_0x5d6daf){if(_0x5d6daf){return _0x5d6daf?{'count':_0x1d275c,'rows':_0x5d6daf}:null;}})[_0xe2ba('0x2b')](respondWithResult(_0x1514d5,null))[_0xe2ba('0x50')](handleError(_0x1514d5,null));};