Built motion from commit d84f5db.|0.0.24
[motion.git] / server / config / automations / fax.js
1 var _0x5be4=["\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","\x46\x61\x78\x52\x6F\x6F\x6D","\x53\x65\x74\x74\x69\x6E\x67\x73","\x63\x61\x74\x63\x68","\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","\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","\x66\x61\x78"];_0x5be4[0];var _=require(_0x5be4[1]);var config=require(_0x5be4[2]);var moment=require(_0x5be4[3]);var sequelize=require(_0x5be4[5])[_0x5be4[4]];var Automation=require(_0x5be4[5])[_0x5be4[6]];var FaxRoom=require(_0x5be4[5])[_0x5be4[7]];var Settings=require(_0x5be4[5])[_0x5be4[8]];var automationTimeout;var activeAutomations={};function getTimeout(){Settings[_0x5be4[12]]()[_0x5be4[11]](function(_0xae0cxc){automationTimeout=_0xae0cxc[_0x5be4[10]]})[_0x5be4[9]](function(_0xae0cxb){})}function executeAutomation(_0xae0cxe){var _0xae0cxf={where:{}};var _0xae0cx10={};var _0xae0cx11=JSON[_0x5be4[15]](_0xae0cxe[_0x5be4[14]])[_0x5be4[13]];var _0xae0cx12=JSON[_0x5be4[15]](_0xae0cxe[_0x5be4[16]])[_0x5be4[13]];var _0xae0cx13={};var _0xae0cx14=_0xae0cx11[_0x5be4[17]]===_0x5be4[18]?_0x5be4[19]:_0x5be4[20];_0xae0cxf[_0x5be4[21]][_0xae0cx14]=[];_0xae0cx11[_0x5be4[25]][_0x5be4[24]](function(_0xae0cx15){if(_0xae0cx15[_0x5be4[22]]){_0xae0cxf[_0x5be4[21]][_0xae0cx14][_0x5be4[23]](getCondition(_0xae0cx15))}else {if(_0xae0cx15[_0x5be4[13]]){var _0xae0cx16=_0xae0cx15[_0x5be4[13]][_0x5be4[17]]===_0x5be4[18]?_0x5be4[19]:_0x5be4[20];var _0xae0cx17={};_0xae0cx17[_0xae0cx16]=[];_0xae0cx15[_0x5be4[13]][_0x5be4[25]][_0x5be4[24]](function(_0xae0cx18){_0xae0cx17[_0xae0cx16][_0x5be4[23]](getCondition(_0xae0cx18))});_0xae0cxf[_0x5be4[21]][_0xae0cx14][_0x5be4[23]](_0xae0cx17);}}});FaxRoom[_0x5be4[32]](_0xae0cxf)[_0x5be4[11]](function(_0xae0cx19){_0xae0cx19[_0x5be4[24]](function(_0xae0cx1a){_0xae0cx12[_0x5be4[25]][_0x5be4[24]](function(_0xae0cx15){switch(_0xae0cx15[_0x5be4[31]][_0x5be4[30]]){case _0x5be4[29]:setStatus(_0xae0cx1a[_0x5be4[27]],_0xae0cx15[_0x5be4[28]]);break ;;default:;}})})})[_0x5be4[9]](function(_0xae0cxb){console[_0x5be4[26]](_0xae0cxb)});}function setStatus(_0xae0cx1c,_0xae0cx1d){FaxRoom[_0x5be4[33]]({status:_0xae0cx1d},{where:{id:_0xae0cx1c}})[_0x5be4[9]](function(_0xae0cxb){console[_0x5be4[26]](_0xae0cxb)})}function getCondition(_0xae0cx15){var _0xae0cxc={};switch(_0xae0cx15[_0x5be4[31]][_0x5be4[30]]){case _0x5be4[29]:switch(_0xae0cx15[_0x5be4[22]]){case _0x5be4[34]:_0xae0cxc[_0xae0cx15[_0x5be4[31]][_0x5be4[30]]]=_0xae0cx15[_0x5be4[28]];break ;;case _0x5be4[35]:_0xae0cxc[_0xae0cx15[_0x5be4[31]][_0x5be4[30]]]={$ne:_0xae0cx15[_0x5be4[28]]};break ;;default:;};break ;;case _0x5be4[44]:var _0xae0cx1f=moment()[_0x5be4[39]](parseInt(_0xae0cx15[_0x5be4[28]],10),_0x5be4[38])[_0x5be4[37]](_0x5be4[36]);switch(_0xae0cx15[_0x5be4[22]]){case _0x5be4[40]:_0xae0cxc[_0xae0cx15[_0x5be4[31]][_0x5be4[30]]]={lt:_0xae0cx1f};break ;;case _0x5be4[41]:_0xae0cxc[_0xae0cx15[_0x5be4[31]][_0x5be4[30]]]={$lte:_0xae0cx1f};break ;;case _0x5be4[42]:_0xae0cxc[_0xae0cx15[_0x5be4[31]][_0x5be4[30]]]={$gt:_0xae0cx1f};break ;;case _0x5be4[43]:_0xae0cxc[_0xae0cx15[_0x5be4[31]][_0x5be4[30]]]={$gte:_0xae0cx1f};break ;;default:;};break ;;default:;};return _0xae0cxc;}function createInterval(_0xae0cxe){activeAutomations[_0x5be4[45]+_0xae0cxe[_0x5be4[27]]]=setInterval(function(){executeAutomation(_0xae0cxe)},automationTimeout*1000)}module[_0x5be4[46]]=function(){getTimeout();Automation[_0x5be4[47]](function(_0xae0cx21,_0xae0cx22){createInterval(_0xae0cx21)});Automation[_0x5be4[48]](function(_0xae0cx21,_0xae0cx22){clearInterval(activeAutomations[_0x5be4[45]+_0xae0cx21[_0x5be4[27]]]);createInterval(_0xae0cx21);});Automation[_0x5be4[49]](function(_0xae0cx21,_0xae0cx22){clearInterval(activeAutomations[_0x5be4[45]+_0xae0cx21[_0x5be4[27]]])});Automation[_0x5be4[32]]({where:{status:true,channel:_0x5be4[51]}})[_0x5be4[11]](function(_0xae0cx23){_0xae0cx23[_0x5be4[24]](function(_0xae0cxe){createInterval(_0xae0cxe)})})[_0x5be4[9]](function(_0xae0cxb){console[_0x5be4[50]](_0xae0cxb)});};