Built motion from commit f861bcb808219e66da88ba48b61bddb35224a65e. Version 3.0.0...
[motion-next.git] / server / api / squareRecording / squareRecording.controller.js
1 'use strict';const a716_0x484a=['offset','@config/logger','decryptFile','attributes','filter','includeAll','@utils/filter-attributes','create','undefined','set','.cypher','nolimit','length','destroy','then','util','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','error-middleware/errors','map','download','@components/encryptor','cancellazione\x20fisica\x20documento\x20%s','rawAttributes','keys','info','979MeGAQv','Entity\x20not\x20found','sort','update','filters','type','rows','uniqueid','options','unlinkSync','findOne','existsSync','fieldName','json','params','@components/parsers/qs','145BHBWAE','%s.cypher','Content-Range','name','show','645522RyTLlS','fields','catch','isNil','212429dhjvKb','108544aBvsCT','limit','api','send','body','168765mmGmVU','model','intersection','where','stack','File:\x20\x22','recordingSecret','unlink','count','message','findAll','sendStatus','extname','include','error','2KCIUOP','706fMjriX','order','976662RBJkZC','index','query','SquareRecording','filename','status','key','3407KMZDUy','savePath','merge','format','SquareRecording\x20not\x20found','path','sequelize','Not\x20found'];const a716_0x5359=function(_0x9aaaeb,_0x27a4b0){_0x9aaaeb=_0x9aaaeb-0x122;let _0x484adb=a716_0x484a[_0x9aaaeb];return _0x484adb;};const a716_0x314dcf=a716_0x5359;(function(_0x95c576,_0x866b84){const _0x36c992=a716_0x5359;while(!![]){try{const _0xcec795=parseInt(_0x36c992(0x173))*-parseInt(_0x36c992(0x142))+parseInt(_0x36c992(0x178))+parseInt(_0x36c992(0x124))+-parseInt(_0x36c992(0x13b))+parseInt(_0x36c992(0x129))+parseInt(_0x36c992(0x138))*parseInt(_0x36c992(0x123))+parseInt(_0x36c992(0x139))*parseInt(_0x36c992(0x163));if(_0xcec795===_0x866b84)break;else _0x95c576['push'](_0x95c576['shift']());}catch(_0x29c33e){_0x95c576['push'](_0x95c576['shift']());}}}(a716_0x484a,0x8ab7a));const util=require(a716_0x314dcf(0x159)),path=require(a716_0x314dcf(0x147)),fs=require('fs'),_=require('lodash'),qs=require(a716_0x314dcf(0x172)),logger=require(a716_0x314dcf(0x14b))(a716_0x314dcf(0x126)),{getConfig}=require('@config/get-config'),config=getConfig(),{db}=require('@mysqldb'),{ValidationError}=require(a716_0x314dcf(0x148)),{filterAttributes}=require(a716_0x314dcf(0x150)),{InternalError}=require(a716_0x314dcf(0x15b));function respondWithResult(_0x471170,_0x3306ca){return _0x3306ca=_0x3306ca||0xc8,function(_0x1f653b){const _0x2bd7c3=a716_0x5359;if(_0x1f653b)return _0x471170[_0x2bd7c3(0x140)](_0x3306ca)['json'](_0x1f653b);};}function respondWithFilteredResult(_0xaa5519,_0x296337){return function(_0x536a57){const _0x5896c1=a716_0x5359;if(_0x536a57){const _0x23273b=_0x536a57[_0x5896c1(0x131)],_0x1847a8=_0x296337[_0x5896c1(0x14a)];let _0x41f021=_0x296337['offset']+_0x296337[_0x5896c1(0x125)],_0x4f174c;return _0x41f021>=_0x23273b?(_0x41f021=_0x23273b,_0x4f174c=0xc8):_0x4f174c=0xce,_0xaa5519['status'](_0x4f174c),_0xaa5519[_0x5896c1(0x153)](_0x5896c1(0x175),_0x1847a8+'-'+_0x41f021+'/'+_0x23273b)[_0x5896c1(0x170)](_0x536a57);}return null;};}function saveUpdates(_0x1a2f60){return function(_0x47b9de){const _0x23daac=a716_0x5359;if(_0x47b9de)return _0x47b9de[_0x23daac(0x166)](_0x1a2f60)[_0x23daac(0x158)](function(_0x2c371c){return _0x2c371c;});return null;};}function handleEntityNotFound(_0x36877a){return function(_0x4bdda3){const _0x2af90b=a716_0x5359;return!_0x4bdda3&&_0x36877a[_0x2af90b(0x134)](0x194),_0x4bdda3;};}function handleError(_0x57ff88,_0x37a5cf){return _0x37a5cf=_0x37a5cf||0x1f4,function(_0x52819a){const _0x2bea90=a716_0x5359;logger[_0x2bea90(0x137)](_0x52819a[_0x2bea90(0x12d)]),_0x52819a[_0x2bea90(0x176)]&&delete _0x52819a[_0x2bea90(0x176)],_0x57ff88[_0x2bea90(0x140)](_0x37a5cf)[_0x2bea90(0x127)](_0x52819a);};}exports[a716_0x314dcf(0x13c)]=function(_0x58f5c7,_0x11c1b8){const _0x37ce0f=a716_0x314dcf;let _0x33c697={};const _0x1cc2d4={},_0x386722={'count':0x0,'rows':[]},_0x24b6e1=_[_0x37ce0f(0x15c)](db[_0x37ce0f(0x13e)][_0x37ce0f(0x160)],function(_0x410f9a){const _0x265b1a=_0x37ce0f;return{'name':_0x410f9a[_0x265b1a(0x16f)],'type':_0x410f9a['type'][_0x265b1a(0x141)]};});_0x1cc2d4[_0x37ce0f(0x12a)]=_[_0x37ce0f(0x15c)](_0x24b6e1,_0x37ce0f(0x176)),_0x1cc2d4[_0x37ce0f(0x13d)]=_[_0x37ce0f(0x161)](_0x58f5c7['query']),_0x1cc2d4[_0x37ce0f(0x167)]=_[_0x37ce0f(0x12b)](_0x1cc2d4[_0x37ce0f(0x12a)],_0x1cc2d4[_0x37ce0f(0x13d)]),_0x33c697[_0x37ce0f(0x14d)]=_[_0x37ce0f(0x12b)](_0x1cc2d4[_0x37ce0f(0x12a)],qs[_0x37ce0f(0x179)](_0x58f5c7[_0x37ce0f(0x13d)][_0x37ce0f(0x179)])),_0x33c697[_0x37ce0f(0x14d)]=_0x33c697['attributes'][_0x37ce0f(0x156)]?_0x33c697['attributes']:_0x1cc2d4[_0x37ce0f(0x12a)];typeof _0x58f5c7[_0x37ce0f(0x13d)][_0x37ce0f(0x155)]===_0x37ce0f(0x152)&&(_0x33c697[_0x37ce0f(0x125)]=qs[_0x37ce0f(0x125)](_0x58f5c7[_0x37ce0f(0x13d)]['limit']),_0x33c697['offset']=qs[_0x37ce0f(0x14a)](_0x58f5c7[_0x37ce0f(0x13d)]['offset']));_0x33c697[_0x37ce0f(0x13a)]=qs[_0x37ce0f(0x165)](_0x58f5c7[_0x37ce0f(0x13d)][_0x37ce0f(0x165)]),_0x33c697['where']=qs[_0x37ce0f(0x167)](_['pick'](_0x58f5c7[_0x37ce0f(0x13d)],_0x1cc2d4['filters']),_0x24b6e1),_0x33c697=filterAttributes(_0x33c697,_0x58f5c7[_0x37ce0f(0x13d)][_0x37ce0f(0x14e)],_0x24b6e1,_0x58f5c7[_0x37ce0f(0x16b)]);const _0x254dbd={'where':_0x33c697[_0x37ce0f(0x12c)]};return db[_0x37ce0f(0x13e)][_0x37ce0f(0x131)](_0x254dbd)['then'](function(_0x539aa8){const _0x4920b4=_0x37ce0f;return _0x386722[_0x4920b4(0x131)]=_0x539aa8,_0x58f5c7[_0x4920b4(0x13d)][_0x4920b4(0x14f)]&&(_0x33c697[_0x4920b4(0x136)]=[{'all':!![]}]),db[_0x4920b4(0x13e)][_0x4920b4(0x133)](_0x33c697);})[_0x37ce0f(0x158)](function(_0x496b3a){const _0x19cfef=_0x37ce0f;return _0x386722[_0x19cfef(0x169)]=_0x496b3a,_0x386722;})[_0x37ce0f(0x158)](respondWithFilteredResult(_0x11c1b8,_0x33c697))[_0x37ce0f(0x17a)](handleError(_0x11c1b8,null));},exports[a716_0x314dcf(0x177)]=function(_0x129bc1,_0x6fe3c5){const _0x119b66=a716_0x314dcf;let _0x5f2fbc={'raw':!![],'where':{'id':_0x129bc1['params']['id']}};const _0xd459de={};return _0xd459de['model']=_['keys'](db[_0x119b66(0x13e)]['rawAttributes']),_0xd459de[_0x119b66(0x13d)]=_[_0x119b66(0x161)](_0x129bc1[_0x119b66(0x13d)]),_0xd459de[_0x119b66(0x167)]=_[_0x119b66(0x12b)](_0xd459de[_0x119b66(0x12a)],_0xd459de['query']),_0x5f2fbc['attributes']=_[_0x119b66(0x12b)](_0xd459de[_0x119b66(0x12a)],qs[_0x119b66(0x179)](_0x129bc1[_0x119b66(0x13d)][_0x119b66(0x179)])),_0x5f2fbc[_0x119b66(0x14d)]=_0x5f2fbc[_0x119b66(0x14d)][_0x119b66(0x156)]?_0x5f2fbc[_0x119b66(0x14d)]:_0xd459de[_0x119b66(0x12a)],_0x129bc1[_0x119b66(0x13d)]['includeAll']&&(_0x5f2fbc['include']=[{'all':!![]}]),_0x5f2fbc=_[_0x119b66(0x144)]({},_0x5f2fbc,_0x129bc1[_0x119b66(0x16b)]),db[_0x119b66(0x13e)][_0x119b66(0x16d)](_0x5f2fbc)[_0x119b66(0x158)](handleEntityNotFound(_0x6fe3c5,null))[_0x119b66(0x158)](respondWithResult(_0x6fe3c5,null))[_0x119b66(0x17a)](handleError(_0x6fe3c5,null));},exports[a716_0x314dcf(0x151)]=function(_0xdc4d7f,_0x2a62d9){const _0xb2c60=a716_0x314dcf;return db[_0xb2c60(0x13e)][_0xb2c60(0x151)](_0xdc4d7f[_0xb2c60(0x128)],{})[_0xb2c60(0x158)](respondWithResult(_0x2a62d9,0xc9))[_0xb2c60(0x17a)](handleError(_0x2a62d9,null));},exports['update']=function(_0x23b6d9,_0x1e52c8){const _0x3116d1=a716_0x314dcf;return _0x23b6d9[_0x3116d1(0x128)]['id']&&delete _0x23b6d9[_0x3116d1(0x128)]['id'],db[_0x3116d1(0x13e)]['findOne']({'where':{'id':_0x23b6d9[_0x3116d1(0x171)]['id']}})[_0x3116d1(0x158)](handleEntityNotFound(_0x1e52c8,null))['then'](saveUpdates(_0x23b6d9[_0x3116d1(0x128)],null))[_0x3116d1(0x158)](respondWithResult(_0x1e52c8,null))['catch'](handleError(_0x1e52c8,null));},exports[a716_0x314dcf(0x15d)]=function(_0x4aa7d6,_0x58afe5){const _0x4a1731=a716_0x314dcf,_0x1272f5=require(_0x4a1731(0x15e));let _0xd9cbb3=![];const _0x3ab7a6={};return _0x4aa7d6[_0x4a1731(0x13d)][_0x4a1731(0x168)]&&_0x4aa7d6[_0x4a1731(0x13d)][_0x4a1731(0x168)]===_0x4a1731(0x16a)?_0x3ab7a6[_0x4a1731(0x16a)]=_0x4aa7d6['params']['id']:_0x3ab7a6['id']=_0x4aa7d6[_0x4a1731(0x171)]['id'],db[_0x4a1731(0x13e)][_0x4a1731(0x16d)]({'where':_0x3ab7a6,'attributes':['id','savePath',_0x4a1731(0x13f)],'raw':!![]})['then'](handleEntityNotFound(_0x58afe5,null))[_0x4a1731(0x158)](function(_0x166ed0){const _0x12c66f=_0x4a1731;if(_0x166ed0){const _0x2d1259=_0x166ed0[_0x12c66f(0x143)],_0x4276c3=util[_0x12c66f(0x145)](_0x12c66f(0x174),_0x2d1259);if(fs['existsSync'](_0x4276c3))return _0xd9cbb3=!![],_0x1272f5[_0x12c66f(0x14c)](_0x4276c3,_0x2d1259,config[_0x12c66f(0x12f)])[_0x12c66f(0x158)](function(){return _0x166ed0;});return _0x166ed0;}})[_0x4a1731(0x158)](function(_0x4784b8){const _0x36db8c=_0x4a1731;if(_0x4784b8){const _0x3fffeb=_0x4784b8[_0x36db8c(0x143)];if(!fs[_0x36db8c(0x16e)](_0x3fffeb))throw new ValidationError('SquareRecording\x20not\x20found');return _0x4784b8['filename']?_0x58afe5[_0x36db8c(0x15d)](_0x3fffeb,_0x4784b8[_0x36db8c(0x13f)]+path[_0x36db8c(0x135)](_0x3fffeb),function(){const _0x4cb6fa=_0x36db8c;_0xd9cbb3&&fs[_0x4cb6fa(0x130)](_0x3fffeb);}):_0x58afe5[_0x36db8c(0x15d)](_0x3fffeb,function(){const _0xcb0950=_0x36db8c;_0xd9cbb3&&fs[_0xcb0950(0x130)](_0x3fffeb);});}})['catch'](function(_0x250c72){const _0x2b18de=_0x4a1731;if(_0x250c72[_0x2b18de(0x132)]===_0x2b18de(0x146))_0x58afe5[_0x2b18de(0x140)](0x194)[_0x2b18de(0x127)](_0x2b18de(0x149));else return handleError(_0x58afe5,null);});},exports['destroy']=function(_0x51feb7,_0x21b22e){const _0x158695=a716_0x314dcf;return db['SquareRecording'][_0x158695(0x16d)]({'where':{'id':_0x51feb7[_0x158695(0x171)]['id']}})[_0x158695(0x158)](function(_0x5db077){const _0x3fa873=_0x158695;if(!_0x5db077)throw new ReferenceError(_0x3fa873(0x164));return _0x5db077;})[_0x158695(0x158)](function(_0x149d36){const _0x1dcb21=_0x158695;let _0x10cea8=_0x149d36[_0x1dcb21(0x143)];return logger[_0x1dcb21(0x162)](_0x1dcb21(0x15f),_0x10cea8),!_[_0x1dcb21(0x122)](_0x149d36['savePath'])&&fs[_0x1dcb21(0x16e)](_0x10cea8)&&(logger[_0x1dcb21(0x162)]('File:\x20\x22'+_0x10cea8+_0x1dcb21(0x15a)),fs[_0x1dcb21(0x16c)](_0x10cea8)),_0x10cea8=_0x10cea8+_0x1dcb21(0x154),!_['isNil'](_0x149d36[_0x1dcb21(0x143)])&&fs[_0x1dcb21(0x16e)](_0x10cea8)&&(logger[_0x1dcb21(0x162)](_0x1dcb21(0x12e)+_0x10cea8+_0x1dcb21(0x15a)),fs[_0x1dcb21(0x16c)](_0x10cea8)),_0x149d36;})[_0x158695(0x158)](function(_0x420e8f){const _0x356a07=_0x158695;if(!_0x420e8f)throw new InternalError();return _0x420e8f[_0x356a07(0x157)]();})[_0x158695(0x158)](function(){const _0x154f85=_0x158695;_0x21b22e[_0x154f85(0x140)](0xcc)['end']();})[_0x158695(0x17a)](handleError(_0x21b22e,null));};