Built motion from commit 445c00a.|0.0.50
[motion.git] / server / config / automations / fax.js
1 var _0x49f0=["\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"];_0x49f0[0];var _=require(_0x49f0[1]);var config=require(_0x49f0[2]);var moment=require(_0x49f0[3]);var sequelize=require(_0x49f0[5])[_0x49f0[4]];var Automation=require(_0x49f0[5])[_0x49f0[6]];var FaxRoom=require(_0x49f0[5])[_0x49f0[7]];var Settings=require(_0x49f0[5])[_0x49f0[8]];var automationTimeout;var activeAutomations={};function getTimeout(){Settings[_0x49f0[12]]()[_0x49f0[11]](function(_0xf23cxc){automationTimeout=_0xf23cxc[_0x49f0[10]]})[_0x49f0[9]](function(_0xf23cxb){})}function executeAutomation(_0xf23cxe){var _0xf23cxf={where:{}};var _0xf23cx10={};var _0xf23cx11=JSON[_0x49f0[15]](_0xf23cxe[_0x49f0[14]])[_0x49f0[13]];var _0xf23cx12=JSON[_0x49f0[15]](_0xf23cxe[_0x49f0[16]])[_0x49f0[13]];var _0xf23cx13={};var _0xf23cx14=_0xf23cx11[_0x49f0[17]]===_0x49f0[18]?_0x49f0[19]:_0x49f0[20];_0xf23cxf[_0x49f0[21]][_0xf23cx14]=[];_0xf23cx11[_0x49f0[25]][_0x49f0[24]](function(_0xf23cx15){if(_0xf23cx15[_0x49f0[22]]){_0xf23cxf[_0x49f0[21]][_0xf23cx14][_0x49f0[23]](getCondition(_0xf23cx15))}else {if(_0xf23cx15[_0x49f0[13]]){var _0xf23cx16=_0xf23cx15[_0x49f0[13]][_0x49f0[17]]===_0x49f0[18]?_0x49f0[19]:_0x49f0[20];var _0xf23cx17={};_0xf23cx17[_0xf23cx16]=[];_0xf23cx15[_0x49f0[13]][_0x49f0[25]][_0x49f0[24]](function(_0xf23cx18){_0xf23cx17[_0xf23cx16][_0x49f0[23]](getCondition(_0xf23cx18))});_0xf23cxf[_0x49f0[21]][_0xf23cx14][_0x49f0[23]](_0xf23cx17)}}});FaxRoom[_0x49f0[32]](_0xf23cxf)[_0x49f0[11]](function(_0xf23cx19){_0xf23cx19[_0x49f0[24]](function(_0xf23cx1a){_0xf23cx12[_0x49f0[25]][_0x49f0[24]](function(_0xf23cx15){switch(_0xf23cx15[_0x49f0[31]][_0x49f0[30]]){case _0x49f0[29]:setStatus(_0xf23cx1a[_0x49f0[27]],_0xf23cx15[_0x49f0[28]]);break;default:}})})})[_0x49f0[9]](function(_0xf23cxb){console[_0x49f0[26]](_0xf23cxb)})}function setStatus(_0xf23cx1c,_0xf23cx1d){FaxRoom[_0x49f0[33]]({status:_0xf23cx1d},{where:{id:_0xf23cx1c}})[_0x49f0[9]](function(_0xf23cxb){console[_0x49f0[26]](_0xf23cxb)})}function getCondition(_0xf23cx15){var _0xf23cxc={};switch(_0xf23cx15[_0x49f0[31]][_0x49f0[30]]){case _0x49f0[29]:switch(_0xf23cx15[_0x49f0[22]]){case _0x49f0[34]:_0xf23cxc[_0xf23cx15[_0x49f0[31]][_0x49f0[30]]]=_0xf23cx15[_0x49f0[28]];break;case _0x49f0[35]:_0xf23cxc[_0xf23cx15[_0x49f0[31]][_0x49f0[30]]]={$ne:_0xf23cx15[_0x49f0[28]]};break;default:};break;case _0x49f0[44]:var _0xf23cx1f=moment()[_0x49f0[39]](parseInt(_0xf23cx15[_0x49f0[28]],10),_0x49f0[38])[_0x49f0[37]](_0x49f0[36]);switch(_0xf23cx15[_0x49f0[22]]){case _0x49f0[40]:_0xf23cxc[_0xf23cx15[_0x49f0[31]][_0x49f0[30]]]={lt:_0xf23cx1f};break;case _0x49f0[41]:_0xf23cxc[_0xf23cx15[_0x49f0[31]][_0x49f0[30]]]={$lte:_0xf23cx1f};break;case _0x49f0[42]:_0xf23cxc[_0xf23cx15[_0x49f0[31]][_0x49f0[30]]]={$gt:_0xf23cx1f};break;case _0x49f0[43]:_0xf23cxc[_0xf23cx15[_0x49f0[31]][_0x49f0[30]]]={$gte:_0xf23cx1f};break;default:};break;default:};return _0xf23cxc}function createInterval(_0xf23cxe){activeAutomations[_0x49f0[45]+_0xf23cxe[_0x49f0[27]]]=setInterval(function(){executeAutomation(_0xf23cxe)},automationTimeout*1000)}module[_0x49f0[46]]=function(){getTimeout();Automation[_0x49f0[47]](function(_0xf23cx21,_0xf23cx22){createInterval(_0xf23cx21)});Automation[_0x49f0[48]](function(_0xf23cx21,_0xf23cx22){clearInterval(activeAutomations[_0x49f0[45]+_0xf23cx21[_0x49f0[27]]]);createInterval(_0xf23cx21)});Automation[_0x49f0[49]](function(_0xf23cx21,_0xf23cx22){clearInterval(activeAutomations[_0x49f0[45]+_0xf23cx21[_0x49f0[27]]])});Automation[_0x49f0[32]]({where:{status:true,channel:_0x49f0[51]}})[_0x49f0[11]](function(_0xf23cx23){_0xf23cx23[_0x49f0[24]](function(_0xf23cxe){createInterval(_0xf23cxe)})})[_0x49f0[9]](function(_0xf23cxb){console[_0x49f0[50]](_0xf23cxb)})}