9ffb3a79bb34db65a7f20f60d3a1bb26ea6ecb9d
[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 _0xabf9=['[%s][recordings][varset]\x20variable:%s\x20value:%s','value','endsWith','replace','.wav49','.WAV','monitors','hangup','calleridnum','calleridname','connectedlinenum','connectedlinename','type','outbound','forEach','[%s][recordings][hangup]','[%s][recordings][newexten]','[%s][recordings][newexten]\x20application:%s\x20appdata:%s','application','toLowerCase','startsWith','appdata','cdr','split','lastIndexOf','queuecallerjoin','[%s][recordings][queuecallerjoin]','queue','blindtransfer','[%s][recordings][blindtransfer]','[%s][recordings][blindtransfer]\x20transferercalleridnum:%s\x20transferercalleridname:%s\x20transfereecalleridnum:%s\x20transfereecalleridname:%s','transferercalleridnum','transferercalleridname','transfereecalleridname','transfereruniqueid','recording','lodash','util','./transfers.controller','info','format','[%s][recordings][writeDB]','uniqueid','blinds','getUserByInternal','accountcode','then','membername','name','UserId','CreateVoiceRecording','request','newchannel','debug','[%s][recordings][newchannel]','linkedid','[%s][recordings][newchannel]\x20context:%s\x20exten:%s','context','exten','channel','error','[%s][recordings][newstate]','isNil','channelstate','transfer','varset','variable','mixmonitor_filename','[%s][recordings][varset]'];(function(_0x3817a9,_0x29e215){var _0x443f30=function(_0x13940b){while(--_0x13940b){_0x3817a9['push'](_0x3817a9['shift']());}};_0x443f30(++_0x29e215);}(_0xabf9,0xf3));var _0x9abf=function(_0x39d4b1,_0x134bd6){_0x39d4b1=_0x39d4b1-0x0;var _0x1eab3d=_0xabf9[_0x39d4b1];return _0x1eab3d;};'use strict';var _=require(_0x9abf('0x0'));var util=require(_0x9abf('0x1'));var utils=require('./utils');var transfers=require(_0x9abf('0x2'));var recordings={};function writeDB(_0x322829){var _0x454cb2;utils[_0x9abf('0x3')](util[_0x9abf('0x4')](_0x9abf('0x5'),_0x322829[_0x9abf('0x6')]));if(transfers[_0x9abf('0x7')][_0x322829[_0x9abf('0x6')]]){_0x454cb2=_0x322829['uniqueid'];_0x322829[_0x9abf('0x6')]=transfers[_0x9abf('0x7')][_0x322829[_0x9abf('0x6')]]['transfereeuniqueid'];}if(_0x322829['accountcode']){utils[_0x9abf('0x8')](_0x322829[_0x9abf('0x9')])[_0x9abf('0xa')](function(_0x440909){if(_0x440909){_0x322829[_0x9abf('0xb')]=_0x440909[_0x9abf('0xc')];_0x322829[_0x9abf('0xd')]=_0x440909['id'];}utils['request'](_0x9abf('0xe'),_0x322829);});}else{utils[_0x9abf('0xf')]('CreateVoiceRecording',_0x322829);}if(_0x454cb2)delete transfers['blinds'][_0x454cb2];}exports[_0x9abf('0x10')]=function(_0x58e44f){try{utils[_0x9abf('0x11')](util['format'](_0x9abf('0x12'),_0x58e44f[_0x9abf('0x6')]),_0x58e44f);if(_0x58e44f[_0x9abf('0x6')]==_0x58e44f[_0x9abf('0x13')]){utils[_0x9abf('0x3')](util[_0x9abf('0x4')](_0x9abf('0x14'),_0x58e44f['uniqueid'],_0x58e44f[_0x9abf('0x15')],_0x58e44f[_0x9abf('0x16')]));recordings[_0x58e44f[_0x9abf('0x6')]]={'uniqueid':_0x58e44f['uniqueid'],'accountcode':_0x58e44f[_0x9abf('0x9')],'exten':_0x58e44f[_0x9abf('0x16')],'context':_0x58e44f[_0x9abf('0x15')],'channel':_0x58e44f[_0x9abf('0x17')],'monitors':[]};}}catch(_0x5b9dab){utils[_0x9abf('0x18')](util[_0x9abf('0x4')](_0x9abf('0x12'),_0x58e44f[_0x9abf('0x6')]),_0x5b9dab);}};exports['newstate']=function(_0x5a9463){try{utils['debug'](util[_0x9abf('0x4')](_0x9abf('0x19'),_0x5a9463[_0x9abf('0x6')]),_0x5a9463);if(!_[_0x9abf('0x1a')](recordings[_0x5a9463[_0x9abf('0x6')]])&&_0x5a9463[_0x9abf('0x1b')]==0x6){utils['info'](util['format']('[%s][recordings][newstate]\x20context:%s\x20channel:%s',_0x5a9463['uniqueid'],_0x5a9463[_0x9abf('0x15')],_0x5a9463[_0x9abf('0x17')]));}else if(!_[_0x9abf('0x1a')](recordings[_0x5a9463[_0x9abf('0x13')]])&&_0x5a9463['channelstate']==0x6&&_0x5a9463[_0x9abf('0x15')]!=_0x9abf('0x1c')){utils[_0x9abf('0x3')](util[_0x9abf('0x4')]('[%s][recordings][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s',_0x5a9463[_0x9abf('0x6')],_0x5a9463['linkedid'],_0x5a9463[_0x9abf('0x15')],_0x5a9463[_0x9abf('0x17')]));recordings[_0x5a9463['linkedid']]['accountcode']=_0x5a9463[_0x9abf('0x9')];}}catch(_0x37b3a1){utils['error'](util[_0x9abf('0x4')]('[%s][recordings][newstate]',_0x5a9463[_0x9abf('0x6')]),_0x37b3a1);}};exports[_0x9abf('0x1d')]=function(_0x5a76a7){try{if(!_[_0x9abf('0x1a')](_0x5a76a7[_0x9abf('0x1e')])&&!_['isNil'](_0x5a76a7[_0x9abf('0x1e')][_0x9abf('0x1f')])){utils[_0x9abf('0x11')](util['format'](_0x9abf('0x20'),_0x5a76a7[_0x9abf('0x6')]),_0x5a76a7);utils[_0x9abf('0x3')](util[_0x9abf('0x4')](_0x9abf('0x21'),_0x5a76a7[_0x9abf('0x6')],_0x5a76a7['variable'],_0x5a76a7[_0x9abf('0x22')]));if(_[_0x9abf('0x23')](_0x5a76a7['value'],'.wav49')){_0x5a76a7[_0x9abf('0x22')]=_0x5a76a7[_0x9abf('0x22')][_0x9abf('0x24')](_0x9abf('0x25'),_0x9abf('0x26'));}if(recordings[_0x5a76a7['linkedid']]){var _0x47e3d1=_['find'](recordings[_0x5a76a7[_0x9abf('0x13')]][_0x9abf('0x27')],{'value':_0x5a76a7[_0x9abf('0x22')]});if(_[_0x9abf('0x1a')](_0x47e3d1)){recordings[_0x5a76a7[_0x9abf('0x13')]]['monitors']['push']({'value':_0x5a76a7[_0x9abf('0x22')]});}}}}catch(_0x352e67){utils[_0x9abf('0x18')](util[_0x9abf('0x4')](_0x9abf('0x20'),_0x5a76a7['uniqueid']),_0x352e67);}};exports[_0x9abf('0x28')]=function(_0x513a78){try{if(!_[_0x9abf('0x1a')](recordings[_0x513a78[_0x9abf('0x6')]])){utils[_0x9abf('0x11')](util['format']('[%s][recordings][hangup]',_0x513a78['uniqueid']),_0x513a78);utils[_0x9abf('0x3')](util['format']('[%s][recordings][hangup]\x20calleridnum:%s\x20calleridname:%s\x20reason:%s',_0x513a78[_0x9abf('0x6')],_0x513a78[_0x9abf('0x29')],_0x513a78[_0x9abf('0x2a')],_0x513a78['cause-txt']));recordings[_0x513a78[_0x9abf('0x6')]][_0x9abf('0x29')]=_0x513a78['calleridnum'];recordings[_0x513a78[_0x9abf('0x6')]][_0x9abf('0x2a')]=_0x513a78[_0x9abf('0x2a')];recordings[_0x513a78[_0x9abf('0x6')]][_0x9abf('0x2b')]=_0x513a78[_0x9abf('0x2b')];recordings[_0x513a78[_0x9abf('0x6')]]['connectedlinename']=_0x513a78[_0x9abf('0x2c')];if(recordings[_0x513a78[_0x9abf('0x6')]][_0x9abf('0x2d')]==_0x9abf('0x2e')&&recordings[_0x513a78[_0x9abf('0x6')]][_0x9abf('0x9')]){recordings[_0x513a78[_0x9abf('0x6')]][_0x9abf('0x2b')]=recordings[_0x513a78[_0x9abf('0x6')]][_0x9abf('0x9')];recordings[_0x513a78['uniqueid']][_0x9abf('0x2c')]='';}recordings[_0x513a78[_0x9abf('0x6')]][_0x9abf('0x27')][_0x9abf('0x2f')](function(_0x385119){var _0x23fd49=_['clone'](recordings[_0x513a78[_0x9abf('0x6')]]);_0x23fd49['value']=_0x385119[_0x9abf('0x22')];writeDB(_0x23fd49);});delete recordings[_0x513a78[_0x9abf('0x6')]];}}catch(_0x42df8a){utils[_0x9abf('0x18')](util[_0x9abf('0x4')](_0x9abf('0x30'),_0x513a78[_0x9abf('0x6')]),_0x42df8a);}};exports['newexten']=function(_0x4c7496){try{if(!_[_0x9abf('0x1a')](recordings[_0x4c7496['uniqueid']])){utils[_0x9abf('0x11')](util['format'](_0x9abf('0x31'),_0x4c7496[_0x9abf('0x6')]),_0x4c7496);utils[_0x9abf('0x3')](util[_0x9abf('0x4')](_0x9abf('0x32'),_0x4c7496['uniqueid'],_0x4c7496[_0x9abf('0x33')],_0x4c7496['appdata']));if(_0x4c7496[_0x9abf('0x33')][_0x9abf('0x34')]()=='set'&&_[_0x9abf('0x35')](_0x4c7496[_0x9abf('0x36')][_0x9abf('0x34')](),_0x9abf('0x37'))){var _0x4a6c4c=_0x4c7496[_0x9abf('0x36')][_0x9abf('0x38')]('=');var _0x40e51e=_0x4a6c4c[0x0]['substring'](_0x4a6c4c[0x0]['lastIndexOf']('(')+0x1,_0x4a6c4c[0x0][_0x9abf('0x39')](')'));var _0x107f10=_0x4a6c4c[0x1];recordings[_0x4c7496[_0x9abf('0x6')]][_0x40e51e]=_0x107f10;}}}catch(_0x5f29b8){utils[_0x9abf('0x18')](util[_0x9abf('0x4')](_0x9abf('0x31'),_0x4c7496[_0x9abf('0x6')]),_0x5f29b8);}};exports[_0x9abf('0x3a')]=function(_0x2fd028){try{if(!_[_0x9abf('0x1a')](recordings[_0x2fd028[_0x9abf('0x6')]])){utils[_0x9abf('0x11')](util[_0x9abf('0x4')](_0x9abf('0x3b'),_0x2fd028[_0x9abf('0x6')]),_0x2fd028);utils[_0x9abf('0x3')](util['format']('[%s][recordings][queuecallerjoin]\x20queue:%s',_0x2fd028[_0x9abf('0x6')],_0x2fd028['queue']));recordings[_0x2fd028['uniqueid']][_0x9abf('0x3c')]=_0x2fd028[_0x9abf('0x3c')];}}catch(_0xb565f4){utils[_0x9abf('0x18')](util[_0x9abf('0x4')](_0x9abf('0x3b'),_0x2fd028[_0x9abf('0x6')]),_0xb565f4);}};exports[_0x9abf('0x3d')]=function(_0x23f685){try{utils['debug'](util[_0x9abf('0x4')](_0x9abf('0x3e'),_0x23f685[_0x9abf('0x6')]),_0x23f685);utils[_0x9abf('0x3')](util[_0x9abf('0x4')](_0x9abf('0x3f'),_0x23f685[_0x9abf('0x6')],_0x23f685[_0x9abf('0x40')],_0x23f685[_0x9abf('0x41')],_0x23f685['transfereecalleridnum'],_0x23f685[_0x9abf('0x42')]));if(recordings[_0x23f685['transfereruniqueid']]&&transfers[_0x9abf('0x7')][_0x23f685['transfereruniqueid']]){transfers[_0x9abf('0x7')][_0x23f685[_0x9abf('0x43')]][_0x9abf('0x44')]=!![];}}catch(_0x5e1b7a){utils[_0x9abf('0x18')](util[_0x9abf('0x4')](_0x9abf('0x3e'),_0x23f685[_0x9abf('0x6')]),_0x5e1b7a);}};