316a7f363642945580ee35ab19dfeabdf3da6a18
[motion.git] / server / config / ami / db / fax.js
1 var _0x8d21=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x6D\x6F\x6D\x65\x6E\x74","\x75\x74\x69\x6C","\x6C\x6F\x64\x61\x73\x68","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\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","\x2E\x2E\x2F\x2E\x2E\x2F\x72\x6F\x75\x74\x69\x6E\x67\x2F\x73\x63\x68\x65\x64\x75\x6C\x65\x72","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x46\x61\x78\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\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\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x66\x6F\x72\x6D\x61\x74","\x6C\x6F\x67","\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","\x65\x72\x72\x6F\x72","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x3A","\x6D\x65\x73\x73\x61\x67\x65","\x5B\x46\x61\x78\x5D\x20\x53\x74\x61\x63\x6B\x3A","\x73\x74\x61\x63\x6B","\x63\x61\x74\x63\x68","\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64","\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","\x66\x61\x78","\x25\x73\x2E\x25\x73","\x75\x6E\x69\x78","\x69\x64","\x6E\x61\x6D\x65","\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x66\x72\x6F\x6D","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x70\x61\x72\x73\x65","\x69\x6E\x69\x74","\x74\x68\x65\x6E","\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","\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\x54\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x20\x66\x69\x6C\x65\x20\x69\x73\x20\x65\x6D\x70\x74\x79\x20\x28\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x3A\x25\x73\x29","\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","\x73\x74\x61\x74\x75\x73","\x52\x45\x43\x45\x49\x56\x45\x44","\x74\x6F","","\x54\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x20\x66\x69\x6C\x65\x20\x69\x73\x20\x65\x6D\x70\x74\x79","\x6C\x65\x6E\x67\x74\x68","\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","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x4E\x45\x57","\x43\x4C\x4F\x53\x45\x44","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x66\x69\x6E\x64\x41\x6C\x6C","\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","\x66\x69\x6E\x64\x4F\x6E\x65","\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","\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","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\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","\x76\x61\x72\x69\x61\x62\x6C\x65","\x73\x65\x6E\x64","\x72\x65\x73\x6F\x6C\x76\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","\x63\x68\x61\x6E\x6E\x65\x6C","\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\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\x61\x78\x65\x72\x72\x6F\x72","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x76\x61\x6C\x75\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"];_0x8d21[0];var BPromise=require(_0x8d21[1]);var moment=require(_0x8d21[2]);var util=require(_0x8d21[3]);var _=require(_0x8d21[4]);var path=require(_0x8d21[5]);var config=require(_0x8d21[6]);var exec=require(_0x8d21[8])[_0x8d21[7]];var Scheduler=require(_0x8d21[9]);var FaxMessage=require(_0x8d21[11])[_0x8d21[10]];var FaxRoom=require(_0x8d21[11])[_0x8d21[12]];var FaxAccount=require(_0x8d21[11])[_0x8d21[13]];var FaxAttachment=require(_0x8d21[11])[_0x8d21[14]];var Contact=require(_0x8d21[11])[_0x8d21[15]];module[_0x8d21[16]]= function(){return {receivefax:function(_0xb8bfxe){return function(_0xb8bfxf){console[_0x8d21[20]](util[_0x8d21[19]](_0x8d21[17],_0xb8bfxe[_0x8d21[18]]));var _0xb8bfx10=_[_0x8d21[21]](_0xb8bfxe);var _0xb8bfx11;var _0xb8bfx12,_0xb8bfx13;return FaxAccount[_0x8d21[81]]({where:{localstationid:_0xb8bfxe[_0x8d21[36]]}})[_0x8d21[41]](function(_0xb8bfx1d){if(!_0xb8bfx1d){throw  new Error(_0x8d21[77])};console[_0x8d21[20]](_0x8d21[78],_0xb8bfxe[_0x8d21[36]]);_0xb8bfx11= _0xb8bfx1d;if(_0xb8bfx11[_0x8d21[79]]){return Contact[_0x8d21[80]]({where:{ListId:_0xb8bfx11[_0x8d21[79]],$or:[{phone:_0xb8bfxe[_0x8d21[18]]},{fax:_0xb8bfxe[_0x8d21[18]]}]},defaults:{phone:_0xb8bfxe[_0x8d21[18]],fax:_0xb8bfxe[_0x8d21[18]],firstName:_0xb8bfxe[_0x8d21[18]],ListId:_0xb8bfx11[_0x8d21[79]]}})}else {return []}})[_0x8d21[76]](function(_0xb8bfx1b,_0xb8bfx1c){if(_0xb8bfx1c!== undefined&&  !_0xb8bfx1c){return _0xb8bfx1b[_0x8d21[70]]({fax:_0xb8bfxe[_0x8d21[18]]})};return})[_0x8d21[41]](function(){return FaxRoom[_0x8d21[75]]({limit:1,where:{contact:_0xb8bfx10[_0x8d21[18]],FaxAccountId:_0xb8bfx11[_0x8d21[34]],status:{$ne:_0x8d21[72]}},order:[[_0x8d21[73],_0x8d21[74]]]})})[_0x8d21[41]](function(_0xb8bfx1a){if(_0xb8bfx1a[_0x8d21[64]]){_0xb8bfx1a= _[_0x8d21[65]](_0xb8bfx1a);return _0xb8bfx1a[_0x8d21[70]]({lastEvent:_0x8d21[60],lastEventAt:moment()[_0x8d21[19]](_0x8d21[66]),status:_0x8d21[67],openReason:_0x8d21[68],faxIn:++_0xb8bfx1a[_0x8d21[69]]})}else {return FaxRoom[_0x8d21[54]]({contact:_0xb8bfx10[_0x8d21[18]],account:_0xb8bfx11[_0x8d21[35]],status:_0x8d21[71],lastEvent:_0x8d21[60],lastEventAt:moment()[_0x8d21[19]](_0x8d21[66]),FaxAccountId:_0xb8bfx11[_0x8d21[34]],faxIn:1})}})[_0x8d21[41]](function(_0xb8bfx1a){if(!_0xb8bfx1a){throw  new Error(_0x8d21[56])};console[_0x8d21[20]](_0x8d21[57],_0xb8bfx1a[_0x8d21[34]]);_0xb8bfx13= _0xb8bfx1a;_0xb8bfx10[_0x8d21[58]]= _0xb8bfx1a[_0x8d21[34]];_0xb8bfx10[_0x8d21[59]]= _0x8d21[60];_0xb8bfx10[_0x8d21[37]]= _0xb8bfx10[_0x8d21[18]];_0xb8bfx10[_0x8d21[61]]= _0xb8bfx10[_0x8d21[36]];_0xb8bfx10[_0x8d21[23]]= parseInt(_0xb8bfx10[_0x8d21[29]])> 0?_0x8d21[62]:_0x8d21[63];return FaxMessage[_0x8d21[54]](_0xb8bfx10)})[_0x8d21[41]](function(_0xb8bfx17){if(!_0xb8bfx17){throw  new Error(_0x8d21[46])};_0xb8bfx12= _0xb8bfx17;console[_0x8d21[20]](_0x8d21[24],_0xb8bfx17[_0x8d21[34]]);if(parseInt(_0xb8bfxe[_0x8d21[29]])> 0){var _0xb8bfx18=path[_0x8d21[39]](_0xb8bfxe[_0x8d21[38]])[_0x8d21[35]];var _0xb8bfx19=_0xb8bfx18+ _0x8d21[47];return FaxAttachment[_0x8d21[54]]({path:path[_0x8d21[53]](config[_0x8d21[48]],_0x8d21[49],_0x8d21[50],_0x8d21[31],_0x8d21[51],_0x8d21[52],_0xb8bfx19),basename:_0xb8bfx19,name:_0xb8bfx18,FaxMessageId:_0xb8bfx17[_0x8d21[34]]})};console[_0x8d21[20]](util[_0x8d21[19]](_0x8d21[55],_0xb8bfxe[_0x8d21[29]]));return})[_0x8d21[41]](function(_0xb8bfx16){if(!_0xb8bfx16){console[_0x8d21[20]](_0x8d21[42]);return};console[_0x8d21[20]](_0x8d21[43],_0xb8bfx16[_0x8d21[34]]);return exec(_0x8d21[44]+ _0xb8bfx16[_0x8d21[5]]+ _0x8d21[45]+ _0xb8bfxe[_0x8d21[38]])})[_0x8d21[41]](function(){if(parseInt(_0xb8bfxe[_0x8d21[29]])> 0){console[_0x8d21[20]](_0x8d21[30]);var _0xb8bfx15= new Scheduler({channel:_0x8d21[31],uniqueid:util[_0x8d21[19]](_0x8d21[32],moment()[_0x8d21[33]](),_0xb8bfx13[_0x8d21[34]]),messageid:_0xb8bfx12[_0x8d21[34]],roomid:_0xb8bfx13[_0x8d21[34]],accountid:_0xb8bfx11[_0x8d21[34]],accountname:_0xb8bfx11[_0x8d21[35]],accountphone:_0xb8bfx11[_0x8d21[36]],from:_0xb8bfx12[_0x8d21[37]],attachmentBasename:path[_0x8d21[39]](_0xb8bfxe[_0x8d21[38]])[_0x8d21[35]]});_0xb8bfx15[_0x8d21[40]]()}})[_0x8d21[28]](function(_0xb8bfx14){console[_0x8d21[23]](_0x8d21[22],_0xb8bfx14);console[_0x8d21[23]](_0x8d21[24],_0xb8bfx14[_0x8d21[25]]);console[_0x8d21[23]](_0x8d21[26],_0xb8bfx14[_0x8d21[27]])})}},sendfax:function(_0xb8bfxe){return function(_0xb8bfxf){var _0xb8bfx12;return FaxMessage[_0x8d21[81]]({where:{filename:_0xb8bfxe[_0x8d21[38]],localstationid:_0xb8bfxe[_0x8d21[36]]}})[_0x8d21[41]](function(_0xb8bfx1f){if(!_0xb8bfx1f){throw  new Error(_0x8d21[88])};_0xb8bfx12= _0xb8bfx1f;var _0xb8bfx20=_0x8d21[85];if(_0xb8bfxe[_0x8d21[29]]=== _0x8d21[89]){_0xb8bfx20= _0x8d21[90]};return _0xb8bfx12[_0x8d21[70]]({remotestationid:_0xb8bfxe[_0x8d21[91]],pagestransferred:_0xb8bfxe[_0x8d21[29]],resolution:_0xb8bfxe[_0x8d21[92]],transferrate:_0xb8bfxe[_0x8d21[93]],status:_0xb8bfx20})})[_0x8d21[41]](function(_0xb8bfx17){console[_0x8d21[20]](_0x8d21[86],_0xb8bfx17[_0x8d21[34]]);return _0xb8bfx12[_0x8d21[87]]()})[_0x8d21[41]](function(_0xb8bfx1e){if(!_0xb8bfx1e){throw  new Error(_0x8d21[84])};return _0xb8bfx1e[_0x8d21[70]]({lastEvent:_0x8d21[85]},{individualHooks:true})})[_0x8d21[41]](function(_0xb8bfx1a){console[_0x8d21[20]](_0x8d21[83],_0xb8bfx1a[_0x8d21[34]])})[_0x8d21[28]](function(_0xb8bfx14){console[_0x8d21[23]](_0x8d21[82],_0xb8bfx14);console[_0x8d21[23]](_0x8d21[24],_0xb8bfx14[_0x8d21[25]]);console[_0x8d21[23]](_0x8d21[26],_0xb8bfx14[_0x8d21[27]])})}},faxstatus:function(_0xb8bfxe){return function(_0xb8bfxf){if(_0xb8bfxe[_0x8d21[94]]!== _0x8d21[95]){return BPromise[_0x8d21[96]]()};return FaxMessage[_0x8d21[81]]({where:{filename:_0xb8bfxe[_0x8d21[38]],localstationid:_0xb8bfxe[_0x8d21[36]]}})[_0x8d21[41]](function(_0xb8bfx1f){if(!_0xb8bfx1f){throw  new Error(_0x8d21[88])};return _0xb8bfx1f[_0x8d21[70]]({channel:_0xb8bfxe[_0x8d21[98]],channelstate:_0xb8bfxe[_0x8d21[99]],channelstatedesc:_0xb8bfxe[_0x8d21[100]],calleridnum:_0xb8bfxe[_0x8d21[18]],calleridname:_0xb8bfxe[_0x8d21[101]],connectedlinenum:_0xb8bfxe[_0x8d21[102]],connectedlinename:_0xb8bfxe[_0x8d21[103]],accountcode:_0xb8bfxe[_0x8d21[104]],context:_0xb8bfxe[_0x8d21[105]],exten:_0xb8bfxe[_0x8d21[106]],priority:_0xb8bfxe[_0x8d21[107]],uniqueid:_0xb8bfxe[_0x8d21[108]],linkedid:_0xb8bfxe[_0x8d21[109]],lastStatus:_0xb8bfxe[_0x8d21[59]]})})[_0x8d21[28]](function(_0xb8bfx14){console[_0x8d21[23]](_0x8d21[97],_0xb8bfx14);console[_0x8d21[23]](_0x8d21[24],_0xb8bfx14[_0x8d21[25]]);console[_0x8d21[23]](_0x8d21[26],_0xb8bfx14[_0x8d21[27]])})}},faxerror:function(_0xb8bfxe){return function(_0xb8bfxf){if(!_0xb8bfxe[_0x8d21[94]][_0x8d21[111]](_0x8d21[110])||  !_0xb8bfxe[_0x8d21[112]]){return BPromise[_0x8d21[96]]()};return FaxMessage[_0x8d21[81]]({where:{channel:_0xb8bfxe[_0x8d21[98]]}})[_0x8d21[41]](function(_0xb8bfx1f){if(_0xb8bfx1f){return _0xb8bfx1f[_0x8d21[70]]({error:_0xb8bfxe[_0x8d21[112]]})};return})[_0x8d21[28]](function(_0xb8bfx14){console[_0x8d21[23]](_0x8d21[113],_0xb8bfx14)})}}}}