Built motion from commit 12b39f1.|0.0.105
[motion.git] / server / config / automations / mail.js
index 07ee779..318e524 100644 (file)
@@ -1 +1 @@
-var _0xaae7=["\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"];_0xaae7[0];var _=require(_0xaae7[1]);var config=require(_0xaae7[2]);var moment=require(_0xaae7[3]);var sequelize=require(_0xaae7[5])[_0xaae7[4]];var Automation=require(_0xaae7[5])[_0xaae7[6]];var MailRoom=require(_0xaae7[5])[_0xaae7[7]];var Settings=require(_0xaae7[5])[_0xaae7[8]];var activeAutomations={};function executeAutomation(_0x2b9dxa){var _0x2b9dxb={where:{$and:[],$or:[]}};var _0x2b9dxc={};_0x2b9dxa[_0xaae7[14]][_0xaae7[13]](function(_0x2b9dxd){_0x2b9dxb[_0xaae7[12]][_0xaae7[11]][_0xaae7[10]](getCondition(_0x2b9dxd[_0xaae7[9]]))});_0x2b9dxa[_0xaae7[16]][_0xaae7[13]](function(_0x2b9dxd){_0x2b9dxb[_0xaae7[12]][_0xaae7[15]][_0xaae7[10]](getCondition(_0x2b9dxd[_0xaae7[9]]))});return MailRoom[_0xaae7[25]](_0x2b9dxb)[_0xaae7[24]](function(_0x2b9dxf){_0x2b9dxf[_0xaae7[13]](function(_0x2b9dx10){_0x2b9dxa[_0xaae7[23]][_0xaae7[13]](function(_0x2b9dx11){switch(_0x2b9dx11[_0xaae7[22]]){case _0xaae7[21]:setStatus(_0x2b9dx10[_0xaae7[19]],_0x2b9dx11[_0xaae7[20]]);break;default:}})})})[_0xaae7[18]](function(_0x2b9dxe){console[_0xaae7[17]](_0x2b9dxe)})}function setStatus(_0x2b9dx13,_0x2b9dx14){return MailRoom[_0xaae7[26]]({status:_0x2b9dx14},{where:{id:_0x2b9dx13}})[_0xaae7[18]](function(_0x2b9dxe){console[_0xaae7[17]](_0x2b9dxe)})}function getCondition(_0x2b9dxd){var _0x2b9dx16={};switch(_0x2b9dxd[_0xaae7[27]]){case _0xaae7[21]:switch(_0x2b9dxd[_0xaae7[31]]){case _0xaae7[29]:_0x2b9dx16[_0x2b9dxd[_0xaae7[27]]]=_0x2b9dxd[_0xaae7[28]];break;case _0xaae7[30]:_0x2b9dx16[_0x2b9dxd[_0xaae7[27]]]={$ne:_0x2b9dxd[_0xaae7[28]]};break;default:};break;case _0xaae7[40]:var _0x2b9dx17=moment()[_0xaae7[35]](parseInt(_0x2b9dxd[_0xaae7[28]],10),_0xaae7[34])[_0xaae7[33]](_0xaae7[32]);switch(_0x2b9dxd[_0xaae7[31]]){case _0xaae7[36]:_0x2b9dx16[_0x2b9dxd[_0xaae7[27]]]={lt:_0x2b9dx17};break;case _0xaae7[37]:_0x2b9dx16[_0x2b9dxd[_0xaae7[27]]]={$lte:_0x2b9dx17};break;case _0xaae7[38]:_0x2b9dx16[_0x2b9dxd[_0xaae7[27]]]={$gt:_0x2b9dx17};break;case _0xaae7[39]:_0x2b9dx16[_0x2b9dxd[_0xaae7[27]]]={$gte:_0x2b9dx17};break;default:};break;default:};return _0x2b9dx16}function createInterval(_0x2b9dxa){activeAutomations[_0xaae7[41]+_0x2b9dxa[_0xaae7[19]]]=setInterval(function(){executeAutomation(_0x2b9dxa)},_0x2b9dxa[_0xaae7[42]]*1000)}module[_0xaae7[43]]=function(){Automation[_0xaae7[46]](function(_0x2b9dx19,_0x2b9dx1a){if(_0x2b9dx19[_0xaae7[21]]&&_0x2b9dx19[_0xaae7[44]]===_0xaae7[45]){createInterval(_0x2b9dx19)}});Automation[_0xaae7[47]](function(_0x2b9dx19,_0x2b9dx1a){if(activeAutomations[_0xaae7[41]+_0x2b9dx19[_0xaae7[19]]]){clearInterval(activeAutomations[_0xaae7[41]+_0x2b9dx19[_0xaae7[19]]])};if(_0x2b9dx19[_0xaae7[21]]&&_0x2b9dx19[_0xaae7[44]]===_0xaae7[45]){createInterval(_0x2b9dx19)}});Automation[_0xaae7[48]](function(_0x2b9dx19,_0x2b9dx1a){if(activeAutomations[_0xaae7[41]+_0x2b9dx19[_0xaae7[19]]]){clearInterval(activeAutomations[_0xaae7[41]+_0x2b9dx19[_0xaae7[19]]])}});Automation[_0xaae7[51]](_0xaae7[50])[_0xaae7[25]]({where:{status:true,channel:_0xaae7[45]}})[_0xaae7[24]](function(_0x2b9dx1b){_0x2b9dx1b[_0xaae7[13]](function(_0x2b9dxa){createInterval(_0x2b9dxa)})})[_0xaae7[18]](function(_0x2b9dxe){console[_0xaae7[49]](_0x2b9dxe)})}
\ No newline at end of file
+var _0xaba5=["\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","\x45\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x4D\x61\x69\x6C\x20\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20","\x6C\x6F\x67","\x4D\x61\x69\x6C\x20\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20\x65\x78\x65\x63\x20\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x69\x64","\x64\x61\x74\x61\x31","\x73\x74\x61\x74\x75\x73","\x61\x63\x74\x69\x6F\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x41\x63\x74\x69\x6F\x6E\x73","\x74\x68\x65\x6E","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x75\x73\x68","\x24\x61\x6E\x64","\x77\x68\x65\x72\x65","\x41\x6C\x6C","\x24\x6F\x72","\x41\x6E\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x6C\x6C","\x73\x63\x6F\x70\x65","\x41\x75\x74\x6F\x6D\x61\x74\x69\x63\x20\x6D\x61\x69\x6C\x20\x73\x74\x61\x74\x75\x73\x20\x65\x72\x72\x6F\x72","\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","\x4D\x61\x69\x6C\x20\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20","\x20\x73\x65\x74\x20\x77\x69\x74\x68\x20\x74\x69\x6D\x65\x6F\x75\x74\x20","\x74\x69\x6D\x65\x6F\x75\x74","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x65\x78\x70\x6F\x72\x74\x73","\x20\x63\x72\x65\x61\x74\x65\x64\x2C\x20\x74\x68\x65\x20\x73\x74\x61\x74\x75\x73\x20\x69\x73\x20","\x63\x68\x61\x6E\x6E\x65\x6C","\x6D\x61\x69\x6C","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x20\x75\x70\x64\x61\x74\x65\x64\x2C\x20\x74\x68\x65\x20\x73\x74\x61\x74\x75\x73\x20\x69\x73\x20","\x4D\x61\x69\x6C\x20\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20\x75\x6E\x73\x65\x74\x20","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x20\x64\x65\x6C\x65\x74\x65\x64","\x61\x66\x74\x65\x72\x44\x65\x6C\x65\x74\x65","\x4D\x61\x69\x6C\x20\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20\x69\x6E\x69\x74\x20\x65\x72\x72\x6F\x72"];_0xaba5[0];var _=require(_0xaba5[1]);var config=require(_0xaba5[2]);var moment=require(_0xaba5[3]);var sequelize=require(_0xaba5[5])[_0xaba5[4]];var Automation=require(_0xaba5[5])[_0xaba5[6]];var MailRoom=require(_0xaba5[5])[_0xaba5[7]];var Settings=require(_0xaba5[5])[_0xaba5[8]];var activeMailAutomations={};function executeAutomation(_0x23afxa){console[_0xaba5[10]](_0xaba5[9],_0x23afxa);var _0x23afxb;return Automation[_0xaba5[30]](_0xaba5[29])[_0xaba5[28]](_0x23afxa)[_0xaba5[19]](function(_0x23afx10){_0x23afxb=_0x23afx10;var _0x23afx11={where:{$and:[],$or:[]}};_0x23afx10[_0xaba5[24]][_0xaba5[17]](function(_0x23afx12){_0x23afx11[_0xaba5[23]][_0xaba5[22]][_0xaba5[21]](getCondition(_0x23afx12[_0xaba5[20]]))});_0x23afx10[_0xaba5[26]][_0xaba5[17]](function(_0x23afx12){_0x23afx11[_0xaba5[23]][_0xaba5[25]][_0xaba5[21]](getCondition(_0x23afx12[_0xaba5[20]]))});return MailRoom[_0xaba5[27]](_0x23afx11)})[_0xaba5[19]](function(_0x23afxd){_0x23afxd[_0xaba5[17]](function(_0x23afxe){_0x23afxb[_0xaba5[18]][_0xaba5[17]](function(_0x23afxf){switch(_0x23afxf[_0xaba5[16]]){case _0xaba5[15]:setStatus(_0x23afxe[_0xaba5[13]],_0x23afxf[_0xaba5[14]]);break;default:}})})})[_0xaba5[12]](function(_0x23afxc){console[_0xaba5[10]](_0xaba5[11],_0x23afxc)})}function setStatus(_0x23afx14,_0x23afx15){return MailRoom[_0xaba5[32]]({status:_0x23afx15},{where:{id:_0x23afx14}})[_0xaba5[12]](function(_0x23afxc){console[_0xaba5[10]](_0xaba5[31],_0x23afxc)})}function getCondition(_0x23afx12){var _0x23afx17={};switch(_0x23afx12[_0xaba5[33]]){case _0xaba5[15]:switch(_0x23afx12[_0xaba5[37]]){case _0xaba5[35]:_0x23afx17[_0x23afx12[_0xaba5[33]]]=_0x23afx12[_0xaba5[34]];break;case _0xaba5[36]:_0x23afx17[_0x23afx12[_0xaba5[33]]]={$ne:_0x23afx12[_0xaba5[34]]};break;default:};break;case _0xaba5[46]:var _0x23afx18=moment()[_0xaba5[41]](parseInt(_0x23afx12[_0xaba5[34]],10),_0xaba5[40])[_0xaba5[39]](_0xaba5[38]);switch(_0x23afx12[_0xaba5[37]]){case _0xaba5[42]:_0x23afx17[_0x23afx12[_0xaba5[33]]]={lt:_0x23afx18};break;case _0xaba5[43]:_0x23afx17[_0x23afx12[_0xaba5[33]]]={$lte:_0x23afx18};break;case _0xaba5[44]:_0x23afx17[_0x23afx12[_0xaba5[33]]]={$gt:_0x23afx18};break;case _0xaba5[45]:_0x23afx17[_0x23afx12[_0xaba5[33]]]={$gte:_0x23afx18};break;default:};break;default:};return _0x23afx17}function createInterval(_0x23afx10){console[_0xaba5[10]](_0xaba5[47],_0x23afx10[_0xaba5[13]],_0xaba5[48],_0x23afx10[_0xaba5[49]]*60*1000);activeMailAutomations[_0xaba5[50]+_0x23afx10[_0xaba5[13]]]=setInterval(function(){executeAutomation(_0x23afx10[_0xaba5[13]])},_0x23afx10[_0xaba5[49]]*60*1000)}module[_0xaba5[51]]=function(){Automation[_0xaba5[55]](function(_0x23afx1a,_0x23afx1b){console[_0xaba5[10]](_0xaba5[47],_0x23afx1a[_0xaba5[13]],_0xaba5[52],_0x23afx1a[_0xaba5[15]]);if(_0x23afx1a[_0xaba5[15]]&&_0x23afx1a[_0xaba5[53]]===_0xaba5[54]){createInterval(_0x23afx1a)}});Automation[_0xaba5[58]](function(_0x23afx1a,_0x23afx1b){console[_0xaba5[10]](_0xaba5[47],_0x23afx1a[_0xaba5[13]],_0xaba5[56],_0x23afx1a[_0xaba5[15]]);if(activeMailAutomations[_0xaba5[50]+_0x23afx1a[_0xaba5[13]]]){console[_0xaba5[10]](_0xaba5[57],_0x23afx1a[_0xaba5[13]]);clearInterval(activeMailAutomations[_0xaba5[50]+_0x23afx1a[_0xaba5[13]]]);delete activeMailAutomations[_0xaba5[50]+_0x23afx1a[_0xaba5[13]]]};if(_0x23afx1a[_0xaba5[15]]&&_0x23afx1a[_0xaba5[53]]===_0xaba5[54]){createInterval(_0x23afx1a)}});Automation[_0xaba5[60]](function(_0x23afx1a,_0x23afx1b){console[_0xaba5[10]](_0xaba5[47],_0x23afx1a[_0xaba5[13]],_0xaba5[59]);if(activeMailAutomations[_0xaba5[50]+_0x23afx1a[_0xaba5[13]]]){console[_0xaba5[10]](_0xaba5[57],_0x23afx1a[_0xaba5[13]]);clearInterval(activeMailAutomations[_0xaba5[50]+_0x23afx1a[_0xaba5[13]]]);delete activeMailAutomations[_0xaba5[50]+_0x23afx1a[_0xaba5[13]]]}});return Automation[_0xaba5[30]](_0xaba5[29])[_0xaba5[27]]({where:{status:true,channel:_0xaba5[54]},attributes:[_0xaba5[13],_0xaba5[49]]})[_0xaba5[19]](function(_0x23afx1c){_0x23afx1c[_0xaba5[17]](function(_0x23afx10){createInterval(_0x23afx10)})})[_0xaba5[12]](function(_0x23afxc){console[_0xaba5[10]](_0xaba5[61],_0x23afxc)})}
\ No newline at end of file