2448ed5e38a03e2ef634815fe17dba6b2a6cf9a4
[motion2.git] / server / services / xdr / dials.controller.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 _0x4dea=['dialstatus','assign','answertime','lastevent','connect','[%s][dials][dialend]\x20dialstatus:%s','hangup','[%s][dials][hangup]\x20calleridnum:%s\x20calleridname:%s\x20lastevent:complete\x20reason:%s','calleridname','cause-txt','complete','duration','diffTime','endtime','holdtime','billableseconds','[%s][dials][hangup]','lodash','./utils','info','format','uniqueid','dialstring','connectedlinenum','CreateVoiceDialReport','newexten','debug','[%s][dials][newexten]','[%s][dials][newexten]\x20application:%s\x20appdata:%s','application','appdata','toLowerCase','startsWith','cdr(routeid)','split','error','[%s][dials][varset]','variable','outboundrouteid','[%s][dials][varset]\x20variable:outboundrouteid\x20value:%s','value','isNil','[%s][dials][dialbegin]','starttime','now','[%s][dials][hangup]\x20starttime:%s\x20lastevent:called','dialend','[%s][dials][dialend]'];(function(_0xeea5ca,_0x2d569b){var _0x1fdf07=function(_0x86809){while(--_0x86809){_0xeea5ca['push'](_0xeea5ca['shift']());}};_0x1fdf07(++_0x2d569b);}(_0x4dea,0x1f1));var _0xa4de=function(_0xb68ad9,_0x111003){_0xb68ad9=_0xb68ad9-0x0;var _0x47eed9=_0x4dea[_0xb68ad9];return _0x47eed9;};'use strict';var _=require(_0xa4de('0x0'));var util=require('util');var utils=require(_0xa4de('0x1'));var dials={};function writeDB(_0x1a99e0){utils[_0xa4de('0x2')](util[_0xa4de('0x3')]('[%s][dials][writeDB]\x20channel:%s\x20dialstring:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20dialstatus:%s',_0x1a99e0[_0xa4de('0x4')],_0x1a99e0['channel'],_0x1a99e0[_0xa4de('0x5')],_0x1a99e0['calleridnum'],_0x1a99e0[_0xa4de('0x6')],_0x1a99e0['dialstatus']));utils['request'](_0xa4de('0x7'),_0x1a99e0);delete dials[_0x1a99e0['uniqueid']];}exports[_0xa4de('0x8')]=function(_0x2845df){try{utils[_0xa4de('0x9')](util[_0xa4de('0x3')](_0xa4de('0xa'),_0x2845df[_0xa4de('0x4')]),_0x2845df);utils[_0xa4de('0x2')](util[_0xa4de('0x3')](_0xa4de('0xb'),_0x2845df[_0xa4de('0x4')],_0x2845df[_0xa4de('0xc')],_0x2845df[_0xa4de('0xd')]));if(_0x2845df[_0xa4de('0xc')][_0xa4de('0xe')]()=='set'&&_[_0xa4de('0xf')](_0x2845df[_0xa4de('0xd')][_0xa4de('0xe')](),_0xa4de('0x10'))){var _0x4deba9=_0x2845df[_0xa4de('0xd')][_0xa4de('0x11')]('=');dials[_0x2845df[_0xa4de('0x4')]]={'routeId':_0x4deba9[0x1]};}}catch(_0x39f29c){utils[_0xa4de('0x12')](util['format'](_0xa4de('0xa'),_0x2845df['uniqueid']),_0x39f29c);}};exports['varset']=function(_0x17f69d){try{utils[_0xa4de('0x9')](util[_0xa4de('0x3')](_0xa4de('0x13'),_0x17f69d['uniqueid']),_0x17f69d);if(!_['isNil'](_0x17f69d[_0xa4de('0x14')][_0xa4de('0x15')])){utils[_0xa4de('0x2')](util[_0xa4de('0x3')](_0xa4de('0x16'),_0x17f69d['uniqueid'],_0x17f69d['value']));dials[_0x17f69d[_0xa4de('0x4')]]={'routeId':_0x17f69d[_0xa4de('0x17')]};}}catch(_0x71650d){utils[_0xa4de('0x12')](util[_0xa4de('0x3')](_0xa4de('0x13'),_0x17f69d['uniqueid']),_0x71650d);}};exports['dialbegin']=function(_0xc5dc52){try{if(!_[_0xa4de('0x18')](dials[_0xc5dc52[_0xa4de('0x4')]])){utils['debug'](util['format'](_0xa4de('0x19'),_0xc5dc52[_0xa4de('0x4')]),_0xc5dc52);dials[_0xc5dc52[_0xa4de('0x4')]]=_['assign'](dials[_0xc5dc52[_0xa4de('0x4')]],_0xc5dc52);dials[_0xc5dc52[_0xa4de('0x4')]][_0xa4de('0x1a')]=utils[_0xa4de('0x1b')]();dials[_0xc5dc52[_0xa4de('0x4')]]['lastevent']='called';utils[_0xa4de('0x2')](util['format'](_0xa4de('0x1c'),_0xc5dc52[_0xa4de('0x4')],dials[_0xc5dc52[_0xa4de('0x4')]][_0xa4de('0x1a')]));}}catch(_0x3dd394){utils[_0xa4de('0x12')](util[_0xa4de('0x3')](_0xa4de('0x19'),_0xc5dc52[_0xa4de('0x4')]),_0x3dd394);}};exports[_0xa4de('0x1d')]=function(_0xd7034c){try{if(!_['isNil'](dials[_0xd7034c[_0xa4de('0x4')]])){utils['debug'](util['format'](_0xa4de('0x1e'),_0xd7034c[_0xa4de('0x4')]),_0xd7034c);dials[_0xd7034c[_0xa4de('0x4')]][_0xa4de('0x1f')]=_0xd7034c[_0xa4de('0x1f')];if(_0xd7034c[_0xa4de('0x1f')]=='ANSWER'){dials[_0xd7034c[_0xa4de('0x4')]]=_[_0xa4de('0x20')](dials[_0xd7034c[_0xa4de('0x4')]],_0xd7034c);dials[_0xd7034c[_0xa4de('0x4')]][_0xa4de('0x21')]=utils[_0xa4de('0x1b')]();dials[_0xd7034c[_0xa4de('0x4')]][_0xa4de('0x22')]=_0xa4de('0x23');utils['info'](util[_0xa4de('0x3')]('[%s][dials][dialend]\x20dialstatus:%s\x20answertime:%s\x20lastevent:connect',_0xd7034c['uniqueid'],_0xd7034c[_0xa4de('0x1f')],dials[_0xd7034c[_0xa4de('0x4')]][_0xa4de('0x21')]));}else{utils[_0xa4de('0x2')](util[_0xa4de('0x3')](_0xa4de('0x24'),_0xd7034c[_0xa4de('0x4')],_0xd7034c[_0xa4de('0x1f')]));}}}catch(_0x3a7a57){utils[_0xa4de('0x12')](util['format']('[%s][dials][dialend]',_0xd7034c[_0xa4de('0x4')]),_0x3a7a57);}};exports[_0xa4de('0x25')]=function(_0x2f79a2){try{if(!_['isNil'](dials[_0x2f79a2['uniqueid']])){utils[_0xa4de('0x9')](util['format']('[%s][dials][hangup]',_0x2f79a2[_0xa4de('0x4')]),_0x2f79a2);utils['info'](util[_0xa4de('0x3')](_0xa4de('0x26'),_0x2f79a2[_0xa4de('0x4')],_0x2f79a2['calleridnum'],_0x2f79a2[_0xa4de('0x27')],_0x2f79a2[_0xa4de('0x28')]));dials[_0x2f79a2[_0xa4de('0x4')]]=_['assign'](dials[_0x2f79a2[_0xa4de('0x4')]],{'endtime':utils[_0xa4de('0x1b')](),'lastevent':_0xa4de('0x29')});dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x2a')]=utils[_0xa4de('0x2b')](dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x2c')],dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x1a')]);dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x2d')]=utils[_0xa4de('0x2b')](dials[_0x2f79a2['uniqueid']]['answertime']||dials[_0x2f79a2[_0xa4de('0x4')]]['endtime'],dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x1a')]);dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x2e')]=dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x21')]?utils[_0xa4de('0x2b')](dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x2c')],dials[_0x2f79a2[_0xa4de('0x4')]][_0xa4de('0x21')]):0x0;writeDB(dials[_0x2f79a2[_0xa4de('0x4')]]);}}catch(_0x4279c8){utils[_0xa4de('0x12')](util[_0xa4de('0x3')](_0xa4de('0x2f'),_0x2f79a2['uniqueid']),_0x4279c8);}};