Built motion from commit 775e2a94.|2.6.3
[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 _0xdd95=['answertime','hangup','[%s][dials][hangup]','calleridname','complete','duration','diffTime','endtime','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','debug','[%s][dials][newexten]','application','appdata','set','startsWith','toLowerCase','cdr(routeid)','split','varset','[%s][dials][varset]','isNil','outboundrouteid','value','dialbegin','assign','starttime','now','lastevent','called','[%s][dials][hangup]\x20starttime:%s\x20lastevent:called','error','[%s][dials][dialbegin]','[%s][dials][dialend]','ANSWER','[%s][dials][dialend]\x20dialstatus:%s\x20answertime:%s\x20lastevent:connect'];(function(_0x15fd74,_0x3d4c70){var _0xc035de=function(_0x372c00){while(--_0x372c00){_0x15fd74['push'](_0x15fd74['shift']());}};_0xc035de(++_0x3d4c70);}(_0xdd95,0x159));var _0x5dd9=function(_0x26c323,_0x559fa7){_0x26c323=_0x26c323-0x0;var _0xaa4f94=_0xdd95[_0x26c323];return _0xaa4f94;};'use strict';var _=require(_0x5dd9('0x0'));var util=require(_0x5dd9('0x1'));var utils=require('./utils');var dials={};function writeDB(_0x486c8d){utils[_0x5dd9('0x2')](util[_0x5dd9('0x3')](_0x5dd9('0x4'),_0x486c8d['uniqueid'],_0x486c8d[_0x5dd9('0x5')],_0x486c8d[_0x5dd9('0x6')],_0x486c8d[_0x5dd9('0x7')],_0x486c8d[_0x5dd9('0x8')],_0x486c8d[_0x5dd9('0x9')]));utils[_0x5dd9('0xa')](_0x5dd9('0xb'),_0x486c8d);delete dials[_0x486c8d[_0x5dd9('0xc')]];}exports['newexten']=function(_0x28da42){try{utils[_0x5dd9('0xd')](util[_0x5dd9('0x3')](_0x5dd9('0xe'),_0x28da42[_0x5dd9('0xc')]),_0x28da42);utils[_0x5dd9('0x2')](util['format']('[%s][dials][newexten]\x20application:%s\x20appdata:%s',_0x28da42[_0x5dd9('0xc')],_0x28da42[_0x5dd9('0xf')],_0x28da42[_0x5dd9('0x10')]));if(_0x28da42[_0x5dd9('0xf')]['toLowerCase']()==_0x5dd9('0x11')&&_[_0x5dd9('0x12')](_0x28da42['appdata'][_0x5dd9('0x13')](),_0x5dd9('0x14'))){var _0x1b7709=_0x28da42[_0x5dd9('0x10')][_0x5dd9('0x15')]('=');dials[_0x28da42[_0x5dd9('0xc')]]={'routeId':_0x1b7709[0x1]};}}catch(_0x124646){utils['error'](util[_0x5dd9('0x3')]('[%s][dials][newexten]',_0x28da42[_0x5dd9('0xc')]),_0x124646);}};exports[_0x5dd9('0x16')]=function(_0x199763){try{utils[_0x5dd9('0xd')](util[_0x5dd9('0x3')](_0x5dd9('0x17'),_0x199763[_0x5dd9('0xc')]),_0x199763);if(!_[_0x5dd9('0x18')](_0x199763['variable'][_0x5dd9('0x19')])){utils['info'](util[_0x5dd9('0x3')]('[%s][dials][varset]\x20variable:outboundrouteid\x20value:%s',_0x199763[_0x5dd9('0xc')],_0x199763[_0x5dd9('0x1a')]));dials[_0x199763['uniqueid']]={'routeId':_0x199763['value']};}}catch(_0x3966a6){utils['error'](util[_0x5dd9('0x3')](_0x5dd9('0x17'),_0x199763[_0x5dd9('0xc')]),_0x3966a6);}};exports[_0x5dd9('0x1b')]=function(_0x2111e1){try{if(!_[_0x5dd9('0x18')](dials[_0x2111e1['uniqueid']])){utils['debug'](util[_0x5dd9('0x3')]('[%s][dials][dialbegin]',_0x2111e1[_0x5dd9('0xc')]),_0x2111e1);dials[_0x2111e1[_0x5dd9('0xc')]]=_[_0x5dd9('0x1c')](dials[_0x2111e1[_0x5dd9('0xc')]],_0x2111e1);dials[_0x2111e1[_0x5dd9('0xc')]][_0x5dd9('0x1d')]=utils[_0x5dd9('0x1e')]();dials[_0x2111e1['uniqueid']][_0x5dd9('0x1f')]=_0x5dd9('0x20');utils[_0x5dd9('0x2')](util[_0x5dd9('0x3')](_0x5dd9('0x21'),_0x2111e1[_0x5dd9('0xc')],dials[_0x2111e1[_0x5dd9('0xc')]][_0x5dd9('0x1d')]));}}catch(_0x147737){utils[_0x5dd9('0x22')](util[_0x5dd9('0x3')](_0x5dd9('0x23'),_0x2111e1[_0x5dd9('0xc')]),_0x147737);}};exports['dialend']=function(_0x15fd57){try{if(!_['isNil'](dials[_0x15fd57[_0x5dd9('0xc')]])){utils[_0x5dd9('0xd')](util[_0x5dd9('0x3')](_0x5dd9('0x24'),_0x15fd57[_0x5dd9('0xc')]),_0x15fd57);dials[_0x15fd57['uniqueid']]['dialstatus']=_0x15fd57['dialstatus'];if(_0x15fd57[_0x5dd9('0x9')]==_0x5dd9('0x25')){dials[_0x15fd57[_0x5dd9('0xc')]]=_[_0x5dd9('0x1c')](dials[_0x15fd57['uniqueid']],_0x15fd57);dials[_0x15fd57['uniqueid']]['answertime']=utils[_0x5dd9('0x1e')]();dials[_0x15fd57[_0x5dd9('0xc')]]['lastevent']='connect';utils[_0x5dd9('0x2')](util[_0x5dd9('0x3')](_0x5dd9('0x26'),_0x15fd57['uniqueid'],_0x15fd57['dialstatus'],dials[_0x15fd57[_0x5dd9('0xc')]][_0x5dd9('0x27')]));}else{utils[_0x5dd9('0x2')](util['format']('[%s][dials][dialend]\x20dialstatus:%s',_0x15fd57[_0x5dd9('0xc')],_0x15fd57[_0x5dd9('0x9')]));}}}catch(_0x380f6e){utils[_0x5dd9('0x22')](util[_0x5dd9('0x3')]('[%s][dials][dialend]',_0x15fd57[_0x5dd9('0xc')]),_0x380f6e);}};exports[_0x5dd9('0x28')]=function(_0x571ece){try{if(!_[_0x5dd9('0x18')](dials[_0x571ece[_0x5dd9('0xc')]])){utils[_0x5dd9('0xd')](util[_0x5dd9('0x3')](_0x5dd9('0x29'),_0x571ece[_0x5dd9('0xc')]),_0x571ece);utils[_0x5dd9('0x2')](util[_0x5dd9('0x3')]('[%s][dials][hangup]\x20calleridnum:%s\x20calleridname:%s\x20lastevent:complete\x20reason:%s',_0x571ece[_0x5dd9('0xc')],_0x571ece[_0x5dd9('0x7')],_0x571ece[_0x5dd9('0x2a')],_0x571ece['cause-txt']));dials[_0x571ece[_0x5dd9('0xc')]]=_[_0x5dd9('0x1c')](dials[_0x571ece[_0x5dd9('0xc')]],{'endtime':utils[_0x5dd9('0x1e')](),'lastevent':_0x5dd9('0x2b')});dials[_0x571ece[_0x5dd9('0xc')]][_0x5dd9('0x2c')]=utils[_0x5dd9('0x2d')](dials[_0x571ece[_0x5dd9('0xc')]][_0x5dd9('0x2e')],dials[_0x571ece['uniqueid']][_0x5dd9('0x1d')]);dials[_0x571ece[_0x5dd9('0xc')]]['holdtime']=utils['diffTime'](dials[_0x571ece[_0x5dd9('0xc')]][_0x5dd9('0x27')]||dials[_0x571ece['uniqueid']][_0x5dd9('0x2e')],dials[_0x571ece[_0x5dd9('0xc')]][_0x5dd9('0x1d')]);dials[_0x571ece[_0x5dd9('0xc')]][_0x5dd9('0x2f')]=dials[_0x571ece[_0x5dd9('0xc')]][_0x5dd9('0x27')]?utils[_0x5dd9('0x2d')](dials[_0x571ece[_0x5dd9('0xc')]]['endtime'],dials[_0x571ece['uniqueid']][_0x5dd9('0x27')]):0x0;writeDB(dials[_0x571ece[_0x5dd9('0xc')]]);}}catch(_0x6f3ac1){utils[_0x5dd9('0x22')](util[_0x5dd9('0x3')](_0x5dd9('0x29'),_0x571ece['uniqueid']),_0x6f3ac1);}};