Built motion from commit aab208717af8d15f4fa224cdb6a202877019af9b. Version 3.0.0...
[motion-next.git] / server / services / ami / report / voiceDialReport.js
1 const a1097_0x418a=['dialbegin','rtpaudioqos','connectedlinename','connect','starttime','[syncDialBegin][VoiceDialReport]','util','rtpaudioqosjitterbridged','channels','includes','lastevent','[syncVarSet][VoiceDialReport]','diff','syncDialBegin','answered','dialstatus','hangup','answertime','rtpaudioqosrtt','memberrealtime','emit','lastIndexOf','syncHangup','bridgepvtcallid','connectedlinenum','value','endtime','merge','ANSWER','exports','rtpaudioqosloss','../../../rediscache','syncDialEnd','memberdynamic','total','voice:outbound','holdtime','voice_outbound_channel:save','linkedid','channel','varset','bind','ami','format','duration','YYYY-MM-DD\x20HH:mm:ss','error','sumHoldTime','privilege','rtpaudioqosbridged','info','isUndefined','addVariable','custom:voiceDialReport','seconds','custom:dialend','uniqueid','sumDuration','dialend','isNotNull','event','outboundrouteid','lodash','keys','[syncDialEnd][VoiceDialReport]','[syncHangup][VoiceDialReport]','memberpenalty','prototype','moment','billableseconds','inspect','membercalls','variable','sipuri','custom:dialconnect','called','custom:dialbegin','syncVarSet','memberlastcall','variables','outbound'];(function(_0xe4941c,_0x418a95){const _0x2e2ebf=function(_0x17c891){while(--_0x17c891){_0xe4941c['push'](_0xe4941c['shift']());}};_0x2e2ebf(++_0x418a95);}(a1097_0x418a,0x168));const a1097_0x2e2e=function(_0xe4941c,_0x418a95){_0xe4941c=_0xe4941c-0x0;let _0x2e2ebf=a1097_0x418a[_0xe4941c];return _0x2e2ebf;};const _0x1c2a4f=a1097_0x2e2e;'use strict';const _=require(_0x1c2a4f('0x1a')),moment=require(_0x1c2a4f('0x20')),util=require(_0x1c2a4f('0x33')),logger=require('../../../config/logger')(_0x1c2a4f('0x6')),ami=require('../ami'),{getSocket}=require(_0x1c2a4f('0x4c')),io=getSocket();function VoiceDialReport(_0x17c891){const _0x3b70f1=_0x1c2a4f;this[_0x3b70f1('0x35')]=_0x17c891['outboundChannels'],this[_0x3b70f1('0x2c')]=_0x17c891[_0x3b70f1('0x2c')],this[_0x3b70f1('0x2b')]={},ami['on'](_0x3b70f1('0x2d'),this[_0x3b70f1('0x3a')][_0x3b70f1('0x5')](this)),ami['on'](_0x3b70f1('0x16'),this[_0x3b70f1('0x4d')][_0x3b70f1('0x5')](this)),ami['on'](_0x3b70f1('0x4'),this[_0x3b70f1('0x29')][_0x3b70f1('0x5')](this)),ami['on'](_0x3b70f1('0x3d'),this[_0x3b70f1('0x43')]['bind'](this));}VoiceDialReport[_0x1c2a4f('0x1f')][_0x1c2a4f('0x17')]=function(_0x431a37){return _0x431a37!==null&&!_['isUndefined'](_0x431a37);},VoiceDialReport[_0x1c2a4f('0x1f')][_0x1c2a4f('0x41')]=function(_0x21e783,_0x46ed5a,_0x348601){io['to'](_0x21e783)['emit'](_0x46ed5a,_0x348601);},VoiceDialReport[_0x1c2a4f('0x1f')][_0x1c2a4f('0x3a')]=function(_0x2ed19e){const _0x2e6259=_0x1c2a4f;try{this['isNotNull'](_0x2ed19e)&&(this[_0x2e6259('0x35')][_0x2ed19e['uniqueid']]&&(_[_0x2e6259('0x48')](this[_0x2e6259('0x35')][_0x2ed19e['uniqueid']],{'starttime':moment()[_0x2e6259('0x7')]('YYYY-MM-DD\x20HH:mm:ss'),'lastevent':_0x2e6259('0x27'),'interface':_0x2ed19e[_0x2e6259('0x3')]['substring'](0x0,_0x2ed19e[_0x2e6259('0x3')]['lastIndexOf']('-')),'membername':_0x2ed19e[_0x2e6259('0x3')]['substring'](_0x2ed19e[_0x2e6259('0x3')][_0x2e6259('0x42')]('/')+0x1,_0x2ed19e[_0x2e6259('0x3')]['lastIndexOf']('-'))},_['omit'](_0x2ed19e,[_0x2e6259('0x18'),_0x2e6259('0xc')])),this[_0x2e6259('0x41')]('voice:outbound',_0x2e6259('0x1'),this['channels'][_0x2ed19e['uniqueid']]),ami['emit'](_0x2e6259('0x28'),this[_0x2e6259('0x35')][_0x2ed19e['uniqueid']])));}catch(_0x2bafee){logger[_0x2e6259('0xa')](_0x2e6259('0x32'),util[_0x2e6259('0x22')](_0x2bafee,{'showHidden':![],'depth':null}));}},VoiceDialReport['prototype']['syncDialEnd']=function(_0x58da26){const _0x274737=_0x1c2a4f;try{this['isNotNull'](_0x58da26)&&(this[_0x274737('0x35')][_0x58da26['uniqueid']]&&(this[_0x274737('0x35')][_0x58da26['uniqueid']][_0x274737('0x3c')]=_0x58da26[_0x274737('0x3c')],_0x58da26[_0x274737('0x3c')]===_0x274737('0x49')&&(this[_0x274737('0x35')][_0x58da26[_0x274737('0x14')]]['connectedlinenum']=_0x58da26[_0x274737('0x45')],this[_0x274737('0x35')][_0x58da26['uniqueid']][_0x274737('0x2f')]=_0x58da26[_0x274737('0x2f')],this['channels'][_0x58da26[_0x274737('0x14')]][_0x274737('0x3e')]=moment()['format'](_0x274737('0x9')),this['channels'][_0x58da26[_0x274737('0x14')]][_0x274737('0x37')]=_0x274737('0x30'),ami[_0x274737('0x41')](_0x274737('0x26'),this[_0x274737('0x35')][_0x58da26[_0x274737('0x14')]])),this['emit']('voice:outbound',_0x274737('0x1'),this[_0x274737('0x35')][_0x58da26[_0x274737('0x14')]])));}catch(_0x4c912c){logger[_0x274737('0xa')](_0x274737('0x1c'),util[_0x274737('0x22')](_0x4c912c,{'showHidden':![],'depth':null}));}},VoiceDialReport[_0x1c2a4f('0x1f')][_0x1c2a4f('0x29')]=function(_0xc2e94b){const _0x56d750=_0x1c2a4f;try{this[_0x56d750('0x17')](_0xc2e94b)&&(this[_0x56d750('0x10')](_0xc2e94b['uniqueid'],_[_0x56d750('0x1b')](_0xc2e94b[_0x56d750('0x24')])[0x0],_0xc2e94b['value']),this['isNotNull'](_0xc2e94b[_0x56d750('0x24')])&&this[_0x56d750('0x17')](_0xc2e94b[_0x56d750('0x24')][_0x56d750('0x19')])&&(_[_0x56d750('0xf')](this[_0x56d750('0x35')][_0xc2e94b['uniqueid']])&&(this[_0x56d750('0x35')][_0xc2e94b['uniqueid']]={'routeId':_0xc2e94b[_0x56d750('0x46')],'variables':this[_0x56d750('0x2b')][_0xc2e94b[_0x56d750('0x14')]]},this[_0x56d750('0x41')]('voice:outbound',_0x56d750('0x1'),this['channels'][_0xc2e94b[_0x56d750('0x14')]]))));}catch(_0x5da6ee){logger[_0x56d750('0xa')](_0x56d750('0x38'),util[_0x56d750('0x22')](_0x5da6ee,{'showHidden':![],'depth':null}));}},VoiceDialReport[_0x1c2a4f('0x1f')][_0x1c2a4f('0x10')]=function(_0x988f15,_0x309d72,_0x2d8ed3){const _0x20cba0=_0x1c2a4f,_0x49a603=[_0x20cba0('0x2e'),_0x20cba0('0xd'),'rtpaudioqosjitter',_0x20cba0('0x34'),_0x20cba0('0x4b'),'rtpaudioqoslossbridged',_0x20cba0('0x3f'),'rtpaudioqosrttbridged','sipcallid',_0x20cba0('0x25'),'bridgepeer',_0x20cba0('0x44'),_0x20cba0('0x23'),_0x20cba0('0x4e'),'memberinterface',_0x20cba0('0x2a'),'membername',_0x20cba0('0x1e'),_0x20cba0('0x40')];!_['isNil'](_0x309d72)&&!_[_0x20cba0('0x36')](_0x49a603,_0x309d72)&&(_[_0x20cba0('0xf')](this[_0x20cba0('0x2b')][_0x988f15])&&(this[_0x20cba0('0x2b')][_0x988f15]={}),this[_0x20cba0('0x2b')][_0x988f15][_0x309d72]=_0x2d8ed3);},VoiceDialReport[_0x1c2a4f('0x1f')][_0x1c2a4f('0x43')]=function(_0xd32eb6){const _0x5f4f42=_0x1c2a4f;try{if(this[_0x5f4f42('0x17')](_0xd32eb6)){if(this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]])this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]]['endtime']=moment()[_0x5f4f42('0x7')]('YYYY-MM-DD\x20HH:mm:ss'),this['channels'][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x8')]=moment(this['channels'][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x47')])[_0x5f4f42('0x39')](this[_0x5f4f42('0x35')][_0xd32eb6['uniqueid']][_0x5f4f42('0x31')],_0x5f4f42('0x12')),this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x37')]='complete',this['outbound'][_0x5f4f42('0x4f')]+=0x1,this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x3e')]&&(this['outbound'][_0x5f4f42('0x3b')]+=0x1,this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x0')]=moment(this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x3e')])[_0x5f4f42('0x39')](this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x31')],_0x5f4f42('0x12')),this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x21')]=moment(this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x47')])[_0x5f4f42('0x39')](this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]]['answertime'],_0x5f4f42('0x12')),this[_0x5f4f42('0x2c')][_0x5f4f42('0xb')]+=this[_0x5f4f42('0x35')][_0xd32eb6['uniqueid']][_0x5f4f42('0x0')]||0x0,this['outbound']['sumBillable']+=this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]][_0x5f4f42('0x21')]),this['outbound'][_0x5f4f42('0x15')]+=this[_0x5f4f42('0x35')][_0xd32eb6['uniqueid']][_0x5f4f42('0x8')],ami['emit'](_0x5f4f42('0x11'),this['channels'][_0xd32eb6[_0x5f4f42('0x14')]]),ami[_0x5f4f42('0x41')](_0x5f4f42('0x13'),this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]]),this[_0x5f4f42('0x41')](_0x5f4f42('0x50'),'voice_outbound:save',this['outbound']),logger[_0x5f4f42('0xe')]('[DEBUG]\x20Emit\x20voice_outbound_channel:remove\x20event',JSON['stringify'](this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]])),this[_0x5f4f42('0x41')]('voice:outbound','voice_outbound_channel:remove',this['channels'][_0xd32eb6[_0x5f4f42('0x14')]]),delete this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x14')]];else this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x2')]]&&(this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x2')]][_0x5f4f42('0x14')]=this[_0x5f4f42('0x35')][_0xd32eb6[_0x5f4f42('0x2')]]['destuniqueid']);this['variables'][_0xd32eb6['uniqueid']]&&delete this[_0x5f4f42('0x2b')][_0xd32eb6[_0x5f4f42('0x14')]];}}catch(_0x393fde){logger['error'](_0x5f4f42('0x1d'),util['inspect'](_0x393fde,{'showHidden':![],'depth':null}));}},module[_0x1c2a4f('0x4a')]=VoiceDialReport;