Built motion from commit f861bcb808219e66da88ba48b61bddb35224a65e. Version 3.0.0...
[motion-next.git] / server / api / team / team.controller.js
1 'use strict';const a741_0x521c=['api','removeQueues','params','Queue:save','1XiiIHh','rows','through','1404855rxnTiQ','remove','all','QueueId','show','count','filter','keys','offset','defaults','emit','model','findOne','30748lSWBOu','end','order','Teams','Fax','limit','sort','penalty','Openchannel','set','voicePause','Sms','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','5RdZjBa','interface','378ItPlrW','SIP/','type','sendStatus','name','3797363vblfgr','User','capitalize','./team.socket','Unknown\x20channel','isNil','map','UserVoiceQueueRt','send','toLowerCase','key','rawAttributes','create','get','Team','filters','fieldName','@config/logger','userProfileId','role','713478uWFFie','json','where','autoAssociation','findAll','Queue:remove','addAgents','catch','Queues','removeAgents','channel','@utils/filter-attributes','error','isValidChannel','include','Content-Range','upsert','nolimit','1456640shtVvT','user','update','Voice','body','includeAll','register','add','merge','transaction','TeamVoiceQueue','1GphHZV','parse','4101uQfGHl','query','Mail','ids','findOrCreate','Chat','then','status','Whatsapp','getAgents','destroy','sequelize','fields','@components/parsers/qs','options','undefined','getQueues','@rediscache','UserProfileResource','pick','intersection','length','198903qZRmXI','attributes','@mysqldb','UserProfileSection','index'];const a741_0x3e68=function(_0x36e7fe,_0x33f443){_0x36e7fe=_0x36e7fe-0x1f3;let _0x521c0e=a741_0x521c[_0x36e7fe];return _0x521c0e;};const a741_0x3b8da1=a741_0x3e68;(function(_0x46fe80,_0x74ce6a){const _0x154d26=a741_0x3e68;while(!![]){try{const _0x15c318=parseInt(_0x154d26(0x258))*-parseInt(_0x154d26(0x21a))+parseInt(_0x154d26(0x25b))+-parseInt(_0x154d26(0x201))*-parseInt(_0x154d26(0x239))+parseInt(_0x154d26(0x24f))*parseInt(_0x154d26(0x1ff))+parseInt(_0x154d26(0x22c))+parseInt(_0x154d26(0x237))*-parseInt(_0x154d26(0x268))+-parseInt(_0x154d26(0x206));if(_0x15c318===_0x74ce6a)break;else _0x46fe80['push'](_0x46fe80['shift']());}catch(_0x30d6d4){_0x46fe80['push'](_0x46fe80['shift']());}}}(a741_0x521c,0xd3157));const _=require('lodash'),qs=require(a741_0x3b8da1(0x246)),logger=require(a741_0x3b8da1(0x217))(a741_0x3b8da1(0x254)),utils=require('@config/utils'),{getSocket}=require(a741_0x3b8da1(0x24a)),socket=getSocket(),{db}=require(a741_0x3b8da1(0x251)),{ValidationError}=require(a741_0x3b8da1(0x244)),{filterAttributes}=require(a741_0x3b8da1(0x225));require(a741_0x3b8da1(0x209))[a741_0x3b8da1(0x232)](socket);function respondWithStatusCode(_0x72e642,_0x1e80e6){return _0x1e80e6=_0x1e80e6||0xcc,function(_0x3303a8){const _0x195d9b=a741_0x3e68;if(_0x3303a8)return _0x72e642[_0x195d9b(0x204)](_0x1e80e6);return _0x72e642[_0x195d9b(0x240)](_0x1e80e6)['end']();};}function respondWithResult(_0x43ad8f,_0x2d9798){return _0x2d9798=_0x2d9798||0xc8,function(_0x4b1753){const _0x20b000=a741_0x3e68;if(_0x4b1753)return _0x43ad8f[_0x20b000(0x240)](_0x2d9798)['json'](_0x4b1753);};}function respondWithFilteredResult(_0x4f9ea1,_0x3a4fdb){return function(_0x1ce690){const _0x1865b0=a741_0x3e68;if(_0x1ce690){const _0x3f5d11=_0x1ce690[_0x1865b0(0x260)],_0x33c875=_0x3a4fdb[_0x1865b0(0x263)];let _0x525b00=_0x3a4fdb[_0x1865b0(0x263)]+_0x3a4fdb[_0x1865b0(0x1f7)],_0xfca292;return _0x525b00>=_0x3f5d11?(_0x525b00=_0x3f5d11,_0xfca292=0xc8):_0xfca292=0xce,_0x4f9ea1[_0x1865b0(0x240)](_0xfca292),_0x4f9ea1[_0x1865b0(0x1fb)](_0x1865b0(0x229),_0x33c875+'-'+_0x525b00+'/'+_0x3f5d11)[_0x1865b0(0x21b)](_0x1ce690);}return null;};}function saveUpdates(_0x1e55d0){return function(_0x40023f){const _0x6d7e2e=a741_0x3e68;if(_0x40023f)return _0x40023f[_0x6d7e2e(0x22e)](_0x1e55d0)[_0x6d7e2e(0x23f)](function(_0x22a718){return _0x22a718;});return null;};}function removeEntity(_0x2dc461){return function(_0x5203b0){const _0x3d472c=a741_0x3e68;if(_0x5203b0)return _0x5203b0[_0x3d472c(0x243)]()[_0x3d472c(0x23f)](function(){const _0x5c9125=_0x3d472c,_0x59c0e8=_0x5203b0[_0x5c9125(0x213)]({'plain':!![]}),_0x57d387=_0x5c9125(0x1f5);return db[_0x5c9125(0x24b)][_0x5c9125(0x243)]({'where':{'type':_0x57d387,'resourceId':_0x59c0e8['id']}})[_0x5c9125(0x23f)](function(){return _0x5203b0;});})[_0x3d472c(0x23f)](function(){const _0x2f324c=_0x3d472c;_0x2dc461[_0x2f324c(0x240)](0xcc)[_0x2f324c(0x1f3)]();});};}function handleEntityNotFound(_0x520d8b){return function(_0x598afb){const _0x593cd7=a741_0x3e68;return!_0x598afb&&_0x520d8b[_0x593cd7(0x204)](0x194),_0x598afb;};}function handleError(_0x58af26,_0x3efbd0){return _0x3efbd0=_0x3efbd0||0x1f4,function(_0x2e00ba){const _0x26651c=a741_0x3e68;logger[_0x26651c(0x226)](_0x2e00ba['stack']),_0x2e00ba[_0x26651c(0x205)]&&delete _0x2e00ba[_0x26651c(0x205)],_0x58af26['status'](_0x3efbd0)[_0x26651c(0x20e)](_0x2e00ba);};}exports[a741_0x3b8da1(0x253)]=function(_0x1958a5,_0x243b51){const _0x6fe7f5=a741_0x3b8da1;let _0x42fa5d={};const _0x4626c4={},_0x3256ec={'count':0x0,'rows':[]},_0x82e5ff=_['map'](db[_0x6fe7f5(0x214)][_0x6fe7f5(0x211)],function(_0xd91726){const _0x226c3a=_0x6fe7f5;return{'name':_0xd91726[_0x226c3a(0x216)],'type':_0xd91726[_0x226c3a(0x203)][_0x226c3a(0x210)]};});_0x4626c4[_0x6fe7f5(0x266)]=_['map'](_0x82e5ff,_0x6fe7f5(0x205)),_0x4626c4['query']=_[_0x6fe7f5(0x262)](_0x1958a5['query']),_0x4626c4[_0x6fe7f5(0x215)]=_[_0x6fe7f5(0x24d)](_0x4626c4[_0x6fe7f5(0x266)],_0x4626c4[_0x6fe7f5(0x23a)]),_0x42fa5d[_0x6fe7f5(0x250)]=_['intersection'](_0x4626c4[_0x6fe7f5(0x266)],qs[_0x6fe7f5(0x245)](_0x1958a5[_0x6fe7f5(0x23a)][_0x6fe7f5(0x245)])),_0x42fa5d['attributes']=_0x42fa5d[_0x6fe7f5(0x250)][_0x6fe7f5(0x24e)]?_0x42fa5d[_0x6fe7f5(0x250)]:_0x4626c4[_0x6fe7f5(0x266)];typeof _0x1958a5[_0x6fe7f5(0x23a)][_0x6fe7f5(0x22b)]==='undefined'&&(_0x42fa5d[_0x6fe7f5(0x1f7)]=qs[_0x6fe7f5(0x1f7)](_0x1958a5[_0x6fe7f5(0x23a)]['limit']),_0x42fa5d[_0x6fe7f5(0x263)]=qs[_0x6fe7f5(0x263)](_0x1958a5['query'][_0x6fe7f5(0x263)]));_0x42fa5d[_0x6fe7f5(0x1f4)]=qs[_0x6fe7f5(0x1f8)](_0x1958a5['query'][_0x6fe7f5(0x1f8)]),_0x42fa5d[_0x6fe7f5(0x21c)]=qs[_0x6fe7f5(0x215)](_[_0x6fe7f5(0x24c)](_0x1958a5['query'],_0x4626c4[_0x6fe7f5(0x215)]),_0x82e5ff),_0x42fa5d=filterAttributes(_0x42fa5d,_0x1958a5[_0x6fe7f5(0x23a)][_0x6fe7f5(0x261)],_0x82e5ff,_0x1958a5[_0x6fe7f5(0x247)]);const _0x21b1ea={'where':_0x42fa5d['where']};return db[_0x6fe7f5(0x214)][_0x6fe7f5(0x260)](_0x21b1ea)[_0x6fe7f5(0x23f)](function(_0xb5924f){const _0x37dd90=_0x6fe7f5;return _0x3256ec[_0x37dd90(0x260)]=_0xb5924f,_0x1958a5['query'][_0x37dd90(0x231)]&&(_0x42fa5d[_0x37dd90(0x228)]=[{'all':!![]}]),db['Team'][_0x37dd90(0x21e)](_0x42fa5d);})[_0x6fe7f5(0x23f)](function(_0x337e95){const _0x5adcb1=_0x6fe7f5;return _0x3256ec[_0x5adcb1(0x259)]=_0x337e95,_0x3256ec;})[_0x6fe7f5(0x23f)](respondWithFilteredResult(_0x243b51,_0x42fa5d))['catch'](handleError(_0x243b51,null));},exports[a741_0x3b8da1(0x25f)]=function(_0xfda4da,_0x46454e){const _0x5241a9=a741_0x3b8da1;let _0x4c6ba6={'raw':![],'where':{'id':_0xfda4da[_0x5241a9(0x256)]['id']}};const _0x112f2e={};return _0x112f2e[_0x5241a9(0x266)]=_[_0x5241a9(0x262)](db[_0x5241a9(0x214)][_0x5241a9(0x211)]),_0x112f2e[_0x5241a9(0x23a)]=_[_0x5241a9(0x262)](_0xfda4da[_0x5241a9(0x23a)]),_0x112f2e[_0x5241a9(0x215)]=_[_0x5241a9(0x24d)](_0x112f2e[_0x5241a9(0x266)],_0x112f2e[_0x5241a9(0x23a)]),_0x4c6ba6['attributes']=_[_0x5241a9(0x24d)](_0x112f2e[_0x5241a9(0x266)],qs['fields'](_0xfda4da[_0x5241a9(0x23a)][_0x5241a9(0x245)])),_0x4c6ba6[_0x5241a9(0x250)]=_0x4c6ba6[_0x5241a9(0x250)][_0x5241a9(0x24e)]?_0x4c6ba6['attributes']:_0x112f2e[_0x5241a9(0x266)],_0xfda4da[_0x5241a9(0x23a)]['includeAll']&&(_0x4c6ba6['include']=[{'all':!![]}]),_0x4c6ba6=_[_0x5241a9(0x234)]({},_0x4c6ba6,_0xfda4da[_0x5241a9(0x247)]),db[_0x5241a9(0x214)]['findOne'](_0x4c6ba6)['then'](handleEntityNotFound(_0x46454e,null))[_0x5241a9(0x23f)](respondWithResult(_0x46454e,null))['catch'](handleError(_0x46454e,null));},exports[a741_0x3b8da1(0x212)]=function(_0x338988,_0x5c9fdc){const _0x213046=a741_0x3b8da1;return db[_0x213046(0x214)][_0x213046(0x212)](_0x338988[_0x213046(0x230)],{})[_0x213046(0x23f)](function(_0x1ce965){const _0x3415f0=_0x213046,_0x1f67e8=_0x338988['user'][_0x3415f0(0x213)]({'plain':!![]});if(!_0x1f67e8)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1f67e8[_0x3415f0(0x219)]===_0x3415f0(0x22d)){const _0x6cc94b=_0x1ce965[_0x3415f0(0x213)]({'plain':!![]}),_0x231345=_0x3415f0(0x1f5);return db[_0x3415f0(0x252)][_0x3415f0(0x267)]({'where':{'name':_0x231345,'userProfileId':_0x1f67e8[_0x3415f0(0x218)]},'raw':!![]})[_0x3415f0(0x23f)](function(_0x562629){const _0x328223=_0x3415f0;return _0x562629&&_0x562629[_0x328223(0x21d)]===0x0?db['UserProfileResource'][_0x328223(0x212)]({'name':_0x6cc94b[_0x328223(0x205)],'resourceId':_0x6cc94b['id'],'type':_0x562629[_0x328223(0x205)],'sectionId':_0x562629['id']},{})[_0x328223(0x23f)](function(){return _0x1ce965;}):_0x1ce965;})[_0x3415f0(0x221)](function(_0x248703){const _0x3173fc=_0x3415f0;logger[_0x3173fc(0x226)](_0x3173fc(0x1fe),_0x248703);throw _0x248703;});}return _0x1ce965;})[_0x213046(0x23f)](respondWithResult(_0x5c9fdc,0xc9))[_0x213046(0x221)](handleError(_0x5c9fdc,null));},exports[a741_0x3b8da1(0x22e)]=function(_0x1d8d1d,_0x24571e){const _0x122c06=a741_0x3b8da1;return _0x1d8d1d[_0x122c06(0x230)]['id']&&delete _0x1d8d1d['body']['id'],db[_0x122c06(0x214)]['findOne']({'where':{'id':_0x1d8d1d[_0x122c06(0x256)]['id']}})[_0x122c06(0x23f)](handleEntityNotFound(_0x24571e,null))[_0x122c06(0x23f)](saveUpdates(_0x1d8d1d['body'],null))['then'](respondWithResult(_0x24571e,null))[_0x122c06(0x221)](handleError(_0x24571e,null));},exports[a741_0x3b8da1(0x243)]=function(_0x3cb478,_0x52a8b4){const _0x107f27=a741_0x3b8da1;return db[_0x107f27(0x214)][_0x107f27(0x267)]({'where':{'id':_0x3cb478[_0x107f27(0x256)]['id']}})[_0x107f27(0x23f)](handleEntityNotFound(_0x52a8b4,null))['then'](removeEntity(_0x52a8b4,null))[_0x107f27(0x221)](handleError(_0x52a8b4,null));},exports[a741_0x3b8da1(0x249)]=function(_0x39b88e,_0x1620f3){const _0x47e9fa=a741_0x3b8da1;return db[_0x47e9fa(0x214)][_0x47e9fa(0x267)]({'where':{'id':_0x39b88e['params']['id']}})[_0x47e9fa(0x23f)](handleEntityNotFound(_0x1620f3,null))[_0x47e9fa(0x23f)](function(_0x438b20){const _0x4529ad=_0x47e9fa;if(!_0x39b88e[_0x4529ad(0x23a)][_0x4529ad(0x224)]||!utils[_0x4529ad(0x227)](_0x39b88e[_0x4529ad(0x23a)][_0x4529ad(0x224)]))throw new ValidationError(_0x4529ad(0x20a));let _0x91455c={};const _0x4a605d={};return _0x4a605d[_0x4529ad(0x266)]=_[_0x4529ad(0x262)](db[_[_0x4529ad(0x208)](_0x39b88e[_0x4529ad(0x23a)][_0x4529ad(0x224)][_0x4529ad(0x20f)]())+'Queue']['rawAttributes']),_0x4a605d[_0x4529ad(0x23a)]=_[_0x4529ad(0x262)](_0x39b88e[_0x4529ad(0x23a)]),_0x4a605d[_0x4529ad(0x215)]=_[_0x4529ad(0x24d)](_0x4a605d['model'],_0x4a605d[_0x4529ad(0x23a)]),_0x91455c[_0x4529ad(0x250)]=_[_0x4529ad(0x24d)](_0x4a605d[_0x4529ad(0x266)],qs[_0x4529ad(0x245)](_0x39b88e[_0x4529ad(0x23a)][_0x4529ad(0x245)])),_0x91455c[_0x4529ad(0x250)]=_0x91455c[_0x4529ad(0x250)]['length']?_0x91455c[_0x4529ad(0x250)]:_0x4a605d[_0x4529ad(0x266)],_0x91455c[_0x4529ad(0x1f7)]=qs[_0x4529ad(0x1f7)](_0x39b88e[_0x4529ad(0x23a)][_0x4529ad(0x1f7)]),_0x91455c[_0x4529ad(0x263)]=qs[_0x4529ad(0x263)](_0x39b88e[_0x4529ad(0x23a)][_0x4529ad(0x263)]),_0x91455c[_0x4529ad(0x1f4)]=qs[_0x4529ad(0x1f8)](_0x39b88e[_0x4529ad(0x23a)][_0x4529ad(0x1f8)]),_0x91455c[_0x4529ad(0x21c)]=qs[_0x4529ad(0x215)](_[_0x4529ad(0x24c)](_0x39b88e['query'],_0x4a605d[_0x4529ad(0x215)])),_0x91455c=_['merge']({},_0x91455c,_0x39b88e[_0x4529ad(0x247)]),_0x438b20['get'+_[_0x4529ad(0x208)](_0x39b88e[_0x4529ad(0x23a)][_0x4529ad(0x224)][_0x4529ad(0x20f)]())+_0x4529ad(0x222)](_0x91455c);})[_0x47e9fa(0x23f)](respondWithResult(_0x1620f3,null))[_0x47e9fa(0x221)](handleError(_0x1620f3,null));},exports['addQueues']=function(_0x1e59bb,_0x224442){const _0x3f70f2=a741_0x3b8da1;return db[_0x3f70f2(0x214)][_0x3f70f2(0x267)]({'where':{'id':_0x1e59bb[_0x3f70f2(0x256)]['id']}})[_0x3f70f2(0x23f)](function(_0x315cc6){const _0x359c6d=_0x3f70f2;if(_0x315cc6){if(!_0x1e59bb['body'][_0x359c6d(0x224)]||!utils[_0x359c6d(0x227)](_0x1e59bb[_0x359c6d(0x230)][_0x359c6d(0x224)]))throw new ValidationError(_0x359c6d(0x20a));return _0x315cc6[_0x359c6d(0x233)+_['capitalize'](_0x1e59bb['body'][_0x359c6d(0x224)][_0x359c6d(0x20f)]())+_0x359c6d(0x222)](_0x1e59bb[_0x359c6d(0x230)][_0x359c6d(0x23c)]);}return null;})[_0x3f70f2(0x23f)](handleEntityNotFound(_0x224442,null))['then'](respondWithStatusCode(_0x224442,null))[_0x3f70f2(0x221)](handleError(_0x224442,null));},exports[a741_0x3b8da1(0x255)]=function(_0x52ee3f,_0x592033){const _0x257efc=a741_0x3b8da1;return db['Team'][_0x257efc(0x267)]({'where':{'id':_0x52ee3f['params']['id']}})[_0x257efc(0x23f)](function(_0x58aeb9){const _0x5b4f48=_0x257efc;if(_0x58aeb9){if(!_0x52ee3f[_0x5b4f48(0x23a)][_0x5b4f48(0x224)]||!utils[_0x5b4f48(0x227)](_0x52ee3f[_0x5b4f48(0x23a)][_0x5b4f48(0x224)]))throw new ValidationError(_0x5b4f48(0x20a));return _0x58aeb9[_0x5b4f48(0x25c)+_['capitalize'](_0x52ee3f[_0x5b4f48(0x23a)][_0x5b4f48(0x224)][_0x5b4f48(0x20f)]())+_0x5b4f48(0x222)](_0x52ee3f[_0x5b4f48(0x23a)][_0x5b4f48(0x23c)]);}return null;})['then'](handleEntityNotFound(_0x592033,null))[_0x257efc(0x23f)](respondWithStatusCode(_0x592033,null))[_0x257efc(0x221)](handleError(_0x592033,null));},exports[a741_0x3b8da1(0x220)]=function(_0x4d0574,_0x3fe5b5){const _0x532f1f=a741_0x3b8da1;return db['Team'][_0x532f1f(0x267)]({'where':{'id':_0x4d0574[_0x532f1f(0x256)]['id']}})[_0x532f1f(0x23f)](handleEntityNotFound(_0x3fe5b5,null))[_0x532f1f(0x23f)](function(_0x27b3fb){const _0x388be1=_0x532f1f;if(_0x27b3fb){const _0x4121ad=['Voice',_0x388be1(0x23e),_0x388be1(0x23b),_0x388be1(0x1fd),_0x388be1(0x1f6),_0x388be1(0x1fa),'Whatsapp'];return db[_0x388be1(0x244)][_0x388be1(0x235)](function(_0x1638bd){const _0x287374=_0x388be1,_0x3fe54e=_[_0x287374(0x20c)](_0x4121ad,function(_0x2122a0){const _0x4391f0=_0x287374,_0x27faac={'attributes':['id',_0x4391f0(0x205)]};return _0x2122a0===_0x4391f0(0x22f)&&(_0x27faac[_0x4391f0(0x25a)]={'attributes':[_0x4391f0(0x1f9)]}),_0x27b3fb[_0x4391f0(0x213)+_0x2122a0+_0x4391f0(0x222)](_0x27faac)[_0x4391f0(0x23f)](function(_0x5a261f){const _0x5af0af=_0x4391f0,_0x153017=_[_0x5af0af(0x20c)](_0x5a261f,function(_0x51f2a1){const _0x497ba1=_0x5af0af,_0x3b66c1=_[_0x497ba1(0x20c)](_0x4d0574[_0x497ba1(0x230)][_0x497ba1(0x23c)],function(_0x13ae0e){const _0x8c803=_0x497ba1,_0x59d141={'where':{'UserId':_0x13ae0e,[_0x2122a0+_0x8c803(0x25e)]:_0x51f2a1['id']},'transaction':_0x1638bd};return _0x2122a0===_0x8c803(0x22f)&&(_0x59d141[_0x8c803(0x264)]={'penalty':_0x51f2a1['TeamVoiceQueue'][_0x8c803(0x1f9)]}),db[_0x8c803(0x207)+_0x2122a0+'Queue'][_0x8c803(0x23d)](_0x59d141)[_0x8c803(0x23f)](function(){const _0x2ff5fd=_0x8c803;socket[_0x2ff5fd(0x265)]('user'+_0x2122a0+_0x2ff5fd(0x257),{'UserId':_0x13ae0e,[_0x2122a0+_0x2ff5fd(0x25e)]:_0x51f2a1['id']});if(_0x2122a0!=='Voice')return;return db[_0x2ff5fd(0x207)][_0x2ff5fd(0x21e)]({'where':{'id':_0x4d0574[_0x2ff5fd(0x230)]['ids'],'online':0x1},'attributes':['id',_0x2ff5fd(0x205),'online',_0x2ff5fd(0x1fc),_0x2ff5fd(0x200)],'raw':!![]})[_0x2ff5fd(0x23f)](function(_0x154376){const _0x59ae84=_0x2ff5fd,_0x26b8fe=_[_0x59ae84(0x20c)](_0x154376,function(_0xb7a891){const _0x3bf36d=_0x59ae84;return db[_0x3bf36d(0x20d)][_0x3bf36d(0x22a)]({'membername':_0xb7a891[_0x3bf36d(0x205)],'UserId':_0xb7a891['id'],'queue_name':_0x51f2a1[_0x3bf36d(0x205)],'VoiceQueueId':_0x51f2a1['id'],'interface':_[_0x3bf36d(0x20b)](_0xb7a891[_0x3bf36d(0x200)])?_0x3bf36d(0x202)+_0xb7a891[_0x3bf36d(0x205)]:_0xb7a891[_0x3bf36d(0x200)],'paused':_0xb7a891[_0x3bf36d(0x1fc)]||![],'penalty':_0x51f2a1[_0x3bf36d(0x236)]['penalty']},{'transaction':_0x1638bd});});return Promise[_0x59ae84(0x25d)](_0x26b8fe);});});});return Promise[_0x497ba1(0x25d)](_0x3b66c1);});return Promise[_0x5af0af(0x25d)](_0x153017);});});return Promise[_0x287374(0x25d)](_0x3fe54e)['then'](function(){const _0x5909ea=_0x287374;return _0x27b3fb['addAgents'](_0x4d0574[_0x5909ea(0x230)][_0x5909ea(0x23c)],{'transaction':_0x1638bd});});});}})['then'](respondWithResult(_0x3fe5b5,null))[_0x532f1f(0x221)](handleError(_0x3fe5b5,null));},exports[a741_0x3b8da1(0x223)]=function(_0x3114c8,_0x3ab44e){const _0x57e583=a741_0x3b8da1;return db[_0x57e583(0x214)][_0x57e583(0x267)]({'where':{'id':_0x3114c8['params']['id']}})['then'](handleEntityNotFound(_0x3ab44e,null))[_0x57e583(0x23f)](function(_0x1c821f){const _0x1e8da6=_0x57e583;if(_0x1c821f){const _0x5d2f9b=['Voice','Chat',_0x1e8da6(0x23b),_0x1e8da6(0x1fd),_0x1e8da6(0x1f6),_0x1e8da6(0x1fa),_0x1e8da6(0x241)];return db[_0x1e8da6(0x244)][_0x1e8da6(0x235)](function(_0x4a8af8){const _0x2d840c=_0x1e8da6,_0x298c60=_[_0x2d840c(0x20c)](_0x5d2f9b,function(_0x1c32dc){const _0x4d13cd=_0x2d840c,_0x2e92af={'attributes':['id',_0x4d13cd(0x205)]};return _0x1c821f[_0x4d13cd(0x213)+_0x1c32dc+_0x4d13cd(0x222)](_0x2e92af)['then'](function(_0x2d2d63){const _0x39053f=_0x4d13cd,_0x2a4b81=_[_0x39053f(0x20c)](_0x2d2d63,function(_0xcea578){const _0x17c49e=_0x39053f;return _0xcea578['removeAgents'](_0x3114c8['query'][_0x17c49e(0x23c)],{'transaction':_0x4a8af8})[_0x17c49e(0x23f)](function(){const _0x526e4e=_0x17c49e,_0x2c5773=JSON[_0x526e4e(0x238)]('['+_0x3114c8[_0x526e4e(0x23a)]['ids']+']'),_0x14f0d8=_[_0x526e4e(0x20c)](_0x2c5773,function(_0x50e204){const _0x3637a9=_0x526e4e;socket[_0x3637a9(0x265)](_0x3637a9(0x22d)+_0x1c32dc+_0x3637a9(0x21f),{'UserId':Number(_0x50e204),[_0x1c32dc+_0x3637a9(0x25e)]:_0xcea578['id']});if(_0x1c32dc!==_0x3637a9(0x22f))return;return db['UserVoiceQueueRt'][_0x3637a9(0x243)]({'where':{'VoiceQueueId':_0xcea578['id'],'UserId':_0x50e204},'transaction':_0x4a8af8});});return Promise[_0x526e4e(0x25d)](_0x14f0d8);});});return Promise[_0x39053f(0x25d)](_0x2a4b81);});});return Promise[_0x2d840c(0x25d)](_0x298c60)[_0x2d840c(0x23f)](function(){const _0x3b2032=_0x2d840c;return _0x1c821f[_0x3b2032(0x223)](_0x3114c8[_0x3b2032(0x23a)][_0x3b2032(0x23c)],{'transaction':_0x4a8af8});});});}})[_0x57e583(0x23f)](respondWithStatusCode(_0x3ab44e,null))['catch'](handleError(_0x3ab44e,null));},exports[a741_0x3b8da1(0x242)]=function(_0x115d4d,_0x4cf796){const _0x44ade4=a741_0x3b8da1;let _0xa04d93={};const _0x5aebfb={};let _0x3dd049,_0x1fc02c;return db[_0x44ade4(0x214)][_0x44ade4(0x267)]({'where':{'id':_0x115d4d[_0x44ade4(0x256)]['id']}})[_0x44ade4(0x23f)](handleEntityNotFound(_0x4cf796,null))[_0x44ade4(0x23f)](function(_0x422457){const _0x450467=_0x44ade4;if(_0x422457)return _0x3dd049=_0x422457,_0x5aebfb[_0x450467(0x266)]=_[_0x450467(0x262)](db[_0x450467(0x207)][_0x450467(0x211)]),_0x5aebfb[_0x450467(0x23a)]=_[_0x450467(0x262)](_0x115d4d[_0x450467(0x23a)]),_0x5aebfb[_0x450467(0x215)]=_[_0x450467(0x24d)](_0x5aebfb[_0x450467(0x266)],_0x5aebfb[_0x450467(0x23a)]),_0xa04d93[_0x450467(0x250)]=_[_0x450467(0x24d)](_0x5aebfb[_0x450467(0x266)],qs[_0x450467(0x245)](_0x115d4d[_0x450467(0x23a)][_0x450467(0x245)])),_0xa04d93['attributes']=_0xa04d93[_0x450467(0x250)][_0x450467(0x24e)]?_0xa04d93['attributes']:_0x5aebfb[_0x450467(0x266)],_0xa04d93[_0x450467(0x1f4)]=qs[_0x450467(0x1f8)](_0x115d4d[_0x450467(0x23a)][_0x450467(0x1f8)]),_0xa04d93[_0x450467(0x21c)]=qs['filters'](_[_0x450467(0x24c)](_0x115d4d[_0x450467(0x23a)],_0x5aebfb[_0x450467(0x215)])),_0xa04d93=filterAttributes(_0xa04d93,_0x115d4d[_0x450467(0x23a)][_0x450467(0x261)],_0xa04d93['attributes'],_0x115d4d[_0x450467(0x247)],![]),_0x3dd049[_0x450467(0x242)](_0xa04d93);})['then'](function(_0x4cb4db){const _0x2fa273=_0x44ade4;if(_0x4cb4db)return _0x1fc02c=_0x4cb4db[_0x2fa273(0x24e)],typeof _0x115d4d[_0x2fa273(0x23a)][_0x2fa273(0x22b)]===_0x2fa273(0x248)&&(_0xa04d93[_0x2fa273(0x1f7)]=qs[_0x2fa273(0x1f7)](_0x115d4d[_0x2fa273(0x23a)]['limit']),_0xa04d93[_0x2fa273(0x263)]=qs[_0x2fa273(0x263)](_0x115d4d['query'][_0x2fa273(0x263)])),_0x3dd049['getAgents'](_0xa04d93);})[_0x44ade4(0x23f)](function(_0x410143){if(_0x410143)return _0x410143?{'count':_0x1fc02c,'rows':_0x410143}:null;})[_0x44ade4(0x23f)](respondWithResult(_0x4cf796,null))[_0x44ade4(0x221)](handleError(_0x4cf796,null));};