e474d80802e69521c4c1531fb438f12db5f289d0
[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 _0xe361=['starttime','now','lastevent','called','stack','dialend','ANSWER','answertime','connect','hangup','duration','diffTime','endtime','holdtime','billableseconds','util','uniqueid','channel','dialstring','calleridnum','connectedlinenum','dialstatus','request','CreateVoiceDialReport','newexten','application','toLowerCase','set','appdata','cdr(routeid)','error','variable','outboundrouteid','value','dialbegin','isNil','assign'];(function(_0xee57da,_0x239ff4){var _0x435af6=function(_0x275e3d){while(--_0x275e3d){_0xee57da['push'](_0xee57da['shift']());}};_0x435af6(++_0x239ff4);}(_0xe361,0x7e));var _0x1e36=function(_0x459423,_0x3416a8){_0x459423=_0x459423-0x0;var _0x42ed14=_0xe361[_0x459423];return _0x42ed14;};'use strict';var _=require('lodash');var util=require(_0x1e36('0x0'));var utils=require('./utils');var dials={};function writeDB(_0x4ff22b){utils['info'](util['format']('DIAL|%s|%s|%s|%s|%s|%s',_0x4ff22b[_0x1e36('0x1')],_0x4ff22b[_0x1e36('0x2')],_0x4ff22b[_0x1e36('0x3')],_0x4ff22b[_0x1e36('0x4')],_0x4ff22b[_0x1e36('0x5')],_0x4ff22b[_0x1e36('0x6')]));utils[_0x1e36('0x7')](_0x1e36('0x8'),_0x4ff22b);delete dials[_0x4ff22b[_0x1e36('0x1')]];}exports[_0x1e36('0x9')]=function(_0x23f8ef){try{if(_0x23f8ef[_0x1e36('0xa')][_0x1e36('0xb')]()==_0x1e36('0xc')&&_['startsWith'](_0x23f8ef[_0x1e36('0xd')]['toLowerCase'](),_0x1e36('0xe'))){var _0x84f564=_0x23f8ef['appdata']['split']('=');dials[_0x23f8ef[_0x1e36('0x1')]]={'routeId':_0x84f564[0x1]};}}catch(_0x458f87){utils[_0x1e36('0xf')](_0x458f87['stack']);}};exports['varset']=function(_0xcb4d5c){try{if(!_['isNil'](_0xcb4d5c[_0x1e36('0x10')][_0x1e36('0x11')])){dials[_0xcb4d5c[_0x1e36('0x1')]]={'routeId':_0xcb4d5c[_0x1e36('0x12')]};}}catch(_0x22c700){utils[_0x1e36('0xf')](_0x22c700['stack']);}};exports[_0x1e36('0x13')]=function(_0x1838f4){try{if(!_[_0x1e36('0x14')](dials[_0x1838f4[_0x1e36('0x1')]])){dials[_0x1838f4[_0x1e36('0x1')]]=_[_0x1e36('0x15')](dials[_0x1838f4['uniqueid']],_0x1838f4);dials[_0x1838f4['uniqueid']][_0x1e36('0x16')]=utils[_0x1e36('0x17')]();dials[_0x1838f4[_0x1e36('0x1')]][_0x1e36('0x18')]=_0x1e36('0x19');}}catch(_0x5349fc){utils[_0x1e36('0xf')](_0x5349fc[_0x1e36('0x1a')]);}};exports[_0x1e36('0x1b')]=function(_0x43e771){try{if(!_['isNil'](dials[_0x43e771['uniqueid']])){dials[_0x43e771['uniqueid']]['dialstatus']=_0x43e771[_0x1e36('0x6')];if(_0x43e771[_0x1e36('0x6')]==_0x1e36('0x1c')){dials[_0x43e771['uniqueid']]=_[_0x1e36('0x15')](dials[_0x43e771['uniqueid']],_0x43e771);dials[_0x43e771['uniqueid']][_0x1e36('0x1d')]=utils['now']();dials[_0x43e771[_0x1e36('0x1')]][_0x1e36('0x18')]=_0x1e36('0x1e');}}}catch(_0x222ac7){utils['error'](_0x222ac7[_0x1e36('0x1a')]);}};exports[_0x1e36('0x1f')]=function(_0x5e10a1){try{if(!_[_0x1e36('0x14')](dials[_0x5e10a1[_0x1e36('0x1')]])){dials[_0x5e10a1[_0x1e36('0x1')]]=_[_0x1e36('0x15')](dials[_0x5e10a1[_0x1e36('0x1')]],{'endtime':utils[_0x1e36('0x17')](),'lastevent':'complete'});dials[_0x5e10a1[_0x1e36('0x1')]][_0x1e36('0x20')]=utils[_0x1e36('0x21')](dials[_0x5e10a1[_0x1e36('0x1')]][_0x1e36('0x22')],dials[_0x5e10a1[_0x1e36('0x1')]]['starttime']);dials[_0x5e10a1['uniqueid']][_0x1e36('0x23')]=utils['diffTime'](dials[_0x5e10a1[_0x1e36('0x1')]][_0x1e36('0x1d')]||dials[_0x5e10a1[_0x1e36('0x1')]][_0x1e36('0x22')],dials[_0x5e10a1['uniqueid']][_0x1e36('0x16')]);dials[_0x5e10a1[_0x1e36('0x1')]][_0x1e36('0x24')]=dials[_0x5e10a1[_0x1e36('0x1')]][_0x1e36('0x1d')]?utils[_0x1e36('0x21')](dials[_0x5e10a1[_0x1e36('0x1')]][_0x1e36('0x22')],dials[_0x5e10a1[_0x1e36('0x1')]][_0x1e36('0x1d')]):0x0;writeDB(dials[_0x5e10a1[_0x1e36('0x1')]]);}}catch(_0x24ac80){utils[_0x1e36('0xf')](_0x24ac80[_0x1e36('0x1a')]);}};