Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / userNotification / userNotification.controller.js
index ab1e26b..2fb639d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x492f=['sequelize','transaction','forEach','recipient','findOne','Invalid\x20\x27TemplateId\x27\x20parameter','catch','startCase','model','toLowerCase','User','ids','queue','push','flatten','getAgents','map','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','redis','localhost','socket.io-emitter','./userNotification.socket','register','sendStatus','end','status','json','undefined','count','offset','limit','Content-Range','apply','reject','save','update','then','error','stack','name','send','sendUserNotification','body','text','hasOwnProperty','TemplateId','Sequelize','Must\x20specify\x20at\x20least\x20one\x20argument\x20for\x20\x27text\x27\x20or\x20\x27TemplateId\x27','view','recipients','Missing\x20\x27recipients\x27\x20parameter','parse','ValidationError','Invalid\x20\x27recipients\x27\x20object','mailqueue','openchannelqueue','smsqueue','whatsappqueue','team','some','includes','Invalid\x20model\x20in\x20\x27recipients\x27\x20object','senderName','user','fullname','recipientsDescription','isEmpty','beep','recipientsId','sortBy','join'];(function(_0x2a67fe,_0x295c09){var _0x57e726=function(_0x280573){while(--_0x280573){_0x2a67fe['push'](_0x2a67fe['shift']());}};_0x57e726(++_0x295c09);}(_0x492f,0x71));var _0xf492=function(_0x211236,_0x2465cb){_0x211236=_0x211236-0x0;var _0x152ea1=_0x492f[_0x211236];return _0x152ea1;};'use strict';var emlformat=require(_0xf492('0x0'));var rimraf=require(_0xf492('0x1'));var zipdir=require(_0xf492('0x2'));var jsonpatch=require(_0xf492('0x3'));var rp=require(_0xf492('0x4'));var moment=require(_0xf492('0x5'));var BPromise=require(_0xf492('0x6'));var Mustache=require(_0xf492('0x7'));var util=require(_0xf492('0x8'));var path=require(_0xf492('0x9'));var sox=require(_0xf492('0xa'));var csv=require(_0xf492('0xb'));var ejs=require(_0xf492('0xc'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf492('0xd'));var squel=require(_0xf492('0xe'));var crypto=require(_0xf492('0xf'));var jsforce=require('jsforce');var deskjs=require(_0xf492('0x10'));var toCsv=require(_0xf492('0xb'));var querystring=require(_0xf492('0x11'));var Papa=require('papaparse');var Redis=require(_0xf492('0x12'));var authService=require(_0xf492('0x13'));var qs=require(_0xf492('0x14'));var as=require(_0xf492('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf492('0x16'))('api');var utils=require(_0xf492('0x17'));var config=require(_0xf492('0x18'));var licenseUtil=require(_0xf492('0x19'));var db=require('../../mysqldb')['db'];config[_0xf492('0x1a')]=_['defaults'](config[_0xf492('0x1a')],{'host':_0xf492('0x1b'),'port':0x18eb});var socket=require(_0xf492('0x1c'))(new Redis(config['redis']));require(_0xf492('0x1d'))[_0xf492('0x1e')](socket);function respondWithStatusCode(_0x2ad70e,_0xda42d){_0xda42d=_0xda42d||0xcc;return function(_0x1ea04f){if(_0x1ea04f){return _0x2ad70e[_0xf492('0x1f')](_0xda42d);}return _0x2ad70e['status'](_0xda42d)[_0xf492('0x20')]();};}function respondWithResult(_0x3c5e46,_0x45c34e){_0x45c34e=_0x45c34e||0xc8;return function(_0x5420af){if(_0x5420af){return _0x3c5e46[_0xf492('0x21')](_0x45c34e)[_0xf492('0x22')](_0x5420af);}};}function respondWithFilteredResult(_0x45c3bb,_0x11c87b){return function(_0x2ec1db){if(_0x2ec1db){var _0x5890a8=typeof _0x11c87b['offset']===_0xf492('0x23')&&typeof _0x11c87b['limit']==='undefined';var _0x262a18=_0x2ec1db[_0xf492('0x24')];var _0x16eeee=_0x5890a8?0x0:_0x11c87b[_0xf492('0x25')];var _0x3b4b19=_0x5890a8?_0x2ec1db[_0xf492('0x24')]:_0x11c87b[_0xf492('0x25')]+_0x11c87b[_0xf492('0x26')];var _0x1394ba;if(_0x3b4b19>=_0x262a18){_0x3b4b19=_0x262a18;_0x1394ba=0xc8;}else{_0x1394ba=0xce;}_0x45c3bb[_0xf492('0x21')](_0x1394ba);return _0x45c3bb['set'](_0xf492('0x27'),_0x16eeee+'-'+_0x3b4b19+'/'+_0x262a18)['json'](_0x2ec1db);}return null;};}function patchUpdates(_0x5a80ae){return function(_0x1420d4){try{jsonpatch[_0xf492('0x28')](_0x1420d4,_0x5a80ae,!![]);}catch(_0x1f8e13){return BPromise[_0xf492('0x29')](_0x1f8e13);}return _0x1420d4[_0xf492('0x2a')]();};}function saveUpdates(_0x5ab86f,_0x33f091){return function(_0x2f4014){if(_0x2f4014){return _0x2f4014[_0xf492('0x2b')](_0x5ab86f)[_0xf492('0x2c')](function(_0x303b10){return _0x303b10;});}return null;};}function removeEntity(_0x4cdf75,_0x39963c){return function(_0x2d4b63){if(_0x2d4b63){return _0x2d4b63['destroy']()[_0xf492('0x2c')](function(){_0x4cdf75['status'](0xcc)[_0xf492('0x20')]();});}};}function handleEntityNotFound(_0xb56a4e,_0x1659a5){return function(_0x5aa8e5){if(!_0x5aa8e5){_0xb56a4e[_0xf492('0x1f')](0x194);}return _0x5aa8e5;};}function handleError(_0x2f2cf4,_0x1d4c16){_0x1d4c16=_0x1d4c16||0x1f4;return function(_0x499837){logger[_0xf492('0x2d')](_0x499837[_0xf492('0x2e')]);if(_0x499837[_0xf492('0x2f')]){delete _0x499837['name'];}_0x2f2cf4['status'](_0x1d4c16)[_0xf492('0x30')](_0x499837);};}exports[_0xf492('0x31')]=function(_0x1deee2,_0x41dc8a,_0x50c75f){if(!_0x1deee2[_0xf492('0x32')]['hasOwnProperty'](_0xf492('0x33'))&&!_0x1deee2[_0xf492('0x32')][_0xf492('0x34')](_0xf492('0x35'))){throw new db[(_0xf492('0x36'))]['ValidationError'](_0xf492('0x37'));}else{if(_0x1deee2[_0xf492('0x32')][_0xf492('0x34')](_0xf492('0x35'))&&!_0x1deee2[_0xf492('0x32')][_0xf492('0x34')](_0xf492('0x38'))){throw new db[(_0xf492('0x36'))]['ValidationError']('Missing\x20\x27view\x27\x20parameter');}if(!_0x1deee2[_0xf492('0x32')][_0xf492('0x34')](_0xf492('0x39'))){throw new db[(_0xf492('0x36'))]['ValidationError'](_0xf492('0x3a'));}else{try{var _0x2e90ff=JSON[_0xf492('0x3b')](_0x1deee2[_0xf492('0x32')][_0xf492('0x39')]);}catch(_0x44d6f0){logger[_0xf492('0x2d')](_0x44d6f0);throw new db[(_0xf492('0x36'))][(_0xf492('0x3c'))](_0xf492('0x3d'));}var _0x13b74a=['chatqueue','faxqueue',_0xf492('0x3e'),_0xf492('0x3f'),_0xf492('0x40'),'voicequeue',_0xf492('0x41'),_0xf492('0x42'),'user'];if(_[_0xf492('0x43')](_0x2e90ff,function(_0x5d5e45){return!_[_0xf492('0x44')](_0x13b74a,_0x5d5e45['model']['toLowerCase']());})){throw new db['Sequelize'][(_0xf492('0x3c'))](_0xf492('0x45'));}}}var _0x18d46d={};_0x18d46d[_0xf492('0x46')]=_0x1deee2[_0xf492('0x32')][_0xf492('0x34')](_0xf492('0x46'))?_0x1deee2['body'][_0xf492('0x46')]:_0x1deee2[_0xf492('0x47')][_0xf492('0x48')];_0x18d46d[_0xf492('0x49')]=_[_0xf492('0x4a')](_0x1deee2[_0xf492('0x32')][_0xf492('0x49')])?null:_0x1deee2[_0xf492('0x32')][_0xf492('0x49')];_0x18d46d[_0xf492('0x4b')]=_0x1deee2['body'][_0xf492('0x4b')]||![];_0x18d46d['SenderId']=_0x1deee2[_0xf492('0x47')]['id'];return getContent(_0x1deee2[_0xf492('0x32')])[_0xf492('0x2c')](function(_0x5504d8){_0x18d46d[_0xf492('0x32')]=_0x5504d8;return getRecipients(_0x2e90ff);})[_0xf492('0x2c')](function(_0x5d7a48){_0x18d46d[_0xf492('0x4c')]=_[_0xf492('0x4d')](_0x5d7a48)[_0xf492('0x4e')](',');return db[_0xf492('0x4f')][_0xf492('0x50')](function(_0x397247){return db['UserNotification']['create'](_0x18d46d,{'raw':!![],'transaction':_0x397247})[_0xf492('0x2c')](function(_0x290246){var _0x3b2cb7={'sender':_0x18d46d[_0xf492('0x46')],'description':_0x18d46d['recipientsDescription'],'content':_0x18d46d[_0xf492('0x32')],'beep':_0x18d46d[_0xf492('0x4b')]};_0x5d7a48[_0xf492('0x51')](function(_0x338404){_0x3b2cb7[_0xf492('0x52')]=_0x338404;socket['emit']('userNotification:send',_0x3b2cb7);});return _0x290246;});});})[_0xf492('0x2c')](respondWithResult(_0x41dc8a,0xc9))['catch'](handleError(_0x41dc8a,null));};function getContent(_0x11d63b){return new BPromise(function(_0xbbeacd,_0xff8b83){if(_0x11d63b[_0xf492('0x33')]){_0xbbeacd(_0x11d63b[_0xf492('0x33')]);return;}return db['Template'][_0xf492('0x53')]({'attributes':['html'],'where':{'id':_0x11d63b[_0xf492('0x35')]},'raw':!![]})[_0xf492('0x2c')](function(_0x24303c){if(!_0x24303c)throw new db[(_0xf492('0x36'))][(_0xf492('0x3c'))](_0xf492('0x54'));var _0x5e40e4=Mustache['render'](_0x24303c['html'],_0x11d63b[_0xf492('0x38')]);_0xbbeacd(_0x5e40e4);})[_0xf492('0x55')](function(_0x987c95){_0xff8b83(_0x987c95);});});}function getRecipients(_0x1d25d4){return new BPromise(function(_0x31f1d3,_0xf50e7e){var _0xd31ef1=[];var _0x543376=[];_0x1d25d4['forEach'](function(_0x2e8fa2){var _0x3bb88f=_[_0xf492('0x56')](_0x2e8fa2[_0xf492('0x57')][_0xf492('0x58')]());if(_0x3bb88f===_0xf492('0x59')){_0xd31ef1=_['union'](_0xd31ef1,_0x2e8fa2[_0xf492('0x5a')]);}else{if(_[_0xf492('0x44')](_0x3bb88f,'queue'))_0x3bb88f=_0x3bb88f['replace'](_0xf492('0x5b'),'Queue');_0x2e8fa2[_0xf492('0x5a')]['forEach'](function(_0x3096d7){_0x543376[_0xf492('0x5c')](getAgents(_0x3bb88f,_0x3096d7));});}});return BPromise['all'](_0x543376)[_0xf492('0x2c')](function(_0x1382db){_0xd31ef1=_['union'](_0xd31ef1,_[_0xf492('0x5d')](_0x1382db));_0x31f1d3(_0xd31ef1);})['catch'](function(_0x2104e4){_0xf50e7e(_0x2104e4);});});}function getAgents(_0x27c7e9,_0x214d60){return new BPromise(function(_0x4205dc,_0x42a76f){return db[_0x27c7e9][_0xf492('0x53')]({'where':{'id':_0x214d60}})[_0xf492('0x2c')](function(_0x304b3b){return _0x304b3b[_0xf492('0x5e')]({'attributes':['id'],'raw':!![]})['then'](function(_0x23e702){var _0x5b6afe=_[_0xf492('0x5f')](_0x23e702,'id');_0x4205dc(_0x5b6afe);});})['catch'](function(_0x2f313){_0x42a76f(_0x2f313);});});}
\ No newline at end of file
+var _0x17e0=['Invalid\x20\x27recipients\x27\x20object','chatqueue','faxqueue','mailqueue','openchannelqueue','smsqueue','voicequeue','whatsappqueue','team','user','some','includes','model','toLowerCase','Invalid\x20model\x20in\x20\x27recipients\x27\x20object','senderName','fullname','recipientsDescription','beep','SenderId','then','recipientsId','sortBy','join','sequelize','transaction','UserNotification','create','forEach','recipient','emit','Template','findOne','Invalid\x20\x27TemplateId\x27\x20parameter','render','html','catch','startCase','queue','push','union','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','offset','undefined','limit','count','set','reject','save','destroy','error','stack','name','send','body','text','TemplateId','Must\x20specify\x20at\x20least\x20one\x20argument\x20for\x20\x27text\x27\x20or\x20\x27TemplateId\x27','hasOwnProperty','view','Sequelize','Missing\x20\x27view\x27\x20parameter','recipients','ValidationError','Missing\x20\x27recipients\x27\x20parameter','parse'];(function(_0x5d5a55,_0x48b339){var _0xa0a1f7=function(_0x22c878){while(--_0x22c878){_0x5d5a55['push'](_0x5d5a55['shift']());}};_0xa0a1f7(++_0x48b339);}(_0x17e0,0x150));var _0x017e=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0x17e0[_0x42cae2];return _0x5f256f;};'use strict';var emlformat=require(_0x017e('0x0'));var rimraf=require(_0x017e('0x1'));var zipdir=require(_0x017e('0x2'));var jsonpatch=require(_0x017e('0x3'));var rp=require(_0x017e('0x4'));var moment=require(_0x017e('0x5'));var BPromise=require(_0x017e('0x6'));var Mustache=require(_0x017e('0x7'));var util=require(_0x017e('0x8'));var path=require(_0x017e('0x9'));var sox=require('sox');var csv=require(_0x017e('0xa'));var ejs=require(_0x017e('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x017e('0xc'));var crypto=require(_0x017e('0xd'));var jsforce=require(_0x017e('0xe'));var deskjs=require(_0x017e('0xf'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x017e('0x10'));var Redis=require(_0x017e('0x11'));var authService=require(_0x017e('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x017e('0x13'));var hardwareService=require(_0x017e('0x14'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x017e('0x15'));var licenseUtil=require(_0x017e('0x16'));var db=require(_0x017e('0x17'))['db'];config[_0x017e('0x18')]=_['defaults'](config['redis'],{'host':_0x017e('0x19'),'port':0x18eb});var socket=require(_0x017e('0x1a'))(new Redis(config[_0x017e('0x18')]));require('./userNotification.socket')[_0x017e('0x1b')](socket);function respondWithStatusCode(_0x4de10c,_0x264016){_0x264016=_0x264016||0xcc;return function(_0xac45c0){if(_0xac45c0){return _0x4de10c[_0x017e('0x1c')](_0x264016);}return _0x4de10c[_0x017e('0x1d')](_0x264016)[_0x017e('0x1e')]();};}function respondWithResult(_0x2b838d,_0x5c83ed){_0x5c83ed=_0x5c83ed||0xc8;return function(_0x3dc200){if(_0x3dc200){return _0x2b838d[_0x017e('0x1d')](_0x5c83ed)[_0x017e('0x1f')](_0x3dc200);}};}function respondWithFilteredResult(_0x27b3f4,_0x2b8c95){return function(_0x27c380){if(_0x27c380){var _0x3edabc=typeof _0x2b8c95[_0x017e('0x20')]===_0x017e('0x21')&&typeof _0x2b8c95[_0x017e('0x22')]===_0x017e('0x21');var _0x445dca=_0x27c380[_0x017e('0x23')];var _0x30a46e=_0x3edabc?0x0:_0x2b8c95[_0x017e('0x20')];var _0x4ffe66=_0x3edabc?_0x27c380[_0x017e('0x23')]:_0x2b8c95[_0x017e('0x20')]+_0x2b8c95['limit'];var _0x29ffbf;if(_0x4ffe66>=_0x445dca){_0x4ffe66=_0x445dca;_0x29ffbf=0xc8;}else{_0x29ffbf=0xce;}_0x27b3f4[_0x017e('0x1d')](_0x29ffbf);return _0x27b3f4[_0x017e('0x24')]('Content-Range',_0x30a46e+'-'+_0x4ffe66+'/'+_0x445dca)[_0x017e('0x1f')](_0x27c380);}return null;};}function patchUpdates(_0x162dd7){return function(_0x53b8e9){try{jsonpatch['apply'](_0x53b8e9,_0x162dd7,!![]);}catch(_0x2d9141){return BPromise[_0x017e('0x25')](_0x2d9141);}return _0x53b8e9[_0x017e('0x26')]();};}function saveUpdates(_0x2fbd6d,_0x1f268f){return function(_0x5aae13){if(_0x5aae13){return _0x5aae13['update'](_0x2fbd6d)['then'](function(_0x1b918e){return _0x1b918e;});}return null;};}function removeEntity(_0x2b591d,_0x1ff3d8){return function(_0x55143c){if(_0x55143c){return _0x55143c[_0x017e('0x27')]()['then'](function(){_0x2b591d[_0x017e('0x1d')](0xcc)[_0x017e('0x1e')]();});}};}function handleEntityNotFound(_0x3d7f31,_0x1255e7){return function(_0x5d0bf4){if(!_0x5d0bf4){_0x3d7f31[_0x017e('0x1c')](0x194);}return _0x5d0bf4;};}function handleError(_0x125854,_0x2a0196){_0x2a0196=_0x2a0196||0x1f4;return function(_0x389dea){logger[_0x017e('0x28')](_0x389dea[_0x017e('0x29')]);if(_0x389dea[_0x017e('0x2a')]){delete _0x389dea[_0x017e('0x2a')];}_0x125854[_0x017e('0x1d')](_0x2a0196)[_0x017e('0x2b')](_0x389dea);};}exports['sendUserNotification']=function(_0x1c4281,_0x3fed46,_0x69998){if(!_0x1c4281[_0x017e('0x2c')]['hasOwnProperty'](_0x017e('0x2d'))&&!_0x1c4281['body']['hasOwnProperty'](_0x017e('0x2e'))){throw new db['Sequelize']['ValidationError'](_0x017e('0x2f'));}else{if(_0x1c4281['body']['hasOwnProperty']('TemplateId')&&!_0x1c4281[_0x017e('0x2c')][_0x017e('0x30')](_0x017e('0x31'))){throw new db[(_0x017e('0x32'))]['ValidationError'](_0x017e('0x33'));}if(!_0x1c4281[_0x017e('0x2c')][_0x017e('0x30')](_0x017e('0x34'))){throw new db[(_0x017e('0x32'))][(_0x017e('0x35'))](_0x017e('0x36'));}else{try{var _0x2eb2ad=JSON[_0x017e('0x37')](_0x1c4281['body']['recipients']);}catch(_0x3d923c){logger['error'](_0x3d923c);throw new db[(_0x017e('0x32'))][(_0x017e('0x35'))](_0x017e('0x38'));}var _0x4ea32d=[_0x017e('0x39'),_0x017e('0x3a'),_0x017e('0x3b'),_0x017e('0x3c'),_0x017e('0x3d'),_0x017e('0x3e'),_0x017e('0x3f'),_0x017e('0x40'),_0x017e('0x41')];if(_[_0x017e('0x42')](_0x2eb2ad,function(_0x46b37c){return!_[_0x017e('0x43')](_0x4ea32d,_0x46b37c[_0x017e('0x44')][_0x017e('0x45')]());})){throw new db[(_0x017e('0x32'))][(_0x017e('0x35'))](_0x017e('0x46'));}}}var _0x295c58={};_0x295c58['senderName']=_0x1c4281['body']['hasOwnProperty']('senderName')?_0x1c4281['body'][_0x017e('0x47')]:_0x1c4281['user'][_0x017e('0x48')];_0x295c58['recipientsDescription']=_['isEmpty'](_0x1c4281[_0x017e('0x2c')][_0x017e('0x49')])?null:_0x1c4281[_0x017e('0x2c')]['recipientsDescription'];_0x295c58[_0x017e('0x4a')]=_0x1c4281[_0x017e('0x2c')][_0x017e('0x4a')]||![];_0x295c58[_0x017e('0x4b')]=_0x1c4281['user']['id'];return getContent(_0x1c4281[_0x017e('0x2c')])[_0x017e('0x4c')](function(_0x4d189f){_0x295c58[_0x017e('0x2c')]=_0x4d189f;return getRecipients(_0x2eb2ad);})['then'](function(_0x2edeb3){_0x295c58[_0x017e('0x4d')]=_[_0x017e('0x4e')](_0x2edeb3)[_0x017e('0x4f')](',');return db[_0x017e('0x50')][_0x017e('0x51')](function(_0x10bae0){return db[_0x017e('0x52')][_0x017e('0x53')](_0x295c58,{'raw':!![],'transaction':_0x10bae0})[_0x017e('0x4c')](function(_0x133cff){var _0xa6a0b0={'sender':_0x295c58[_0x017e('0x47')],'description':_0x295c58[_0x017e('0x49')],'content':_0x295c58[_0x017e('0x2c')],'beep':_0x295c58['beep']};_0x2edeb3[_0x017e('0x54')](function(_0x195efd){_0xa6a0b0[_0x017e('0x55')]=_0x195efd;socket[_0x017e('0x56')]('userNotification:send',_0xa6a0b0);});return _0x133cff;});});})[_0x017e('0x4c')](respondWithResult(_0x3fed46,0xc9))['catch'](handleError(_0x3fed46,null));};function getContent(_0x1114e5){return new BPromise(function(_0x345587,_0x22db0b){if(_0x1114e5[_0x017e('0x2d')]){_0x345587(_0x1114e5[_0x017e('0x2d')]);return;}return db[_0x017e('0x57')][_0x017e('0x58')]({'attributes':['html'],'where':{'id':_0x1114e5[_0x017e('0x2e')]},'raw':!![]})[_0x017e('0x4c')](function(_0x4d8455){if(!_0x4d8455)throw new db['Sequelize'][(_0x017e('0x35'))](_0x017e('0x59'));var _0x1f93c1=Mustache[_0x017e('0x5a')](_0x4d8455[_0x017e('0x5b')],_0x1114e5[_0x017e('0x31')]);_0x345587(_0x1f93c1);})[_0x017e('0x5c')](function(_0x3f0d1c){_0x22db0b(_0x3f0d1c);});});}function getRecipients(_0x54336b){return new BPromise(function(_0x2cd2e2,_0x34ea29){var _0x17a374=[];var _0x561337=[];_0x54336b[_0x017e('0x54')](function(_0x1611b2){var _0x123e2d=_[_0x017e('0x5d')](_0x1611b2[_0x017e('0x44')][_0x017e('0x45')]());if(_0x123e2d==='User'){_0x17a374=_['union'](_0x17a374,_0x1611b2['ids']);}else{if(_[_0x017e('0x43')](_0x123e2d,_0x017e('0x5e')))_0x123e2d=_0x123e2d['replace']('queue','Queue');_0x1611b2['ids']['forEach'](function(_0xe1164e){_0x561337[_0x017e('0x5f')](getAgents(_0x123e2d,_0xe1164e));});}});return BPromise['all'](_0x561337)[_0x017e('0x4c')](function(_0x4e2019){_0x17a374=_[_0x017e('0x60')](_0x17a374,_['flatten'](_0x4e2019));_0x2cd2e2(_0x17a374);})[_0x017e('0x5c')](function(_0x119e49){_0x34ea29(_0x119e49);});});}function getAgents(_0x4ff86,_0x509aec){return new BPromise(function(_0x4144af,_0x20ad9b){return db[_0x4ff86]['findOne']({'where':{'id':_0x509aec}})[_0x017e('0x4c')](function(_0x3f01a5){return _0x3f01a5[_0x017e('0x61')]({'attributes':['id'],'raw':!![]})[_0x017e('0x4c')](function(_0x27ab18){var _0x4adeae=_['map'](_0x27ab18,'id');_0x4144af(_0x4adeae);});})[_0x017e('0x5c')](function(_0x4f6ee2){_0x20ad9b(_0x4f6ee2);});});}
\ No newline at end of file