897278c8f0e6557e56250a9acdb3e9c44ae59a85
[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 _0xdc7e=['ANSWER','answertime','hangup','complete','diffTime','endtime','holdtime','billableseconds','lodash','util','info','format','DIAL|%s|%s|%s|%s|%s|%s','uniqueid','dialstring','connectedlinenum','request','CreateVoiceDialReport','application','toLowerCase','set','startsWith','appdata','cdr(routeid)','split','stack','varset','isNil','error','dialbegin','assign','starttime','now','lastevent','called','dialend','dialstatus'];(function(_0x42245d,_0x51758f){var _0x4b211a=function(_0x2634e){while(--_0x2634e){_0x42245d['push'](_0x42245d['shift']());}};_0x4b211a(++_0x51758f);}(_0xdc7e,0x1e9));var _0xedc7=function(_0x4c884a,_0x2603ae){_0x4c884a=_0x4c884a-0x0;var _0x8ffffb=_0xdc7e[_0x4c884a];return _0x8ffffb;};'use strict';var _=require(_0xedc7('0x0'));var util=require(_0xedc7('0x1'));var utils=require('./utils');var dials={};function writeDB(_0x2d67c8){utils[_0xedc7('0x2')](util[_0xedc7('0x3')](_0xedc7('0x4'),_0x2d67c8[_0xedc7('0x5')],_0x2d67c8['channel'],_0x2d67c8[_0xedc7('0x6')],_0x2d67c8['calleridnum'],_0x2d67c8[_0xedc7('0x7')],_0x2d67c8['dialstatus']));utils[_0xedc7('0x8')](_0xedc7('0x9'),_0x2d67c8);delete dials[_0x2d67c8[_0xedc7('0x5')]];}exports['newexten']=function(_0x47717e){try{if(_0x47717e[_0xedc7('0xa')][_0xedc7('0xb')]()==_0xedc7('0xc')&&_[_0xedc7('0xd')](_0x47717e[_0xedc7('0xe')][_0xedc7('0xb')](),_0xedc7('0xf'))){var _0xf8f244=_0x47717e[_0xedc7('0xe')][_0xedc7('0x10')]('=');dials[_0x47717e['uniqueid']]={'routeId':_0xf8f244[0x1]};}}catch(_0x2c91f3){utils['error'](_0x2c91f3[_0xedc7('0x11')]);}};exports[_0xedc7('0x12')]=function(_0x1e5414){try{if(!_[_0xedc7('0x13')](_0x1e5414['variable']['outboundrouteid'])){dials[_0x1e5414[_0xedc7('0x5')]]={'routeId':_0x1e5414['value']};}}catch(_0x32337e){utils[_0xedc7('0x14')](_0x32337e[_0xedc7('0x11')]);}};exports[_0xedc7('0x15')]=function(_0x3338f8){try{if(!_['isNil'](dials[_0x3338f8[_0xedc7('0x5')]])){dials[_0x3338f8[_0xedc7('0x5')]]=_[_0xedc7('0x16')](dials[_0x3338f8[_0xedc7('0x5')]],_0x3338f8);dials[_0x3338f8[_0xedc7('0x5')]][_0xedc7('0x17')]=utils[_0xedc7('0x18')]();dials[_0x3338f8['uniqueid']][_0xedc7('0x19')]=_0xedc7('0x1a');}}catch(_0x810fae){utils['error'](_0x810fae[_0xedc7('0x11')]);}};exports[_0xedc7('0x1b')]=function(_0x286853){try{if(!_[_0xedc7('0x13')](dials[_0x286853[_0xedc7('0x5')]])){dials[_0x286853[_0xedc7('0x5')]][_0xedc7('0x1c')]=_0x286853[_0xedc7('0x1c')];if(_0x286853[_0xedc7('0x1c')]==_0xedc7('0x1d')){dials[_0x286853['uniqueid']]=_[_0xedc7('0x16')](dials[_0x286853['uniqueid']],_0x286853);dials[_0x286853[_0xedc7('0x5')]][_0xedc7('0x1e')]=utils[_0xedc7('0x18')]();dials[_0x286853['uniqueid']]['lastevent']='connect';}}}catch(_0x668f57){utils[_0xedc7('0x14')](_0x668f57[_0xedc7('0x11')]);}};exports[_0xedc7('0x1f')]=function(_0x1efd9d){try{if(!_[_0xedc7('0x13')](dials[_0x1efd9d[_0xedc7('0x5')]])){dials[_0x1efd9d[_0xedc7('0x5')]]=_['assign'](dials[_0x1efd9d[_0xedc7('0x5')]],{'endtime':utils[_0xedc7('0x18')](),'lastevent':_0xedc7('0x20')});dials[_0x1efd9d[_0xedc7('0x5')]]['duration']=utils[_0xedc7('0x21')](dials[_0x1efd9d[_0xedc7('0x5')]][_0xedc7('0x22')],dials[_0x1efd9d[_0xedc7('0x5')]]['starttime']);dials[_0x1efd9d['uniqueid']][_0xedc7('0x23')]=utils[_0xedc7('0x21')](dials[_0x1efd9d[_0xedc7('0x5')]][_0xedc7('0x1e')]||dials[_0x1efd9d[_0xedc7('0x5')]][_0xedc7('0x22')],dials[_0x1efd9d[_0xedc7('0x5')]][_0xedc7('0x17')]);dials[_0x1efd9d[_0xedc7('0x5')]][_0xedc7('0x24')]=dials[_0x1efd9d['uniqueid']][_0xedc7('0x1e')]?utils[_0xedc7('0x21')](dials[_0x1efd9d[_0xedc7('0x5')]][_0xedc7('0x22')],dials[_0x1efd9d[_0xedc7('0x5')]][_0xedc7('0x1e')]):0x0;writeDB(dials[_0x1efd9d[_0xedc7('0x5')]]);}}catch(_0x366674){utils[_0xedc7('0x14')](_0x366674[_0xedc7('0x11')]);}};