68f1c766fd0f818d3f4bc5743e0250c99673af7d
[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 _0x6050=['existsSync','value','format','%s.cypher','encryptFile','secrets','recording','unlink','CreateVoiceRecording\x20file\x20encrypted','CreateVoiceRecording','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','http','request','then','VoiceRecording,\x20%s,\x20%s','request\x20sent','debug','VoiceRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','UpdateVoiceRecording','VoiceRecording','update','body','options','raw','where','attributes','../../components/encryptor','Setting','findOne','callRecordingEncryption'];(function(_0x558d7c,_0x2bb3c2){var _0x4f720e=function(_0xf4f835){while(--_0xf4f835){_0x558d7c['push'](_0x558d7c['shift']());}};_0x4f720e(++_0x2bb3c2);}(_0x6050,0x196));var _0x0605=function(_0x39b802,_0x216248){_0x39b802=_0x39b802-0x0;var _0x25918d=_0x6050[_0x39b802];return _0x25918d;};'use strict';var _=require(_0x0605('0x0'));var util=require(_0x0605('0x1'));var moment=require(_0x0605('0x2'));var BPromise=require(_0x0605('0x3'));var rs=require(_0x0605('0x4'));var fs=require('fs');var Redis=require(_0x0605('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x0605('0x6'));var logger=require(_0x0605('0x7'))(_0x0605('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x0605('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x578623,_0x58f7d2,_0x5660ad){return new BPromise(function(_0x1629bf,_0x11b8b5){return client[_0x0605('0xa')](_0x578623,_0x5660ad)[_0x0605('0xb')](function(_0x44fdd3){logger['info'](_0x0605('0xc'),_0x58f7d2,_0x0605('0xd'));logger[_0x0605('0xe')](_0x0605('0xf'),_0x58f7d2,_0x0605('0xd'),JSON[_0x0605('0x10')](_0x44fdd3));if(_0x44fdd3[_0x0605('0x11')]){if(_0x44fdd3[_0x0605('0x11')][_0x0605('0x12')]===0x1f4){logger[_0x0605('0x11')](_0x0605('0xc'),_0x58f7d2,_0x44fdd3[_0x0605('0x11')][_0x0605('0x13')]);return _0x11b8b5(_0x44fdd3[_0x0605('0x11')][_0x0605('0x13')]);}logger[_0x0605('0x11')](_0x0605('0xc'),_0x58f7d2,_0x44fdd3[_0x0605('0x11')][_0x0605('0x13')]);return _0x1629bf(_0x44fdd3['error'][_0x0605('0x13')]);}else{logger[_0x0605('0x14')](_0x0605('0xc'),_0x58f7d2,'request\x20sent');_0x1629bf(_0x44fdd3['result'][_0x0605('0x13')]);}})[_0x0605('0x15')](function(_0xa83443){logger[_0x0605('0x11')](_0x0605('0xc'),_0x58f7d2,_0xa83443);_0x11b8b5(_0xa83443);});});}exports[_0x0605('0x16')]=function(_0x2b7b5a){var _0x1d57ba=this;return new Promise(function(_0x193520,_0x40abb2){return db[_0x0605('0x17')][_0x0605('0x18')](_0x2b7b5a[_0x0605('0x19')],{'raw':_0x2b7b5a[_0x0605('0x1a')]?_0x2b7b5a['options'][_0x0605('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2b7b5a[_0x0605('0x1a')]?_0x2b7b5a[_0x0605('0x1a')][_0x0605('0x1c')]||null:null,'attributes':_0x2b7b5a[_0x0605('0x1a')]?_0x2b7b5a[_0x0605('0x1a')][_0x0605('0x1d')]||null:null,'limit':_0x2b7b5a[_0x0605('0x1a')]?_0x2b7b5a[_0x0605('0x1a')]['limit']||null:null})[_0x0605('0xb')](function(_0x4fe293){logger[_0x0605('0x14')](_0x0605('0x16'),_0x2b7b5a);logger[_0x0605('0xe')](_0x0605('0x16'),_0x2b7b5a,JSON[_0x0605('0x10')](_0x4fe293));_0x193520(_0x4fe293);})[_0x0605('0x15')](function(_0x2ea61d){logger[_0x0605('0x11')](_0x0605('0x16'),_0x2ea61d[_0x0605('0x13')],_0x2b7b5a);_0x40abb2(_0x1d57ba[_0x0605('0x11')](0x1f4,_0x2ea61d[_0x0605('0x13')]));});});};exports['CreateVoiceRecording']=function(_0x6bc204){var _0x3c8e36=this;return new Promise(function(_0x4b1e0c,_0x4d9a31){var _0x55ebd8=require(_0x0605('0x1e'));var _0x226825;return db[_0x0605('0x1f')][_0x0605('0x20')]({'attributes':['id',_0x0605('0x21')],'where':{'id':0x1},'raw':!![]})[_0x0605('0xb')](function(_0x4e32ef){_0x226825=_0x4e32ef;return db[_0x0605('0x17')]['create'](_0x6bc204[_0x0605('0x19')]);})[_0x0605('0xb')](function(_0x421c26){if(_0x226825[_0x0605('0x21')]&&fs[_0x0605('0x22')](_0x421c26[_0x0605('0x23')])){var _0x56dd1a=util[_0x0605('0x24')](_0x0605('0x25'),_0x421c26[_0x0605('0x23')]);return _0x55ebd8[_0x0605('0x26')](_0x421c26[_0x0605('0x23')],_0x56dd1a,config[_0x0605('0x27')][_0x0605('0x28')])[_0x0605('0xb')](function(){fs[_0x0605('0x29')](_0x421c26[_0x0605('0x23')]);logger[_0x0605('0x14')](_0x0605('0x2a'));return _0x421c26;});}return _0x421c26;})[_0x0605('0xb')](function(_0x992e4f){logger[_0x0605('0x14')](_0x0605('0x2b'),_0x6bc204);logger[_0x0605('0xe')](_0x0605('0x2b'),_0x6bc204,JSON[_0x0605('0x10')](_0x992e4f));_0x4b1e0c(_0x992e4f);})[_0x0605('0x15')](function(_0x3a1c75){logger[_0x0605('0x11')](_0x0605('0x2b'),_0x3a1c75[_0x0605('0x13')],_0x6bc204);_0x4d9a31(_0x3c8e36[_0x0605('0x11')](0x1f4,_0x3a1c75[_0x0605('0x13')]));});});};