Built motion from commit (unavailable).|2.5.31
[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 _0xa40f=['./userReport','realtime','agents','telephones','sync','xdr','disabled','voiceQueueReport','voiceCallReport','custom:voiceAgentReport','voiceAgentReport','bind','custom:voiceDialReport','voiceDialReport','blindtransfer','blindTransfer','attendedtransfer','attendedTransfer','prototype','findAgent','find','accountcode','name','interface','format','SIP/%s','connectedlinenum','assigned','queuecallercomplete','queuecallercompleteAt','YYYY-MM-DD\x20HH:mm:ss','queuecallerexit','match','destination','exten','type','dialer','lastapplication','queue','context','from-voip-provider','callerid','from-sip','xcally-motion-preview','calleridpreview','calleridnum','originatecalleridnum','destinationchannel','channel','ANSWERED','\x22%s\x22\x20<%s>','linkedid','transfers','transfereelinkedid','uniqueid','monitor','monitors','length','monitorFilename','filename','createdAt','calleridname','connectedlinename','membername','create','forEach','startsWith','Local','substring','indexOf','mobile','phone','lastIndexOf','transfererlinkedid','lodash','util','../../../config/environment','../rpc/voiceCallReport','../rpc/voiceDialReport','../rpc/voiceQueueReport','../rpc/voiceRecording','../rpc/voiceTransferReport','./voiceQueueReport','./voiceAgentReport'];(function(_0x1a7c3a,_0x3847ed){var _0x438dad=function(_0xa12ecc){while(--_0xa12ecc){_0x1a7c3a['push'](_0x1a7c3a['shift']());}};_0x438dad(++_0x3847ed);}(_0xa40f,0x19a));var _0xfa40=function(_0x27b79a,_0x1509ae){_0x27b79a=_0x27b79a-0x0;var _0xf1ef77=_0xa40f[_0x27b79a];return _0xf1ef77;};'use strict';var _=require(_0xfa40('0x0'));var moment=require('moment');var util=require(_0xfa40('0x1'));var config=require(_0xfa40('0x2'));var ami=require('../ami');var RpcVoiceAgentReport=require('../rpc/voiceAgentReport');var RpcVoiceCallReport=require(_0xfa40('0x3'));var RpcVoiceDialReport=require(_0xfa40('0x4'));var RpcMemberReport=require('../rpc/memberReport');var RpcVoiceQueueReport=require(_0xfa40('0x5'));var RpcVoiceRecording=require(_0xfa40('0x6'));var RpcVoiceTransferReport=require(_0xfa40('0x7'));var VoiceQueueReport=require(_0xfa40('0x8'));var VoiceCallReport=require('./voiceCallReport');var VoiceAgentReport=require(_0xfa40('0x9'));var VoiceDialReport=require('./voiceDialReport');var UserReport=require(_0xfa40('0xa'));function Report(_0x44f80c){this[_0xfa40('0xb')]=_0x44f80c;this[_0xfa40('0xc')]=_0x44f80c[_0xfa40('0xc')];this[_0xfa40('0xd')]=_0x44f80c['telephones'];}Report['prototype'][_0xfa40('0xe')]=function(_0x1668e3){var _0x3d0018=new VoiceQueueReport(this['realtime']);var _0xa37e1b=new VoiceAgentReport(this[_0xfa40('0xb')]);var _0x34cf5b=new VoiceDialReport(this[_0xfa40('0xb')]);var _0x24cb6e=new VoiceCallReport(this[_0xfa40('0xb')]);var _0x4bd31f=new UserReport(this[_0xfa40('0xb')]);if(config[_0xfa40('0xf')]&&config['xdr'][_0xfa40('0x10')]){ami['on']('custom:voiceQueueReport',this[_0xfa40('0x11')]['bind'](this));ami['on']('custom:voiceCallReport',this[_0xfa40('0x12')]['bind'](this));ami['on'](_0xfa40('0x13'),this[_0xfa40('0x14')][_0xfa40('0x15')](this));ami['on'](_0xfa40('0x16'),this[_0xfa40('0x17')][_0xfa40('0x15')](this));ami['on'](_0xfa40('0x18'),this[_0xfa40('0x19')][_0xfa40('0x15')](this));ami['on'](_0xfa40('0x1a'),this[_0xfa40('0x1b')]['bind'](this));}};Report[_0xfa40('0x1c')][_0xfa40('0x1d')]=function(_0x50b1c7){var _0x2b10df;_0x2b10df=_[_0xfa40('0x1e')](this['agents'],function(_0x57a5ca){return _0x57a5ca['accountcode']==_0x50b1c7||_0x57a5ca['name']==_0x50b1c7;});if(_['isNil'](_0x2b10df)){var _0x32a32b=_[_0xfa40('0x1e')](this['telephones'],function(_0x89105a){return _0x89105a[_0xfa40('0x1f')]==_0x50b1c7||_0x89105a[_0xfa40('0x20')]==_0x50b1c7;});if(_0x32a32b){_0x2b10df=_['find'](this[_0xfa40('0xc')],function(_0x2624b9){return _0x2624b9[_0xfa40('0x21')]==util[_0xfa40('0x22')](_0xfa40('0x23'),_0x32a32b[_0xfa40('0x20')]);});}}return _0x2b10df;};Report[_0xfa40('0x1c')][_0xfa40('0x11')]=function(_0x90737a){for(var _0x16fc77=0x0;_0x16fc77<_0x90737a['length'];_0x16fc77+=0x1){var _0x4adf98=this[_0xfa40('0x1d')](_0x90737a[_0x16fc77][_0xfa40('0x24')]);if(_0x4adf98){_0x90737a[_0x16fc77][_0xfa40('0x1f')]=_0x4adf98[_0xfa40('0x1f')];_0x90737a[_0x16fc77][_0xfa40('0x25')]=!![];_0x90737a[_0x16fc77]['lastAssignedTo']=_0x4adf98['name'];_0x90737a[_0x16fc77][_0xfa40('0x21')]=_['isNil'](_0x4adf98[_0xfa40('0x21')])?util[_0xfa40('0x22')](_0xfa40('0x23'),_0x4adf98['name']):_0x4adf98[_0xfa40('0x21')];if(_0x90737a[_0x16fc77][_0xfa40('0x26')]){_0x90737a[_0x16fc77][_0xfa40('0x27')]=moment()['format'](_0xfa40('0x28'));}if(_0x90737a[_0x16fc77][_0xfa40('0x29')]){_0x90737a[_0x16fc77]['queuecallerexitAt']=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');}RpcMemberReport['voiceQueueReport'](_0x90737a[_0x16fc77]);}RpcVoiceQueueReport['create'](_0x90737a[_0x16fc77]);}};function extractCalleridNumber(_0x5e3532){var _0x181feb=_0x5e3532[_0xfa40('0x2a')](/<(.*?)>/);return _0x181feb?_0x181feb[0x1]:_0x5e3532;}Report[_0xfa40('0x1c')][_0xfa40('0x12')]=function(_0x431a1f){_0x431a1f[_0xfa40('0x2b')]=_0x431a1f[_0xfa40('0x2b')]||_0x431a1f[_0xfa40('0x2c')];if(_0x431a1f[_0xfa40('0x2d')]==_0xfa40('0x2e')){_0x431a1f[_0xfa40('0x2f')]=_0xfa40('0x30');_0x431a1f['lastdata']=_0x431a1f[_0xfa40('0x30')];if(_0x431a1f[_0xfa40('0x31')]==_0xfa40('0x32')){_0x431a1f[_0xfa40('0x1f')]='';_0x431a1f['destination']=extractCalleridNumber(_0x431a1f[_0xfa40('0x33')]);}else if(_0x431a1f[_0xfa40('0x31')]==_0xfa40('0x34')){if(_0x431a1f[_0xfa40('0x2b')]==_0xfa40('0x35')){_0x431a1f[_0xfa40('0x2b')]=extractCalleridNumber(_0x431a1f[_0xfa40('0x36')]);_0x431a1f[_0xfa40('0x37')]=_0x431a1f[_0xfa40('0x38')];_0x431a1f[_0xfa40('0x39')]=[_0x431a1f[_0xfa40('0x3a')],_0x431a1f[_0xfa40('0x3a')]=_0x431a1f[_0xfa40('0x39')]][0x0];_0x431a1f[_0xfa40('0x33')]=_0x431a1f[_0xfa40('0x36')];}else{_0x431a1f[_0xfa40('0x2b')]=_0x431a1f[_0xfa40('0x37')];_0x431a1f[_0xfa40('0x37')]=_0x431a1f[_0xfa40('0x38')];if(_0x431a1f['disposition']==_0xfa40('0x3b')){_0x431a1f[_0xfa40('0x1f')]=_0x431a1f[_0xfa40('0x24')];}else{_0x431a1f['accountcode']='';}}}}else{_0x431a1f['callerid']=util[_0xfa40('0x22')](_0xfa40('0x3c'),_0x431a1f['calleridname'],_0x431a1f[_0xfa40('0x37')]);}if(RpcVoiceTransferReport['transfers'][_0x431a1f[_0xfa40('0x3d')]]){var _0x583271=RpcVoiceTransferReport[_0xfa40('0x3e')][_0x431a1f[_0xfa40('0x3d')]];_0x583271[_0xfa40('0x3f')]=_0x431a1f[_0xfa40('0x40')];RpcVoiceTransferReport['blindTransfer'](_0x583271);delete RpcVoiceTransferReport['transfers'][_0x431a1f[_0xfa40('0x3d')]];}RpcVoiceCallReport['create'](_0x431a1f);if(_0x431a1f[_0xfa40('0x41')]){for(var _0x11176d=0x0;_0x11176d<_0x431a1f[_0xfa40('0x42')][_0xfa40('0x43')];_0x11176d+=0x1){_0x431a1f[_0xfa40('0x44')]=_0x431a1f['monitors'][_0x11176d][_0xfa40('0x45')];_0x431a1f[_0xfa40('0x46')]=_0x431a1f[_0xfa40('0x42')][_0x11176d][_0xfa40('0x46')];if(_0x431a1f[_0xfa40('0x2c')]==_0xfa40('0x35')){_0x431a1f[_0xfa40('0x37')]=_0x431a1f[_0xfa40('0x24')];_0x431a1f[_0xfa40('0x47')]=_0x431a1f[_0xfa40('0x48')];_0x431a1f[_0xfa40('0x24')]=_0x431a1f[_0xfa40('0x1f')];_0x431a1f['connectedlinename']=_0x431a1f[_0xfa40('0x49')];_0x431a1f[_0xfa40('0x2c')]=_0x431a1f[_0xfa40('0x38')];}else if(_0x431a1f[_0xfa40('0x2c')]=='xcally-motion-dialer'){_0x431a1f[_0xfa40('0x37')]=_0x431a1f[_0xfa40('0x2b')];_0x431a1f[_0xfa40('0x2c')]=_0x431a1f[_0xfa40('0x38')];}RpcVoiceRecording[_0xfa40('0x4a')](_0x431a1f);}}};Report[_0xfa40('0x1c')][_0xfa40('0x14')]=function(_0x4c0e1b){if(_['isArray'](_0x4c0e1b)){_0x4c0e1b[_0xfa40('0x4b')](function(_0x3028e4){RpcVoiceAgentReport[_0xfa40('0x4a')](_0x3028e4);});}else{RpcVoiceAgentReport['create'](_0x4c0e1b);}};Report['prototype'][_0xfa40('0x17')]=function(_0x2c625c){RpcVoiceDialReport[_0xfa40('0x4a')](_0x2c625c);var _0x13abbb;var _0x49d140;var _0x2b8e8e=_0x2c625c[_0xfa40('0x3a')];if(_[_0xfa40('0x4c')](_0x2b8e8e,_0xfa40('0x4d'))){_0x49d140=_0x2b8e8e[_0xfa40('0x4e')](_0x2b8e8e['indexOf']('/')+0x1,_0x2b8e8e[_0xfa40('0x4f')]('@'));_0x13abbb=_[_0xfa40('0x1e')](this[_0xfa40('0xc')],function(_0x317de0){return _0x317de0[_0xfa40('0x50')]==_0x49d140||_0x317de0[_0xfa40('0x51')]==_0x49d140||_0x317de0[_0xfa40('0x1f')]==_0x49d140;});}else{_0x49d140=_0x2b8e8e[_0xfa40('0x4e')](_0x2b8e8e[_0xfa40('0x4f')]('/')+0x1,_0x2b8e8e[_0xfa40('0x52')]('-'));_0x13abbb=this[_0xfa40('0x1d')](_0x49d140);}if(_0x13abbb){_0x2c625c[_0xfa40('0x21')]=_['isNil'](_0x13abbb[_0xfa40('0x21')])?util[_0xfa40('0x22')](_0xfa40('0x23'),_0x13abbb[_0xfa40('0x20')]):_0x13abbb[_0xfa40('0x21')];_0x2c625c[_0xfa40('0x49')]=_0x13abbb[_0xfa40('0x20')];_0x2c625c[_0xfa40('0x1f')]=_0x13abbb['accountcode'];RpcMemberReport[_0xfa40('0x17')](_0x2c625c);}};Report['prototype']['blindTransfer']=function(_0x10c24d){RpcVoiceTransferReport['transfers'][_0x10c24d[_0xfa40('0x53')]]=_0x10c24d;};Report[_0xfa40('0x1c')]['attendedTransfer']=function(_0x1f64d4){RpcVoiceTransferReport[_0xfa40('0x1b')](_0x1f64d4);};module['exports']=Report;