Built motion from commit 7e4f41e.|0.0.26
[motion.git] / server / config / automations / mail.js
1 var _0xeb38=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x2E\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6D\x6F\x6D\x65\x6E\x74","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x53\x65\x74\x74\x69\x6E\x67\x73","\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x5F\x74\x69\x6D\x65\x6F\x75\x74","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x4F\x6E\x65","\x67\x72\x6F\x75\x70","\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x70\x61\x72\x73\x65","\x61\x63\x74\x69\x6F\x6E\x73","\x62\x6F\x6F\x6C\x65\x61\x6E","\x41\x4E\x44","\x24\x61\x6E\x64","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x6F\x70\x65\x72\x61\x74\x6F\x72","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x72\x75\x6C\x65\x73","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x69\x64","\x64\x61\x74\x61","\x73\x74\x61\x74\x75\x73","\x76\x61\x6C\x75\x65","\x66\x69\x65\x6C\x64","\x66\x69\x6E\x64\x41\x6C\x6C","\x75\x70\x64\x61\x74\x65","\x3D","\x3C\x3E","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x68\x6F\x75\x72\x73","\x73\x75\x62\x74\x72\x61\x63\x74","\x3E","\x3E\x3D","\x3C","\x3C\x3D","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x65\x78\x70\x6F\x72\x74\x73","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x6C\x65\x74\x65","\x65\x72\x72\x6F\x72","\x6D\x61\x69\x6C"];_0xeb38[0];var _=require(_0xeb38[1]);var config=require(_0xeb38[2]);var moment=require(_0xeb38[3]);var sequelize=require(_0xeb38[5])[_0xeb38[4]];var Automation=require(_0xeb38[5])[_0xeb38[6]];var MailRoom=require(_0xeb38[5])[_0xeb38[7]];var Settings=require(_0xeb38[5])[_0xeb38[8]];var automationTimeout;var activeAutomations={};function getTimeout(){return Settings[_0xeb38[11]]()[_0xeb38[10]](function(_0x843exb){automationTimeout=_0x843exb[_0xeb38[9]];return ;})}function executeAutomation(_0x843exd){var _0x843exe={where:{}};var _0x843exf={};var _0x843ex10=JSON[_0xeb38[14]](_0x843exd[_0xeb38[13]])[_0xeb38[12]];var _0x843ex11=JSON[_0xeb38[14]](_0x843exd[_0xeb38[15]])[_0xeb38[12]];var _0x843ex12={};var _0x843ex13=_0x843ex10[_0xeb38[16]]===_0xeb38[17]?_0xeb38[18]:_0xeb38[19];_0x843exe[_0xeb38[20]][_0x843ex13]=[];_0x843ex10[_0xeb38[24]][_0xeb38[23]](function(_0x843ex14){if(_0x843ex14[_0xeb38[21]]){_0x843exe[_0xeb38[20]][_0x843ex13][_0xeb38[22]](getCondition(_0x843ex14))}else {if(_0x843ex14[_0xeb38[12]]){var _0x843ex15=_0x843ex14[_0xeb38[12]][_0xeb38[16]]===_0xeb38[17]?_0xeb38[18]:_0xeb38[19];var _0x843ex16={};_0x843ex16[_0x843ex15]=[];_0x843ex14[_0xeb38[12]][_0xeb38[24]][_0xeb38[23]](function(_0x843ex17){_0x843ex16[_0x843ex15][_0xeb38[22]](getCondition(_0x843ex17))});_0x843exe[_0xeb38[20]][_0x843ex13][_0xeb38[22]](_0x843ex16);}}});MailRoom[_0xeb38[32]](_0x843exe)[_0xeb38[10]](function(_0x843ex19){_0x843ex19[_0xeb38[23]](function(_0x843ex1a){_0x843ex11[_0xeb38[24]][_0xeb38[23]](function(_0x843ex14){switch(_0x843ex14[_0xeb38[31]][_0xeb38[30]]){case _0xeb38[29]:setStatus(_0x843ex1a[_0xeb38[27]],_0x843ex14[_0xeb38[28]]);break ;;default:;}})})})[_0xeb38[26]](function(_0x843ex18){console[_0xeb38[25]](_0x843ex18)});}function setStatus(_0x843ex1c,_0x843ex1d){MailRoom[_0xeb38[33]]({status:_0x843ex1d},{where:{id:_0x843ex1c}})[_0xeb38[26]](function(_0x843ex18){console[_0xeb38[25]](_0x843ex18)})}function getCondition(_0x843ex14){var _0x843exb={};switch(_0x843ex14[_0xeb38[31]][_0xeb38[30]]){case _0xeb38[29]:switch(_0x843ex14[_0xeb38[21]]){case _0xeb38[34]:_0x843exb[_0x843ex14[_0xeb38[31]][_0xeb38[30]]]=_0x843ex14[_0xeb38[28]];break ;;case _0xeb38[35]:_0x843exb[_0x843ex14[_0xeb38[31]][_0xeb38[30]]]={$ne:_0x843ex14[_0xeb38[28]]};break ;;default:;};break ;;case _0xeb38[44]:var _0x843ex1f=moment()[_0xeb38[39]](parseInt(_0x843ex14[_0xeb38[28]],10),_0xeb38[38])[_0xeb38[37]](_0xeb38[36]);switch(_0x843ex14[_0xeb38[21]]){case _0xeb38[40]:_0x843exb[_0x843ex14[_0xeb38[31]][_0xeb38[30]]]={lt:_0x843ex1f};break ;;case _0xeb38[41]:_0x843exb[_0x843ex14[_0xeb38[31]][_0xeb38[30]]]={$lte:_0x843ex1f};break ;;case _0xeb38[42]:_0x843exb[_0x843ex14[_0xeb38[31]][_0xeb38[30]]]={$gt:_0x843ex1f};break ;;case _0xeb38[43]:_0x843exb[_0x843ex14[_0xeb38[31]][_0xeb38[30]]]={$gte:_0x843ex1f};break ;;default:;};break ;;default:;};return _0x843exb;}function createInterval(_0x843exd){activeAutomations[_0xeb38[45]+_0x843exd[_0xeb38[27]]]=setInterval(function(){executeAutomation(_0x843exd)},automationTimeout*1000)}module[_0xeb38[46]]=function(){getTimeout();Automation[_0xeb38[47]](function(_0x843ex21,_0x843ex22){createInterval(_0x843ex21)});Automation[_0xeb38[48]](function(_0x843ex21,_0x843ex22){clearInterval(activeAutomations[_0xeb38[45]+_0x843ex21[_0xeb38[27]]]);createInterval(_0x843ex21);});Automation[_0xeb38[49]](function(_0x843ex21,_0x843ex22){clearInterval(activeAutomations[_0xeb38[45]+_0x843ex21[_0xeb38[27]]])});Automation[_0xeb38[32]]({where:{status:true,channel:_0xeb38[51]}})[_0xeb38[10]](function(_0x843ex23){_0x843ex23[_0xeb38[23]](function(_0x843exd){createInterval(_0x843exd)})})[_0xeb38[26]](function(_0x843ex18){console[_0xeb38[50]](_0x843ex18)});};