Built motion from commit (unavailable).|2.4.0
[motion2.git] / server / config / schedule / index.js
index 7935dfe..7454ba9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf1c7=['isBetween','startAt','endAt','stop\x20cron','exists','update','update\x20cron','run','cron-job-manager','jayson/promise','bluebird','../logger','../../mysqldb','../../api/analyticCustomReport/analyticCustomReport.controller','../../api/analyticDefaultReport/analyticDefaultReport.controller','http','info','Try\x20to\x20send\x20a\x20mail\x20to','MailAccount','Smtp','service','host','port','secure','authentication','auth','user','pass','format','name','email','bcc','subtractNumber','%s.%s','basename','savename','extname','zip','join','existsSync','Sent','message','text','Info\x20report:\x0a%s\x0aPlease\x20see\x20the\x20attachments\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20it.\x0a\x0a','stringify','Report\x20empty\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20this\x20email.\x0a\x0a','empty\x20file,\x20email\x20not\x20sent','request','SendMail','error','error\x20mail','email\x20sent','catch','data','isNil','subtractNumber\x20null\x20or\x20undefined','subtractUnit','subtractUnit\x20null\x20or\x20undefined','YYYY-MM-DD\x20HH:mm:ss','output','DefaultReportId','exec\x20defaul\x20report\x20id:%s','runReport','then','CustomReportId','findAll','jobs','map','toString','difference','length','stop','deleteJob','delete\x20cron','index','resolve','run\x20job','cron','active'];(function(_0x2c7dc6,_0x3c4ce0){var _0x10002b=function(_0x26f390){while(--_0x26f390){_0x2c7dc6['push'](_0x2c7dc6['shift']());}};_0x10002b(++_0x3c4ce0);}(_0xf1c7,0xf5));var _0x7f1c=function(_0x56916d,_0x37b935){_0x56916d=_0x56916d-0x0;var _0x2b7f1f=_0xf1c7[_0x56916d];return _0x2b7f1f;};'use strict';var fs=require('fs');var util=require('util');var path=require('path');var _=require('lodash');var moment=require('moment');var CronJobManager=require(_0x7f1c('0x0'));var jayson=require(_0x7f1c('0x1'));var BPromise=require(_0x7f1c('0x2'));var logger=require(_0x7f1c('0x3'))('schedule');var db=require(_0x7f1c('0x4'))['db'];var analyticCustomReportController=require(_0x7f1c('0x5'));var analyticDefaultReportController=require(_0x7f1c('0x6'));var client=jayson['client'][_0x7f1c('0x7')]({'port':0x232b});var manager=new CronJobManager();function handleSendEmail(_0x280fbe,_0x3617f1){return function(){logger[_0x7f1c('0x8')](_0x7f1c('0x9'),_0x280fbe['email']);var _0x5c5a22=!![];var _0x212785={'tls':{'rejectUnauthorized':![]}};if(_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0xb')]['service']){_0x212785[_0x7f1c('0xc')]=_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0xb')][_0x7f1c('0xc')];}else{_0x212785['host']=_0x280fbe['MailAccount'][_0x7f1c('0xb')][_0x7f1c('0xd')];_0x212785[_0x7f1c('0xe')]=_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0xb')][_0x7f1c('0xe')];_0x212785[_0x7f1c('0xf')]=_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0xb')]['secure'];}if(_0x280fbe['MailAccount']['Smtp'][_0x7f1c('0x10')]){_0x212785[_0x7f1c('0x11')]={'user':_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0xb')][_0x7f1c('0x12')],'pass':_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0xb')][_0x7f1c('0x13')]};}var _0x450075={'account':_0x212785,'message':{'from':util[_0x7f1c('0x14')]('\x22%s\x22\x20<%s>',_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0x15')],_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0x16')]||_0x280fbe[_0x7f1c('0xa')][_0x7f1c('0xb')][_0x7f1c('0x12')]),'to':_0x280fbe['email'],'cc':_0x280fbe['cc'],'bcc':_0x280fbe[_0x7f1c('0x17')],'subject':util['format']('Report\x20%s\x20last\x20%s\x20%s',_0x3617f1[_0x7f1c('0x15')],_0x280fbe[_0x7f1c('0x18')],_0x280fbe['subtractUnit'])}};var _0x5e36cb=path['join'](__dirname,'../../files/reports');var _0x41f5cc=_0x3617f1['savename'];var _0x156b2c=util[_0x7f1c('0x14')](_0x7f1c('0x19'),path[_0x7f1c('0x1a')](_0x3617f1[_0x7f1c('0x1b')],path[_0x7f1c('0x1c')](_0x3617f1[_0x7f1c('0x1b')])),_0x7f1c('0x1d'));var _0x226be1=path['join'](_0x5e36cb,_0x41f5cc);var _0x12fa05=path[_0x7f1c('0x1e')](_0x5e36cb,_0x156b2c);if(fs[_0x7f1c('0x1f')](_0x226be1)){_0x3617f1['status']=_0x7f1c('0x20');_0x450075['message']['attachments']=[{'filename':_0x41f5cc,'path':_0x226be1}];_0x450075[_0x7f1c('0x21')][_0x7f1c('0x22')]=util[_0x7f1c('0x14')](_0x7f1c('0x23'),JSON[_0x7f1c('0x24')](_0x3617f1,null,0x2));}else if(fs['existsSync'](_0x12fa05)){_0x3617f1['status']=_0x7f1c('0x20');_0x450075[_0x7f1c('0x21')]['attachments']=[{'filename':_0x156b2c,'path':_0x12fa05}];}else{_0x450075[_0x7f1c('0x21')][_0x7f1c('0x22')]=_0x7f1c('0x25');if(!_0x280fbe['sendIfEmpty']){_0x5c5a22=![];logger['info'](_0x7f1c('0x26'));}}if(_0x5c5a22){return client[_0x7f1c('0x27')](_0x7f1c('0x28'),_0x450075)['then'](function(_0x3b993b){if(_0x3b993b[_0x7f1c('0x29')]){return logger[_0x7f1c('0x29')](_0x7f1c('0x2a'),JSON[_0x7f1c('0x24')](_0x3b993b));}return logger[_0x7f1c('0x8')](_0x7f1c('0x2b'));})[_0x7f1c('0x2c')](function(_0x386ca9){return logger['error'](_0x7f1c('0x2a'),JSON[_0x7f1c('0x24')](_0x386ca9));});}};}function handleError(){return function(_0x50b3d9){return logger[_0x7f1c('0x29')](JSON[_0x7f1c('0x24')](_0x50b3d9));};}function handleResult(_0x497852){return function(_0xb0a3f1){logger[_0x7f1c('0x8')](_0x7f1c('0x2d'),JSON['stringify'](_0xb0a3f1));if(_0x497852[_0x7f1c('0xa')]&&_0x497852[_0x7f1c('0xa')][_0x7f1c('0xb')]&&!_[_0x7f1c('0x2e')](_0x497852['email'])){setTimeout(handleSendEmail(_0x497852,_0xb0a3f1),0x3c*0x3e8);}};}function handleJob(_0x41fdff){return function(){try{if(_[_0x7f1c('0x2e')](_0x41fdff[_0x7f1c('0x18')])){return logger[_0x7f1c('0x8')](_0x7f1c('0x2f'));}if(_['isNil'](_0x41fdff[_0x7f1c('0x30')])){return logger[_0x7f1c('0x8')](_0x7f1c('0x31'));}var _0x30515c={'startDate':moment()['subtract'](_0x41fdff[_0x7f1c('0x18')],_0x41fdff[_0x7f1c('0x30')])[_0x7f1c('0x14')](_0x7f1c('0x32')),'endDate':moment()[_0x7f1c('0x14')](_0x7f1c('0x32')),'type':'scheduled','output':_0x41fdff[_0x7f1c('0x33')],'name':_0x41fdff[_0x7f1c('0x15')]};if(!_['isNil'](_0x41fdff[_0x7f1c('0x34')])){logger[_0x7f1c('0x8')](_0x7f1c('0x35'),_0x41fdff['DefaultReportId']);return analyticDefaultReportController[_0x7f1c('0x36')]({'id':_0x41fdff[_0x7f1c('0x34')]},_0x30515c)[_0x7f1c('0x37')](handleResult(_0x41fdff))[_0x7f1c('0x2c')](handleError());}if(!_['isNil'](_0x41fdff['CustomReportId'])){logger['info']('exec\x20custom\x20report\x20id:%s',_0x41fdff['CustomReportId']);return analyticCustomReportController[_0x7f1c('0x36')]({'id':_0x41fdff[_0x7f1c('0x38')]},_0x30515c)[_0x7f1c('0x37')](handleResult(_0x41fdff))[_0x7f1c('0x2c')](handleError());}}catch(_0x801ed6){logger[_0x7f1c('0x29')](JSON[_0x7f1c('0x24')](_0x801ed6));}return logger[_0x7f1c('0x8')]('no\x20report\x20id');};}function getJobs(_0x350965){var _0x1a5aa8={};if(_0x350965){_0x1a5aa8['id']=_0x350965;}return db['Schedule'][_0x7f1c('0x39')]({'where':_0x1a5aa8,'include':[{'model':db['MailAccount'],'attributes':['id',_0x7f1c('0x15'),_0x7f1c('0x16')],'include':[{'model':db['MailServerOut'],'as':_0x7f1c('0xb')}]}]})['then'](function(_0x262760){var _0x58f626=_['keys'](manager[_0x7f1c('0x3a')]);var _0x502091=_[_0x7f1c('0x3b')](_0x262760,function(_0x45b916){return _0x45b916['id'][_0x7f1c('0x3c')]();});var _0x238dda=_['keyBy'](_0x262760,function(_0x58da00){return _0x58da00['id'][_0x7f1c('0x3c')]();});var _0x5c271f=_0x350965?_0x502091:_[_0x7f1c('0x3d')](_0x502091,_0x58f626);var _0x28d86f=_['intersection'](_0x502091,_0x58f626);var _0xb8d8a4=_[_0x7f1c('0x3d')](_0x58f626,_0x502091);var _0x3939f6;var _0x5961e1;for(_0x3939f6=0x0;_0x3939f6<_0xb8d8a4[_0x7f1c('0x3e')]&&!_0x350965;_0x3939f6+=0x1){_0x5961e1=_0xb8d8a4[_0x3939f6][_0x7f1c('0x3c')]();if(manager['exists'](_0x5961e1)){manager[_0x7f1c('0x3f')](_0x5961e1);manager[_0x7f1c('0x40')](_0x5961e1);logger[_0x7f1c('0x8')](_0x7f1c('0x41'),_0x5961e1);}}logger[_0x7f1c('0x8')]('toRun',JSON[_0x7f1c('0x24')](_0x5c271f));for(_0x3939f6=0x0;_0x3939f6<_0x5c271f[_0x7f1c('0x3e')];_0x3939f6+=0x1){_0x5961e1=_0x5c271f[_0x3939f6][_0x7f1c('0x3c')]();logger[_0x7f1c('0x8')](_0x7f1c('0x42'),_0x5961e1);if(_0x350965){logger[_0x7f1c('0x8')]('my\x20id',_0x350965);logger['info'](JSON[_0x7f1c('0x24')](_0x238dda[_0x5961e1]));BPromise[_0x7f1c('0x43')]()[_0x7f1c('0x37')](handleJob(_0x238dda[_0x5961e1]));logger[_0x7f1c('0x8')](_0x7f1c('0x44'),_0x238dda[_0x5961e1]['name'],_0x238dda[_0x5961e1][_0x7f1c('0x45')]);}else if(_0x238dda[_0x5961e1][_0x7f1c('0x45')]&&_0x238dda[_0x5961e1][_0x7f1c('0x46')]&&moment()[_0x7f1c('0x47')](_0x238dda[_0x5961e1][_0x7f1c('0x48')],_0x238dda[_0x5961e1][_0x7f1c('0x49')])){manager['add'](_0x5961e1,_0x238dda[_0x5961e1][_0x7f1c('0x45')],handleJob(_0x238dda[_0x5961e1]));manager['start'](_0x5961e1);logger['info']('add\x20cron',_0x238dda[_0x5961e1][_0x7f1c('0x15')],_0x238dda[_0x5961e1][_0x7f1c('0x45')]);}else if(manager['exists'](_0x5961e1)){manager[_0x7f1c('0x3f')](_0x5961e1);manager[_0x7f1c('0x40')](_0x5961e1);logger[_0x7f1c('0x8')](_0x7f1c('0x4a'),_0x238dda[_0x5961e1][_0x7f1c('0x15')],_0x238dda[_0x5961e1][_0x7f1c('0x45')]);}}for(_0x3939f6=0x0,_0x5961e1;_0x3939f6<_0x28d86f[_0x7f1c('0x3e')]&&!_0x350965;_0x3939f6+=0x1){_0x5961e1=_0x28d86f[_0x3939f6]['toString']();if(manager[_0x7f1c('0x4b')](_0x5961e1)){if(_0x238dda[_0x5961e1][_0x7f1c('0x45')]&&_0x238dda[_0x5961e1]['active']&&moment()['isBetween'](_0x238dda[_0x5961e1]['startAt'],_0x238dda[_0x5961e1][_0x7f1c('0x49')])){manager[_0x7f1c('0x4c')](_0x5961e1,_0x238dda[_0x5961e1][_0x7f1c('0x45')],handleJob(_0x238dda[_0x5961e1]));logger[_0x7f1c('0x8')](_0x7f1c('0x4d'),_0x238dda[_0x5961e1][_0x7f1c('0x15')],_0x238dda[_0x5961e1][_0x7f1c('0x45')]);}else{manager[_0x7f1c('0x3f')](_0x5961e1);manager[_0x7f1c('0x40')](_0x5961e1);logger['info'](_0x7f1c('0x4a'),_0x238dda[_0x5961e1]['name'],_0x238dda[_0x5961e1]['cron']);}}}})[_0x7f1c('0x2c')](function(_0x5a69d9){logger[_0x7f1c('0x29')](JSON[_0x7f1c('0x24')](_0x5a69d9));});}exports[_0x7f1c('0x4e')]=function(_0x4c67fb){return getJobs(_0x4c67fb);};exports['start']=function(){setInterval(function(){return getJobs();},0x3c*0x3e8);return getJobs();};
\ No newline at end of file
+var _0xba9f=['add','start','add\x20cron','stop\x20cron','update','update\x20cron','run','util','lodash','moment','cron-job-manager','schedule','../../mysqldb','../../api/analyticCustomReport/analyticCustomReport.controller','../../api/analyticDefaultReport/analyticDefaultReport.controller','client','http','info','Try\x20to\x20send\x20a\x20mail\x20to','email','MailAccount','service','Smtp','host','port','secure','authentication','auth','format','name','user','bcc','Report\x20%s\x20last\x20%s\x20%s','subtractUnit','join','../../files/reports','%s.%s','basename','savename','zip','status','Sent','message','attachments','text','Info\x20report:\x0a%s\x0aPlease\x20see\x20the\x20attachments\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20it.\x0a\x0a','Report\x20empty\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20this\x20email.\x0a\x0a','sendIfEmpty','empty\x20file,\x20email\x20not\x20sent','SendMail','then','error','error\x20mail','stringify','catch','data','isNil','subtractNumber','subtractNumber\x20null\x20or\x20undefined','subtractUnit\x20null\x20or\x20undefined','subtract','YYYY-MM-DD\x20HH:mm:ss','scheduled','output','exec\x20defaul\x20report\x20id:%s','DefaultReportId','runReport','CustomReportId','exec\x20custom\x20report\x20id:%s','no\x20report\x20id','Schedule','MailServerOut','map','toString','intersection','difference','length','exists','stop','deleteJob','delete\x20cron','my\x20id','resolve','run\x20job','cron','active','isBetween','startAt','endAt'];(function(_0x200152,_0x2c9a47){var _0xdbba14=function(_0x349a75){while(--_0x349a75){_0x200152['push'](_0x200152['shift']());}};_0xdbba14(++_0x2c9a47);}(_0xba9f,0x16b));var _0xfba9=function(_0x285934,_0x7d493f){_0x285934=_0x285934-0x0;var _0x5b12bf=_0xba9f[_0x285934];return _0x5b12bf;};'use strict';var fs=require('fs');var util=require(_0xfba9('0x0'));var path=require('path');var _=require(_0xfba9('0x1'));var moment=require(_0xfba9('0x2'));var CronJobManager=require(_0xfba9('0x3'));var jayson=require('jayson/promise');var BPromise=require('bluebird');var logger=require('../logger')(_0xfba9('0x4'));var db=require(_0xfba9('0x5'))['db'];var analyticCustomReportController=require(_0xfba9('0x6'));var analyticDefaultReportController=require(_0xfba9('0x7'));var client=jayson[_0xfba9('0x8')][_0xfba9('0x9')]({'port':0x232b});var manager=new CronJobManager();function handleSendEmail(_0x377f5a,_0x170d25){return function(){logger[_0xfba9('0xa')](_0xfba9('0xb'),_0x377f5a[_0xfba9('0xc')]);var _0x17e0f4=!![];var _0x8dbd0={'tls':{'rejectUnauthorized':![]}};if(_0x377f5a[_0xfba9('0xd')]['Smtp'][_0xfba9('0xe')]){_0x8dbd0[_0xfba9('0xe')]=_0x377f5a[_0xfba9('0xd')][_0xfba9('0xf')][_0xfba9('0xe')];}else{_0x8dbd0[_0xfba9('0x10')]=_0x377f5a[_0xfba9('0xd')][_0xfba9('0xf')][_0xfba9('0x10')];_0x8dbd0[_0xfba9('0x11')]=_0x377f5a[_0xfba9('0xd')][_0xfba9('0xf')][_0xfba9('0x11')];_0x8dbd0[_0xfba9('0x12')]=_0x377f5a['MailAccount'][_0xfba9('0xf')][_0xfba9('0x12')];}if(_0x377f5a['MailAccount'][_0xfba9('0xf')][_0xfba9('0x13')]){_0x8dbd0[_0xfba9('0x14')]={'user':_0x377f5a[_0xfba9('0xd')][_0xfba9('0xf')]['user'],'pass':_0x377f5a['MailAccount'][_0xfba9('0xf')]['pass']};}var _0x20b7b2={'account':_0x8dbd0,'message':{'from':util[_0xfba9('0x15')]('\x22%s\x22\x20<%s>',_0x377f5a['MailAccount'][_0xfba9('0x16')],_0x377f5a[_0xfba9('0xd')][_0xfba9('0xc')]||_0x377f5a[_0xfba9('0xd')]['Smtp'][_0xfba9('0x17')]),'to':_0x377f5a[_0xfba9('0xc')],'cc':_0x377f5a['cc'],'bcc':_0x377f5a[_0xfba9('0x18')],'subject':util['format'](_0xfba9('0x19'),_0x170d25[_0xfba9('0x16')],_0x377f5a['subtractNumber'],_0x377f5a[_0xfba9('0x1a')])}};var _0x16ca51=path[_0xfba9('0x1b')](__dirname,_0xfba9('0x1c'));var _0x38b32d=_0x170d25['savename'];var _0x15f882=util['format'](_0xfba9('0x1d'),path[_0xfba9('0x1e')](_0x170d25['savename'],path['extname'](_0x170d25[_0xfba9('0x1f')])),_0xfba9('0x20'));var _0x5204d4=path[_0xfba9('0x1b')](_0x16ca51,_0x38b32d);var _0x1a58b0=path[_0xfba9('0x1b')](_0x16ca51,_0x15f882);if(fs['existsSync'](_0x5204d4)){_0x170d25[_0xfba9('0x21')]=_0xfba9('0x22');_0x20b7b2[_0xfba9('0x23')][_0xfba9('0x24')]=[{'filename':_0x38b32d,'path':_0x5204d4}];_0x20b7b2[_0xfba9('0x23')][_0xfba9('0x25')]=util[_0xfba9('0x15')](_0xfba9('0x26'),JSON['stringify'](_0x170d25,null,0x2));}else if(fs['existsSync'](_0x1a58b0)){_0x170d25['status']='Sent';_0x20b7b2[_0xfba9('0x23')]['attachments']=[{'filename':_0x15f882,'path':_0x1a58b0}];}else{_0x20b7b2[_0xfba9('0x23')][_0xfba9('0x25')]=_0xfba9('0x27');if(!_0x377f5a[_0xfba9('0x28')]){_0x17e0f4=![];logger[_0xfba9('0xa')](_0xfba9('0x29'));}}if(_0x17e0f4){return client['request'](_0xfba9('0x2a'),_0x20b7b2)[_0xfba9('0x2b')](function(_0xc86c22){if(_0xc86c22[_0xfba9('0x2c')]){return logger[_0xfba9('0x2c')](_0xfba9('0x2d'),JSON[_0xfba9('0x2e')](_0xc86c22));}return logger[_0xfba9('0xa')]('email\x20sent');})[_0xfba9('0x2f')](function(_0x36ea2a){return logger[_0xfba9('0x2c')]('error\x20mail',JSON['stringify'](_0x36ea2a));});}};}function handleError(){return function(_0x23269b){return logger[_0xfba9('0x2c')](JSON[_0xfba9('0x2e')](_0x23269b));};}function handleResult(_0x325493){return function(_0xff1c51){logger[_0xfba9('0xa')](_0xfba9('0x30'),JSON[_0xfba9('0x2e')](_0xff1c51));if(_0x325493[_0xfba9('0xd')]&&_0x325493[_0xfba9('0xd')][_0xfba9('0xf')]&&!_[_0xfba9('0x31')](_0x325493[_0xfba9('0xc')])){setTimeout(handleSendEmail(_0x325493,_0xff1c51),0x3c*0x3e8);}};}function handleJob(_0x288a5f){return function(){try{if(_[_0xfba9('0x31')](_0x288a5f[_0xfba9('0x32')])){return logger[_0xfba9('0xa')](_0xfba9('0x33'));}if(_['isNil'](_0x288a5f[_0xfba9('0x1a')])){return logger[_0xfba9('0xa')](_0xfba9('0x34'));}var _0x464d6a={'startDate':moment()[_0xfba9('0x35')](_0x288a5f['subtractNumber'],_0x288a5f[_0xfba9('0x1a')])['format'](_0xfba9('0x36')),'endDate':moment()[_0xfba9('0x15')](_0xfba9('0x36')),'type':_0xfba9('0x37'),'output':_0x288a5f[_0xfba9('0x38')],'name':_0x288a5f['name']};if(!_[_0xfba9('0x31')](_0x288a5f['DefaultReportId'])){logger[_0xfba9('0xa')](_0xfba9('0x39'),_0x288a5f[_0xfba9('0x3a')]);return analyticDefaultReportController[_0xfba9('0x3b')]({'id':_0x288a5f[_0xfba9('0x3a')]},_0x464d6a)[_0xfba9('0x2b')](handleResult(_0x288a5f))[_0xfba9('0x2f')](handleError());}if(!_[_0xfba9('0x31')](_0x288a5f[_0xfba9('0x3c')])){logger[_0xfba9('0xa')](_0xfba9('0x3d'),_0x288a5f[_0xfba9('0x3c')]);return analyticCustomReportController[_0xfba9('0x3b')]({'id':_0x288a5f[_0xfba9('0x3c')]},_0x464d6a)[_0xfba9('0x2b')](handleResult(_0x288a5f))[_0xfba9('0x2f')](handleError());}}catch(_0x8c4a31){logger[_0xfba9('0x2c')](JSON[_0xfba9('0x2e')](_0x8c4a31));}return logger[_0xfba9('0xa')](_0xfba9('0x3e'));};}function getJobs(_0x109218){var _0x45786b={};if(_0x109218){_0x45786b['id']=_0x109218;}return db[_0xfba9('0x3f')]['findAll']({'where':_0x45786b,'include':[{'model':db['MailAccount'],'attributes':['id',_0xfba9('0x16'),_0xfba9('0xc')],'include':[{'model':db[_0xfba9('0x40')],'as':_0xfba9('0xf')}]}]})['then'](function(_0x3e26b7){var _0x126099=_['keys'](manager['jobs']);var _0x4c227f=_[_0xfba9('0x41')](_0x3e26b7,function(_0xcba504){return _0xcba504['id'][_0xfba9('0x42')]();});var _0x32d2ab=_['keyBy'](_0x3e26b7,function(_0x3c9f9f){return _0x3c9f9f['id'][_0xfba9('0x42')]();});var _0x4e0e0b=_0x109218?_0x4c227f:_['difference'](_0x4c227f,_0x126099);var _0x34ad98=_[_0xfba9('0x43')](_0x4c227f,_0x126099);var _0x43194e=_[_0xfba9('0x44')](_0x126099,_0x4c227f);var _0xe1dd24;var _0x169dff;for(_0xe1dd24=0x0;_0xe1dd24<_0x43194e[_0xfba9('0x45')]&&!_0x109218;_0xe1dd24+=0x1){_0x169dff=_0x43194e[_0xe1dd24][_0xfba9('0x42')]();if(manager[_0xfba9('0x46')](_0x169dff)){manager[_0xfba9('0x47')](_0x169dff);manager[_0xfba9('0x48')](_0x169dff);logger['info'](_0xfba9('0x49'),_0x169dff);}}logger[_0xfba9('0xa')]('toRun',JSON[_0xfba9('0x2e')](_0x4e0e0b));for(_0xe1dd24=0x0;_0xe1dd24<_0x4e0e0b['length'];_0xe1dd24+=0x1){_0x169dff=_0x4e0e0b[_0xe1dd24][_0xfba9('0x42')]();logger['info']('index',_0x169dff);if(_0x109218){logger[_0xfba9('0xa')](_0xfba9('0x4a'),_0x109218);logger['info'](JSON[_0xfba9('0x2e')](_0x32d2ab[_0x169dff]));BPromise[_0xfba9('0x4b')]()['then'](handleJob(_0x32d2ab[_0x169dff]));logger[_0xfba9('0xa')](_0xfba9('0x4c'),_0x32d2ab[_0x169dff][_0xfba9('0x16')],_0x32d2ab[_0x169dff]['cron']);}else if(_0x32d2ab[_0x169dff][_0xfba9('0x4d')]&&_0x32d2ab[_0x169dff][_0xfba9('0x4e')]&&moment()[_0xfba9('0x4f')](_0x32d2ab[_0x169dff][_0xfba9('0x50')],_0x32d2ab[_0x169dff][_0xfba9('0x51')])){manager[_0xfba9('0x52')](_0x169dff,_0x32d2ab[_0x169dff]['cron'],handleJob(_0x32d2ab[_0x169dff]));manager[_0xfba9('0x53')](_0x169dff);logger[_0xfba9('0xa')](_0xfba9('0x54'),_0x32d2ab[_0x169dff][_0xfba9('0x16')],_0x32d2ab[_0x169dff][_0xfba9('0x4d')]);}else if(manager[_0xfba9('0x46')](_0x169dff)){manager[_0xfba9('0x47')](_0x169dff);manager[_0xfba9('0x48')](_0x169dff);logger[_0xfba9('0xa')](_0xfba9('0x55'),_0x32d2ab[_0x169dff][_0xfba9('0x16')],_0x32d2ab[_0x169dff][_0xfba9('0x4d')]);}}for(_0xe1dd24=0x0,_0x169dff;_0xe1dd24<_0x34ad98[_0xfba9('0x45')]&&!_0x109218;_0xe1dd24+=0x1){_0x169dff=_0x34ad98[_0xe1dd24]['toString']();if(manager[_0xfba9('0x46')](_0x169dff)){if(_0x32d2ab[_0x169dff][_0xfba9('0x4d')]&&_0x32d2ab[_0x169dff][_0xfba9('0x4e')]&&moment()[_0xfba9('0x4f')](_0x32d2ab[_0x169dff][_0xfba9('0x50')],_0x32d2ab[_0x169dff]['endAt'])){manager[_0xfba9('0x56')](_0x169dff,_0x32d2ab[_0x169dff][_0xfba9('0x4d')],handleJob(_0x32d2ab[_0x169dff]));logger[_0xfba9('0xa')](_0xfba9('0x57'),_0x32d2ab[_0x169dff][_0xfba9('0x16')],_0x32d2ab[_0x169dff]['cron']);}else{manager[_0xfba9('0x47')](_0x169dff);manager['deleteJob'](_0x169dff);logger[_0xfba9('0xa')](_0xfba9('0x55'),_0x32d2ab[_0x169dff][_0xfba9('0x16')],_0x32d2ab[_0x169dff]['cron']);}}}})['catch'](function(_0x82f680){logger[_0xfba9('0x2c')](JSON[_0xfba9('0x2e')](_0x82f680));});}exports[_0xfba9('0x58')]=function(_0x115f5b){return getJobs(_0x115f5b);};exports[_0xfba9('0x53')]=function(){setInterval(function(){return getJobs();},0x3c*0x3e8);return getJobs();};
\ No newline at end of file