Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / voiceRecording / voiceRecording.rpc.js
index eb4ed03..a6f3fb3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x33af=['error','code','message','result','catch','UpdateVoiceRecording','VoiceRecording','body','options','raw','where','attributes','limit','findOne','callRecordingEncryption','create','existsSync','value','format','%s.cypher','encryptFile','secrets','recording','unlink','CreateVoiceRecording\x20file\x20encrypted','CreateVoiceRecording','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','then','info','VoiceRecording,\x20%s,\x20%s','request\x20sent','debug','stringify'];(function(_0x39e177,_0x1f09d9){var _0x441aa0=function(_0x533eef){while(--_0x533eef){_0x39e177['push'](_0x39e177['shift']());}};_0x441aa0(++_0x1f09d9);}(_0x33af,0xec));var _0xf33a=function(_0x57fda8,_0x5e80a0){_0x57fda8=_0x57fda8-0x0;var _0x11c895=_0x33af[_0x57fda8];return _0x11c895;};'use strict';var _=require('lodash');var util=require(_0xf33a('0x0'));var moment=require('moment');var BPromise=require(_0xf33a('0x1'));var rs=require(_0xf33a('0x2'));var fs=require('fs');var Redis=require(_0xf33a('0x3'));var db=require(_0xf33a('0x4'))['db'];var utils=require(_0xf33a('0x5'));var logger=require(_0xf33a('0x6'))('rpc');var config=require(_0xf33a('0x7'));var jayson=require(_0xf33a('0x8'));var client=jayson['client'][_0xf33a('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x384b14,_0x1b2b01,_0x2f3730){return new BPromise(function(_0x2baabb,_0x2cb169){return client['request'](_0x384b14,_0x2f3730)[_0xf33a('0xa')](function(_0x14eb0e){logger[_0xf33a('0xb')](_0xf33a('0xc'),_0x1b2b01,_0xf33a('0xd'));logger[_0xf33a('0xe')]('VoiceRecording,\x20%s,\x20%s,\x20%s',_0x1b2b01,'request\x20sent',JSON[_0xf33a('0xf')](_0x14eb0e));if(_0x14eb0e[_0xf33a('0x10')]){if(_0x14eb0e[_0xf33a('0x10')][_0xf33a('0x11')]===0x1f4){logger[_0xf33a('0x10')]('VoiceRecording,\x20%s,\x20%s',_0x1b2b01,_0x14eb0e[_0xf33a('0x10')][_0xf33a('0x12')]);return _0x2cb169(_0x14eb0e['error']['message']);}logger[_0xf33a('0x10')](_0xf33a('0xc'),_0x1b2b01,_0x14eb0e[_0xf33a('0x10')][_0xf33a('0x12')]);return _0x2baabb(_0x14eb0e[_0xf33a('0x10')][_0xf33a('0x12')]);}else{logger[_0xf33a('0xb')](_0xf33a('0xc'),_0x1b2b01,'request\x20sent');_0x2baabb(_0x14eb0e[_0xf33a('0x13')]['message']);}})[_0xf33a('0x14')](function(_0x229389){logger['error'](_0xf33a('0xc'),_0x1b2b01,_0x229389);_0x2cb169(_0x229389);});});}exports[_0xf33a('0x15')]=function(_0x524109){var _0x2946ef=this;return new Promise(function(_0x23d9e2,_0x38d69a){return db[_0xf33a('0x16')]['update'](_0x524109[_0xf33a('0x17')],{'raw':_0x524109[_0xf33a('0x18')]?_0x524109[_0xf33a('0x18')][_0xf33a('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x524109[_0xf33a('0x18')]?_0x524109[_0xf33a('0x18')][_0xf33a('0x1a')]||null:null,'attributes':_0x524109[_0xf33a('0x18')]?_0x524109[_0xf33a('0x18')][_0xf33a('0x1b')]||null:null,'limit':_0x524109['options']?_0x524109[_0xf33a('0x18')][_0xf33a('0x1c')]||null:null})[_0xf33a('0xa')](function(_0x27faa1){logger[_0xf33a('0xb')]('UpdateVoiceRecording',_0x524109);logger[_0xf33a('0xe')]('UpdateVoiceRecording',_0x524109,JSON[_0xf33a('0xf')](_0x27faa1));_0x23d9e2(_0x27faa1);})[_0xf33a('0x14')](function(_0x394468){logger[_0xf33a('0x10')](_0xf33a('0x15'),_0x394468['message'],_0x524109);_0x38d69a(_0x2946ef[_0xf33a('0x10')](0x1f4,_0x394468[_0xf33a('0x12')]));});});};exports['CreateVoiceRecording']=function(_0x4af24a){var _0x16ef31=this;return new Promise(function(_0x5f0a53,_0x5cf981){var _0x38eba2=require('../../components/encryptor');var _0x79d653;return db['Setting'][_0xf33a('0x1d')]({'attributes':['id',_0xf33a('0x1e')],'where':{'id':0x1},'raw':!![]})[_0xf33a('0xa')](function(_0x729fca){_0x79d653=_0x729fca;return db[_0xf33a('0x16')][_0xf33a('0x1f')](_0x4af24a[_0xf33a('0x17')]);})[_0xf33a('0xa')](function(_0x26e81){if(_0x79d653[_0xf33a('0x1e')]&&fs[_0xf33a('0x20')](_0x26e81[_0xf33a('0x21')])){var _0x22c9f2=util[_0xf33a('0x22')](_0xf33a('0x23'),_0x26e81['value']);return _0x38eba2[_0xf33a('0x24')](_0x26e81[_0xf33a('0x21')],_0x22c9f2,config[_0xf33a('0x25')][_0xf33a('0x26')])['then'](function(){fs[_0xf33a('0x27')](_0x26e81[_0xf33a('0x21')]);logger[_0xf33a('0xb')](_0xf33a('0x28'));return _0x26e81;});}return _0x26e81;})[_0xf33a('0xa')](function(_0x109d84){logger['info'](_0xf33a('0x29'),_0x4af24a);logger[_0xf33a('0xe')](_0xf33a('0x29'),_0x4af24a,JSON[_0xf33a('0xf')](_0x109d84));_0x5f0a53(_0x109d84);})[_0xf33a('0x14')](function(_0x57e7be){logger['error'](_0xf33a('0x29'),_0x57e7be['message'],_0x4af24a);_0x5cf981(_0x16ef31['error'](0x1f4,_0x57e7be['message']));});});};
\ No newline at end of file
+var _0xaebd=['randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','request\x20sent','VoiceRecording,\x20%s,\x20%s,\x20%s','stringify','error','message','VoiceRecording,\x20%s,\x20%s','catch','UpdateVoiceRecording','update','options','raw','where','attributes','debug','CreateVoiceRecording','Setting','findOne','callRecordingEncryption','VoiceRecording','create','body','value','format','%s.cypher','encryptFile','recording','unlink','lodash','moment','bluebird'];(function(_0xfb0cfd,_0x500179){var _0x2fd8aa=function(_0xccb501){while(--_0xccb501){_0xfb0cfd['push'](_0xfb0cfd['shift']());}};_0x2fd8aa(++_0x500179);}(_0xaebd,0x1e9));var _0xdaeb=function(_0x4ab015,_0x332cc4){_0x4ab015=_0x4ab015-0x0;var _0x19410d=_0xaebd[_0x4ab015];return _0x19410d;};'use strict';var _=require(_0xdaeb('0x0'));var util=require('util');var moment=require(_0xdaeb('0x1'));var BPromise=require(_0xdaeb('0x2'));var rs=require(_0xdaeb('0x3'));var fs=require('fs');var Redis=require(_0xdaeb('0x4'));var db=require(_0xdaeb('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xdaeb('0x6'))(_0xdaeb('0x7'));var config=require(_0xdaeb('0x8'));var jayson=require(_0xdaeb('0x9'));var client=jayson[_0xdaeb('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3ea090,_0x3f7ba1,_0x52c717){return new BPromise(function(_0x550bd9,_0x1b9d37){return client[_0xdaeb('0xb')](_0x3ea090,_0x52c717)[_0xdaeb('0xc')](function(_0x5e0ae9){logger[_0xdaeb('0xd')]('VoiceRecording,\x20%s,\x20%s',_0x3f7ba1,_0xdaeb('0xe'));logger['debug'](_0xdaeb('0xf'),_0x3f7ba1,'request\x20sent',JSON[_0xdaeb('0x10')](_0x5e0ae9));if(_0x5e0ae9[_0xdaeb('0x11')]){if(_0x5e0ae9['error']['code']===0x1f4){logger[_0xdaeb('0x11')]('VoiceRecording,\x20%s,\x20%s',_0x3f7ba1,_0x5e0ae9[_0xdaeb('0x11')][_0xdaeb('0x12')]);return _0x1b9d37(_0x5e0ae9[_0xdaeb('0x11')][_0xdaeb('0x12')]);}logger[_0xdaeb('0x11')](_0xdaeb('0x13'),_0x3f7ba1,_0x5e0ae9[_0xdaeb('0x11')]['message']);return _0x550bd9(_0x5e0ae9['error'][_0xdaeb('0x12')]);}else{logger[_0xdaeb('0xd')](_0xdaeb('0x13'),_0x3f7ba1,_0xdaeb('0xe'));_0x550bd9(_0x5e0ae9['result']['message']);}})[_0xdaeb('0x14')](function(_0x4dd803){logger['error'](_0xdaeb('0x13'),_0x3f7ba1,_0x4dd803);_0x1b9d37(_0x4dd803);});});}exports[_0xdaeb('0x15')]=function(_0x1b5243){var _0x1fe84e=this;return new Promise(function(_0x2d8f11,_0x36f9ac){return db['VoiceRecording'][_0xdaeb('0x16')](_0x1b5243['body'],{'raw':_0x1b5243[_0xdaeb('0x17')]?_0x1b5243[_0xdaeb('0x17')][_0xdaeb('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1b5243['options']?_0x1b5243['options'][_0xdaeb('0x19')]||null:null,'attributes':_0x1b5243[_0xdaeb('0x17')]?_0x1b5243[_0xdaeb('0x17')][_0xdaeb('0x1a')]||null:null,'limit':_0x1b5243[_0xdaeb('0x17')]?_0x1b5243['options']['limit']||null:null})[_0xdaeb('0xc')](function(_0x3cfcaf){logger[_0xdaeb('0xd')](_0xdaeb('0x15'),_0x1b5243);logger[_0xdaeb('0x1b')]('UpdateVoiceRecording',_0x1b5243,JSON[_0xdaeb('0x10')](_0x3cfcaf));_0x2d8f11(_0x3cfcaf);})['catch'](function(_0x130c35){logger[_0xdaeb('0x11')](_0xdaeb('0x15'),_0x130c35[_0xdaeb('0x12')],_0x1b5243);_0x36f9ac(_0x1fe84e[_0xdaeb('0x11')](0x1f4,_0x130c35['message']));});});};exports[_0xdaeb('0x1c')]=function(_0x34fa21){var _0x338687=this;return new Promise(function(_0x4eb719,_0x57c2c4){var _0x43095f=require('../../components/encryptor');var _0x5045f8;return db[_0xdaeb('0x1d')][_0xdaeb('0x1e')]({'attributes':['id',_0xdaeb('0x1f')],'where':{'id':0x1},'raw':!![]})['then'](function(_0x5e6f97){_0x5045f8=_0x5e6f97;return db[_0xdaeb('0x20')][_0xdaeb('0x21')](_0x34fa21[_0xdaeb('0x22')]);})['then'](function(_0x36c933){if(_0x5045f8['callRecordingEncryption']&&fs['existsSync'](_0x36c933[_0xdaeb('0x23')])){var _0x21f6cf=util[_0xdaeb('0x24')](_0xdaeb('0x25'),_0x36c933[_0xdaeb('0x23')]);return _0x43095f[_0xdaeb('0x26')](_0x36c933[_0xdaeb('0x23')],_0x21f6cf,config['secrets'][_0xdaeb('0x27')])[_0xdaeb('0xc')](function(){fs[_0xdaeb('0x28')](_0x36c933[_0xdaeb('0x23')]);logger[_0xdaeb('0xd')]('CreateVoiceRecording\x20file\x20encrypted');return _0x36c933;});}return _0x36c933;})[_0xdaeb('0xc')](function(_0x3de2bd){logger['info'](_0xdaeb('0x1c'),_0x34fa21);logger[_0xdaeb('0x1b')](_0xdaeb('0x1c'),_0x34fa21,JSON[_0xdaeb('0x10')](_0x3de2bd));_0x4eb719(_0x3de2bd);})[_0xdaeb('0x14')](function(_0x1628b8){logger[_0xdaeb('0x11')](_0xdaeb('0x1c'),_0x1628b8[_0xdaeb('0x12')],_0x34fa21);_0x57c2c4(_0x338687[_0xdaeb('0x11')](0x1f4,_0x1628b8['message']));});});};
\ No newline at end of file