Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / services / ami / report / voiceDialReport.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 _0xdedf=['sumDuration','custom:voiceDialReport','custom:dialend','voice_outbound:save','info','[DEBUG]\x20Emit\x20voice_outbound_channel:remove\x20event','stringify','voice_outbound_channel:remove','[syncHangup][VoiceDialReport]','exports','lodash','moment','ioredis','../../../config/environment','../../../config/logger','ami','defaults','redis','socket.io-emitter','channels','outboundChannels','outbound','variables','dialbegin','syncDialBegin','bind','syncDialEnd','varset','syncVarSet','prototype','isNotNull','isUndefined','emit','uniqueid','merge','format','YYYY-MM-DD\x20HH:mm:ss','called','channel','substring','lastIndexOf','omit','event','privilege','voice:outbound','voice_outbound_channel:save','custom:dialbegin','error','[syncDialBegin][VoiceDialReport]','inspect','dialstatus','ANSWER','connectedlinenum','connectedlinename','answertime','connect','custom:dialconnect','addVariable','keys','variable','value','[syncVarSet][VoiceDialReport]','rtpaudioqosbridged','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','bridgepvtcallid','membercalls','memberdynamic','memberinterface','memberlastcall','membername','memberpenalty','memberrealtime','isNil','includes','syncHangup','endtime','duration','diff','starttime','seconds','lastevent','complete','total','billableseconds','sumHoldTime','holdtime','sumBillable'];(function(_0x4cb322,_0x505daf){var _0x25be4b=function(_0x944c96){while(--_0x944c96){_0x4cb322['push'](_0x4cb322['shift']());}};_0x25be4b(++_0x505daf);}(_0xdedf,0x17a));var _0xfded=function(_0x2f0597,_0x269561){_0x2f0597=_0x2f0597-0x0;var _0x2a0882=_0xdedf[_0x2f0597];return _0x2a0882;};'use strict';var _=require(_0xfded('0x0'));var moment=require(_0xfded('0x1'));var util=require('util');var Redis=require(_0xfded('0x2'));var config=require(_0xfded('0x3'));var logger=require(_0xfded('0x4'))(_0xfded('0x5'));var ami=require('../ami');config['redis']=_[_0xfded('0x6')](config[_0xfded('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0xfded('0x8'))(new Redis(config[_0xfded('0x7')]));function VoiceDialReport(_0x32fe31){this[_0xfded('0x9')]=_0x32fe31[_0xfded('0xa')];this[_0xfded('0xb')]=_0x32fe31['outbound'];this[_0xfded('0xc')]={};ami['on'](_0xfded('0xd'),this[_0xfded('0xe')][_0xfded('0xf')](this));ami['on']('dialend',this[_0xfded('0x10')][_0xfded('0xf')](this));ami['on'](_0xfded('0x11'),this[_0xfded('0x12')][_0xfded('0xf')](this));ami['on']('hangup',this['syncHangup']['bind'](this));}VoiceDialReport[_0xfded('0x13')][_0xfded('0x14')]=function(_0x488e1a){return _0x488e1a!==null&&!_[_0xfded('0x15')](_0x488e1a);};VoiceDialReport[_0xfded('0x13')][_0xfded('0x16')]=function(_0x116b69,_0x40932c,_0x16803a){io['to'](_0x116b69)[_0xfded('0x16')](_0x40932c,_0x16803a);};VoiceDialReport[_0xfded('0x13')][_0xfded('0xe')]=function(_0x34ad7f){try{if(this[_0xfded('0x14')](_0x34ad7f)){if(this[_0xfded('0x9')][_0x34ad7f[_0xfded('0x17')]]){_[_0xfded('0x18')](this[_0xfded('0x9')][_0x34ad7f[_0xfded('0x17')]],{'starttime':moment()[_0xfded('0x19')](_0xfded('0x1a')),'lastevent':_0xfded('0x1b'),'interface':_0x34ad7f[_0xfded('0x1c')][_0xfded('0x1d')](0x0,_0x34ad7f['channel'][_0xfded('0x1e')]('-')),'membername':_0x34ad7f[_0xfded('0x1c')][_0xfded('0x1d')](_0x34ad7f[_0xfded('0x1c')][_0xfded('0x1e')]('/')+0x1,_0x34ad7f[_0xfded('0x1c')][_0xfded('0x1e')]('-'))},_[_0xfded('0x1f')](_0x34ad7f,[_0xfded('0x20'),_0xfded('0x21')]));this[_0xfded('0x16')](_0xfded('0x22'),_0xfded('0x23'),this[_0xfded('0x9')][_0x34ad7f['uniqueid']]);ami[_0xfded('0x16')](_0xfded('0x24'),this[_0xfded('0x9')][_0x34ad7f[_0xfded('0x17')]]);}}}catch(_0x594b6e){logger[_0xfded('0x25')](_0xfded('0x26'),util[_0xfded('0x27')](_0x594b6e,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xfded('0x13')]['syncDialEnd']=function(_0x599346){try{if(this[_0xfded('0x14')](_0x599346)){if(this[_0xfded('0x9')][_0x599346['uniqueid']]){this[_0xfded('0x9')][_0x599346[_0xfded('0x17')]]['dialstatus']=_0x599346[_0xfded('0x28')];if(_0x599346[_0xfded('0x28')]===_0xfded('0x29')){this[_0xfded('0x9')][_0x599346[_0xfded('0x17')]][_0xfded('0x2a')]=_0x599346[_0xfded('0x2a')];this[_0xfded('0x9')][_0x599346[_0xfded('0x17')]][_0xfded('0x2b')]=_0x599346['connectedlinename'];this['channels'][_0x599346['uniqueid']][_0xfded('0x2c')]=moment()[_0xfded('0x19')](_0xfded('0x1a'));this[_0xfded('0x9')][_0x599346[_0xfded('0x17')]]['lastevent']=_0xfded('0x2d');ami[_0xfded('0x16')](_0xfded('0x2e'),this[_0xfded('0x9')][_0x599346[_0xfded('0x17')]]);}this[_0xfded('0x16')](_0xfded('0x22'),_0xfded('0x23'),this[_0xfded('0x9')][_0x599346[_0xfded('0x17')]]);}}}catch(_0x529500){logger['error']('[syncDialEnd][VoiceDialReport]',util[_0xfded('0x27')](_0x529500,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xfded('0x13')][_0xfded('0x12')]=function(_0x2b7fef){try{if(this['isNotNull'](_0x2b7fef)){this[_0xfded('0x2f')](_0x2b7fef['uniqueid'],_[_0xfded('0x30')](_0x2b7fef[_0xfded('0x31')])[0x0],_0x2b7fef['value']);if(this[_0xfded('0x14')](_0x2b7fef[_0xfded('0x31')])&&this[_0xfded('0x14')](_0x2b7fef['variable']['outboundrouteid'])){if(_[_0xfded('0x15')](this['channels'][_0x2b7fef[_0xfded('0x17')]])){this[_0xfded('0x9')][_0x2b7fef[_0xfded('0x17')]]={'routeId':_0x2b7fef[_0xfded('0x32')],'variables':this['variables'][_0x2b7fef[_0xfded('0x17')]]};this[_0xfded('0x16')]('voice:outbound',_0xfded('0x23'),this[_0xfded('0x9')][_0x2b7fef['uniqueid']]);}}}}catch(_0x19a3e2){logger['error'](_0xfded('0x33'),util[_0xfded('0x27')](_0x19a3e2,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xfded('0x13')][_0xfded('0x2f')]=function(_0x11b114,_0x1275ac,_0x38712b){var _0x28d3eb=['rtpaudioqos',_0xfded('0x34'),'rtpaudioqosjitter',_0xfded('0x35'),_0xfded('0x36'),_0xfded('0x37'),_0xfded('0x38'),_0xfded('0x39'),_0xfded('0x3a'),'sipuri','bridgepeer',_0xfded('0x3b'),_0xfded('0x3c'),_0xfded('0x3d'),_0xfded('0x3e'),_0xfded('0x3f'),_0xfded('0x40'),_0xfded('0x41'),_0xfded('0x42')];if(!_[_0xfded('0x43')](_0x1275ac)&&!_[_0xfded('0x44')](_0x28d3eb,_0x1275ac)){if(_[_0xfded('0x15')](this[_0xfded('0xc')][_0x11b114])){this[_0xfded('0xc')][_0x11b114]={};}this['variables'][_0x11b114][_0x1275ac]=_0x38712b;}};VoiceDialReport['prototype'][_0xfded('0x45')]=function(_0x4b4c9e){try{if(this['isNotNull'](_0x4b4c9e)){if(this[_0xfded('0x9')][_0x4b4c9e['uniqueid']]){this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x46')]=moment()[_0xfded('0x19')](_0xfded('0x1a'));this[_0xfded('0x9')][_0x4b4c9e['uniqueid']][_0xfded('0x47')]=moment(this['channels'][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x46')])[_0xfded('0x48')](this['channels'][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x49')],_0xfded('0x4a'));this['channels'][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x4b')]=_0xfded('0x4c');this[_0xfded('0xb')][_0xfded('0x4d')]+=0x1;if(this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x2c')]){this[_0xfded('0xb')]['answered']+=0x1;this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]]['holdtime']=moment(this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x2c')])[_0xfded('0x48')](this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x49')],'seconds');this[_0xfded('0x9')][_0x4b4c9e['uniqueid']][_0xfded('0x4e')]=moment(this[_0xfded('0x9')][_0x4b4c9e['uniqueid']][_0xfded('0x46')])[_0xfded('0x48')](this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]]['answertime'],_0xfded('0x4a'));this['outbound'][_0xfded('0x4f')]+=this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x50')]||0x0;this[_0xfded('0xb')][_0xfded('0x51')]+=this[_0xfded('0x9')][_0x4b4c9e['uniqueid']][_0xfded('0x4e')];}this['outbound'][_0xfded('0x52')]+=this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]][_0xfded('0x47')];ami[_0xfded('0x16')](_0xfded('0x53'),this['channels'][_0x4b4c9e[_0xfded('0x17')]]);ami['emit'](_0xfded('0x54'),this['channels'][_0x4b4c9e[_0xfded('0x17')]]);this[_0xfded('0x16')](_0xfded('0x22'),_0xfded('0x55'),this[_0xfded('0xb')]);logger[_0xfded('0x56')](_0xfded('0x57'),JSON[_0xfded('0x58')](this['channels'][_0x4b4c9e['uniqueid']]));this['emit']('voice:outbound',_0xfded('0x59'),this[_0xfded('0x9')][_0x4b4c9e[_0xfded('0x17')]]);delete this[_0xfded('0x9')][_0x4b4c9e['uniqueid']];}if(this[_0xfded('0xc')][_0x4b4c9e[_0xfded('0x17')]]){delete this['variables'][_0x4b4c9e[_0xfded('0x17')]];}}}catch(_0x13d3ae){logger[_0xfded('0x25')](_0xfded('0x5a'),util['inspect'](_0x13d3ae,{'showHidden':![],'depth':null}));}};module[_0xfded('0x5b')]=VoiceDialReport;