Built motion from commit 14588770.|2.5.38
[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 _0x6fff=['[%s][dials][newexten]','application','toLowerCase','startsWith','appdata','cdr(routeid)','split','error','varset','[%s][dials][varset]','isNil','variable','[%s][dials][varset]\x20variable:outboundrouteid\x20value:%s','value','dialbegin','[%s][dials][dialbegin]','assign','now','lastevent','called','dialend','[%s][dials][dialend]','ANSWER','answertime','connect','[%s][dials][dialend]\x20dialstatus:%s\x20answertime:%s\x20lastevent:connect','[%s][dials][hangup]','[%s][dials][hangup]\x20calleridnum:%s\x20calleridname:%s\x20lastevent:complete\x20reason:%s','calleridname','cause-txt','complete','duration','diffTime','endtime','starttime','holdtime','billableseconds','lodash','util','info','format','[%s][dials][writeDB]\x20channel:%s\x20dialstring:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20dialstatus:%s','channel','dialstring','calleridnum','connectedlinenum','dialstatus','request','CreateVoiceDialReport','uniqueid','newexten','debug'];(function(_0x5ecde8,_0x534fb2){var _0x527523=function(_0x4952e6){while(--_0x4952e6){_0x5ecde8['push'](_0x5ecde8['shift']());}};_0x527523(++_0x534fb2);}(_0x6fff,0xc1));var _0xf6ff=function(_0x143a25,_0x37d7f5){_0x143a25=_0x143a25-0x0;var _0x326bb9=_0x6fff[_0x143a25];return _0x326bb9;};'use strict';var _=require(_0xf6ff('0x0'));var util=require(_0xf6ff('0x1'));var utils=require('./utils');var dials={};function writeDB(_0x526c3f){utils[_0xf6ff('0x2')](util[_0xf6ff('0x3')](_0xf6ff('0x4'),_0x526c3f['uniqueid'],_0x526c3f[_0xf6ff('0x5')],_0x526c3f[_0xf6ff('0x6')],_0x526c3f[_0xf6ff('0x7')],_0x526c3f[_0xf6ff('0x8')],_0x526c3f[_0xf6ff('0x9')]));utils[_0xf6ff('0xa')](_0xf6ff('0xb'),_0x526c3f);delete dials[_0x526c3f[_0xf6ff('0xc')]];}exports[_0xf6ff('0xd')]=function(_0x511546){try{utils[_0xf6ff('0xe')](util[_0xf6ff('0x3')](_0xf6ff('0xf'),_0x511546[_0xf6ff('0xc')]),_0x511546);utils[_0xf6ff('0x2')](util['format']('[%s][dials][newexten]\x20application:%s\x20appdata:%s',_0x511546[_0xf6ff('0xc')],_0x511546[_0xf6ff('0x10')],_0x511546['appdata']));if(_0x511546[_0xf6ff('0x10')][_0xf6ff('0x11')]()=='set'&&_[_0xf6ff('0x12')](_0x511546[_0xf6ff('0x13')][_0xf6ff('0x11')](),_0xf6ff('0x14'))){var _0x10767e=_0x511546[_0xf6ff('0x13')][_0xf6ff('0x15')]('=');dials[_0x511546['uniqueid']]={'routeId':_0x10767e[0x1]};}}catch(_0x5b341b){utils[_0xf6ff('0x16')](util[_0xf6ff('0x3')](_0xf6ff('0xf'),_0x511546['uniqueid']),_0x5b341b);}};exports[_0xf6ff('0x17')]=function(_0x48900e){try{utils[_0xf6ff('0xe')](util['format'](_0xf6ff('0x18'),_0x48900e[_0xf6ff('0xc')]),_0x48900e);if(!_[_0xf6ff('0x19')](_0x48900e[_0xf6ff('0x1a')]['outboundrouteid'])){utils['info'](util[_0xf6ff('0x3')](_0xf6ff('0x1b'),_0x48900e[_0xf6ff('0xc')],_0x48900e[_0xf6ff('0x1c')]));dials[_0x48900e[_0xf6ff('0xc')]]={'routeId':_0x48900e[_0xf6ff('0x1c')]};}}catch(_0x3ce5f5){utils[_0xf6ff('0x16')](util[_0xf6ff('0x3')](_0xf6ff('0x18'),_0x48900e['uniqueid']),_0x3ce5f5);}};exports[_0xf6ff('0x1d')]=function(_0x58104b){try{if(!_[_0xf6ff('0x19')](dials[_0x58104b['uniqueid']])){utils[_0xf6ff('0xe')](util['format'](_0xf6ff('0x1e'),_0x58104b[_0xf6ff('0xc')]),_0x58104b);dials[_0x58104b['uniqueid']]=_[_0xf6ff('0x1f')](dials[_0x58104b[_0xf6ff('0xc')]],_0x58104b);dials[_0x58104b[_0xf6ff('0xc')]]['starttime']=utils[_0xf6ff('0x20')]();dials[_0x58104b[_0xf6ff('0xc')]][_0xf6ff('0x21')]=_0xf6ff('0x22');utils[_0xf6ff('0x2')](util[_0xf6ff('0x3')]('[%s][dials][hangup]\x20starttime:%s\x20lastevent:called',_0x58104b['uniqueid'],dials[_0x58104b[_0xf6ff('0xc')]]['starttime']));}}catch(_0x397aa3){utils[_0xf6ff('0x16')](util[_0xf6ff('0x3')](_0xf6ff('0x1e'),_0x58104b[_0xf6ff('0xc')]),_0x397aa3);}};exports[_0xf6ff('0x23')]=function(_0x4e900e){try{if(!_['isNil'](dials[_0x4e900e['uniqueid']])){utils[_0xf6ff('0xe')](util[_0xf6ff('0x3')](_0xf6ff('0x24'),_0x4e900e[_0xf6ff('0xc')]),_0x4e900e);dials[_0x4e900e[_0xf6ff('0xc')]][_0xf6ff('0x9')]=_0x4e900e['dialstatus'];if(_0x4e900e['dialstatus']==_0xf6ff('0x25')){dials[_0x4e900e[_0xf6ff('0xc')]]=_[_0xf6ff('0x1f')](dials[_0x4e900e[_0xf6ff('0xc')]],_0x4e900e);dials[_0x4e900e['uniqueid']][_0xf6ff('0x26')]=utils[_0xf6ff('0x20')]();dials[_0x4e900e[_0xf6ff('0xc')]][_0xf6ff('0x21')]=_0xf6ff('0x27');utils[_0xf6ff('0x2')](util[_0xf6ff('0x3')](_0xf6ff('0x28'),_0x4e900e[_0xf6ff('0xc')],_0x4e900e['dialstatus'],dials[_0x4e900e[_0xf6ff('0xc')]][_0xf6ff('0x26')]));}else{utils[_0xf6ff('0x2')](util[_0xf6ff('0x3')]('[%s][dials][dialend]\x20dialstatus:%s',_0x4e900e[_0xf6ff('0xc')],_0x4e900e[_0xf6ff('0x9')]));}}}catch(_0x35a45b){utils['error'](util[_0xf6ff('0x3')](_0xf6ff('0x24'),_0x4e900e[_0xf6ff('0xc')]),_0x35a45b);}};exports['hangup']=function(_0x30f4c7){try{if(!_[_0xf6ff('0x19')](dials[_0x30f4c7[_0xf6ff('0xc')]])){utils['debug'](util[_0xf6ff('0x3')](_0xf6ff('0x29'),_0x30f4c7['uniqueid']),_0x30f4c7);utils[_0xf6ff('0x2')](util['format'](_0xf6ff('0x2a'),_0x30f4c7['uniqueid'],_0x30f4c7['calleridnum'],_0x30f4c7[_0xf6ff('0x2b')],_0x30f4c7[_0xf6ff('0x2c')]));dials[_0x30f4c7[_0xf6ff('0xc')]]=_[_0xf6ff('0x1f')](dials[_0x30f4c7[_0xf6ff('0xc')]],{'endtime':utils[_0xf6ff('0x20')](),'lastevent':_0xf6ff('0x2d')});dials[_0x30f4c7[_0xf6ff('0xc')]][_0xf6ff('0x2e')]=utils[_0xf6ff('0x2f')](dials[_0x30f4c7['uniqueid']][_0xf6ff('0x30')],dials[_0x30f4c7[_0xf6ff('0xc')]][_0xf6ff('0x31')]);dials[_0x30f4c7[_0xf6ff('0xc')]][_0xf6ff('0x32')]=utils[_0xf6ff('0x2f')](dials[_0x30f4c7[_0xf6ff('0xc')]]['answertime']||dials[_0x30f4c7[_0xf6ff('0xc')]][_0xf6ff('0x30')],dials[_0x30f4c7[_0xf6ff('0xc')]][_0xf6ff('0x31')]);dials[_0x30f4c7[_0xf6ff('0xc')]][_0xf6ff('0x33')]=dials[_0x30f4c7[_0xf6ff('0xc')]][_0xf6ff('0x26')]?utils[_0xf6ff('0x2f')](dials[_0x30f4c7[_0xf6ff('0xc')]]['endtime'],dials[_0x30f4c7[_0xf6ff('0xc')]][_0xf6ff('0x26')]):0x0;writeDB(dials[_0x30f4c7['uniqueid']]);}}catch(_0x368425){utils[_0xf6ff('0x16')](util[_0xf6ff('0x3')](_0xf6ff('0x29'),_0x30f4c7['uniqueid']),_0x368425);}};