Built motion from commit 0900f080.|2.5.45
[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 _0x8ace=['VoiceRecording,\x20%s,\x20%s','request\x20sent','debug','VoiceRecording,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','UpdateVoiceRecording','VoiceRecording','update','options','raw','where','attributes','then','CreateVoiceRecording','../../components/encryptor','Setting','findOne','create','body','callRecordingEncryption','value','format','secrets','recording','unlink','CreateVoiceRecording\x20file\x20encrypted','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info'];(function(_0x22e9fe,_0x3d019f){var _0x47cd19=function(_0x8fd5fc){while(--_0x8fd5fc){_0x22e9fe['push'](_0x22e9fe['shift']());}};_0x47cd19(++_0x3d019f);}(_0x8ace,0x1bc));var _0xe8ac=function(_0x98417d,_0x2d249c){_0x98417d=_0x98417d-0x0;var _0x51ee3c=_0x8ace[_0x98417d];return _0x51ee3c;};'use strict';var _=require(_0xe8ac('0x0'));var util=require(_0xe8ac('0x1'));var moment=require(_0xe8ac('0x2'));var BPromise=require(_0xe8ac('0x3'));var rs=require(_0xe8ac('0x4'));var fs=require('fs');var Redis=require(_0xe8ac('0x5'));var db=require(_0xe8ac('0x6'))['db'];var utils=require(_0xe8ac('0x7'));var logger=require(_0xe8ac('0x8'))(_0xe8ac('0x9'));var config=require(_0xe8ac('0xa'));var jayson=require(_0xe8ac('0xb'));var client=jayson[_0xe8ac('0xc')][_0xe8ac('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x4eb087,_0x2d56f0,_0x1357ed){return new BPromise(function(_0x4f9233,_0x5c83e1){return client[_0xe8ac('0xe')](_0x4eb087,_0x1357ed)['then'](function(_0x1b5467){logger[_0xe8ac('0xf')](_0xe8ac('0x10'),_0x2d56f0,_0xe8ac('0x11'));logger[_0xe8ac('0x12')](_0xe8ac('0x13'),_0x2d56f0,'request\x20sent',JSON[_0xe8ac('0x14')](_0x1b5467));if(_0x1b5467[_0xe8ac('0x15')]){if(_0x1b5467[_0xe8ac('0x15')]['code']===0x1f4){logger[_0xe8ac('0x15')](_0xe8ac('0x10'),_0x2d56f0,_0x1b5467['error'][_0xe8ac('0x16')]);return _0x5c83e1(_0x1b5467[_0xe8ac('0x15')][_0xe8ac('0x16')]);}logger[_0xe8ac('0x15')](_0xe8ac('0x10'),_0x2d56f0,_0x1b5467[_0xe8ac('0x15')][_0xe8ac('0x16')]);return _0x4f9233(_0x1b5467[_0xe8ac('0x15')][_0xe8ac('0x16')]);}else{logger[_0xe8ac('0xf')]('VoiceRecording,\x20%s,\x20%s',_0x2d56f0,_0xe8ac('0x11'));_0x4f9233(_0x1b5467[_0xe8ac('0x17')]['message']);}})[_0xe8ac('0x18')](function(_0x3a7939){logger[_0xe8ac('0x15')](_0xe8ac('0x10'),_0x2d56f0,_0x3a7939);_0x5c83e1(_0x3a7939);});});}exports[_0xe8ac('0x19')]=function(_0x36759c){var _0x4892d0=this;return new Promise(function(_0x59df3d,_0x5f3433){return db[_0xe8ac('0x1a')][_0xe8ac('0x1b')](_0x36759c['body'],{'raw':_0x36759c[_0xe8ac('0x1c')]?_0x36759c['options'][_0xe8ac('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x36759c[_0xe8ac('0x1c')]?_0x36759c['options'][_0xe8ac('0x1e')]||null:null,'attributes':_0x36759c[_0xe8ac('0x1c')]?_0x36759c[_0xe8ac('0x1c')][_0xe8ac('0x1f')]||null:null,'limit':_0x36759c['options']?_0x36759c[_0xe8ac('0x1c')]['limit']||null:null})[_0xe8ac('0x20')](function(_0x3933d2){logger[_0xe8ac('0xf')](_0xe8ac('0x19'),_0x36759c);logger[_0xe8ac('0x12')](_0xe8ac('0x19'),_0x36759c,JSON[_0xe8ac('0x14')](_0x3933d2));_0x59df3d(_0x3933d2);})['catch'](function(_0x1c3ea4){logger[_0xe8ac('0x15')](_0xe8ac('0x19'),_0x1c3ea4[_0xe8ac('0x16')],_0x36759c);_0x5f3433(_0x4892d0[_0xe8ac('0x15')](0x1f4,_0x1c3ea4[_0xe8ac('0x16')]));});});};exports[_0xe8ac('0x21')]=function(_0x3e3fc2){var _0x44b07c=this;return new Promise(function(_0x562e44,_0x5a1b69){var _0x346dcb=require(_0xe8ac('0x22'));var _0x59512c;return db[_0xe8ac('0x23')][_0xe8ac('0x24')]({'attributes':['id','callRecordingEncryption'],'where':{'id':0x1},'raw':!![]})['then'](function(_0x1f1e44){_0x59512c=_0x1f1e44;return db[_0xe8ac('0x1a')][_0xe8ac('0x25')](_0x3e3fc2[_0xe8ac('0x26')]);})[_0xe8ac('0x20')](function(_0x41ffe8){if(_0x59512c[_0xe8ac('0x27')]&&fs['existsSync'](_0x41ffe8[_0xe8ac('0x28')])){var _0x5459e5=util[_0xe8ac('0x29')]('%s.cypher',_0x41ffe8['value']);return _0x346dcb['encryptFile'](_0x41ffe8['value'],_0x5459e5,config[_0xe8ac('0x2a')][_0xe8ac('0x2b')])[_0xe8ac('0x20')](function(){fs[_0xe8ac('0x2c')](_0x41ffe8[_0xe8ac('0x28')]);logger[_0xe8ac('0xf')](_0xe8ac('0x2d'));return _0x41ffe8;});}return _0x41ffe8;})['then'](function(_0x1cacb0){logger['info']('CreateVoiceRecording',_0x3e3fc2);logger['debug'](_0xe8ac('0x21'),_0x3e3fc2,JSON[_0xe8ac('0x14')](_0x1cacb0));_0x562e44(_0x1cacb0);})[_0xe8ac('0x18')](function(_0x56feff){logger['error'](_0xe8ac('0x21'),_0x56feff[_0xe8ac('0x16')],_0x3e3fc2);_0x5a1b69(_0x44b07c[_0xe8ac('0x15')](0x1f4,_0x56feff[_0xe8ac('0x16')]));});});};