bcbcd61703af1b9194eba72f12adf61d857fde42
[motion2.git] / server / api / voiceRecording / voiceRecording.rpc.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 _0xa456=['UpdateVoiceRecording','options','attributes','stringify','catch','CreateVoiceRecording','../../components/encryptor','Setting','findOne','callRecordingEncryption','VoiceRecording','create','body','existsSync','value','%s.cypher','encryptFile','CreateVoiceRecording\x20file\x20encrypted','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','then','info','VoiceRecording,\x20%s,\x20%s','request\x20sent','debug','VoiceRecording,\x20%s,\x20%s,\x20%s','error','message','result'];(function(_0x110e11,_0x2386fb){var _0x16d509=function(_0x58d8e7){while(--_0x58d8e7){_0x110e11['push'](_0x110e11['shift']());}};_0x16d509(++_0x2386fb);}(_0xa456,0x142));var _0x6a45=function(_0x3fba9f,_0x3b7b9b){_0x3fba9f=_0x3fba9f-0x0;var _0x192cf1=_0xa456[_0x3fba9f];return _0x192cf1;};'use strict';var _=require(_0x6a45('0x0'));var util=require(_0x6a45('0x1'));var moment=require(_0x6a45('0x2'));var BPromise=require(_0x6a45('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6a45('0x4'));var db=require(_0x6a45('0x5'))['db'];var utils=require(_0x6a45('0x6'));var logger=require('../../config/logger')(_0x6a45('0x7'));var config=require(_0x6a45('0x8'));var jayson=require(_0x6a45('0x9'));var client=jayson[_0x6a45('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x25cf8d,_0x26bfc0,_0x214514){return new BPromise(function(_0x19e67c,_0x3deb09){return client['request'](_0x25cf8d,_0x214514)[_0x6a45('0xb')](function(_0x517040){logger[_0x6a45('0xc')](_0x6a45('0xd'),_0x26bfc0,_0x6a45('0xe'));logger[_0x6a45('0xf')](_0x6a45('0x10'),_0x26bfc0,'request\x20sent',JSON['stringify'](_0x517040));if(_0x517040[_0x6a45('0x11')]){if(_0x517040[_0x6a45('0x11')]['code']===0x1f4){logger['error']('VoiceRecording,\x20%s,\x20%s',_0x26bfc0,_0x517040[_0x6a45('0x11')][_0x6a45('0x12')]);return _0x3deb09(_0x517040[_0x6a45('0x11')][_0x6a45('0x12')]);}logger[_0x6a45('0x11')]('VoiceRecording,\x20%s,\x20%s',_0x26bfc0,_0x517040['error'][_0x6a45('0x12')]);return _0x19e67c(_0x517040[_0x6a45('0x11')]['message']);}else{logger[_0x6a45('0xc')](_0x6a45('0xd'),_0x26bfc0,_0x6a45('0xe'));_0x19e67c(_0x517040[_0x6a45('0x13')]['message']);}})['catch'](function(_0x49023f){logger[_0x6a45('0x11')](_0x6a45('0xd'),_0x26bfc0,_0x49023f);_0x3deb09(_0x49023f);});});}exports[_0x6a45('0x14')]=function(_0x52a055){var _0x379c22=this;return new Promise(function(_0x102981,_0x3439c8){return db['VoiceRecording']['update'](_0x52a055['body'],{'raw':_0x52a055[_0x6a45('0x15')]?_0x52a055[_0x6a45('0x15')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x52a055[_0x6a45('0x15')]?_0x52a055[_0x6a45('0x15')]['where']||null:null,'attributes':_0x52a055[_0x6a45('0x15')]?_0x52a055[_0x6a45('0x15')][_0x6a45('0x16')]||null:null,'limit':_0x52a055[_0x6a45('0x15')]?_0x52a055[_0x6a45('0x15')]['limit']||null:null})['then'](function(_0x3faae5){logger[_0x6a45('0xc')](_0x6a45('0x14'),_0x52a055);logger[_0x6a45('0xf')](_0x6a45('0x14'),_0x52a055,JSON[_0x6a45('0x17')](_0x3faae5));_0x102981(_0x3faae5);})[_0x6a45('0x18')](function(_0x4692f5){logger[_0x6a45('0x11')](_0x6a45('0x14'),_0x4692f5[_0x6a45('0x12')],_0x52a055);_0x3439c8(_0x379c22[_0x6a45('0x11')](0x1f4,_0x4692f5['message']));});});};exports[_0x6a45('0x19')]=function(_0x5a0389){var _0x1b83fa=this;return new Promise(function(_0x25467d,_0x28bdf0){var _0x2c7315=require(_0x6a45('0x1a'));var _0x526062;return db[_0x6a45('0x1b')][_0x6a45('0x1c')]({'attributes':['id',_0x6a45('0x1d')],'where':{'id':0x1},'raw':!![]})[_0x6a45('0xb')](function(_0x8265d9){_0x526062=_0x8265d9;return db[_0x6a45('0x1e')][_0x6a45('0x1f')](_0x5a0389[_0x6a45('0x20')]);})['then'](function(_0x14adb5){if(_0x526062[_0x6a45('0x1d')]&&fs[_0x6a45('0x21')](_0x14adb5[_0x6a45('0x22')])){var _0x3b07a1=util['format'](_0x6a45('0x23'),_0x14adb5[_0x6a45('0x22')]);return _0x2c7315[_0x6a45('0x24')](_0x14adb5[_0x6a45('0x22')],_0x3b07a1,config['secrets']['recording'])[_0x6a45('0xb')](function(){fs['unlink'](_0x14adb5[_0x6a45('0x22')]);logger['info'](_0x6a45('0x25'));return _0x14adb5;});}return _0x14adb5;})[_0x6a45('0xb')](function(_0x429900){logger[_0x6a45('0xc')](_0x6a45('0x19'),_0x5a0389);logger[_0x6a45('0xf')](_0x6a45('0x19'),_0x5a0389,JSON[_0x6a45('0x17')](_0x429900));_0x25467d(_0x429900);})[_0x6a45('0x18')](function(_0x36f4a4){logger[_0x6a45('0x11')](_0x6a45('0x19'),_0x36f4a4[_0x6a45('0x12')],_0x5a0389);_0x28bdf0(_0x1b83fa['error'](0x1f4,_0x36f4a4[_0x6a45('0x12')]));});});};