Built motion from commit (unavailable).|2.3.7
[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 _0xb3d2=['request\x20sent','debug','stringify','error','code','VoiceRecording,\x20%s,\x20%s','message','result','UpdateVoiceRecording','body','options','raw','where','limit','then','catch','CreateVoiceRecording','../../components/encryptor','Setting','findOne','callRecordingEncryption','existsSync','value','format','%s.cypher','encryptFile','secrets','unlink','CreateVoiceRecording\x20file\x20encrypted','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','request','info'];(function(_0x2a37b4,_0x166973){var _0x567f46=function(_0x55eae0){while(--_0x55eae0){_0x2a37b4['push'](_0x2a37b4['shift']());}};_0x567f46(++_0x166973);}(_0xb3d2,0x1c1));var _0x2b3d=function(_0x1151fa,_0x5d8819){_0x1151fa=_0x1151fa-0x0;var _0xedb08b=_0xb3d2[_0x1151fa];return _0xedb08b;};'use strict';var _=require(_0x2b3d('0x0'));var util=require(_0x2b3d('0x1'));var moment=require(_0x2b3d('0x2'));var BPromise=require('bluebird');var rs=require(_0x2b3d('0x3'));var fs=require('fs');var Redis=require(_0x2b3d('0x4'));var db=require(_0x2b3d('0x5'))['db'];var utils=require(_0x2b3d('0x6'));var logger=require(_0x2b3d('0x7'))(_0x2b3d('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x2b3d('0x9')][_0x2b3d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x5452b4,_0x1e4571,_0xcf5cf3){return new BPromise(function(_0x117ce1,_0x50d8a0){return client[_0x2b3d('0xb')](_0x5452b4,_0xcf5cf3)['then'](function(_0x3b0fd3){logger[_0x2b3d('0xc')]('VoiceRecording,\x20%s,\x20%s',_0x1e4571,_0x2b3d('0xd'));logger[_0x2b3d('0xe')]('VoiceRecording,\x20%s,\x20%s,\x20%s',_0x1e4571,_0x2b3d('0xd'),JSON[_0x2b3d('0xf')](_0x3b0fd3));if(_0x3b0fd3[_0x2b3d('0x10')]){if(_0x3b0fd3[_0x2b3d('0x10')][_0x2b3d('0x11')]===0x1f4){logger[_0x2b3d('0x10')](_0x2b3d('0x12'),_0x1e4571,_0x3b0fd3['error'][_0x2b3d('0x13')]);return _0x50d8a0(_0x3b0fd3['error'][_0x2b3d('0x13')]);}logger['error'](_0x2b3d('0x12'),_0x1e4571,_0x3b0fd3['error'][_0x2b3d('0x13')]);return _0x117ce1(_0x3b0fd3[_0x2b3d('0x10')][_0x2b3d('0x13')]);}else{logger[_0x2b3d('0xc')]('VoiceRecording,\x20%s,\x20%s',_0x1e4571,_0x2b3d('0xd'));_0x117ce1(_0x3b0fd3[_0x2b3d('0x14')]['message']);}})['catch'](function(_0x566e19){logger[_0x2b3d('0x10')](_0x2b3d('0x12'),_0x1e4571,_0x566e19);_0x50d8a0(_0x566e19);});});}exports[_0x2b3d('0x15')]=function(_0x591794){var _0x11b4e9=this;return new Promise(function(_0x404a74,_0xcf0754){return db['VoiceRecording']['update'](_0x591794[_0x2b3d('0x16')],{'raw':_0x591794[_0x2b3d('0x17')]?_0x591794['options'][_0x2b3d('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x591794[_0x2b3d('0x17')]?_0x591794[_0x2b3d('0x17')][_0x2b3d('0x19')]||null:null,'attributes':_0x591794['options']?_0x591794[_0x2b3d('0x17')]['attributes']||null:null,'limit':_0x591794[_0x2b3d('0x17')]?_0x591794[_0x2b3d('0x17')][_0x2b3d('0x1a')]||null:null})[_0x2b3d('0x1b')](function(_0x6e01ce){logger[_0x2b3d('0xc')](_0x2b3d('0x15'),_0x591794);logger['debug'](_0x2b3d('0x15'),_0x591794,JSON[_0x2b3d('0xf')](_0x6e01ce));_0x404a74(_0x6e01ce);})[_0x2b3d('0x1c')](function(_0x75f7ce){logger['error'](_0x2b3d('0x15'),_0x75f7ce[_0x2b3d('0x13')],_0x591794);_0xcf0754(_0x11b4e9[_0x2b3d('0x10')](0x1f4,_0x75f7ce['message']));});});};exports[_0x2b3d('0x1d')]=function(_0x1eba9c){var _0x564f1f=this;return new Promise(function(_0x5bf40b,_0x16ea65){var _0x3b173b=require(_0x2b3d('0x1e'));var _0x42ef8d;return db[_0x2b3d('0x1f')][_0x2b3d('0x20')]({'attributes':['id',_0x2b3d('0x21')],'where':{'id':0x1},'raw':!![]})[_0x2b3d('0x1b')](function(_0x3aa888){_0x42ef8d=_0x3aa888;return db['VoiceRecording']['create'](_0x1eba9c[_0x2b3d('0x16')]);})[_0x2b3d('0x1b')](function(_0x2236c9){if(_0x42ef8d[_0x2b3d('0x21')]&&fs[_0x2b3d('0x22')](_0x2236c9[_0x2b3d('0x23')])){var _0x32a89b=util[_0x2b3d('0x24')](_0x2b3d('0x25'),_0x2236c9[_0x2b3d('0x23')]);return _0x3b173b[_0x2b3d('0x26')](_0x2236c9[_0x2b3d('0x23')],_0x32a89b,config[_0x2b3d('0x27')]['recording'])[_0x2b3d('0x1b')](function(){fs[_0x2b3d('0x28')](_0x2236c9[_0x2b3d('0x23')]);logger[_0x2b3d('0xc')](_0x2b3d('0x29'));return _0x2236c9;});}return _0x2236c9;})[_0x2b3d('0x1b')](function(_0x35c6d5){logger[_0x2b3d('0xc')](_0x2b3d('0x1d'),_0x1eba9c);logger[_0x2b3d('0xe')](_0x2b3d('0x1d'),_0x1eba9c,JSON[_0x2b3d('0xf')](_0x35c6d5));_0x5bf40b(_0x35c6d5);})['catch'](function(_0x88bea){logger[_0x2b3d('0x10')]('CreateVoiceRecording',_0x88bea[_0x2b3d('0x13')],_0x1eba9c);_0x16ea65(_0x564f1f[_0x2b3d('0x10')](0x1f4,_0x88bea['message']));});});};