Built motion from commit b45d4e0.|0.0.147
[motion.git] / server / config / ami / fax.js
1 var _0xbd7a=["\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","\x52\x65\x70\x6F\x72\x74\x46\x61\x78","\x54\x72\x75\x6E\x6B","\x55\x73\x65\x72","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x75\x74\x69\x6C","\x46\x61\x78\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x72\x65\x70\x6F\x72\x74\x5F\x66\x61\x78\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x61\x67\x65\x6E\x74\x3A\x25\x73","\x6D\x65\x6D\x62\x65\x72\x69\x64","\x66\x6F\x72\x6D\x61\x74","\x74\x6F","\x75\x73\x65\x72\x73","\x61\x64\x6D\x69\x6E\x73","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\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","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x65\x72\x72\x6F\x72\x3A","\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x3A\x73\x61\x76\x65","\x5B\x46\x61\x78\x5D\x20\x4D\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","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x3A","\x5B\x46\x61\x78\x5D\x20\x53\x74\x61\x63\x6B\x3A","\x73\x74\x61\x63\x6B","\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","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x75\x70\x64\x61\x74\x65\x20\x66\x6F\x72\x20\x53\x65\x6E\x64\x46\x61\x78\x20\x65\x76\x65\x6E\x74","\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x3A\x73\x61\x76\x65","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x53\x45\x4E\x54","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x75\x70\x64\x61\x74\x65\x20\x66\x6F\x72\x20\x53\x65\x6E\x64\x46\x61\x78\x20\x65\x76\x65\x6E\x74","\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","\x5B\x46\x61\x78\x5D\x20\x4E\x65\x77\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x66\x72\x6F\x6D\x20\x25\x73","\x63\x6C\x6F\x6E\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x72\x65\x63\x65\x69\x76\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x5B\x46\x61\x78\x5D\x20\x46\x69\x6C\x65\x20\x63\x6F\x72\x72\x65\x63\x74\x6C\x79\x20\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x69\x6E\x69\x74\x46\x61\x78\x53\x63\x68\x65\x64\x75\x6C\x65\x72","\x66\x61\x78","\x25\x73\x2E\x25\x73","\x75\x6E\x69\x78","\x66\x72\x6F\x6D","\x73\x65\x6E\x64","\x5B\x46\x61\x78\x5D\x20\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x20\x6E\x6F\x74\x20\x63\x72\x65\x61\x74\x65\x64","\x5B\x46\x61\x78\x5D\x20\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x3A","\x74\x69\x66\x66\x32\x70\x64\x66\x20\x2D\x6F\x20","\x20","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x6E\x6F\x74\x20\x63\x72\x65\x61\x74\x65\x64","\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","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x2F\x63\x72\x65\x61\x74\x65\x64","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x3A","\x46\x61\x78\x52\x6F\x6F\x6D\x49\x64","\x52\x45\x43\x45\x49\x56\x45\x44","\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","\x5B\x46\x61\x78\x5D\x20\x41\x63\x63\x6F\x75\x6E\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x5B\x46\x61\x78\x5D\x20\x41\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","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x5B\x46\x61\x78\x5D\x20\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\x3A","\x75\x70\x64\x61\x74\x65","\x5B\x46\x61\x78\x5D\x20\x52\x65\x73\x70\x6F\x6E\x73\x65\x20\x74\x6F\x20\x41\x4D\x49\x20\x41\x63\x74\x69\x6F\x6E\x20\x4F\x72\x69\x67\x69\x6E\x61\x74\x65","\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","\x5B\x46\x61\x78\x5D\x20\x46\x69\x6C\x65\x20\x63\x6F\x72\x72\x65\x63\x74\x6C\x79\x20\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x20\x61\x6E\x64\x20\x72\x65\x61\x64\x79\x20\x74\x6F\x20\x75\x73\x65","\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","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x75\x70\x64\x61\x74\x65\x64\x3A","\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","\x5B\x46\x61\x78\x5D\x20\x54\x72\x75\x6E\x6B\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x5B\x46\x61\x78\x5D\x20\x54\x72\x75\x6E\x6B\x20\x66\x6F\x75\x6E\x64\x3A","\x54\x72\x75\x6E\x6B\x4E\x61\x6D\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xbd7a[0];var fs=require(_0xbd7a[1]);var util=require(_0xbd7a[2]);var path=require(_0xbd7a[3]);var config=require(_0xbd7a[4]);var _=require(_0xbd7a[5]);var Promise=require(_0xbd7a[6]);var exec=require(_0xbd7a[8])[_0xbd7a[7]];var fse=require(_0xbd7a[9]);var moment=require(_0xbd7a[10]);var FaxAccount=require(_0xbd7a[12])[_0xbd7a[11]];var FaxRoom=require(_0xbd7a[12])[_0xbd7a[13]];var FaxMessage=require(_0xbd7a[12])[_0xbd7a[14]];var FaxAttachment=require(_0xbd7a[12])[_0xbd7a[15]];var ReportFax=require(_0xbd7a[12])[_0xbd7a[16]];var Trunk=require(_0xbd7a[12])[_0xbd7a[17]];var User=require(_0xbd7a[12])[_0xbd7a[18]];var Contact=require(_0xbd7a[12])[_0xbd7a[19]];var Util=require(_0xbd7a[20]);var faxaccounts;var io;function Fax(_0xfcb5x16,_0xfcb5x17){console[_0xbd7a[22]](_0xbd7a[21]);io= _0xfcb5x17;ReportFax[_0xbd7a[31]](function(_0xfcb5x18,_0xfcb5x19){io[_0xbd7a[28]](util[_0xbd7a[27]](_0xbd7a[25],_0xfcb5x18[_0xbd7a[26]]))[_0xbd7a[24]](_0xbd7a[23],_0xfcb5x18);io[_0xbd7a[28]](_0xbd7a[29])[_0xbd7a[24]](_0xbd7a[23],_0xfcb5x18);io[_0xbd7a[28]](_0xbd7a[30])[_0xbd7a[24]](_0xbd7a[23],_0xfcb5x18)});process[_0xbd7a[64]](_0xbd7a[32],function(_0xfcb5x1a){switch(_0xfcb5x1a[_0xbd7a[32]]){case _0xbd7a[35]:sendfax(_0xfcb5x1a[_0xbd7a[33]],_0xfcb5x16,0,_0xfcb5x1a[_0xbd7a[34]],io);break;case _0xbd7a[41]:if(_[_0xbd7a[38]](_0xfcb5x1a[_0xbd7a[34]][_0xbd7a[36]],_0xbd7a[37])&& _0xfcb5x1a[_0xbd7a[33]][_0xbd7a[37]]=== _0xbd7a[39]){sendfax(_0xfcb5x1a[_0xbd7a[33]],_0xfcb5x16,_0xfcb5x1a[_0xbd7a[33]][_0xbd7a[40]]+ 1,_0xfcb5x1a[_0xbd7a[34]],io)};break;case _0xbd7a[48]:var _0xfcb5x1b=_[_0xbd7a[43]](faxaccounts,{id:parseInt(_0xfcb5x1a[_0xbd7a[33]][_0xbd7a[42]])});if(_0xfcb5x1b&& _[_0xbd7a[38]](_0xfcb5x1a[_0xbd7a[34]][_0xbd7a[36]],_0xbd7a[44])){webhook(_0xfcb5x1a[_0xbd7a[33]],_0xfcb5x1b,_0xbd7a[45])};if(_0xfcb5x1b&& _[_0xbd7a[38]](_0xfcb5x1a[_0xbd7a[34]][_0xbd7a[36]],_0xbd7a[46])){webhook(_0xfcb5x1a[_0xbd7a[33]],_0xfcb5x1b,_0xbd7a[47])};break;case _0xbd7a[52]:var _0xfcb5x1c=_[_0xbd7a[43]](faxaccounts,{id:_0xfcb5x1a[_0xbd7a[33]][_0xbd7a[49]]});if(_0xfcb5x1c&& _[_0xbd7a[38]](_0xfcb5x1a[_0xbd7a[34]][_0xbd7a[36]],_0xbd7a[37])&& _0xfcb5x1a[_0xbd7a[33]][_0xbd7a[37]]=== _0xbd7a[50]){webhook(_0xfcb5x1a[_0xbd7a[33]],_0xfcb5x1c,_0xbd7a[51])};break;case _0xbd7a[54]:faxaccounts[_0xbd7a[53]](_0xfcb5x1a[_0xbd7a[33]]);break;case _0xbd7a[61]:var _0xfcb5x1d=_[_0xbd7a[43]](faxaccounts,{id:_0xfcb5x1a[_0xbd7a[33]][_0xbd7a[55]]});if(_0xfcb5x1d){console[_0xbd7a[22]](_0xbd7a[56]+ _0xfcb5x1d[_0xbd7a[57]]+ _0xbd7a[58]);_[_0xbd7a[59]](_0xfcb5x1d,_0xfcb5x1a[_0xbd7a[33]])}else {faxaccounts[_0xbd7a[60]](_0xfcb5x1a[_0xbd7a[33]])};break;case _0xbd7a[63]:_[_0xbd7a[62]](faxaccounts,{id:_0xfcb5x1a[_0xbd7a[33]][_0xbd7a[55]]});break;default:}});FaxAccount[_0xbd7a[68]]()[_0xbd7a[67]](function(_0xfcb5x1f){faxaccounts= _0xfcb5x1f})[_0xbd7a[66]](function(_0xfcb5x1e){console[_0xbd7a[65]](_0xfcb5x1e)})}function webhook(_0xfcb5x18,_0xfcb5x1b,_0xfcb5x21){var _0xfcb5x22=_0xfcb5x1b;switch(_0xfcb5x21){case _0xbd7a[45]:if(_0xfcb5x22[_0xbd7a[69]]&& _0xfcb5x22[_0xbd7a[70]]){console[_0xbd7a[22]](_0xbd7a[71]+ _0xfcb5x22[_0xbd7a[57]]+ _0xbd7a[72]);execRequest(_0xfcb5x18[_0xbd7a[73]]|| _0xfcb5x18,_0xfcb5x22[_0xbd7a[69]],_0xfcb5x22[_0xbd7a[70]])};if(_0xfcb5x22[_0xbd7a[75]][_0xbd7a[74]]){_[_0xbd7a[78]](_0xfcb5x22[_0xbd7a[75]],function(_0xfcb5x23){if(_0xfcb5x23[_0xbd7a[76]]){Util[_0xbd7a[77]](_0xfcb5x23,_0xfcb5x18)}})};break;case _0xbd7a[47]:if(_0xfcb5x22[_0xbd7a[79]]&& _0xfcb5x22[_0xbd7a[80]]){console[_0xbd7a[22]](_0xbd7a[71]+ _0xfcb5x22[_0xbd7a[57]]+ _0xbd7a[81]);execRequest(_0xfcb5x18[_0xbd7a[73]]|| _0xfcb5x18,_0xfcb5x22[_0xbd7a[79]],_0xfcb5x22[_0xbd7a[80]])};break;case _0xbd7a[51]:if(_0xfcb5x22[_0xbd7a[82]]&& _0xfcb5x22[_0xbd7a[83]]){console[_0xbd7a[22]](_0xbd7a[71]+ _0xfcb5x22[_0xbd7a[57]]+ _0xbd7a[84]);execRequest(_0xfcb5x18[_0xbd7a[73]]|| _0xfcb5x18,_0xfcb5x22[_0xbd7a[82]],_0xfcb5x22[_0xbd7a[83]])};break;default:console[_0xbd7a[22]](_0xbd7a[85])}}function execRequest(_0xfcb5x18,_0xfcb5x25,_0xfcb5x26){return Util[_0xbd7a[88]](_0xfcb5x18,_0xfcb5x25,_0xfcb5x26)[_0xbd7a[67]](function(_0xfcb5x27){console[_0xbd7a[22]](_0xbd7a[87])})[_0xbd7a[66]](function(_0xfcb5x1e){console[_0xbd7a[22]](_0xbd7a[86])})}Fax[_0xbd7a[90]][_0xbd7a[89]]= function(_0xfcb5x28){return FaxMessage[_0xbd7a[97]]({where:{channel:_0xfcb5x28[_0xbd7a[96]]}})[_0xbd7a[67]](function(_0xfcb5x2a){if(!_0xfcb5x2a){throw  new Error(_0xbd7a[93])};return _0xfcb5x2a[_0xbd7a[95]]({error:_0xfcb5x28[_0xbd7a[94]]})})[_0xbd7a[67]](function(_0xfcb5x29){io[_0xbd7a[24]](_0xbd7a[92],_0xfcb5x29)})[_0xbd7a[66]](function(_0xfcb5x1e){console[_0xbd7a[65]](_0xbd7a[91],_0xfcb5x1e)})};Fax[_0xbd7a[90]][_0xbd7a[98]]= function(_0xfcb5x28){return FaxMessage[_0xbd7a[97]]({where:{filename:_0xfcb5x28[_0xbd7a[115]],localstationid:_0xfcb5x28[_0xbd7a[116]]}})[_0xbd7a[67]](function(_0xfcb5x2a){if(!_0xfcb5x2a){throw  new Error(_0xbd7a[93])};return _0xfcb5x2a[_0xbd7a[95]]({channel:_0xfcb5x28[_0xbd7a[96]],channelstate:_0xfcb5x28[_0xbd7a[103]],channelstatedesc:_0xfcb5x28[_0xbd7a[104]],calleridnum:_0xfcb5x28[_0xbd7a[105]],calleridname:_0xfcb5x28[_0xbd7a[106]],connectedlinenum:_0xfcb5x28[_0xbd7a[107]],connectedlinename:_0xfcb5x28[_0xbd7a[108]],accountcode:_0xfcb5x28[_0xbd7a[109]],context:_0xfcb5x28[_0xbd7a[110]],exten:_0xfcb5x28[_0xbd7a[111]],priority:_0xfcb5x28[_0xbd7a[112]],uniqueid:_0xfcb5x28[_0xbd7a[113]],linkedid:_0xfcb5x28[_0xbd7a[114]],lastStatus:_0xfcb5x28[_0xbd7a[37]]})})[_0xbd7a[67]](function(_0xfcb5x29){io[_0xbd7a[24]](_0xbd7a[92],_0xfcb5x29)})[_0xbd7a[66]](function(_0xfcb5x1e){console[_0xbd7a[65]](_0xbd7a[99],_0xfcb5x1e);console[_0xbd7a[65]](_0xbd7a[100],_0xfcb5x1e[_0xbd7a[32]]);console[_0xbd7a[65]](_0xbd7a[101],_0xfcb5x1e[_0xbd7a[102]])})};Fax[_0xbd7a[90]][_0xbd7a[117]]= function(_0xfcb5x28){var _0xfcb5x2b;return FaxMessage[_0xbd7a[97]]({where:{filename:_0xfcb5x28[_0xbd7a[115]],localstationid:_0xfcb5x28[_0xbd7a[116]]}})[_0xbd7a[67]](function(_0xfcb5x2a){if(!_0xfcb5x2a){throw  new Error(_0xbd7a[93])};_0xfcb5x2b= _0xfcb5x2a;var _0xfcb5x2e=_0xbd7a[122];if(_0xfcb5x28[_0xbd7a[125]]== _0xbd7a[126]){_0xfcb5x2e= _0xbd7a[127]};return _0xfcb5x2b[_0xbd7a[95]]({remotestationid:_0xfcb5x28[_0xbd7a[128]],pagestransferred:_0xfcb5x28[_0xbd7a[125]],resolution:_0xfcb5x28[_0xbd7a[129]],transferrate:_0xfcb5x28[_0xbd7a[130]],status:_0xfcb5x2e})})[_0xbd7a[67]](function(_0xfcb5x29){io[_0xbd7a[24]](_0xbd7a[92],_0xfcb5x29);console[_0xbd7a[22]](_0xbd7a[123],_0xfcb5x29[_0xbd7a[55]]);return _0xfcb5x2b[_0xbd7a[124]]()})[_0xbd7a[67]](function(_0xfcb5x2d){if(!_0xfcb5x2d){throw  new Error(_0xbd7a[121])};return _0xfcb5x2d[_0xbd7a[95]]({lastEvent:_0xbd7a[122]},{individualHooks:true})})[_0xbd7a[67]](function(_0xfcb5x2c){console[_0xbd7a[22]](_0xbd7a[119],_0xfcb5x2c[_0xbd7a[55]]);io[_0xbd7a[24]](_0xbd7a[120],_0xfcb5x2c)})[_0xbd7a[66]](function(_0xfcb5x1e){console[_0xbd7a[65]](_0xbd7a[118],_0xfcb5x1e);console[_0xbd7a[65]](_0xbd7a[100],_0xfcb5x1e[_0xbd7a[32]]);console[_0xbd7a[65]](_0xbd7a[101],_0xfcb5x1e[_0xbd7a[102]])})};Fax[_0xbd7a[90]][_0xbd7a[131]]= function(_0xfcb5x28){console[_0xbd7a[22]](util[_0xbd7a[27]](_0xbd7a[132],_0xfcb5x28[_0xbd7a[105]]));var _0xfcb5x2f=_[_0xbd7a[133]](_0xfcb5x28);var _0xfcb5x30;var _0xfcb5x2b,_0xfcb5x31;return FaxAccount[_0xbd7a[97]]({where:{localstationid:_0xfcb5x28[_0xbd7a[116]]}})[_0xbd7a[67]](function(_0xfcb5x39){if(!_0xfcb5x39){throw  new Error(_0xbd7a[169])};console[_0xbd7a[22]](_0xbd7a[170],_0xfcb5x28[_0xbd7a[116]]);_0xfcb5x30= _0xfcb5x39;if(_0xfcb5x30[_0xbd7a[171]]){return Contact[_0xbd7a[172]]({where:{ListId:_0xfcb5x30[_0xbd7a[171]],$or:[{phone:_0xfcb5x28[_0xbd7a[105]]},{fax:_0xfcb5x28[_0xbd7a[105]]}]},defaults:{phone:_0xfcb5x28[_0xbd7a[105]],fax:_0xfcb5x28[_0xbd7a[105]],firstName:_0xfcb5x28[_0xbd7a[105]],ListId:_0xfcb5x30[_0xbd7a[171]]}})}else {return []}})[_0xbd7a[168]](function(_0xfcb5x37,_0xfcb5x38){if(_0xfcb5x38!= undefined&&  !_0xfcb5x38){return _0xfcb5x37[_0xbd7a[95]]({fax:_0xfcb5x28[_0xbd7a[105]]})};return})[_0xbd7a[67]](function(){return FaxRoom[_0xbd7a[68]]({limit:1,where:{contact:_0xfcb5x2f[_0xbd7a[105]],FaxAccountId:_0xfcb5x30[_0xbd7a[55]],status:{$ne:_0xbd7a[50]}},order:[[_0xbd7a[166],_0xbd7a[167]]]})})[_0xbd7a[67]](function(_0xfcb5x2c){if(_0xfcb5x2c[_0xbd7a[74]]){_0xfcb5x2c= _[_0xbd7a[160]](_0xfcb5x2c);return _0xfcb5x2c[_0xbd7a[95]]({lastEvent:_0xbd7a[159],lastEventAt:moment()[_0xbd7a[27]](_0xbd7a[161]),status:_0xbd7a[162],openReason:_0xbd7a[163],faxIn:++_0xfcb5x2c[_0xbd7a[164]]})}else {return FaxRoom[_0xbd7a[155]]({contact:_0xfcb5x2f[_0xbd7a[105]],account:_0xfcb5x30[_0xbd7a[57]],status:_0xbd7a[165],lastEvent:_0xbd7a[159],lastEventAt:moment()[_0xbd7a[27]](_0xbd7a[161]),FaxAccountId:_0xfcb5x30[_0xbd7a[55]],faxIn:1})}})[_0xbd7a[67]](function(_0xfcb5x2c){if(!_0xfcb5x2c){throw  new Error(_0xbd7a[156])};console[_0xbd7a[22]](_0xbd7a[157],_0xfcb5x2c[_0xbd7a[55]]);io[_0xbd7a[24]](_0xbd7a[120],_0xfcb5x2c);_0xfcb5x31= _0xfcb5x2c;_0xfcb5x2f[_0xbd7a[158]]= _0xfcb5x2c[_0xbd7a[55]];_0xfcb5x2f[_0xbd7a[37]]= _0xbd7a[159];_0xfcb5x2f[_0xbd7a[140]]= _0xfcb5x2f[_0xbd7a[105]];_0xfcb5x2f[_0xbd7a[28]]= _0xfcb5x2f[_0xbd7a[116]];return FaxMessage[_0xbd7a[155]](_0xfcb5x2f)})[_0xbd7a[67]](function(_0xfcb5x29){if(!_0xfcb5x29){throw  new Error(_0xbd7a[146])};_0xfcb5x2b= _0xfcb5x29;io[_0xbd7a[24]](_0xbd7a[92],_0xfcb5x29);console[_0xbd7a[22]](_0xbd7a[100],_0xfcb5x29[_0xbd7a[55]]);var _0xfcb5x34=[];var _0xfcb5x35=path[_0xbd7a[147]](_0xfcb5x28[_0xbd7a[115]])[_0xbd7a[57]];var _0xfcb5x36=_0xfcb5x35+ _0xbd7a[148];return FaxAttachment[_0xbd7a[155]]({path:path[_0xbd7a[154]](config[_0xbd7a[149]],_0xbd7a[150],_0xbd7a[151],_0xbd7a[137],_0xbd7a[152],_0xbd7a[153],_0xfcb5x36),basename:_0xfcb5x36,name:_0xfcb5x35,FaxMessageId:_0xfcb5x29[_0xbd7a[55]]})})[_0xbd7a[67]](function(_0xfcb5x33){if(!_0xfcb5x33){throw  new Error(_0xbd7a[142])};console[_0xbd7a[22]](_0xbd7a[143],_0xfcb5x33[_0xbd7a[55]]);return exec(_0xbd7a[144]+ _0xfcb5x33[_0xbd7a[3]]+ _0xbd7a[145]+ _0xfcb5x28[_0xbd7a[115]])})[_0xbd7a[67]](function(){console[_0xbd7a[22]](_0xbd7a[135]);var _0xfcb5x32={type:_0xbd7a[136],doc:{channel:_0xbd7a[137],uniqueid:util[_0xbd7a[27]](_0xbd7a[138],moment()[_0xbd7a[139]](),_0xfcb5x31[_0xbd7a[55]]),messageid:_0xfcb5x2b[_0xbd7a[55]],roomid:_0xfcb5x31[_0xbd7a[55]],accountid:_0xfcb5x30[_0xbd7a[55]],accountname:_0xfcb5x30[_0xbd7a[57]],accountphone:_0xfcb5x30[_0xbd7a[116]],from:_0xfcb5x2b[_0xbd7a[140]]}};process[_0xbd7a[141]](_0xfcb5x32)})[_0xbd7a[66]](function(_0xfcb5x1e){console[_0xbd7a[65]](_0xbd7a[134],_0xfcb5x1e);console[_0xbd7a[65]](_0xbd7a[100],_0xfcb5x1e[_0xbd7a[32]]);console[_0xbd7a[65]](_0xbd7a[101],_0xfcb5x1e[_0xbd7a[102]])})};function sendfax(_0xfcb5x29,_0xfcb5x16,_0xfcb5x3b,_0xfcb5x3c,io){if(_0xfcb5x29[_0xbd7a[37]]=== _0xbd7a[39]){var _0xfcb5x31;var _0xfcb5x2b=_0xfcb5x29;var _0xfcb5x3d=_0xfcb5x29[_0xbd7a[140]];var _0xfcb5x3e=_0xfcb5x29[_0xbd7a[28]];var _0xfcb5x3f;var _0xfcb5x40;var _0xfcb5x41,_0xfcb5x42;return FaxAccount[_0xbd7a[97]]({where:{localstationid:_0xfcb5x2b[_0xbd7a[140]]}})[_0xbd7a[67]](function(_0xfcb5x39){if(!_0xfcb5x39){throw  new Error(_0xbd7a[169])};console[_0xbd7a[22]](_0xbd7a[170],_0xfcb5x39[_0xbd7a[116]]);_0xfcb5x3f= _[_0xbd7a[133]](_0xfcb5x39[_0xbd7a[73]]);return Trunk[_0xbd7a[97]]({where:{name:_0xfcb5x3f[_0xbd7a[212]]},attributes:[_0xbd7a[57]]})})[_0xbd7a[67]](function(_0xfcb5x44){if(!_0xfcb5x44){throw  new Error(_0xbd7a[210])};console[_0xbd7a[22]](_0xbd7a[211],_0xfcb5x44[_0xbd7a[57]]);_0xfcb5x40= _[_0xbd7a[133]](_0xfcb5x44[_0xbd7a[73]]);return})[_0xbd7a[67]](function(){return [_0xfcb5x3f,_0xfcb5x2b]})[_0xbd7a[168]](getFaxRoom())[_0xbd7a[67]](function(_0xfcb5x2d){if(!_0xfcb5x2d){throw  new Error(_0xbd7a[121])};console[_0xbd7a[22]](_0xbd7a[157],_0xfcb5x2d[_0xbd7a[55]]);_0xfcb5x31= _0xfcb5x2d;return _0xfcb5x31[_0xbd7a[209]](_0xfcb5x2b[_0xbd7a[55]])})[_0xbd7a[67]](function(){return _0xfcb5x31[_0xbd7a[95]]({status:_0xbd7a[206],lastEvent:_0xbd7a[39],lastEventAt:moment()[_0xbd7a[27]](_0xbd7a[161]),faxOut:++_0xfcb5x31[_0xbd7a[207]]},{individualHooks:true,user:_0xfcb5x3c[_0xbd7a[208]]})})[_0xbd7a[67]](function(_0xfcb5x1a){console[_0xbd7a[22]](_0xbd7a[204],_0xfcb5x1a[_0xbd7a[55]]);io[_0xbd7a[24]](_0xbd7a[120],_0xfcb5x1a);return _0xfcb5x31[_0xbd7a[205]](_0xfcb5x2b.UserId)})[_0xbd7a[67]](function(){return User[_0xbd7a[203]](_0xfcb5x2b.UserId)})[_0xbd7a[67]](function(){if(_0xfcb5x3f[_0xbd7a[171]]){return Contact[_0xbd7a[172]]({where:{ListId:_0xfcb5x3f[_0xbd7a[171]],$or:[{phone:_0xfcb5x3e},{fax:_0xfcb5x3e}]},defaults:{fax:_0xfcb5x3e,phone:_0xfcb5x3e,firstName:_0xfcb5x3e,ListId:_0xfcb5x3f[_0xbd7a[171]]}})}else {return []}})[_0xbd7a[168]](function(_0xfcb5x37,_0xfcb5x38){if(_0xfcb5x38!= undefined&&  !_0xfcb5x38){return _0xfcb5x37[_0xbd7a[95]]({fax:_0xfcb5x3e})};return})[_0xbd7a[67]](function(){_0xfcb5x41= _0xfcb5x2b[_0xbd7a[194]][0][_0xbd7a[3]];if(_0xfcb5x2b[_0xbd7a[194]][0][_0xbd7a[195]]=== _0xbd7a[196]){_0xfcb5x42= path[_0xbd7a[154]](config[_0xbd7a[149]],_0xbd7a[150],_0xbd7a[151],_0xbd7a[137],_0xbd7a[197],_0xbd7a[153],_0xbd7a[198],path[_0xbd7a[147]](_0xfcb5x41)[_0xbd7a[57]]+ _0xbd7a[199]);return exec(_0xbd7a[200]+ _0xfcb5x42+ _0xbd7a[145]+ _0xfcb5x41)}else {_0xfcb5x42= path[_0xbd7a[154]](config[_0xbd7a[149]],_0xbd7a[150],_0xbd7a[151],_0xbd7a[137],_0xbd7a[197],_0xbd7a[153],_0xbd7a[198],path[_0xbd7a[147]](_0xfcb5x41)[_0xbd7a[201]]);fse[_0xbd7a[202]](_0xfcb5x41,_0xfcb5x42);return}})[_0xbd7a[67]](function(){fs[_0xbd7a[192]](_0xfcb5x42,511);console[_0xbd7a[22]](_0xbd7a[193]);return FaxMessage[_0xbd7a[175]]({filename:_0xfcb5x42,localstationid:_0xfcb5x2b[_0xbd7a[140]],retry:_0xfcb5x3b},{where:{id:_0xfcb5x2b[_0xbd7a[55]]}})})[_0xbd7a[67]](function(_0xfcb5x29){if(_0xfcb5x29){io[_0xbd7a[24]](_0xbd7a[92],_0xfcb5x29)};return Promise[_0xbd7a[191]](_0xfcb5x16[_0xbd7a[190]])({action:_0xbd7a[177],channel:util[_0xbd7a[27]](_0xbd7a[178],_0xfcb5x3f[_0xbd7a[179]],_0xfcb5x40[_0xbd7a[57]],_0xfcb5x3e),exten:_0xfcb5x3e,context:_0xbd7a[180],priority:1,callerid:util[_0xbd7a[27]](_0xbd7a[181],_0xfcb5x3f[_0xbd7a[116]],_0xfcb5x3f[_0xbd7a[116]]),variable:{FAXNAME:_0xfcb5x3f[_0xbd7a[57]],FAXNUMBER:_0xfcb5x3e,FAXECM:_0xfcb5x3f[_0xbd7a[182]],FAXHEADERINFO:_0xfcb5x3f[_0xbd7a[183]],FAXLOCALSTATIONID:_0xfcb5x3f[_0xbd7a[116]],FAXMINRATE:_0xfcb5x3f[_0xbd7a[184]],FAXMAXRATE:_0xfcb5x3f[_0xbd7a[185]],FAXMODEM:util[_0xbd7a[27]](_0xbd7a[186],_0xfcb5x3f[_0xbd7a[187]]),FAXGATEWAY:_0xfcb5x3f[_0xbd7a[188]],FAXT38TIMEOUT:_0xfcb5x3f[_0xbd7a[189]],FAXOUTFILE:_0xfcb5x42},account:_0xfcb5x3f[_0xbd7a[116]]})})[_0xbd7a[67]](function(_0xfcb5x43){console[_0xbd7a[22]](_0xbd7a[176]);console[_0xbd7a[22]](_0xfcb5x43)})[_0xbd7a[66]](function(_0xfcb5x1e){console[_0xbd7a[65]](_0xbd7a[173],_0xfcb5x1e);console[_0xbd7a[65]](_0xbd7a[100],_0xfcb5x1e[_0xbd7a[32]]);console[_0xbd7a[65]](_0xbd7a[101],_0xfcb5x1e[_0xbd7a[102]]);return FaxMessage[_0xbd7a[175]]({status:_0xbd7a[127]},{where:{id:_0xfcb5x2b[_0xbd7a[55]]}})[_0xbd7a[67]](function(_0xfcb5x1a){io[_0xbd7a[24]](_0xbd7a[92],_0xfcb5x1a);if(_0xfcb5x31){return _0xfcb5x31[_0xbd7a[95]]({lastEvent:_0xbd7a[127]})};return})[_0xbd7a[67]](function(_0xfcb5x1a){if(_0xfcb5x1a){io[_0xbd7a[24]](_0xbd7a[120],_0xfcb5x1a)}})[_0xbd7a[66]](function(_0xfcb5x1e){console[_0xbd7a[65]](_0xbd7a[174],_0xfcb5x1e);console[_0xbd7a[65]](_0xbd7a[100],_0xfcb5x1e[_0xbd7a[32]]);console[_0xbd7a[65]](_0xbd7a[101],_0xfcb5x1e[_0xbd7a[102]])})})}}function getFaxRoom(){return function(_0xfcb5x1b,_0xfcb5x2a){if(_0xfcb5x2a[_0xbd7a[158]]){return FaxRoom[_0xbd7a[203]](_0xfcb5x2a.FaxRoomId)}else {return FaxRoom[_0xbd7a[68]]({limit:1,where:{contact:_0xfcb5x2a[_0xbd7a[28]],FaxAccountId:_0xfcb5x1b[_0xbd7a[55]]},order:[[_0xbd7a[166],_0xbd7a[167]]]})[_0xbd7a[67]](function(_0xfcb5x46){var _0xfcb5x2c=_[_0xbd7a[160]](_0xfcb5x46);if(!_0xfcb5x2c|| _0xfcb5x2c[_0xbd7a[37]]=== _0xbd7a[50]){return FaxRoom[_0xbd7a[155]]({contact:_0xfcb5x2a[_0xbd7a[28]],account:_0xfcb5x1b[_0xbd7a[57]],status:_0xbd7a[206],FaxAccountId:_0xfcb5x1b[_0xbd7a[55]]})}else {return _0xfcb5x2c}})}}}module[_0xbd7a[213]]= Fax