272f01b23fe06a50f519b9ca344f5325343bfba8
[motion-next.git] / server / services / ami / report / index.js
1 const a1092_0x51cd=['match','custom:voiceAgentReport','attendedTransfer','../ami','isArray','context','../rpc/voiceRecording','SIP/%s','exports','callerid','realtime','findAgent','interface','../rpc/memberReport','calleridnum','lastdata','xcally-motion-preview','substring','queue','blindTransfer','channel','ANSWERED','moment','lastapplication','prototype','voiceCallReport','calleridname','createdAt','isNil','voiceQueueReport','indexOf','queuecallercompleteAt','destination','create','connectedlinename','calleridpreview','sync','Local','lodash','xcally-motion-dialer','from-voip-provider','format','connectedlinenum','name','../rpc/voiceDialReport','custom:voiceDialReport','telephones','accountcode','\x22%s\x22\x20<%s>','../rpc/voiceTransferReport','../../../config/environment','bind','type','disposition','monitors','length','YYYY-MM-DD\x20HH:mm:ss','util','disabled','from-sip','voiceDialReport','dialer','voiceAgentReport','../rpc/voiceAgentReport','agents','exten','find','originatecalleridnum','membername','destinationchannel'];(function(_0x362d4f,_0x51cd0a){const _0x212231=function(_0x4e061d){while(--_0x4e061d){_0x362d4f['push'](_0x362d4f['shift']());}};_0x212231(++_0x51cd0a);}(a1092_0x51cd,0x1cd));const a1092_0x2122=function(_0x362d4f,_0x51cd0a){_0x362d4f=_0x362d4f-0x0;let _0x212231=a1092_0x51cd[_0x362d4f];return _0x212231;};const _0x506eb3=a1092_0x2122;'use strict';const _=require(_0x506eb3('0x43')),moment=require(_0x506eb3('0x33')),util=require(_0x506eb3('0x10')),config=require(_0x506eb3('0x9')),ami=require(_0x506eb3('0x20')),RpcVoiceAgentReport=require(_0x506eb3('0x16')),RpcVoiceCallReport=require('../rpc/voiceCallReport'),RpcVoiceDialReport=require(_0x506eb3('0x3')),RpcMemberReport=require(_0x506eb3('0x2a')),RpcVoiceQueueReport=require('../rpc/voiceQueueReport'),RpcVoiceRecording=require(_0x506eb3('0x23')),RpcVoiceTransferReport=require(_0x506eb3('0x8'));function Report(_0x4e061d){const _0x1d8284=_0x506eb3;this[_0x1d8284('0x27')]=_0x4e061d,this[_0x1d8284('0x17')]=_0x4e061d[_0x1d8284('0x17')],this[_0x1d8284('0x5')]=_0x4e061d[_0x1d8284('0x5')];}Report[_0x506eb3('0x35')][_0x506eb3('0x41')]=function(){const _0x9496c7=_0x506eb3;config['xdr']&&config['xdr'][_0x9496c7('0x11')]&&(ami['on']('custom:voiceQueueReport',this['voiceQueueReport'][_0x9496c7('0xa')](this)),ami['on']('custom:voiceCallReport',this[_0x9496c7('0x36')][_0x9496c7('0xa')](this)),ami['on'](_0x9496c7('0x1e'),this[_0x9496c7('0x15')]['bind'](this)),ami['on'](_0x9496c7('0x4'),this['voiceDialReport'][_0x9496c7('0xa')](this)),ami['on']('blindtransfer',this['blindTransfer'][_0x9496c7('0xa')](this)),ami['on']('attendedtransfer',this['attendedTransfer'][_0x9496c7('0xa')](this)));},Report['prototype'][_0x506eb3('0x28')]=function(_0x5a8fbd){const _0xa40f4d=_0x506eb3;let _0x2ff598=undefined;_0x2ff598=_[_0xa40f4d('0x19')](this[_0xa40f4d('0x17')],function(_0x329087){const _0x26e588=_0xa40f4d;return _0x329087[_0x26e588('0x6')]==_0x5a8fbd||_0x329087['name']==_0x5a8fbd;});if(_[_0xa40f4d('0x39')](_0x2ff598)){const _0x318cdf=_[_0xa40f4d('0x19')](this[_0xa40f4d('0x5')],function(_0x5d3b3b){const _0x5d5b00=_0xa40f4d;return _0x5d3b3b[_0x5d5b00('0x6')]==_0x5a8fbd||_0x5d3b3b[_0x5d5b00('0x2')]==_0x5a8fbd;});_0x318cdf&&(_0x2ff598=_[_0xa40f4d('0x19')](this[_0xa40f4d('0x17')],function(_0x255ceb){const _0x1bd6f0=_0xa40f4d;return _0x255ceb['interface']==util[_0x1bd6f0('0x0')]('SIP/%s',_0x318cdf[_0x1bd6f0('0x2')]);}));}return _0x2ff598;},Report[_0x506eb3('0x35')][_0x506eb3('0x3a')]=function(_0x5c4b9a){const _0x2aa9c2=_0x506eb3;for(let _0x96d2b1=0x0;_0x96d2b1<_0x5c4b9a[_0x2aa9c2('0xe')];_0x96d2b1+=0x1){const _0x287dc2=this[_0x2aa9c2('0x28')](_0x5c4b9a[_0x96d2b1]['connectedlinenum']);_0x287dc2&&(_0x5c4b9a[_0x96d2b1]['accountcode']=_0x287dc2[_0x2aa9c2('0x6')],_0x5c4b9a[_0x96d2b1]['assigned']=!![],_0x5c4b9a[_0x96d2b1]['lastAssignedTo']=_0x287dc2[_0x2aa9c2('0x2')],_0x5c4b9a[_0x96d2b1][_0x2aa9c2('0x29')]=_[_0x2aa9c2('0x39')](_0x287dc2['interface'])?util[_0x2aa9c2('0x0')](_0x2aa9c2('0x24'),_0x287dc2[_0x2aa9c2('0x2')]):_0x287dc2[_0x2aa9c2('0x29')],_0x5c4b9a[_0x96d2b1]['queuecallercomplete']&&(_0x5c4b9a[_0x96d2b1][_0x2aa9c2('0x3c')]=moment()[_0x2aa9c2('0x0')](_0x2aa9c2('0xf'))),_0x5c4b9a[_0x96d2b1]['queuecallerexit']&&(_0x5c4b9a[_0x96d2b1]['queuecallerexitAt']=moment()[_0x2aa9c2('0x0')]('YYYY-MM-DD\x20HH:mm:ss')),RpcMemberReport['voiceQueueReport'](_0x5c4b9a[_0x96d2b1])),RpcVoiceQueueReport['create'](_0x5c4b9a[_0x96d2b1]);}};function extractCalleridNumber(_0x27f6af){const _0x1b3f6c=_0x506eb3,_0x2c5c4b=_0x27f6af[_0x1b3f6c('0x1d')](/<(.*?)>/);return _0x2c5c4b?_0x2c5c4b[0x1]:_0x27f6af;}Report[_0x506eb3('0x35')][_0x506eb3('0x36')]=function(_0x88ebaa){const _0x4f7f58=_0x506eb3;_0x88ebaa['destination']=_0x88ebaa[_0x4f7f58('0x3d')]||_0x88ebaa[_0x4f7f58('0x18')];if(_0x88ebaa[_0x4f7f58('0xb')]==_0x4f7f58('0x14')){_0x88ebaa[_0x4f7f58('0x34')]=_0x4f7f58('0x2f'),_0x88ebaa[_0x4f7f58('0x2c')]=_0x88ebaa[_0x4f7f58('0x2f')];if(_0x88ebaa[_0x4f7f58('0x22')]==_0x4f7f58('0x45'))_0x88ebaa[_0x4f7f58('0x6')]='',_0x88ebaa[_0x4f7f58('0x3d')]=extractCalleridNumber(_0x88ebaa[_0x4f7f58('0x26')]);else _0x88ebaa[_0x4f7f58('0x22')]==_0x4f7f58('0x12')&&(_0x88ebaa[_0x4f7f58('0x3d')]==_0x4f7f58('0x2d')?(_0x88ebaa[_0x4f7f58('0x3d')]=extractCalleridNumber(_0x88ebaa['calleridpreview']),_0x88ebaa[_0x4f7f58('0x2b')]=_0x88ebaa[_0x4f7f58('0x1a')],_0x88ebaa[_0x4f7f58('0x1c')]=[_0x88ebaa['channel'],_0x88ebaa['channel']=_0x88ebaa[_0x4f7f58('0x1c')]][0x0],_0x88ebaa[_0x4f7f58('0x26')]=_0x88ebaa[_0x4f7f58('0x40')]):(_0x88ebaa[_0x4f7f58('0x3d')]=_0x88ebaa[_0x4f7f58('0x2b')],_0x88ebaa[_0x4f7f58('0x2b')]=_0x88ebaa[_0x4f7f58('0x1a')],_0x88ebaa[_0x4f7f58('0xc')]==_0x4f7f58('0x32')?_0x88ebaa[_0x4f7f58('0x6')]=_0x88ebaa[_0x4f7f58('0x1')]:_0x88ebaa[_0x4f7f58('0x6')]=''));}else _0x88ebaa[_0x4f7f58('0x26')]=util[_0x4f7f58('0x0')](_0x4f7f58('0x7'),_0x88ebaa[_0x4f7f58('0x37')],_0x88ebaa['calleridnum']);RpcVoiceCallReport[_0x4f7f58('0x3e')](_0x88ebaa);if(_0x88ebaa['monitor'])for(let _0x4347fa=0x0;_0x4347fa<_0x88ebaa[_0x4f7f58('0xd')][_0x4f7f58('0xe')];_0x4347fa+=0x1){_0x88ebaa['monitorFilename']=_0x88ebaa['monitors'][_0x4347fa]['filename'],_0x88ebaa[_0x4f7f58('0x38')]=_0x88ebaa['monitors'][_0x4347fa][_0x4f7f58('0x38')];if(_0x88ebaa[_0x4f7f58('0x18')]==_0x4f7f58('0x2d'))_0x88ebaa[_0x4f7f58('0x2b')]=_0x88ebaa['connectedlinenum'],_0x88ebaa['calleridname']=_0x88ebaa[_0x4f7f58('0x3f')],_0x88ebaa['connectedlinenum']=_0x88ebaa['accountcode'],_0x88ebaa[_0x4f7f58('0x3f')]=_0x88ebaa[_0x4f7f58('0x1b')],_0x88ebaa[_0x4f7f58('0x18')]=_0x88ebaa[_0x4f7f58('0x1a')];else _0x88ebaa[_0x4f7f58('0x18')]==_0x4f7f58('0x44')&&(_0x88ebaa[_0x4f7f58('0x2b')]=_0x88ebaa[_0x4f7f58('0x3d')],_0x88ebaa[_0x4f7f58('0x18')]=_0x88ebaa['originatecalleridnum']);RpcVoiceRecording[_0x4f7f58('0x3e')](_0x88ebaa);}},Report[_0x506eb3('0x35')][_0x506eb3('0x15')]=function(_0x322096){const _0x27620e=_0x506eb3;_[_0x27620e('0x21')](_0x322096)?_0x322096['forEach'](function(_0xb2a8d0){RpcVoiceAgentReport['create'](_0xb2a8d0);}):RpcVoiceAgentReport['create'](_0x322096);},Report[_0x506eb3('0x35')][_0x506eb3('0x13')]=function(_0x3cb2f6){const _0xf86919=_0x506eb3;RpcVoiceDialReport[_0xf86919('0x3e')](_0x3cb2f6);let _0x433863=undefined;const _0xa09464=_0x3cb2f6[_0xf86919('0x31')];if(_['startsWith'](_0xa09464,_0xf86919('0x42'))){const _0x5e2313=_0xa09464[_0xf86919('0x2e')](_0xa09464['indexOf']('/')+0x1,_0xa09464['indexOf']('@'));_0x433863=_[_0xf86919('0x19')](this[_0xf86919('0x17')],function(_0xaa305b){const _0x50897e=_0xf86919;return _0xaa305b['mobile']==_0x5e2313||_0xaa305b['phone']==_0x5e2313||_0xaa305b[_0x50897e('0x6')]==_0x5e2313;});}else{const _0x3823b4=_0xa09464[_0xf86919('0x2e')](_0xa09464[_0xf86919('0x3b')]('/')+0x1,_0xa09464['lastIndexOf']('-'));_0x433863=this[_0xf86919('0x28')](_0x3823b4);}_0x433863&&(_0x3cb2f6['interface']=_[_0xf86919('0x39')](_0x433863[_0xf86919('0x29')])?util[_0xf86919('0x0')](_0xf86919('0x24'),_0x433863[_0xf86919('0x2')]):_0x433863[_0xf86919('0x29')],_0x3cb2f6[_0xf86919('0x1b')]=_0x433863[_0xf86919('0x2')],_0x3cb2f6[_0xf86919('0x6')]=_0x433863['accountcode'],RpcMemberReport[_0xf86919('0x13')](_0x3cb2f6));},Report[_0x506eb3('0x35')][_0x506eb3('0x30')]=function(_0x50db0c){RpcVoiceTransferReport['blindTransfer'](_0x50db0c);},Report[_0x506eb3('0x35')][_0x506eb3('0x1f')]=function(_0x3c3c9d){const _0x4318a3=_0x506eb3;RpcVoiceTransferReport[_0x4318a3('0x1f')](_0x3c3c9d);},module[_0x506eb3('0x25')]=Report;