Built motion from commit 22bc4a4.|0.0.19
[motion.git] / server / config / automations / mail.js
1 var _0x3f40=["\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"];_0x3f40[0];var _=require(_0x3f40[1]);var config=require(_0x3f40[2]);var moment=require(_0x3f40[3]);var sequelize=require(_0x3f40[5])[_0x3f40[4]];var Automation=require(_0x3f40[5])[_0x3f40[6]];var MailRoom=require(_0x3f40[5])[_0x3f40[7]];var Settings=require(_0x3f40[5])[_0x3f40[8]];var automationTimeout;var activeAutomations={};function getTimeout(){return Settings[_0x3f40[11]]()[_0x3f40[10]](function(_0xc2d8xb){automationTimeout=_0xc2d8xb[_0x3f40[9]];return ;})}function executeAutomation(_0xc2d8xd){var _0xc2d8xe={where:{}};var _0xc2d8xf={};var _0xc2d8x10=JSON[_0x3f40[14]](_0xc2d8xd[_0x3f40[13]])[_0x3f40[12]];var _0xc2d8x11=JSON[_0x3f40[14]](_0xc2d8xd[_0x3f40[15]])[_0x3f40[12]];var _0xc2d8x12={};var _0xc2d8x13=_0xc2d8x10[_0x3f40[16]]===_0x3f40[17]?_0x3f40[18]:_0x3f40[19];_0xc2d8xe[_0x3f40[20]][_0xc2d8x13]=[];_0xc2d8x10[_0x3f40[24]][_0x3f40[23]](function(_0xc2d8x14){if(_0xc2d8x14[_0x3f40[21]]){_0xc2d8xe[_0x3f40[20]][_0xc2d8x13][_0x3f40[22]](getCondition(_0xc2d8x14))}else {if(_0xc2d8x14[_0x3f40[12]]){var _0xc2d8x15=_0xc2d8x14[_0x3f40[12]][_0x3f40[16]]===_0x3f40[17]?_0x3f40[18]:_0x3f40[19];var _0xc2d8x16={};_0xc2d8x16[_0xc2d8x15]=[];_0xc2d8x14[_0x3f40[12]][_0x3f40[24]][_0x3f40[23]](function(_0xc2d8x17){_0xc2d8x16[_0xc2d8x15][_0x3f40[22]](getCondition(_0xc2d8x17))});_0xc2d8xe[_0x3f40[20]][_0xc2d8x13][_0x3f40[22]](_0xc2d8x16);}}});MailRoom[_0x3f40[32]](_0xc2d8xe)[_0x3f40[10]](function(_0xc2d8x19){_0xc2d8x19[_0x3f40[23]](function(_0xc2d8x1a){_0xc2d8x11[_0x3f40[24]][_0x3f40[23]](function(_0xc2d8x14){switch(_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]){case _0x3f40[29]:setStatus(_0xc2d8x1a[_0x3f40[27]],_0xc2d8x14[_0x3f40[28]]);break ;;default:;}})})})[_0x3f40[26]](function(_0xc2d8x18){console[_0x3f40[25]](_0xc2d8x18)});}function setStatus(_0xc2d8x1c,_0xc2d8x1d){MailRoom[_0x3f40[33]]({status:_0xc2d8x1d},{where:{id:_0xc2d8x1c}})[_0x3f40[26]](function(_0xc2d8x18){console[_0x3f40[25]](_0xc2d8x18)})}function getCondition(_0xc2d8x14){var _0xc2d8xb={};switch(_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]){case _0x3f40[29]:switch(_0xc2d8x14[_0x3f40[21]]){case _0x3f40[34]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]=_0xc2d8x14[_0x3f40[28]];break ;;case _0x3f40[35]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={$ne:_0xc2d8x14[_0x3f40[28]]};break ;;default:;};break ;;case _0x3f40[44]:var _0xc2d8x1f=moment()[_0x3f40[39]](parseInt(_0xc2d8x14[_0x3f40[28]],10),_0x3f40[38])[_0x3f40[37]](_0x3f40[36]);switch(_0xc2d8x14[_0x3f40[21]]){case _0x3f40[40]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={lt:_0xc2d8x1f};break ;;case _0x3f40[41]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={$lte:_0xc2d8x1f};break ;;case _0x3f40[42]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={$gt:_0xc2d8x1f};break ;;case _0x3f40[43]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={$gte:_0xc2d8x1f};break ;;default:;};break ;;default:;};return _0xc2d8xb;}function createInterval(_0xc2d8xd){activeAutomations[_0x3f40[45]+_0xc2d8xd[_0x3f40[27]]]=setInterval(function(){executeAutomation(_0xc2d8xd)},automationTimeout*1000)}module[_0x3f40[46]]=function(){getTimeout();Automation[_0x3f40[47]](function(_0xc2d8x21,_0xc2d8x22){createInterval(_0xc2d8x21)});Automation[_0x3f40[48]](function(_0xc2d8x21,_0xc2d8x22){clearInterval(activeAutomations[_0x3f40[45]+_0xc2d8x21[_0x3f40[27]]]);createInterval(_0xc2d8x21);});Automation[_0x3f40[49]](function(_0xc2d8x21,_0xc2d8x22){clearInterval(activeAutomations[_0x3f40[45]+_0xc2d8x21[_0x3f40[27]]])});Automation[_0x3f40[32]]({where:{status:true,channel:_0x3f40[51]}})[_0x3f40[10]](function(_0xc2d8x23){_0xc2d8x23[_0x3f40[23]](function(_0xc2d8xd){createInterval(_0xc2d8xd)})})[_0x3f40[26]](function(_0xc2d8x18){console[_0x3f40[50]](_0xc2d8x18)});};