Built motion from commit 82a371561bcdbc7605c801e5e414f4032ba9e7ad. Version 3.0.0...
[motion-next.git] / server / services / ami / report / index.js
1 const a1092_0x4d83=['calleridpreview','from-sip','xdr','callerid','voiceQueueReport','lastapplication','../rpc/voiceTransferReport','substring','\x22%s\x22\x20<%s>','disabled','exten','startsWith','xcally-motion-preview','membername','moment','filename','attendedTransfer','voiceDialReport','isNil','queue','disposition','format','voiceCallReport','../rpc/memberReport','find','create','custom:voiceAgentReport','calleridname','blindTransfer','custom:voiceDialReport','custom:voiceQueueReport','type','custom:voiceCallReport','channel','exports','accountcode','mobile','monitors','monitorFilename','YYYY-MM-DD\x20HH:mm:ss','SIP/%s','name','findAgent','voiceAgentReport','interface','match','calleridnum','createdAt','queuecallercompleteAt','bind','../rpc/voiceQueueReport','indexOf','xcally-motion-dialer','../ami','telephones','from-voip-provider','../rpc/voiceAgentReport','prototype','queuecallercomplete','sync','../rpc/voiceCallReport','destination','connectedlinenum','isArray','destinationchannel','context','../rpc/voiceRecording','util','originatecalleridnum','Local','attendedtransfer','agents'];(function(_0x44b39e,_0x4d8328){const _0x18c4fd=function(_0x1214d5){while(--_0x1214d5){_0x44b39e['push'](_0x44b39e['shift']());}};_0x18c4fd(++_0x4d8328);}(a1092_0x4d83,0x1dd));const a1092_0x18c4=function(_0x44b39e,_0x4d8328){_0x44b39e=_0x44b39e-0x0;let _0x18c4fd=a1092_0x4d83[_0x44b39e];return _0x18c4fd;};const _0x5a448e=a1092_0x18c4;'use strict';const _=require('lodash'),moment=require(_0x5a448e('0x29')),util=require(_0x5a448e('0x16')),config=require('../../../config/environment'),ami=require(_0x5a448e('0x8')),RpcVoiceAgentReport=require(_0x5a448e('0xb')),RpcVoiceCallReport=require(_0x5a448e('0xf')),RpcVoiceDialReport=require('../rpc/voiceDialReport'),RpcMemberReport=require(_0x5a448e('0x32')),RpcVoiceQueueReport=require(_0x5a448e('0x5')),RpcVoiceRecording=require(_0x5a448e('0x15')),RpcVoiceTransferReport=require(_0x5a448e('0x21'));function Report(_0x1214d5){const _0x54bbbb=_0x5a448e;this['realtime']=_0x1214d5,this[_0x54bbbb('0x1a')]=_0x1214d5[_0x54bbbb('0x1a')],this[_0x54bbbb('0x9')]=_0x1214d5[_0x54bbbb('0x9')];}Report['prototype'][_0x5a448e('0xe')]=function(){const _0x404984=_0x5a448e;config[_0x404984('0x1d')]&&config['xdr'][_0x404984('0x24')]&&(ami['on'](_0x404984('0x39'),this[_0x404984('0x1f')][_0x404984('0x4')](this)),ami['on'](_0x404984('0x3b'),this[_0x404984('0x31')][_0x404984('0x4')](this)),ami['on'](_0x404984('0x35'),this[_0x404984('0x46')][_0x404984('0x4')](this)),ami['on'](_0x404984('0x38'),this[_0x404984('0x2c')][_0x404984('0x4')](this)),ami['on']('blindtransfer',this[_0x404984('0x37')]['bind'](this)),ami['on'](_0x404984('0x19'),this[_0x404984('0x2b')][_0x404984('0x4')](this)));},Report[_0x5a448e('0xc')][_0x5a448e('0x45')]=function(_0x40f752){const _0x430149=_0x5a448e;let _0x4966e0=undefined;_0x4966e0=_[_0x430149('0x33')](this[_0x430149('0x1a')],function(_0x3cdb65){const _0xad0f03=_0x430149;return _0x3cdb65[_0xad0f03('0x3e')]==_0x40f752||_0x3cdb65[_0xad0f03('0x44')]==_0x40f752;});if(_[_0x430149('0x2d')](_0x4966e0)){const _0x499d84=_[_0x430149('0x33')](this[_0x430149('0x9')],function(_0x398da4){const _0x282156=_0x430149;return _0x398da4[_0x282156('0x3e')]==_0x40f752||_0x398da4[_0x282156('0x44')]==_0x40f752;});_0x499d84&&(_0x4966e0=_[_0x430149('0x33')](this[_0x430149('0x1a')],function(_0x582042){const _0x5c2dc9=_0x430149;return _0x582042[_0x5c2dc9('0x47')]==util['format'](_0x5c2dc9('0x43'),_0x499d84['name']);}));}return _0x4966e0;},Report[_0x5a448e('0xc')]['voiceQueueReport']=function(_0x219095){const _0x18aed6=_0x5a448e;for(let _0x6aff10=0x0;_0x6aff10<_0x219095['length'];_0x6aff10+=0x1){const _0x62125a=this['findAgent'](_0x219095[_0x6aff10][_0x18aed6('0x11')]);_0x62125a&&(_0x219095[_0x6aff10]['accountcode']=_0x62125a[_0x18aed6('0x3e')],_0x219095[_0x6aff10]['assigned']=!![],_0x219095[_0x6aff10]['lastAssignedTo']=_0x62125a[_0x18aed6('0x44')],_0x219095[_0x6aff10][_0x18aed6('0x47')]=_['isNil'](_0x62125a[_0x18aed6('0x47')])?util['format'](_0x18aed6('0x43'),_0x62125a[_0x18aed6('0x44')]):_0x62125a[_0x18aed6('0x47')],_0x219095[_0x6aff10][_0x18aed6('0xd')]&&(_0x219095[_0x6aff10][_0x18aed6('0x3')]=moment()[_0x18aed6('0x30')]('YYYY-MM-DD\x20HH:mm:ss')),_0x219095[_0x6aff10]['queuecallerexit']&&(_0x219095[_0x6aff10]['queuecallerexitAt']=moment()['format'](_0x18aed6('0x42'))),RpcMemberReport[_0x18aed6('0x1f')](_0x219095[_0x6aff10])),RpcVoiceQueueReport[_0x18aed6('0x34')](_0x219095[_0x6aff10]);}};function extractCalleridNumber(_0x46d8ec){const _0x2e5d14=_0x5a448e,_0x44d589=_0x46d8ec[_0x2e5d14('0x0')](/<(.*?)>/);return _0x44d589?_0x44d589[0x1]:_0x46d8ec;}Report[_0x5a448e('0xc')][_0x5a448e('0x31')]=function(_0x14dbab){const _0x1e3f27=_0x5a448e;_0x14dbab['destination']=_0x14dbab[_0x1e3f27('0x10')]||_0x14dbab[_0x1e3f27('0x25')];if(_0x14dbab[_0x1e3f27('0x3a')]=='dialer'){_0x14dbab[_0x1e3f27('0x20')]=_0x1e3f27('0x2e'),_0x14dbab['lastdata']=_0x14dbab['queue'];if(_0x14dbab[_0x1e3f27('0x14')]==_0x1e3f27('0xa'))_0x14dbab[_0x1e3f27('0x3e')]='',_0x14dbab[_0x1e3f27('0x10')]=extractCalleridNumber(_0x14dbab[_0x1e3f27('0x1e')]);else _0x14dbab[_0x1e3f27('0x14')]==_0x1e3f27('0x1c')&&(_0x14dbab[_0x1e3f27('0x10')]==_0x1e3f27('0x27')?(_0x14dbab[_0x1e3f27('0x10')]=extractCalleridNumber(_0x14dbab[_0x1e3f27('0x1b')]),_0x14dbab[_0x1e3f27('0x1')]=_0x14dbab[_0x1e3f27('0x17')],_0x14dbab[_0x1e3f27('0x13')]=[_0x14dbab['channel'],_0x14dbab['channel']=_0x14dbab[_0x1e3f27('0x13')]][0x0],_0x14dbab[_0x1e3f27('0x1e')]=_0x14dbab[_0x1e3f27('0x1b')]):(_0x14dbab[_0x1e3f27('0x10')]=_0x14dbab[_0x1e3f27('0x1')],_0x14dbab['calleridnum']=_0x14dbab[_0x1e3f27('0x17')],_0x14dbab[_0x1e3f27('0x2f')]=='ANSWERED'?_0x14dbab[_0x1e3f27('0x3e')]=_0x14dbab[_0x1e3f27('0x11')]:_0x14dbab[_0x1e3f27('0x3e')]=''));}else _0x14dbab[_0x1e3f27('0x1e')]=util['format'](_0x1e3f27('0x23'),_0x14dbab[_0x1e3f27('0x36')],_0x14dbab['calleridnum']);RpcVoiceCallReport[_0x1e3f27('0x34')](_0x14dbab);if(_0x14dbab['monitor'])for(let _0x1ee1cf=0x0;_0x1ee1cf<_0x14dbab[_0x1e3f27('0x40')]['length'];_0x1ee1cf+=0x1){_0x14dbab[_0x1e3f27('0x41')]=_0x14dbab[_0x1e3f27('0x40')][_0x1ee1cf][_0x1e3f27('0x2a')],_0x14dbab['createdAt']=_0x14dbab['monitors'][_0x1ee1cf][_0x1e3f27('0x2')];if(_0x14dbab['exten']==_0x1e3f27('0x27'))_0x14dbab[_0x1e3f27('0x1')]=_0x14dbab['connectedlinenum'],_0x14dbab[_0x1e3f27('0x36')]=_0x14dbab['connectedlinename'],_0x14dbab[_0x1e3f27('0x11')]=_0x14dbab['accountcode'],_0x14dbab['connectedlinename']=_0x14dbab[_0x1e3f27('0x28')],_0x14dbab[_0x1e3f27('0x25')]=_0x14dbab[_0x1e3f27('0x17')];else _0x14dbab[_0x1e3f27('0x25')]==_0x1e3f27('0x7')&&(_0x14dbab[_0x1e3f27('0x1')]=_0x14dbab[_0x1e3f27('0x10')],_0x14dbab[_0x1e3f27('0x25')]=_0x14dbab[_0x1e3f27('0x17')]);RpcVoiceRecording[_0x1e3f27('0x34')](_0x14dbab);}},Report[_0x5a448e('0xc')][_0x5a448e('0x46')]=function(_0x44fae7){const _0x5f0c0b=_0x5a448e;_[_0x5f0c0b('0x12')](_0x44fae7)?_0x44fae7['forEach'](function(_0x5bb274){const _0x240a69=_0x5f0c0b;RpcVoiceAgentReport[_0x240a69('0x34')](_0x5bb274);}):RpcVoiceAgentReport[_0x5f0c0b('0x34')](_0x44fae7);},Report[_0x5a448e('0xc')][_0x5a448e('0x2c')]=function(_0xe5bcde){const _0x373bc1=_0x5a448e;RpcVoiceDialReport[_0x373bc1('0x34')](_0xe5bcde);let _0x241337=undefined;const _0x245cb8=_0xe5bcde[_0x373bc1('0x3c')];if(_[_0x373bc1('0x26')](_0x245cb8,_0x373bc1('0x18'))){const _0x458ade=_0x245cb8[_0x373bc1('0x22')](_0x245cb8[_0x373bc1('0x6')]('/')+0x1,_0x245cb8['indexOf']('@'));_0x241337=_[_0x373bc1('0x33')](this['agents'],function(_0x1698e7){const _0x5523ad=_0x373bc1;return _0x1698e7[_0x5523ad('0x3f')]==_0x458ade||_0x1698e7['phone']==_0x458ade||_0x1698e7[_0x5523ad('0x3e')]==_0x458ade;});}else{const _0x321d7f=_0x245cb8[_0x373bc1('0x22')](_0x245cb8['indexOf']('/')+0x1,_0x245cb8['lastIndexOf']('-'));_0x241337=this['findAgent'](_0x321d7f);}_0x241337&&(_0xe5bcde[_0x373bc1('0x47')]=_[_0x373bc1('0x2d')](_0x241337[_0x373bc1('0x47')])?util[_0x373bc1('0x30')](_0x373bc1('0x43'),_0x241337[_0x373bc1('0x44')]):_0x241337[_0x373bc1('0x47')],_0xe5bcde[_0x373bc1('0x28')]=_0x241337[_0x373bc1('0x44')],_0xe5bcde['accountcode']=_0x241337['accountcode'],RpcMemberReport[_0x373bc1('0x2c')](_0xe5bcde));},Report[_0x5a448e('0xc')][_0x5a448e('0x37')]=function(_0x56e335){const _0x30384a=_0x5a448e;RpcVoiceTransferReport[_0x30384a('0x37')](_0x56e335);},Report[_0x5a448e('0xc')]['attendedTransfer']=function(_0x2759fd){const _0x172713=_0x5a448e;RpcVoiceTransferReport[_0x172713('0x2b')](_0x2759fd);},module[_0x5a448e('0x3d')]=Report;