Built motion from commit (unavailable).|2.5.2
[motion2.git] / server / api / notification / notification.controller.js
index fd9ff59..8b6983a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xad37=['to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','redis','defaults','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','update','then','destroy','error','stack','name','sendNotification','body','hasOwnProperty','TemplateId','Sequelize','ValidationError','view','Missing\x20\x27view\x27\x20parameter','Missing\x20\x27recipients\x27\x20parameter','parse','recipients','Invalid\x20\x27recipients\x27\x20object','chatqueue','faxqueue','mailqueue','openchannelqueue','smsqueue','voicequeue','whatsappqueue','team','some','includes','model','Invalid\x20model\x20in\x20\x27recipients\x27\x20object','senderName','user','fullname','isEmpty','recipientsDescription','SenderId','recipientsId','sortBy','join','sequelize','transaction','Notification','create','beep','forEach','recipient','emit','notification:send','catch','text','Template','html','startCase','toLowerCase','ids','queue','replace','Queue','push','all','union','flatten','findOne','map','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox'];(function(_0x561430,_0x449efc){var _0x5a4964=function(_0x469c41){while(--_0x469c41){_0x561430['push'](_0x561430['shift']());}};_0x5a4964(++_0x449efc);}(_0xad37,0x18b));var _0x7ad3=function(_0x1d9f7f,_0xd01b44){_0x1d9f7f=_0x1d9f7f-0x0;var _0x4542ff=_0xad37[_0x1d9f7f];return _0x4542ff;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x7ad3('0x0'));var rimraf=require(_0x7ad3('0x1'));var zipdir=require(_0x7ad3('0x2'));var jsonpatch=require(_0x7ad3('0x3'));var rp=require('request-promise');var moment=require(_0x7ad3('0x4'));var BPromise=require(_0x7ad3('0x5'));var Mustache=require(_0x7ad3('0x6'));var util=require('util');var path=require(_0x7ad3('0x7'));var sox=require(_0x7ad3('0x8'));var csv=require(_0x7ad3('0x9'));var ejs=require(_0x7ad3('0xa'));var fs=require('fs');var _=require(_0x7ad3('0xb'));var squel=require(_0x7ad3('0xc'));var crypto=require(_0x7ad3('0xd'));var jsforce=require(_0x7ad3('0xe'));var deskjs=require(_0x7ad3('0xf'));var toCsv=require(_0x7ad3('0x9'));var querystring=require(_0x7ad3('0x10'));var Papa=require(_0x7ad3('0x11'));var Redis=require(_0x7ad3('0x12'));var authService=require(_0x7ad3('0x13'));var qs=require(_0x7ad3('0x14'));var as=require(_0x7ad3('0x15'));var hardwareService=require(_0x7ad3('0x16'));var logger=require(_0x7ad3('0x17'))('api');var utils=require(_0x7ad3('0x18'));var config=require(_0x7ad3('0x19'));var db=require('../../mysqldb')['db'];config[_0x7ad3('0x1a')]=_[_0x7ad3('0x1b')](config[_0x7ad3('0x1a')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x7ad3('0x1a')]));require('./notification.socket')['register'](socket);function respondWithStatusCode(_0x477a22,_0x51fde1){_0x51fde1=_0x51fde1||0xcc;return function(_0x472725){if(_0x472725){return _0x477a22[_0x7ad3('0x1c')](_0x51fde1);}return _0x477a22[_0x7ad3('0x1d')](_0x51fde1)[_0x7ad3('0x1e')]();};}function respondWithResult(_0x4b4373,_0x5525ff){_0x5525ff=_0x5525ff||0xc8;return function(_0x22a2b2){if(_0x22a2b2){return _0x4b4373[_0x7ad3('0x1d')](_0x5525ff)[_0x7ad3('0x1f')](_0x22a2b2);}};}function respondWithFilteredResult(_0x2c77f5,_0x155438){return function(_0x4e15da){if(_0x4e15da){var _0x37a6f4=_0x4e15da['count'],_0x97ad01=_0x155438['offset'],_0x3fb379=_0x155438[_0x7ad3('0x20')]+_0x155438[_0x7ad3('0x21')],_0x7b1be3;if(_0x3fb379>=_0x37a6f4){_0x3fb379=_0x37a6f4;_0x7b1be3=0xc8;}else{_0x7b1be3=0xce;}_0x2c77f5[_0x7ad3('0x1d')](_0x7b1be3);return _0x2c77f5[_0x7ad3('0x22')](_0x7ad3('0x23'),_0x97ad01+'-'+_0x3fb379+'/'+_0x37a6f4)['json'](_0x4e15da);}return null;};}function patchUpdates(_0x2d40a3){return function(_0x314c86){try{jsonpatch[_0x7ad3('0x24')](_0x314c86,_0x2d40a3,!![]);}catch(_0x32f626){return BPromise['reject'](_0x32f626);}return _0x314c86['save']();};}function saveUpdates(_0x58ce4f,_0x2d3cc0){return function(_0x4a3f41){if(_0x4a3f41){return _0x4a3f41[_0x7ad3('0x25')](_0x58ce4f)[_0x7ad3('0x26')](function(_0x23cd77){return _0x23cd77;});}return null;};}function removeEntity(_0xab510,_0x9fc13e){return function(_0x35a650){if(_0x35a650){return _0x35a650[_0x7ad3('0x27')]()[_0x7ad3('0x26')](function(){_0xab510[_0x7ad3('0x1d')](0xcc)[_0x7ad3('0x1e')]();});}};}function handleEntityNotFound(_0x2c1e72,_0x56fa61){return function(_0x55a7c0){if(!_0x55a7c0){_0x2c1e72[_0x7ad3('0x1c')](0x194);}return _0x55a7c0;};}function handleError(_0x5e67dd,_0xc03920){_0xc03920=_0xc03920||0x1f4;return function(_0x35d5c6){logger[_0x7ad3('0x28')](_0x35d5c6[_0x7ad3('0x29')]);if(_0x35d5c6[_0x7ad3('0x2a')]){delete _0x35d5c6[_0x7ad3('0x2a')];}_0x5e67dd[_0x7ad3('0x1d')](_0xc03920)['send'](_0x35d5c6);};}exports[_0x7ad3('0x2b')]=function(_0x3f3beb,_0x3b3a65,_0x51cc63){if(!_0x3f3beb[_0x7ad3('0x2c')][_0x7ad3('0x2d')]('text')&&!_0x3f3beb['body']['hasOwnProperty'](_0x7ad3('0x2e'))){throw new db[(_0x7ad3('0x2f'))][(_0x7ad3('0x30'))]('Must\x20specify\x20at\x20least\x20one\x20argument\x20for\x20\x27text\x27\x20or\x20\x27TemplateId\x27');}else{if(_0x3f3beb['body'][_0x7ad3('0x2d')](_0x7ad3('0x2e'))&&!_0x3f3beb[_0x7ad3('0x2c')][_0x7ad3('0x2d')](_0x7ad3('0x31'))){throw new db[(_0x7ad3('0x2f'))][(_0x7ad3('0x30'))](_0x7ad3('0x32'));}if(!_0x3f3beb[_0x7ad3('0x2c')][_0x7ad3('0x2d')]('recipients')){throw new db['Sequelize'][(_0x7ad3('0x30'))](_0x7ad3('0x33'));}else{try{var _0x53a3be=JSON[_0x7ad3('0x34')](_0x3f3beb[_0x7ad3('0x2c')][_0x7ad3('0x35')]);}catch(_0x3fe9e6){logger['error'](_0x3fe9e6);throw new db['Sequelize'][(_0x7ad3('0x30'))](_0x7ad3('0x36'));}var _0x2c6fab=[_0x7ad3('0x37'),_0x7ad3('0x38'),_0x7ad3('0x39'),_0x7ad3('0x3a'),_0x7ad3('0x3b'),_0x7ad3('0x3c'),_0x7ad3('0x3d'),_0x7ad3('0x3e'),'user'];if(_[_0x7ad3('0x3f')](_0x53a3be,function(_0x2fb6ee){return!_[_0x7ad3('0x40')](_0x2c6fab,_0x2fb6ee[_0x7ad3('0x41')]['toLowerCase']());})){throw new db[(_0x7ad3('0x2f'))]['ValidationError'](_0x7ad3('0x42'));}}}var _0x3d2dbe={};_0x3d2dbe[_0x7ad3('0x43')]=_0x3f3beb[_0x7ad3('0x2c')][_0x7ad3('0x2d')](_0x7ad3('0x43'))?_0x3f3beb['body'][_0x7ad3('0x43')]:_0x3f3beb[_0x7ad3('0x44')][_0x7ad3('0x45')];_0x3d2dbe['recipientsDescription']=_[_0x7ad3('0x46')](_0x3f3beb['body']['recipientsDescription'])?null:_0x3f3beb['body'][_0x7ad3('0x47')];_0x3d2dbe['beep']=_0x3f3beb[_0x7ad3('0x2c')]['beep']||![];_0x3d2dbe[_0x7ad3('0x48')]=_0x3f3beb[_0x7ad3('0x44')]['id'];return getContent(_0x3f3beb[_0x7ad3('0x2c')])[_0x7ad3('0x26')](function(_0x398c68){_0x3d2dbe[_0x7ad3('0x2c')]=_0x398c68;return getRecipients(_0x53a3be);})[_0x7ad3('0x26')](function(_0x1ecdaa){_0x3d2dbe[_0x7ad3('0x49')]=_[_0x7ad3('0x4a')](_0x1ecdaa)[_0x7ad3('0x4b')](',');return db[_0x7ad3('0x4c')][_0x7ad3('0x4d')](function(_0x5e685d){return db[_0x7ad3('0x4e')][_0x7ad3('0x4f')](_0x3d2dbe,{'raw':!![],'transaction':_0x5e685d})[_0x7ad3('0x26')](function(_0x31a744){var _0x6fdb9f={'sender':_0x3d2dbe['senderName'],'description':_0x3d2dbe['recipientsDescription'],'content':_0x3d2dbe['body'],'beep':_0x3d2dbe[_0x7ad3('0x50')]};_0x1ecdaa[_0x7ad3('0x51')](function(_0x358159){_0x6fdb9f[_0x7ad3('0x52')]=_0x358159;socket[_0x7ad3('0x53')](_0x7ad3('0x54'),_0x6fdb9f);});return _0x31a744;});});})[_0x7ad3('0x26')](respondWithResult(_0x3b3a65,0xc9))[_0x7ad3('0x55')](handleError(_0x3b3a65,null));};function getContent(_0x1ee2f8){return new BPromise(function(_0x252acf,_0x312671){if(_0x1ee2f8[_0x7ad3('0x56')]){_0x252acf(_0x1ee2f8[_0x7ad3('0x56')]);return;}return db[_0x7ad3('0x57')]['findOne']({'attributes':['html'],'where':{'id':_0x1ee2f8[_0x7ad3('0x2e')]},'raw':!![]})[_0x7ad3('0x26')](function(_0x5849cc){if(!_0x5849cc)throw new db[(_0x7ad3('0x2f'))][(_0x7ad3('0x30'))]('Invalid\x20\x27TemplateId\x27\x20parameter');var _0x228446=Mustache['render'](_0x5849cc[_0x7ad3('0x58')],_0x1ee2f8[_0x7ad3('0x31')]);_0x252acf(_0x228446);})[_0x7ad3('0x55')](function(_0x4bcfa6){_0x312671(_0x4bcfa6);});});}function getRecipients(_0x32ec9d){return new BPromise(function(_0xbe1838,_0x4c9180){var _0x5e5396=[];var _0x1ee3d7=[];_0x32ec9d[_0x7ad3('0x51')](function(_0x19f52a){var _0x1666c2=_[_0x7ad3('0x59')](_0x19f52a[_0x7ad3('0x41')][_0x7ad3('0x5a')]());if(_0x1666c2==='User'){_0x5e5396=_['union'](_0x5e5396,_0x19f52a[_0x7ad3('0x5b')]);}else{if(_[_0x7ad3('0x40')](_0x1666c2,_0x7ad3('0x5c')))_0x1666c2=_0x1666c2[_0x7ad3('0x5d')](_0x7ad3('0x5c'),_0x7ad3('0x5e'));_0x19f52a[_0x7ad3('0x5b')][_0x7ad3('0x51')](function(_0x50cdbd){_0x1ee3d7[_0x7ad3('0x5f')](getAgents(_0x1666c2,_0x50cdbd));});}});return BPromise[_0x7ad3('0x60')](_0x1ee3d7)[_0x7ad3('0x26')](function(_0x431b2d){_0x5e5396=_[_0x7ad3('0x61')](_0x5e5396,_[_0x7ad3('0x62')](_0x431b2d));_0xbe1838(_0x5e5396);})['catch'](function(_0x1006e8){_0x4c9180(_0x1006e8);});});}function getAgents(_0x1a8d17,_0x51d991){return new BPromise(function(_0x1ea052,_0x59a989){return db[_0x1a8d17][_0x7ad3('0x63')]({'where':{'id':_0x51d991}})[_0x7ad3('0x26')](function(_0x1e91db){return _0x1e91db['getAgents']({'attributes':['id'],'raw':!![]})[_0x7ad3('0x26')](function(_0x520132){var _0x5be168=_[_0x7ad3('0x64')](_0x520132,'id');_0x1ea052(_0x5be168);});})[_0x7ad3('0x55')](function(_0x1c1631){_0x59a989(_0x1c1631);});});}
\ No newline at end of file
+var _0x36e6=['sendStatus','status','end','count','offset','limit','Content-Range','apply','reject','save','update','then','destroy','name','body','hasOwnProperty','text','Sequelize','ValidationError','Must\x20specify\x20at\x20least\x20one\x20argument\x20for\x20\x27text\x27\x20or\x20\x27TemplateId\x27','Missing\x20\x27view\x27\x20parameter','recipients','parse','error','chatqueue','faxqueue','mailqueue','openchannelqueue','voicequeue','whatsappqueue','team','user','some','includes','model','toLowerCase','Invalid\x20model\x20in\x20\x27recipients\x27\x20object','senderName','fullname','recipientsDescription','isEmpty','beep','SenderId','recipientsId','join','sequelize','transaction','Notification','emit','catch','Template','findOne','html','Invalid\x20\x27TemplateId\x27\x20parameter','render','view','forEach','User','union','queue','replace','Queue','ids','all','getAgents','map','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','path','sox','lodash','squel','crypto','to-csv','querystring','../../components/auth/service','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./notification.socket','register'];(function(_0x3a5565,_0x334bdb){var _0x2c2574=function(_0x26ab73){while(--_0x26ab73){_0x3a5565['push'](_0x3a5565['shift']());}};_0x2c2574(++_0x334bdb);}(_0x36e6,0x1aa));var _0x636e=function(_0x3ab51d,_0x2fa01d){_0x3ab51d=_0x3ab51d-0x0;var _0x29a04e=_0x36e6[_0x3ab51d];return _0x29a04e;};'use strict';var pdf=require(_0x636e('0x0'));var emlformat=require(_0x636e('0x1'));var rimraf=require(_0x636e('0x2'));var zipdir=require(_0x636e('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x636e('0x4'));var moment=require(_0x636e('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x636e('0x6'));var sox=require(_0x636e('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x636e('0x8'));var squel=require(_0x636e('0x9'));var crypto=require(_0x636e('0xa'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x636e('0xb'));var querystring=require(_0x636e('0xc'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x636e('0xd'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x636e('0xe'))(_0x636e('0xf'));var utils=require('../../config/utils');var config=require(_0x636e('0x10'));var db=require(_0x636e('0x11'))['db'];config[_0x636e('0x12')]=_[_0x636e('0x13')](config['redis'],{'host':_0x636e('0x14'),'port':0x18eb});var socket=require(_0x636e('0x15'))(new Redis(config[_0x636e('0x12')]));require(_0x636e('0x16'))[_0x636e('0x17')](socket);function respondWithStatusCode(_0x343343,_0x216313){_0x216313=_0x216313||0xcc;return function(_0xa18901){if(_0xa18901){return _0x343343[_0x636e('0x18')](_0x216313);}return _0x343343[_0x636e('0x19')](_0x216313)[_0x636e('0x1a')]();};}function respondWithResult(_0x491d11,_0x4db7c9){_0x4db7c9=_0x4db7c9||0xc8;return function(_0x466be4){if(_0x466be4){return _0x491d11[_0x636e('0x19')](_0x4db7c9)['json'](_0x466be4);}};}function respondWithFilteredResult(_0x55748c,_0x32b331){return function(_0x3258db){if(_0x3258db){var _0x164953=_0x3258db[_0x636e('0x1b')],_0x1f1997=_0x32b331[_0x636e('0x1c')],_0x4c4193=_0x32b331[_0x636e('0x1c')]+_0x32b331[_0x636e('0x1d')],_0x3d2129;if(_0x4c4193>=_0x164953){_0x4c4193=_0x164953;_0x3d2129=0xc8;}else{_0x3d2129=0xce;}_0x55748c['status'](_0x3d2129);return _0x55748c['set'](_0x636e('0x1e'),_0x1f1997+'-'+_0x4c4193+'/'+_0x164953)['json'](_0x3258db);}return null;};}function patchUpdates(_0x2369e4){return function(_0x407c56){try{jsonpatch[_0x636e('0x1f')](_0x407c56,_0x2369e4,!![]);}catch(_0x1d1dea){return BPromise[_0x636e('0x20')](_0x1d1dea);}return _0x407c56[_0x636e('0x21')]();};}function saveUpdates(_0x30a070,_0xc2bef2){return function(_0x55f6fc){if(_0x55f6fc){return _0x55f6fc[_0x636e('0x22')](_0x30a070)[_0x636e('0x23')](function(_0x28d2f8){return _0x28d2f8;});}return null;};}function removeEntity(_0x1a5d01,_0x124ef9){return function(_0x150158){if(_0x150158){return _0x150158[_0x636e('0x24')]()[_0x636e('0x23')](function(){_0x1a5d01[_0x636e('0x19')](0xcc)[_0x636e('0x1a')]();});}};}function handleEntityNotFound(_0x4d9ee2,_0x134c18){return function(_0x50a450){if(!_0x50a450){_0x4d9ee2[_0x636e('0x18')](0x194);}return _0x50a450;};}function handleError(_0x31f72f,_0x16fbaf){_0x16fbaf=_0x16fbaf||0x1f4;return function(_0x63a389){logger['error'](_0x63a389['stack']);if(_0x63a389[_0x636e('0x25')]){delete _0x63a389[_0x636e('0x25')];}_0x31f72f[_0x636e('0x19')](_0x16fbaf)['send'](_0x63a389);};}exports['sendNotification']=function(_0x41986a,_0x23c43d,_0x14ceae){if(!_0x41986a[_0x636e('0x26')][_0x636e('0x27')](_0x636e('0x28'))&&!_0x41986a[_0x636e('0x26')][_0x636e('0x27')]('TemplateId')){throw new db[(_0x636e('0x29'))][(_0x636e('0x2a'))](_0x636e('0x2b'));}else{if(_0x41986a[_0x636e('0x26')][_0x636e('0x27')]('TemplateId')&&!_0x41986a[_0x636e('0x26')][_0x636e('0x27')]('view')){throw new db[(_0x636e('0x29'))][(_0x636e('0x2a'))](_0x636e('0x2c'));}if(!_0x41986a[_0x636e('0x26')][_0x636e('0x27')](_0x636e('0x2d'))){throw new db[(_0x636e('0x29'))][(_0x636e('0x2a'))]('Missing\x20\x27recipients\x27\x20parameter');}else{try{var _0x173f01=JSON[_0x636e('0x2e')](_0x41986a[_0x636e('0x26')]['recipients']);}catch(_0xd81da5){logger[_0x636e('0x2f')](_0xd81da5);throw new db[(_0x636e('0x29'))]['ValidationError']('Invalid\x20\x27recipients\x27\x20object');}var _0x3a700b=[_0x636e('0x30'),_0x636e('0x31'),_0x636e('0x32'),_0x636e('0x33'),'smsqueue',_0x636e('0x34'),_0x636e('0x35'),_0x636e('0x36'),_0x636e('0x37')];if(_[_0x636e('0x38')](_0x173f01,function(_0x353b18){return!_[_0x636e('0x39')](_0x3a700b,_0x353b18[_0x636e('0x3a')][_0x636e('0x3b')]());})){throw new db['Sequelize'][(_0x636e('0x2a'))](_0x636e('0x3c'));}}}var _0x5a1eef={};_0x5a1eef[_0x636e('0x3d')]=_0x41986a['body'][_0x636e('0x27')](_0x636e('0x3d'))?_0x41986a['body'][_0x636e('0x3d')]:_0x41986a[_0x636e('0x37')][_0x636e('0x3e')];_0x5a1eef[_0x636e('0x3f')]=_[_0x636e('0x40')](_0x41986a[_0x636e('0x26')][_0x636e('0x3f')])?null:_0x41986a['body']['recipientsDescription'];_0x5a1eef[_0x636e('0x41')]=_0x41986a[_0x636e('0x26')]['beep']||![];_0x5a1eef[_0x636e('0x42')]=_0x41986a[_0x636e('0x37')]['id'];return getContent(_0x41986a[_0x636e('0x26')])[_0x636e('0x23')](function(_0x47f180){_0x5a1eef[_0x636e('0x26')]=_0x47f180;return getRecipients(_0x173f01);})[_0x636e('0x23')](function(_0x2e58b2){_0x5a1eef[_0x636e('0x43')]=_['sortBy'](_0x2e58b2)[_0x636e('0x44')](',');return db[_0x636e('0x45')][_0x636e('0x46')](function(_0xf6fda0){return db[_0x636e('0x47')]['create'](_0x5a1eef,{'raw':!![],'transaction':_0xf6fda0})[_0x636e('0x23')](function(_0x2be537){var _0x5a8386={'sender':_0x5a1eef[_0x636e('0x3d')],'description':_0x5a1eef[_0x636e('0x3f')],'content':_0x5a1eef[_0x636e('0x26')],'beep':_0x5a1eef[_0x636e('0x41')]};_0x2e58b2['forEach'](function(_0x181a00){_0x5a8386['recipient']=_0x181a00;socket[_0x636e('0x48')]('notification:send',_0x5a8386);});return _0x2be537;});});})[_0x636e('0x23')](respondWithResult(_0x23c43d,0xc9))[_0x636e('0x49')](handleError(_0x23c43d,null));};function getContent(_0x464080){return new BPromise(function(_0x207862,_0x30609b){if(_0x464080[_0x636e('0x28')]){_0x207862(_0x464080[_0x636e('0x28')]);return;}return db[_0x636e('0x4a')][_0x636e('0x4b')]({'attributes':[_0x636e('0x4c')],'where':{'id':_0x464080['TemplateId']},'raw':!![]})['then'](function(_0x4b2264){if(!_0x4b2264)throw new db[(_0x636e('0x29'))][(_0x636e('0x2a'))](_0x636e('0x4d'));var _0x57c97f=Mustache[_0x636e('0x4e')](_0x4b2264[_0x636e('0x4c')],_0x464080[_0x636e('0x4f')]);_0x207862(_0x57c97f);})[_0x636e('0x49')](function(_0x241a30){_0x30609b(_0x241a30);});});}function getRecipients(_0x264238){return new BPromise(function(_0x278479,_0x54bdc8){var _0x569530=[];var _0x14db0f=[];_0x264238[_0x636e('0x50')](function(_0x4a29bc){var _0x344181=_['startCase'](_0x4a29bc[_0x636e('0x3a')][_0x636e('0x3b')]());if(_0x344181===_0x636e('0x51')){_0x569530=_[_0x636e('0x52')](_0x569530,_0x4a29bc['ids']);}else{if(_[_0x636e('0x39')](_0x344181,_0x636e('0x53')))_0x344181=_0x344181[_0x636e('0x54')](_0x636e('0x53'),_0x636e('0x55'));_0x4a29bc[_0x636e('0x56')][_0x636e('0x50')](function(_0x4c1b7c){_0x14db0f['push'](getAgents(_0x344181,_0x4c1b7c));});}});return BPromise[_0x636e('0x57')](_0x14db0f)[_0x636e('0x23')](function(_0x1407d4){_0x569530=_[_0x636e('0x52')](_0x569530,_['flatten'](_0x1407d4));_0x278479(_0x569530);})['catch'](function(_0x266aff){_0x54bdc8(_0x266aff);});});}function getAgents(_0x176300,_0x393724){return new BPromise(function(_0x3c9c98,_0x39fcd2){return db[_0x176300]['findOne']({'where':{'id':_0x393724}})[_0x636e('0x23')](function(_0x1a9a44){return _0x1a9a44[_0x636e('0x58')]({'attributes':['id'],'raw':!![]})[_0x636e('0x23')](function(_0x11d01b){var _0x3bd68c=_[_0x636e('0x59')](_0x11d01b,'id');_0x3c9c98(_0x3bd68c);});})['catch'](function(_0x436a9b){_0x39fcd2(_0x436a9b);});});}
\ No newline at end of file