Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / team / team.controller.js
index cd74b96..4d40182 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2f6b=['filter','merge','where','VIRTUAL','options','count','includeAll','include','catch','params','fields','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','getQueues','findOne','channel','Sequelize','Unknown\x20channel','capitalize','toLowerCase','Queue','Queues','addQueues','isValidChannel','ValidationError','add','ids','removeQueues','remove','Voice','Chat','Mail','Fax','Openchannel','Whatsapp','each','addAgents','User','findAll','online','voicePause','interface','UserVoiceQueueRt','upsert','isNil','format','SIP/%s','omit','spread','emit','userTeam:save','removeAgents','voice','chat','sms','fax','userTeam:remove','getAgents','hasOwnProperty','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','squel','jsforce','desk.js','querystring','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','./team.socket','register','sendStatus','status','end','offset','limit','set','Content-Range','json','apply','reject','update','then','destroy','get','error','stack','name','index','map','Team','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','length','nolimit','order','sort','pick'];(function(_0x105e3e,_0x4cb667){var _0x5b0125=function(_0x877866){while(--_0x877866){_0x105e3e['push'](_0x105e3e['shift']());}};_0x5b0125(++_0x4cb667);}(_0x2f6b,0xc8));var _0xb2f6=function(_0x1f4b18,_0x4e777c){_0x1f4b18=_0x1f4b18-0x0;var _0xde3957=_0x2f6b[_0x1f4b18];return _0xde3957;};'use strict';var pdf=require(_0xb2f6('0x0'));var emlformat=require(_0xb2f6('0x1'));var rimraf=require(_0xb2f6('0x2'));var zipdir=require(_0xb2f6('0x3'));var jsonpatch=require(_0xb2f6('0x4'));var rp=require('request-promise');var moment=require(_0xb2f6('0x5'));var BPromise=require(_0xb2f6('0x6'));var Mustache=require(_0xb2f6('0x7'));var util=require('util');var path=require(_0xb2f6('0x8'));var sox=require(_0xb2f6('0x9'));var csv=require(_0xb2f6('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xb2f6('0xb'));var crypto=require('crypto');var jsforce=require(_0xb2f6('0xc'));var deskjs=require(_0xb2f6('0xd'));var toCsv=require(_0xb2f6('0xa'));var querystring=require(_0xb2f6('0xe'));var Papa=require(_0xb2f6('0xf'));var Redis=require(_0xb2f6('0x10'));var authService=require(_0xb2f6('0x11'));var qs=require(_0xb2f6('0x12'));var as=require(_0xb2f6('0x13'));var hardwareService=require(_0xb2f6('0x14'));var logger=require(_0xb2f6('0x15'))(_0xb2f6('0x16'));var utils=require(_0xb2f6('0x17'));var config=require(_0xb2f6('0x18'));var licenseUtil=require(_0xb2f6('0x19'));var db=require(_0xb2f6('0x1a'))['db'];config[_0xb2f6('0x1b')]=_[_0xb2f6('0x1c')](config[_0xb2f6('0x1b')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb2f6('0x1b')]));require(_0xb2f6('0x1d'))[_0xb2f6('0x1e')](socket);function respondWithStatusCode(_0x1db366,_0x21885f){_0x21885f=_0x21885f||0xcc;return function(_0x180cfc){if(_0x180cfc){return _0x1db366[_0xb2f6('0x1f')](_0x21885f);}return _0x1db366[_0xb2f6('0x20')](_0x21885f)[_0xb2f6('0x21')]();};}function respondWithResult(_0x37a338,_0x4e0d05){_0x4e0d05=_0x4e0d05||0xc8;return function(_0x5c0b9b){if(_0x5c0b9b){return _0x37a338[_0xb2f6('0x20')](_0x4e0d05)['json'](_0x5c0b9b);}};}function respondWithFilteredResult(_0x3a05a5,_0x54160c){return function(_0x4f46da){if(_0x4f46da){var _0x41feae=_0x4f46da['count'],_0x3a4bbe=_0x54160c[_0xb2f6('0x22')],_0x510916=_0x54160c[_0xb2f6('0x22')]+_0x54160c[_0xb2f6('0x23')],_0x4eb51d;if(_0x510916>=_0x41feae){_0x510916=_0x41feae;_0x4eb51d=0xc8;}else{_0x4eb51d=0xce;}_0x3a05a5[_0xb2f6('0x20')](_0x4eb51d);return _0x3a05a5[_0xb2f6('0x24')](_0xb2f6('0x25'),_0x3a4bbe+'-'+_0x510916+'/'+_0x41feae)[_0xb2f6('0x26')](_0x4f46da);}return null;};}function patchUpdates(_0x2c6dfc){return function(_0x3ed91d){try{jsonpatch[_0xb2f6('0x27')](_0x3ed91d,_0x2c6dfc,!![]);}catch(_0x564baa){return BPromise[_0xb2f6('0x28')](_0x564baa);}return _0x3ed91d['save']();};}function saveUpdates(_0x5d7423,_0x3a7346){return function(_0x2f0420){if(_0x2f0420){return _0x2f0420[_0xb2f6('0x29')](_0x5d7423)[_0xb2f6('0x2a')](function(_0x5743d2){return _0x5743d2;});}return null;};}function removeEntity(_0x6af807,_0x51a18e){return function(_0x275f09){if(_0x275f09){return _0x275f09[_0xb2f6('0x2b')]()[_0xb2f6('0x2a')](function(){var _0x3ac668=_0x275f09[_0xb2f6('0x2c')]({'plain':!![]});var _0x463f9e='Teams';return db['UserProfileResource'][_0xb2f6('0x2b')]({'where':{'type':_0x463f9e,'resourceId':_0x3ac668['id']}})[_0xb2f6('0x2a')](function(){return _0x275f09;});})[_0xb2f6('0x2a')](function(){_0x6af807[_0xb2f6('0x20')](0xcc)[_0xb2f6('0x21')]();});}};}function handleEntityNotFound(_0x19dfd8,_0xd42bff){return function(_0x302817){if(!_0x302817){_0x19dfd8[_0xb2f6('0x1f')](0x194);}return _0x302817;};}function handleError(_0x545f94,_0x43dcb8){_0x43dcb8=_0x43dcb8||0x1f4;return function(_0x338c21){logger[_0xb2f6('0x2d')](_0x338c21[_0xb2f6('0x2e')]);if(_0x338c21[_0xb2f6('0x2f')]){delete _0x338c21[_0xb2f6('0x2f')];}_0x545f94[_0xb2f6('0x20')](_0x43dcb8)['send'](_0x338c21);};}exports[_0xb2f6('0x30')]=function(_0x26acdd,_0x2e9ca2){var _0x1dc599={},_0x5ebf57={},_0x2f2614={'count':0x0,'rows':[]};var _0x4779ec=_[_0xb2f6('0x31')](db[_0xb2f6('0x32')][_0xb2f6('0x33')],function(_0x251066){return{'name':_0x251066[_0xb2f6('0x34')],'type':_0x251066[_0xb2f6('0x35')][_0xb2f6('0x36')]};});_0x5ebf57[_0xb2f6('0x37')]=_[_0xb2f6('0x31')](_0x4779ec,'name');_0x5ebf57[_0xb2f6('0x38')]=_[_0xb2f6('0x39')](_0x26acdd[_0xb2f6('0x38')]);_0x5ebf57[_0xb2f6('0x3a')]=_['intersection'](_0x5ebf57['model'],_0x5ebf57[_0xb2f6('0x38')]);_0x1dc599['attributes']=_[_0xb2f6('0x3b')](_0x5ebf57[_0xb2f6('0x37')],qs['fields'](_0x26acdd[_0xb2f6('0x38')]['fields']));_0x1dc599['attributes']=_0x1dc599[_0xb2f6('0x3c')][_0xb2f6('0x3d')]?_0x1dc599[_0xb2f6('0x3c')]:_0x5ebf57[_0xb2f6('0x37')];if(!_0x26acdd[_0xb2f6('0x38')]['hasOwnProperty'](_0xb2f6('0x3e'))){_0x1dc599[_0xb2f6('0x23')]=qs[_0xb2f6('0x23')](_0x26acdd[_0xb2f6('0x38')][_0xb2f6('0x23')]);_0x1dc599[_0xb2f6('0x22')]=qs[_0xb2f6('0x22')](_0x26acdd[_0xb2f6('0x38')][_0xb2f6('0x22')]);}_0x1dc599[_0xb2f6('0x3f')]=qs[_0xb2f6('0x40')](_0x26acdd['query'][_0xb2f6('0x40')]);_0x1dc599['where']=qs['filters'](_[_0xb2f6('0x41')](_0x26acdd[_0xb2f6('0x38')],_0x5ebf57[_0xb2f6('0x3a')]),_0x4779ec);if(_0x26acdd[_0xb2f6('0x38')][_0xb2f6('0x42')]){_0x1dc599['where']=_[_0xb2f6('0x43')](_0x1dc599[_0xb2f6('0x44')],{'$or':_['map'](_0x4779ec,function(_0x5f0637){if(_0x5f0637['type']!==_0xb2f6('0x45')){var _0x3606c7={};_0x3606c7[_0x5f0637[_0xb2f6('0x2f')]]={'$like':'%'+_0x26acdd['query'][_0xb2f6('0x42')]+'%'};return _0x3606c7;}})});}_0x1dc599=_[_0xb2f6('0x43')]({},_0x1dc599,_0x26acdd[_0xb2f6('0x46')]);var _0x5484fc={'where':_0x1dc599[_0xb2f6('0x44')]};return db[_0xb2f6('0x32')]['count'](_0x5484fc)[_0xb2f6('0x2a')](function(_0x22c291){_0x2f2614[_0xb2f6('0x47')]=_0x22c291;if(_0x26acdd[_0xb2f6('0x38')][_0xb2f6('0x48')]){_0x1dc599[_0xb2f6('0x49')]=[{'all':!![]}];}return db[_0xb2f6('0x32')]['findAll'](_0x1dc599);})[_0xb2f6('0x2a')](function(_0x5b2323){_0x2f2614['rows']=_0x5b2323;return _0x2f2614;})[_0xb2f6('0x2a')](respondWithFilteredResult(_0x2e9ca2,_0x1dc599))[_0xb2f6('0x4a')](handleError(_0x2e9ca2,null));};exports['show']=function(_0x20b0d0,_0x1b4c53){var _0x506028={'raw':![],'where':{'id':_0x20b0d0[_0xb2f6('0x4b')]['id']}},_0x4d230b={};_0x4d230b['model']=_[_0xb2f6('0x39')](db['Team'][_0xb2f6('0x33')]);_0x4d230b['query']=_[_0xb2f6('0x39')](_0x20b0d0[_0xb2f6('0x38')]);_0x4d230b[_0xb2f6('0x3a')]=_[_0xb2f6('0x3b')](_0x4d230b[_0xb2f6('0x37')],_0x4d230b[_0xb2f6('0x38')]);_0x506028['attributes']=_[_0xb2f6('0x3b')](_0x4d230b[_0xb2f6('0x37')],qs[_0xb2f6('0x4c')](_0x20b0d0[_0xb2f6('0x38')][_0xb2f6('0x4c')]));_0x506028[_0xb2f6('0x3c')]=_0x506028[_0xb2f6('0x3c')][_0xb2f6('0x3d')]?_0x506028[_0xb2f6('0x3c')]:_0x4d230b[_0xb2f6('0x37')];if(_0x20b0d0[_0xb2f6('0x38')][_0xb2f6('0x48')]){_0x506028[_0xb2f6('0x49')]=[{'all':!![]}];}_0x506028=_['merge']({},_0x506028,_0x20b0d0[_0xb2f6('0x46')]);return db[_0xb2f6('0x32')]['find'](_0x506028)[_0xb2f6('0x2a')](handleEntityNotFound(_0x1b4c53,null))[_0xb2f6('0x2a')](respondWithResult(_0x1b4c53,null))[_0xb2f6('0x4a')](handleError(_0x1b4c53,null));};exports[_0xb2f6('0x4d')]=function(_0x56b870,_0xc6a967){return db[_0xb2f6('0x32')][_0xb2f6('0x4d')](_0x56b870['body'],{})[_0xb2f6('0x2a')](function(_0x37356d){var _0x53e283=_0x56b870[_0xb2f6('0x4e')]['get']({'plain':!![]});if(!_0x53e283)throw new Error(_0xb2f6('0x4f'));if(_0x53e283[_0xb2f6('0x50')]===_0xb2f6('0x4e')){var _0x4efd01=_0x37356d[_0xb2f6('0x2c')]({'plain':!![]});var _0x54ca5a='Teams';return db['UserProfileSection'][_0xb2f6('0x51')]({'where':{'name':_0x54ca5a,'userProfileId':_0x53e283[_0xb2f6('0x52')]},'raw':!![]})[_0xb2f6('0x2a')](function(_0x21d7ac){if(_0x21d7ac&&_0x21d7ac[_0xb2f6('0x53')]===0x0){return db[_0xb2f6('0x54')][_0xb2f6('0x4d')]({'name':_0x4efd01['name'],'resourceId':_0x4efd01['id'],'type':_0x21d7ac[_0xb2f6('0x2f')],'sectionId':_0x21d7ac['id']},{})[_0xb2f6('0x2a')](function(){return _0x37356d;});}else{return _0x37356d;}})['catch'](function(_0x29ac6a){logger[_0xb2f6('0x2d')](_0xb2f6('0x55'),_0x29ac6a);throw _0x29ac6a;});}return _0x37356d;})['then'](respondWithResult(_0xc6a967,0xc9))[_0xb2f6('0x4a')](handleError(_0xc6a967,null));};exports[_0xb2f6('0x29')]=function(_0x4688e2,_0x138eba){if(_0x4688e2[_0xb2f6('0x56')]['id']){delete _0x4688e2[_0xb2f6('0x56')]['id'];}return db[_0xb2f6('0x32')][_0xb2f6('0x51')]({'where':{'id':_0x4688e2['params']['id']}})[_0xb2f6('0x2a')](handleEntityNotFound(_0x138eba,null))['then'](saveUpdates(_0x4688e2[_0xb2f6('0x56')],null))[_0xb2f6('0x2a')](respondWithResult(_0x138eba,null))[_0xb2f6('0x4a')](handleError(_0x138eba,null));};exports[_0xb2f6('0x2b')]=function(_0x5b0b05,_0x3f88bf){return db['Team'][_0xb2f6('0x51')]({'where':{'id':_0x5b0b05[_0xb2f6('0x4b')]['id']}})[_0xb2f6('0x2a')](handleEntityNotFound(_0x3f88bf,null))['then'](removeEntity(_0x3f88bf,null))[_0xb2f6('0x4a')](handleError(_0x3f88bf,null));};exports[_0xb2f6('0x57')]=function(_0x12f1d1,_0x57ed27,_0x4a1dd4){return db['Team'][_0xb2f6('0x58')]({'where':{'id':_0x12f1d1[_0xb2f6('0x4b')]['id']}})[_0xb2f6('0x2a')](handleEntityNotFound(_0x57ed27,null))['then'](function(_0x924644){if(!_0x12f1d1['query'][_0xb2f6('0x59')]||!utils['isValidChannel'](_0x12f1d1['query']['channel'])){throw new db[(_0xb2f6('0x5a'))]['ValidationError'](_0xb2f6('0x5b'));}var _0x53d1b6={};var _0x3486cc={};_0x3486cc[_0xb2f6('0x37')]=_[_0xb2f6('0x39')](db[_[_0xb2f6('0x5c')](_0x12f1d1[_0xb2f6('0x38')][_0xb2f6('0x59')][_0xb2f6('0x5d')]())+_0xb2f6('0x5e')][_0xb2f6('0x33')]);_0x3486cc['query']=_[_0xb2f6('0x39')](_0x12f1d1[_0xb2f6('0x38')]);_0x3486cc[_0xb2f6('0x3a')]=_[_0xb2f6('0x3b')](_0x3486cc[_0xb2f6('0x37')],_0x3486cc[_0xb2f6('0x38')]);_0x53d1b6[_0xb2f6('0x3c')]=_['intersection'](_0x3486cc[_0xb2f6('0x37')],qs[_0xb2f6('0x4c')](_0x12f1d1[_0xb2f6('0x38')]['fields']));_0x53d1b6[_0xb2f6('0x3c')]=_0x53d1b6[_0xb2f6('0x3c')][_0xb2f6('0x3d')]?_0x53d1b6[_0xb2f6('0x3c')]:_0x3486cc[_0xb2f6('0x37')];_0x53d1b6[_0xb2f6('0x23')]=qs[_0xb2f6('0x23')](_0x12f1d1['query'][_0xb2f6('0x23')]);_0x53d1b6[_0xb2f6('0x22')]=qs[_0xb2f6('0x22')](_0x12f1d1['query'][_0xb2f6('0x22')]);_0x53d1b6[_0xb2f6('0x3f')]=qs[_0xb2f6('0x40')](_0x12f1d1[_0xb2f6('0x38')][_0xb2f6('0x40')]);_0x53d1b6[_0xb2f6('0x44')]=qs[_0xb2f6('0x3a')](_[_0xb2f6('0x41')](_0x12f1d1[_0xb2f6('0x38')],_0x3486cc[_0xb2f6('0x3a')]));_0x53d1b6=_[_0xb2f6('0x43')]({},_0x53d1b6,_0x12f1d1[_0xb2f6('0x46')]);return _0x924644[_0xb2f6('0x2c')+_[_0xb2f6('0x5c')](_0x12f1d1['query'][_0xb2f6('0x59')][_0xb2f6('0x5d')]())+_0xb2f6('0x5f')](_0x53d1b6);})[_0xb2f6('0x2a')](respondWithResult(_0x57ed27,null))['catch'](handleError(_0x57ed27,null));};exports[_0xb2f6('0x60')]=function(_0x55795e,_0x37f7ad,_0x2943c2){return db[_0xb2f6('0x32')][_0xb2f6('0x58')]({'where':{'id':_0x55795e[_0xb2f6('0x4b')]['id']}})[_0xb2f6('0x2a')](function(_0xda7ad5){if(_0xda7ad5){if(!_0x55795e[_0xb2f6('0x56')]['channel']||!utils[_0xb2f6('0x61')](_0x55795e['body'][_0xb2f6('0x59')])){throw new db[(_0xb2f6('0x5a'))][(_0xb2f6('0x62'))](_0xb2f6('0x5b'));}return _0xda7ad5[_0xb2f6('0x63')+_[_0xb2f6('0x5c')](_0x55795e[_0xb2f6('0x56')][_0xb2f6('0x59')]['toLowerCase']())+_0xb2f6('0x5f')](_0x55795e['body'][_0xb2f6('0x64')]);}return null;})[_0xb2f6('0x2a')](handleEntityNotFound(_0x37f7ad,null))[_0xb2f6('0x2a')](respondWithStatusCode(_0x37f7ad,null))['catch'](handleError(_0x37f7ad,null));};exports[_0xb2f6('0x65')]=function(_0x5b723b,_0x1d1096,_0x4acb20){return db[_0xb2f6('0x32')][_0xb2f6('0x58')]({'where':{'id':_0x5b723b[_0xb2f6('0x4b')]['id']}})['then'](function(_0x4dffbb){if(_0x4dffbb){if(!_0x5b723b[_0xb2f6('0x38')]['channel']||!utils[_0xb2f6('0x61')](_0x5b723b['query']['channel'])){throw new db[(_0xb2f6('0x5a'))][(_0xb2f6('0x62'))](_0xb2f6('0x5b'));}return _0x4dffbb[_0xb2f6('0x66')+_[_0xb2f6('0x5c')](_0x5b723b[_0xb2f6('0x38')][_0xb2f6('0x59')][_0xb2f6('0x5d')]())+_0xb2f6('0x5f')](_0x5b723b[_0xb2f6('0x38')][_0xb2f6('0x64')]);}return null;})[_0xb2f6('0x2a')](handleEntityNotFound(_0x1d1096,null))[_0xb2f6('0x2a')](respondWithStatusCode(_0x1d1096,null))[_0xb2f6('0x4a')](handleError(_0x1d1096,null));};exports['addAgents']=function(_0x3e6ec4,_0x2a88ac,_0x1766e3){return db[_0xb2f6('0x32')][_0xb2f6('0x51')]({'where':{'id':_0x3e6ec4[_0xb2f6('0x4b')]['id']}})[_0xb2f6('0x2a')](handleEntityNotFound(_0x2a88ac,null))[_0xb2f6('0x2a')](function(_0x5c24ad){if(_0x5c24ad){var _0x109c70=[_0xb2f6('0x67'),_0xb2f6('0x68'),_0xb2f6('0x69'),'Sms',_0xb2f6('0x6a'),_0xb2f6('0x6b'),_0xb2f6('0x6c')];return BPromise[_0xb2f6('0x6d')](_0x109c70,function(_0x1ec736){return _0x5c24ad['get'+_0x1ec736+_0xb2f6('0x5f')]({'attributes':['id',_0xb2f6('0x2f')]})[_0xb2f6('0x2a')](function(_0x69add){return BPromise[_0xb2f6('0x6d')](_0x69add,function(_0x12f1fe){return _0x12f1fe[_0xb2f6('0x6e')](_0x3e6ec4[_0xb2f6('0x56')][_0xb2f6('0x64')])['then'](function(){if(_0x1ec736===_0xb2f6('0x67')){return db[_0xb2f6('0x6f')][_0xb2f6('0x70')]({'where':{'id':_0x3e6ec4[_0xb2f6('0x56')][_0xb2f6('0x64')]},'attributes':['id','name',_0xb2f6('0x71'),_0xb2f6('0x72'),_0xb2f6('0x73')],'raw':!![]})[_0xb2f6('0x2a')](function(_0x41fde3){return BPromise[_0xb2f6('0x6d')](_[_0xb2f6('0x42')](_0x41fde3,{'online':0x1}),function(_0x43714d){return db[_0xb2f6('0x74')][_0xb2f6('0x75')]({'membername':_0x43714d[_0xb2f6('0x2f')],'UserId':_0x43714d['id'],'queue_name':_0x12f1fe[_0xb2f6('0x2f')],'VoiceQueueId':_0x12f1fe['id'],'interface':_[_0xb2f6('0x76')](_0x43714d['interface'])?util[_0xb2f6('0x77')](_0xb2f6('0x78'),_0x43714d[_0xb2f6('0x2f')]):_0x43714d[_0xb2f6('0x73')],'paused':_0x43714d[_0xb2f6('0x72')]||![],'penalty':0x0});});});}});});})['then'](function(){return _0x5c24ad;});})['then'](function(){return _0x5c24ad;});}})[_0xb2f6('0x2a')](function(_0x1a5043){if(_0x1a5043){return _0x1a5043[_0xb2f6('0x6e')](_0x3e6ec4[_0xb2f6('0x56')][_0xb2f6('0x64')],_[_0xb2f6('0x79')](_0x3e6ec4[_0xb2f6('0x56')],['ids','id'])||{})[_0xb2f6('0x7a')](function(_0x81b34d){for(var _0x3e8f64=0x0;_0x3e8f64<_0x3e6ec4[_0xb2f6('0x56')][_0xb2f6('0x64')][_0xb2f6('0x3d')];_0x3e8f64+=0x1){socket[_0xb2f6('0x7b')](_0xb2f6('0x7c'),{'UserId':_0x3e6ec4[_0xb2f6('0x56')]['ids'][_0x3e8f64],'TeamId':_0x3e6ec4['params']['id']});}return _0x81b34d;});}})['then'](respondWithResult(_0x2a88ac,null))[_0xb2f6('0x4a')](handleError(_0x2a88ac,null));};exports[_0xb2f6('0x7d')]=function(_0x3e075a,_0x2bea56,_0x398a00){return db[_0xb2f6('0x32')][_0xb2f6('0x51')]({'where':{'id':_0x3e075a[_0xb2f6('0x4b')]['id']}})['then'](handleEntityNotFound(_0x2bea56,null))['then'](function(_0x33aef8){if(_0x33aef8){return BPromise[_0xb2f6('0x6d')]([_0xb2f6('0x7e'),_0xb2f6('0x7f'),'mail',_0xb2f6('0x80'),_0xb2f6('0x81'),'openchannel','whatsapp'],function(_0xabe1e9){return _0x33aef8[_0xb2f6('0x2c')+_[_0xb2f6('0x5c')](_0xabe1e9)+'Queues']({'attributes':['id',_0xb2f6('0x2f')]})[_0xb2f6('0x2a')](function(_0x5c975b){return BPromise[_0xb2f6('0x6d')](_0x5c975b,function(_0x5339c8){return _0x5339c8[_0xb2f6('0x7d')](_0x3e075a[_0xb2f6('0x38')][_0xb2f6('0x64')])[_0xb2f6('0x2a')](function(){if(_0xabe1e9===_0xb2f6('0x7e')){return db[_0xb2f6('0x74')][_0xb2f6('0x2b')]({'where':{'VoiceQueueId':_0x5339c8['id'],'UserId':_0x3e075a[_0xb2f6('0x38')][_0xb2f6('0x64')]}});}});});})[_0xb2f6('0x2a')](function(){return _0x33aef8;});})[_0xb2f6('0x2a')](function(){return _0x33aef8;});}})['then'](function(_0x3fa802){if(_0x3fa802){return _0x3fa802[_0xb2f6('0x7d')](_0x3e075a[_0xb2f6('0x38')]['ids'])['then'](function(){if(_['isArray'](_0x3e075a[_0xb2f6('0x38')][_0xb2f6('0x64')])){for(var _0x3cd123=0x0;_0x3cd123<_0x3e075a['query'][_0xb2f6('0x64')][_0xb2f6('0x3d')];_0x3cd123+=0x1){socket[_0xb2f6('0x7b')](_0xb2f6('0x82'),{'UserId':Number(_0x3e075a['query'][_0xb2f6('0x64')][_0x3cd123]),'TeamId':Number(_0x3e075a['params']['id'])});}}else{socket[_0xb2f6('0x7b')](_0xb2f6('0x82'),{'UserId':Number(_0x3e075a[_0xb2f6('0x38')]['ids']),'TeamId':Number(_0x3e075a[_0xb2f6('0x4b')]['id'])});}});}})[_0xb2f6('0x2a')](respondWithStatusCode(_0x2bea56,null))['catch'](handleError(_0x2bea56,null));};exports['getAgents']=function(_0x2f6875,_0x522b42,_0xcd61f6){var _0x41b217={};var _0x11c0ef={};var _0x1e3bc7;var _0x32907e;return db[_0xb2f6('0x32')]['findOne']({'where':{'id':_0x2f6875[_0xb2f6('0x4b')]['id']}})[_0xb2f6('0x2a')](handleEntityNotFound(_0x522b42,null))[_0xb2f6('0x2a')](function(_0x4aab1c){if(_0x4aab1c){_0x1e3bc7=_0x4aab1c;_0x11c0ef['model']=_[_0xb2f6('0x39')](db[_0xb2f6('0x6f')][_0xb2f6('0x33')]);_0x11c0ef[_0xb2f6('0x38')]=_[_0xb2f6('0x39')](_0x2f6875[_0xb2f6('0x38')]);_0x11c0ef[_0xb2f6('0x3a')]=_[_0xb2f6('0x3b')](_0x11c0ef['model'],_0x11c0ef[_0xb2f6('0x38')]);_0x41b217['attributes']=_[_0xb2f6('0x3b')](_0x11c0ef[_0xb2f6('0x37')],qs['fields'](_0x2f6875['query']['fields']));_0x41b217[_0xb2f6('0x3c')]=_0x41b217['attributes'][_0xb2f6('0x3d')]?_0x41b217[_0xb2f6('0x3c')]:_0x11c0ef['model'];_0x41b217[_0xb2f6('0x3f')]=qs[_0xb2f6('0x40')](_0x2f6875['query']['sort']);_0x41b217[_0xb2f6('0x44')]=qs[_0xb2f6('0x3a')](_[_0xb2f6('0x41')](_0x2f6875[_0xb2f6('0x38')],_0x11c0ef[_0xb2f6('0x3a')]));if(_0x2f6875['query'][_0xb2f6('0x42')]){_0x41b217['where']=_['merge'](_0x41b217[_0xb2f6('0x44')],{'$or':_['map'](_0x41b217[_0xb2f6('0x3c')],function(_0x13457e){var _0x8887af={};_0x8887af[_0x13457e]={'$like':'%'+_0x2f6875[_0xb2f6('0x38')][_0xb2f6('0x42')]+'%'};return _0x8887af;})});}_0x41b217=_['merge']({},_0x41b217,_0x2f6875[_0xb2f6('0x46')]);return _0x1e3bc7[_0xb2f6('0x83')](_0x41b217);}})[_0xb2f6('0x2a')](function(_0x1faac1){if(_0x1faac1){_0x32907e=_0x1faac1['length'];if(!_0x2f6875[_0xb2f6('0x38')][_0xb2f6('0x84')](_0xb2f6('0x3e'))){_0x41b217[_0xb2f6('0x23')]=qs[_0xb2f6('0x23')](_0x2f6875[_0xb2f6('0x38')][_0xb2f6('0x23')]);_0x41b217[_0xb2f6('0x22')]=qs[_0xb2f6('0x22')](_0x2f6875[_0xb2f6('0x38')][_0xb2f6('0x22')]);}return _0x1e3bc7['getAgents'](_0x41b217);}})[_0xb2f6('0x2a')](function(_0x18532b){if(_0x18532b){return _0x18532b?{'count':_0x32907e,'rows':_0x18532b}:null;}})[_0xb2f6('0x2a')](respondWithResult(_0x522b42,null))[_0xb2f6('0x4a')](handleError(_0x522b42,null));};
\ No newline at end of file
+var _0xf86c=['addQueues','Sequelize','Queues','ids','removeQueues','remove','Voice','Chat','Sms','Fax','Openchannel','Whatsapp','each','addAgents','User','online','voicePause','interface','UserVoiceQueueRt','upsert','isNil','SIP/%s','spread','emit','userTeam:save','removeAgents','voice','chat','sms','fax','openchannel','whatsapp','isArray','userTeam:remove','getAgents','html-pdf','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','count','offset','limit','set','apply','then','destroy','get','Teams','UserProfileResource','name','send','index','map','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','pick','filter','merge','type','options','Team','includeAll','include','findAll','rows','show','params','rawAttributes','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','getQueues','findOne','channel','isValidChannel','ValidationError','Unknown\x20channel','toLowerCase','Queue','sort','capitalize'];(function(_0x2db735,_0x5ddb29){var _0x445d0e=function(_0x571f5a){while(--_0x571f5a){_0x2db735['push'](_0x2db735['shift']());}};_0x445d0e(++_0x5ddb29);}(_0xf86c,0x11f));var _0xcf86=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xf86c[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xcf86('0x0'));var emlformat=require(_0xcf86('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xcf86('0x2'));var rp=require(_0xcf86('0x3'));var moment=require(_0xcf86('0x4'));var BPromise=require(_0xcf86('0x5'));var Mustache=require(_0xcf86('0x6'));var util=require(_0xcf86('0x7'));var path=require(_0xcf86('0x8'));var sox=require(_0xcf86('0x9'));var csv=require(_0xcf86('0xa'));var ejs=require(_0xcf86('0xb'));var fs=require('fs');var _=require(_0xcf86('0xc'));var squel=require('squel');var crypto=require(_0xcf86('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xcf86('0xe'));var toCsv=require(_0xcf86('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xcf86('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xcf86('0x10'));var as=require(_0xcf86('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xcf86('0x12'))('api');var utils=require(_0xcf86('0x13'));var config=require(_0xcf86('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xcf86('0x15'))['db'];config[_0xcf86('0x16')]=_['defaults'](config[_0xcf86('0x16')],{'host':_0xcf86('0x17'),'port':0x18eb});var socket=require(_0xcf86('0x18'))(new Redis(config[_0xcf86('0x16')]));require('./team.socket')[_0xcf86('0x19')](socket);function respondWithStatusCode(_0x10e253,_0x211aee){_0x211aee=_0x211aee||0xcc;return function(_0x1b8384){if(_0x1b8384){return _0x10e253[_0xcf86('0x1a')](_0x211aee);}return _0x10e253[_0xcf86('0x1b')](_0x211aee)[_0xcf86('0x1c')]();};}function respondWithResult(_0x348782,_0x51bd52){_0x51bd52=_0x51bd52||0xc8;return function(_0x1ccc97){if(_0x1ccc97){return _0x348782[_0xcf86('0x1b')](_0x51bd52)[_0xcf86('0x1d')](_0x1ccc97);}};}function respondWithFilteredResult(_0x43b07c,_0x27ff8f){return function(_0xa519d4){if(_0xa519d4){var _0x2d55c0=_0xa519d4[_0xcf86('0x1e')],_0x4f76c8=_0x27ff8f[_0xcf86('0x1f')],_0x10c2cd=_0x27ff8f[_0xcf86('0x1f')]+_0x27ff8f[_0xcf86('0x20')],_0x18e3a2;if(_0x10c2cd>=_0x2d55c0){_0x10c2cd=_0x2d55c0;_0x18e3a2=0xc8;}else{_0x18e3a2=0xce;}_0x43b07c['status'](_0x18e3a2);return _0x43b07c[_0xcf86('0x21')]('Content-Range',_0x4f76c8+'-'+_0x10c2cd+'/'+_0x2d55c0)[_0xcf86('0x1d')](_0xa519d4);}return null;};}function patchUpdates(_0xdcb271){return function(_0x4ed71c){try{jsonpatch[_0xcf86('0x22')](_0x4ed71c,_0xdcb271,!![]);}catch(_0x10b709){return BPromise['reject'](_0x10b709);}return _0x4ed71c['save']();};}function saveUpdates(_0x52c93a,_0x4e8658){return function(_0x3df226){if(_0x3df226){return _0x3df226['update'](_0x52c93a)[_0xcf86('0x23')](function(_0x293a4f){return _0x293a4f;});}return null;};}function removeEntity(_0x1aa1f3,_0x409b6c){return function(_0x328bc0){if(_0x328bc0){return _0x328bc0[_0xcf86('0x24')]()[_0xcf86('0x23')](function(){var _0x1ddc7d=_0x328bc0[_0xcf86('0x25')]({'plain':!![]});var _0x26929f=_0xcf86('0x26');return db[_0xcf86('0x27')][_0xcf86('0x24')]({'where':{'type':_0x26929f,'resourceId':_0x1ddc7d['id']}})[_0xcf86('0x23')](function(){return _0x328bc0;});})[_0xcf86('0x23')](function(){_0x1aa1f3[_0xcf86('0x1b')](0xcc)[_0xcf86('0x1c')]();});}};}function handleEntityNotFound(_0x21fd0e,_0x569977){return function(_0x28aef4){if(!_0x28aef4){_0x21fd0e['sendStatus'](0x194);}return _0x28aef4;};}function handleError(_0x11e458,_0x25a632){_0x25a632=_0x25a632||0x1f4;return function(_0x47229e){logger['error'](_0x47229e['stack']);if(_0x47229e['name']){delete _0x47229e[_0xcf86('0x28')];}_0x11e458['status'](_0x25a632)[_0xcf86('0x29')](_0x47229e);};}exports[_0xcf86('0x2a')]=function(_0x2dcfb8,_0x1fe869){var _0xb5323c={},_0x437b94={},_0x3097c7={'count':0x0,'rows':[]};var _0x5c8f96=_[_0xcf86('0x2b')](db['Team']['rawAttributes'],function(_0x3f16e7){return{'name':_0x3f16e7['fieldName'],'type':_0x3f16e7['type'][_0xcf86('0x2c')]};});_0x437b94[_0xcf86('0x2d')]=_[_0xcf86('0x2b')](_0x5c8f96,_0xcf86('0x28'));_0x437b94[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x2dcfb8['query']);_0x437b94[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x437b94[_0xcf86('0x2d')],_0x437b94[_0xcf86('0x2e')]);_0xb5323c[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x437b94[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x33')]));_0xb5323c['attributes']=_0xb5323c['attributes'][_0xcf86('0x34')]?_0xb5323c[_0xcf86('0x32')]:_0x437b94['model'];if(!_0x2dcfb8['query'][_0xcf86('0x35')](_0xcf86('0x36'))){_0xb5323c[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x2dcfb8['query'][_0xcf86('0x20')]);_0xb5323c[_0xcf86('0x1f')]=qs[_0xcf86('0x1f')](_0x2dcfb8['query'][_0xcf86('0x1f')]);}_0xb5323c[_0xcf86('0x37')]=qs['sort'](_0x2dcfb8[_0xcf86('0x2e')]['sort']);_0xb5323c[_0xcf86('0x38')]=qs['filters'](_[_0xcf86('0x39')](_0x2dcfb8[_0xcf86('0x2e')],_0x437b94[_0xcf86('0x30')]),_0x5c8f96);if(_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3a')]){_0xb5323c['where']=_[_0xcf86('0x3b')](_0xb5323c[_0xcf86('0x38')],{'$or':_[_0xcf86('0x2b')](_0x5c8f96,function(_0x5eee4e){if(_0x5eee4e[_0xcf86('0x3c')]!=='VIRTUAL'){var _0x21bb42={};_0x21bb42[_0x5eee4e[_0xcf86('0x28')]]={'$like':'%'+_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3a')]+'%'};return _0x21bb42;}})});}_0xb5323c=_[_0xcf86('0x3b')]({},_0xb5323c,_0x2dcfb8[_0xcf86('0x3d')]);var _0x5029e8={'where':_0xb5323c['where']};return db[_0xcf86('0x3e')][_0xcf86('0x1e')](_0x5029e8)[_0xcf86('0x23')](function(_0x480fdb){_0x3097c7[_0xcf86('0x1e')]=_0x480fdb;if(_0x2dcfb8[_0xcf86('0x2e')][_0xcf86('0x3f')]){_0xb5323c[_0xcf86('0x40')]=[{'all':!![]}];}return db[_0xcf86('0x3e')][_0xcf86('0x41')](_0xb5323c);})[_0xcf86('0x23')](function(_0x5966b6){_0x3097c7[_0xcf86('0x42')]=_0x5966b6;return _0x3097c7;})[_0xcf86('0x23')](respondWithFilteredResult(_0x1fe869,_0xb5323c))['catch'](handleError(_0x1fe869,null));};exports[_0xcf86('0x43')]=function(_0x33e92a,_0x27a089){var _0x18518b={'raw':![],'where':{'id':_0x33e92a[_0xcf86('0x44')]['id']}},_0x204fd5={};_0x204fd5[_0xcf86('0x2d')]=_[_0xcf86('0x2f')](db[_0xcf86('0x3e')][_0xcf86('0x45')]);_0x204fd5[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x33e92a[_0xcf86('0x2e')]);_0x204fd5[_0xcf86('0x30')]=_['intersection'](_0x204fd5[_0xcf86('0x2d')],_0x204fd5[_0xcf86('0x2e')]);_0x18518b[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x204fd5[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x33e92a[_0xcf86('0x2e')][_0xcf86('0x33')]));_0x18518b[_0xcf86('0x32')]=_0x18518b['attributes'][_0xcf86('0x34')]?_0x18518b[_0xcf86('0x32')]:_0x204fd5[_0xcf86('0x2d')];if(_0x33e92a[_0xcf86('0x2e')][_0xcf86('0x3f')]){_0x18518b['include']=[{'all':!![]}];}_0x18518b=_[_0xcf86('0x3b')]({},_0x18518b,_0x33e92a[_0xcf86('0x3d')]);return db[_0xcf86('0x3e')][_0xcf86('0x46')](_0x18518b)['then'](handleEntityNotFound(_0x27a089,null))['then'](respondWithResult(_0x27a089,null))[_0xcf86('0x47')](handleError(_0x27a089,null));};exports[_0xcf86('0x48')]=function(_0x138ead,_0x2392bd){return db[_0xcf86('0x3e')]['create'](_0x138ead[_0xcf86('0x49')],{})[_0xcf86('0x23')](function(_0x264f26){var _0x5d3b07=_0x138ead[_0xcf86('0x4a')][_0xcf86('0x25')]({'plain':!![]});if(!_0x5d3b07)throw new Error(_0xcf86('0x4b'));if(_0x5d3b07[_0xcf86('0x4c')]===_0xcf86('0x4a')){var _0x353b4a=_0x264f26[_0xcf86('0x25')]({'plain':!![]});var _0x2ddd87='Teams';return db['UserProfileSection'][_0xcf86('0x46')]({'where':{'name':_0x2ddd87,'userProfileId':_0x5d3b07[_0xcf86('0x4d')]},'raw':!![]})[_0xcf86('0x23')](function(_0x4a4008){if(_0x4a4008&&_0x4a4008['autoAssociation']===0x0){return db[_0xcf86('0x27')][_0xcf86('0x48')]({'name':_0x353b4a[_0xcf86('0x28')],'resourceId':_0x353b4a['id'],'type':_0x4a4008[_0xcf86('0x28')],'sectionId':_0x4a4008['id']},{})[_0xcf86('0x23')](function(){return _0x264f26;});}else{return _0x264f26;}})['catch'](function(_0x4bd781){logger[_0xcf86('0x4e')](_0xcf86('0x4f'),_0x4bd781);throw _0x4bd781;});}return _0x264f26;})[_0xcf86('0x23')](respondWithResult(_0x2392bd,0xc9))[_0xcf86('0x47')](handleError(_0x2392bd,null));};exports[_0xcf86('0x50')]=function(_0x424da,_0x27af8f){if(_0x424da[_0xcf86('0x49')]['id']){delete _0x424da[_0xcf86('0x49')]['id'];}return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x424da[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x27af8f,null))[_0xcf86('0x23')](saveUpdates(_0x424da[_0xcf86('0x49')],null))['then'](respondWithResult(_0x27af8f,null))[_0xcf86('0x47')](handleError(_0x27af8f,null));};exports[_0xcf86('0x24')]=function(_0x4a4403,_0x5487ab){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x4a4403[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x5487ab,null))[_0xcf86('0x23')](removeEntity(_0x5487ab,null))[_0xcf86('0x47')](handleError(_0x5487ab,null));};exports[_0xcf86('0x51')]=function(_0x3eb775,_0x315881,_0x78c63c){return db[_0xcf86('0x3e')][_0xcf86('0x52')]({'where':{'id':_0x3eb775[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x315881,null))[_0xcf86('0x23')](function(_0x284330){if(!_0x3eb775['query'][_0xcf86('0x53')]||!utils[_0xcf86('0x54')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')])){throw new db['Sequelize'][(_0xcf86('0x55'))](_0xcf86('0x56'));}var _0x2395f7={};var _0x10a79c={};_0x10a79c[_0xcf86('0x2d')]=_[_0xcf86('0x2f')](db[_['capitalize'](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')][_0xcf86('0x57')]())+_0xcf86('0x58')][_0xcf86('0x45')]);_0x10a79c[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x3eb775[_0xcf86('0x2e')]);_0x10a79c[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x10a79c[_0xcf86('0x2d')],_0x10a79c['query']);_0x2395f7[_0xcf86('0x32')]=_[_0xcf86('0x31')](_0x10a79c[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x3eb775[_0xcf86('0x2e')]['fields']));_0x2395f7['attributes']=_0x2395f7[_0xcf86('0x32')][_0xcf86('0x34')]?_0x2395f7[_0xcf86('0x32')]:_0x10a79c[_0xcf86('0x2d')];_0x2395f7[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x20')]);_0x2395f7['offset']=qs[_0xcf86('0x1f')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x1f')]);_0x2395f7[_0xcf86('0x37')]=qs[_0xcf86('0x59')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x59')]);_0x2395f7[_0xcf86('0x38')]=qs[_0xcf86('0x30')](_[_0xcf86('0x39')](_0x3eb775[_0xcf86('0x2e')],_0x10a79c[_0xcf86('0x30')]));_0x2395f7=_['merge']({},_0x2395f7,_0x3eb775[_0xcf86('0x3d')]);return _0x284330[_0xcf86('0x25')+_[_0xcf86('0x5a')](_0x3eb775[_0xcf86('0x2e')][_0xcf86('0x53')][_0xcf86('0x57')]())+'Queues'](_0x2395f7);})['then'](respondWithResult(_0x315881,null))['catch'](handleError(_0x315881,null));};exports[_0xcf86('0x5b')]=function(_0x550bc0,_0x2968b8,_0x57255c){return db[_0xcf86('0x3e')]['findOne']({'where':{'id':_0x550bc0['params']['id']}})[_0xcf86('0x23')](function(_0x2100f8){if(_0x2100f8){if(!_0x550bc0[_0xcf86('0x49')][_0xcf86('0x53')]||!utils['isValidChannel'](_0x550bc0[_0xcf86('0x49')][_0xcf86('0x53')])){throw new db[(_0xcf86('0x5c'))]['ValidationError'](_0xcf86('0x56'));}return _0x2100f8['add'+_[_0xcf86('0x5a')](_0x550bc0[_0xcf86('0x49')]['channel'][_0xcf86('0x57')]())+_0xcf86('0x5d')](_0x550bc0['body'][_0xcf86('0x5e')]);}return null;})[_0xcf86('0x23')](handleEntityNotFound(_0x2968b8,null))[_0xcf86('0x23')](respondWithStatusCode(_0x2968b8,null))['catch'](handleError(_0x2968b8,null));};exports[_0xcf86('0x5f')]=function(_0xf0e230,_0x450ad9,_0x559877){return db[_0xcf86('0x3e')][_0xcf86('0x52')]({'where':{'id':_0xf0e230[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](function(_0x4e2e1e){if(_0x4e2e1e){if(!_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x53')]||!utils[_0xcf86('0x54')](_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x53')])){throw new db[(_0xcf86('0x5c'))][(_0xcf86('0x55'))](_0xcf86('0x56'));}return _0x4e2e1e[_0xcf86('0x60')+_['capitalize'](_0xf0e230['query'][_0xcf86('0x53')][_0xcf86('0x57')]())+'Queues'](_0xf0e230[_0xcf86('0x2e')][_0xcf86('0x5e')]);}return null;})[_0xcf86('0x23')](handleEntityNotFound(_0x450ad9,null))[_0xcf86('0x23')](respondWithStatusCode(_0x450ad9,null))[_0xcf86('0x47')](handleError(_0x450ad9,null));};exports['addAgents']=function(_0x18e898,_0x11b629,_0x131d61){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x18e898['params']['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x11b629,null))[_0xcf86('0x23')](function(_0x2cb634){if(_0x2cb634){var _0x1fcb82=[_0xcf86('0x61'),_0xcf86('0x62'),'Mail',_0xcf86('0x63'),_0xcf86('0x64'),_0xcf86('0x65'),_0xcf86('0x66')];return BPromise[_0xcf86('0x67')](_0x1fcb82,function(_0x45e9ec){return _0x2cb634[_0xcf86('0x25')+_0x45e9ec+_0xcf86('0x5d')]({'attributes':['id',_0xcf86('0x28')]})[_0xcf86('0x23')](function(_0x15b521){return BPromise['each'](_0x15b521,function(_0x4c4a52){return _0x4c4a52[_0xcf86('0x68')](_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')])['then'](function(){if(_0x45e9ec==='Voice'){return db[_0xcf86('0x69')][_0xcf86('0x41')]({'where':{'id':_0x18e898['body']['ids']},'attributes':['id',_0xcf86('0x28'),_0xcf86('0x6a'),_0xcf86('0x6b'),_0xcf86('0x6c')],'raw':!![]})[_0xcf86('0x23')](function(_0x265802){return BPromise[_0xcf86('0x67')](_[_0xcf86('0x3a')](_0x265802,{'online':0x1}),function(_0x8d6a51){return db[_0xcf86('0x6d')][_0xcf86('0x6e')]({'membername':_0x8d6a51[_0xcf86('0x28')],'UserId':_0x8d6a51['id'],'queue_name':_0x4c4a52[_0xcf86('0x28')],'VoiceQueueId':_0x4c4a52['id'],'interface':_[_0xcf86('0x6f')](_0x8d6a51['interface'])?util['format'](_0xcf86('0x70'),_0x8d6a51[_0xcf86('0x28')]):_0x8d6a51[_0xcf86('0x6c')],'paused':_0x8d6a51[_0xcf86('0x6b')]||![],'penalty':0x0});});});}});});})[_0xcf86('0x23')](function(){return _0x2cb634;});})[_0xcf86('0x23')](function(){return _0x2cb634;});}})[_0xcf86('0x23')](function(_0x15d468){if(_0x15d468){return _0x15d468['addAgents'](_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')],_['omit'](_0x18e898[_0xcf86('0x49')],[_0xcf86('0x5e'),'id'])||{})[_0xcf86('0x71')](function(_0x54fda8){for(var _0xd2e31e=0x0;_0xd2e31e<_0x18e898[_0xcf86('0x49')][_0xcf86('0x5e')][_0xcf86('0x34')];_0xd2e31e+=0x1){socket[_0xcf86('0x72')](_0xcf86('0x73'),{'UserId':_0x18e898['body']['ids'][_0xd2e31e],'TeamId':_0x18e898[_0xcf86('0x44')]['id']});}return _0x54fda8;});}})[_0xcf86('0x23')](respondWithResult(_0x11b629,null))[_0xcf86('0x47')](handleError(_0x11b629,null));};exports[_0xcf86('0x74')]=function(_0x40fd1a,_0x45f981,_0x319346){return db[_0xcf86('0x3e')][_0xcf86('0x46')]({'where':{'id':_0x40fd1a[_0xcf86('0x44')]['id']}})['then'](handleEntityNotFound(_0x45f981,null))[_0xcf86('0x23')](function(_0x339856){if(_0x339856){return BPromise[_0xcf86('0x67')]([_0xcf86('0x75'),_0xcf86('0x76'),'mail',_0xcf86('0x77'),_0xcf86('0x78'),_0xcf86('0x79'),_0xcf86('0x7a')],function(_0x9ac1a5){return _0x339856[_0xcf86('0x25')+_[_0xcf86('0x5a')](_0x9ac1a5)+_0xcf86('0x5d')]({'attributes':['id',_0xcf86('0x28')]})[_0xcf86('0x23')](function(_0x5ffa59){return BPromise[_0xcf86('0x67')](_0x5ffa59,function(_0x467cc7){return _0x467cc7['removeAgents'](_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')])[_0xcf86('0x23')](function(){if(_0x9ac1a5===_0xcf86('0x75')){return db[_0xcf86('0x6d')][_0xcf86('0x24')]({'where':{'VoiceQueueId':_0x467cc7['id'],'UserId':_0x40fd1a[_0xcf86('0x2e')]['ids']}});}});});})['then'](function(){return _0x339856;});})[_0xcf86('0x23')](function(){return _0x339856;});}})[_0xcf86('0x23')](function(_0x2966b3){if(_0x2966b3){return _0x2966b3[_0xcf86('0x74')](_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')])[_0xcf86('0x23')](function(){if(_[_0xcf86('0x7b')](_0x40fd1a['query'][_0xcf86('0x5e')])){for(var _0xcab53a=0x0;_0xcab53a<_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')][_0xcf86('0x34')];_0xcab53a+=0x1){socket['emit'](_0xcf86('0x7c'),{'UserId':Number(_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')][_0xcab53a]),'TeamId':Number(_0x40fd1a['params']['id'])});}}else{socket['emit'](_0xcf86('0x7c'),{'UserId':Number(_0x40fd1a[_0xcf86('0x2e')][_0xcf86('0x5e')]),'TeamId':Number(_0x40fd1a[_0xcf86('0x44')]['id'])});}});}})[_0xcf86('0x23')](respondWithStatusCode(_0x45f981,null))['catch'](handleError(_0x45f981,null));};exports[_0xcf86('0x7d')]=function(_0x319ada,_0x457e08,_0x4cf4bf){var _0x31f519={};var _0x32b1e7={};var _0x3fc4ff;var _0x1b41f7;return db[_0xcf86('0x3e')]['findOne']({'where':{'id':_0x319ada[_0xcf86('0x44')]['id']}})[_0xcf86('0x23')](handleEntityNotFound(_0x457e08,null))[_0xcf86('0x23')](function(_0x11a059){if(_0x11a059){_0x3fc4ff=_0x11a059;_0x32b1e7['model']=_[_0xcf86('0x2f')](db[_0xcf86('0x69')][_0xcf86('0x45')]);_0x32b1e7[_0xcf86('0x2e')]=_[_0xcf86('0x2f')](_0x319ada[_0xcf86('0x2e')]);_0x32b1e7[_0xcf86('0x30')]=_[_0xcf86('0x31')](_0x32b1e7[_0xcf86('0x2d')],_0x32b1e7[_0xcf86('0x2e')]);_0x31f519[_0xcf86('0x32')]=_['intersection'](_0x32b1e7[_0xcf86('0x2d')],qs[_0xcf86('0x33')](_0x319ada[_0xcf86('0x2e')]['fields']));_0x31f519[_0xcf86('0x32')]=_0x31f519[_0xcf86('0x32')][_0xcf86('0x34')]?_0x31f519[_0xcf86('0x32')]:_0x32b1e7['model'];_0x31f519['order']=qs[_0xcf86('0x59')](_0x319ada[_0xcf86('0x2e')]['sort']);_0x31f519['where']=qs[_0xcf86('0x30')](_[_0xcf86('0x39')](_0x319ada['query'],_0x32b1e7['filters']));if(_0x319ada['query']['filter']){_0x31f519[_0xcf86('0x38')]=_['merge'](_0x31f519[_0xcf86('0x38')],{'$or':_[_0xcf86('0x2b')](_0x31f519['attributes'],function(_0x32b0b5){var _0x99972a={};_0x99972a[_0x32b0b5]={'$like':'%'+_0x319ada[_0xcf86('0x2e')][_0xcf86('0x3a')]+'%'};return _0x99972a;})});}_0x31f519=_[_0xcf86('0x3b')]({},_0x31f519,_0x319ada['options']);return _0x3fc4ff[_0xcf86('0x7d')](_0x31f519);}})[_0xcf86('0x23')](function(_0xbe67a8){if(_0xbe67a8){_0x1b41f7=_0xbe67a8[_0xcf86('0x34')];if(!_0x319ada[_0xcf86('0x2e')][_0xcf86('0x35')]('nolimit')){_0x31f519[_0xcf86('0x20')]=qs[_0xcf86('0x20')](_0x319ada[_0xcf86('0x2e')][_0xcf86('0x20')]);_0x31f519[_0xcf86('0x1f')]=qs['offset'](_0x319ada[_0xcf86('0x2e')][_0xcf86('0x1f')]);}return _0x3fc4ff[_0xcf86('0x7d')](_0x31f519);}})[_0xcf86('0x23')](function(_0x38aff2){if(_0x38aff2){return _0x38aff2?{'count':_0x1b41f7,'rows':_0x38aff2}:null;}})['then'](respondWithResult(_0x457e08,null))[_0xcf86('0x47')](handleError(_0x457e08,null));};
\ No newline at end of file