Built motion from commit 264c1c7.|0.0.142
[motion.git] / server / config / ami / fax.js
index 94dfccd..8b4c862 100644 (file)
@@ -1 +1 @@
-var _0xe3dd=["\x66\x73","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6C\x6F\x64\x61\x73\x68","\x62\x6C\x75\x65\x62\x69\x72\x64","\x65\x78\x65\x63","\x63\x68\x69\x6C\x64\x2D\x70\x72\x6F\x63\x65\x73\x73\x2D\x70\x72\x6F\x6D\x69\x73\x65","\x66\x73\x2D\x65\x78\x74\x72\x61","\x6D\x6F\x6D\x65\x6E\x74","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x46\x61\x78\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x54\x72\x75\x6E\x6B","\x55\x73\x65\x72","\x43\x6F\x6E\x74\x61\x63\x74","\x52\x65\x70\x6F\x72\x74\x46\x61\x78","\x2E\x2E\x2F\x75\x74\x69\x6C","\x2E\x2E\x2F\x72\x6F\x75\x74\x69\x6E\x67\x2F\x73\x63\x68\x65\x64\x75\x6C\x65\x72","\x46\x61\x78\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x73\x74\x61\x74\x75\x73","\x63\x68\x61\x6E\x67\x65\x64","\x53\x45\x4E\x44\x49\x4E\x47","\x72\x65\x74\x72\x79","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x61\x63\x63\x6F\x75\x6E\x74\x69\x64","\x66\x69\x6E\x64","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x64","\x61\x63\x63\x65\x70\x74","\x72\x65\x6A\x65\x63\x74\x65\x64\x41\x74","\x72\x65\x6A\x65\x63\x74","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x43\x4C\x4F\x53\x45\x44","\x63\x6C\x6F\x73\x65","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x70\x75\x73\x68","\x69\x64","\x46\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74\x3A\x20","\x6E\x61\x6D\x65","\x20\x55\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x75\x6E\x73\x68\x69\x66\x74","\x72\x65\x6D\x6F\x76\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x63\x63\x65\x70\x74\x4D\x65\x74\x68\x6F\x64","\x61\x63\x63\x65\x70\x74\x55\x72\x6C","\x46\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74\x20\x3C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x61\x63\x63\x65\x70\x74\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x6C\x65\x6E\x67\x74\x68","\x61\x63\x74\x69\x6F\x6E\x73","\x65\x6E\x61\x62\x6C\x65\x64","\x65\x78\x65\x63\x41\x63\x74\x69\x6F\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x72\x65\x6A\x65\x63\x74\x4D\x65\x74\x68\x6F\x64","\x72\x65\x6A\x65\x63\x74\x55\x72\x6C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x72\x65\x6A\x65\x63\x74\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x63\x6C\x6F\x73\x65\x4D\x65\x74\x68\x6F\x64","\x63\x6C\x6F\x73\x65\x55\x72\x6C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x63\x6C\x6F\x73\x65\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x57\x65\x62\x68\x6F\x6F\x6B\x20\x6E\x6F\x74\x20\x72\x65\x63\x6F\x67\x6E\x69\x7A\x65\x64","\x72\x65\x71\x75\x65\x73\x74\x20\x66\x61\x69\x6C\x65\x64\x21","\x72\x65\x71\x75\x65\x73\x74\x20\x73\x75\x63\x63\x65\x73\x73\x65\x66\x75\x6C\x21","\x73\x65\x6E\x64\x52\x65\x71\x75\x65\x73\x74","\x75\x70\x64\x61\x74\x65\x45\x72\x72\x6F\x72","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x45\x72\x72\x6F\x72","\x46\x61\x78\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x76\x61\x6C\x75\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x63\x68\x61\x6E\x6E\x65\x6C","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x70\x64\x61\x74\x65\x4D\x65\x73\x73\x61\x67\x65","\x63\x68\x61\x6E\x6E\x65\x6C\x73\x74\x61\x74\x65","\x63\x68\x61\x6E\x6E\x65\x6C\x73\x74\x61\x74\x65\x64\x65\x73\x63","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x61\x6D\x65","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x6C\x69\x6E\x65\x6E\x75\x6D","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x6C\x69\x6E\x65\x6E\x61\x6D\x65","\x61\x63\x63\x6F\x75\x6E\x74\x63\x6F\x64\x65","\x63\x6F\x6E\x74\x65\x78\x74","\x65\x78\x74\x65\x6E","\x70\x72\x69\x6F\x72\x69\x74\x79","\x75\x6E\x69\x71\x75\x65\x69\x64","\x6C\x69\x6E\x6B\x65\x64\x69\x64","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x75\x70\x64\x61\x74\x65\x53\x65\x6E\x64","\x46\x61\x78\x20\x72\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x53\x45\x4E\x54","\x67\x65\x74\x46\x61\x78\x52\x6F\x6F\x6D","\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64","\x30","\x46\x41\x49\x4C\x45\x44","\x72\x65\x6D\x6F\x74\x65\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x72\x65\x73\x6F\x6C\x75\x74\x69\x6F\x6E","\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x61\x74\x65","\x72\x65\x63\x65\x69\x76\x65\x66\x61\x78","\x4E\x65\x77\x20\x46\x61\x78\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x66\x72\x6F\x6D\x20\x25\x73","\x66\x6F\x72\x6D\x61\x74","\x63\x6C\x6F\x6E\x65","\x45\x72\x72\x6F\x72\x20\x72\x65\x63\x65\x69\x76\x69\x6E\x67\x20\x66\x61\x78\x20\x6D\x65\x73\x73\x61\x67\x65","\x66\x61\x78","\x25\x73\x2E\x25\x73","\x75\x6E\x69\x78","\x66\x72\x6F\x6D","\x69\x6E\x69\x74","\x74\x69\x66\x66\x32\x70\x64\x66\x20\x2D\x6F\x20","\x20","\x70\x61\x72\x73\x65","\x2E\x70\x64\x66","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x69\x6E\x62\x6F\x75\x6E\x64","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x6A\x6F\x69\x6E","\x63\x72\x65\x61\x74\x65","\x46\x61\x78\x20\x72\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x2F\x63\x72\x65\x61\x74\x65\x64","\x46\x61\x78\x52\x6F\x6F\x6D\x49\x64","\x52\x45\x43\x45\x49\x56\x45\x44","\x74\x6F","\x66\x69\x72\x73\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x4F\x50\x45\x4E","\x73\x79\x73\x74\x65\x6D","\x66\x61\x78\x49\x6E","\x4E\x45\x57","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x73\x70\x72\x65\x61\x64","\x46\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x46\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74\x20\x66\x6F\x75\x6E\x64\x3A","\x4C\x69\x73\x74\x49\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x45\x72\x72\x6F\x72\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x66\x61\x78","\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x65\x72\x72\x6F\x72\x20\x73\x74\x61\x74\x75\x73","\x75\x70\x64\x61\x74\x65","\x72\x65\x73","\x6F\x72\x69\x67\x69\x6E\x61\x74\x65","\x25\x73\x2F\x25\x73\x2F\x25\x73","\x74\x65\x63\x68","\x6F\x75\x74\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x22\x25\x73\x22\x20\x3C\x25\x73\x3E","\x65\x63\x6D","\x68\x65\x61\x64\x65\x72\x69\x6E\x66\x6F","\x6D\x69\x6E\x72\x61\x74\x65","\x6D\x61\x78\x72\x61\x74\x65","\x22\x25\x73\x22","\x6D\x6F\x64\x65\x6D","\x67\x61\x74\x65\x77\x61\x79","\x74\x33\x38\x74\x69\x6D\x65\x6F\x75\x74","\x61\x63\x74\x69\x6F\x6E","\x70\x72\x6F\x6D\x69\x73\x69\x66\x79","\x63\x68\x6D\x6F\x64\x53\x79\x6E\x63","\x46\x61\x78\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x74\x79\x70\x65","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x70\x64\x66","\x6F\x75\x74\x62\x6F\x75\x6E\x64","\x2F","\x2E\x74\x69\x66","\x67\x73\x20\x2D\x71\x20\x2D\x64\x4E\x4F\x50\x41\x55\x53\x45\x20\x2D\x64\x42\x41\x54\x43\x48\x20\x2D\x73\x44\x45\x56\x49\x43\x45\x3D\x74\x69\x66\x66\x67\x34\x20\x2D\x73\x50\x41\x50\x45\x52\x53\x49\x5A\x45\x3D\x6C\x65\x74\x74\x65\x72\x20\x2D\x73\x4F\x75\x74\x70\x75\x74\x46\x69\x6C\x65\x3D","\x62\x61\x73\x65","\x63\x6F\x70\x79\x53\x79\x6E\x63","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x64\x64\x55\x73\x65\x72","\x50\x45\x4E\x44\x49\x4E\x47","\x66\x61\x78\x4F\x75\x74","\x75\x73\x65\x72","\x61\x64\x64\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x54\x72\x75\x6E\x6B\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x54\x72\x75\x6E\x6B\x4E\x61\x6D\x65","\x65\x78\x70\x6F\x72\x74\x73"];var fs=require(_0xe3dd[0]);var util=require(_0xe3dd[1]);var path=require(_0xe3dd[2]);var config=require(_0xe3dd[3]);var _=require(_0xe3dd[4]);var Promise=require(_0xe3dd[5]);var exec=require(_0xe3dd[7])[_0xe3dd[6]];var fse=require(_0xe3dd[8]);var moment=require(_0xe3dd[9]);var FaxAccount=require(_0xe3dd[11])[_0xe3dd[10]];var FaxRoom=require(_0xe3dd[11])[_0xe3dd[12]];var FaxMessage=require(_0xe3dd[11])[_0xe3dd[13]];var FaxAttachment=require(_0xe3dd[11])[_0xe3dd[14]];var Trunk=require(_0xe3dd[11])[_0xe3dd[15]];var User=require(_0xe3dd[11])[_0xe3dd[16]];var Contact=require(_0xe3dd[11])[_0xe3dd[17]];var ReportFax=require(_0xe3dd[11])[_0xe3dd[18]];var Util=require(_0xe3dd[19]);var Scheduler=require(_0xe3dd[20]);var faxaccounts;function Fax(_0x7479x16){console[_0xe3dd[22]](_0xe3dd[21]);FaxMessage[_0xe3dd[23]](function(_0x7479x17,_0x7479x18){sendfax(_0x7479x17,_0x7479x16,0,_0x7479x18)});FaxMessage[_0xe3dd[28]](function(_0x7479x17,_0x7479x18){if(_0x7479x17[_0xe3dd[25]](_0xe3dd[24])&& _0x7479x17[_0xe3dd[24]]=== _0xe3dd[26]){sendfax(_0x7479x17,_0x7479x16,_0x7479x17[_0xe3dd[27]]+ 1,_0x7479x18)}});FaxAccount[_0xe3dd[41]]()[_0xe3dd[40]](function(_0x7479x1a){faxaccounts= _0x7479x1a;synch(faxaccounts);ReportFax[_0xe3dd[28]](function(_0x7479x17){var _0x7479x1b=_[_0xe3dd[32]](faxaccounts,{id:parseInt(_0x7479x17[_0xe3dd[31]])});if(_0x7479x1b&& _0x7479x17[_0xe3dd[25]](_0xe3dd[33])){webhook(_0x7479x17,_0x7479x1b,_0xe3dd[34])};if(_0x7479x1b&& _0x7479x17[_0xe3dd[25]](_0xe3dd[35])){webhook(_0x7479x17,_0x7479x1b,_0xe3dd[36])}});FaxRoom[_0xe3dd[28]](function(_0x7479x17){var _0x7479x1b=_[_0xe3dd[32]](faxaccounts,{id:_0x7479x17[_0xe3dd[37]]});if(_0x7479x1b&& _0x7479x17[_0xe3dd[25]](_0xe3dd[24])&& _0x7479x17[_0xe3dd[24]]=== _0xe3dd[38]){webhook(_0x7479x17,_0x7479x1b,_0xe3dd[39])}})})[_0xe3dd[30]](function(_0x7479x19){console[_0xe3dd[29]](_0x7479x19)})}function synch(faxaccounts){FaxAccount[_0xe3dd[23]](function(_0x7479x17){faxaccounts[_0xe3dd[42]](_0x7479x17)});FaxAccount[_0xe3dd[28]](function(_0x7479x17){var _0x7479x1d=_[_0xe3dd[32]](faxaccounts,{id:_0x7479x17[_0xe3dd[43]]});if(_0x7479x1d){console[_0xe3dd[22]](_0xe3dd[44]+ _0x7479x1d[_0xe3dd[45]]+ _0xe3dd[46]);_[_0xe3dd[47]](_0x7479x1d,_0x7479x17)}else {faxaccounts[_0xe3dd[48]](_0x7479x17)}});FaxAccount[_0xe3dd[50]](function(_0x7479x17){_[_0xe3dd[49]](faxaccounts,{id:_0x7479x17[_0xe3dd[43]]})})}function webhook(_0x7479x17,_0x7479x1b,_0x7479x1f){var _0x7479x20=_0x7479x1b;switch(_0x7479x1f){case _0xe3dd[34]:if(_0x7479x20[_0xe3dd[51]]&& _0x7479x20[_0xe3dd[52]]){console[_0xe3dd[22]](_0xe3dd[53]+ _0x7479x20[_0xe3dd[45]]+ _0xe3dd[54]);execRequest(_0x7479x17[_0xe3dd[55]],_0x7479x20[_0xe3dd[51]],_0x7479x20[_0xe3dd[52]])};if(_0x7479x20[_0xe3dd[57]][_0xe3dd[56]]){_[_0xe3dd[60]](_0x7479x20[_0xe3dd[57]],function(_0x7479x21){if(_0x7479x21[_0xe3dd[58]]){Util[_0xe3dd[59]](_0x7479x21,_0x7479x17)}})};break;case _0xe3dd[36]:if(_0x7479x20[_0xe3dd[61]]&& _0x7479x20[_0xe3dd[62]]){console[_0xe3dd[22]](_0xe3dd[53]+ _0x7479x20[_0xe3dd[45]]+ _0xe3dd[63]);execRequest(_0x7479x17[_0xe3dd[55]],_0x7479x20[_0xe3dd[61]],_0x7479x20[_0xe3dd[62]])};break;case _0xe3dd[39]:if(_0x7479x20[_0xe3dd[64]]&& _0x7479x20[_0xe3dd[65]]){console[_0xe3dd[22]](_0xe3dd[53]+ _0x7479x20[_0xe3dd[45]]+ _0xe3dd[66]);execRequest(_0x7479x17[_0xe3dd[55]],_0x7479x20[_0xe3dd[64]],_0x7479x20[_0xe3dd[65]])};break;default:console[_0xe3dd[22]](_0xe3dd[67])}}function execRequest(_0x7479x17,_0x7479x23,_0x7479x24){Util[_0xe3dd[70]](_0x7479x17,_0x7479x23,_0x7479x24)[_0xe3dd[40]](function(_0x7479x25){console[_0xe3dd[22]](_0xe3dd[69])})[_0xe3dd[30]](function(_0x7479x19){console[_0xe3dd[22]](_0xe3dd[68])})}Fax[_0xe3dd[72]][_0xe3dd[71]]= function(_0x7479x26){return FaxMessage[_0xe3dd[78]]({where:{channel:_0x7479x26[_0xe3dd[77]]}})[_0xe3dd[40]](function(_0x7479x27){if(!_0x7479x27){throw  new Error(_0xe3dd[74])};return _0x7479x27[_0xe3dd[76]]({error:_0x7479x26[_0xe3dd[75]]})})[_0xe3dd[30]](function(_0x7479x19){console[_0xe3dd[22]](_0xe3dd[73],_0x7479x19)})};Fax[_0xe3dd[72]][_0xe3dd[79]]= function(_0x7479x26){return FaxMessage[_0xe3dd[78]]({where:{filename:_0x7479x26[_0xe3dd[92]],localstationid:_0x7479x26[_0xe3dd[93]]}})[_0xe3dd[40]](function(_0x7479x27){if(!_0x7479x27){throw  new Error(_0xe3dd[74])};return _0x7479x27[_0xe3dd[76]]({channel:_0x7479x26[_0xe3dd[77]],channelstate:_0x7479x26[_0xe3dd[80]],channelstatedesc:_0x7479x26[_0xe3dd[81]],calleridnum:_0x7479x26[_0xe3dd[82]],calleridname:_0x7479x26[_0xe3dd[83]],connectedlinenum:_0x7479x26[_0xe3dd[84]],connectedlinename:_0x7479x26[_0xe3dd[85]],accountcode:_0x7479x26[_0xe3dd[86]],context:_0x7479x26[_0xe3dd[87]],exten:_0x7479x26[_0xe3dd[88]],priority:_0x7479x26[_0xe3dd[89]],uniqueid:_0x7479x26[_0xe3dd[90]],linkedid:_0x7479x26[_0xe3dd[91]],lastStatus:_0x7479x26[_0xe3dd[24]]})})[_0xe3dd[30]](function(_0x7479x19){console[_0xe3dd[22]](_0xe3dd[73],_0x7479x19)})};Fax[_0xe3dd[72]][_0xe3dd[94]]= function(_0x7479x26){var _0x7479x28;return FaxMessage[_0xe3dd[78]]({where:{filename:_0x7479x26[_0xe3dd[92]],localstationid:_0x7479x26[_0xe3dd[93]]}})[_0xe3dd[40]](function(_0x7479x27){if(!_0x7479x27){throw  new Error(_0xe3dd[74])};_0x7479x28= _0x7479x27;var _0x7479x2a=_0xe3dd[96];if(_0x7479x26[_0xe3dd[98]]== _0xe3dd[99]){_0x7479x2a= _0xe3dd[100]};return _0x7479x28[_0xe3dd[76]]({remotestationid:_0x7479x26[_0xe3dd[101]],pagestransferred:_0x7479x26[_0xe3dd[98]],resolution:_0x7479x26[_0xe3dd[102]],transferrate:_0x7479x26[_0xe3dd[103]],status:_0x7479x2a})})[_0xe3dd[40]](function(){return _0x7479x28[_0xe3dd[97]]()})[_0xe3dd[40]](function(_0x7479x29){if(!_0x7479x29){throw  new Error(_0xe3dd[95])};return _0x7479x29[_0xe3dd[76]]({lastEvent:_0xe3dd[96]},{individualHooks:true})})[_0xe3dd[30]](function(_0x7479x19){console[_0xe3dd[22]](_0xe3dd[73],_0x7479x19)})};Fax[_0xe3dd[72]][_0xe3dd[104]]= function(_0x7479x26){console[_0xe3dd[22]](util[_0xe3dd[106]](_0xe3dd[105],_0x7479x26[_0xe3dd[82]]));var _0x7479x2b=_[_0xe3dd[107]](_0x7479x26);var _0x7479x2c;var _0x7479x28,_0x7479x2d;return FaxAccount[_0xe3dd[78]]({where:{localstationid:_0x7479x26[_0xe3dd[93]]}})[_0xe3dd[40]](function(_0x7479x37){if(!_0x7479x37){throw  new Error(_0xe3dd[138])};console[_0xe3dd[22]](_0xe3dd[139],_0x7479x26[_0xe3dd[93]]);_0x7479x2c= _0x7479x37;if(_0x7479x2c[_0xe3dd[140]]){return Contact[_0xe3dd[141]]({where:{ListId:_0x7479x2c[_0xe3dd[140]],$or:[{phone:_0x7479x26[_0xe3dd[82]]},{fax:_0x7479x26[_0xe3dd[82]]}]},defaults:{phone:_0x7479x26[_0xe3dd[82]],fax:_0x7479x26[_0xe3dd[82]],firstName:_0x7479x26[_0xe3dd[82]],ListId:_0x7479x2c[_0xe3dd[140]]}})}else {return []}})[_0xe3dd[137]](function(_0x7479x35,_0x7479x36){if(_0x7479x36!= undefined&&  !_0x7479x36){return _0x7479x35[_0xe3dd[76]]({fax:_0x7479x26[_0xe3dd[82]]})};return})[_0xe3dd[40]](function(){return FaxRoom[_0xe3dd[41]]({limit:1,where:{contact:_0x7479x2b[_0xe3dd[82]],FaxAccountId:_0x7479x2c[_0xe3dd[43]],status:{$ne:_0xe3dd[38]}},order:[[_0xe3dd[135],_0xe3dd[136]]]})})[_0xe3dd[40]](function(_0x7479x34){if(_0x7479x34[_0xe3dd[56]]){_0x7479x34= _[_0xe3dd[129]](_0x7479x34);return _0x7479x34[_0xe3dd[76]]({lastEvent:_0xe3dd[127],lastEventAt:moment()[_0xe3dd[106]](_0xe3dd[130]),status:_0xe3dd[131],openReason:_0xe3dd[132],faxIn:++_0x7479x34[_0xe3dd[133]]})}else {return FaxRoom[_0xe3dd[124]]({contact:_0x7479x2b[_0xe3dd[82]],account:_0x7479x2c[_0xe3dd[45]],status:_0xe3dd[134],lastEvent:_0xe3dd[127],lastEventAt:moment()[_0xe3dd[106]](_0xe3dd[130]),FaxAccountId:_0x7479x2c[_0xe3dd[43]],faxIn:1})}})[_0xe3dd[40]](function(_0x7479x34){if(!_0x7479x34){throw  new Error(_0xe3dd[125])};_0x7479x2d= _0x7479x34;_0x7479x2b[_0xe3dd[126]]= _0x7479x34[_0xe3dd[43]];_0x7479x2b[_0xe3dd[24]]= _0xe3dd[127];_0x7479x2b[_0xe3dd[112]]= _0x7479x2b[_0xe3dd[82]];_0x7479x2b[_0xe3dd[128]]= _0x7479x2b[_0xe3dd[93]];return FaxMessage[_0xe3dd[124]](_0x7479x2b)})[_0xe3dd[40]](function(_0x7479x30){_0x7479x28= _0x7479x30;var _0x7479x31=[];var _0x7479x32=path[_0xe3dd[116]](_0x7479x26[_0xe3dd[92]])[_0xe3dd[45]];var _0x7479x33=_0x7479x32+ _0xe3dd[117];return FaxAttachment[_0xe3dd[124]]({path:path[_0xe3dd[123]](config[_0xe3dd[118]],_0xe3dd[119],_0xe3dd[120],_0xe3dd[109],_0xe3dd[121],_0xe3dd[122],_0x7479x33),basename:_0x7479x33,name:_0x7479x32,FaxMessageId:_0x7479x30[_0xe3dd[43]]})})[_0xe3dd[40]](function(_0x7479x2f){return exec(_0xe3dd[114]+ _0x7479x2f[_0xe3dd[2]]+ _0xe3dd[115]+ _0x7479x26[_0xe3dd[92]])})[_0xe3dd[40]](function(){var _0x7479x2e= new Scheduler({channel:_0xe3dd[109],uniqueid:util[_0xe3dd[106]](_0xe3dd[110],moment()[_0xe3dd[111]](),_0x7479x2d[_0xe3dd[43]]),messageid:_0x7479x28[_0xe3dd[43]],roomid:_0x7479x2d[_0xe3dd[43]],accountid:_0x7479x2c[_0xe3dd[43]],accountname:_0x7479x2c[_0xe3dd[45]],accountphone:_0x7479x2c[_0xe3dd[93]],from:_0x7479x28[_0xe3dd[112]]});_0x7479x2e[_0xe3dd[113]]()})[_0xe3dd[30]](function(_0x7479x19){console[_0xe3dd[22]](_0xe3dd[108],_0x7479x19)})};function sendfax(_0x7479x30,_0x7479x16,_0x7479x39,_0x7479x18){if(_0x7479x30[_0xe3dd[24]]=== _0xe3dd[26]){var _0x7479x2d;var _0x7479x28=_0x7479x30;var _0x7479x3a=_0x7479x30[_0xe3dd[112]];var _0x7479x3b=_0x7479x30[_0xe3dd[128]];var _0x7479x3c;var _0x7479x3d;var _0x7479x3e,_0x7479x3f;return FaxAccount[_0xe3dd[78]]({where:{localstationid:_0x7479x28[_0xe3dd[112]]}})[_0xe3dd[40]](function(_0x7479x37){if(!_0x7479x37){throw  new Error(_0xe3dd[138])};_0x7479x3c= _[_0xe3dd[107]](_0x7479x37[_0xe3dd[55]]);return Trunk[_0xe3dd[78]]({where:{name:_0x7479x3c[_0xe3dd[178]]},attributes:[_0xe3dd[45]]})})[_0xe3dd[40]](function(_0x7479x41){if(!_0x7479x41){throw  new Error(_0xe3dd[177])};_0x7479x3d= _[_0xe3dd[107]](_0x7479x41[_0xe3dd[55]]);return})[_0xe3dd[40]](function(){return _0x7479x3c})[_0xe3dd[40]](getFaxRoom(_0x7479x28))[_0xe3dd[40]](function(_0x7479x29){_0x7479x2d= _0x7479x29;return _0x7479x2d[_0xe3dd[176]](_0x7479x28[_0xe3dd[43]])})[_0xe3dd[40]](function(){return _0x7479x2d[_0xe3dd[76]]({status:_0xe3dd[173],lastEvent:_0xe3dd[26],lastEventAt:moment()[_0xe3dd[106]](_0xe3dd[130]),faxOut:++_0x7479x2d[_0xe3dd[174]]},{individualHooks:true,user:_0x7479x18[_0xe3dd[175]]})})[_0xe3dd[40]](function(){return _0x7479x2d[_0xe3dd[172]](_0x7479x28.UserId)})[_0xe3dd[40]](function(){return User[_0xe3dd[171]](_0x7479x28.UserId)})[_0xe3dd[40]](function(){if(_0x7479x3c[_0xe3dd[140]]){return Contact[_0xe3dd[141]]({where:{ListId:_0x7479x3c[_0xe3dd[140]],$or:[{phone:_0x7479x3b},{fax:_0x7479x3b}]},defaults:{fax:_0x7479x3b,phone:_0x7479x3b,firstName:_0x7479x3b,ListId:_0x7479x3c[_0xe3dd[140]]}})}else {return []}})[_0xe3dd[137]](function(_0x7479x35,_0x7479x36){if(_0x7479x36!= undefined&&  !_0x7479x36){return _0x7479x35[_0xe3dd[76]]({fax:_0x7479x3b})};return})[_0xe3dd[40]](function(){_0x7479x3e= _0x7479x28[_0xe3dd[162]][0][_0xe3dd[2]];if(_0x7479x28[_0xe3dd[162]][0][_0xe3dd[163]]=== _0xe3dd[164]){_0x7479x3f= path[_0xe3dd[123]](config[_0xe3dd[118]],_0xe3dd[119],_0xe3dd[120],_0xe3dd[109],_0xe3dd[165],_0xe3dd[122],_0xe3dd[166],path[_0xe3dd[116]](_0x7479x3e)[_0xe3dd[45]]+ _0xe3dd[167]);return exec(_0xe3dd[168]+ _0x7479x3f+ _0xe3dd[115]+ _0x7479x3e)}else {_0x7479x3f= path[_0xe3dd[123]](config[_0xe3dd[118]],_0xe3dd[119],_0xe3dd[120],_0xe3dd[109],_0xe3dd[165],_0xe3dd[122],_0xe3dd[166],path[_0xe3dd[116]](_0x7479x3e)[_0xe3dd[169]]);fse[_0xe3dd[170]](_0x7479x3e,_0x7479x3f);return}})[_0xe3dd[40]](function(){fs[_0xe3dd[161]](_0x7479x3f,511);return _0x7479x28[_0xe3dd[76]]({filename:_0x7479x3f,localstationid:_0x7479x28[_0xe3dd[112]],retry:_0x7479x39})})[_0xe3dd[40]](function(){return Promise[_0xe3dd[160]](_0x7479x16[_0xe3dd[159]])({action:_0xe3dd[146],channel:util[_0xe3dd[106]](_0xe3dd[147],_0x7479x3c[_0xe3dd[148]],_0x7479x3d[_0xe3dd[45]],_0x7479x3b),exten:_0x7479x3b,context:_0xe3dd[149],priority:1,callerid:util[_0xe3dd[106]](_0xe3dd[150],_0x7479x3c[_0xe3dd[93]],_0x7479x3c[_0xe3dd[93]]),variable:{FAXNAME:_0x7479x3c[_0xe3dd[45]],FAXNUMBER:_0x7479x3b,FAXECM:_0x7479x3c[_0xe3dd[151]],FAXHEADERINFO:_0x7479x3c[_0xe3dd[152]],FAXLOCALSTATIONID:_0x7479x3c[_0xe3dd[93]],FAXMINRATE:_0x7479x3c[_0xe3dd[153]],FAXMAXRATE:_0x7479x3c[_0xe3dd[154]],FAXMODEM:util[_0xe3dd[106]](_0xe3dd[155],_0x7479x3c[_0xe3dd[156]]),FAXGATEWAY:_0x7479x3c[_0xe3dd[157]],FAXT38TIMEOUT:_0x7479x3c[_0xe3dd[158]],FAXOUTFILE:_0x7479x3f},account:_0x7479x3c[_0xe3dd[93]]})})[_0xe3dd[40]](function(_0x7479x40){console[_0xe3dd[22]](_0xe3dd[145],_0x7479x40)})[_0xe3dd[30]](function(_0x7479x19){console[_0xe3dd[22]](_0xe3dd[142],_0x7479x19);return _0x7479x28[_0xe3dd[144]]({status:_0xe3dd[100]})[_0xe3dd[40]](function(){if(_0x7479x2d){return _0x7479x2d[_0xe3dd[76]]({lastEvent:_0xe3dd[100]})};return})[_0xe3dd[30]](function(_0x7479x19){console[_0xe3dd[22]](_0xe3dd[143])})})}}function getFaxRoom(_0x7479x28){return function(_0x7479x1b){if(_0x7479x28[_0xe3dd[126]]){return FaxRoom[_0xe3dd[171]](_0x7479x28.FaxRoomId)}else {return FaxRoom[_0xe3dd[41]]({limit:1,where:{contact:_0x7479x28[_0xe3dd[128]],FaxAccountId:_0x7479x1b[_0xe3dd[43]]},order:[[_0xe3dd[135],_0xe3dd[136]]]})[_0xe3dd[40]](function(_0x7479x43){var _0x7479x34=_[_0xe3dd[129]](_0x7479x43);if(!_0x7479x34|| _0x7479x34[_0xe3dd[24]]=== _0xe3dd[38]){return FaxRoom[_0xe3dd[124]]({contact:_0x7479x28[_0xe3dd[128]],account:_0x7479x1b[_0xe3dd[45]],status:_0xe3dd[173],FaxAccountId:_0x7479x1b[_0xe3dd[43]]})}else {return _0x7479x34}})}}}module[_0xe3dd[179]]= Fax
\ No newline at end of file
+var _0x28ef=["\x75\x73\x65\x20\x73\x74\x69\x63\x74","\x66\x73","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6C\x6F\x64\x61\x73\x68","\x62\x6C\x75\x65\x62\x69\x72\x64","\x65\x78\x65\x63","\x63\x68\x69\x6C\x64\x2D\x70\x72\x6F\x63\x65\x73\x73\x2D\x70\x72\x6F\x6D\x69\x73\x65","\x66\x73\x2D\x65\x78\x74\x72\x61","\x6D\x6F\x6D\x65\x6E\x74","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x46\x61\x78\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x54\x72\x75\x6E\x6B","\x55\x73\x65\x72","\x43\x6F\x6E\x74\x61\x63\x74","\x52\x65\x70\x6F\x72\x74\x46\x61\x78","\x2E\x2E\x2F\x75\x74\x69\x6C","\x2E\x2E\x2F\x72\x6F\x75\x74\x69\x6E\x67\x2F\x73\x63\x68\x65\x64\x75\x6C\x65\x72","\x46\x61\x78\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x6D\x65\x73\x73\x61\x67\x65","\x64\x6F\x63","\x6F\x70\x74\x69\x6F\x6E\x73","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65\x2E\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x63\x68\x61\x6E\x67\x65\x64","\x73\x74\x61\x74\x75\x73","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x53\x45\x4E\x44\x49\x4E\x47","\x72\x65\x74\x72\x79","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65\x2E\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x63\x63\x6F\x75\x6E\x74\x69\x64","\x66\x69\x6E\x64","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x64","\x61\x63\x63\x65\x70\x74","\x72\x65\x6A\x65\x63\x74\x65\x64\x41\x74","\x72\x65\x6A\x65\x63\x74","\x52\x65\x70\x6F\x72\x74\x46\x61\x78\x2E\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x43\x4C\x4F\x53\x45\x44","\x63\x6C\x6F\x73\x65","\x46\x61\x78\x52\x6F\x6F\x6D\x2E\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x70\x75\x73\x68","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x2E\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x69\x64","\x46\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74\x3A\x20","\x6E\x61\x6D\x65","\x20\x55\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x75\x6E\x73\x68\x69\x66\x74","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x2E\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x72\x65\x6D\x6F\x76\x65","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x2E\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6F\x6E","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x61\x63\x63\x65\x70\x74\x4D\x65\x74\x68\x6F\x64","\x61\x63\x63\x65\x70\x74\x55\x72\x6C","\x46\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74\x20\x3C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x61\x63\x63\x65\x70\x74\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x6C\x65\x6E\x67\x74\x68","\x61\x63\x74\x69\x6F\x6E\x73","\x65\x6E\x61\x62\x6C\x65\x64","\x65\x78\x65\x63\x41\x63\x74\x69\x6F\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x72\x65\x6A\x65\x63\x74\x4D\x65\x74\x68\x6F\x64","\x72\x65\x6A\x65\x63\x74\x55\x72\x6C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x72\x65\x6A\x65\x63\x74\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x63\x6C\x6F\x73\x65\x4D\x65\x74\x68\x6F\x64","\x63\x6C\x6F\x73\x65\x55\x72\x6C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x63\x6C\x6F\x73\x65\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x57\x65\x62\x68\x6F\x6F\x6B\x20\x6E\x6F\x74\x20\x72\x65\x63\x6F\x67\x6E\x69\x7A\x65\x64","\x72\x65\x71\x75\x65\x73\x74\x20\x66\x61\x69\x6C\x65\x64\x21","\x72\x65\x71\x75\x65\x73\x74\x20\x73\x75\x63\x63\x65\x73\x73\x65\x66\x75\x6C\x21","\x73\x65\x6E\x64\x52\x65\x71\x75\x65\x73\x74","\x75\x70\x64\x61\x74\x65\x45\x72\x72\x6F\x72","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x45\x72\x72\x6F\x72","\x46\x61\x78\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x76\x61\x6C\x75\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x63\x68\x61\x6E\x6E\x65\x6C","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x70\x64\x61\x74\x65\x4D\x65\x73\x73\x61\x67\x65","\x63\x68\x61\x6E\x6E\x65\x6C\x73\x74\x61\x74\x65","\x63\x68\x61\x6E\x6E\x65\x6C\x73\x74\x61\x74\x65\x64\x65\x73\x63","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x61\x6D\x65","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x6C\x69\x6E\x65\x6E\x75\x6D","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x6C\x69\x6E\x65\x6E\x61\x6D\x65","\x61\x63\x63\x6F\x75\x6E\x74\x63\x6F\x64\x65","\x63\x6F\x6E\x74\x65\x78\x74","\x65\x78\x74\x65\x6E","\x70\x72\x69\x6F\x72\x69\x74\x79","\x75\x6E\x69\x71\x75\x65\x69\x64","\x6C\x69\x6E\x6B\x65\x64\x69\x64","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x75\x70\x64\x61\x74\x65\x53\x65\x6E\x64","\x46\x61\x78\x20\x72\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x53\x45\x4E\x54","\x67\x65\x74\x46\x61\x78\x52\x6F\x6F\x6D","\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64","\x30","\x46\x41\x49\x4C\x45\x44","\x72\x65\x6D\x6F\x74\x65\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x72\x65\x73\x6F\x6C\x75\x74\x69\x6F\x6E","\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x61\x74\x65","\x72\x65\x63\x65\x69\x76\x65\x66\x61\x78","\x4E\x65\x77\x20\x46\x61\x78\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x66\x72\x6F\x6D\x20\x25\x73","\x66\x6F\x72\x6D\x61\x74","\x63\x6C\x6F\x6E\x65","\x45\x72\x72\x6F\x72\x20\x72\x65\x63\x65\x69\x76\x69\x6E\x67\x20\x66\x61\x78\x20\x6D\x65\x73\x73\x61\x67\x65","\x66\x61\x78","\x25\x73\x2E\x25\x73","\x75\x6E\x69\x78","\x66\x72\x6F\x6D","\x69\x6E\x69\x74","\x74\x69\x66\x66\x32\x70\x64\x66\x20\x2D\x6F\x20","\x20","\x70\x61\x72\x73\x65","\x2E\x70\x64\x66","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x69\x6E\x62\x6F\x75\x6E\x64","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x6A\x6F\x69\x6E","\x63\x72\x65\x61\x74\x65","\x46\x61\x78\x20\x72\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x2F\x63\x72\x65\x61\x74\x65\x64","\x46\x61\x78\x52\x6F\x6F\x6D\x49\x64","\x52\x45\x43\x45\x49\x56\x45\x44","\x74\x6F","\x66\x69\x72\x73\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x4F\x50\x45\x4E","\x73\x79\x73\x74\x65\x6D","\x66\x61\x78\x49\x6E","\x4E\x45\x57","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x73\x70\x72\x65\x61\x64","\x46\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x46\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74\x20\x66\x6F\x75\x6E\x64\x3A","\x4C\x69\x73\x74\x49\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x45\x72\x72\x6F\x72\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x66\x61\x78","\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x65\x72\x72\x6F\x72\x20\x73\x74\x61\x74\x75\x73","\x75\x70\x64\x61\x74\x65","\x72\x65\x73","\x6F\x72\x69\x67\x69\x6E\x61\x74\x65","\x25\x73\x2F\x25\x73\x2F\x25\x73","\x74\x65\x63\x68","\x6F\x75\x74\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x22\x25\x73\x22\x20\x3C\x25\x73\x3E","\x65\x63\x6D","\x68\x65\x61\x64\x65\x72\x69\x6E\x66\x6F","\x6D\x69\x6E\x72\x61\x74\x65","\x6D\x61\x78\x72\x61\x74\x65","\x22\x25\x73\x22","\x6D\x6F\x64\x65\x6D","\x67\x61\x74\x65\x77\x61\x79","\x74\x33\x38\x74\x69\x6D\x65\x6F\x75\x74","\x61\x63\x74\x69\x6F\x6E","\x70\x72\x6F\x6D\x69\x73\x69\x66\x79","\x63\x68\x6D\x6F\x64\x53\x79\x6E\x63","\x46\x61\x78\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x74\x79\x70\x65","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x70\x64\x66","\x6F\x75\x74\x62\x6F\x75\x6E\x64","\x2F","\x2E\x74\x69\x66","\x67\x73\x20\x2D\x71\x20\x2D\x64\x4E\x4F\x50\x41\x55\x53\x45\x20\x2D\x64\x42\x41\x54\x43\x48\x20\x2D\x73\x44\x45\x56\x49\x43\x45\x3D\x74\x69\x66\x66\x67\x34\x20\x2D\x73\x50\x41\x50\x45\x52\x53\x49\x5A\x45\x3D\x6C\x65\x74\x74\x65\x72\x20\x2D\x73\x4F\x75\x74\x70\x75\x74\x46\x69\x6C\x65\x3D","\x62\x61\x73\x65","\x63\x6F\x70\x79\x53\x79\x6E\x63","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x64\x64\x55\x73\x65\x72","\x50\x45\x4E\x44\x49\x4E\x47","\x66\x61\x78\x4F\x75\x74","\x75\x73\x65\x72","\x61\x64\x64\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x54\x72\x75\x6E\x6B\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x54\x72\x75\x6E\x6B\x4E\x61\x6D\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x28ef[0];var fs=require(_0x28ef[1]);var util=require(_0x28ef[2]);var path=require(_0x28ef[3]);var config=require(_0x28ef[4]);var _=require(_0x28ef[5]);var Promise=require(_0x28ef[6]);var exec=require(_0x28ef[8])[_0x28ef[7]];var fse=require(_0x28ef[9]);var moment=require(_0x28ef[10]);var FaxAccount=require(_0x28ef[12])[_0x28ef[11]];var FaxRoom=require(_0x28ef[12])[_0x28ef[13]];var FaxMessage=require(_0x28ef[12])[_0x28ef[14]];var FaxAttachment=require(_0x28ef[12])[_0x28ef[15]];var Trunk=require(_0x28ef[12])[_0x28ef[16]];var User=require(_0x28ef[12])[_0x28ef[17]];var Contact=require(_0x28ef[12])[_0x28ef[18]];var ReportFax=require(_0x28ef[12])[_0x28ef[19]];var Util=require(_0x28ef[20]);var Scheduler=require(_0x28ef[21]);var faxaccounts;function Fax(_0xac0bx16,_0xac0bx17){console[_0x28ef[23]](_0x28ef[22]);process[_0x28ef[56]](_0x28ef[24],function(_0xac0bx18){switch(_0xac0bx18[_0x28ef[24]]){case _0x28ef[27]:sendfax(_0xac0bx18[_0x28ef[25]],_0xac0bx16,0,_0xac0bx18[_0x28ef[26]]);break;case _0x28ef[33]:if(_[_0x28ef[30]](_0xac0bx18[_0x28ef[26]][_0x28ef[28]],_0x28ef[29])&& _0xac0bx18[_0x28ef[25]][_0x28ef[29]]=== _0x28ef[31]){sendfax(_0xac0bx18[_0x28ef[25]],_0xac0bx16,_0xac0bx18[_0x28ef[25]][_0x28ef[32]]+ 1,_0xac0bx18[_0x28ef[26]])};break;case _0x28ef[40]:var _0xac0bx19=_[_0x28ef[35]](faxaccounts,{id:parseInt(_0xac0bx18[_0x28ef[25]][_0x28ef[34]])});if(_0xac0bx19&& _[_0x28ef[30]](_0xac0bx18[_0x28ef[26]][_0x28ef[28]],_0x28ef[36])){webhook(_0xac0bx18[_0x28ef[25]],_0xac0bx19,_0x28ef[37])};if(_0xac0bx19&& _[_0x28ef[30]](_0xac0bx18[_0x28ef[26]][_0x28ef[28]],_0x28ef[38])){webhook(_0xac0bx18[_0x28ef[25]],_0xac0bx19,_0x28ef[39])};break;case _0x28ef[44]:var _0xac0bx1a=_[_0x28ef[35]](faxaccounts,{id:_0xac0bx18[_0x28ef[25]][_0x28ef[41]]});if(_0xac0bx1a&& _[_0x28ef[30]](_0xac0bx18[_0x28ef[26]][_0x28ef[28]],_0x28ef[29])&& _0xac0bx18[_0x28ef[25]][_0x28ef[29]]=== _0x28ef[42]){webhook(_0xac0bx18[_0x28ef[25]],_0xac0bx1a,_0x28ef[43])};break;case _0x28ef[46]:faxaccounts[_0x28ef[45]](_0xac0bx18[_0x28ef[25]]);break;case _0x28ef[53]:var _0xac0bx1b=_[_0x28ef[35]](faxaccounts,{id:_0xac0bx18[_0x28ef[25]][_0x28ef[47]]});if(_0xac0bx1b){console[_0x28ef[23]](_0x28ef[48]+ _0xac0bx1b[_0x28ef[49]]+ _0x28ef[50]);_[_0x28ef[51]](_0xac0bx1b,_0xac0bx18[_0x28ef[25]])}else {faxaccounts[_0x28ef[52]](_0xac0bx18[_0x28ef[25]])};break;case _0x28ef[55]:_[_0x28ef[54]](faxaccounts,{id:_0xac0bx18[_0x28ef[25]][_0x28ef[47]]});break;default:}});FaxAccount[_0x28ef[60]]()[_0x28ef[59]](function(_0xac0bx1d){faxaccounts= _0xac0bx1d})[_0x28ef[58]](function(_0xac0bx1c){console[_0x28ef[57]](_0xac0bx1c)})}function webhook(_0xac0bx1f,_0xac0bx19,_0xac0bx20){var _0xac0bx21=_0xac0bx19;switch(_0xac0bx20){case _0x28ef[37]:if(_0xac0bx21[_0x28ef[61]]&& _0xac0bx21[_0x28ef[62]]){console[_0x28ef[23]](_0x28ef[63]+ _0xac0bx21[_0x28ef[49]]+ _0x28ef[64]);execRequest(_0xac0bx1f[_0x28ef[65]]|| _0xac0bx1f,_0xac0bx21[_0x28ef[61]],_0xac0bx21[_0x28ef[62]])};if(_0xac0bx21[_0x28ef[67]][_0x28ef[66]]){_[_0x28ef[70]](_0xac0bx21[_0x28ef[67]],function(_0xac0bx22){if(_0xac0bx22[_0x28ef[68]]){Util[_0x28ef[69]](_0xac0bx22,_0xac0bx1f)}})};break;case _0x28ef[39]:if(_0xac0bx21[_0x28ef[71]]&& _0xac0bx21[_0x28ef[72]]){console[_0x28ef[23]](_0x28ef[63]+ _0xac0bx21[_0x28ef[49]]+ _0x28ef[73]);execRequest(_0xac0bx1f[_0x28ef[65]]|| _0xac0bx1f,_0xac0bx21[_0x28ef[71]],_0xac0bx21[_0x28ef[72]])};break;case _0x28ef[43]:if(_0xac0bx21[_0x28ef[74]]&& _0xac0bx21[_0x28ef[75]]){console[_0x28ef[23]](_0x28ef[63]+ _0xac0bx21[_0x28ef[49]]+ _0x28ef[76]);execRequest(_0xac0bx1f[_0x28ef[65]]|| _0xac0bx1f,_0xac0bx21[_0x28ef[74]],_0xac0bx21[_0x28ef[75]])};break;default:console[_0x28ef[23]](_0x28ef[77])}}function execRequest(_0xac0bx1f,_0xac0bx24,_0xac0bx25){return Util[_0x28ef[80]](_0xac0bx1f,_0xac0bx24,_0xac0bx25)[_0x28ef[59]](function(_0xac0bx26){console[_0x28ef[23]](_0x28ef[79])})[_0x28ef[58]](function(_0xac0bx1c){console[_0x28ef[23]](_0x28ef[78])})}Fax[_0x28ef[82]][_0x28ef[81]]= function(_0xac0bx27){return FaxMessage[_0x28ef[88]]({where:{channel:_0xac0bx27[_0x28ef[87]]}})[_0x28ef[59]](function(_0xac0bx28){if(!_0xac0bx28){throw  new Error(_0x28ef[84])};return _0xac0bx28[_0x28ef[86]]({error:_0xac0bx27[_0x28ef[85]]})})[_0x28ef[58]](function(_0xac0bx1c){console[_0x28ef[23]](_0x28ef[83],_0xac0bx1c)})};Fax[_0x28ef[82]][_0x28ef[89]]= function(_0xac0bx27){return FaxMessage[_0x28ef[88]]({where:{filename:_0xac0bx27[_0x28ef[102]],localstationid:_0xac0bx27[_0x28ef[103]]}})[_0x28ef[59]](function(_0xac0bx28){if(!_0xac0bx28){throw  new Error(_0x28ef[84])};return _0xac0bx28[_0x28ef[86]]({channel:_0xac0bx27[_0x28ef[87]],channelstate:_0xac0bx27[_0x28ef[90]],channelstatedesc:_0xac0bx27[_0x28ef[91]],calleridnum:_0xac0bx27[_0x28ef[92]],calleridname:_0xac0bx27[_0x28ef[93]],connectedlinenum:_0xac0bx27[_0x28ef[94]],connectedlinename:_0xac0bx27[_0x28ef[95]],accountcode:_0xac0bx27[_0x28ef[96]],context:_0xac0bx27[_0x28ef[97]],exten:_0xac0bx27[_0x28ef[98]],priority:_0xac0bx27[_0x28ef[99]],uniqueid:_0xac0bx27[_0x28ef[100]],linkedid:_0xac0bx27[_0x28ef[101]],lastStatus:_0xac0bx27[_0x28ef[29]]})})[_0x28ef[58]](function(_0xac0bx1c){console[_0x28ef[23]](_0x28ef[83],_0xac0bx1c)})};Fax[_0x28ef[82]][_0x28ef[104]]= function(_0xac0bx27){var _0xac0bx29;return FaxMessage[_0x28ef[88]]({where:{filename:_0xac0bx27[_0x28ef[102]],localstationid:_0xac0bx27[_0x28ef[103]]}})[_0x28ef[59]](function(_0xac0bx28){if(!_0xac0bx28){throw  new Error(_0x28ef[84])};_0xac0bx29= _0xac0bx28;var _0xac0bx2b=_0x28ef[106];if(_0xac0bx27[_0x28ef[108]]== _0x28ef[109]){_0xac0bx2b= _0x28ef[110]};return _0xac0bx29[_0x28ef[86]]({remotestationid:_0xac0bx27[_0x28ef[111]],pagestransferred:_0xac0bx27[_0x28ef[108]],resolution:_0xac0bx27[_0x28ef[112]],transferrate:_0xac0bx27[_0x28ef[113]],status:_0xac0bx2b})})[_0x28ef[59]](function(){return _0xac0bx29[_0x28ef[107]]()})[_0x28ef[59]](function(_0xac0bx2a){if(!_0xac0bx2a){throw  new Error(_0x28ef[105])};return _0xac0bx2a[_0x28ef[86]]({lastEvent:_0x28ef[106]},{individualHooks:true})})[_0x28ef[58]](function(_0xac0bx1c){console[_0x28ef[23]](_0x28ef[83],_0xac0bx1c)})};Fax[_0x28ef[82]][_0x28ef[114]]= function(_0xac0bx27){console[_0x28ef[23]](util[_0x28ef[116]](_0x28ef[115],_0xac0bx27[_0x28ef[92]]));var _0xac0bx2c=_[_0x28ef[117]](_0xac0bx27);var _0xac0bx2d;var _0xac0bx29,_0xac0bx2e;return FaxAccount[_0x28ef[88]]({where:{localstationid:_0xac0bx27[_0x28ef[103]]}})[_0x28ef[59]](function(_0xac0bx38){if(!_0xac0bx38){throw  new Error(_0x28ef[148])};console[_0x28ef[23]](_0x28ef[149],_0xac0bx27[_0x28ef[103]]);_0xac0bx2d= _0xac0bx38;if(_0xac0bx2d[_0x28ef[150]]){return Contact[_0x28ef[151]]({where:{ListId:_0xac0bx2d[_0x28ef[150]],$or:[{phone:_0xac0bx27[_0x28ef[92]]},{fax:_0xac0bx27[_0x28ef[92]]}]},defaults:{phone:_0xac0bx27[_0x28ef[92]],fax:_0xac0bx27[_0x28ef[92]],firstName:_0xac0bx27[_0x28ef[92]],ListId:_0xac0bx2d[_0x28ef[150]]}})}else {return []}})[_0x28ef[147]](function(_0xac0bx36,_0xac0bx37){if(_0xac0bx37!= undefined&&  !_0xac0bx37){return _0xac0bx36[_0x28ef[86]]({fax:_0xac0bx27[_0x28ef[92]]})};return})[_0x28ef[59]](function(){return FaxRoom[_0x28ef[60]]({limit:1,where:{contact:_0xac0bx2c[_0x28ef[92]],FaxAccountId:_0xac0bx2d[_0x28ef[47]],status:{$ne:_0x28ef[42]}},order:[[_0x28ef[145],_0x28ef[146]]]})})[_0x28ef[59]](function(_0xac0bx35){if(_0xac0bx35[_0x28ef[66]]){_0xac0bx35= _[_0x28ef[139]](_0xac0bx35);return _0xac0bx35[_0x28ef[86]]({lastEvent:_0x28ef[137],lastEventAt:moment()[_0x28ef[116]](_0x28ef[140]),status:_0x28ef[141],openReason:_0x28ef[142],faxIn:++_0xac0bx35[_0x28ef[143]]})}else {return FaxRoom[_0x28ef[134]]({contact:_0xac0bx2c[_0x28ef[92]],account:_0xac0bx2d[_0x28ef[49]],status:_0x28ef[144],lastEvent:_0x28ef[137],lastEventAt:moment()[_0x28ef[116]](_0x28ef[140]),FaxAccountId:_0xac0bx2d[_0x28ef[47]],faxIn:1})}})[_0x28ef[59]](function(_0xac0bx35){if(!_0xac0bx35){throw  new Error(_0x28ef[135])};_0xac0bx2e= _0xac0bx35;_0xac0bx2c[_0x28ef[136]]= _0xac0bx35[_0x28ef[47]];_0xac0bx2c[_0x28ef[29]]= _0x28ef[137];_0xac0bx2c[_0x28ef[122]]= _0xac0bx2c[_0x28ef[92]];_0xac0bx2c[_0x28ef[138]]= _0xac0bx2c[_0x28ef[103]];return FaxMessage[_0x28ef[134]](_0xac0bx2c)})[_0x28ef[59]](function(_0xac0bx31){_0xac0bx29= _0xac0bx31;var _0xac0bx32=[];var _0xac0bx33=path[_0x28ef[126]](_0xac0bx27[_0x28ef[102]])[_0x28ef[49]];var _0xac0bx34=_0xac0bx33+ _0x28ef[127];return FaxAttachment[_0x28ef[134]]({path:path[_0x28ef[133]](config[_0x28ef[128]],_0x28ef[129],_0x28ef[130],_0x28ef[119],_0x28ef[131],_0x28ef[132],_0xac0bx34),basename:_0xac0bx34,name:_0xac0bx33,FaxMessageId:_0xac0bx31[_0x28ef[47]]})})[_0x28ef[59]](function(_0xac0bx30){return exec(_0x28ef[124]+ _0xac0bx30[_0x28ef[3]]+ _0x28ef[125]+ _0xac0bx27[_0x28ef[102]])})[_0x28ef[59]](function(){var _0xac0bx2f= new Scheduler({channel:_0x28ef[119],uniqueid:util[_0x28ef[116]](_0x28ef[120],moment()[_0x28ef[121]](),_0xac0bx2e[_0x28ef[47]]),messageid:_0xac0bx29[_0x28ef[47]],roomid:_0xac0bx2e[_0x28ef[47]],accountid:_0xac0bx2d[_0x28ef[47]],accountname:_0xac0bx2d[_0x28ef[49]],accountphone:_0xac0bx2d[_0x28ef[103]],from:_0xac0bx29[_0x28ef[122]]});_0xac0bx2f[_0x28ef[123]]()})[_0x28ef[58]](function(_0xac0bx1c){console[_0x28ef[23]](_0x28ef[118],_0xac0bx1c)})};function sendfax(_0xac0bx31,_0xac0bx16,_0xac0bx3a,_0xac0bx3b,_0xac0bx17){if(_0xac0bx31[_0x28ef[29]]=== _0x28ef[31]){var _0xac0bx2e;var _0xac0bx29=_0xac0bx31;var _0xac0bx3c=_0xac0bx31[_0x28ef[122]];var _0xac0bx3d=_0xac0bx31[_0x28ef[138]];var _0xac0bx3e;var _0xac0bx3f;var _0xac0bx40,_0xac0bx41;return FaxAccount[_0x28ef[88]]({where:{localstationid:_0xac0bx29[_0x28ef[122]]}})[_0x28ef[59]](function(_0xac0bx38){if(!_0xac0bx38){throw  new Error(_0x28ef[148])};_0xac0bx3e= _[_0x28ef[117]](_0xac0bx38[_0x28ef[65]]);return Trunk[_0x28ef[88]]({where:{name:_0xac0bx3e[_0x28ef[188]]},attributes:[_0x28ef[49]]})})[_0x28ef[59]](function(_0xac0bx43){if(!_0xac0bx43){throw  new Error(_0x28ef[187])};_0xac0bx3f= _[_0x28ef[117]](_0xac0bx43[_0x28ef[65]]);return})[_0x28ef[59]](function(){return [_0xac0bx3e,_0xac0bx29]})[_0x28ef[147]](getFaxRoom())[_0x28ef[59]](function(_0xac0bx2a){_0xac0bx2e= _0xac0bx2a;return _0xac0bx2e[_0x28ef[186]](_0xac0bx29[_0x28ef[47]])})[_0x28ef[59]](function(){return _0xac0bx2e[_0x28ef[86]]({status:_0x28ef[183],lastEvent:_0x28ef[31],lastEventAt:moment()[_0x28ef[116]](_0x28ef[140]),faxOut:++_0xac0bx2e[_0x28ef[184]]},{individualHooks:true,user:_0xac0bx3b[_0x28ef[185]]})})[_0x28ef[59]](function(_0xac0bx18){return _0xac0bx2e[_0x28ef[182]](_0xac0bx29.UserId)})[_0x28ef[59]](function(){return User[_0x28ef[181]](_0xac0bx29.UserId)})[_0x28ef[59]](function(){if(_0xac0bx3e[_0x28ef[150]]){return Contact[_0x28ef[151]]({where:{ListId:_0xac0bx3e[_0x28ef[150]],$or:[{phone:_0xac0bx3d},{fax:_0xac0bx3d}]},defaults:{fax:_0xac0bx3d,phone:_0xac0bx3d,firstName:_0xac0bx3d,ListId:_0xac0bx3e[_0x28ef[150]]}})}else {return []}})[_0x28ef[147]](function(_0xac0bx36,_0xac0bx37){if(_0xac0bx37!= undefined&&  !_0xac0bx37){return _0xac0bx36[_0x28ef[86]]({fax:_0xac0bx3d})};return})[_0x28ef[59]](function(){_0xac0bx40= _0xac0bx29[_0x28ef[172]][0][_0x28ef[3]];if(_0xac0bx29[_0x28ef[172]][0][_0x28ef[173]]=== _0x28ef[174]){_0xac0bx41= path[_0x28ef[133]](config[_0x28ef[128]],_0x28ef[129],_0x28ef[130],_0x28ef[119],_0x28ef[175],_0x28ef[132],_0x28ef[176],path[_0x28ef[126]](_0xac0bx40)[_0x28ef[49]]+ _0x28ef[177]);return exec(_0x28ef[178]+ _0xac0bx41+ _0x28ef[125]+ _0xac0bx40)}else {_0xac0bx41= path[_0x28ef[133]](config[_0x28ef[128]],_0x28ef[129],_0x28ef[130],_0x28ef[119],_0x28ef[175],_0x28ef[132],_0x28ef[176],path[_0x28ef[126]](_0xac0bx40)[_0x28ef[179]]);fse[_0x28ef[180]](_0xac0bx40,_0xac0bx41);return}})[_0x28ef[59]](function(){fs[_0x28ef[171]](_0xac0bx41,511);return FaxMessage[_0x28ef[154]]({filename:_0xac0bx41,localstationid:_0xac0bx29[_0x28ef[122]],retry:_0xac0bx3a},{where:{id:_0xac0bx29[_0x28ef[47]]}})})[_0x28ef[59]](function(){return Promise[_0x28ef[170]](_0xac0bx16[_0x28ef[169]])({action:_0x28ef[156],channel:util[_0x28ef[116]](_0x28ef[157],_0xac0bx3e[_0x28ef[158]],_0xac0bx3f[_0x28ef[49]],_0xac0bx3d),exten:_0xac0bx3d,context:_0x28ef[159],priority:1,callerid:util[_0x28ef[116]](_0x28ef[160],_0xac0bx3e[_0x28ef[103]],_0xac0bx3e[_0x28ef[103]]),variable:{FAXNAME:_0xac0bx3e[_0x28ef[49]],FAXNUMBER:_0xac0bx3d,FAXECM:_0xac0bx3e[_0x28ef[161]],FAXHEADERINFO:_0xac0bx3e[_0x28ef[162]],FAXLOCALSTATIONID:_0xac0bx3e[_0x28ef[103]],FAXMINRATE:_0xac0bx3e[_0x28ef[163]],FAXMAXRATE:_0xac0bx3e[_0x28ef[164]],FAXMODEM:util[_0x28ef[116]](_0x28ef[165],_0xac0bx3e[_0x28ef[166]]),FAXGATEWAY:_0xac0bx3e[_0x28ef[167]],FAXT38TIMEOUT:_0xac0bx3e[_0x28ef[168]],FAXOUTFILE:_0xac0bx41},account:_0xac0bx3e[_0x28ef[103]]})})[_0x28ef[59]](function(_0xac0bx42){console[_0x28ef[23]](_0x28ef[155],_0xac0bx42)})[_0x28ef[58]](function(_0xac0bx1c){console[_0x28ef[23]](_0x28ef[152],_0xac0bx1c);return FaxMessage[_0x28ef[154]]({status:_0x28ef[110]},{where:{id:_0xac0bx29[_0x28ef[47]]}})[_0x28ef[59]](function(_0xac0bx18){if(_0xac0bx2e){return _0xac0bx2e[_0x28ef[86]]({lastEvent:_0x28ef[110]})};return})[_0x28ef[58]](function(_0xac0bx1c){console[_0x28ef[23]](_0x28ef[153])})})}}function getFaxRoom(){return function(_0xac0bx19,_0xac0bx28){if(_0xac0bx28[_0x28ef[136]]){return FaxRoom[_0x28ef[181]](_0xac0bx28.FaxRoomId)}else {return FaxRoom[_0x28ef[60]]({limit:1,where:{contact:_0xac0bx28[_0x28ef[138]],FaxAccountId:_0xac0bx19[_0x28ef[47]]},order:[[_0x28ef[145],_0x28ef[146]]]})[_0x28ef[59]](function(_0xac0bx45){var _0xac0bx35=_[_0x28ef[139]](_0xac0bx45);if(!_0xac0bx35|| _0xac0bx35[_0x28ef[29]]=== _0x28ef[42]){return FaxRoom[_0x28ef[134]]({contact:_0xac0bx28[_0x28ef[138]],account:_0xac0bx19[_0x28ef[49]],status:_0x28ef[183],FaxAccountId:_0xac0bx19[_0x28ef[47]]})}else {return _0xac0bx35}})}}}module[_0x28ef[189]]= Fax
\ No newline at end of file