Built motion from commit ab870f9e.|2.5.44
[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 _0x9259=['[%s][recordings][newstate]','channelstate','isNil','transfer','[%s][recordings][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s','varset','variable','debug','[%s][recordings][varset]','[%s][recordings][varset]\x20variable:%s\x20value:%s','value','endsWith','.wav49','replace','.WAV','find','monitors','push','error','hangup','[%s][recordings][hangup]','calleridnum','calleridname','cause-txt','connectedlinenum','connectedlinename','type','outbound','clone','newexten','[%s][recordings][newexten]','[%s][recordings][newexten]\x20application:%s\x20appdata:%s','appdata','application','set','cdr','split','substring','lastIndexOf','queuecallerjoin','[%s][recordings][queuecallerjoin]','[%s][recordings][queuecallerjoin]\x20queue:%s','queue','blindtransfer','[%s][recordings][blindtransfer]','transferercalleridnum','transfereecalleridnum','transfereecalleridname','transfereruniqueid','recording','lodash','./utils','./transfers.controller','info','format','[%s][recordings][writeDB]','uniqueid','blinds','transfereeuniqueid','accountcode','getUserByInternal','then','membername','name','request','CreateVoiceRecording','newchannel','[%s][recordings][newchannel]','linkedid','[%s][recordings][newchannel]\x20context:%s\x20exten:%s','exten','context','channel','newstate'];(function(_0x156e9b,_0x4fdea5){var _0x3b1772=function(_0x5274d5){while(--_0x5274d5){_0x156e9b['push'](_0x156e9b['shift']());}};_0x3b1772(++_0x4fdea5);}(_0x9259,0x1ee));var _0x9925=function(_0xef66ed,_0x1a5239){_0xef66ed=_0xef66ed-0x0;var _0xa14f66=_0x9259[_0xef66ed];return _0xa14f66;};'use strict';var _=require(_0x9925('0x0'));var util=require('util');var utils=require(_0x9925('0x1'));var transfers=require(_0x9925('0x2'));var recordings={};function writeDB(_0x12ed34){var _0x4cc353;utils[_0x9925('0x3')](util[_0x9925('0x4')](_0x9925('0x5'),_0x12ed34['uniqueid']));if(transfers['blinds'][_0x12ed34['uniqueid']]){_0x4cc353=_0x12ed34[_0x9925('0x6')];_0x12ed34[_0x9925('0x6')]=transfers[_0x9925('0x7')][_0x12ed34['uniqueid']][_0x9925('0x8')];}if(_0x12ed34[_0x9925('0x9')]){utils[_0x9925('0xa')](_0x12ed34[_0x9925('0x9')])[_0x9925('0xb')](function(_0x2b00f6){if(_0x2b00f6){_0x12ed34[_0x9925('0xc')]=_0x2b00f6[_0x9925('0xd')];_0x12ed34['UserId']=_0x2b00f6['id'];}utils[_0x9925('0xe')](_0x9925('0xf'),_0x12ed34);});}else{utils[_0x9925('0xe')](_0x9925('0xf'),_0x12ed34);}if(_0x4cc353)delete transfers[_0x9925('0x7')][_0x4cc353];}exports[_0x9925('0x10')]=function(_0x334a28){try{utils['debug'](util[_0x9925('0x4')](_0x9925('0x11'),_0x334a28['uniqueid']),_0x334a28);if(_0x334a28['uniqueid']==_0x334a28[_0x9925('0x12')]){utils[_0x9925('0x3')](util[_0x9925('0x4')](_0x9925('0x13'),_0x334a28[_0x9925('0x6')],_0x334a28['context'],_0x334a28[_0x9925('0x14')]));recordings[_0x334a28[_0x9925('0x6')]]={'uniqueid':_0x334a28[_0x9925('0x6')],'accountcode':_0x334a28[_0x9925('0x9')],'exten':_0x334a28['exten'],'context':_0x334a28[_0x9925('0x15')],'channel':_0x334a28[_0x9925('0x16')],'monitors':[]};}}catch(_0x3b1590){utils['error'](util[_0x9925('0x4')](_0x9925('0x11'),_0x334a28['uniqueid']),_0x3b1590);}};exports[_0x9925('0x17')]=function(_0x569f2a){try{utils['debug'](util[_0x9925('0x4')](_0x9925('0x18'),_0x569f2a[_0x9925('0x6')]),_0x569f2a);if(!_['isNil'](recordings[_0x569f2a['uniqueid']])&&_0x569f2a[_0x9925('0x19')]==0x6){utils[_0x9925('0x3')](util['format']('[%s][recordings][newstate]\x20context:%s\x20channel:%s',_0x569f2a[_0x9925('0x6')],_0x569f2a[_0x9925('0x15')],_0x569f2a['channel']));}else if(!_[_0x9925('0x1a')](recordings[_0x569f2a[_0x9925('0x12')]])&&_0x569f2a[_0x9925('0x19')]==0x6&&_0x569f2a[_0x9925('0x15')]!=_0x9925('0x1b')){utils[_0x9925('0x3')](util[_0x9925('0x4')](_0x9925('0x1c'),_0x569f2a[_0x9925('0x6')],_0x569f2a[_0x9925('0x12')],_0x569f2a[_0x9925('0x15')],_0x569f2a[_0x9925('0x16')]));recordings[_0x569f2a[_0x9925('0x12')]][_0x9925('0x9')]=_0x569f2a['accountcode'];}}catch(_0x3e1f7d){utils['error'](util['format'](_0x9925('0x18'),_0x569f2a[_0x9925('0x6')]),_0x3e1f7d);}};exports[_0x9925('0x1d')]=function(_0x3b69e4){try{if(!_[_0x9925('0x1a')](_0x3b69e4[_0x9925('0x1e')])&&!_[_0x9925('0x1a')](_0x3b69e4[_0x9925('0x1e')]['mixmonitor_filename'])){utils[_0x9925('0x1f')](util[_0x9925('0x4')](_0x9925('0x20'),_0x3b69e4[_0x9925('0x6')]),_0x3b69e4);utils['info'](util[_0x9925('0x4')](_0x9925('0x21'),_0x3b69e4[_0x9925('0x6')],_0x3b69e4[_0x9925('0x1e')],_0x3b69e4[_0x9925('0x22')]));if(_[_0x9925('0x23')](_0x3b69e4[_0x9925('0x22')],_0x9925('0x24'))){_0x3b69e4[_0x9925('0x22')]=_0x3b69e4[_0x9925('0x22')][_0x9925('0x25')]('.wav49',_0x9925('0x26'));}if(recordings[_0x3b69e4[_0x9925('0x12')]]){var _0x236fdb=_[_0x9925('0x27')](recordings[_0x3b69e4[_0x9925('0x12')]][_0x9925('0x28')],{'value':_0x3b69e4[_0x9925('0x22')]});if(_[_0x9925('0x1a')](_0x236fdb)){recordings[_0x3b69e4['linkedid']][_0x9925('0x28')][_0x9925('0x29')]({'value':_0x3b69e4[_0x9925('0x22')]});}}}}catch(_0x127edf){utils[_0x9925('0x2a')](util[_0x9925('0x4')](_0x9925('0x20'),_0x3b69e4[_0x9925('0x6')]),_0x127edf);}};exports[_0x9925('0x2b')]=function(_0x39d079){try{if(!_[_0x9925('0x1a')](recordings[_0x39d079[_0x9925('0x6')]])){utils[_0x9925('0x1f')](util[_0x9925('0x4')](_0x9925('0x2c'),_0x39d079['uniqueid']),_0x39d079);utils['info'](util['format']('[%s][recordings][hangup]\x20calleridnum:%s\x20calleridname:%s\x20reason:%s',_0x39d079[_0x9925('0x6')],_0x39d079[_0x9925('0x2d')],_0x39d079[_0x9925('0x2e')],_0x39d079[_0x9925('0x2f')]));recordings[_0x39d079[_0x9925('0x6')]][_0x9925('0x2d')]=_0x39d079['calleridnum'];recordings[_0x39d079[_0x9925('0x6')]][_0x9925('0x2e')]=_0x39d079['calleridname'];recordings[_0x39d079[_0x9925('0x6')]][_0x9925('0x30')]=_0x39d079[_0x9925('0x30')];recordings[_0x39d079[_0x9925('0x6')]][_0x9925('0x31')]=_0x39d079[_0x9925('0x31')];if(recordings[_0x39d079['uniqueid']][_0x9925('0x32')]==_0x9925('0x33')&&recordings[_0x39d079[_0x9925('0x6')]][_0x9925('0x9')]){recordings[_0x39d079[_0x9925('0x6')]][_0x9925('0x30')]=recordings[_0x39d079[_0x9925('0x6')]][_0x9925('0x9')];recordings[_0x39d079['uniqueid']]['connectedlinename']='';}recordings[_0x39d079[_0x9925('0x6')]][_0x9925('0x28')]['forEach'](function(_0x13712e){var _0x1aca47=_[_0x9925('0x34')](recordings[_0x39d079[_0x9925('0x6')]]);_0x1aca47[_0x9925('0x22')]=_0x13712e[_0x9925('0x22')];writeDB(_0x1aca47);});delete recordings[_0x39d079[_0x9925('0x6')]];}}catch(_0x10ae9a){utils[_0x9925('0x2a')](util[_0x9925('0x4')](_0x9925('0x2c'),_0x39d079[_0x9925('0x6')]),_0x10ae9a);}};exports[_0x9925('0x35')]=function(_0x4cbc13){try{if(!_[_0x9925('0x1a')](recordings[_0x4cbc13['uniqueid']])){utils['debug'](util[_0x9925('0x4')](_0x9925('0x36'),_0x4cbc13[_0x9925('0x6')]),_0x4cbc13);utils['info'](util[_0x9925('0x4')](_0x9925('0x37'),_0x4cbc13[_0x9925('0x6')],_0x4cbc13['application'],_0x4cbc13[_0x9925('0x38')]));if(_0x4cbc13[_0x9925('0x39')]['toLowerCase']()==_0x9925('0x3a')&&_['startsWith'](_0x4cbc13[_0x9925('0x38')]['toLowerCase'](),_0x9925('0x3b'))){var _0x3f4aaf=_0x4cbc13[_0x9925('0x38')][_0x9925('0x3c')]('=');var _0x3059bc=_0x3f4aaf[0x0][_0x9925('0x3d')](_0x3f4aaf[0x0]['lastIndexOf']('(')+0x1,_0x3f4aaf[0x0][_0x9925('0x3e')](')'));var _0x17e040=_0x3f4aaf[0x1];recordings[_0x4cbc13[_0x9925('0x6')]][_0x3059bc]=_0x17e040;}}}catch(_0x4943a8){utils[_0x9925('0x2a')](util['format'](_0x9925('0x36'),_0x4cbc13[_0x9925('0x6')]),_0x4943a8);}};exports[_0x9925('0x3f')]=function(_0x2deb54){try{if(!_[_0x9925('0x1a')](recordings[_0x2deb54[_0x9925('0x6')]])){utils['debug'](util[_0x9925('0x4')](_0x9925('0x40'),_0x2deb54[_0x9925('0x6')]),_0x2deb54);utils['info'](util[_0x9925('0x4')](_0x9925('0x41'),_0x2deb54['uniqueid'],_0x2deb54[_0x9925('0x42')]));recordings[_0x2deb54[_0x9925('0x6')]][_0x9925('0x42')]=_0x2deb54[_0x9925('0x42')];}}catch(_0x5289fe){utils['error'](util[_0x9925('0x4')](_0x9925('0x40'),_0x2deb54['uniqueid']),_0x5289fe);}};exports[_0x9925('0x43')]=function(_0x41c99f){try{utils['debug'](util[_0x9925('0x4')](_0x9925('0x44'),_0x41c99f[_0x9925('0x6')]),_0x41c99f);utils[_0x9925('0x3')](util['format']('[%s][recordings][blindtransfer]\x20transferercalleridnum:%s\x20transferercalleridname:%s\x20transfereecalleridnum:%s\x20transfereecalleridname:%s',_0x41c99f[_0x9925('0x6')],_0x41c99f[_0x9925('0x45')],_0x41c99f['transferercalleridname'],_0x41c99f[_0x9925('0x46')],_0x41c99f[_0x9925('0x47')]));if(recordings[_0x41c99f[_0x9925('0x48')]]&&transfers[_0x9925('0x7')][_0x41c99f['transfereruniqueid']]){transfers[_0x9925('0x7')][_0x41c99f[_0x9925('0x48')]][_0x9925('0x49')]=!![];}}catch(_0x11cd9d){utils[_0x9925('0x2a')](util[_0x9925('0x4')]('[%s][recordings][blindtransfer]',_0x41c99f['uniqueid']),_0x11cd9d);}};