1 var _0x58d9=["\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","\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","\x41\x6C\x6C","\x41\x6E\x79","\x6C\x65\x6E\x67\x74\x68","\x24\x61\x6E\x64","\x77\x68\x65\x72\x65","\x24\x6F\x72","\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"];_0x58d9[0];var _=require(_0x58d9[1]);var config=require(_0x58d9[2]);var moment=require(_0x58d9[3]);var sequelize=require(_0x58d9[5])[_0x58d9[4]];var Automation=require(_0x58d9[5])[_0x58d9[6]];var MailRoom=require(_0x58d9[5])[_0x58d9[7]];var activeMailAutomations={};function executeAutomation(_0x6be6x9){console[_0x58d9[9]](_0x58d9[8],_0x6be6x9);var _0x6be6xa;return Automation[_0x58d9[30]](_0x58d9[29])[_0x58d9[28]](_0x6be6x9)[_0x58d9[18]](function(_0x6be6xf){_0x6be6xa= _0x6be6xf;var _0x6be6x10=[];var _0x6be6x11=[];var _0x6be6x12={where:{}};_0x6be6xf[_0x58d9[21]][_0x58d9[16]](function(_0x6be6x13){_0x6be6x11[_0x58d9[20]](getCondition(_0x6be6x13[_0x58d9[19]]))});_0x6be6xf[_0x58d9[22]][_0x58d9[16]](function(_0x6be6x13){_0x6be6x10[_0x58d9[20]](getCondition(_0x6be6x13[_0x58d9[19]]))});if(_0x6be6x11[_0x58d9[23]]){_0x6be6x12[_0x58d9[25]][_0x58d9[24]]= _0x6be6x11};if(_0x6be6x10[_0x58d9[23]]){_0x6be6x12[_0x58d9[25]][_0x58d9[26]]= _0x6be6x10};return MailRoom[_0x58d9[27]](_0x6be6x12)})[_0x58d9[18]](function(_0x6be6xc){_0x6be6xc[_0x58d9[16]](function(_0x6be6xd){_0x6be6xa[_0x58d9[17]][_0x58d9[16]](function(_0x6be6xe){switch(_0x6be6xe[_0x58d9[15]]){case _0x58d9[14]:setStatus(_0x6be6xd[_0x58d9[12]],_0x6be6xe[_0x58d9[13]]);break;default:}})})})[_0x58d9[11]](function(_0x6be6xb){console[_0x58d9[9]](_0x58d9[10],_0x6be6xb)})}function setStatus(_0x6be6x15,_0x6be6x16){return MailRoom[_0x58d9[32]]({status:_0x6be6x16},{where:{id:_0x6be6x15}})[_0x58d9[11]](function(_0x6be6xb){console[_0x58d9[9]](_0x58d9[31],_0x6be6xb)})}function getCondition(_0x6be6x13){var _0x6be6x18={};switch(_0x6be6x13[_0x58d9[33]]){case _0x58d9[14]:switch(_0x6be6x13[_0x58d9[37]]){case _0x58d9[35]:_0x6be6x18[_0x6be6x13[_0x58d9[33]]]= _0x6be6x13[_0x58d9[34]];break;case _0x58d9[36]:_0x6be6x18[_0x6be6x13[_0x58d9[33]]]= {$ne:_0x6be6x13[_0x58d9[34]]};break;default:};break;case _0x58d9[46]:var _0x6be6x19=moment()[_0x58d9[41]](parseInt(_0x6be6x13[_0x58d9[34]],10),_0x58d9[40])[_0x58d9[39]](_0x58d9[38]);switch(_0x6be6x13[_0x58d9[37]]){case _0x58d9[42]:_0x6be6x18[_0x6be6x13[_0x58d9[33]]]= {lt:_0x6be6x19};break;case _0x58d9[43]:_0x6be6x18[_0x6be6x13[_0x58d9[33]]]= {$lte:_0x6be6x19};break;case _0x58d9[44]:_0x6be6x18[_0x6be6x13[_0x58d9[33]]]= {$gt:_0x6be6x19};break;case _0x58d9[45]:_0x6be6x18[_0x6be6x13[_0x58d9[33]]]= {$gte:_0x6be6x19};break;default:};break;default:};return _0x6be6x18}function createInterval(_0x6be6xf){console[_0x58d9[9]](_0x58d9[47],_0x6be6xf[_0x58d9[12]],_0x58d9[48],_0x6be6xf[_0x58d9[49]]* 60* 1000);activeMailAutomations[_0x58d9[50]+ _0x6be6xf[_0x58d9[12]]]= setInterval(function(){executeAutomation(_0x6be6xf[_0x58d9[12]])},_0x6be6xf[_0x58d9[49]]* 60* 1000)}module[_0x58d9[51]]= function(){Automation[_0x58d9[55]](function(_0x6be6x1b,_0x6be6x1c){console[_0x58d9[9]](_0x58d9[47],_0x6be6x1b[_0x58d9[12]],_0x58d9[52],_0x6be6x1b[_0x58d9[14]]);if(_0x6be6x1b[_0x58d9[14]]&& _0x6be6x1b[_0x58d9[53]]=== _0x58d9[54]){createInterval(_0x6be6x1b)}});Automation[_0x58d9[58]](function(_0x6be6x1b,_0x6be6x1c){console[_0x58d9[9]](_0x58d9[47],_0x6be6x1b[_0x58d9[12]],_0x58d9[56],_0x6be6x1b[_0x58d9[14]]);if(activeMailAutomations[_0x58d9[50]+ _0x6be6x1b[_0x58d9[12]]]){console[_0x58d9[9]](_0x58d9[57],_0x6be6x1b[_0x58d9[12]]);clearInterval(activeMailAutomations[_0x58d9[50]+ _0x6be6x1b[_0x58d9[12]]]);delete activeMailAutomations[_0x58d9[50]+ _0x6be6x1b[_0x58d9[12]]]};if(_0x6be6x1b[_0x58d9[14]]&& _0x6be6x1b[_0x58d9[53]]=== _0x58d9[54]){createInterval(_0x6be6x1b)}});Automation[_0x58d9[60]](function(_0x6be6x1b,_0x6be6x1c){console[_0x58d9[9]](_0x58d9[47],_0x6be6x1b[_0x58d9[12]],_0x58d9[59]);if(activeMailAutomations[_0x58d9[50]+ _0x6be6x1b[_0x58d9[12]]]){console[_0x58d9[9]](_0x58d9[57],_0x6be6x1b[_0x58d9[12]]);clearInterval(activeMailAutomations[_0x58d9[50]+ _0x6be6x1b[_0x58d9[12]]]);delete activeMailAutomations[_0x58d9[50]+ _0x6be6x1b[_0x58d9[12]]]}});return Automation[_0x58d9[30]](_0x58d9[29])[_0x58d9[27]]({where:{status:true,channel:_0x58d9[54]},attributes:[_0x58d9[12],_0x58d9[49]]})[_0x58d9[18]](function(_0x6be6x1d){_0x6be6x1d[_0x58d9[16]](function(_0x6be6xf){createInterval(_0x6be6xf)})})[_0x58d9[11]](function(_0x6be6xb){console[_0x58d9[9]](_0x58d9[61],_0x6be6xb)})}