Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / services / xdr / recordings.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 _0x093b=['[%s][recordings][blindtransfer]\x20transferercalleridnum:%s\x20transferercalleridname:%s\x20transfereecalleridnum:%s\x20transfereecalleridname:%s','transferercalleridnum','transfereecalleridnum','transfereecalleridname','transfereruniqueid','lodash','./utils','./transfers.controller','info','format','uniqueid','blinds','transfereeuniqueid','accountcode','then','membername','name','request','CreateVoiceRecording','newchannel','debug','[%s][recordings][newchannel]','[%s][recordings][newchannel]\x20context:%s\x20exten:%s','context','exten','channel','error','newstate','isNil','[%s][recordings][newstate]\x20context:%s\x20channel:%s','channelstate','transfer','[%s][recordings][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s','linkedid','varset','variable','[%s][recordings][varset]','value','endsWith','.wav49','replace','.WAV','monitors','[%s][recordings][hangup]','[%s][recordings][hangup]\x20calleridnum:%s\x20calleridname:%s\x20reason:%s','calleridnum','calleridname','connectedlinenum','connectedlinename','outbound','forEach','clone','newexten','[%s][recordings][newexten]','[%s][recordings][newexten]\x20application:%s\x20appdata:%s','application','startsWith','appdata','toLowerCase','split','substring','lastIndexOf','queuecallerjoin','[%s][recordings][queuecallerjoin]','[%s][recordings][queuecallerjoin]\x20queue:%s','queue','blindtransfer','[%s][recordings][blindtransfer]'];(function(_0x337a4f,_0x329311){var _0x13d3d0=function(_0x2ce706){while(--_0x2ce706){_0x337a4f['push'](_0x337a4f['shift']());}};_0x13d3d0(++_0x329311);}(_0x093b,0xd1));var _0xb093=function(_0xbec8e6,_0x2841b5){_0xbec8e6=_0xbec8e6-0x0;var _0x4aa6f2=_0x093b[_0xbec8e6];return _0x4aa6f2;};'use strict';var _=require(_0xb093('0x0'));var util=require('util');var utils=require(_0xb093('0x1'));var transfers=require(_0xb093('0x2'));var recordings={};function writeDB(_0x25591e){var _0x22c4e0;utils[_0xb093('0x3')](util[_0xb093('0x4')]('[%s][recordings][writeDB]',_0x25591e[_0xb093('0x5')]));if(transfers[_0xb093('0x6')][_0x25591e['uniqueid']]){_0x22c4e0=_0x25591e[_0xb093('0x5')];_0x25591e['uniqueid']=transfers[_0xb093('0x6')][_0x25591e['uniqueid']][_0xb093('0x7')];}if(_0x25591e[_0xb093('0x8')]){utils['getUserByInternal'](_0x25591e['accountcode'])[_0xb093('0x9')](function(_0x490c58){if(_0x490c58){_0x25591e[_0xb093('0xa')]=_0x490c58[_0xb093('0xb')];_0x25591e['UserId']=_0x490c58['id'];}utils[_0xb093('0xc')](_0xb093('0xd'),_0x25591e);});}else{utils[_0xb093('0xc')](_0xb093('0xd'),_0x25591e);}if(_0x22c4e0)delete transfers[_0xb093('0x6')][_0x22c4e0];}exports[_0xb093('0xe')]=function(_0xdddfd2){try{utils[_0xb093('0xf')](util[_0xb093('0x4')](_0xb093('0x10'),_0xdddfd2[_0xb093('0x5')]),_0xdddfd2);if(_0xdddfd2[_0xb093('0x5')]==_0xdddfd2['linkedid']){utils[_0xb093('0x3')](util[_0xb093('0x4')](_0xb093('0x11'),_0xdddfd2[_0xb093('0x5')],_0xdddfd2[_0xb093('0x12')],_0xdddfd2[_0xb093('0x13')]));recordings[_0xdddfd2['uniqueid']]={'uniqueid':_0xdddfd2[_0xb093('0x5')],'accountcode':_0xdddfd2[_0xb093('0x8')],'exten':_0xdddfd2[_0xb093('0x13')],'context':_0xdddfd2[_0xb093('0x12')],'channel':_0xdddfd2[_0xb093('0x14')],'monitors':[]};}}catch(_0x333912){utils[_0xb093('0x15')](util[_0xb093('0x4')]('[%s][recordings][newchannel]',_0xdddfd2[_0xb093('0x5')]),_0x333912);}};exports[_0xb093('0x16')]=function(_0x4bfaf5){try{utils['debug'](util['format']('[%s][recordings][newstate]',_0x4bfaf5[_0xb093('0x5')]),_0x4bfaf5);if(!_[_0xb093('0x17')](recordings[_0x4bfaf5[_0xb093('0x5')]])&&_0x4bfaf5['channelstate']==0x6){utils['info'](util[_0xb093('0x4')](_0xb093('0x18'),_0x4bfaf5['uniqueid'],_0x4bfaf5[_0xb093('0x12')],_0x4bfaf5[_0xb093('0x14')]));}else if(!_[_0xb093('0x17')](recordings[_0x4bfaf5['linkedid']])&&_0x4bfaf5[_0xb093('0x19')]==0x6&&_0x4bfaf5[_0xb093('0x12')]!=_0xb093('0x1a')){utils['info'](util[_0xb093('0x4')](_0xb093('0x1b'),_0x4bfaf5[_0xb093('0x5')],_0x4bfaf5[_0xb093('0x1c')],_0x4bfaf5['context'],_0x4bfaf5[_0xb093('0x14')]));recordings[_0x4bfaf5[_0xb093('0x1c')]][_0xb093('0x8')]=_0x4bfaf5[_0xb093('0x8')];}}catch(_0x2a3a5b){utils[_0xb093('0x15')](util['format']('[%s][recordings][newstate]',_0x4bfaf5['uniqueid']),_0x2a3a5b);}};exports[_0xb093('0x1d')]=function(_0x4c3505){try{if(!_[_0xb093('0x17')](_0x4c3505[_0xb093('0x1e')])&&!_[_0xb093('0x17')](_0x4c3505[_0xb093('0x1e')]['mixmonitor_filename'])){utils['debug'](util['format'](_0xb093('0x1f'),_0x4c3505[_0xb093('0x5')]),_0x4c3505);utils[_0xb093('0x3')](util['format']('[%s][recordings][varset]\x20variable:%s\x20value:%s',_0x4c3505[_0xb093('0x5')],_0x4c3505[_0xb093('0x1e')],_0x4c3505[_0xb093('0x20')]));if(_[_0xb093('0x21')](_0x4c3505[_0xb093('0x20')],_0xb093('0x22'))){_0x4c3505[_0xb093('0x20')]=_0x4c3505[_0xb093('0x20')][_0xb093('0x23')]('.wav49',_0xb093('0x24'));}if(recordings[_0x4c3505['linkedid']]){var _0x1d18c1=_['find'](recordings[_0x4c3505[_0xb093('0x1c')]][_0xb093('0x25')],{'value':_0x4c3505[_0xb093('0x20')]});if(_[_0xb093('0x17')](_0x1d18c1)){recordings[_0x4c3505[_0xb093('0x1c')]][_0xb093('0x25')]['push']({'value':_0x4c3505['value']});}}}}catch(_0x3b1160){utils[_0xb093('0x15')](util[_0xb093('0x4')](_0xb093('0x1f'),_0x4c3505['uniqueid']),_0x3b1160);}};exports['hangup']=function(_0x4e0152){try{if(!_[_0xb093('0x17')](recordings[_0x4e0152[_0xb093('0x5')]])){utils[_0xb093('0xf')](util[_0xb093('0x4')](_0xb093('0x26'),_0x4e0152[_0xb093('0x5')]),_0x4e0152);utils['info'](util['format'](_0xb093('0x27'),_0x4e0152[_0xb093('0x5')],_0x4e0152[_0xb093('0x28')],_0x4e0152[_0xb093('0x29')],_0x4e0152['cause-txt']));recordings[_0x4e0152[_0xb093('0x5')]][_0xb093('0x28')]=_0x4e0152[_0xb093('0x28')];recordings[_0x4e0152[_0xb093('0x5')]][_0xb093('0x29')]=_0x4e0152['calleridname'];recordings[_0x4e0152['uniqueid']][_0xb093('0x2a')]=_0x4e0152['connectedlinenum'];recordings[_0x4e0152[_0xb093('0x5')]][_0xb093('0x2b')]=_0x4e0152[_0xb093('0x2b')];if(recordings[_0x4e0152[_0xb093('0x5')]]['type']==_0xb093('0x2c')&&recordings[_0x4e0152['uniqueid']]['accountcode']){recordings[_0x4e0152[_0xb093('0x5')]][_0xb093('0x2a')]=recordings[_0x4e0152[_0xb093('0x5')]][_0xb093('0x8')];recordings[_0x4e0152[_0xb093('0x5')]][_0xb093('0x2b')]='';}recordings[_0x4e0152[_0xb093('0x5')]][_0xb093('0x25')][_0xb093('0x2d')](function(_0x4804dd){var _0x2b356f=_[_0xb093('0x2e')](recordings[_0x4e0152['uniqueid']]);_0x2b356f[_0xb093('0x20')]=_0x4804dd[_0xb093('0x20')];writeDB(_0x2b356f);});delete recordings[_0x4e0152['uniqueid']];}}catch(_0x245854){utils[_0xb093('0x15')](util[_0xb093('0x4')](_0xb093('0x26'),_0x4e0152['uniqueid']),_0x245854);}};exports[_0xb093('0x2f')]=function(_0x4dde24){try{if(!_[_0xb093('0x17')](recordings[_0x4dde24[_0xb093('0x5')]])){utils['debug'](util['format'](_0xb093('0x30'),_0x4dde24[_0xb093('0x5')]),_0x4dde24);utils['info'](util['format'](_0xb093('0x31'),_0x4dde24[_0xb093('0x5')],_0x4dde24[_0xb093('0x32')],_0x4dde24['appdata']));if(_0x4dde24['application']['toLowerCase']()=='set'&&_[_0xb093('0x33')](_0x4dde24[_0xb093('0x34')][_0xb093('0x35')](),'cdr')){var _0x1d954c=_0x4dde24[_0xb093('0x34')][_0xb093('0x36')]('=');var _0x2931de=_0x1d954c[0x0][_0xb093('0x37')](_0x1d954c[0x0][_0xb093('0x38')]('(')+0x1,_0x1d954c[0x0][_0xb093('0x38')](')'));var _0xf81e6a=_0x1d954c[0x1];recordings[_0x4dde24[_0xb093('0x5')]][_0x2931de]=_0xf81e6a;}}}catch(_0x1fc3a4){utils[_0xb093('0x15')](util[_0xb093('0x4')]('[%s][recordings][newexten]',_0x4dde24[_0xb093('0x5')]),_0x1fc3a4);}};exports[_0xb093('0x39')]=function(_0x26b3b5){try{if(!_[_0xb093('0x17')](recordings[_0x26b3b5[_0xb093('0x5')]])){utils[_0xb093('0xf')](util[_0xb093('0x4')](_0xb093('0x3a'),_0x26b3b5['uniqueid']),_0x26b3b5);utils[_0xb093('0x3')](util[_0xb093('0x4')](_0xb093('0x3b'),_0x26b3b5[_0xb093('0x5')],_0x26b3b5[_0xb093('0x3c')]));recordings[_0x26b3b5[_0xb093('0x5')]]['queue']=_0x26b3b5[_0xb093('0x3c')];}}catch(_0x2cdd48){utils['error'](util[_0xb093('0x4')](_0xb093('0x3a'),_0x26b3b5[_0xb093('0x5')]),_0x2cdd48);}};exports[_0xb093('0x3d')]=function(_0x281a3d){try{utils['debug'](util['format'](_0xb093('0x3e'),_0x281a3d[_0xb093('0x5')]),_0x281a3d);utils[_0xb093('0x3')](util[_0xb093('0x4')](_0xb093('0x3f'),_0x281a3d[_0xb093('0x5')],_0x281a3d[_0xb093('0x40')],_0x281a3d['transferercalleridname'],_0x281a3d[_0xb093('0x41')],_0x281a3d[_0xb093('0x42')]));if(recordings[_0x281a3d['transfereruniqueid']]&&transfers['blinds'][_0x281a3d[_0xb093('0x43')]]){transfers[_0xb093('0x6')][_0x281a3d[_0xb093('0x43')]]['recording']=!![];}}catch(_0x22217c){utils[_0xb093('0x15')](util[_0xb093('0x4')](_0xb093('0x3e'),_0x281a3d[_0xb093('0x5')]),_0x22217c);}};