Built motion from commit 9d0783e6.|2.6.13
[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 _0x834e=['toLowerCase','startsWith','cdr(routeid)','error','varset','debug','[%s][dials][varset]','variable','outboundrouteid','[%s][dials][varset]\x20variable:outboundrouteid\x20value:%s','value','isNil','assign','starttime','now','lastevent','called','[%s][dials][hangup]\x20starttime:%s\x20lastevent:called','[%s][dials][dialbegin]','dialend','[%s][dials][dialend]','dialstatus','ANSWER','answertime','connect','[%s][dials][dialend]\x20dialstatus:%s\x20answertime:%s\x20lastevent:connect','[%s][dials][dialend]\x20dialstatus:%s','hangup','[%s][dials][hangup]','[%s][dials][hangup]\x20calleridnum:%s\x20calleridname:%s\x20lastevent:complete\x20reason:%s','calleridname','complete','diffTime','endtime','holdtime','billableseconds','lodash','util','./utils','info','format','[%s][dials][writeDB]\x20channel:%s\x20dialstring:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20dialstatus:%s','uniqueid','channel','dialstring','calleridnum','connectedlinenum','request','CreateVoiceDialReport','newexten','[%s][dials][newexten]','appdata','application'];(function(_0x251e8c,_0x277c33){var _0x1e0c1d=function(_0x20b89c){while(--_0x20b89c){_0x251e8c['push'](_0x251e8c['shift']());}};_0x1e0c1d(++_0x277c33);}(_0x834e,0x162));var _0xe834=function(_0x38428c,_0x5575c1){_0x38428c=_0x38428c-0x0;var _0x4466e0=_0x834e[_0x38428c];return _0x4466e0;};'use strict';var _=require(_0xe834('0x0'));var util=require(_0xe834('0x1'));var utils=require(_0xe834('0x2'));var dials={};function writeDB(_0x2c49f4){utils[_0xe834('0x3')](util[_0xe834('0x4')](_0xe834('0x5'),_0x2c49f4[_0xe834('0x6')],_0x2c49f4[_0xe834('0x7')],_0x2c49f4[_0xe834('0x8')],_0x2c49f4[_0xe834('0x9')],_0x2c49f4[_0xe834('0xa')],_0x2c49f4['dialstatus']));utils[_0xe834('0xb')](_0xe834('0xc'),_0x2c49f4);delete dials[_0x2c49f4[_0xe834('0x6')]];}exports[_0xe834('0xd')]=function(_0x529415){try{utils['debug'](util[_0xe834('0x4')](_0xe834('0xe'),_0x529415[_0xe834('0x6')]),_0x529415);utils[_0xe834('0x3')](util['format']('[%s][dials][newexten]\x20application:%s\x20appdata:%s',_0x529415[_0xe834('0x6')],_0x529415['application'],_0x529415[_0xe834('0xf')]));if(_0x529415[_0xe834('0x10')][_0xe834('0x11')]()=='set'&&_[_0xe834('0x12')](_0x529415['appdata'][_0xe834('0x11')](),_0xe834('0x13'))){var _0x4d283e=_0x529415['appdata']['split']('=');dials[_0x529415[_0xe834('0x6')]]={'routeId':_0x4d283e[0x1]};}}catch(_0x366c79){utils[_0xe834('0x14')](util[_0xe834('0x4')](_0xe834('0xe'),_0x529415[_0xe834('0x6')]),_0x366c79);}};exports[_0xe834('0x15')]=function(_0x5aa5ea){try{utils[_0xe834('0x16')](util[_0xe834('0x4')](_0xe834('0x17'),_0x5aa5ea[_0xe834('0x6')]),_0x5aa5ea);if(!_['isNil'](_0x5aa5ea[_0xe834('0x18')][_0xe834('0x19')])){utils['info'](util[_0xe834('0x4')](_0xe834('0x1a'),_0x5aa5ea[_0xe834('0x6')],_0x5aa5ea[_0xe834('0x1b')]));dials[_0x5aa5ea[_0xe834('0x6')]]={'routeId':_0x5aa5ea[_0xe834('0x1b')]};}}catch(_0x7b3d62){utils['error'](util['format'](_0xe834('0x17'),_0x5aa5ea[_0xe834('0x6')]),_0x7b3d62);}};exports['dialbegin']=function(_0x3a5951){try{if(!_[_0xe834('0x1c')](dials[_0x3a5951[_0xe834('0x6')]])){utils[_0xe834('0x16')](util[_0xe834('0x4')]('[%s][dials][dialbegin]',_0x3a5951[_0xe834('0x6')]),_0x3a5951);dials[_0x3a5951[_0xe834('0x6')]]=_[_0xe834('0x1d')](dials[_0x3a5951['uniqueid']],_0x3a5951);dials[_0x3a5951[_0xe834('0x6')]][_0xe834('0x1e')]=utils[_0xe834('0x1f')]();dials[_0x3a5951[_0xe834('0x6')]][_0xe834('0x20')]=_0xe834('0x21');utils[_0xe834('0x3')](util[_0xe834('0x4')](_0xe834('0x22'),_0x3a5951[_0xe834('0x6')],dials[_0x3a5951['uniqueid']]['starttime']));}}catch(_0x2cac85){utils['error'](util[_0xe834('0x4')](_0xe834('0x23'),_0x3a5951[_0xe834('0x6')]),_0x2cac85);}};exports[_0xe834('0x24')]=function(_0x51fbf7){try{if(!_[_0xe834('0x1c')](dials[_0x51fbf7[_0xe834('0x6')]])){utils[_0xe834('0x16')](util[_0xe834('0x4')](_0xe834('0x25'),_0x51fbf7['uniqueid']),_0x51fbf7);dials[_0x51fbf7[_0xe834('0x6')]]['dialstatus']=_0x51fbf7['dialstatus'];if(_0x51fbf7[_0xe834('0x26')]==_0xe834('0x27')){dials[_0x51fbf7[_0xe834('0x6')]]=_[_0xe834('0x1d')](dials[_0x51fbf7[_0xe834('0x6')]],_0x51fbf7);dials[_0x51fbf7['uniqueid']][_0xe834('0x28')]=utils[_0xe834('0x1f')]();dials[_0x51fbf7[_0xe834('0x6')]][_0xe834('0x20')]=_0xe834('0x29');utils['info'](util[_0xe834('0x4')](_0xe834('0x2a'),_0x51fbf7[_0xe834('0x6')],_0x51fbf7[_0xe834('0x26')],dials[_0x51fbf7[_0xe834('0x6')]][_0xe834('0x28')]));}else{utils['info'](util[_0xe834('0x4')](_0xe834('0x2b'),_0x51fbf7[_0xe834('0x6')],_0x51fbf7[_0xe834('0x26')]));}}}catch(_0x4b169c){utils[_0xe834('0x14')](util[_0xe834('0x4')]('[%s][dials][dialend]',_0x51fbf7[_0xe834('0x6')]),_0x4b169c);}};exports[_0xe834('0x2c')]=function(_0x470c34){try{if(!_[_0xe834('0x1c')](dials[_0x470c34[_0xe834('0x6')]])){utils['debug'](util['format'](_0xe834('0x2d'),_0x470c34[_0xe834('0x6')]),_0x470c34);utils[_0xe834('0x3')](util[_0xe834('0x4')](_0xe834('0x2e'),_0x470c34['uniqueid'],_0x470c34[_0xe834('0x9')],_0x470c34[_0xe834('0x2f')],_0x470c34['cause-txt']));dials[_0x470c34['uniqueid']]=_['assign'](dials[_0x470c34['uniqueid']],{'endtime':utils[_0xe834('0x1f')](),'lastevent':_0xe834('0x30')});dials[_0x470c34[_0xe834('0x6')]]['duration']=utils[_0xe834('0x31')](dials[_0x470c34[_0xe834('0x6')]][_0xe834('0x32')],dials[_0x470c34['uniqueid']][_0xe834('0x1e')]);dials[_0x470c34[_0xe834('0x6')]][_0xe834('0x33')]=utils['diffTime'](dials[_0x470c34[_0xe834('0x6')]][_0xe834('0x28')]||dials[_0x470c34['uniqueid']][_0xe834('0x32')],dials[_0x470c34[_0xe834('0x6')]][_0xe834('0x1e')]);dials[_0x470c34[_0xe834('0x6')]][_0xe834('0x34')]=dials[_0x470c34[_0xe834('0x6')]]['answertime']?utils['diffTime'](dials[_0x470c34[_0xe834('0x6')]]['endtime'],dials[_0x470c34['uniqueid']]['answertime']):0x0;writeDB(dials[_0x470c34[_0xe834('0x6')]]);}}catch(_0xda6d59){utils['error'](util[_0xe834('0x4')]('[%s][dials][hangup]',_0x470c34[_0xe834('0x6')]),_0xda6d59);}};