Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / services / ami / report / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x4877=['ANSWERED','\x22%s\x22\x20<%s>','calleridname','linkedid','transfers','transfereelinkedid','monitor','monitorFilename','monitors','filename','createdAt','connectedlinename','membername','xcally-motion-dialer','isArray','forEach','Local','substring','indexOf','mobile','lastIndexOf','exports','lodash','../../../config/environment','../ami','../rpc/voiceAgentReport','../rpc/voiceCallReport','../rpc/voiceDialReport','../rpc/memberReport','../rpc/voiceRecording','./voiceQueueReport','./voiceCallReport','./voiceAgentReport','./voiceDialReport','telephones','prototype','sync','realtime','xdr','disabled','bind','custom:voiceCallReport','voiceCallReport','custom:voiceAgentReport','voiceAgentReport','custom:voiceDialReport','voiceDialReport','blindTransfer','attendedTransfer','find','agents','name','isNil','accountcode','format','SIP/%s','findAgent','connectedlinenum','lastAssignedTo','interface','queuecallercompleteAt','YYYY-MM-DD\x20HH:mm:ss','queuecallerexit','queuecallerexitAt','create','destination','exten','dialer','lastapplication','queue','lastdata','context','from-voip-provider','callerid','xcally-motion-preview','originatecalleridnum','destinationchannel','channel','calleridpreview','calleridnum','disposition'];(function(_0x3d3bef,_0x491eac){var _0x2394ac=function(_0x40d724){while(--_0x40d724){_0x3d3bef['push'](_0x3d3bef['shift']());}};_0x2394ac(++_0x491eac);}(_0x4877,0x15a));var _0x7487=function(_0x17fc84,_0x3985d2){_0x17fc84=_0x17fc84-0x0;var _0x50ab69=_0x4877[_0x17fc84];return _0x50ab69;};'use strict';var _=require(_0x7487('0x0'));var moment=require('moment');var util=require('util');var config=require(_0x7487('0x1'));var ami=require(_0x7487('0x2'));var RpcVoiceAgentReport=require(_0x7487('0x3'));var RpcVoiceCallReport=require(_0x7487('0x4'));var RpcVoiceDialReport=require(_0x7487('0x5'));var RpcMemberReport=require(_0x7487('0x6'));var RpcVoiceQueueReport=require('../rpc/voiceQueueReport');var RpcVoiceRecording=require(_0x7487('0x7'));var RpcVoiceTransferReport=require('../rpc/voiceTransferReport');var VoiceQueueReport=require(_0x7487('0x8'));var VoiceCallReport=require(_0x7487('0x9'));var VoiceAgentReport=require(_0x7487('0xa'));var VoiceDialReport=require(_0x7487('0xb'));var UserReport=require('./userReport');function Report(_0x1ad882){this['realtime']=_0x1ad882;this['agents']=_0x1ad882['agents'];this[_0x7487('0xc')]=_0x1ad882[_0x7487('0xc')];}Report[_0x7487('0xd')][_0x7487('0xe')]=function(_0x16145a){var _0x1250c5=new VoiceQueueReport(this[_0x7487('0xf')]);var _0x4ffcb6=new VoiceAgentReport(this[_0x7487('0xf')]);var _0xb90553=new VoiceDialReport(this[_0x7487('0xf')]);var _0x574c8b=new VoiceCallReport(this[_0x7487('0xf')]);var _0x42af1b=new UserReport(this[_0x7487('0xf')]);if(config[_0x7487('0x10')]&&config[_0x7487('0x10')][_0x7487('0x11')]){ami['on']('custom:voiceQueueReport',this['voiceQueueReport'][_0x7487('0x12')](this));ami['on'](_0x7487('0x13'),this[_0x7487('0x14')][_0x7487('0x12')](this));ami['on'](_0x7487('0x15'),this[_0x7487('0x16')][_0x7487('0x12')](this));ami['on'](_0x7487('0x17'),this[_0x7487('0x18')]['bind'](this));ami['on']('blindtransfer',this[_0x7487('0x19')]['bind'](this));ami['on']('attendedtransfer',this[_0x7487('0x1a')]['bind'](this));}};Report[_0x7487('0xd')]['findAgent']=function(_0x4be454){var _0x490b23;_0x490b23=_[_0x7487('0x1b')](this[_0x7487('0x1c')],function(_0x5de132){return _0x5de132['accountcode']==_0x4be454||_0x5de132[_0x7487('0x1d')]==_0x4be454;});if(_[_0x7487('0x1e')](_0x490b23)){var _0x25b870=_[_0x7487('0x1b')](this[_0x7487('0xc')],function(_0x3950fa){return _0x3950fa[_0x7487('0x1f')]==_0x4be454||_0x3950fa[_0x7487('0x1d')]==_0x4be454;});if(_0x25b870){_0x490b23=_['find'](this['agents'],function(_0x368bcb){return _0x368bcb['interface']==util[_0x7487('0x20')](_0x7487('0x21'),_0x25b870['name']);});}}return _0x490b23;};Report[_0x7487('0xd')]['voiceQueueReport']=function(_0x129ab5){for(var _0xaacbe5=0x0;_0xaacbe5<_0x129ab5['length'];_0xaacbe5+=0x1){var _0xa847c3=this[_0x7487('0x22')](_0x129ab5[_0xaacbe5][_0x7487('0x23')]);if(_0xa847c3){_0x129ab5[_0xaacbe5][_0x7487('0x1f')]=_0xa847c3[_0x7487('0x1f')];_0x129ab5[_0xaacbe5]['assigned']=!![];_0x129ab5[_0xaacbe5][_0x7487('0x24')]=_0xa847c3[_0x7487('0x1d')];_0x129ab5[_0xaacbe5][_0x7487('0x25')]=_[_0x7487('0x1e')](_0xa847c3[_0x7487('0x25')])?util[_0x7487('0x20')](_0x7487('0x21'),_0xa847c3[_0x7487('0x1d')]):_0xa847c3[_0x7487('0x25')];if(_0x129ab5[_0xaacbe5]['queuecallercomplete']){_0x129ab5[_0xaacbe5][_0x7487('0x26')]=moment()[_0x7487('0x20')](_0x7487('0x27'));}if(_0x129ab5[_0xaacbe5][_0x7487('0x28')]){_0x129ab5[_0xaacbe5][_0x7487('0x29')]=moment()['format'](_0x7487('0x27'));}RpcMemberReport['voiceQueueReport'](_0x129ab5[_0xaacbe5]);}RpcVoiceQueueReport[_0x7487('0x2a')](_0x129ab5[_0xaacbe5]);}};function extractCalleridNumber(_0x53c477){var _0x498b31=_0x53c477['match'](/<(.*?)>/);return _0x498b31?_0x498b31[0x1]:_0x53c477;}Report[_0x7487('0xd')][_0x7487('0x14')]=function(_0x497e62){_0x497e62[_0x7487('0x2b')]=_0x497e62[_0x7487('0x2b')]||_0x497e62[_0x7487('0x2c')];if(_0x497e62['type']==_0x7487('0x2d')){_0x497e62[_0x7487('0x2e')]=_0x7487('0x2f');_0x497e62[_0x7487('0x30')]=_0x497e62[_0x7487('0x2f')];if(_0x497e62[_0x7487('0x31')]==_0x7487('0x32')){_0x497e62[_0x7487('0x1f')]='';_0x497e62[_0x7487('0x2b')]=extractCalleridNumber(_0x497e62[_0x7487('0x33')]);}else if(_0x497e62[_0x7487('0x31')]=='from-sip'){if(_0x497e62[_0x7487('0x2b')]==_0x7487('0x34')){_0x497e62[_0x7487('0x2b')]=extractCalleridNumber(_0x497e62['calleridpreview']);_0x497e62['calleridnum']=_0x497e62[_0x7487('0x35')];_0x497e62[_0x7487('0x36')]=[_0x497e62['channel'],_0x497e62[_0x7487('0x37')]=_0x497e62[_0x7487('0x36')]][0x0];_0x497e62[_0x7487('0x33')]=_0x497e62[_0x7487('0x38')];}else{_0x497e62['destination']=_0x497e62[_0x7487('0x39')];_0x497e62['calleridnum']=_0x497e62['originatecalleridnum'];if(_0x497e62[_0x7487('0x3a')]==_0x7487('0x3b')){_0x497e62[_0x7487('0x1f')]=_0x497e62[_0x7487('0x23')];}else{_0x497e62[_0x7487('0x1f')]='';}}}}else{_0x497e62[_0x7487('0x33')]=util[_0x7487('0x20')](_0x7487('0x3c'),_0x497e62[_0x7487('0x3d')],_0x497e62[_0x7487('0x39')]);}if(RpcVoiceTransferReport['transfers'][_0x497e62[_0x7487('0x3e')]]){var _0x30e043=RpcVoiceTransferReport[_0x7487('0x3f')][_0x497e62[_0x7487('0x3e')]];_0x30e043[_0x7487('0x40')]=_0x497e62['uniqueid'];RpcVoiceTransferReport[_0x7487('0x19')](_0x30e043);delete RpcVoiceTransferReport[_0x7487('0x3f')][_0x497e62[_0x7487('0x3e')]];}RpcVoiceCallReport[_0x7487('0x2a')](_0x497e62);if(_0x497e62[_0x7487('0x41')]){for(var _0x1b1c8d=0x0;_0x1b1c8d<_0x497e62['monitors']['length'];_0x1b1c8d+=0x1){_0x497e62[_0x7487('0x42')]=_0x497e62[_0x7487('0x43')][_0x1b1c8d][_0x7487('0x44')];_0x497e62['createdAt']=_0x497e62[_0x7487('0x43')][_0x1b1c8d][_0x7487('0x45')];if(_0x497e62[_0x7487('0x2c')]==_0x7487('0x34')){_0x497e62[_0x7487('0x39')]=_0x497e62[_0x7487('0x23')];_0x497e62['calleridname']=_0x497e62[_0x7487('0x46')];_0x497e62['connectedlinenum']=_0x497e62[_0x7487('0x1f')];_0x497e62['connectedlinename']=_0x497e62[_0x7487('0x47')];_0x497e62[_0x7487('0x2c')]=_0x497e62[_0x7487('0x35')];}else if(_0x497e62[_0x7487('0x2c')]==_0x7487('0x48')){_0x497e62['calleridnum']=_0x497e62[_0x7487('0x2b')];_0x497e62['exten']=_0x497e62[_0x7487('0x35')];}RpcVoiceRecording[_0x7487('0x2a')](_0x497e62);}}};Report[_0x7487('0xd')][_0x7487('0x16')]=function(_0xa496ee){if(_[_0x7487('0x49')](_0xa496ee)){_0xa496ee[_0x7487('0x4a')](function(_0x3d0ea5){RpcVoiceAgentReport[_0x7487('0x2a')](_0x3d0ea5);});}else{RpcVoiceAgentReport['create'](_0xa496ee);}};Report[_0x7487('0xd')][_0x7487('0x18')]=function(_0x5d63e5){RpcVoiceDialReport[_0x7487('0x2a')](_0x5d63e5);var _0x46ead4;var _0xb94fe6;var _0x5dc060=_0x5d63e5[_0x7487('0x37')];if(_['startsWith'](_0x5dc060,_0x7487('0x4b'))){_0xb94fe6=_0x5dc060[_0x7487('0x4c')](_0x5dc060[_0x7487('0x4d')]('/')+0x1,_0x5dc060[_0x7487('0x4d')]('@'));_0x46ead4=_[_0x7487('0x1b')](this[_0x7487('0x1c')],function(_0x1a05dc){return _0x1a05dc[_0x7487('0x4e')]==_0xb94fe6||_0x1a05dc['phone']==_0xb94fe6||_0x1a05dc['accountcode']==_0xb94fe6;});}else{_0xb94fe6=_0x5dc060[_0x7487('0x4c')](_0x5dc060['indexOf']('/')+0x1,_0x5dc060[_0x7487('0x4f')]('-'));_0x46ead4=this[_0x7487('0x22')](_0xb94fe6);}if(_0x46ead4){_0x5d63e5['interface']=_[_0x7487('0x1e')](_0x46ead4[_0x7487('0x25')])?util['format'](_0x7487('0x21'),_0x46ead4[_0x7487('0x1d')]):_0x46ead4[_0x7487('0x25')];_0x5d63e5['membername']=_0x46ead4[_0x7487('0x1d')];_0x5d63e5[_0x7487('0x1f')]=_0x46ead4[_0x7487('0x1f')];RpcMemberReport[_0x7487('0x18')](_0x5d63e5);}};Report['prototype'][_0x7487('0x19')]=function(_0x2b24bd){RpcVoiceTransferReport[_0x7487('0x3f')][_0x2b24bd['transfererlinkedid']]=_0x2b24bd;};Report['prototype']['attendedTransfer']=function(_0x1b8823){RpcVoiceTransferReport[_0x7487('0x1a')](_0x1b8823);};module[_0x7487('0x50')]=Report;