Built motion from commit bbcb218.|0.0.68
[motion.git] / server / config / automations / mail.js
1 var _0x8158=["\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","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x75\x73\x68","\x24\x61\x6E\x64","\x77\x68\x65\x72\x65","\x66\x6F\x72\x45\x61\x63\x68","\x41\x6C\x6C","\x24\x6F\x72","\x41\x6E\x79","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x69\x64","\x64\x61\x74\x61\x31","\x73\x74\x61\x74\x75\x73","\x61\x63\x74\x69\x6F\x6E","\x41\x63\x74\x69\x6F\x6E\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x75\x70\x64\x61\x74\x65","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x65\x71\x75\x61\x6C\x73","\x6E\x6F\x74\x5F\x65\x71\x75\x61\x6C\x73","\x6F\x70\x65\x72\x61\x74\x6F\x72","\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","\x67\x72\x65\x61\x74\x65\x72","\x67\x72\x65\x61\x74\x65\x72\x5F\x6F\x72\x5F\x65\x71\x75\x61\x6C","\x6C\x65\x73\x73","\x6C\x65\x73\x73\x5F\x6F\x72\x5F\x65\x71\x75\x61\x6C","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x74\x69\x6D\x65\x6F\x75\x74","\x65\x78\x70\x6F\x72\x74\x73","\x63\x68\x61\x6E\x6E\x65\x6C","\x6D\x61\x69\x6C","\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","\x61\x6C\x6C","\x73\x63\x6F\x70\x65"];_0x8158[0];var _=require(_0x8158[1]);var config=require(_0x8158[2]);var moment=require(_0x8158[3]);var sequelize=require(_0x8158[5])[_0x8158[4]];var Automation=require(_0x8158[5])[_0x8158[6]];var MailRoom=require(_0x8158[5])[_0x8158[7]];var Settings=require(_0x8158[5])[_0x8158[8]];var activeAutomations={};function executeAutomation(_0xd837xa){var _0xd837xb={where:{$and:[],$or:[]}};var _0xd837xc={};_0xd837xa[_0x8158[14]][_0x8158[13]](function(_0xd837xd){_0xd837xb[_0x8158[12]][_0x8158[11]][_0x8158[10]](getCondition(_0xd837xd[_0x8158[9]]))});_0xd837xa[_0x8158[16]][_0x8158[13]](function(_0xd837xd){_0xd837xb[_0x8158[12]][_0x8158[15]][_0x8158[10]](getCondition(_0xd837xd[_0x8158[9]]))});return MailRoom[_0x8158[25]](_0xd837xb)[_0x8158[24]](function(_0xd837xf){_0xd837xf[_0x8158[13]](function(_0xd837x10){_0xd837xa[_0x8158[23]][_0x8158[13]](function(_0xd837x11){switch(_0xd837x11[_0x8158[22]]){case _0x8158[21]:setStatus(_0xd837x10[_0x8158[19]],_0xd837x11[_0x8158[20]]);break;default:}})})})[_0x8158[18]](function(_0xd837xe){console[_0x8158[17]](_0xd837xe)})}function setStatus(_0xd837x13,_0xd837x14){return MailRoom[_0x8158[26]]({status:_0xd837x14},{where:{id:_0xd837x13}})[_0x8158[18]](function(_0xd837xe){console[_0x8158[17]](_0xd837xe)})}function getCondition(_0xd837xd){var _0xd837x16={};switch(_0xd837xd[_0x8158[27]]){case _0x8158[21]:switch(_0xd837xd[_0x8158[31]]){case _0x8158[29]:_0xd837x16[_0xd837xd[_0x8158[27]]]=_0xd837xd[_0x8158[28]];break;case _0x8158[30]:_0xd837x16[_0xd837xd[_0x8158[27]]]={$ne:_0xd837xd[_0x8158[28]]};break;default:};break;case _0x8158[40]:var _0xd837x17=moment()[_0x8158[35]](parseInt(_0xd837xd[_0x8158[28]],10),_0x8158[34])[_0x8158[33]](_0x8158[32]);switch(_0xd837xd[_0x8158[31]]){case _0x8158[36]:_0xd837x16[_0xd837xd[_0x8158[27]]]={lt:_0xd837x17};break;case _0x8158[37]:_0xd837x16[_0xd837xd[_0x8158[27]]]={$lte:_0xd837x17};break;case _0x8158[38]:_0xd837x16[_0xd837xd[_0x8158[27]]]={$gt:_0xd837x17};break;case _0x8158[39]:_0xd837x16[_0xd837xd[_0x8158[27]]]={$gte:_0xd837x17};break;default:};break;default:};return _0xd837x16}function createInterval(_0xd837xa){activeAutomations[_0x8158[41]+_0xd837xa[_0x8158[19]]]=setInterval(function(){executeAutomation(_0xd837xa)},_0xd837xa[_0x8158[42]]*1000)}module[_0x8158[43]]=function(){Automation[_0x8158[46]](function(_0xd837x19,_0xd837x1a){if(_0xd837x19[_0x8158[21]]&&_0xd837x19[_0x8158[44]]===_0x8158[45]){createInterval(_0xd837x19)}});Automation[_0x8158[47]](function(_0xd837x19,_0xd837x1a){if(activeAutomations[_0x8158[41]+_0xd837x19[_0x8158[19]]]){clearInterval(activeAutomations[_0x8158[41]+_0xd837x19[_0x8158[19]]])};if(_0xd837x19[_0x8158[21]]&&_0xd837x19[_0x8158[44]]===_0x8158[45]){createInterval(_0xd837x19)}});Automation[_0x8158[48]](function(_0xd837x19,_0xd837x1a){if(activeAutomations[_0x8158[41]+_0xd837x19[_0x8158[19]]]){clearInterval(activeAutomations[_0x8158[41]+_0xd837x19[_0x8158[19]]])}});Automation[_0x8158[51]](_0x8158[50])[_0x8158[25]]({where:{status:true,channel:_0x8158[45]}})[_0x8158[24]](function(_0xd837x1b){_0xd837x1b[_0x8158[13]](function(_0xd837xa){createInterval(_0xd837xa)})})[_0x8158[18]](function(_0xd837xe){console[_0x8158[49]](_0xd837xe)})}