d07206b9c436f3ab7b146212158a52bdbb274511
[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 _0xe350=['util','./utils','format','[%s][dials][writeDB]\x20channel:%s\x20dialstring:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20dialstatus:%s','uniqueid','dialstring','calleridnum','connectedlinenum','dialstatus','request','CreateVoiceDialReport','newexten','debug','[%s][dials][newexten]','info','[%s][dials][newexten]\x20application:%s\x20appdata:%s','appdata','toLowerCase','startsWith','split','varset','[%s][dials][varset]','isNil','outboundrouteid','value','error','dialbegin','starttime','lastevent','called','[%s][dials][dialbegin]','dialend','[%s][dials][dialend]','ANSWER','assign','answertime','now','connect','[%s][dials][dialend]\x20dialstatus:%s\x20answertime:%s\x20lastevent:connect','[%s][dials][dialend]\x20dialstatus:%s','hangup','[%s][dials][hangup]','calleridname','complete','duration','endtime','diffTime','billableseconds','lodash'];(function(_0x3c52e6,_0x2834ab){var _0x23977e=function(_0x507e19){while(--_0x507e19){_0x3c52e6['push'](_0x3c52e6['shift']());}};_0x23977e(++_0x2834ab);}(_0xe350,0xc3));var _0x0e35=function(_0xcd641,_0x49bb95){_0xcd641=_0xcd641-0x0;var _0x464f70=_0xe350[_0xcd641];return _0x464f70;};'use strict';var _=require(_0x0e35('0x0'));var util=require(_0x0e35('0x1'));var utils=require(_0x0e35('0x2'));var dials={};function writeDB(_0x59d4bd){utils['info'](util[_0x0e35('0x3')](_0x0e35('0x4'),_0x59d4bd[_0x0e35('0x5')],_0x59d4bd['channel'],_0x59d4bd[_0x0e35('0x6')],_0x59d4bd[_0x0e35('0x7')],_0x59d4bd[_0x0e35('0x8')],_0x59d4bd[_0x0e35('0x9')]));utils[_0x0e35('0xa')](_0x0e35('0xb'),_0x59d4bd);delete dials[_0x59d4bd['uniqueid']];}exports[_0x0e35('0xc')]=function(_0x1eb4b0){try{utils[_0x0e35('0xd')](util[_0x0e35('0x3')](_0x0e35('0xe'),_0x1eb4b0[_0x0e35('0x5')]),_0x1eb4b0);utils[_0x0e35('0xf')](util[_0x0e35('0x3')](_0x0e35('0x10'),_0x1eb4b0[_0x0e35('0x5')],_0x1eb4b0['application'],_0x1eb4b0[_0x0e35('0x11')]));if(_0x1eb4b0['application'][_0x0e35('0x12')]()=='set'&&_[_0x0e35('0x13')](_0x1eb4b0[_0x0e35('0x11')][_0x0e35('0x12')](),'cdr(routeid)')){var _0xb0a681=_0x1eb4b0['appdata'][_0x0e35('0x14')]('=');dials[_0x1eb4b0[_0x0e35('0x5')]]={'routeId':_0xb0a681[0x1]};}}catch(_0x491351){utils['error'](util[_0x0e35('0x3')](_0x0e35('0xe'),_0x1eb4b0[_0x0e35('0x5')]),_0x491351);}};exports[_0x0e35('0x15')]=function(_0x20f90e){try{utils[_0x0e35('0xd')](util[_0x0e35('0x3')](_0x0e35('0x16'),_0x20f90e[_0x0e35('0x5')]),_0x20f90e);if(!_[_0x0e35('0x17')](_0x20f90e['variable'][_0x0e35('0x18')])){utils[_0x0e35('0xf')](util[_0x0e35('0x3')]('[%s][dials][varset]\x20variable:outboundrouteid\x20value:%s',_0x20f90e[_0x0e35('0x5')],_0x20f90e[_0x0e35('0x19')]));dials[_0x20f90e[_0x0e35('0x5')]]={'routeId':_0x20f90e[_0x0e35('0x19')]};}}catch(_0x16e6cf){utils[_0x0e35('0x1a')](util['format']('[%s][dials][varset]',_0x20f90e[_0x0e35('0x5')]),_0x16e6cf);}};exports[_0x0e35('0x1b')]=function(_0x23e019){try{if(!_[_0x0e35('0x17')](dials[_0x23e019['uniqueid']])){utils[_0x0e35('0xd')](util['format']('[%s][dials][dialbegin]',_0x23e019[_0x0e35('0x5')]),_0x23e019);dials[_0x23e019['uniqueid']]=_['assign'](dials[_0x23e019[_0x0e35('0x5')]],_0x23e019);dials[_0x23e019[_0x0e35('0x5')]][_0x0e35('0x1c')]=utils['now']();dials[_0x23e019[_0x0e35('0x5')]][_0x0e35('0x1d')]=_0x0e35('0x1e');utils[_0x0e35('0xf')](util['format']('[%s][dials][hangup]\x20starttime:%s\x20lastevent:called',_0x23e019[_0x0e35('0x5')],dials[_0x23e019[_0x0e35('0x5')]][_0x0e35('0x1c')]));}}catch(_0x2d5d26){utils['error'](util[_0x0e35('0x3')](_0x0e35('0x1f'),_0x23e019[_0x0e35('0x5')]),_0x2d5d26);}};exports[_0x0e35('0x20')]=function(_0x55015c){try{if(!_['isNil'](dials[_0x55015c[_0x0e35('0x5')]])){utils['debug'](util[_0x0e35('0x3')](_0x0e35('0x21'),_0x55015c['uniqueid']),_0x55015c);dials[_0x55015c['uniqueid']]['dialstatus']=_0x55015c['dialstatus'];if(_0x55015c[_0x0e35('0x9')]==_0x0e35('0x22')){dials[_0x55015c[_0x0e35('0x5')]]=_[_0x0e35('0x23')](dials[_0x55015c[_0x0e35('0x5')]],_0x55015c);dials[_0x55015c[_0x0e35('0x5')]][_0x0e35('0x24')]=utils[_0x0e35('0x25')]();dials[_0x55015c[_0x0e35('0x5')]][_0x0e35('0x1d')]=_0x0e35('0x26');utils[_0x0e35('0xf')](util[_0x0e35('0x3')](_0x0e35('0x27'),_0x55015c[_0x0e35('0x5')],_0x55015c[_0x0e35('0x9')],dials[_0x55015c[_0x0e35('0x5')]][_0x0e35('0x24')]));}else{utils[_0x0e35('0xf')](util[_0x0e35('0x3')](_0x0e35('0x28'),_0x55015c[_0x0e35('0x5')],_0x55015c[_0x0e35('0x9')]));}}}catch(_0x20ad21){utils['error'](util['format'](_0x0e35('0x21'),_0x55015c[_0x0e35('0x5')]),_0x20ad21);}};exports[_0x0e35('0x29')]=function(_0x1f3bbf){try{if(!_[_0x0e35('0x17')](dials[_0x1f3bbf[_0x0e35('0x5')]])){utils[_0x0e35('0xd')](util['format'](_0x0e35('0x2a'),_0x1f3bbf[_0x0e35('0x5')]),_0x1f3bbf);utils[_0x0e35('0xf')](util[_0x0e35('0x3')]('[%s][dials][hangup]\x20calleridnum:%s\x20calleridname:%s\x20lastevent:complete\x20reason:%s',_0x1f3bbf[_0x0e35('0x5')],_0x1f3bbf['calleridnum'],_0x1f3bbf[_0x0e35('0x2b')],_0x1f3bbf['cause-txt']));dials[_0x1f3bbf[_0x0e35('0x5')]]=_[_0x0e35('0x23')](dials[_0x1f3bbf[_0x0e35('0x5')]],{'endtime':utils[_0x0e35('0x25')](),'lastevent':_0x0e35('0x2c')});dials[_0x1f3bbf['uniqueid']][_0x0e35('0x2d')]=utils['diffTime'](dials[_0x1f3bbf[_0x0e35('0x5')]][_0x0e35('0x2e')],dials[_0x1f3bbf[_0x0e35('0x5')]][_0x0e35('0x1c')]);dials[_0x1f3bbf[_0x0e35('0x5')]]['holdtime']=utils[_0x0e35('0x2f')](dials[_0x1f3bbf[_0x0e35('0x5')]][_0x0e35('0x24')]||dials[_0x1f3bbf[_0x0e35('0x5')]][_0x0e35('0x2e')],dials[_0x1f3bbf[_0x0e35('0x5')]][_0x0e35('0x1c')]);dials[_0x1f3bbf[_0x0e35('0x5')]][_0x0e35('0x30')]=dials[_0x1f3bbf['uniqueid']][_0x0e35('0x24')]?utils['diffTime'](dials[_0x1f3bbf['uniqueid']][_0x0e35('0x2e')],dials[_0x1f3bbf[_0x0e35('0x5')]][_0x0e35('0x24')]):0x0;writeDB(dials[_0x1f3bbf[_0x0e35('0x5')]]);}}catch(_0x23b442){utils[_0x0e35('0x1a')](util[_0x0e35('0x3')](_0x0e35('0x2a'),_0x1f3bbf[_0x0e35('0x5')]),_0x23b442);}};