Built motion from commit 82cfc5ed0.|1.0.23
[motion.git] / server / api / square_recording / square_recording.controller.js
1 var _0x9f16=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x53\x71\x75\x61\x72\x65\x52\x65\x63\x6F\x72\x64\x69\x6E\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x62\x6C\x75\x65\x62\x69\x72\x64","\x66\x69\x6C\x65\x2D\x62\x61\x73\x65\x36\x34","\x66\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72","\x63\x61\x75\x73\x65","\x63\x6F\x64\x65","\x45\x4E\x4F\x45\x4E\x54","\x4E\x6F\x20\x66\x69\x6C\x65\x20\x6F\x72\x20\x64\x69\x72\x65\x63\x74\x6F\x72\x79","\x4D\x45\x53\x53\x41\x47\x45\x5F\x4E\x4F\x5F\x46\x49\x4C\x45\x5F\x4F\x52\x5F\x44\x49\x52\x45\x43\x54\x4F\x52\x59","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x73\x61\x76\x65\x50\x61\x74\x68","\x73\x74\x61\x74\x53\x79\x6E\x63","\x74\x68\x65\x6E","\x64\x65\x73\x74\x72\x6F\x79","\x75\x6E\x6C\x69\x6E\x6B\x53\x79\x6E\x63","\x69\x6E\x64\x65\x78","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x63\x61\x74\x63\x68","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x67\x65\x74\x53\x74\x72\x65\x61\x6D","\x62\x61\x73\x65\x36\x34","\x62\x69\x6E\x61\x72\x79","\x72\x65\x61\x64\x46\x69\x6C\x65","\x70\x72\x6F\x6D\x69\x73\x69\x66\x79","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x61\x6C\x6C","\x70\x75\x73\x68","\x43\x61\x6E\x27\x20\x74\x20\x64\x65\x6C\x65\x74\x65\x20\x74\x68\x65\x20\x66\x69\x6C\x65","\x66\x6F\x72\x45\x61\x63\x68","\x69\x64\x73","\x66\x69\x6E\x64\x41\x6C\x6C"];_0x9f16[0];var _=require(_0x9f16[1]);var util=require(_0x9f16[2]);var logger=require(_0x9f16[4])(_0x9f16[3]);var SquareRecording=require(_0x9f16[6])[_0x9f16[5]];var Promise=require(_0x9f16[7]);var base64=require(_0x9f16[8]);var fs=require(_0x9f16[9]);var Util=require(_0x9f16[10]);function handleError(_0x3020xa){return function(_0x3020xb){logger[_0x9f16[12]](_0x3020xb[_0x9f16[11]]);if(_0x3020xb[_0x9f16[13]]&& _0x3020xb[_0x9f16[13]][_0x9f16[14]]=== _0x9f16[15]){_0x3020xb= {message:_0x9f16[16],translatedMessage:_0x9f16[17]}};return _0x3020xa[_0x9f16[19]](500)[_0x9f16[18]](_0x3020xb)}}function responseWithResult(_0x3020xa,_0x3020xd){_0x3020xd= _0x3020xd|| 200;return function(_0x3020xe){if(_0x3020xe){_0x3020xa[_0x9f16[19]](_0x3020xd)[_0x9f16[20]](_0x3020xe)}}}function handleEntityNotFound(_0x3020xa){return function(_0x3020xe){if(!_0x3020xe){_0x3020xa[_0x9f16[19]](404)[_0x9f16[21]]();return null};return _0x3020xe}}function saveUpdates(_0x3020x11){return function(_0x3020xe){return _0x3020xe[_0x9f16[22]](_0x3020x11)}}function removeEntity(_0x3020xa){return function(_0x3020xe){if(_0x3020xe){try{fs[_0x9f16[24]](_0x3020xe[_0x9f16[23]])}catch(err){logger[_0x9f16[12]](err);return _0x3020xe[_0x9f16[26]]()[_0x9f16[25]](function(){_0x3020xa[_0x9f16[19]](204)[_0x9f16[21]]()})};try{fs[_0x9f16[27]](_0x3020xe[_0x9f16[23]]);return _0x3020xe[_0x9f16[26]]()[_0x9f16[25]](function(){_0x3020xa[_0x9f16[19]](204)[_0x9f16[21]]()})}catch(err){throw  new Error(err)}}}}exports[_0x9f16[28]]= function(_0x3020x13,_0x3020xa){var _0x3020x14=Util[_0x9f16[30]](_0x3020x13[_0x9f16[29]]);return SquareRecording[_0x9f16[32]](_0x3020x14)[_0x9f16[25]](responseWithResult(_0x3020xa))[_0x9f16[31]](handleError(_0x3020xa))};exports[_0x9f16[33]]= function(_0x3020x13,_0x3020xa){return SquareRecording[_0x9f16[36]](_0x3020x13[_0x9f16[35]][_0x9f16[34]])[_0x9f16[25]](handleEntityNotFound(_0x3020xa))[_0x9f16[25]](responseWithResult(_0x3020xa))[_0x9f16[31]](handleError(_0x3020xa))};exports[_0x9f16[37]]= function(_0x3020x13,_0x3020xa){return SquareRecording[_0x9f16[36]](_0x3020x13[_0x9f16[35]][_0x9f16[34]])[_0x9f16[25]](function(_0x3020x17){var _0x3020x18=Promise[_0x9f16[41]](fs[_0x9f16[40]]);return _0x3020x18(_0x3020x17[_0x9f16[23]])})[_0x9f16[25]](function(_0x3020x16){var _0x3020x15= new Buffer(_0x3020x16,_0x9f16[39]).toString(_0x9f16[38]);return _0x3020x15})[_0x9f16[25]](function(_0x3020x15){return _0x3020xa[_0x9f16[19]](200)[_0x9f16[18]]({downloadString:_0x3020x15})})[_0x9f16[31]](handleError(_0x3020xa))};exports[_0x9f16[42]]= function(_0x3020x13,_0x3020xa){return SquareRecording[_0x9f16[42]](_0x3020x13[_0x9f16[43]])[_0x9f16[25]](responseWithResult(_0x3020xa,201))[_0x9f16[31]](handleError(_0x3020xa))};exports[_0x9f16[44]]= function(_0x3020x13,_0x3020xa){if(_0x3020x13[_0x9f16[43]][_0x9f16[34]]){delete _0x3020x13[_0x9f16[43]][_0x9f16[34]]};return SquareRecording[_0x9f16[36]](_0x3020x13[_0x9f16[35]][_0x9f16[34]])[_0x9f16[25]](handleEntityNotFound(_0x3020xa))[_0x9f16[25]](saveUpdates(_0x3020x13[_0x9f16[43]]))[_0x9f16[25]](responseWithResult(_0x3020xa))[_0x9f16[31]](handleError(_0x3020xa))};exports[_0x9f16[26]]= function(_0x3020x13,_0x3020xa){return SquareRecording[_0x9f16[36]](_0x3020x13[_0x9f16[35]][_0x9f16[34]])[_0x9f16[25]](handleEntityNotFound(_0x3020xa))[_0x9f16[25]](removeEntity(_0x3020xa))[_0x9f16[31]](handleError(_0x3020xa))};exports[_0x9f16[45]]= function(_0x3020x13,_0x3020xa){return SquareRecording[_0x9f16[52]]({where:{id:_0x3020x13[_0x9f16[29]][_0x9f16[51]]}})[_0x9f16[25]](function(_0x3020x19){var _0x3020x1a=[];_[_0x9f16[50]](_0x3020x19,function(_0x3020x1b){try{fs[_0x9f16[24]](_0x3020x1b[_0x9f16[23]]);try{fs[_0x9f16[27]](_0x3020x1b[_0x9f16[23]]);_0x3020x1a[_0x9f16[48]](_0x3020x1b[_0x9f16[26]]())}catch(err){logger[_0x9f16[12]](_0x9f16[49],err)}}catch(err){logger[_0x9f16[12]](_0x9f16[49],err);_0x3020x1a[_0x9f16[48]](_0x3020x1b[_0x9f16[26]]())}});return _0x3020x1a})[_0x9f16[47]]()[_0x9f16[25]](function(){return _0x3020xa[_0x9f16[46]](204)})[_0x9f16[31]](handleError(_0x3020xa))}