a7175e44aa3dc61f4320bf19aa1d7bff20044331
[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 _0xa1e9=['info','[%s][dials][newexten]\x20application:%s\x20appdata:%s','application','toLowerCase','startsWith','appdata','error','varset','isNil','variable','outboundrouteid','[%s][dials][varset]\x20variable:outboundrouteid\x20value:%s','value','[%s][dials][dialbegin]','assign','starttime','now','lastevent','called','dialend','[%s][dials][dialend]','answertime','connect','[%s][dials][dialend]\x20dialstatus:%s','hangup','[%s][dials][hangup]','[%s][dials][hangup]\x20calleridnum:%s\x20calleridname:%s\x20lastevent:complete\x20reason:%s','calleridname','cause-txt','duration','diffTime','endtime','holdtime','billableseconds','lodash','util','./utils','format','[%s][dials][writeDB]\x20channel:%s\x20dialstring:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20dialstatus:%s','uniqueid','channel','calleridnum','connectedlinenum','dialstatus','request','CreateVoiceDialReport','newexten','debug','[%s][dials][newexten]'];(function(_0x32802a,_0x339b50){var _0x364b94=function(_0x3c3064){while(--_0x3c3064){_0x32802a['push'](_0x32802a['shift']());}};_0x364b94(++_0x339b50);}(_0xa1e9,0x117));var _0x9a1e=function(_0x475ace,_0x42d817){_0x475ace=_0x475ace-0x0;var _0xaa85a5=_0xa1e9[_0x475ace];return _0xaa85a5;};'use strict';var _=require(_0x9a1e('0x0'));var util=require(_0x9a1e('0x1'));var utils=require(_0x9a1e('0x2'));var dials={};function writeDB(_0xa5f418){utils['info'](util[_0x9a1e('0x3')](_0x9a1e('0x4'),_0xa5f418[_0x9a1e('0x5')],_0xa5f418[_0x9a1e('0x6')],_0xa5f418['dialstring'],_0xa5f418[_0x9a1e('0x7')],_0xa5f418[_0x9a1e('0x8')],_0xa5f418[_0x9a1e('0x9')]));utils[_0x9a1e('0xa')](_0x9a1e('0xb'),_0xa5f418);delete dials[_0xa5f418[_0x9a1e('0x5')]];}exports[_0x9a1e('0xc')]=function(_0xeec555){try{utils[_0x9a1e('0xd')](util[_0x9a1e('0x3')](_0x9a1e('0xe'),_0xeec555['uniqueid']),_0xeec555);utils[_0x9a1e('0xf')](util['format'](_0x9a1e('0x10'),_0xeec555['uniqueid'],_0xeec555[_0x9a1e('0x11')],_0xeec555['appdata']));if(_0xeec555[_0x9a1e('0x11')][_0x9a1e('0x12')]()=='set'&&_[_0x9a1e('0x13')](_0xeec555[_0x9a1e('0x14')][_0x9a1e('0x12')](),'cdr(routeid)')){var _0x1ebb06=_0xeec555['appdata']['split']('=');dials[_0xeec555[_0x9a1e('0x5')]]={'routeId':_0x1ebb06[0x1]};}}catch(_0x4d769b){utils[_0x9a1e('0x15')](util['format'](_0x9a1e('0xe'),_0xeec555[_0x9a1e('0x5')]),_0x4d769b);}};exports[_0x9a1e('0x16')]=function(_0x44d7ea){try{utils['debug'](util[_0x9a1e('0x3')]('[%s][dials][varset]',_0x44d7ea[_0x9a1e('0x5')]),_0x44d7ea);if(!_[_0x9a1e('0x17')](_0x44d7ea[_0x9a1e('0x18')][_0x9a1e('0x19')])){utils[_0x9a1e('0xf')](util['format'](_0x9a1e('0x1a'),_0x44d7ea[_0x9a1e('0x5')],_0x44d7ea[_0x9a1e('0x1b')]));dials[_0x44d7ea[_0x9a1e('0x5')]]={'routeId':_0x44d7ea[_0x9a1e('0x1b')]};}}catch(_0x297905){utils[_0x9a1e('0x15')](util['format']('[%s][dials][varset]',_0x44d7ea[_0x9a1e('0x5')]),_0x297905);}};exports['dialbegin']=function(_0x43ffde){try{if(!_[_0x9a1e('0x17')](dials[_0x43ffde[_0x9a1e('0x5')]])){utils[_0x9a1e('0xd')](util[_0x9a1e('0x3')](_0x9a1e('0x1c'),_0x43ffde[_0x9a1e('0x5')]),_0x43ffde);dials[_0x43ffde[_0x9a1e('0x5')]]=_[_0x9a1e('0x1d')](dials[_0x43ffde['uniqueid']],_0x43ffde);dials[_0x43ffde[_0x9a1e('0x5')]][_0x9a1e('0x1e')]=utils[_0x9a1e('0x1f')]();dials[_0x43ffde['uniqueid']][_0x9a1e('0x20')]=_0x9a1e('0x21');utils[_0x9a1e('0xf')](util[_0x9a1e('0x3')]('[%s][dials][hangup]\x20starttime:%s\x20lastevent:called',_0x43ffde[_0x9a1e('0x5')],dials[_0x43ffde[_0x9a1e('0x5')]]['starttime']));}}catch(_0x2ab6f3){utils[_0x9a1e('0x15')](util[_0x9a1e('0x3')](_0x9a1e('0x1c'),_0x43ffde[_0x9a1e('0x5')]),_0x2ab6f3);}};exports[_0x9a1e('0x22')]=function(_0x5edbbc){try{if(!_[_0x9a1e('0x17')](dials[_0x5edbbc[_0x9a1e('0x5')]])){utils[_0x9a1e('0xd')](util[_0x9a1e('0x3')](_0x9a1e('0x23'),_0x5edbbc[_0x9a1e('0x5')]),_0x5edbbc);dials[_0x5edbbc[_0x9a1e('0x5')]][_0x9a1e('0x9')]=_0x5edbbc[_0x9a1e('0x9')];if(_0x5edbbc[_0x9a1e('0x9')]=='ANSWER'){dials[_0x5edbbc[_0x9a1e('0x5')]]=_[_0x9a1e('0x1d')](dials[_0x5edbbc[_0x9a1e('0x5')]],_0x5edbbc);dials[_0x5edbbc[_0x9a1e('0x5')]][_0x9a1e('0x24')]=utils['now']();dials[_0x5edbbc[_0x9a1e('0x5')]][_0x9a1e('0x20')]=_0x9a1e('0x25');utils[_0x9a1e('0xf')](util[_0x9a1e('0x3')]('[%s][dials][dialend]\x20dialstatus:%s\x20answertime:%s\x20lastevent:connect',_0x5edbbc['uniqueid'],_0x5edbbc[_0x9a1e('0x9')],dials[_0x5edbbc[_0x9a1e('0x5')]]['answertime']));}else{utils[_0x9a1e('0xf')](util['format'](_0x9a1e('0x26'),_0x5edbbc[_0x9a1e('0x5')],_0x5edbbc[_0x9a1e('0x9')]));}}}catch(_0x30862e){utils[_0x9a1e('0x15')](util['format'](_0x9a1e('0x23'),_0x5edbbc[_0x9a1e('0x5')]),_0x30862e);}};exports[_0x9a1e('0x27')]=function(_0x454d23){try{if(!_['isNil'](dials[_0x454d23['uniqueid']])){utils['debug'](util['format'](_0x9a1e('0x28'),_0x454d23['uniqueid']),_0x454d23);utils[_0x9a1e('0xf')](util[_0x9a1e('0x3')](_0x9a1e('0x29'),_0x454d23[_0x9a1e('0x5')],_0x454d23[_0x9a1e('0x7')],_0x454d23[_0x9a1e('0x2a')],_0x454d23[_0x9a1e('0x2b')]));dials[_0x454d23[_0x9a1e('0x5')]]=_['assign'](dials[_0x454d23['uniqueid']],{'endtime':utils[_0x9a1e('0x1f')](),'lastevent':'complete'});dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x2c')]=utils[_0x9a1e('0x2d')](dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x2e')],dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x1e')]);dials[_0x454d23['uniqueid']][_0x9a1e('0x2f')]=utils['diffTime'](dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x24')]||dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x2e')],dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x1e')]);dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x30')]=dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x24')]?utils[_0x9a1e('0x2d')](dials[_0x454d23[_0x9a1e('0x5')]]['endtime'],dials[_0x454d23[_0x9a1e('0x5')]][_0x9a1e('0x24')]):0x0;writeDB(dials[_0x454d23['uniqueid']]);}}catch(_0x2c6dc0){utils[_0x9a1e('0x15')](util[_0x9a1e('0x3')](_0x9a1e('0x28'),_0x454d23[_0x9a1e('0x5')]),_0x2c6dc0);}};