258c64e1567d8af7c10df88a40b3c9f28accd59d
[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 _0x7708=['code','message','UpdateVoiceRecording','VoiceRecording','update','body','options','where','limit','then','catch','CreateVoiceRecording','../../components/encryptor','Setting','findOne','callRecordingEncryption','existsSync','value','%s.cypher','encryptFile','recording','CreateVoiceRecording\x20file\x20encrypted','lodash','util','bluebird','../../config/logger','rpc','jayson/promise','http','request','info','VoiceRecording,\x20%s,\x20%s','debug','VoiceRecording,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x1d20f0,_0x38810b){var _0x2b3ee6=function(_0x445a0d){while(--_0x445a0d){_0x1d20f0['push'](_0x1d20f0['shift']());}};_0x2b3ee6(++_0x38810b);}(_0x7708,0x188));var _0x8770=function(_0x4e0a03,_0x5eb6b0){_0x4e0a03=_0x4e0a03-0x0;var _0x2478fc=_0x7708[_0x4e0a03];return _0x2478fc;};'use strict';var _=require(_0x8770('0x0'));var util=require(_0x8770('0x1'));var moment=require('moment');var BPromise=require(_0x8770('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x8770('0x3'))(_0x8770('0x4'));var config=require('../../config/environment');var jayson=require(_0x8770('0x5'));var client=jayson['client'][_0x8770('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x42d305,_0x2b0295,_0x20e293){return new BPromise(function(_0x212b12,_0x3e1113){return client[_0x8770('0x7')](_0x42d305,_0x20e293)['then'](function(_0x396322){logger[_0x8770('0x8')](_0x8770('0x9'),_0x2b0295,'request\x20sent');logger[_0x8770('0xa')](_0x8770('0xb'),_0x2b0295,_0x8770('0xc'),JSON[_0x8770('0xd')](_0x396322));if(_0x396322['error']){if(_0x396322[_0x8770('0xe')][_0x8770('0xf')]===0x1f4){logger[_0x8770('0xe')]('VoiceRecording,\x20%s,\x20%s',_0x2b0295,_0x396322[_0x8770('0xe')][_0x8770('0x10')]);return _0x3e1113(_0x396322[_0x8770('0xe')][_0x8770('0x10')]);}logger[_0x8770('0xe')](_0x8770('0x9'),_0x2b0295,_0x396322[_0x8770('0xe')][_0x8770('0x10')]);return _0x212b12(_0x396322['error'][_0x8770('0x10')]);}else{logger[_0x8770('0x8')]('VoiceRecording,\x20%s,\x20%s',_0x2b0295,_0x8770('0xc'));_0x212b12(_0x396322['result'][_0x8770('0x10')]);}})['catch'](function(_0x5b4716){logger['error'](_0x8770('0x9'),_0x2b0295,_0x5b4716);_0x3e1113(_0x5b4716);});});}exports[_0x8770('0x11')]=function(_0x17b634){var _0xe0d611=this;return new Promise(function(_0x4b0691,_0x550be9){return db[_0x8770('0x12')][_0x8770('0x13')](_0x17b634[_0x8770('0x14')],{'raw':_0x17b634[_0x8770('0x15')]?_0x17b634[_0x8770('0x15')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x17b634[_0x8770('0x15')]?_0x17b634[_0x8770('0x15')][_0x8770('0x16')]||null:null,'attributes':_0x17b634[_0x8770('0x15')]?_0x17b634['options']['attributes']||null:null,'limit':_0x17b634[_0x8770('0x15')]?_0x17b634[_0x8770('0x15')][_0x8770('0x17')]||null:null})[_0x8770('0x18')](function(_0x2760b2){logger[_0x8770('0x8')]('UpdateVoiceRecording',_0x17b634);logger[_0x8770('0xa')](_0x8770('0x11'),_0x17b634,JSON[_0x8770('0xd')](_0x2760b2));_0x4b0691(_0x2760b2);})[_0x8770('0x19')](function(_0x51cdb5){logger[_0x8770('0xe')]('UpdateVoiceRecording',_0x51cdb5[_0x8770('0x10')],_0x17b634);_0x550be9(_0xe0d611[_0x8770('0xe')](0x1f4,_0x51cdb5[_0x8770('0x10')]));});});};exports[_0x8770('0x1a')]=function(_0x1538b2){var _0x2cd084=this;return new Promise(function(_0x293f53,_0x367564){var _0xb3f4aa=require(_0x8770('0x1b'));var _0x5f4973;return db[_0x8770('0x1c')][_0x8770('0x1d')]({'attributes':['id',_0x8770('0x1e')],'where':{'id':0x1},'raw':!![]})[_0x8770('0x18')](function(_0x246128){_0x5f4973=_0x246128;return db[_0x8770('0x12')]['create'](_0x1538b2['body']);})[_0x8770('0x18')](function(_0x11de6e){if(_0x5f4973[_0x8770('0x1e')]&&fs[_0x8770('0x1f')](_0x11de6e[_0x8770('0x20')])){var _0x4bc072=util['format'](_0x8770('0x21'),_0x11de6e[_0x8770('0x20')]);return _0xb3f4aa[_0x8770('0x22')](_0x11de6e[_0x8770('0x20')],_0x4bc072,config['secrets'][_0x8770('0x23')])['then'](function(){fs['unlink'](_0x11de6e[_0x8770('0x20')]);logger['info'](_0x8770('0x24'));return _0x11de6e;});}return _0x11de6e;})[_0x8770('0x18')](function(_0x1f3af6){logger[_0x8770('0x8')](_0x8770('0x1a'),_0x1538b2);logger[_0x8770('0xa')](_0x8770('0x1a'),_0x1538b2,JSON[_0x8770('0xd')](_0x1f3af6));_0x293f53(_0x1f3af6);})[_0x8770('0x19')](function(_0x53197e){logger[_0x8770('0xe')](_0x8770('0x1a'),_0x53197e[_0x8770('0x10')],_0x1538b2);_0x367564(_0x2cd084['error'](0x1f4,_0x53197e['message']));});});};