Built motion from commit e493b9a4954b50a8ee6d0034ba3601cd210d989d. Version 3.0.0...
[motion-next.git] / server / services / ami / fax / index.js
index f91d4e1..ab0bdda 100644 (file)
@@ -1 +1 @@
-const a1229_0x2f7a=['create','Trunk\x20Reachable','\x20result\x20conversion\x20file\x20','execOriginate','faxpages','Trunk\x20not\x20working','dir','originateresponse','finally','[Fax][checkTrunk][Empty\x20path]','prototype','from-voip-provider','pagestransferred','./util/gs','trunks','isValid','faxAccounts','faxstatus','actions','syncVarSet','name','checkTrunk','\x20hangup\x20sendFile\x20','channelstate','localstationid','message','path','Fax\x20received','../ami','transferrate','error','lodash','parse','\x20Trunk\x20is\x20not\x20active','remotestationid','faxstatusstring','isTrunkReachable','calleridnum','logger','hangup','variable','[Fax][Message][NoUpdate2]','syncNewchannel','exten','[Fax][Message][Error][NoUpdate1]','bind','reason','operation','Convert\x20pdf\x20to\x20tif','../../../config/logger','channelstatedesc','reachable','checkAfterSend','SENDING\x20FAILED:\x20','updateStatus','\x20syncFaxStatus\x20','tiff2pdf','syncOriginateResponse','../rpc/faxMessage','stringify','active','XMF-PATH','newstate','varset','SIP/%s','\x20receiveFax\x20','filename','gs\x20-q\x20-dNOPAUSE\x20-dBATCH\x20-sDEVICE=tiffg4\x20-sPAPERSIZE=letter\x20-sOutputFile=/var/opt/motion2/server/files/attachments/%s.tif\x20\x20%s\x20-c\x20quit','pick','syncNewState','value','receivefax','FaxAccountId','uniqueid','[Fax][Message][Error][Updated]','util','./action','AttachmentId','status','Action','[Fax][Message][Updated]','syncNewExten','syncHangup','catch','../rpc/faxAccount','.pdf','Is\x20Valid','../rpc/attachment','variablesAction','then','update','uuid','newchannel','ext','Fax\x20failed','isNil','[Fax][execOriginate][success]','channels','info','response','syncFaxStatus','Empty\x20path','syncReceiveFax','/var/opt/motion2/server/files/attachments/','resolution','\x20syncNewchannel\x20','application/pdf','\x20hangup\x20faxRiceive\x20','fax','[Fax][Message][Error][NoUpdate2]','format','\x20notify\x20','channel','./util/util','undefined','send'];(function(_0x3ce01a,_0x786a2c){const _0x2f7a46=function(_0x53ef68){while(--_0x53ef68){_0x3ce01a['push'](_0x3ce01a['shift']());}};_0x2f7a46(++_0x786a2c);}(a1229_0x2f7a,0x17c));const a1229_0x53ef=function(_0x3ce01a,_0x786a2c){_0x3ce01a=_0x3ce01a-0xe8;let _0x2f7a46=a1229_0x2f7a[_0x3ce01a];return _0x2f7a46;};const a1229_0x43963f=a1229_0x53ef;'use strict';const util=require(a1229_0x43963f(0x113)),_=require(a1229_0x43963f(0x15b)),uuid=require(a1229_0x43963f(0x123)),path=require(a1229_0x43963f(0x156)),tiff2pdf=require(a1229_0x43963f(0x100)),gs=require(a1229_0x43963f(0x149)),logger=require(a1229_0x43963f(0xf9))(a1229_0x43963f(0x134)),ami=require(a1229_0x43963f(0x158)),ut=require(a1229_0x43963f(0x139)),Action=require(a1229_0x43963f(0x114)),faxAccount=require(a1229_0x43963f(0x11c)),attachment=require(a1229_0x43963f(0x11f)),faxMessage=require(a1229_0x43963f(0x102));function Fax(_0x60a50a){const _0x21e215=a1229_0x43963f;this['channels']={},this['faxAccounts']=_0x60a50a[_0x21e215(0x14c)],this['trunks']=_0x60a50a['trunks'],this[_0x21e215(0x14e)]={},ami['on'](_0x21e215(0x124),this[_0x21e215(0xf2)][_0x21e215(0xf5)](this)),ami['on'](_0x21e215(0x107),this[_0x21e215(0x14f)]['bind'](this)),ami['on'](_0x21e215(0x106),this[_0x21e215(0x10d)]['bind'](this)),ami['on']('newexten',this['syncNewExten']['bind'](this)),ami['on'](_0x21e215(0x14d),this[_0x21e215(0x12c)][_0x21e215(0xf5)](this)),ami['on'](_0x21e215(0x10f),this[_0x21e215(0x12e)][_0x21e215(0xf5)](this)),ami['on'](_0x21e215(0xef),this[_0x21e215(0x11a)][_0x21e215(0xf5)](this)),ami['on'](_0x21e215(0x143),this['syncOriginateResponse']['bind'](this));}Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0xf2)]=function(_0x9f0a4d){const _0x50c18e=a1229_0x43963f;if(_0x9f0a4d['context']===_0x50c18e(0x147))for(const _0x4d4a4e in this[_0x50c18e(0x14c)]){typeof this[_0x50c18e(0x14c)][_0x4d4a4e]!==_0x50c18e(0x13a)&&(_0x9f0a4d[_0x50c18e(0xf3)]===this[_0x50c18e(0x14c)][_0x4d4a4e]['localstationid']&&(this['channels'][_0x9f0a4d[_0x50c18e(0x111)]]={},this[_0x50c18e(0x129)][_0x9f0a4d[_0x50c18e(0x111)]][_0x50c18e(0x138)]=_0x9f0a4d[_0x50c18e(0x138)],this['channels'][_0x9f0a4d[_0x50c18e(0x111)]]['id']=this['faxAccounts'][_0x4d4a4e]['id'],this[_0x50c18e(0x129)][_0x9f0a4d[_0x50c18e(0x111)]][_0x50c18e(0x150)]=this[_0x50c18e(0x14c)][_0x4d4a4e][_0x50c18e(0x150)],logger[_0x50c18e(0x12a)](_0x9f0a4d[_0x50c18e(0x111)],_0x50c18e(0x131))));}this[_0x50c18e(0x14e)][_0x9f0a4d[_0x50c18e(0x111)]]&&(this['channels'][_0x9f0a4d[_0x50c18e(0x111)]]={},this[_0x50c18e(0x129)][_0x9f0a4d['uniqueid']][_0x50c18e(0x138)]=_0x9f0a4d[_0x50c18e(0x138)],logger['info'](_0x9f0a4d[_0x50c18e(0x111)],'\x20syncNewchannel\x20'));},Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0x14f)]=function(_0x1668c2){const _0x1a2e57=a1229_0x43963f;if(this[_0x1a2e57(0x129)][_0x1668c2['uniqueid']])for(const _0x1603cb in _0x1668c2['variable']){typeof _0x1668c2[_0x1a2e57(0xf0)][_0x1603cb]!==_0x1a2e57(0x13a)&&(this['channels'][_0x1668c2[_0x1a2e57(0x111)]][_0x1603cb]=_0x1668c2['value']);}},Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0x10d)]=function(_0x4e3fd3){const _0x3964fc=a1229_0x43963f;this[_0x3964fc(0x129)][_0x4e3fd3[_0x3964fc(0x111)]]&&(this['channels'][_0x4e3fd3[_0x3964fc(0x111)]][_0x3964fc(0x153)]=_0x4e3fd3[_0x3964fc(0x153)],this[_0x3964fc(0x129)][_0x4e3fd3[_0x3964fc(0x111)]]['channelstatedesc']=_0x4e3fd3[_0x3964fc(0xfa)]);},Fax['prototype'][a1229_0x43963f(0x119)]=function(_0x197315){const _0x32f0cc=a1229_0x43963f;if(this[_0x32f0cc(0x129)][_0x197315[_0x32f0cc(0x111)]])for(const _0x1f4d67 in _0x197315['variable']){typeof _0x197315[_0x32f0cc(0xf0)][_0x1f4d67]!==_0x32f0cc(0x13a)&&(this[_0x32f0cc(0x129)][_0x197315['uniqueid']][_0x1f4d67]=_0x197315[_0x32f0cc(0x10e)]);}},Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0x12c)]=function(_0x42b0fb){const _0x42e9fd=a1229_0x43963f;this[_0x42e9fd(0x129)][_0x42b0fb[_0x42e9fd(0x111)]]&&(this[_0x42e9fd(0x129)][_0x42b0fb[_0x42e9fd(0x111)]][_0x42e9fd(0xf7)]=_0x42b0fb[_0x42e9fd(0xf7)],this[_0x42e9fd(0x129)][_0x42b0fb[_0x42e9fd(0x111)]][_0x42e9fd(0x116)]=_0x42b0fb[_0x42e9fd(0x116)],this[_0x42e9fd(0x129)][_0x42b0fb[_0x42e9fd(0x111)]]['localstationid']=_0x42b0fb[_0x42e9fd(0x154)],this['channels'][_0x42b0fb[_0x42e9fd(0x111)]]['filename']=_0x42b0fb[_0x42e9fd(0x10a)],logger['info'](_0x42b0fb['uniqueid'],_0x42e9fd(0xff)));},Fax['prototype']['syncReceiveFax']=function(_0x4124ac){const _0x4aaae5=a1229_0x43963f;if(this[_0x4aaae5(0x129)][_0x4124ac['uniqueid']]){const _0xc18466=this[_0x4aaae5(0x129)][_0x4124ac[_0x4aaae5(0x111)]]['id'];this[_0x4aaae5(0x129)][_0x4124ac[_0x4aaae5(0x111)]]['remotestationid']=_0x4124ac[_0x4aaae5(0xea)],this[_0x4aaae5(0x129)][_0x4124ac[_0x4aaae5(0x111)]][_0x4aaae5(0x148)]=_0x4124ac['pagestransferred'],this['channels'][_0x4124ac[_0x4aaae5(0x111)]]['localstationid']=_0x4124ac[_0x4aaae5(0x154)],this[_0x4aaae5(0x129)][_0x4124ac['uniqueid']][_0x4aaae5(0x130)]=_0x4124ac[_0x4aaae5(0x130)],this[_0x4aaae5(0x129)][_0x4124ac[_0x4aaae5(0x111)]][_0x4aaae5(0x159)]=_0x4124ac['transferrate'],this['channels'][_0x4124ac[_0x4aaae5(0x111)]]['filename']=_0x4124ac[_0x4aaae5(0x10a)],this[_0x4aaae5(0x129)][_0x4124ac[_0x4aaae5(0x111)]][_0x4aaae5(0xed)]=_0x4124ac[_0x4aaae5(0xed)],this[_0x4aaae5(0x129)][_0x4124ac['uniqueid']][_0x4aaae5(0x148)]>0x0&&tiff2pdf(_0x4124ac[_0x4aaae5(0x10a)],_0x4aaae5(0x12f),function(_0x440eff){const _0x33ba1c=_0x4aaae5;logger[_0x33ba1c(0x12a)](_0x4124ac[_0x33ba1c(0x111)],_0x33ba1c(0x13e),_0x440eff[_0x33ba1c(0x155)]),attachment[_0x33ba1c(0x13c)]({'name':path[_0x33ba1c(0xe8)](_0x4124ac[_0x33ba1c(0x10a)])[_0x33ba1c(0x150)],'basename':path[_0x33ba1c(0xe8)](_0x4124ac['filename'])[_0x33ba1c(0x150)]+'.pdf','type':_0x33ba1c(0x132)})[_0x33ba1c(0x121)](function(_0x564b16){const _0x33ff94=_0x33ba1c;faxAccount['notify'](_0xc18466,{'from':_0x4124ac[_0x33ff94(0xed)],'mapKey':_0x33ff94(0x134),'body':path['parse'](_0x4124ac[_0x33ff94(0x10a)])[_0x33ff94(0x150)]+'.pdf','AttachmentId':_0x564b16['id']})[_0x33ff94(0x11b)](function(_0x16de6f){const _0x3e3d44=_0x33ff94;logger[_0x3e3d44(0x15a)](_0x4124ac['uniqueid'],_0x3e3d44(0x137),JSON['stringify'](_0x16de6f));});})['catch'](function(_0x151648){const _0x3971d0=_0x33ba1c;logger[_0x3971d0(0x15a)](_0x4124ac['uniqueid'],_0x3971d0(0x109),JSON[_0x3971d0(0x103)](_0x151648));});}),logger['info'](_0x4124ac['uniqueid'],'\x20receiveFax\x20');}},Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0x101)]=function(_0x1c4c22){const _0x448e36=a1229_0x43963f;this[_0x448e36(0x14e)][_0x1c4c22[_0x448e36(0x111)]]&&_['merge'](this['channels'][_0x1c4c22[_0x448e36(0x111)]],_[_0x448e36(0x10c)](_0x1c4c22,[_0x448e36(0x12b),_0x448e36(0xf6)]));};function updateStatus(_0xf14d50){const _0x545653=a1229_0x43963f;_0xf14d50['AttachmentId']?faxMessage[_0x545653(0x122)](_0xf14d50[_0x545653(0x115)],{'failMessage':'SENDING\x20FAILED\x20'})[_0x545653(0x121)](function(_0x1f1406){const _0x35c403=_0x545653;ut[_0x35c403(0xee)](_0x35c403(0x112),_0x1f1406);})[_0x545653(0x11b)](function(_0x3177b6){const _0x4d6082=_0x545653;ut[_0x4d6082(0xee)](_0x4d6082(0xf4),_0x3177b6);}):ut['logger'](_0x545653(0x135));}Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0xfe)]=function(_0x1d731c,_0x13f134,_0x3257d6){const _0x4586fa=a1229_0x43963f,_0xc0cd9a=this;let _0x5f0aa1={};_0x13f134?_0x5f0aa1={'read':_0x13f134}:_0x5f0aa1={'failMessage':_0x3257d6},this[_0x4586fa(0x14e)][_0x1d731c][_0x4586fa(0x115)]?faxMessage[_0x4586fa(0x122)](this[_0x4586fa(0x14e)][_0x1d731c][_0x4586fa(0x115)],_0x5f0aa1)[_0x4586fa(0x121)](function(_0x16ffb3){const _0x1a7cde=_0x4586fa;ut[_0x1a7cde(0xee)](_0x1a7cde(0x118),_0x16ffb3);})[_0x4586fa(0x11b)](function(_0x309db){const _0x162d8c=_0x4586fa;ut[_0x162d8c(0xee)]('[Fax][Message][NoUpdate1]',_0x309db);})[_0x4586fa(0x144)](function(){delete _0xc0cd9a['channels'][_0x1d731c],delete _0xc0cd9a['actions'][_0x1d731c];}):(ut[_0x4586fa(0xee)](_0x4586fa(0xf1)),delete this[_0x4586fa(0x129)][_0x1d731c],delete this[_0x4586fa(0x14e)][_0x1d731c]);},Fax['prototype'][a1229_0x43963f(0x11a)]=function(_0x3bc5f8){const _0x419e4a=a1229_0x43963f;this[_0x419e4a(0x129)][_0x3bc5f8['uniqueid']]&&(this['actions'][_0x3bc5f8[_0x419e4a(0x111)]]&&(this[_0x419e4a(0x129)][_0x3bc5f8[_0x419e4a(0x111)]]['id']=this['actions'][_0x3bc5f8['uniqueid']]['id'],this[_0x419e4a(0x129)][_0x3bc5f8[_0x419e4a(0x111)]][_0x419e4a(0x150)]=this['actions'][_0x3bc5f8[_0x419e4a(0x111)]]['name']),logger[_0x419e4a(0x12a)](_0x3bc5f8[_0x419e4a(0x111)],this['actions'][_0x3bc5f8[_0x419e4a(0x111)]]?_0x419e4a(0x152):_0x419e4a(0x133),JSON[_0x419e4a(0x103)](this['channels'][_0x3bc5f8[_0x419e4a(0x111)]])),this['actions'][_0x3bc5f8[_0x419e4a(0x111)]]&&(this[_0x419e4a(0x129)][_0x3bc5f8[_0x419e4a(0x111)]][_0x419e4a(0x140)]>0x0&&this[_0x419e4a(0x129)][_0x3bc5f8[_0x419e4a(0x111)]][_0x419e4a(0x14d)]==='SUCCESS'?this[_0x419e4a(0xfe)](_0x3bc5f8[_0x419e4a(0x111)],!![]):this[_0x419e4a(0xfe)](_0x3bc5f8[_0x419e4a(0x111)],![],this['channels'][_0x3bc5f8[_0x419e4a(0x111)]][_0x419e4a(0xeb)]?_0x419e4a(0xfd)+this[_0x419e4a(0x129)][_0x3bc5f8[_0x419e4a(0x111)]][_0x419e4a(0xeb)]:'SENDING\x20FAILED')));},Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0x13b)]=function(_0x54a351){const _0x53527d=this;return new Promise(function(_0x91cf75,_0x3e748e){const _0x162820=a1229_0x53ef;_0x53527d[_0x162820(0x13f)](_0x54a351,_0x53527d[_0x162820(0x14c)][_0x54a351[_0x162820(0x110)]])[_0x162820(0x121)](function(_0x2fdb7d){const _0x28f129=_0x162820;ut[_0x28f129(0xee)](_0x28f129(0x128),_0x2fdb7d),_0x91cf75(ut[_0x28f129(0x155)](_0x28f129(0x157)));})[_0x162820(0x11b)](function(_0x264cb3){const _0x26824f=_0x162820;ut['logger']('[Fax][execOriginate][failure]',_0x264cb3),updateStatus(_0x54a351),_0x3e748e(ut[_0x26824f(0x155)](_0x26824f(0x126)));});});},Fax['prototype'][a1229_0x43963f(0xfc)]=function(_0x24622a){const _0x332469=this;return new Promise(function(_0x42a410,_0x2063f0){const _0x51a8ad=a1229_0x53ef,_0x1d85f5=_0x332469['checkTrunk'](_0x332469[_0x51a8ad(0x14c)][_0x24622a['FaxAccountId']]['Trunk'],_0x24622a);_0x1d85f5[_0x51a8ad(0x14b)]?_0x42a410(ut[_0x51a8ad(0x155)](_0x51a8ad(0x13d))):_0x2063f0(ut[_0x51a8ad(0x155)](_0x1d85f5[_0x51a8ad(0x155)]));});};function originate(_0x536d99,_0x26e4a8,_0x1d61ea){return new Promise(function(_0x193a10,_0xb1a131){const _0x2c74f9=a1229_0x53ef;if(_0x1d61ea){const _0x624b01=util['format'](_0x2c74f9(0x10b),path[_0x2c74f9(0xe8)](_0x536d99['path'])['name'],_0x536d99[_0x2c74f9(0x156)]);gs['execute'](_0x624b01)[_0x2c74f9(0x121)](function(){const _0x345b1a=_0x2c74f9;_0x536d99[_0x345b1a(0x156)]=util[_0x345b1a(0x136)]('%s/%s.tif',path['parse'](_0x536d99[_0x345b1a(0x156)])[_0x345b1a(0x142)],path[_0x345b1a(0xe8)](_0x536d99['path'])[_0x345b1a(0x150)]),_0x26e4a8[_0x345b1a(0x105)]=_0x536d99[_0x345b1a(0x156)],ut[_0x345b1a(0xee)](_0x345b1a(0xf8),''),ami['Action'](ut[_0x345b1a(0x120)](_0x536d99,_0x26e4a8))[_0x345b1a(0x121)](function(_0x3f04d1){_0x193a10(_0x3f04d1);})[_0x345b1a(0x11b)](function(_0x1ff1d4){_0xb1a131(_0x1ff1d4);});})[_0x2c74f9(0x11b)](function(_0x189ea1){_0xb1a131(_0x189ea1);});}else ami[_0x2c74f9(0x117)](ut[_0x2c74f9(0x120)](_0x536d99,_0x26e4a8))['then'](function(_0x1c1c21){_0x193a10(_0x1c1c21);})['catch'](function(_0x58c346){_0xb1a131(_0x58c346);});});}Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0x13f)]=function(_0x4475bc,_0x1d618a){const _0x1885b7=this;return new Promise(function(_0x53da8b,_0x1b89fa){const _0x2eb8de=a1229_0x53ef,_0x50b2d2=uuid['v4'](),_0x1f6d50=ut['addVariables'](_0x4475bc,_0x1d618a);_0x1885b7[_0x2eb8de(0x14e)][_0x50b2d2]=new Action(_0x50b2d2,_0x1d618a,_0x4475bc);const _0x3395d5=_0x1885b7[_0x2eb8de(0x14e)][_0x50b2d2];path[_0x2eb8de(0xe8)](_0x4475bc[_0x2eb8de(0x156)])[_0x2eb8de(0x125)]===_0x2eb8de(0x11d)?originate(_0x3395d5,_0x1f6d50,!![])[_0x2eb8de(0x121)](function(_0x127d28){_0x53da8b(_0x127d28);})[_0x2eb8de(0x11b)](function(_0x293f8d){_0x1b89fa(_0x293f8d);}):originate(_0x3395d5,_0x1f6d50,![])[_0x2eb8de(0x121)](function(_0x3e9fcf){_0x53da8b(_0x3e9fcf);})[_0x2eb8de(0x11b)](function(_0xb99410){_0x1b89fa(_0xb99410);});});},Fax[a1229_0x43963f(0x146)][a1229_0x43963f(0xec)]=function(_0x3be834){const _0x4ef89c=a1229_0x43963f;return!_[_0x4ef89c(0x127)](_0x3be834)&&!_[_0x4ef89c(0x127)](_0x3be834[_0x4ef89c(0x150)])&&!_['isNil'](_0x3be834[_0x4ef89c(0x104)])&&_0x3be834[_0x4ef89c(0x104)]&&!_[_0x4ef89c(0x127)](this[_0x4ef89c(0x14a)][util[_0x4ef89c(0x136)]('SIP/%s',_0x3be834[_0x4ef89c(0x150)])])&&!_['isNil'](this[_0x4ef89c(0x14a)][util['format']('SIP/%s',_0x3be834[_0x4ef89c(0x150)])][_0x4ef89c(0x116)])&&(this['trunks'][util[_0x4ef89c(0x136)](_0x4ef89c(0x108),_0x3be834[_0x4ef89c(0x150)])][_0x4ef89c(0x116)]===_0x4ef89c(0xfb)||this['trunks'][util[_0x4ef89c(0x136)](_0x4ef89c(0x108),_0x3be834['name'])][_0x4ef89c(0x116)]==='unmonitored');},Fax['prototype'][a1229_0x43963f(0x151)]=function(_0x3110e5,_0x3fea08){const _0x1af2c2=a1229_0x43963f;if(!this[_0x1af2c2(0xec)](_0x3110e5))return ut[_0x1af2c2(0xee)]('[Fax][checkTrunk][Trunk\x20not\x20work]',_[_0x1af2c2(0x127)](_0x3110e5)?'':_0x3110e5['name']+_0x1af2c2(0xe9)),{'isValid':![],'message':_0x1af2c2(0x141)};if(_['isNil'](_0x3fea08[_0x1af2c2(0x134)]))return ut['logger']('[Fax][checkTrunk][Empty\x20Fax]',JSON['stringify'](_0x3fea08)),{'isValid':![],'message':'Empty\x20Fax'};if(_[_0x1af2c2(0x127)](_0x3fea08[_0x1af2c2(0x156)]))return ut[_0x1af2c2(0xee)](_0x1af2c2(0x145),JSON[_0x1af2c2(0x103)](_0x3fea08)),{'isValid':![],'message':_0x1af2c2(0x12d)};return{'isValid':!![],'message':_0x1af2c2(0x11e)};},module['exports']=Fax;
\ No newline at end of file
+'use strict';const a1245_0x4c0f=['info','isValid','\x20syncNewchannel\x20','checkAfterSend','exten','fax','syncOriginateResponse','application/pdf','1643165YClfRL','varset','variablesAction','378fPCkwd','isNil','parse','Fax\x20received','reachable','faxAccounts','@config/environment','send','actions','SENDING\x20FAILED:\x20','.pdf','value','unmonitored','pagestransferred','929TwFNcl','trunks','[Fax][checkTrunk][Empty\x20Fax]','files','383BuyJMH','XMF-PATH','variable','SENDING\x20FAILED','[Fax][Message][Error][NoUpdate1]','prototype','1820873atZRbh','468189qAjoRO','notify','error','Convert\x20pdf\x20to\x20tif','./action','addVariables','1184762LdyHTW','\x20Trunk\x20is\x20not\x20active','logger','../ami','updateStatus','\x20hangup\x20sendFile\x20','channel','Empty\x20Fax','Trunk','update','catch','attachments/','31TnbEOS','lodash','execOriginate','Is\x20Valid','channelstate','@config/logger','ext','exports','Trunk\x20Reachable','transferrate','response','\x20receiveFax\x20','channels','receivefax','uuid','tiff2pdf','bind','faxstatus','operation','Fax\x20failed','merge','SUCCESS','newchannel','status','root','145cQvCmW','syncNewchannel','calleridnum','hangup','active','newexten','finally','syncFaxStatus','stringify','path','syncNewState','newstate','util','filename','syncHangup','context','[Fax][Message][Updated]','message','undefined','AttachmentId','then','syncReceiveFax','gs\x20-q\x20-dNOPAUSE\x20-dBATCH\x20-sDEVICE=tiffg4\x20-sPAPERSIZE=letter\x20-sOutputFile=','SENDING\x20FAILED\x20','[Fax][Message][NoUpdate2]','[Fax][Message][Error][NoUpdate2]','[Fax][execOriginate][failure]','channelstatedesc','faxstatusstring','.tif','localstationid','Action','join','10202oNiCAA','attachments','../rpc/attachment','SIP/%s','resolution','%s/%s.tif','format','checkTrunk','uniqueid','[Fax][Message][Error][Updated]','\x20hangup\x20faxRiceive\x20','name','isTrunkReachable','execute'];const a1245_0x3c9b=function(_0x3a452c,_0x29b3aa){_0x3a452c=_0x3a452c-0xfb;let _0x4c0fb0=a1245_0x4c0f[_0x3a452c];return _0x4c0fb0;};const a1245_0x37d586=a1245_0x3c9b;(function(_0x5622ba,_0x5624fe){const _0x7f67af=a1245_0x3c9b;while(!![]){try{const _0x9b7ca5=parseInt(_0x7f67af(0x11b))*parseInt(_0x7f67af(0x11f))+-parseInt(_0x7f67af(0x10d))*parseInt(_0x7f67af(0x138))+parseInt(_0x7f67af(0x172))*parseInt(_0x7f67af(0x151))+parseInt(_0x7f67af(0x126))+-parseInt(_0x7f67af(0x125))+-parseInt(_0x7f67af(0x12c))+parseInt(_0x7f67af(0x10a));if(_0x9b7ca5===_0x5624fe)break;else _0x5622ba['push'](_0x5622ba['shift']());}catch(_0x3e553c){_0x5622ba['push'](_0x5622ba['shift']());}}}(a1245_0x4c0f,0xe2d4a));const util=require(a1245_0x37d586(0x15d)),_=require(a1245_0x37d586(0x139)),uuid=require(a1245_0x37d586(0x146)),path=require(a1245_0x37d586(0x15a)),tiff2pdf=require(a1245_0x37d586(0x147)),gs=require('./util/gs'),config=require(a1245_0x37d586(0x113)),logger=require(a1245_0x37d586(0x13d))(a1245_0x37d586(0x107)),ami=require(a1245_0x37d586(0x12f)),ut=require('./util/util'),Action=require(a1245_0x37d586(0x12a)),faxAccount=require('../rpc/faxAccount'),attachment=require(a1245_0x37d586(0x174)),faxMessage=require('../rpc/faxMessage'),attachmentsFolder=path[a1245_0x37d586(0x171)](config[a1245_0x37d586(0x150)],a1245_0x37d586(0x11e),a1245_0x37d586(0x137));function Fax(_0x17d25a){const _0x3fe249=a1245_0x37d586;this[_0x3fe249(0x144)]={},this[_0x3fe249(0x112)]=_0x17d25a[_0x3fe249(0x112)],this[_0x3fe249(0x11c)]=_0x17d25a[_0x3fe249(0x11c)],this['actions']={},ami['on'](_0x3fe249(0x14e),this[_0x3fe249(0x152)][_0x3fe249(0x148)](this)),ami['on'](_0x3fe249(0x10b),this['syncVarSet'][_0x3fe249(0x148)](this)),ami['on'](_0x3fe249(0x15c),this[_0x3fe249(0x15b)][_0x3fe249(0x148)](this)),ami['on'](_0x3fe249(0x156),this['syncNewExten'][_0x3fe249(0x148)](this)),ami['on'](_0x3fe249(0x149),this[_0x3fe249(0x158)][_0x3fe249(0x148)](this)),ami['on'](_0x3fe249(0x145),this[_0x3fe249(0x166)]['bind'](this)),ami['on'](_0x3fe249(0x154),this[_0x3fe249(0x15f)][_0x3fe249(0x148)](this)),ami['on']('originateresponse',this[_0x3fe249(0x108)][_0x3fe249(0x148)](this));}Fax[a1245_0x37d586(0x124)][a1245_0x37d586(0x152)]=function(_0x2ce21e){const _0x1fc012=a1245_0x37d586;if(_0x2ce21e[_0x1fc012(0x160)]==='from-voip-provider')for(const _0x158965 in this[_0x1fc012(0x112)]){typeof this[_0x1fc012(0x112)][_0x158965]!=='undefined'&&(_0x2ce21e[_0x1fc012(0x106)]===this[_0x1fc012(0x112)][_0x158965][_0x1fc012(0x16f)]&&(this[_0x1fc012(0x144)][_0x2ce21e['uniqueid']]={},this[_0x1fc012(0x144)][_0x2ce21e[_0x1fc012(0xfc)]]['channel']=_0x2ce21e['channel'],this[_0x1fc012(0x144)][_0x2ce21e[_0x1fc012(0xfc)]]['id']=this[_0x1fc012(0x112)][_0x158965]['id'],this[_0x1fc012(0x144)][_0x2ce21e[_0x1fc012(0xfc)]][_0x1fc012(0xff)]=this['faxAccounts'][_0x158965][_0x1fc012(0xff)],logger[_0x1fc012(0x102)](_0x2ce21e[_0x1fc012(0xfc)],_0x1fc012(0x104))));}this[_0x1fc012(0x115)][_0x2ce21e[_0x1fc012(0xfc)]]&&(this[_0x1fc012(0x144)][_0x2ce21e[_0x1fc012(0xfc)]]={},this['channels'][_0x2ce21e[_0x1fc012(0xfc)]][_0x1fc012(0x132)]=_0x2ce21e[_0x1fc012(0x132)],logger['info'](_0x2ce21e['uniqueid'],'\x20syncNewchannel\x20'));},Fax[a1245_0x37d586(0x124)]['syncVarSet']=function(_0x57171c){const _0xa22ccf=a1245_0x37d586;if(this[_0xa22ccf(0x144)][_0x57171c[_0xa22ccf(0xfc)]])for(const _0x5cc51f in _0x57171c[_0xa22ccf(0x121)]){typeof _0x57171c[_0xa22ccf(0x121)][_0x5cc51f]!==_0xa22ccf(0x163)&&(this[_0xa22ccf(0x144)][_0x57171c['uniqueid']][_0x5cc51f]=_0x57171c[_0xa22ccf(0x118)]);}},Fax[a1245_0x37d586(0x124)][a1245_0x37d586(0x15b)]=function(_0xf79836){const _0x4971eb=a1245_0x37d586;this[_0x4971eb(0x144)][_0xf79836['uniqueid']]&&(this[_0x4971eb(0x144)][_0xf79836[_0x4971eb(0xfc)]][_0x4971eb(0x13c)]=_0xf79836[_0x4971eb(0x13c)],this[_0x4971eb(0x144)][_0xf79836[_0x4971eb(0xfc)]]['channelstatedesc']=_0xf79836[_0x4971eb(0x16c)]);},Fax[a1245_0x37d586(0x124)]['syncNewExten']=function(_0x5d36cd){const _0x5d6980=a1245_0x37d586;if(this[_0x5d6980(0x144)][_0x5d36cd[_0x5d6980(0xfc)]])for(const _0x4a4797 in _0x5d36cd[_0x5d6980(0x121)]){typeof _0x5d36cd[_0x5d6980(0x121)][_0x4a4797]!==_0x5d6980(0x163)&&(this['channels'][_0x5d36cd[_0x5d6980(0xfc)]][_0x4a4797]=_0x5d36cd[_0x5d6980(0x118)]);}},Fax['prototype'][a1245_0x37d586(0x158)]=function(_0x2ee4d6){const _0x1ab259=a1245_0x37d586;this['channels'][_0x2ee4d6['uniqueid']]&&(this[_0x1ab259(0x144)][_0x2ee4d6[_0x1ab259(0xfc)]][_0x1ab259(0x14a)]=_0x2ee4d6[_0x1ab259(0x14a)],this['channels'][_0x2ee4d6[_0x1ab259(0xfc)]]['status']=_0x2ee4d6['status'],this[_0x1ab259(0x144)][_0x2ee4d6[_0x1ab259(0xfc)]]['localstationid']=_0x2ee4d6[_0x1ab259(0x16f)],this[_0x1ab259(0x144)][_0x2ee4d6[_0x1ab259(0xfc)]]['filename']=_0x2ee4d6[_0x1ab259(0x15e)],logger[_0x1ab259(0x102)](_0x2ee4d6[_0x1ab259(0xfc)],'\x20syncFaxStatus\x20'));},Fax[a1245_0x37d586(0x124)][a1245_0x37d586(0x166)]=function(_0x12604e){const _0x13e81a=a1245_0x37d586;if(this['channels'][_0x12604e[_0x13e81a(0xfc)]]){const _0x460348=this[_0x13e81a(0x144)][_0x12604e[_0x13e81a(0xfc)]]['id'];this['channels'][_0x12604e[_0x13e81a(0xfc)]]['remotestationid']=_0x12604e['remotestationid'],this['channels'][_0x12604e[_0x13e81a(0xfc)]][_0x13e81a(0x11a)]=_0x12604e['pagestransferred'],this[_0x13e81a(0x144)][_0x12604e[_0x13e81a(0xfc)]]['localstationid']=_0x12604e['localstationid'],this[_0x13e81a(0x144)][_0x12604e[_0x13e81a(0xfc)]][_0x13e81a(0x176)]=_0x12604e[_0x13e81a(0x176)],this[_0x13e81a(0x144)][_0x12604e[_0x13e81a(0xfc)]][_0x13e81a(0x141)]=_0x12604e[_0x13e81a(0x141)],this[_0x13e81a(0x144)][_0x12604e[_0x13e81a(0xfc)]][_0x13e81a(0x15e)]=_0x12604e[_0x13e81a(0x15e)],this[_0x13e81a(0x144)][_0x12604e[_0x13e81a(0xfc)]][_0x13e81a(0x153)]=_0x12604e[_0x13e81a(0x153)],this['channels'][_0x12604e[_0x13e81a(0xfc)]][_0x13e81a(0x11a)]>0x0&&tiff2pdf(_0x12604e[_0x13e81a(0x15e)],attachmentsFolder,function(_0x9034ab){const _0x596e17=_0x13e81a;logger[_0x596e17(0x102)](_0x12604e['uniqueid'],'\x20result\x20conversion\x20file\x20',_0x9034ab[_0x596e17(0x162)]),attachment['create']({'name':path['parse'](_0x12604e[_0x596e17(0x15e)])[_0x596e17(0xff)],'basename':path['parse'](_0x12604e[_0x596e17(0x15e)])[_0x596e17(0xff)]+_0x596e17(0x117),'type':_0x596e17(0x109)})[_0x596e17(0x165)](function(_0x3f3217){const _0x3cbd91=_0x596e17;faxAccount[_0x3cbd91(0x127)](_0x460348,{'from':_0x12604e[_0x3cbd91(0x153)],'mapKey':'fax','body':path[_0x3cbd91(0x10f)](_0x12604e[_0x3cbd91(0x15e)])['name']+_0x3cbd91(0x117),'AttachmentId':_0x3f3217['id']})['catch'](function(_0x9484c7){const _0x34d241=_0x3cbd91;logger[_0x34d241(0x128)](_0x12604e[_0x34d241(0xfc)],'\x20notify\x20',JSON[_0x34d241(0x159)](_0x9484c7));});})[_0x596e17(0x136)](function(_0x50e24f){const _0x5775b9=_0x596e17;logger[_0x5775b9(0x128)](_0x12604e[_0x5775b9(0xfc)],'\x20receiveFax\x20',JSON[_0x5775b9(0x159)](_0x50e24f));});}),logger['info'](_0x12604e[_0x13e81a(0xfc)],_0x13e81a(0x143));}},Fax['prototype'][a1245_0x37d586(0x108)]=function(_0x38eccf){const _0x5959bc=a1245_0x37d586;this[_0x5959bc(0x115)][_0x38eccf[_0x5959bc(0xfc)]]&&_[_0x5959bc(0x14c)](this[_0x5959bc(0x144)][_0x38eccf[_0x5959bc(0xfc)]],_['pick'](_0x38eccf,[_0x5959bc(0x142),'reason']));};function updateStatus(_0x1918b4){const _0x1c9688=a1245_0x37d586;_0x1918b4[_0x1c9688(0x164)]?faxMessage[_0x1c9688(0x135)](_0x1918b4[_0x1c9688(0x164)],{'failMessage':_0x1c9688(0x168)})[_0x1c9688(0x165)](function(_0x5b7278){const _0x13fa3f=_0x1c9688;ut[_0x13fa3f(0x12e)](_0x13fa3f(0xfd),_0x5b7278);})['catch'](function(_0x2af045){const _0x14f1f7=_0x1c9688;ut[_0x14f1f7(0x12e)](_0x14f1f7(0x123),_0x2af045);}):ut['logger'](_0x1c9688(0x16a));}Fax[a1245_0x37d586(0x124)][a1245_0x37d586(0x130)]=function(_0x2bd5e3,_0x2d24ab,_0x45f201){const _0x3f058d=a1245_0x37d586,_0x55df49=this;let _0x583628={};_0x2d24ab?_0x583628={'read':_0x2d24ab}:_0x583628={'failMessage':_0x45f201},this[_0x3f058d(0x115)][_0x2bd5e3][_0x3f058d(0x164)]?faxMessage['update'](this[_0x3f058d(0x115)][_0x2bd5e3]['AttachmentId'],_0x583628)[_0x3f058d(0x165)](function(_0x3b13c3){const _0x20dca0=_0x3f058d;ut[_0x20dca0(0x12e)](_0x20dca0(0x161),_0x3b13c3);})[_0x3f058d(0x136)](function(_0xbe5d31){const _0x5a939c=_0x3f058d;ut[_0x5a939c(0x12e)]('[Fax][Message][NoUpdate1]',_0xbe5d31);})[_0x3f058d(0x157)](function(){const _0x24a758=_0x3f058d;delete _0x55df49[_0x24a758(0x144)][_0x2bd5e3],delete _0x55df49[_0x24a758(0x115)][_0x2bd5e3];}):(ut[_0x3f058d(0x12e)](_0x3f058d(0x169)),delete this[_0x3f058d(0x144)][_0x2bd5e3],delete this[_0x3f058d(0x115)][_0x2bd5e3]);},Fax[a1245_0x37d586(0x124)][a1245_0x37d586(0x15f)]=function(_0x2cae3b){const _0x17484a=a1245_0x37d586;this[_0x17484a(0x144)][_0x2cae3b[_0x17484a(0xfc)]]&&(this[_0x17484a(0x115)][_0x2cae3b[_0x17484a(0xfc)]]&&(this[_0x17484a(0x144)][_0x2cae3b[_0x17484a(0xfc)]]['id']=this['actions'][_0x2cae3b[_0x17484a(0xfc)]]['id'],this[_0x17484a(0x144)][_0x2cae3b['uniqueid']][_0x17484a(0xff)]=this[_0x17484a(0x115)][_0x2cae3b[_0x17484a(0xfc)]][_0x17484a(0xff)]),logger['info'](_0x2cae3b[_0x17484a(0xfc)],this['actions'][_0x2cae3b['uniqueid']]?_0x17484a(0x131):_0x17484a(0xfe),JSON[_0x17484a(0x159)](this[_0x17484a(0x144)][_0x2cae3b[_0x17484a(0xfc)]])),this[_0x17484a(0x115)][_0x2cae3b[_0x17484a(0xfc)]]&&(this[_0x17484a(0x144)][_0x2cae3b[_0x17484a(0xfc)]]['faxpages']>0x0&&this[_0x17484a(0x144)][_0x2cae3b[_0x17484a(0xfc)]]['faxstatus']===_0x17484a(0x14d)?this[_0x17484a(0x130)](_0x2cae3b[_0x17484a(0xfc)],!![]):this[_0x17484a(0x130)](_0x2cae3b[_0x17484a(0xfc)],![],this[_0x17484a(0x144)][_0x2cae3b[_0x17484a(0xfc)]][_0x17484a(0x16d)]?_0x17484a(0x116)+this[_0x17484a(0x144)][_0x2cae3b['uniqueid']][_0x17484a(0x16d)]:_0x17484a(0x122))));},Fax[a1245_0x37d586(0x124)][a1245_0x37d586(0x114)]=function(_0x4b1f83){const _0x3c29d1=this;return new Promise(function(_0x43dd77,_0x17cd84){const _0x389aa8=a1245_0x3c9b;_0x3c29d1[_0x389aa8(0x13a)](_0x4b1f83,_0x3c29d1['faxAccounts'][_0x4b1f83['FaxAccountId']])[_0x389aa8(0x165)](function(_0x28565c){const _0x170db0=_0x389aa8;ut[_0x170db0(0x12e)]('[Fax][execOriginate][success]',_0x28565c),_0x43dd77(ut[_0x170db0(0x162)](_0x170db0(0x110)));})['catch'](function(_0x49d375){const _0x29dff9=_0x389aa8;ut[_0x29dff9(0x12e)](_0x29dff9(0x16b),_0x49d375),updateStatus(_0x4b1f83),_0x17cd84(ut[_0x29dff9(0x162)](_0x29dff9(0x14b)));});});},Fax['prototype'][a1245_0x37d586(0x105)]=function(_0x25aa98){const _0x5a266f=this;return new Promise(function(_0x3e1195,_0x300c30){const _0xeedfeb=a1245_0x3c9b,_0x1fefe4=_0x5a266f['checkTrunk'](_0x5a266f['faxAccounts'][_0x25aa98['FaxAccountId']][_0xeedfeb(0x134)],_0x25aa98);_0x1fefe4[_0xeedfeb(0x103)]?_0x3e1195(ut[_0xeedfeb(0x162)](_0xeedfeb(0x140))):_0x300c30(ut[_0xeedfeb(0x162)](_0x1fefe4['message']));});};function originate(_0x5e08cd,_0x43adaf,_0x4d2ee8){return new Promise(function(_0x2b8d52,_0x537f7c){const _0x549e61=a1245_0x3c9b;if(_0x4d2ee8){const _0x121e05=path[_0x549e61(0x171)](config[_0x549e61(0x150)],'files',_0x549e61(0x173),path[_0x549e61(0x10f)](_0x5e08cd[_0x549e61(0x15a)])['name']+_0x549e61(0x16e)),_0xdd587d=_0x549e61(0x167)+_0x121e05+'\x20\x20'+_0x5e08cd['path']+'\x20-c\x20quit';gs[_0x549e61(0x101)](_0xdd587d)['then'](function(){const _0x222321=_0x549e61;_0x5e08cd[_0x222321(0x15a)]=util[_0x222321(0x178)](_0x222321(0x177),path['parse'](_0x5e08cd[_0x222321(0x15a)])['dir'],path[_0x222321(0x10f)](_0x5e08cd['path'])[_0x222321(0xff)]),_0x43adaf[_0x222321(0x120)]=_0x5e08cd['path'],ut['logger'](_0x222321(0x129),''),ami['Action'](ut['variablesAction'](_0x5e08cd,_0x43adaf))[_0x222321(0x165)](function(_0x5abe50){_0x2b8d52(_0x5abe50);})[_0x222321(0x136)](function(_0x2758a4){_0x537f7c(_0x2758a4);});})[_0x549e61(0x136)](function(_0x1fa950){_0x537f7c(_0x1fa950);});}else ami[_0x549e61(0x170)](ut[_0x549e61(0x10c)](_0x5e08cd,_0x43adaf))[_0x549e61(0x165)](function(_0xd6b673){_0x2b8d52(_0xd6b673);})['catch'](function(_0x493750){_0x537f7c(_0x493750);});});}Fax[a1245_0x37d586(0x124)][a1245_0x37d586(0x13a)]=function(_0x2d098b,_0x3be2ba){const _0x56ebcb=this;return new Promise(function(_0x5aae84,_0x485d40){const _0x52d79d=a1245_0x3c9b,_0x1c84b5=uuid['v4'](),_0x5c113d=ut[_0x52d79d(0x12b)](_0x2d098b,_0x3be2ba);_0x56ebcb['actions'][_0x1c84b5]=new Action(_0x1c84b5,_0x3be2ba,_0x2d098b);const _0x57c6b2=_0x56ebcb[_0x52d79d(0x115)][_0x1c84b5];path[_0x52d79d(0x10f)](_0x2d098b[_0x52d79d(0x15a)])[_0x52d79d(0x13e)]===_0x52d79d(0x117)?originate(_0x57c6b2,_0x5c113d,!![])['then'](function(_0x1e23a6){_0x5aae84(_0x1e23a6);})[_0x52d79d(0x136)](function(_0x215aad){_0x485d40(_0x215aad);}):originate(_0x57c6b2,_0x5c113d,![])[_0x52d79d(0x165)](function(_0x2bec27){_0x5aae84(_0x2bec27);})[_0x52d79d(0x136)](function(_0x3fb8b8){_0x485d40(_0x3fb8b8);});});},Fax['prototype'][a1245_0x37d586(0x100)]=function(_0x2baf35){const _0x5835e7=a1245_0x37d586;return!_[_0x5835e7(0x10e)](_0x2baf35)&&!_[_0x5835e7(0x10e)](_0x2baf35['name'])&&!_[_0x5835e7(0x10e)](_0x2baf35[_0x5835e7(0x155)])&&_0x2baf35[_0x5835e7(0x155)]&&!_[_0x5835e7(0x10e)](this[_0x5835e7(0x11c)][util[_0x5835e7(0x178)](_0x5835e7(0x175),_0x2baf35[_0x5835e7(0xff)])])&&!_['isNil'](this[_0x5835e7(0x11c)][util['format'](_0x5835e7(0x175),_0x2baf35[_0x5835e7(0xff)])][_0x5835e7(0x14f)])&&(this['trunks'][util[_0x5835e7(0x178)]('SIP/%s',_0x2baf35[_0x5835e7(0xff)])][_0x5835e7(0x14f)]===_0x5835e7(0x111)||this[_0x5835e7(0x11c)][util[_0x5835e7(0x178)](_0x5835e7(0x175),_0x2baf35[_0x5835e7(0xff)])][_0x5835e7(0x14f)]===_0x5835e7(0x119));},Fax[a1245_0x37d586(0x124)][a1245_0x37d586(0xfb)]=function(_0x3772d9,_0x168476){const _0xf780eb=a1245_0x37d586;if(!this[_0xf780eb(0x100)](_0x3772d9))return ut[_0xf780eb(0x12e)]('[Fax][checkTrunk][Trunk\x20not\x20work]',_['isNil'](_0x3772d9)?'':_0x3772d9[_0xf780eb(0xff)]+_0xf780eb(0x12d)),{'isValid':![],'message':'Trunk\x20not\x20working'};if(_[_0xf780eb(0x10e)](_0x168476['fax']))return ut['logger'](_0xf780eb(0x11d),JSON[_0xf780eb(0x159)](_0x168476)),{'isValid':![],'message':_0xf780eb(0x133)};if(_[_0xf780eb(0x10e)](_0x168476[_0xf780eb(0x15a)]))return ut[_0xf780eb(0x12e)]('[Fax][checkTrunk][Empty\x20path]',JSON[_0xf780eb(0x159)](_0x168476)),{'isValid':![],'message':'Empty\x20path'};return{'isValid':!![],'message':_0xf780eb(0x13b)};},module[a1245_0x37d586(0x13f)]=Fax;
\ No newline at end of file