Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index 1034b01..a49f7fb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb2d4=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','offset','undefined','count','limit','json','apply','reject','update','destroy','then','stack','name','send','index','map','VoiceRecording','rawAttributes','fieldName','key','model','differenceBy','format','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','params','options','create','body','find','describe','download','../../components/encryptor','type','uniqueid','value','%s.cypher','secrets','recording','existsSync','Sequelize','ValidationError','filename','unlink','message','VoiceRecording\x20not\x20found','Not\x20found','downloads','sequelize','MD5','col','token','$and','push','decryptFile','extname','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','isNil','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','end','createBucket','upload','TranscribeService','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','readFileSync','Location','bucket','Bucket','location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','TranscriptionJob','TranscriptionJobName','transcribeName','transcribeStatus','runTranscribe','findOne','Setting','transcribe','transcribeAccountId','transcribeRegion','language','Transcribe\x20not\x20configured','runSentiment','sentiment','CloudProvider','Cloud\x20Provider\x20not\x20available','data1','data2','Buckets','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','NEW','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','tempSentiment','updateAttributes','writeFile','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','Transcript\x20not\x20available','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','aws-sdk','uuid/v4','ioredis','../../components/parsers/qs'];(function(_0x514fc0,_0x1032a0){var _0x26f8ee=function(_0x3bd0da){while(--_0x3bd0da){_0x514fc0['push'](_0x514fc0['shift']());}};_0x26f8ee(++_0x1032a0);}(_0xb2d4,0x84));var _0x4b2d=function(_0xa1e3e3,_0x29fe0e){_0xa1e3e3=_0xa1e3e3-0x0;var _0xc980e9=_0xb2d4[_0xa1e3e3];return _0xc980e9;};'use strict';var emlformat=require(_0x4b2d('0x0'));var rimraf=require(_0x4b2d('0x1'));var zipdir=require(_0x4b2d('0x2'));var jsonpatch=require(_0x4b2d('0x3'));var rp=require(_0x4b2d('0x4'));var moment=require(_0x4b2d('0x5'));var BPromise=require(_0x4b2d('0x6'));var Mustache=require(_0x4b2d('0x7'));var util=require('util');var path=require(_0x4b2d('0x8'));var sox=require(_0x4b2d('0x9'));var csv=require(_0x4b2d('0xa'));var ejs=require(_0x4b2d('0xb'));var fs=require('fs');var fs_extra=require(_0x4b2d('0xc'));var _=require(_0x4b2d('0xd'));var squel=require(_0x4b2d('0xe'));var crypto=require('crypto');var jsforce=require(_0x4b2d('0xf'));var deskjs=require(_0x4b2d('0x10'));var toCsv=require(_0x4b2d('0xa'));var querystring=require(_0x4b2d('0x11'));var Papa=require(_0x4b2d('0x12'));var AWS=require(_0x4b2d('0x13'));var uuidv4=require(_0x4b2d('0x14'));var Redis=require(_0x4b2d('0x15'));var authService=require('../../components/auth/service');var qs=require(_0x4b2d('0x16'));var as=require(_0x4b2d('0x17'));var hardwareService=require(_0x4b2d('0x18'));var logger=require(_0x4b2d('0x19'))('api');var utils=require(_0x4b2d('0x1a'));var config=require(_0x4b2d('0x1b'));var licenseUtil=require(_0x4b2d('0x1c'));var db=require(_0x4b2d('0x1d'))['db'];function respondWithStatusCode(_0x3e478f,_0xfe3c04){_0xfe3c04=_0xfe3c04||0xcc;return function(_0x64c313){if(_0x64c313){return _0x3e478f[_0x4b2d('0x1e')](_0xfe3c04);}return _0x3e478f[_0x4b2d('0x1f')](_0xfe3c04)['end']();};}function respondWithResult(_0x111439,_0x12447f){_0x12447f=_0x12447f||0xc8;return function(_0x13cc10){if(_0x13cc10){return _0x111439[_0x4b2d('0x1f')](_0x12447f)['json'](_0x13cc10);}};}function respondWithFilteredResult(_0x3630f6,_0x380879){return function(_0x62ee9){if(_0x62ee9){var _0x62850f=typeof _0x380879[_0x4b2d('0x20')]===_0x4b2d('0x21')&&typeof _0x380879['limit']===_0x4b2d('0x21');var _0x5abc03=_0x62ee9[_0x4b2d('0x22')];var _0x20c9fd=_0x62850f?0x0:_0x380879[_0x4b2d('0x20')];var _0x5a3ca4=_0x62850f?_0x62ee9[_0x4b2d('0x22')]:_0x380879[_0x4b2d('0x20')]+_0x380879[_0x4b2d('0x23')];var _0x4184ba;if(_0x5a3ca4>=_0x5abc03){_0x5a3ca4=_0x5abc03;_0x4184ba=0xc8;}else{_0x4184ba=0xce;}_0x3630f6[_0x4b2d('0x1f')](_0x4184ba);return _0x3630f6['set']('Content-Range',_0x20c9fd+'-'+_0x5a3ca4+'/'+_0x5abc03)[_0x4b2d('0x24')](_0x62ee9);}return null;};}function patchUpdates(_0x5044ac){return function(_0x53cf59){try{jsonpatch[_0x4b2d('0x25')](_0x53cf59,_0x5044ac,!![]);}catch(_0x2f562){return BPromise[_0x4b2d('0x26')](_0x2f562);}return _0x53cf59['save']();};}function saveUpdates(_0x4a7022,_0x4c9e5a){return function(_0x3138fc){if(_0x3138fc){return _0x3138fc[_0x4b2d('0x27')](_0x4a7022)['then'](function(_0x309541){return _0x309541;});}return null;};}function removeEntity(_0x97f731,_0x268d72){return function(_0xb920ca){if(_0xb920ca){return _0xb920ca[_0x4b2d('0x28')]()[_0x4b2d('0x29')](function(){_0x97f731[_0x4b2d('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x392c3d,_0x3ee5a7){return function(_0xb8c179){if(!_0xb8c179){_0x392c3d[_0x4b2d('0x1e')](0x194);}return _0xb8c179;};}function handleError(_0x31abe1,_0x2d2d3a){_0x2d2d3a=_0x2d2d3a||0x1f4;return function(_0x5818da){logger['error'](_0x5818da[_0x4b2d('0x2a')]);if(_0x5818da[_0x4b2d('0x2b')]){delete _0x5818da['name'];}_0x31abe1[_0x4b2d('0x1f')](_0x2d2d3a)[_0x4b2d('0x2c')](_0x5818da);};}exports[_0x4b2d('0x2d')]=function(_0x5b41a4,_0xddd076){var _0x13d5a7={},_0x2c9b3e={},_0xc2dca0={'count':0x0,'rows':[]};var _0x58b65d=_[_0x4b2d('0x2e')](db[_0x4b2d('0x2f')][_0x4b2d('0x30')],function(_0x4122c1){return{'name':_0x4122c1[_0x4b2d('0x31')],'type':_0x4122c1['type'][_0x4b2d('0x32')]};});_0x2c9b3e[_0x4b2d('0x33')]=_[_0x4b2d('0x34')](_[_0x4b2d('0x2e')](_0x58b65d,_0x4b2d('0x2b')),[_0x4b2d('0x35')]);_0x2c9b3e[_0x4b2d('0x36')]=_[_0x4b2d('0x37')](_0x5b41a4[_0x4b2d('0x36')]);_0x2c9b3e[_0x4b2d('0x38')]=_[_0x4b2d('0x39')](_0x2c9b3e[_0x4b2d('0x33')],_0x2c9b3e['query']);_0x13d5a7[_0x4b2d('0x3a')]=_[_0x4b2d('0x39')](_0x2c9b3e[_0x4b2d('0x33')],qs[_0x4b2d('0x3b')](_0x5b41a4[_0x4b2d('0x36')][_0x4b2d('0x3b')]));_0x13d5a7[_0x4b2d('0x3a')]=_0x13d5a7[_0x4b2d('0x3a')][_0x4b2d('0x3c')]?_0x13d5a7[_0x4b2d('0x3a')]:_0x2c9b3e[_0x4b2d('0x33')];if(!_0x5b41a4[_0x4b2d('0x36')][_0x4b2d('0x3d')]('nolimit')){_0x13d5a7[_0x4b2d('0x23')]=qs['limit'](_0x5b41a4[_0x4b2d('0x36')][_0x4b2d('0x23')]);_0x13d5a7[_0x4b2d('0x20')]=qs[_0x4b2d('0x20')](_0x5b41a4[_0x4b2d('0x36')][_0x4b2d('0x20')]);}_0x13d5a7[_0x4b2d('0x3e')]=qs[_0x4b2d('0x3f')](_0x5b41a4[_0x4b2d('0x36')][_0x4b2d('0x3f')]);_0x13d5a7[_0x4b2d('0x40')]=qs[_0x4b2d('0x38')](_[_0x4b2d('0x41')](_0x5b41a4['query'],_0x2c9b3e[_0x4b2d('0x38')]),_0x58b65d);if(_0x5b41a4[_0x4b2d('0x36')][_0x4b2d('0x42')]){_0x13d5a7[_0x4b2d('0x40')]=_[_0x4b2d('0x43')](_0x13d5a7['where'],{'$or':_['map'](_0x58b65d,function(_0x3b7224){if(_0x3b7224['type']!==_0x4b2d('0x44')){var _0x485df6={};_0x485df6[_0x3b7224[_0x4b2d('0x2b')]]={'$like':'%'+_0x5b41a4[_0x4b2d('0x36')][_0x4b2d('0x42')]+'%'};return _0x485df6;}})});}_0x13d5a7=_[_0x4b2d('0x43')]({},_0x13d5a7,_0x5b41a4['options']);var _0x43b7af={'where':_0x13d5a7[_0x4b2d('0x40')]};return db['VoiceRecording'][_0x4b2d('0x22')](_0x43b7af)['then'](function(_0x5cf1e4){_0xc2dca0[_0x4b2d('0x22')]=_0x5cf1e4;if(_0x5b41a4[_0x4b2d('0x36')][_0x4b2d('0x45')]){_0x13d5a7[_0x4b2d('0x46')]=[{'all':!![]}];}return db['VoiceRecording'][_0x4b2d('0x47')](_0x13d5a7);})['then'](function(_0x3b3efa){_0xc2dca0[_0x4b2d('0x48')]=_0x3b3efa;return _0xc2dca0;})[_0x4b2d('0x29')](respondWithFilteredResult(_0xddd076,_0x13d5a7))[_0x4b2d('0x49')](handleError(_0xddd076,null));};exports['show']=function(_0x3a07aa,_0x212cd2){var _0x50bbd3={'raw':![],'where':{'id':_0x3a07aa[_0x4b2d('0x4a')]['id']}},_0x12b6de={};_0x12b6de['model']=_['keys'](db['VoiceRecording']['rawAttributes']);_0x12b6de[_0x4b2d('0x36')]=_[_0x4b2d('0x37')](_0x3a07aa[_0x4b2d('0x36')]);_0x12b6de[_0x4b2d('0x38')]=_['intersection'](_0x12b6de['model'],_0x12b6de[_0x4b2d('0x36')]);_0x50bbd3['attributes']=_[_0x4b2d('0x39')](_0x12b6de[_0x4b2d('0x33')],qs['fields'](_0x3a07aa[_0x4b2d('0x36')][_0x4b2d('0x3b')]));_0x50bbd3['attributes']=_0x50bbd3[_0x4b2d('0x3a')][_0x4b2d('0x3c')]?_0x50bbd3[_0x4b2d('0x3a')]:_0x12b6de[_0x4b2d('0x33')];if(_0x3a07aa['query'][_0x4b2d('0x45')]){_0x50bbd3[_0x4b2d('0x46')]=[{'all':!![]}];}_0x50bbd3=_[_0x4b2d('0x43')]({},_0x50bbd3,_0x3a07aa[_0x4b2d('0x4b')]);return db[_0x4b2d('0x2f')]['find'](_0x50bbd3)[_0x4b2d('0x29')](handleEntityNotFound(_0x212cd2,null))[_0x4b2d('0x29')](respondWithResult(_0x212cd2,null))[_0x4b2d('0x49')](handleError(_0x212cd2,null));};exports[_0x4b2d('0x4c')]=function(_0x1f6d95,_0x174d9f){return db['VoiceRecording'][_0x4b2d('0x4c')](_0x1f6d95[_0x4b2d('0x4d')],{})[_0x4b2d('0x29')](respondWithResult(_0x174d9f,0xc9))['catch'](handleError(_0x174d9f,null));};exports[_0x4b2d('0x27')]=function(_0x38e502,_0x1f334a){if(_0x38e502[_0x4b2d('0x4d')]['id']){delete _0x38e502['body']['id'];}return db[_0x4b2d('0x2f')][_0x4b2d('0x4e')]({'where':{'id':_0x38e502['params']['id']}})[_0x4b2d('0x29')](handleEntityNotFound(_0x1f334a,null))['then'](saveUpdates(_0x38e502[_0x4b2d('0x4d')],null))['then'](respondWithResult(_0x1f334a,null))[_0x4b2d('0x49')](handleError(_0x1f334a,null));};exports[_0x4b2d('0x4f')]=function(_0x98602,_0x17db45){return db[_0x4b2d('0x2f')][_0x4b2d('0x4f')]()[_0x4b2d('0x29')](respondWithResult(_0x17db45,null))[_0x4b2d('0x49')](handleError(_0x17db45,null));};exports[_0x4b2d('0x50')]=function(_0x52cc60,_0x5a2f0c,_0x1d58dd){var _0xff2132=require(_0x4b2d('0x51'));var _0x3d53e3=![];var _0x56bb80={};if(_0x52cc60[_0x4b2d('0x36')][_0x4b2d('0x52')]&&_0x52cc60[_0x4b2d('0x36')]['type']===_0x4b2d('0x53')){_0x56bb80[_0x4b2d('0x53')]=_0x52cc60['params']['id'];}else{_0x56bb80['id']=_0x52cc60['params']['id'];}return db['VoiceRecording'][_0x4b2d('0x4e')]({'where':_0x56bb80,'attributes':['id',_0x4b2d('0x54')],'raw':!![]})[_0x4b2d('0x29')](handleEntityNotFound(_0x5a2f0c,null))[_0x4b2d('0x29')](function(_0x327749){if(_0x327749){var _0x4c236f=_0x327749[_0x4b2d('0x54')];var _0x40825a=util[_0x4b2d('0x35')](_0x4b2d('0x55'),_0x4c236f);if(fs['existsSync'](_0x40825a)){_0x3d53e3=!![];return _0xff2132['decryptFile'](_0x40825a,_0x4c236f,config[_0x4b2d('0x56')][_0x4b2d('0x57')])[_0x4b2d('0x29')](function(){return _0x327749;});}return _0x327749;}})[_0x4b2d('0x29')](function(_0x15e967){if(_0x15e967){var _0x1b4924=_0x15e967['value'];if(!fs[_0x4b2d('0x58')](_0x1b4924)){throw new db[(_0x4b2d('0x59'))][(_0x4b2d('0x5a'))]('VoiceRecording\x20not\x20found');}if(_0x15e967[_0x4b2d('0x5b')]){return _0x5a2f0c[_0x4b2d('0x50')](_0x1b4924,_0x15e967[_0x4b2d('0x5b')]+path['extname'](_0x1b4924),function(){if(_0x3d53e3){fs['unlink'](_0x1b4924);}});}else{return _0x5a2f0c['download'](_0x1b4924,function(_0x211791){if(_0x3d53e3){fs[_0x4b2d('0x5c')](_0x1b4924);}});}}})[_0x4b2d('0x49')](function(_0x2c871e){if(_0x2c871e[_0x4b2d('0x5d')]===_0x4b2d('0x5e')){_0x5a2f0c[_0x4b2d('0x1f')](0x194)[_0x4b2d('0x2c')](_0x4b2d('0x5f'));}else{return handleError(_0x5a2f0c,null);}});};exports[_0x4b2d('0x60')]=function(_0x423cc0,_0x546536,_0x5cac6f){var _0x53e7b6=require(_0x4b2d('0x51'));var _0x3761e3=![];var _0x2cab5b={'$and':[db['sequelize'][_0x4b2d('0x40')](db[_0x4b2d('0x61')]['fn'](_0x4b2d('0x62'),db[_0x4b2d('0x61')][_0x4b2d('0x63')](_0x4b2d('0x53'))),_0x423cc0['query'][_0x4b2d('0x64')])]};if(_0x423cc0[_0x4b2d('0x36')]['type']&&_0x423cc0[_0x4b2d('0x36')]['type']===_0x4b2d('0x53')){_0x2cab5b[_0x4b2d('0x65')][_0x4b2d('0x66')]({'uniqueid':_0x423cc0[_0x4b2d('0x4a')]['id']});}else{_0x2cab5b['$and'][_0x4b2d('0x66')]({'id':_0x423cc0['params']['id']});}return db[_0x4b2d('0x2f')][_0x4b2d('0x4e')]({'where':_0x2cab5b,'attributes':['id',_0x4b2d('0x54')],'raw':!![]})[_0x4b2d('0x29')](handleEntityNotFound(_0x546536,null))[_0x4b2d('0x29')](function(_0x3a3698){if(_0x3a3698){var _0x190643=util[_0x4b2d('0x35')](_0x4b2d('0x55'),_0x3a3698[_0x4b2d('0x54')]);if(fs[_0x4b2d('0x58')](_0x190643)){_0x3761e3=!![];return _0x53e7b6[_0x4b2d('0x67')](_0x190643,_0x3a3698['value'],config[_0x4b2d('0x56')][_0x4b2d('0x57')])[_0x4b2d('0x29')](function(){return _0x3a3698;});}return _0x3a3698;}})[_0x4b2d('0x29')](function(_0x38a635){if(_0x38a635){if(!fs['existsSync'](_0x38a635[_0x4b2d('0x54')])){throw new db['Sequelize'][(_0x4b2d('0x5a'))](_0x4b2d('0x5e'));}if(_0x38a635['filename']){return _0x546536[_0x4b2d('0x50')](_0x38a635[_0x4b2d('0x54')],_0x38a635[_0x4b2d('0x5b')]+path[_0x4b2d('0x68')](_0x38a635[_0x4b2d('0x54')]),function(){if(_0x3761e3){fs[_0x4b2d('0x5c')](_0x38a635['value']);}});}else{return _0x546536[_0x4b2d('0x50')](_0x38a635[_0x4b2d('0x54')],function(_0x17b4cd){if(_0x3761e3){fs[_0x4b2d('0x5c')](_0x38a635['value']);}});}}})['catch'](handleError(_0x546536,null));};exports[_0x4b2d('0x28')]=function(_0x4b7e8a,_0x62cee6){return db['VoiceRecording'][_0x4b2d('0x4e')]({'where':{'id':_0x4b7e8a[_0x4b2d('0x4a')]['id']}})[_0x4b2d('0x29')](function(_0x14ac5b){if(_['isNil'](_0x14ac5b)){throw new ReferenceError(_0x4b2d('0x69'));}return _0x14ac5b;})[_0x4b2d('0x29')](function(_0x58c2ab){var _0x22dc5d=_0x58c2ab[_0x4b2d('0x54')];logger[_0x4b2d('0x6a')](_0x4b2d('0x6b'),_0x22dc5d);if(!_[_0x4b2d('0x6c')](_0x58c2ab['value'])&&fs['existsSync'](_0x22dc5d)){logger['info'](_0x4b2d('0x6d')+_0x22dc5d+_0x4b2d('0x6e'));fs['unlinkSync'](_0x22dc5d);}_0x22dc5d=_0x22dc5d+'.cypher';if(!_['isNil'](_0x58c2ab[_0x4b2d('0x54')])&&fs[_0x4b2d('0x58')](_0x22dc5d)){logger[_0x4b2d('0x6a')]('File:\x20\x22'+_0x22dc5d+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs[_0x4b2d('0x6f')](_0x22dc5d);}return _0x58c2ab;})[_0x4b2d('0x29')](function(_0x1f9316){if(!_0x1f9316)throw new InternalError();return _0x1f9316[_0x4b2d('0x28')]();})[_0x4b2d('0x29')](function(){_0x62cee6[_0x4b2d('0x1f')](0xcc)[_0x4b2d('0x70')]();})[_0x4b2d('0x49')](handleError(_0x62cee6,null));};function getBucketslist(_0x5613ea,_0x5c9275,_0x3c2036){return new Promise(function(_0x4dc60f,_0x277cb3){var _0xe9aea2=new AWS['S3']({'accessKeyId':_0x5c9275,'secretAccessKey':_0x5613ea,'region':_0x3c2036});_0xe9aea2['listBuckets']({},function(_0xb565ed,_0x24faa3){if(_0xb565ed){return _0x277cb3(_0xb565ed);}else{return _0x4dc60f(_0x24faa3);}});});}function createBucket(_0x151281,_0x42104b,_0x256eb8,_0x2211dc){return new Promise(function(_0x2112fb,_0x562eeb){var _0x309d5b=new AWS['S3']({'accessKeyId':_0x42104b,'secretAccessKey':_0x151281,'region':_0x256eb8});_0x309d5b[_0x4b2d('0x71')]({'Bucket':_0x2211dc},function(_0x620315,_0x36b3c3){if(_0x620315){return _0x562eeb(_0x620315);}else{return _0x2112fb(_0x36b3c3);}});});}function uploadFile(_0x2b23f9,_0x15ef05,_0x324f0a,_0x56522f,_0x41278c,_0x27469f){return new Promise(function(_0x2a68c8,_0x5b2177){var _0x289ee2=new AWS['S3']({'accessKeyId':_0x15ef05,'secretAccessKey':_0x2b23f9,'region':_0x324f0a});_0x289ee2[_0x4b2d('0x72')]({'Bucket':_0x56522f,'Key':_0x41278c,'Body':_0x27469f},function(_0xe36baf,_0x1952fd){if(_0xe36baf){return _0x5b2177(_0xe36baf);}else{return _0x2a68c8(_0x1952fd);}});});}function startTranscribe(_0x5976c4,_0x15067b,_0x5518b0,_0x4dfd10,_0x1a08ad,_0x4fa3ba){return new Promise(function(_0x316476,_0x31e7a7){var _0x4ead71=new AWS[(_0x4b2d('0x73'))]({'accessKeyId':_0x15067b,'secretAccessKey':_0x5976c4,'region':_0x5518b0});_0x4ead71[_0x4b2d('0x74')]({'TranscriptionJobName':_0x4dfd10,'LanguageCode':_0x1a08ad,'Media':{'MediaFileUri':_0x4fa3ba}},function(_0x3e9ed4,_0x124567){if(_0x3e9ed4){return _0x31e7a7(_0x3e9ed4);}else{return _0x316476(_0x124567);}});});}function transcribe(_0x1b4069,_0x265ac9,_0x58051f,_0x6966a,_0x100838,_0x394ae5,_0x42179f){return new Promise(function(_0x2589e5,_0x5ea637){var _0x3d04d8={};logger['info'](util[_0x4b2d('0x35')](_0x4b2d('0x75'),_0x1b4069,_0x100838));return uploadFile(_0x265ac9,_0x58051f,_0x6966a,_0x100838,path['basename'](_0x394ae5),fs[_0x4b2d('0x76')](_0x394ae5))['then'](function(_0x521d02){logger['info'](util[_0x4b2d('0x35')]('[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)',_0x1b4069,_0x100838,_0x521d02[_0x4b2d('0x77')]));_0x3d04d8[_0x4b2d('0x78')]=_0x521d02[_0x4b2d('0x79')];_0x3d04d8[_0x4b2d('0x7a')]=_0x521d02['Location'];logger['info'](util[_0x4b2d('0x35')](_0x4b2d('0x7b'),_0x1b4069));return startTranscribe(_0x265ac9,_0x58051f,_0x6966a,uuidv4(),_0x42179f,_0x521d02[_0x4b2d('0x77')]);})[_0x4b2d('0x29')](function(_0x114c13){logger[_0x4b2d('0x6a')](util[_0x4b2d('0x35')]('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0x1b4069,_0x114c13[_0x4b2d('0x7c')][_0x4b2d('0x7d')]));_0x3d04d8[_0x4b2d('0x7e')]=_0x114c13[_0x4b2d('0x7c')][_0x4b2d('0x7d')];_0x3d04d8[_0x4b2d('0x7f')]=_0x114c13[_0x4b2d('0x7c')]['TranscriptionJobStatus'];return _0x2589e5(_0x3d04d8);})[_0x4b2d('0x49')](function(_0x1d5e41){return _0x5ea637(_0x1d5e41);});});}exports[_0x4b2d('0x80')]=function(_0x2d601b,_0x2345ed,_0x4d3e51){var _0x5415ec;var _0x7dab6;var _0x5120b1;var _0x537ddf=require(_0x4b2d('0x51'));return db[_0x4b2d('0x2f')][_0x4b2d('0x81')]({'where':{'id':_0x2d601b[_0x4b2d('0x4a')]['id']}})[_0x4b2d('0x29')](function(_0x49a43f){if(_0x49a43f){var _0x5d3754=util[_0x4b2d('0x35')](_0x4b2d('0x55'),_0x49a43f[_0x4b2d('0x54')]);if(fs[_0x4b2d('0x58')](_0x5d3754)){cypher=!![];return _0x537ddf[_0x4b2d('0x67')](_0x5d3754,_0x49a43f[_0x4b2d('0x54')],config[_0x4b2d('0x56')]['recording'])[_0x4b2d('0x29')](function(){return _0x49a43f;});}return _0x49a43f;}})[_0x4b2d('0x29')](function(_0xf5edb8){if(!_0xf5edb8){throw new db['Sequelize'][(_0x4b2d('0x5a'))]('Voice\x20Recording\x20not\x20found');}_0x7dab6=_0xf5edb8;return db[_0x4b2d('0x82')][_0x4b2d('0x81')]({'where':{'id':0x1}});})['then'](handleEntityNotFound(_0x2345ed,null))[_0x4b2d('0x29')](function(_0x215e33){if(_0x215e33){_0x5415ec=_0x215e33;if(!_0x5415ec[_0x4b2d('0x83')]||!_0x5415ec[_0x4b2d('0x84')]||!_0x5415ec[_0x4b2d('0x85')]||!_0x5415ec[_0x4b2d('0x86')]||!_0x5415ec['bucket']){throw new db[(_0x4b2d('0x59'))][(_0x4b2d('0x5a'))](_0x4b2d('0x87'));}if(_0x2d601b[_0x4b2d('0x4d')][_0x4b2d('0x88')]&&(!_0x5415ec[_0x4b2d('0x89')]||!_0x5415ec['sentimentAccountId']||!_0x5415ec['sentimentRegion']||!_0x5415ec[_0x4b2d('0x86')]||!_0x5415ec['bucket'])){throw new db[(_0x4b2d('0x59'))]['ValidationError']('Sentiment\x20Analysis\x20not\x20configured');}return db[_0x4b2d('0x8a')][_0x4b2d('0x81')]({'where':{'id':_0x5415ec[_0x4b2d('0x84')]}});}})['then'](function(_0x1a6263){if(!_0x1a6263){throw new db[(_0x4b2d('0x59'))]['ValidationError'](_0x4b2d('0x8b'));}if(!_0x1a6263[_0x4b2d('0x8c')]||!_0x1a6263[_0x4b2d('0x8d')]){throw new db['Sequelize'][(_0x4b2d('0x5a'))]('Cloud\x20Provider\x20not\x20configured');}_0x5120b1=_0x1a6263;return getBucketslist(_0x5120b1['data1'],_0x5120b1[_0x4b2d('0x8d')],_0x5415ec['transcribeRegion']);})[_0x4b2d('0x29')](function(_0x18ccee){if(_0x18ccee&&_0x18ccee[_0x4b2d('0x8e')]){var _0x1079a4=_['find'](_0x18ccee[_0x4b2d('0x8e')],function(_0x2315da){return _0x2315da['Name']===_0x5415ec[_0x4b2d('0x78')];});if(!_0x1079a4){logger['info'](util[_0x4b2d('0x35')](_0x4b2d('0x8f'),_0x2d601b[_0x4b2d('0x4a')]['id'],_0x5415ec[_0x4b2d('0x78')]));return createBucket(_0x5120b1[_0x4b2d('0x8c')],_0x5120b1[_0x4b2d('0x8d')],_0x5415ec[_0x4b2d('0x85')],_0x5415ec['bucket']);}logger['info'](util['format']('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available',_0x2d601b[_0x4b2d('0x4a')]['id'],_0x5415ec['bucket']));return;}})[_0x4b2d('0x29')](function(_0x2d8956){if(_0x7dab6[_0x4b2d('0x7f')]===_0x4b2d('0x90')){return transcribe(_0x2d601b[_0x4b2d('0x4a')]['id'],_0x5120b1[_0x4b2d('0x8c')],_0x5120b1[_0x4b2d('0x8d')],_0x5415ec[_0x4b2d('0x85')],_0x5415ec['bucket'],_0x7dab6[_0x4b2d('0x54')],_0x5415ec[_0x4b2d('0x86')]);}else{logger[_0x4b2d('0x6a')](util[_0x4b2d('0x35')](_0x4b2d('0x91'),_0x2d601b[_0x4b2d('0x4a')]['id']));return{'transcribeStatus':_0x4b2d('0x92')};}})[_0x4b2d('0x29')](function(_0x4de904){if(_0x4de904){_0x4de904[_0x4b2d('0x93')]=_0x2d601b[_0x4b2d('0x4d')][_0x4b2d('0x88')];return _0x7dab6[_0x4b2d('0x94')](_0x4de904);}})[_0x4b2d('0x29')](respondWithResult(_0x2345ed,null))[_0x4b2d('0x49')](handleError(_0x2345ed,null));};function writeFile(_0xdbfcf2,_0x43a81a){return new Promise(function(_0x5a5043,_0x1679cb){fs[_0x4b2d('0x95')](_0x43a81a,_0xdbfcf2,function(_0x380ca1,_0x3f4595){if(_0x380ca1){return _0x1679cb(_0x380ca1);}else{return _0x5a5043(_0x3f4595);}});});}exports[_0x4b2d('0x96')]=function(_0x37b0f1,_0x2d7aad,_0xd3ced8){return db[_0x4b2d('0x2f')][_0x4b2d('0x81')]({'where':{'id':_0x37b0f1[_0x4b2d('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2d7aad))['then'](function(_0x13e5b4){if(_0x13e5b4&&_0x13e5b4['fileText']){var _0x2ab978=_0x13e5b4[_0x4b2d('0x97')];var _0x489743=config[_0x4b2d('0x98')]+_0x4b2d('0x99')+_0x13e5b4['id']+'.txt';if(fs[_0x4b2d('0x58')](_0x489743)){return _0x489743;}return writeFile(_0x2ab978,_0x489743)[_0x4b2d('0x29')](function(){return _0x489743;});}else{throw new db[(_0x4b2d('0x59'))]['ValidationError'](_0x4b2d('0x9a'));}})[_0x4b2d('0x29')](function(_0x5e3da8){return _0x2d7aad[_0x4b2d('0x50')](_0x5e3da8);})[_0x4b2d('0x49')](handleError(_0x2d7aad));};
\ No newline at end of file
+var _0x2f65=['recording','Sequelize','ValidationError','filename','unlink','message','VoiceRecording\x20not\x20found','downloads','sequelize','MD5','col','uniqueid','token','$and','push','decryptFile','extname','isNil','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','createBucket','upload','TranscribeService','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','basename','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','bucket','Bucket','location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','TranscriptionJob','TranscriptionJobName','transcribeStatus','TranscriptionJobStatus','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribe','transcribeAccountId','transcribeRegion','language','sentiment','sentimentAccountId','sentimentRegion','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','data1','data2','Buckets','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','NEW','IN_PROGRESS','tempSentiment','runSentiment','updateAttributes','downloadTranscribe','fileText','root','.txt','Transcript\x20not\x20available','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','to-csv','fs-extra','crypto','jsforce','desk.js','querystring','papaparse','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','end','status','json','offset','undefined','limit','count','Content-Range','apply','save','update','then','destroy','error','stack','name','send','VoiceRecording','rawAttributes','type','model','differenceBy','map','format','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','VIRTUAL','filter','merge','options','includeAll','include','rows','catch','show','params','keys','create','body','find','describe','download','../../components/encryptor','value','%s.cypher','existsSync','secrets'];(function(_0x4a5516,_0x4cf973){var _0x161148=function(_0xe05e8a){while(--_0xe05e8a){_0x4a5516['push'](_0x4a5516['shift']());}};_0x161148(++_0x4cf973);}(_0x2f65,0x179));var _0x52f6=function(_0x5900bb,_0x35566b){_0x5900bb=_0x5900bb-0x0;var _0x1fe8ca=_0x2f65[_0x5900bb];return _0x1fe8ca;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x52f6('0x0'));var zipdir=require(_0x52f6('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x52f6('0x2'));var moment=require(_0x52f6('0x3'));var BPromise=require(_0x52f6('0x4'));var Mustache=require('mustache');var util=require(_0x52f6('0x5'));var path=require(_0x52f6('0x6'));var sox=require(_0x52f6('0x7'));var csv=require(_0x52f6('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x52f6('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x52f6('0xa'));var jsforce=require(_0x52f6('0xb'));var deskjs=require(_0x52f6('0xc'));var toCsv=require('to-csv');var querystring=require(_0x52f6('0xd'));var Papa=require(_0x52f6('0xe'));var AWS=require('aws-sdk');var uuidv4=require(_0x52f6('0xf'));var Redis=require(_0x52f6('0x10'));var authService=require(_0x52f6('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x52f6('0x12'));var hardwareService=require(_0x52f6('0x13'));var logger=require(_0x52f6('0x14'))(_0x52f6('0x15'));var utils=require(_0x52f6('0x16'));var config=require(_0x52f6('0x17'));var licenseUtil=require(_0x52f6('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x360b87,_0x29e3f2){_0x29e3f2=_0x29e3f2||0xcc;return function(_0x5544d3){if(_0x5544d3){return _0x360b87[_0x52f6('0x19')](_0x29e3f2);}return _0x360b87['status'](_0x29e3f2)[_0x52f6('0x1a')]();};}function respondWithResult(_0x7d9d8c,_0xf196ed){_0xf196ed=_0xf196ed||0xc8;return function(_0x26c3c4){if(_0x26c3c4){return _0x7d9d8c[_0x52f6('0x1b')](_0xf196ed)[_0x52f6('0x1c')](_0x26c3c4);}};}function respondWithFilteredResult(_0x359d33,_0x5341f4){return function(_0x16e9e0){if(_0x16e9e0){var _0x7cb89b=typeof _0x5341f4[_0x52f6('0x1d')]===_0x52f6('0x1e')&&typeof _0x5341f4[_0x52f6('0x1f')]==='undefined';var _0x42c0e5=_0x16e9e0[_0x52f6('0x20')];var _0xfcd933=_0x7cb89b?0x0:_0x5341f4['offset'];var _0x18f3d3=_0x7cb89b?_0x16e9e0[_0x52f6('0x20')]:_0x5341f4[_0x52f6('0x1d')]+_0x5341f4['limit'];var _0x20b9ca;if(_0x18f3d3>=_0x42c0e5){_0x18f3d3=_0x42c0e5;_0x20b9ca=0xc8;}else{_0x20b9ca=0xce;}_0x359d33['status'](_0x20b9ca);return _0x359d33['set'](_0x52f6('0x21'),_0xfcd933+'-'+_0x18f3d3+'/'+_0x42c0e5)['json'](_0x16e9e0);}return null;};}function patchUpdates(_0x3eab03){return function(_0x33876a){try{jsonpatch[_0x52f6('0x22')](_0x33876a,_0x3eab03,!![]);}catch(_0x720c7a){return BPromise['reject'](_0x720c7a);}return _0x33876a[_0x52f6('0x23')]();};}function saveUpdates(_0x44fe32,_0x1e83e0){return function(_0x5180ee){if(_0x5180ee){return _0x5180ee[_0x52f6('0x24')](_0x44fe32)[_0x52f6('0x25')](function(_0x47fa26){return _0x47fa26;});}return null;};}function removeEntity(_0x1fa6a1,_0x3002e5){return function(_0x2196f1){if(_0x2196f1){return _0x2196f1[_0x52f6('0x26')]()[_0x52f6('0x25')](function(){_0x1fa6a1[_0x52f6('0x1b')](0xcc)[_0x52f6('0x1a')]();});}};}function handleEntityNotFound(_0x1de416,_0x486d20){return function(_0x19a259){if(!_0x19a259){_0x1de416[_0x52f6('0x19')](0x194);}return _0x19a259;};}function handleError(_0x13cd2e,_0x4767b7){_0x4767b7=_0x4767b7||0x1f4;return function(_0x466c88){logger[_0x52f6('0x27')](_0x466c88[_0x52f6('0x28')]);if(_0x466c88[_0x52f6('0x29')]){delete _0x466c88[_0x52f6('0x29')];}_0x13cd2e[_0x52f6('0x1b')](_0x4767b7)[_0x52f6('0x2a')](_0x466c88);};}exports['index']=function(_0x4d31dc,_0x1a609d){var _0x132688={},_0x5a74e2={},_0x54fa2d={'count':0x0,'rows':[]};var _0x36a875=_['map'](db[_0x52f6('0x2b')][_0x52f6('0x2c')],function(_0x1b7759){return{'name':_0x1b7759['fieldName'],'type':_0x1b7759[_0x52f6('0x2d')]['key']};});_0x5a74e2[_0x52f6('0x2e')]=_[_0x52f6('0x2f')](_[_0x52f6('0x30')](_0x36a875,_0x52f6('0x29')),[_0x52f6('0x31')]);_0x5a74e2[_0x52f6('0x32')]=_['keys'](_0x4d31dc[_0x52f6('0x32')]);_0x5a74e2[_0x52f6('0x33')]=_[_0x52f6('0x34')](_0x5a74e2[_0x52f6('0x2e')],_0x5a74e2[_0x52f6('0x32')]);_0x132688[_0x52f6('0x35')]=_[_0x52f6('0x34')](_0x5a74e2[_0x52f6('0x2e')],qs['fields'](_0x4d31dc[_0x52f6('0x32')][_0x52f6('0x36')]));_0x132688[_0x52f6('0x35')]=_0x132688['attributes'][_0x52f6('0x37')]?_0x132688[_0x52f6('0x35')]:_0x5a74e2['model'];if(!_0x4d31dc['query'][_0x52f6('0x38')](_0x52f6('0x39'))){_0x132688[_0x52f6('0x1f')]=qs[_0x52f6('0x1f')](_0x4d31dc['query'][_0x52f6('0x1f')]);_0x132688[_0x52f6('0x1d')]=qs[_0x52f6('0x1d')](_0x4d31dc[_0x52f6('0x32')][_0x52f6('0x1d')]);}_0x132688['order']=qs['sort'](_0x4d31dc[_0x52f6('0x32')][_0x52f6('0x3a')]);_0x132688[_0x52f6('0x3b')]=qs['filters'](_[_0x52f6('0x3c')](_0x4d31dc[_0x52f6('0x32')],_0x5a74e2[_0x52f6('0x33')]),_0x36a875);if(_0x4d31dc[_0x52f6('0x32')]['filter']){_0x132688['where']=_['merge'](_0x132688[_0x52f6('0x3b')],{'$or':_[_0x52f6('0x30')](_0x36a875,function(_0x543f50){if(_0x543f50[_0x52f6('0x2d')]!==_0x52f6('0x3d')){var _0x576104={};_0x576104[_0x543f50[_0x52f6('0x29')]]={'$like':'%'+_0x4d31dc[_0x52f6('0x32')][_0x52f6('0x3e')]+'%'};return _0x576104;}})});}_0x132688=_[_0x52f6('0x3f')]({},_0x132688,_0x4d31dc[_0x52f6('0x40')]);var _0x65ed5f={'where':_0x132688[_0x52f6('0x3b')]};return db['VoiceRecording'][_0x52f6('0x20')](_0x65ed5f)[_0x52f6('0x25')](function(_0x262741){_0x54fa2d[_0x52f6('0x20')]=_0x262741;if(_0x4d31dc[_0x52f6('0x32')][_0x52f6('0x41')]){_0x132688[_0x52f6('0x42')]=[{'all':!![]}];}return db[_0x52f6('0x2b')]['findAll'](_0x132688);})['then'](function(_0x5b996e){_0x54fa2d[_0x52f6('0x43')]=_0x5b996e;return _0x54fa2d;})[_0x52f6('0x25')](respondWithFilteredResult(_0x1a609d,_0x132688))[_0x52f6('0x44')](handleError(_0x1a609d,null));};exports[_0x52f6('0x45')]=function(_0x27f794,_0x58a2f3){var _0x333d3e={'raw':![],'where':{'id':_0x27f794[_0x52f6('0x46')]['id']}},_0x4b139a={};_0x4b139a[_0x52f6('0x2e')]=_[_0x52f6('0x47')](db[_0x52f6('0x2b')][_0x52f6('0x2c')]);_0x4b139a[_0x52f6('0x32')]=_[_0x52f6('0x47')](_0x27f794['query']);_0x4b139a[_0x52f6('0x33')]=_[_0x52f6('0x34')](_0x4b139a[_0x52f6('0x2e')],_0x4b139a[_0x52f6('0x32')]);_0x333d3e[_0x52f6('0x35')]=_['intersection'](_0x4b139a[_0x52f6('0x2e')],qs[_0x52f6('0x36')](_0x27f794[_0x52f6('0x32')][_0x52f6('0x36')]));_0x333d3e['attributes']=_0x333d3e['attributes'][_0x52f6('0x37')]?_0x333d3e[_0x52f6('0x35')]:_0x4b139a[_0x52f6('0x2e')];if(_0x27f794['query'][_0x52f6('0x41')]){_0x333d3e[_0x52f6('0x42')]=[{'all':!![]}];}_0x333d3e=_[_0x52f6('0x3f')]({},_0x333d3e,_0x27f794[_0x52f6('0x40')]);return db[_0x52f6('0x2b')]['find'](_0x333d3e)[_0x52f6('0x25')](handleEntityNotFound(_0x58a2f3,null))[_0x52f6('0x25')](respondWithResult(_0x58a2f3,null))[_0x52f6('0x44')](handleError(_0x58a2f3,null));};exports[_0x52f6('0x48')]=function(_0x419e07,_0x441016){return db[_0x52f6('0x2b')][_0x52f6('0x48')](_0x419e07[_0x52f6('0x49')],{})[_0x52f6('0x25')](respondWithResult(_0x441016,0xc9))[_0x52f6('0x44')](handleError(_0x441016,null));};exports[_0x52f6('0x24')]=function(_0x26149e,_0x23fc77){if(_0x26149e[_0x52f6('0x49')]['id']){delete _0x26149e[_0x52f6('0x49')]['id'];}return db[_0x52f6('0x2b')][_0x52f6('0x4a')]({'where':{'id':_0x26149e['params']['id']}})[_0x52f6('0x25')](handleEntityNotFound(_0x23fc77,null))[_0x52f6('0x25')](saveUpdates(_0x26149e[_0x52f6('0x49')],null))[_0x52f6('0x25')](respondWithResult(_0x23fc77,null))[_0x52f6('0x44')](handleError(_0x23fc77,null));};exports[_0x52f6('0x4b')]=function(_0x54a4b5,_0x166522){return db[_0x52f6('0x2b')][_0x52f6('0x4b')]()[_0x52f6('0x25')](respondWithResult(_0x166522,null))[_0x52f6('0x44')](handleError(_0x166522,null));};exports[_0x52f6('0x4c')]=function(_0x413a96,_0x55ddbf,_0x4b3f9d){var _0x2e3160=require(_0x52f6('0x4d'));var _0x3368ae=![];var _0x106632={};if(_0x413a96['query'][_0x52f6('0x2d')]&&_0x413a96[_0x52f6('0x32')][_0x52f6('0x2d')]==='uniqueid'){_0x106632['uniqueid']=_0x413a96[_0x52f6('0x46')]['id'];}else{_0x106632['id']=_0x413a96[_0x52f6('0x46')]['id'];}return db[_0x52f6('0x2b')]['find']({'where':_0x106632,'attributes':['id',_0x52f6('0x4e')],'raw':!![]})[_0x52f6('0x25')](handleEntityNotFound(_0x55ddbf,null))[_0x52f6('0x25')](function(_0x55feaf){if(_0x55feaf){var _0x43be82=_0x55feaf[_0x52f6('0x4e')];var _0x54dc90=util[_0x52f6('0x31')](_0x52f6('0x4f'),_0x43be82);if(fs[_0x52f6('0x50')](_0x54dc90)){_0x3368ae=!![];return _0x2e3160['decryptFile'](_0x54dc90,_0x43be82,config[_0x52f6('0x51')][_0x52f6('0x52')])[_0x52f6('0x25')](function(){return _0x55feaf;});}return _0x55feaf;}})[_0x52f6('0x25')](function(_0x61b1a6){if(_0x61b1a6){var _0x170ff5=_0x61b1a6['value'];if(!fs[_0x52f6('0x50')](_0x170ff5)){throw new db[(_0x52f6('0x53'))][(_0x52f6('0x54'))]('VoiceRecording\x20not\x20found');}if(_0x61b1a6[_0x52f6('0x55')]){return _0x55ddbf[_0x52f6('0x4c')](_0x170ff5,_0x61b1a6[_0x52f6('0x55')]+path['extname'](_0x170ff5),function(){if(_0x3368ae){fs[_0x52f6('0x56')](_0x170ff5);}});}else{return _0x55ddbf['download'](_0x170ff5,function(_0x2bd554){if(_0x3368ae){fs[_0x52f6('0x56')](_0x170ff5);}});}}})[_0x52f6('0x44')](function(_0x590732){if(_0x590732[_0x52f6('0x57')]===_0x52f6('0x58')){_0x55ddbf[_0x52f6('0x1b')](0x194)[_0x52f6('0x2a')]('Not\x20found');}else{return handleError(_0x55ddbf,null);}});};exports[_0x52f6('0x59')]=function(_0x26a59b,_0xd7b79,_0x2bafd5){var _0x1c0bd0=require('../../components/encryptor');var _0x571584=![];var _0xd353ab={'$and':[db[_0x52f6('0x5a')][_0x52f6('0x3b')](db[_0x52f6('0x5a')]['fn'](_0x52f6('0x5b'),db[_0x52f6('0x5a')][_0x52f6('0x5c')](_0x52f6('0x5d'))),_0x26a59b[_0x52f6('0x32')][_0x52f6('0x5e')])]};if(_0x26a59b['query'][_0x52f6('0x2d')]&&_0x26a59b[_0x52f6('0x32')][_0x52f6('0x2d')]===_0x52f6('0x5d')){_0xd353ab[_0x52f6('0x5f')][_0x52f6('0x60')]({'uniqueid':_0x26a59b[_0x52f6('0x46')]['id']});}else{_0xd353ab[_0x52f6('0x5f')][_0x52f6('0x60')]({'id':_0x26a59b[_0x52f6('0x46')]['id']});}return db[_0x52f6('0x2b')][_0x52f6('0x4a')]({'where':_0xd353ab,'attributes':['id',_0x52f6('0x4e')],'raw':!![]})['then'](handleEntityNotFound(_0xd7b79,null))[_0x52f6('0x25')](function(_0x8fa41a){if(_0x8fa41a){var _0x5a044f=util[_0x52f6('0x31')](_0x52f6('0x4f'),_0x8fa41a[_0x52f6('0x4e')]);if(fs[_0x52f6('0x50')](_0x5a044f)){_0x571584=!![];return _0x1c0bd0[_0x52f6('0x61')](_0x5a044f,_0x8fa41a[_0x52f6('0x4e')],config[_0x52f6('0x51')]['recording'])[_0x52f6('0x25')](function(){return _0x8fa41a;});}return _0x8fa41a;}})['then'](function(_0x3e432a){if(_0x3e432a){if(!fs[_0x52f6('0x50')](_0x3e432a[_0x52f6('0x4e')])){throw new db[(_0x52f6('0x53'))][(_0x52f6('0x54'))](_0x52f6('0x58'));}if(_0x3e432a['filename']){return _0xd7b79[_0x52f6('0x4c')](_0x3e432a[_0x52f6('0x4e')],_0x3e432a[_0x52f6('0x55')]+path[_0x52f6('0x62')](_0x3e432a[_0x52f6('0x4e')]),function(){if(_0x571584){fs['unlink'](_0x3e432a[_0x52f6('0x4e')]);}});}else{return _0xd7b79[_0x52f6('0x4c')](_0x3e432a[_0x52f6('0x4e')],function(_0x2eb9f7){if(_0x571584){fs['unlink'](_0x3e432a[_0x52f6('0x4e')]);}});}}})[_0x52f6('0x44')](handleError(_0xd7b79,null));};exports[_0x52f6('0x26')]=function(_0x4d13cc,_0x216999){return db['VoiceRecording'][_0x52f6('0x4a')]({'where':{'id':_0x4d13cc['params']['id']}})[_0x52f6('0x25')](function(_0x40e798){if(_[_0x52f6('0x63')](_0x40e798)){throw new ReferenceError(_0x52f6('0x64'));}return _0x40e798;})[_0x52f6('0x25')](function(_0x5cdaa6){var _0x22604d=_0x5cdaa6[_0x52f6('0x4e')];logger[_0x52f6('0x65')](_0x52f6('0x66'),_0x22604d);if(!_[_0x52f6('0x63')](_0x5cdaa6[_0x52f6('0x4e')])&&fs['existsSync'](_0x22604d)){logger[_0x52f6('0x65')](_0x52f6('0x67')+_0x22604d+_0x52f6('0x68'));fs['unlinkSync'](_0x22604d);}_0x22604d=_0x22604d+'.cypher';if(!_['isNil'](_0x5cdaa6[_0x52f6('0x4e')])&&fs['existsSync'](_0x22604d)){logger[_0x52f6('0x65')]('File:\x20\x22'+_0x22604d+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs[_0x52f6('0x69')](_0x22604d);}return _0x5cdaa6;})[_0x52f6('0x25')](function(_0x5a6a82){if(!_0x5a6a82)throw new InternalError();return _0x5a6a82[_0x52f6('0x26')]();})[_0x52f6('0x25')](function(){_0x216999[_0x52f6('0x1b')](0xcc)['end']();})[_0x52f6('0x44')](handleError(_0x216999,null));};function getBucketslist(_0x58609e,_0xc4d16f,_0x4c8ad8){return new Promise(function(_0x5ad19c,_0xfc6f33){var _0x427901=new AWS['S3']({'accessKeyId':_0xc4d16f,'secretAccessKey':_0x58609e,'region':_0x4c8ad8});_0x427901['listBuckets']({},function(_0x181cae,_0x4ff7d8){if(_0x181cae){return _0xfc6f33(_0x181cae);}else{return _0x5ad19c(_0x4ff7d8);}});});}function createBucket(_0x3a2e30,_0x15814c,_0x238cb0,_0xcc8c21){return new Promise(function(_0x196a33,_0x3aac91){var _0x58ad42=new AWS['S3']({'accessKeyId':_0x15814c,'secretAccessKey':_0x3a2e30,'region':_0x238cb0});_0x58ad42[_0x52f6('0x6a')]({'Bucket':_0xcc8c21},function(_0x8f7a39,_0x1440dc){if(_0x8f7a39){return _0x3aac91(_0x8f7a39);}else{return _0x196a33(_0x1440dc);}});});}function uploadFile(_0x2fa7ce,_0x4ae6cb,_0x322c78,_0x206729,_0x148fd5,_0x332477){return new Promise(function(_0x3e8aeb,_0x593bb4){var _0x591376=new AWS['S3']({'accessKeyId':_0x4ae6cb,'secretAccessKey':_0x2fa7ce,'region':_0x322c78});_0x591376[_0x52f6('0x6b')]({'Bucket':_0x206729,'Key':_0x148fd5,'Body':_0x332477},function(_0x43f02d,_0x59bf9b){if(_0x43f02d){return _0x593bb4(_0x43f02d);}else{return _0x3e8aeb(_0x59bf9b);}});});}function startTranscribe(_0x508072,_0x3908a8,_0x3d90c8,_0x59819d,_0x44cc19,_0x3a5120){return new Promise(function(_0x46f850,_0x885443){var _0x345208=new AWS[(_0x52f6('0x6c'))]({'accessKeyId':_0x3908a8,'secretAccessKey':_0x508072,'region':_0x3d90c8});_0x345208[_0x52f6('0x6d')]({'TranscriptionJobName':_0x59819d,'LanguageCode':_0x44cc19,'Media':{'MediaFileUri':_0x3a5120}},function(_0x5cf7b9,_0x2308da){if(_0x5cf7b9){return _0x885443(_0x5cf7b9);}else{return _0x46f850(_0x2308da);}});});}function transcribe(_0x1ac51f,_0x2c43ce,_0x4113fb,_0x184902,_0x1d8d74,_0x4fd573,_0x13ec0e){return new Promise(function(_0x1d0446,_0x4159a3){var _0x43f963={};logger[_0x52f6('0x65')](util[_0x52f6('0x31')](_0x52f6('0x6e'),_0x1ac51f,_0x1d8d74));return uploadFile(_0x2c43ce,_0x4113fb,_0x184902,_0x1d8d74,path[_0x52f6('0x6f')](_0x4fd573),fs[_0x52f6('0x70')](_0x4fd573))[_0x52f6('0x25')](function(_0x4baf14){logger[_0x52f6('0x65')](util[_0x52f6('0x31')](_0x52f6('0x71'),_0x1ac51f,_0x1d8d74,_0x4baf14[_0x52f6('0x72')]));_0x43f963[_0x52f6('0x73')]=_0x4baf14[_0x52f6('0x74')];_0x43f963[_0x52f6('0x75')]=_0x4baf14[_0x52f6('0x72')];logger[_0x52f6('0x65')](util[_0x52f6('0x31')](_0x52f6('0x76'),_0x1ac51f));return startTranscribe(_0x2c43ce,_0x4113fb,_0x184902,uuidv4(),_0x13ec0e,_0x4baf14[_0x52f6('0x72')]);})['then'](function(_0xef3264){logger[_0x52f6('0x65')](util['format'](_0x52f6('0x77'),_0x1ac51f,_0xef3264[_0x52f6('0x78')][_0x52f6('0x79')]));_0x43f963['transcribeName']=_0xef3264[_0x52f6('0x78')]['TranscriptionJobName'];_0x43f963[_0x52f6('0x7a')]=_0xef3264[_0x52f6('0x78')][_0x52f6('0x7b')];return _0x1d0446(_0x43f963);})[_0x52f6('0x44')](function(_0x34760e){return _0x4159a3(_0x34760e);});});}exports[_0x52f6('0x7c')]=function(_0x3d8fbe,_0x3e7c8e,_0x1fa53a){var _0x3ace0b;var _0x2f7831;var _0x39fa6e;var _0x3c1a29=require(_0x52f6('0x4d'));return db[_0x52f6('0x2b')][_0x52f6('0x7d')]({'where':{'id':_0x3d8fbe['params']['id']}})[_0x52f6('0x25')](function(_0x16c1f6){if(_0x16c1f6){var _0xa96b85=util[_0x52f6('0x31')](_0x52f6('0x4f'),_0x16c1f6[_0x52f6('0x4e')]);if(fs[_0x52f6('0x50')](_0xa96b85)){cypher=!![];return _0x3c1a29[_0x52f6('0x61')](_0xa96b85,_0x16c1f6['value'],config['secrets'][_0x52f6('0x52')])[_0x52f6('0x25')](function(){return _0x16c1f6;});}return _0x16c1f6;}})[_0x52f6('0x25')](function(_0x1fff7a){if(!_0x1fff7a){throw new db[(_0x52f6('0x53'))][(_0x52f6('0x54'))](_0x52f6('0x7e'));}_0x2f7831=_0x1fff7a;return db[_0x52f6('0x7f')][_0x52f6('0x7d')]({'where':{'id':0x1}});})[_0x52f6('0x25')](handleEntityNotFound(_0x3e7c8e,null))[_0x52f6('0x25')](function(_0x557e33){if(_0x557e33){_0x3ace0b=_0x557e33;if(!_0x3ace0b[_0x52f6('0x80')]||!_0x3ace0b[_0x52f6('0x81')]||!_0x3ace0b[_0x52f6('0x82')]||!_0x3ace0b[_0x52f6('0x83')]||!_0x3ace0b[_0x52f6('0x73')]){throw new db[(_0x52f6('0x53'))][(_0x52f6('0x54'))]('Transcribe\x20not\x20configured');}if(_0x3d8fbe[_0x52f6('0x49')]['runSentiment']&&(!_0x3ace0b[_0x52f6('0x84')]||!_0x3ace0b[_0x52f6('0x85')]||!_0x3ace0b[_0x52f6('0x86')]||!_0x3ace0b[_0x52f6('0x83')]||!_0x3ace0b[_0x52f6('0x73')])){throw new db[(_0x52f6('0x53'))][(_0x52f6('0x54'))](_0x52f6('0x87'));}return db[_0x52f6('0x88')][_0x52f6('0x7d')]({'where':{'id':_0x3ace0b[_0x52f6('0x81')]}});}})[_0x52f6('0x25')](function(_0xd6a688){if(!_0xd6a688){throw new db['Sequelize']['ValidationError'](_0x52f6('0x89'));}if(!_0xd6a688[_0x52f6('0x8a')]||!_0xd6a688['data2']){throw new db[(_0x52f6('0x53'))][(_0x52f6('0x54'))]('Cloud\x20Provider\x20not\x20configured');}_0x39fa6e=_0xd6a688;return getBucketslist(_0x39fa6e['data1'],_0x39fa6e[_0x52f6('0x8b')],_0x3ace0b[_0x52f6('0x82')]);})[_0x52f6('0x25')](function(_0x5dcefd){if(_0x5dcefd&&_0x5dcefd[_0x52f6('0x8c')]){var _0x3614c4=_[_0x52f6('0x4a')](_0x5dcefd[_0x52f6('0x8c')],function(_0x5b49eb){return _0x5b49eb[_0x52f6('0x8d')]===_0x3ace0b['bucket'];});if(!_0x3614c4){logger['info'](util['format'](_0x52f6('0x8e'),_0x3d8fbe['params']['id'],_0x3ace0b[_0x52f6('0x73')]));return createBucket(_0x39fa6e[_0x52f6('0x8a')],_0x39fa6e[_0x52f6('0x8b')],_0x3ace0b[_0x52f6('0x82')],_0x3ace0b['bucket']);}logger[_0x52f6('0x65')](util[_0x52f6('0x31')]('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available',_0x3d8fbe[_0x52f6('0x46')]['id'],_0x3ace0b['bucket']));return;}})[_0x52f6('0x25')](function(_0x135f64){if(_0x2f7831[_0x52f6('0x7a')]===_0x52f6('0x8f')){return transcribe(_0x3d8fbe['params']['id'],_0x39fa6e[_0x52f6('0x8a')],_0x39fa6e[_0x52f6('0x8b')],_0x3ace0b[_0x52f6('0x82')],_0x3ace0b[_0x52f6('0x73')],_0x2f7831[_0x52f6('0x4e')],_0x3ace0b[_0x52f6('0x83')]);}else{logger[_0x52f6('0x65')](util[_0x52f6('0x31')]('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x3d8fbe[_0x52f6('0x46')]['id']));return{'transcribeStatus':_0x52f6('0x90')};}})[_0x52f6('0x25')](function(_0x4bcd13){if(_0x4bcd13){_0x4bcd13[_0x52f6('0x91')]=_0x3d8fbe[_0x52f6('0x49')][_0x52f6('0x92')];return _0x2f7831[_0x52f6('0x93')](_0x4bcd13);}})[_0x52f6('0x25')](respondWithResult(_0x3e7c8e,null))[_0x52f6('0x44')](handleError(_0x3e7c8e,null));};function writeFile(_0x41b201,_0x2151f8){return new Promise(function(_0x5360d8,_0x2e75d7){fs['writeFile'](_0x2151f8,_0x41b201,function(_0xf2284c,_0x8ab64a){if(_0xf2284c){return _0x2e75d7(_0xf2284c);}else{return _0x5360d8(_0x8ab64a);}});});}exports[_0x52f6('0x94')]=function(_0x5b9581,_0x523fc6,_0x3fe964){return db['VoiceRecording'][_0x52f6('0x7d')]({'where':{'id':_0x5b9581['params']['id']}})['then'](handleEntityNotFound(_0x523fc6))[_0x52f6('0x25')](function(_0x5e343f){if(_0x5e343f&&_0x5e343f[_0x52f6('0x95')]){var _0x583bc4=_0x5e343f[_0x52f6('0x95')];var _0x5773d5=config[_0x52f6('0x96')]+'/server/files/transcribes/transcribe_'+_0x5e343f['id']+_0x52f6('0x97');if(fs[_0x52f6('0x50')](_0x5773d5)){return _0x5773d5;}return writeFile(_0x583bc4,_0x5773d5)[_0x52f6('0x25')](function(){return _0x5773d5;});}else{throw new db[(_0x52f6('0x53'))][(_0x52f6('0x54'))](_0x52f6('0x98'));}})[_0x52f6('0x25')](function(_0x3e8040){return _0x523fc6[_0x52f6('0x4c')](_0x3e8040);})[_0x52f6('0x44')](handleError(_0x523fc6));};
\ No newline at end of file