Built motion from commit 264c1c7.|0.0.142
[motion.git] / server / config / ami / fax.js
index 2565f4c..8b4c862 100644 (file)
@@ -1 +1 @@
-var _0xbb38=["\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(_0xbb38[0]);var util=require(_0xbb38[1]);var path=require(_0xbb38[2]);var config=require(_0xbb38[3]);var _=require(_0xbb38[4]);var Promise=require(_0xbb38[5]);var exec=require(_0xbb38[7])[_0xbb38[6]];var fse=require(_0xbb38[8]);var moment=require(_0xbb38[9]);var FaxAccount=require(_0xbb38[11])[_0xbb38[10]];var FaxRoom=require(_0xbb38[11])[_0xbb38[12]];var FaxMessage=require(_0xbb38[11])[_0xbb38[13]];var FaxAttachment=require(_0xbb38[11])[_0xbb38[14]];var Trunk=require(_0xbb38[11])[_0xbb38[15]];var User=require(_0xbb38[11])[_0xbb38[16]];var Contact=require(_0xbb38[11])[_0xbb38[17]];var ReportFax=require(_0xbb38[11])[_0xbb38[18]];var Util=require(_0xbb38[19]);var Scheduler=require(_0xbb38[20]);var faxaccounts;function Fax(_0x33cdx16){console[_0xbb38[22]](_0xbb38[21]);FaxMessage[_0xbb38[23]](function(_0x33cdx17,_0x33cdx18){sendfax(_0x33cdx17,_0x33cdx16,0,_0x33cdx18)});FaxMessage[_0xbb38[28]](function(_0x33cdx17,_0x33cdx18){if(_0x33cdx17[_0xbb38[25]](_0xbb38[24])&& _0x33cdx17[_0xbb38[24]]=== _0xbb38[26]){sendfax(_0x33cdx17,_0x33cdx16,_0x33cdx17[_0xbb38[27]]+ 1,_0x33cdx18)}});FaxAccount[_0xbb38[41]]()[_0xbb38[40]](function(_0x33cdx1a){faxaccounts= _0x33cdx1a;synch(faxaccounts);ReportFax[_0xbb38[28]](function(_0x33cdx17){var _0x33cdx1b=_[_0xbb38[32]](faxaccounts,{id:parseInt(_0x33cdx17[_0xbb38[31]])});if(_0x33cdx1b&& _0x33cdx17[_0xbb38[25]](_0xbb38[33])){webhook(_0x33cdx17,_0x33cdx1b,_0xbb38[34])};if(_0x33cdx1b&& _0x33cdx17[_0xbb38[25]](_0xbb38[35])){webhook(_0x33cdx17,_0x33cdx1b,_0xbb38[36])}});FaxRoom[_0xbb38[28]](function(_0x33cdx17){var _0x33cdx1b=_[_0xbb38[32]](faxaccounts,{id:_0x33cdx17[_0xbb38[37]]});if(_0x33cdx1b&& _0x33cdx17[_0xbb38[25]](_0xbb38[24])&& _0x33cdx17[_0xbb38[24]]=== _0xbb38[38]){webhook(_0x33cdx17,_0x33cdx1b,_0xbb38[39])}})})[_0xbb38[30]](function(_0x33cdx19){console[_0xbb38[29]](_0x33cdx19)})}function synch(faxaccounts){FaxAccount[_0xbb38[23]](function(_0x33cdx17){faxaccounts[_0xbb38[42]](_0x33cdx17)});FaxAccount[_0xbb38[28]](function(_0x33cdx17){var _0x33cdx1d=_[_0xbb38[32]](faxaccounts,{id:_0x33cdx17[_0xbb38[43]]});if(_0x33cdx1d){console[_0xbb38[22]](_0xbb38[44]+ _0x33cdx1d[_0xbb38[45]]+ _0xbb38[46]);_[_0xbb38[47]](_0x33cdx1d,_0x33cdx17)}else {faxaccounts[_0xbb38[48]](_0x33cdx17)}});FaxAccount[_0xbb38[50]](function(_0x33cdx17){_[_0xbb38[49]](faxaccounts,{id:_0x33cdx17[_0xbb38[43]]})})}function webhook(_0x33cdx17,_0x33cdx1b,_0x33cdx1f){var _0x33cdx20=_0x33cdx1b;switch(_0x33cdx1f){case _0xbb38[34]:if(_0x33cdx20[_0xbb38[51]]&& _0x33cdx20[_0xbb38[52]]){console[_0xbb38[22]](_0xbb38[53]+ _0x33cdx20[_0xbb38[45]]+ _0xbb38[54]);execRequest(_0x33cdx17[_0xbb38[55]],_0x33cdx20[_0xbb38[51]],_0x33cdx20[_0xbb38[52]])};if(_0x33cdx20[_0xbb38[57]][_0xbb38[56]]){_[_0xbb38[60]](_0x33cdx20[_0xbb38[57]],function(_0x33cdx21){if(_0x33cdx21[_0xbb38[58]]){Util[_0xbb38[59]](_0x33cdx21,_0x33cdx17)}})};break;case _0xbb38[36]:if(_0x33cdx20[_0xbb38[61]]&& _0x33cdx20[_0xbb38[62]]){console[_0xbb38[22]](_0xbb38[53]+ _0x33cdx20[_0xbb38[45]]+ _0xbb38[63]);execRequest(_0x33cdx17[_0xbb38[55]],_0x33cdx20[_0xbb38[61]],_0x33cdx20[_0xbb38[62]])};break;case _0xbb38[39]:if(_0x33cdx20[_0xbb38[64]]&& _0x33cdx20[_0xbb38[65]]){console[_0xbb38[22]](_0xbb38[53]+ _0x33cdx20[_0xbb38[45]]+ _0xbb38[66]);execRequest(_0x33cdx17[_0xbb38[55]],_0x33cdx20[_0xbb38[64]],_0x33cdx20[_0xbb38[65]])};break;default:console[_0xbb38[22]](_0xbb38[67])}}function execRequest(_0x33cdx17,_0x33cdx23,_0x33cdx24){Util[_0xbb38[70]](_0x33cdx17,_0x33cdx23,_0x33cdx24)[_0xbb38[40]](function(_0x33cdx25){console[_0xbb38[22]](_0xbb38[69])})[_0xbb38[30]](function(_0x33cdx19){console[_0xbb38[22]](_0xbb38[68])})}Fax[_0xbb38[72]][_0xbb38[71]]= function(_0x33cdx26){return FaxMessage[_0xbb38[78]]({where:{channel:_0x33cdx26[_0xbb38[77]]}})[_0xbb38[40]](function(_0x33cdx27){if(!_0x33cdx27){throw  new Error(_0xbb38[74])};return _0x33cdx27[_0xbb38[76]]({error:_0x33cdx26[_0xbb38[75]]})})[_0xbb38[30]](function(_0x33cdx19){console[_0xbb38[22]](_0xbb38[73],_0x33cdx19)})};Fax[_0xbb38[72]][_0xbb38[79]]= function(_0x33cdx26){return FaxMessage[_0xbb38[78]]({where:{filename:_0x33cdx26[_0xbb38[92]],localstationid:_0x33cdx26[_0xbb38[93]]}})[_0xbb38[40]](function(_0x33cdx27){if(!_0x33cdx27){throw  new Error(_0xbb38[74])};return _0x33cdx27[_0xbb38[76]]({channel:_0x33cdx26[_0xbb38[77]],channelstate:_0x33cdx26[_0xbb38[80]],channelstatedesc:_0x33cdx26[_0xbb38[81]],calleridnum:_0x33cdx26[_0xbb38[82]],calleridname:_0x33cdx26[_0xbb38[83]],connectedlinenum:_0x33cdx26[_0xbb38[84]],connectedlinename:_0x33cdx26[_0xbb38[85]],accountcode:_0x33cdx26[_0xbb38[86]],context:_0x33cdx26[_0xbb38[87]],exten:_0x33cdx26[_0xbb38[88]],priority:_0x33cdx26[_0xbb38[89]],uniqueid:_0x33cdx26[_0xbb38[90]],linkedid:_0x33cdx26[_0xbb38[91]],lastStatus:_0x33cdx26[_0xbb38[24]]})})[_0xbb38[30]](function(_0x33cdx19){console[_0xbb38[22]](_0xbb38[73],_0x33cdx19)})};Fax[_0xbb38[72]][_0xbb38[94]]= function(_0x33cdx26){var _0x33cdx28;return FaxMessage[_0xbb38[78]]({where:{filename:_0x33cdx26[_0xbb38[92]],localstationid:_0x33cdx26[_0xbb38[93]]}})[_0xbb38[40]](function(_0x33cdx27){if(!_0x33cdx27){throw  new Error(_0xbb38[74])};_0x33cdx28= _0x33cdx27;var _0x33cdx2a=_0xbb38[96];if(_0x33cdx26[_0xbb38[98]]== _0xbb38[99]){_0x33cdx2a= _0xbb38[100]};return _0x33cdx28[_0xbb38[76]]({remotestationid:_0x33cdx26[_0xbb38[101]],pagestransferred:_0x33cdx26[_0xbb38[98]],resolution:_0x33cdx26[_0xbb38[102]],transferrate:_0x33cdx26[_0xbb38[103]],status:_0x33cdx2a})})[_0xbb38[40]](function(){return _0x33cdx28[_0xbb38[97]]()})[_0xbb38[40]](function(_0x33cdx29){if(!_0x33cdx29){throw  new Error(_0xbb38[95])};return _0x33cdx29[_0xbb38[76]]({lastEvent:_0xbb38[96]},{individualHooks:true})})[_0xbb38[30]](function(_0x33cdx19){console[_0xbb38[22]](_0xbb38[73],_0x33cdx19)})};Fax[_0xbb38[72]][_0xbb38[104]]= function(_0x33cdx26){console[_0xbb38[22]](util[_0xbb38[106]](_0xbb38[105],_0x33cdx26[_0xbb38[82]]));var _0x33cdx2b=_[_0xbb38[107]](_0x33cdx26);var _0x33cdx2c;var _0x33cdx28,_0x33cdx2d;return FaxAccount[_0xbb38[78]]({where:{localstationid:_0x33cdx26[_0xbb38[93]]}})[_0xbb38[40]](function(_0x33cdx37){if(!_0x33cdx37){throw  new Error(_0xbb38[138])};console[_0xbb38[22]](_0xbb38[139],_0x33cdx26[_0xbb38[93]]);_0x33cdx2c= _0x33cdx37;if(_0x33cdx2c[_0xbb38[140]]){return Contact[_0xbb38[141]]({where:{ListId:_0x33cdx2c[_0xbb38[140]],$or:[{phone:_0x33cdx26[_0xbb38[82]]},{fax:_0x33cdx26[_0xbb38[82]]}]},defaults:{phone:_0x33cdx26[_0xbb38[82]],fax:_0x33cdx26[_0xbb38[82]],firstName:_0x33cdx26[_0xbb38[82]],ListId:_0x33cdx2c[_0xbb38[140]]}})}else {return []}})[_0xbb38[137]](function(_0x33cdx35,_0x33cdx36){if(_0x33cdx36!= undefined&&  !_0x33cdx36){return _0x33cdx35[_0xbb38[76]]({fax:_0x33cdx26[_0xbb38[82]]})};return})[_0xbb38[40]](function(){return FaxRoom[_0xbb38[41]]({limit:1,where:{contact:_0x33cdx2b[_0xbb38[82]],FaxAccountId:_0x33cdx2c[_0xbb38[43]],status:{$ne:_0xbb38[38]}},order:[[_0xbb38[135],_0xbb38[136]]]})})[_0xbb38[40]](function(_0x33cdx34){if(_0x33cdx34[_0xbb38[56]]){_0x33cdx34= _[_0xbb38[129]](_0x33cdx34);return _0x33cdx34[_0xbb38[76]]({lastEvent:_0xbb38[127],lastEventAt:moment()[_0xbb38[106]](_0xbb38[130]),status:_0xbb38[131],openReason:_0xbb38[132],faxIn:++_0x33cdx34[_0xbb38[133]]})}else {return FaxRoom[_0xbb38[124]]({contact:_0x33cdx2b[_0xbb38[82]],account:_0x33cdx2c[_0xbb38[45]],status:_0xbb38[134],lastEvent:_0xbb38[127],lastEventAt:moment()[_0xbb38[106]](_0xbb38[130]),FaxAccountId:_0x33cdx2c[_0xbb38[43]],faxIn:1})}})[_0xbb38[40]](function(_0x33cdx34){if(!_0x33cdx34){throw  new Error(_0xbb38[125])};_0x33cdx2d= _0x33cdx34;_0x33cdx2b[_0xbb38[126]]= _0x33cdx34[_0xbb38[43]];_0x33cdx2b[_0xbb38[24]]= _0xbb38[127];_0x33cdx2b[_0xbb38[112]]= _0x33cdx2b[_0xbb38[82]];_0x33cdx2b[_0xbb38[128]]= _0x33cdx2b[_0xbb38[93]];return FaxMessage[_0xbb38[124]](_0x33cdx2b)})[_0xbb38[40]](function(_0x33cdx30){_0x33cdx28= _0x33cdx30;var _0x33cdx31=[];var _0x33cdx32=path[_0xbb38[116]](_0x33cdx26[_0xbb38[92]])[_0xbb38[45]];var _0x33cdx33=_0x33cdx32+ _0xbb38[117];return FaxAttachment[_0xbb38[124]]({path:path[_0xbb38[123]](config[_0xbb38[118]],_0xbb38[119],_0xbb38[120],_0xbb38[109],_0xbb38[121],_0xbb38[122],_0x33cdx33),basename:_0x33cdx33,name:_0x33cdx32,FaxMessageId:_0x33cdx30[_0xbb38[43]]})})[_0xbb38[40]](function(_0x33cdx2f){return exec(_0xbb38[114]+ _0x33cdx2f[_0xbb38[2]]+ _0xbb38[115]+ _0x33cdx26[_0xbb38[92]])})[_0xbb38[40]](function(){var _0x33cdx2e= new Scheduler({channel:_0xbb38[109],uniqueid:util[_0xbb38[106]](_0xbb38[110],moment()[_0xbb38[111]](),_0x33cdx2d[_0xbb38[43]]),messageid:_0x33cdx28[_0xbb38[43]],roomid:_0x33cdx2d[_0xbb38[43]],accountid:_0x33cdx2c[_0xbb38[43]],accountname:_0x33cdx2c[_0xbb38[45]],accountphone:_0x33cdx2c[_0xbb38[93]],from:_0x33cdx28[_0xbb38[112]]});_0x33cdx2e[_0xbb38[113]]()})[_0xbb38[30]](function(_0x33cdx19){console[_0xbb38[22]](_0xbb38[108],_0x33cdx19)})};function sendfax(_0x33cdx30,_0x33cdx16,_0x33cdx39,_0x33cdx18){if(_0x33cdx30[_0xbb38[24]]=== _0xbb38[26]){var _0x33cdx2d;var _0x33cdx28=_0x33cdx30;var _0x33cdx3a=_0x33cdx30[_0xbb38[112]];var _0x33cdx3b=_0x33cdx30[_0xbb38[128]];var _0x33cdx3c;var _0x33cdx3d;var _0x33cdx3e,_0x33cdx3f;return FaxAccount[_0xbb38[78]]({where:{localstationid:_0x33cdx28[_0xbb38[112]]}})[_0xbb38[40]](function(_0x33cdx37){if(!_0x33cdx37){throw  new Error(_0xbb38[138])};_0x33cdx3c= _[_0xbb38[107]](_0x33cdx37[_0xbb38[55]]);return Trunk[_0xbb38[78]]({where:{name:_0x33cdx3c[_0xbb38[178]]},attributes:[_0xbb38[45]]})})[_0xbb38[40]](function(_0x33cdx41){if(!_0x33cdx41){throw  new Error(_0xbb38[177])};_0x33cdx3d= _[_0xbb38[107]](_0x33cdx41[_0xbb38[55]]);return})[_0xbb38[40]](function(){return _0x33cdx3c})[_0xbb38[40]](getFaxRoom(_0x33cdx28))[_0xbb38[40]](function(_0x33cdx29){_0x33cdx2d= _0x33cdx29;return _0x33cdx2d[_0xbb38[176]](_0x33cdx28[_0xbb38[43]])})[_0xbb38[40]](function(){return _0x33cdx2d[_0xbb38[76]]({status:_0xbb38[173],lastEvent:_0xbb38[26],lastEventAt:moment()[_0xbb38[106]](_0xbb38[130]),faxOut:++_0x33cdx2d[_0xbb38[174]]},{individualHooks:true,user:_0x33cdx18[_0xbb38[175]]})})[_0xbb38[40]](function(){return _0x33cdx2d[_0xbb38[172]](_0x33cdx28.UserId)})[_0xbb38[40]](function(){return User[_0xbb38[171]](_0x33cdx28.UserId)})[_0xbb38[40]](function(){if(_0x33cdx3c[_0xbb38[140]]){return Contact[_0xbb38[141]]({where:{ListId:_0x33cdx3c[_0xbb38[140]],$or:[{phone:_0x33cdx3b},{fax:_0x33cdx3b}]},defaults:{fax:_0x33cdx3b,phone:_0x33cdx3b,firstName:_0x33cdx3b,ListId:_0x33cdx3c[_0xbb38[140]]}})}else {return []}})[_0xbb38[137]](function(_0x33cdx35,_0x33cdx36){if(_0x33cdx36!= undefined&&  !_0x33cdx36){return _0x33cdx35[_0xbb38[76]]({fax:_0x33cdx3b})};return})[_0xbb38[40]](function(){_0x33cdx3e= _0x33cdx28[_0xbb38[162]][0][_0xbb38[2]];if(_0x33cdx28[_0xbb38[162]][0][_0xbb38[163]]=== _0xbb38[164]){_0x33cdx3f= path[_0xbb38[123]](config[_0xbb38[118]],_0xbb38[119],_0xbb38[120],_0xbb38[109],_0xbb38[165],_0xbb38[122],_0xbb38[166],path[_0xbb38[116]](_0x33cdx3e)[_0xbb38[45]]+ _0xbb38[167]);return exec(_0xbb38[168]+ _0x33cdx3f+ _0xbb38[115]+ _0x33cdx3e)}else {_0x33cdx3f= path[_0xbb38[123]](config[_0xbb38[118]],_0xbb38[119],_0xbb38[120],_0xbb38[109],_0xbb38[165],_0xbb38[122],_0xbb38[166],path[_0xbb38[116]](_0x33cdx3e)[_0xbb38[169]]);fse[_0xbb38[170]](_0x33cdx3e,_0x33cdx3f);return}})[_0xbb38[40]](function(){fs[_0xbb38[161]](_0x33cdx3f,511);return _0x33cdx28[_0xbb38[76]]({filename:_0x33cdx3f,localstationid:_0x33cdx28[_0xbb38[112]],retry:_0x33cdx39})})[_0xbb38[40]](function(){return Promise[_0xbb38[160]](_0x33cdx16[_0xbb38[159]])({action:_0xbb38[146],channel:util[_0xbb38[106]](_0xbb38[147],_0x33cdx3c[_0xbb38[148]],_0x33cdx3d[_0xbb38[45]],_0x33cdx3b),exten:_0x33cdx3b,context:_0xbb38[149],priority:1,callerid:util[_0xbb38[106]](_0xbb38[150],_0x33cdx3c[_0xbb38[93]],_0x33cdx3c[_0xbb38[93]]),variable:{FAXNAME:_0x33cdx3c[_0xbb38[45]],FAXNUMBER:_0x33cdx3b,FAXECM:_0x33cdx3c[_0xbb38[151]],FAXHEADERINFO:_0x33cdx3c[_0xbb38[152]],FAXLOCALSTATIONID:_0x33cdx3c[_0xbb38[93]],FAXMINRATE:_0x33cdx3c[_0xbb38[153]],FAXMAXRATE:_0x33cdx3c[_0xbb38[154]],FAXMODEM:util[_0xbb38[106]](_0xbb38[155],_0x33cdx3c[_0xbb38[156]]),FAXGATEWAY:_0x33cdx3c[_0xbb38[157]],FAXT38TIMEOUT:_0x33cdx3c[_0xbb38[158]],FAXOUTFILE:_0x33cdx3f},account:_0x33cdx3c[_0xbb38[93]]})})[_0xbb38[40]](function(_0x33cdx40){console[_0xbb38[22]](_0xbb38[145],_0x33cdx40)})[_0xbb38[30]](function(_0x33cdx19){console[_0xbb38[22]](_0xbb38[142],_0x33cdx19);return _0x33cdx28[_0xbb38[144]]({status:_0xbb38[100]})[_0xbb38[40]](function(){if(_0x33cdx2d){return _0x33cdx2d[_0xbb38[76]]({lastEvent:_0xbb38[100]})};return})[_0xbb38[30]](function(_0x33cdx19){console[_0xbb38[22]](_0xbb38[143])})})}}function getFaxRoom(_0x33cdx28){return function(_0x33cdx1b){if(_0x33cdx28[_0xbb38[126]]){return FaxRoom[_0xbb38[171]](_0x33cdx28.FaxRoomId)}else {return FaxRoom[_0xbb38[41]]({limit:1,where:{contact:_0x33cdx28[_0xbb38[128]],FaxAccountId:_0x33cdx1b[_0xbb38[43]]},order:[[_0xbb38[135],_0xbb38[136]]]})[_0xbb38[40]](function(_0x33cdx43){var _0x33cdx34=_[_0xbb38[129]](_0x33cdx43);if(!_0x33cdx34|| _0x33cdx34[_0xbb38[24]]=== _0xbb38[38]){return FaxRoom[_0xbb38[124]]({contact:_0x33cdx28[_0xbb38[128]],account:_0x33cdx1b[_0xbb38[45]],status:_0xbb38[173],FaxAccountId:_0x33cdx1b[_0xbb38[43]]})}else {return _0x33cdx34}})}}}module[_0xbb38[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