Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index f643a0d..7943fb5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf3b9=['../../components/encryptor','uniqueid','value','%s.cypher','existsSync','secrets','recording','Sequelize','ValidationError','VoiceRecording\x20not\x20found','filename','extname','unlink','message','Not\x20found','downloads','sequelize','MD5','col','token','$and','push','decryptFile','destroy','isNil','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','.cypher','listBuckets','upload','TranscribeService','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','basename','readFileSync','Location','Bucket','location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','TranscriptionJob','TranscriptionJobName','transcribeName','transcribeStatus','TranscriptionJobStatus','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribe','transcribeAccountId','language','bucket','Transcribe\x20not\x20configured','runSentiment','sentiment','sentimentAccountId','sentimentRegion','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','data1','data2','Cloud\x20Provider\x20not\x20configured','transcribeRegion','Buckets','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','NEW','IN_PROGRESS','tempSentiment','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','.txt','Transcript\x20not\x20available','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','aws-sdk','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','end','offset','undefined','limit','count','status','Content-Range','json','apply','reject','save','update','then','error','stack','name','send','index','map','VoiceRecording','rawAttributes','type','key','model','differenceBy','format','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','sort','where','pick','filter','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','describe','download'];(function(_0x3c8533,_0x2517ef){var _0x3305a7=function(_0x1d4842){while(--_0x1d4842){_0x3c8533['push'](_0x3c8533['shift']());}};_0x3305a7(++_0x2517ef);}(_0xf3b9,0x190));var _0x9f3b=function(_0x13f83f,_0x44e4b6){_0x13f83f=_0x13f83f-0x0;var _0x5648f5=_0xf3b9[_0x13f83f];return _0x5648f5;};'use strict';var emlformat=require(_0x9f3b('0x0'));var rimraf=require(_0x9f3b('0x1'));var zipdir=require(_0x9f3b('0x2'));var jsonpatch=require(_0x9f3b('0x3'));var rp=require(_0x9f3b('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x9f3b('0x5'));var util=require(_0x9f3b('0x6'));var path=require(_0x9f3b('0x7'));var sox=require(_0x9f3b('0x8'));var csv=require(_0x9f3b('0x9'));var ejs=require(_0x9f3b('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x9f3b('0xb'));var squel=require(_0x9f3b('0xc'));var crypto=require(_0x9f3b('0xd'));var jsforce=require(_0x9f3b('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x9f3b('0x9'));var querystring=require(_0x9f3b('0xf'));var Papa=require(_0x9f3b('0x10'));var AWS=require(_0x9f3b('0x11'));var uuidv4=require(_0x9f3b('0x12'));var Redis=require(_0x9f3b('0x13'));var authService=require(_0x9f3b('0x14'));var qs=require(_0x9f3b('0x15'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9f3b('0x16'));var logger=require(_0x9f3b('0x17'))(_0x9f3b('0x18'));var utils=require(_0x9f3b('0x19'));var config=require('../../config/environment');var licenseUtil=require(_0x9f3b('0x1a'));var db=require(_0x9f3b('0x1b'))['db'];function respondWithStatusCode(_0x51dbe3,_0x3f1009){_0x3f1009=_0x3f1009||0xcc;return function(_0x414e13){if(_0x414e13){return _0x51dbe3['sendStatus'](_0x3f1009);}return _0x51dbe3['status'](_0x3f1009)[_0x9f3b('0x1c')]();};}function respondWithResult(_0x4ef862,_0x5c4e4f){_0x5c4e4f=_0x5c4e4f||0xc8;return function(_0x4e5274){if(_0x4e5274){return _0x4ef862['status'](_0x5c4e4f)['json'](_0x4e5274);}};}function respondWithFilteredResult(_0x11fa81,_0x58dba9){return function(_0x84e11f){if(_0x84e11f){var _0x2c9bcb=typeof _0x58dba9[_0x9f3b('0x1d')]===_0x9f3b('0x1e')&&typeof _0x58dba9[_0x9f3b('0x1f')]===_0x9f3b('0x1e');var _0x2d609f=_0x84e11f[_0x9f3b('0x20')];var _0x4c5ad6=_0x2c9bcb?0x0:_0x58dba9[_0x9f3b('0x1d')];var _0x5014a8=_0x2c9bcb?_0x84e11f[_0x9f3b('0x20')]:_0x58dba9[_0x9f3b('0x1d')]+_0x58dba9[_0x9f3b('0x1f')];var _0x485a7c;if(_0x5014a8>=_0x2d609f){_0x5014a8=_0x2d609f;_0x485a7c=0xc8;}else{_0x485a7c=0xce;}_0x11fa81[_0x9f3b('0x21')](_0x485a7c);return _0x11fa81['set'](_0x9f3b('0x22'),_0x4c5ad6+'-'+_0x5014a8+'/'+_0x2d609f)[_0x9f3b('0x23')](_0x84e11f);}return null;};}function patchUpdates(_0x553b41){return function(_0x38cd73){try{jsonpatch[_0x9f3b('0x24')](_0x38cd73,_0x553b41,!![]);}catch(_0x3e646d){return BPromise[_0x9f3b('0x25')](_0x3e646d);}return _0x38cd73[_0x9f3b('0x26')]();};}function saveUpdates(_0x12b7ff,_0x2e61e1){return function(_0x2a97c7){if(_0x2a97c7){return _0x2a97c7[_0x9f3b('0x27')](_0x12b7ff)[_0x9f3b('0x28')](function(_0x4448d1){return _0x4448d1;});}return null;};}function removeEntity(_0x4cddd1,_0x3cc08b){return function(_0x32db9b){if(_0x32db9b){return _0x32db9b['destroy']()[_0x9f3b('0x28')](function(){_0x4cddd1[_0x9f3b('0x21')](0xcc)['end']();});}};}function handleEntityNotFound(_0x583ff4,_0x1920a1){return function(_0x20c9fb){if(!_0x20c9fb){_0x583ff4['sendStatus'](0x194);}return _0x20c9fb;};}function handleError(_0x264a25,_0x336b86){_0x336b86=_0x336b86||0x1f4;return function(_0x173132){logger[_0x9f3b('0x29')](_0x173132[_0x9f3b('0x2a')]);if(_0x173132[_0x9f3b('0x2b')]){delete _0x173132['name'];}_0x264a25[_0x9f3b('0x21')](_0x336b86)[_0x9f3b('0x2c')](_0x173132);};}exports[_0x9f3b('0x2d')]=function(_0x147847,_0x50f923){var _0x52c478={},_0x454e2a={},_0x4ea89e={'count':0x0,'rows':[]};var _0x434c76=_[_0x9f3b('0x2e')](db[_0x9f3b('0x2f')][_0x9f3b('0x30')],function(_0x2f5f32){return{'name':_0x2f5f32['fieldName'],'type':_0x2f5f32[_0x9f3b('0x31')][_0x9f3b('0x32')]};});_0x454e2a[_0x9f3b('0x33')]=_[_0x9f3b('0x34')](_['map'](_0x434c76,_0x9f3b('0x2b')),[_0x9f3b('0x35')]);_0x454e2a['query']=_[_0x9f3b('0x36')](_0x147847[_0x9f3b('0x37')]);_0x454e2a[_0x9f3b('0x38')]=_['intersection'](_0x454e2a['model'],_0x454e2a[_0x9f3b('0x37')]);_0x52c478[_0x9f3b('0x39')]=_[_0x9f3b('0x3a')](_0x454e2a['model'],qs[_0x9f3b('0x3b')](_0x147847[_0x9f3b('0x37')][_0x9f3b('0x3b')]));_0x52c478[_0x9f3b('0x39')]=_0x52c478[_0x9f3b('0x39')][_0x9f3b('0x3c')]?_0x52c478[_0x9f3b('0x39')]:_0x454e2a['model'];if(!_0x147847[_0x9f3b('0x37')][_0x9f3b('0x3d')]('nolimit')){_0x52c478[_0x9f3b('0x1f')]=qs[_0x9f3b('0x1f')](_0x147847[_0x9f3b('0x37')]['limit']);_0x52c478['offset']=qs[_0x9f3b('0x1d')](_0x147847[_0x9f3b('0x37')][_0x9f3b('0x1d')]);}_0x52c478['order']=qs['sort'](_0x147847[_0x9f3b('0x37')][_0x9f3b('0x3e')]);_0x52c478[_0x9f3b('0x3f')]=qs[_0x9f3b('0x38')](_[_0x9f3b('0x40')](_0x147847[_0x9f3b('0x37')],_0x454e2a[_0x9f3b('0x38')]),_0x434c76);if(_0x147847[_0x9f3b('0x37')][_0x9f3b('0x41')]){_0x52c478[_0x9f3b('0x3f')]=_['merge'](_0x52c478[_0x9f3b('0x3f')],{'$or':_[_0x9f3b('0x2e')](_0x434c76,function(_0x2eea35){if(_0x2eea35[_0x9f3b('0x31')]!==_0x9f3b('0x42')){var _0x383606={};_0x383606[_0x2eea35[_0x9f3b('0x2b')]]={'$like':'%'+_0x147847[_0x9f3b('0x37')][_0x9f3b('0x41')]+'%'};return _0x383606;}})});}_0x52c478=_['merge']({},_0x52c478,_0x147847[_0x9f3b('0x43')]);var _0xb7109e={'where':_0x52c478['where']};return db[_0x9f3b('0x2f')]['count'](_0xb7109e)['then'](function(_0x3ced71){_0x4ea89e[_0x9f3b('0x20')]=_0x3ced71;if(_0x147847[_0x9f3b('0x37')][_0x9f3b('0x44')]){_0x52c478[_0x9f3b('0x45')]=[{'all':!![]}];}return db[_0x9f3b('0x2f')][_0x9f3b('0x46')](_0x52c478);})[_0x9f3b('0x28')](function(_0xed65b5){_0x4ea89e[_0x9f3b('0x47')]=_0xed65b5;return _0x4ea89e;})[_0x9f3b('0x28')](respondWithFilteredResult(_0x50f923,_0x52c478))[_0x9f3b('0x48')](handleError(_0x50f923,null));};exports[_0x9f3b('0x49')]=function(_0x55bee8,_0x460178){var _0x56b7fe={'raw':![],'where':{'id':_0x55bee8[_0x9f3b('0x4a')]['id']}},_0x5e713f={};_0x5e713f[_0x9f3b('0x33')]=_[_0x9f3b('0x36')](db[_0x9f3b('0x2f')][_0x9f3b('0x30')]);_0x5e713f['query']=_['keys'](_0x55bee8['query']);_0x5e713f['filters']=_[_0x9f3b('0x3a')](_0x5e713f[_0x9f3b('0x33')],_0x5e713f[_0x9f3b('0x37')]);_0x56b7fe['attributes']=_['intersection'](_0x5e713f[_0x9f3b('0x33')],qs[_0x9f3b('0x3b')](_0x55bee8['query'][_0x9f3b('0x3b')]));_0x56b7fe[_0x9f3b('0x39')]=_0x56b7fe[_0x9f3b('0x39')][_0x9f3b('0x3c')]?_0x56b7fe[_0x9f3b('0x39')]:_0x5e713f[_0x9f3b('0x33')];if(_0x55bee8[_0x9f3b('0x37')][_0x9f3b('0x44')]){_0x56b7fe[_0x9f3b('0x45')]=[{'all':!![]}];}_0x56b7fe=_['merge']({},_0x56b7fe,_0x55bee8[_0x9f3b('0x43')]);return db[_0x9f3b('0x2f')][_0x9f3b('0x4b')](_0x56b7fe)[_0x9f3b('0x28')](handleEntityNotFound(_0x460178,null))[_0x9f3b('0x28')](respondWithResult(_0x460178,null))['catch'](handleError(_0x460178,null));};exports[_0x9f3b('0x4c')]=function(_0x2b6b57,_0x1dd67f){return db[_0x9f3b('0x2f')]['create'](_0x2b6b57[_0x9f3b('0x4d')],{})['then'](respondWithResult(_0x1dd67f,0xc9))[_0x9f3b('0x48')](handleError(_0x1dd67f,null));};exports[_0x9f3b('0x27')]=function(_0x2310e8,_0x46da54){if(_0x2310e8['body']['id']){delete _0x2310e8[_0x9f3b('0x4d')]['id'];}return db[_0x9f3b('0x2f')][_0x9f3b('0x4b')]({'where':{'id':_0x2310e8[_0x9f3b('0x4a')]['id']}})[_0x9f3b('0x28')](handleEntityNotFound(_0x46da54,null))['then'](saveUpdates(_0x2310e8[_0x9f3b('0x4d')],null))['then'](respondWithResult(_0x46da54,null))[_0x9f3b('0x48')](handleError(_0x46da54,null));};exports[_0x9f3b('0x4e')]=function(_0x582cf7,_0x33e698){return db[_0x9f3b('0x2f')]['describe']()[_0x9f3b('0x28')](respondWithResult(_0x33e698,null))['catch'](handleError(_0x33e698,null));};exports[_0x9f3b('0x4f')]=function(_0x44d81f,_0x491b33,_0x28763d){var _0x32969d=require(_0x9f3b('0x50'));var _0x3f66bb=![];var _0x40c437={};if(_0x44d81f[_0x9f3b('0x37')][_0x9f3b('0x31')]&&_0x44d81f[_0x9f3b('0x37')][_0x9f3b('0x31')]===_0x9f3b('0x51')){_0x40c437['uniqueid']=_0x44d81f[_0x9f3b('0x4a')]['id'];}else{_0x40c437['id']=_0x44d81f['params']['id'];}return db[_0x9f3b('0x2f')][_0x9f3b('0x4b')]({'where':_0x40c437,'attributes':['id',_0x9f3b('0x52')],'raw':!![]})[_0x9f3b('0x28')](handleEntityNotFound(_0x491b33,null))[_0x9f3b('0x28')](function(_0x56fc5c){if(_0x56fc5c){var _0x41a855=_0x56fc5c[_0x9f3b('0x52')];var _0xbfc3dd=util['format'](_0x9f3b('0x53'),_0x41a855);if(fs[_0x9f3b('0x54')](_0xbfc3dd)){_0x3f66bb=!![];return _0x32969d['decryptFile'](_0xbfc3dd,_0x41a855,config[_0x9f3b('0x55')][_0x9f3b('0x56')])[_0x9f3b('0x28')](function(){return _0x56fc5c;});}return _0x56fc5c;}})['then'](function(_0x26aa80){if(_0x26aa80){var _0x194965=_0x26aa80['value'];if(!fs[_0x9f3b('0x54')](_0x194965)){throw new db[(_0x9f3b('0x57'))][(_0x9f3b('0x58'))](_0x9f3b('0x59'));}if(_0x26aa80[_0x9f3b('0x5a')]){return _0x491b33[_0x9f3b('0x4f')](_0x194965,_0x26aa80[_0x9f3b('0x5a')]+path[_0x9f3b('0x5b')](_0x194965),function(){if(_0x3f66bb){fs[_0x9f3b('0x5c')](_0x194965);}});}else{return _0x491b33[_0x9f3b('0x4f')](_0x194965,function(_0xa1ce8f){if(_0x3f66bb){fs[_0x9f3b('0x5c')](_0x194965);}});}}})[_0x9f3b('0x48')](function(_0x18bebe){if(_0x18bebe[_0x9f3b('0x5d')]==='VoiceRecording\x20not\x20found'){_0x491b33[_0x9f3b('0x21')](0x194)[_0x9f3b('0x2c')](_0x9f3b('0x5e'));}else{return handleError(_0x491b33,null);}});};exports[_0x9f3b('0x5f')]=function(_0x55c92d,_0x31541c,_0x4ca180){var _0x6c6189=require(_0x9f3b('0x50'));var _0x41f173=![];var _0x58e398={'$and':[db[_0x9f3b('0x60')][_0x9f3b('0x3f')](db[_0x9f3b('0x60')]['fn'](_0x9f3b('0x61'),db[_0x9f3b('0x60')][_0x9f3b('0x62')]('uniqueid')),_0x55c92d[_0x9f3b('0x37')][_0x9f3b('0x63')])]};if(_0x55c92d['query'][_0x9f3b('0x31')]&&_0x55c92d[_0x9f3b('0x37')][_0x9f3b('0x31')]===_0x9f3b('0x51')){_0x58e398[_0x9f3b('0x64')][_0x9f3b('0x65')]({'uniqueid':_0x55c92d[_0x9f3b('0x4a')]['id']});}else{_0x58e398['$and'][_0x9f3b('0x65')]({'id':_0x55c92d[_0x9f3b('0x4a')]['id']});}return db[_0x9f3b('0x2f')]['find']({'where':_0x58e398,'attributes':['id','value'],'raw':!![]})[_0x9f3b('0x28')](handleEntityNotFound(_0x31541c,null))[_0x9f3b('0x28')](function(_0x4dd579){if(_0x4dd579){var _0x18f26a=util[_0x9f3b('0x35')]('%s.cypher',_0x4dd579[_0x9f3b('0x52')]);if(fs['existsSync'](_0x18f26a)){_0x41f173=!![];return _0x6c6189[_0x9f3b('0x66')](_0x18f26a,_0x4dd579['value'],config['secrets']['recording'])['then'](function(){return _0x4dd579;});}return _0x4dd579;}})[_0x9f3b('0x28')](function(_0x2f39b7){if(_0x2f39b7){if(!fs[_0x9f3b('0x54')](_0x2f39b7[_0x9f3b('0x52')])){throw new db[(_0x9f3b('0x57'))][(_0x9f3b('0x58'))](_0x9f3b('0x59'));}if(_0x2f39b7[_0x9f3b('0x5a')]){return _0x31541c[_0x9f3b('0x4f')](_0x2f39b7[_0x9f3b('0x52')],_0x2f39b7[_0x9f3b('0x5a')]+path[_0x9f3b('0x5b')](_0x2f39b7[_0x9f3b('0x52')]),function(){if(_0x41f173){fs[_0x9f3b('0x5c')](_0x2f39b7['value']);}});}else{return _0x31541c[_0x9f3b('0x4f')](_0x2f39b7[_0x9f3b('0x52')],function(_0x142785){if(_0x41f173){fs[_0x9f3b('0x5c')](_0x2f39b7[_0x9f3b('0x52')]);}});}}})['catch'](handleError(_0x31541c,null));};exports[_0x9f3b('0x67')]=function(_0x5aaf9a,_0x4057f0){return db['VoiceRecording'][_0x9f3b('0x4b')]({'where':{'id':_0x5aaf9a[_0x9f3b('0x4a')]['id']}})[_0x9f3b('0x28')](function(_0x35ec7e){if(_[_0x9f3b('0x68')](_0x35ec7e)){throw new ReferenceError(_0x9f3b('0x69'));}return _0x35ec7e;})['then'](function(_0x11e57d){var _0x12d0aa=_0x11e57d[_0x9f3b('0x52')];logger[_0x9f3b('0x6a')](_0x9f3b('0x6b'),_0x12d0aa);if(!_[_0x9f3b('0x68')](_0x11e57d[_0x9f3b('0x52')])&&fs[_0x9f3b('0x54')](_0x12d0aa)){logger[_0x9f3b('0x6a')](_0x9f3b('0x6c')+_0x12d0aa+_0x9f3b('0x6d'));fs[_0x9f3b('0x6e')](_0x12d0aa);}_0x12d0aa=_0x12d0aa+_0x9f3b('0x6f');if(!_[_0x9f3b('0x68')](_0x11e57d[_0x9f3b('0x52')])&&fs[_0x9f3b('0x54')](_0x12d0aa)){logger[_0x9f3b('0x6a')](_0x9f3b('0x6c')+_0x12d0aa+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs[_0x9f3b('0x6e')](_0x12d0aa);}return _0x11e57d;})[_0x9f3b('0x28')](function(_0x45a963){if(!_0x45a963)throw new InternalError();return _0x45a963[_0x9f3b('0x67')]();})[_0x9f3b('0x28')](function(){_0x4057f0[_0x9f3b('0x21')](0xcc)[_0x9f3b('0x1c')]();})[_0x9f3b('0x48')](handleError(_0x4057f0,null));};function getBucketslist(_0x194ad1,_0x2ddc67,_0x9ec8f0){return new Promise(function(_0x3adf12,_0x7fde2c){var _0x294eec=new AWS['S3']({'accessKeyId':_0x2ddc67,'secretAccessKey':_0x194ad1,'region':_0x9ec8f0});_0x294eec[_0x9f3b('0x70')]({},function(_0x1d5a3d,_0x510a08){if(_0x1d5a3d){return _0x7fde2c(_0x1d5a3d);}else{return _0x3adf12(_0x510a08);}});});}function createBucket(_0x34182e,_0x31dbcb,_0x28efb0,_0x13b286){return new Promise(function(_0x5c1790,_0x21bdec){var _0x3d2079=new AWS['S3']({'accessKeyId':_0x31dbcb,'secretAccessKey':_0x34182e,'region':_0x28efb0});_0x3d2079['createBucket']({'Bucket':_0x13b286},function(_0x3d6096,_0x1daed1){if(_0x3d6096){return _0x21bdec(_0x3d6096);}else{return _0x5c1790(_0x1daed1);}});});}function uploadFile(_0x371b4e,_0x72b2e8,_0x13ea3d,_0x253dc5,_0x50c422,_0x3c724b){return new Promise(function(_0x3e6127,_0x186987){var _0x414e71=new AWS['S3']({'accessKeyId':_0x72b2e8,'secretAccessKey':_0x371b4e,'region':_0x13ea3d});_0x414e71[_0x9f3b('0x71')]({'Bucket':_0x253dc5,'Key':_0x50c422,'Body':_0x3c724b},function(_0x2f4282,_0x2b8da9){if(_0x2f4282){return _0x186987(_0x2f4282);}else{return _0x3e6127(_0x2b8da9);}});});}function startTranscribe(_0x5da079,_0x1cb179,_0x5637a8,_0x47d5ee,_0x590997,_0x1122e3){return new Promise(function(_0x267111,_0x4047fa){var _0x1ce0c9=new AWS[(_0x9f3b('0x72'))]({'accessKeyId':_0x1cb179,'secretAccessKey':_0x5da079,'region':_0x5637a8});_0x1ce0c9[_0x9f3b('0x73')]({'TranscriptionJobName':_0x47d5ee,'LanguageCode':_0x590997,'Media':{'MediaFileUri':_0x1122e3}},function(_0x588af3,_0x1c0cbf){if(_0x588af3){return _0x4047fa(_0x588af3);}else{return _0x267111(_0x1c0cbf);}});});}function transcribe(_0x55fbe4,_0xc1dac9,_0x457ce6,_0xcdbaf8,_0x20d9ba,_0xeac4f8,_0x1affd6){return new Promise(function(_0x4efaeb,_0x238eea){var _0x2e3212={};logger[_0x9f3b('0x6a')](util['format'](_0x9f3b('0x74'),_0x55fbe4,_0x20d9ba));return uploadFile(_0xc1dac9,_0x457ce6,_0xcdbaf8,_0x20d9ba,path[_0x9f3b('0x75')](_0xeac4f8),fs[_0x9f3b('0x76')](_0xeac4f8))[_0x9f3b('0x28')](function(_0xc48b70){logger['info'](util[_0x9f3b('0x35')]('[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)',_0x55fbe4,_0x20d9ba,_0xc48b70[_0x9f3b('0x77')]));_0x2e3212['bucket']=_0xc48b70[_0x9f3b('0x78')];_0x2e3212[_0x9f3b('0x79')]=_0xc48b70['Location'];logger[_0x9f3b('0x6a')](util[_0x9f3b('0x35')](_0x9f3b('0x7a'),_0x55fbe4));return startTranscribe(_0xc1dac9,_0x457ce6,_0xcdbaf8,uuidv4(),_0x1affd6,_0xc48b70[_0x9f3b('0x77')]);})[_0x9f3b('0x28')](function(_0x93a97a){logger[_0x9f3b('0x6a')](util[_0x9f3b('0x35')](_0x9f3b('0x7b'),_0x55fbe4,_0x93a97a[_0x9f3b('0x7c')][_0x9f3b('0x7d')]));_0x2e3212[_0x9f3b('0x7e')]=_0x93a97a[_0x9f3b('0x7c')][_0x9f3b('0x7d')];_0x2e3212[_0x9f3b('0x7f')]=_0x93a97a[_0x9f3b('0x7c')][_0x9f3b('0x80')];return _0x4efaeb(_0x2e3212);})['catch'](function(_0x5ec1ff){return _0x238eea(_0x5ec1ff);});});}exports['runTranscribe']=function(_0x188c94,_0x2c1ed8,_0x1444fc){var _0x911607;var _0x152009;var _0x4f327b;var _0x1868ae=require('../../components/encryptor');return db[_0x9f3b('0x2f')][_0x9f3b('0x81')]({'where':{'id':_0x188c94[_0x9f3b('0x4a')]['id']}})['then'](function(_0x45797a){if(_0x45797a){var _0x1604da=util[_0x9f3b('0x35')](_0x9f3b('0x53'),_0x45797a['value']);if(fs[_0x9f3b('0x54')](_0x1604da)){cypher=!![];return _0x1868ae[_0x9f3b('0x66')](_0x1604da,_0x45797a[_0x9f3b('0x52')],config[_0x9f3b('0x55')][_0x9f3b('0x56')])[_0x9f3b('0x28')](function(){return _0x45797a;});}return _0x45797a;}})[_0x9f3b('0x28')](function(_0x16af8e){if(!_0x16af8e){throw new db[(_0x9f3b('0x57'))][(_0x9f3b('0x58'))](_0x9f3b('0x82'));}_0x152009=_0x16af8e;return db[_0x9f3b('0x83')][_0x9f3b('0x81')]({'where':{'id':0x1}});})[_0x9f3b('0x28')](handleEntityNotFound(_0x2c1ed8,null))[_0x9f3b('0x28')](function(_0x327a2f){if(_0x327a2f){_0x911607=_0x327a2f;if(!_0x911607[_0x9f3b('0x84')]||!_0x911607[_0x9f3b('0x85')]||!_0x911607['transcribeRegion']||!_0x911607[_0x9f3b('0x86')]||!_0x911607[_0x9f3b('0x87')]){throw new db[(_0x9f3b('0x57'))]['ValidationError'](_0x9f3b('0x88'));}if(_0x188c94[_0x9f3b('0x4d')][_0x9f3b('0x89')]&&(!_0x911607[_0x9f3b('0x8a')]||!_0x911607[_0x9f3b('0x8b')]||!_0x911607[_0x9f3b('0x8c')]||!_0x911607[_0x9f3b('0x86')]||!_0x911607['bucket'])){throw new db[(_0x9f3b('0x57'))][(_0x9f3b('0x58'))](_0x9f3b('0x8d'));}return db[_0x9f3b('0x8e')][_0x9f3b('0x81')]({'where':{'id':_0x911607[_0x9f3b('0x85')]}});}})[_0x9f3b('0x28')](function(_0x8d07f8){if(!_0x8d07f8){throw new db[(_0x9f3b('0x57'))][(_0x9f3b('0x58'))](_0x9f3b('0x8f'));}if(!_0x8d07f8[_0x9f3b('0x90')]||!_0x8d07f8[_0x9f3b('0x91')]){throw new db[(_0x9f3b('0x57'))][(_0x9f3b('0x58'))](_0x9f3b('0x92'));}_0x4f327b=_0x8d07f8;return getBucketslist(_0x4f327b['data1'],_0x4f327b[_0x9f3b('0x91')],_0x911607[_0x9f3b('0x93')]);})[_0x9f3b('0x28')](function(_0x1065bb){if(_0x1065bb&&_0x1065bb['Buckets']){var _0x25de77=_[_0x9f3b('0x4b')](_0x1065bb[_0x9f3b('0x94')],function(_0x15432c){return _0x15432c['Name']===_0x911607[_0x9f3b('0x87')];});if(!_0x25de77){logger['info'](util[_0x9f3b('0x35')](_0x9f3b('0x95'),_0x188c94[_0x9f3b('0x4a')]['id'],_0x911607[_0x9f3b('0x87')]));return createBucket(_0x4f327b[_0x9f3b('0x90')],_0x4f327b['data2'],_0x911607[_0x9f3b('0x93')],_0x911607[_0x9f3b('0x87')]);}logger['info'](util[_0x9f3b('0x35')](_0x9f3b('0x96'),_0x188c94[_0x9f3b('0x4a')]['id'],_0x911607[_0x9f3b('0x87')]));return;}})['then'](function(_0x585e22){if(_0x152009[_0x9f3b('0x7f')]===_0x9f3b('0x97')){return transcribe(_0x188c94[_0x9f3b('0x4a')]['id'],_0x4f327b['data1'],_0x4f327b['data2'],_0x911607['transcribeRegion'],_0x911607[_0x9f3b('0x87')],_0x152009[_0x9f3b('0x52')],_0x911607[_0x9f3b('0x86')]);}else{logger[_0x9f3b('0x6a')](util[_0x9f3b('0x35')]('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x188c94[_0x9f3b('0x4a')]['id']));return{'transcribeStatus':_0x9f3b('0x98')};}})['then'](function(_0x4a2bf7){if(_0x4a2bf7){_0x4a2bf7[_0x9f3b('0x99')]=_0x188c94[_0x9f3b('0x4d')]['runSentiment'];return _0x152009['updateAttributes'](_0x4a2bf7);}})[_0x9f3b('0x28')](respondWithResult(_0x2c1ed8,null))['catch'](handleError(_0x2c1ed8,null));};function writeFile(_0x112d93,_0x2a8dbb){return new Promise(function(_0x37a288,_0x44d720){fs['writeFile'](_0x2a8dbb,_0x112d93,function(_0x3c581c,_0x5e96aa){if(_0x3c581c){return _0x44d720(_0x3c581c);}else{return _0x37a288(_0x5e96aa);}});});}exports[_0x9f3b('0x9a')]=function(_0x4d66c0,_0x4ad38a,_0x202499){return db[_0x9f3b('0x2f')]['findOne']({'where':{'id':_0x4d66c0[_0x9f3b('0x4a')]['id']}})['then'](handleEntityNotFound(_0x4ad38a))[_0x9f3b('0x28')](function(_0x39d294){if(_0x39d294&&_0x39d294['fileText']){var _0x2390aa=_0x39d294[_0x9f3b('0x9b')];var _0x18cae5=config[_0x9f3b('0x9c')]+_0x9f3b('0x9d')+_0x39d294['id']+_0x9f3b('0x9e');if(fs[_0x9f3b('0x54')](_0x18cae5)){return _0x18cae5;}return writeFile(_0x2390aa,_0x18cae5)['then'](function(){return _0x18cae5;});}else{throw new db['Sequelize'][(_0x9f3b('0x58'))](_0x9f3b('0x9f'));}})[_0x9f3b('0x28')](function(_0x5b8c4e){return _0x4ad38a[_0x9f3b('0x4f')](_0x5b8c4e);})[_0x9f3b('0x48')](handleError(_0x4ad38a));};
\ No newline at end of file
+var _0xb4fb=['[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','updateAttributes','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','.txt','Transcript\x20not\x20available','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','aws-sdk','uuid/v4','ioredis','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','error','stack','name','VoiceRecording','rawAttributes','type','key','differenceBy','map','format','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','show','params','options','find','create','body','catch','describe','download','../../components/encryptor','value','%s.cypher','existsSync','decryptFile','Sequelize','ValidationError','VoiceRecording\x20not\x20found','filename','unlink','message','send','Not\x20found','sequelize','MD5','col','uniqueid','token','$and','push','secrets','recording','Entity\x20not\x20found','cancellazione\x20fisica\x20documento\x20%s','isNil','info','unlinkSync','.cypher','File:\x20\x22','listBuckets','createBucket','upload','startTranscriptionJob','basename','[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','TranscriptionJobName','TranscriptionJob','TranscriptionJobStatus','Voice\x20Recording\x20not\x20found','Setting','findOne','transcribe','transcribeRegion','language','runSentiment','sentiment','sentimentAccountId','sentimentRegion','Sentiment\x20Analysis\x20not\x20configured','transcribeAccountId','Cloud\x20Provider\x20not\x20available','data1','data2','Buckets','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','NEW'];(function(_0x1099f9,_0x59a040){var _0x46eae8=function(_0x1b2d1a){while(--_0x1b2d1a){_0x1099f9['push'](_0x1099f9['shift']());}};_0x46eae8(++_0x59a040);}(_0xb4fb,0x13a));var _0xbb4f=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0xb4fb[_0x20a584];return _0x4b41a8;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xbb4f('0x0'));var zipdir=require(_0xbb4f('0x1'));var jsonpatch=require(_0xbb4f('0x2'));var rp=require('request-promise');var moment=require(_0xbb4f('0x3'));var BPromise=require(_0xbb4f('0x4'));var Mustache=require(_0xbb4f('0x5'));var util=require('util');var path=require(_0xbb4f('0x6'));var sox=require('sox');var csv=require(_0xbb4f('0x7'));var ejs=require(_0xbb4f('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xbb4f('0x9'));var squel=require(_0xbb4f('0xa'));var crypto=require(_0xbb4f('0xb'));var jsforce=require(_0xbb4f('0xc'));var deskjs=require(_0xbb4f('0xd'));var toCsv=require(_0xbb4f('0x7'));var querystring=require(_0xbb4f('0xe'));var Papa=require(_0xbb4f('0xf'));var AWS=require(_0xbb4f('0x10'));var uuidv4=require(_0xbb4f('0x11'));var Redis=require(_0xbb4f('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xbb4f('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xbb4f('0x14'))(_0xbb4f('0x15'));var utils=require(_0xbb4f('0x16'));var config=require(_0xbb4f('0x17'));var licenseUtil=require(_0xbb4f('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x334728,_0x1d116b){_0x1d116b=_0x1d116b||0xcc;return function(_0x1c546c){if(_0x1c546c){return _0x334728[_0xbb4f('0x19')](_0x1d116b);}return _0x334728[_0xbb4f('0x1a')](_0x1d116b)[_0xbb4f('0x1b')]();};}function respondWithResult(_0x2882b9,_0x382f6f){_0x382f6f=_0x382f6f||0xc8;return function(_0x1bc297){if(_0x1bc297){return _0x2882b9[_0xbb4f('0x1a')](_0x382f6f)[_0xbb4f('0x1c')](_0x1bc297);}};}function respondWithFilteredResult(_0x32aeb9,_0x3b75c2){return function(_0x2b14fb){if(_0x2b14fb){var _0x38de3f=typeof _0x3b75c2[_0xbb4f('0x1d')]===_0xbb4f('0x1e')&&typeof _0x3b75c2[_0xbb4f('0x1f')]===_0xbb4f('0x1e');var _0x127138=_0x2b14fb[_0xbb4f('0x20')];var _0x13fcb8=_0x38de3f?0x0:_0x3b75c2[_0xbb4f('0x1d')];var _0x1e42dc=_0x38de3f?_0x2b14fb[_0xbb4f('0x20')]:_0x3b75c2['offset']+_0x3b75c2[_0xbb4f('0x1f')];var _0x43ced2;if(_0x1e42dc>=_0x127138){_0x1e42dc=_0x127138;_0x43ced2=0xc8;}else{_0x43ced2=0xce;}_0x32aeb9['status'](_0x43ced2);return _0x32aeb9[_0xbb4f('0x21')](_0xbb4f('0x22'),_0x13fcb8+'-'+_0x1e42dc+'/'+_0x127138)[_0xbb4f('0x1c')](_0x2b14fb);}return null;};}function patchUpdates(_0x58725c){return function(_0x100ebe){try{jsonpatch[_0xbb4f('0x23')](_0x100ebe,_0x58725c,!![]);}catch(_0x11744a){return BPromise[_0xbb4f('0x24')](_0x11744a);}return _0x100ebe[_0xbb4f('0x25')]();};}function saveUpdates(_0xf61503,_0x2309aa){return function(_0x4a2737){if(_0x4a2737){return _0x4a2737[_0xbb4f('0x26')](_0xf61503)['then'](function(_0x55b654){return _0x55b654;});}return null;};}function removeEntity(_0x1b1125,_0x46137f){return function(_0x26873c){if(_0x26873c){return _0x26873c[_0xbb4f('0x27')]()[_0xbb4f('0x28')](function(){_0x1b1125['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0xd44573,_0x5c1dc){return function(_0x48d43b){if(!_0x48d43b){_0xd44573['sendStatus'](0x194);}return _0x48d43b;};}function handleError(_0x23bea8,_0x26a70c){_0x26a70c=_0x26a70c||0x1f4;return function(_0x5310df){logger[_0xbb4f('0x29')](_0x5310df[_0xbb4f('0x2a')]);if(_0x5310df[_0xbb4f('0x2b')]){delete _0x5310df[_0xbb4f('0x2b')];}_0x23bea8[_0xbb4f('0x1a')](_0x26a70c)['send'](_0x5310df);};}exports['index']=function(_0x4cdf0e,_0x479aad){var _0x21ab5a={},_0x13b784={},_0x1a2a8d={'count':0x0,'rows':[]};var _0x4d4a8=_['map'](db[_0xbb4f('0x2c')][_0xbb4f('0x2d')],function(_0x3d56c0){return{'name':_0x3d56c0['fieldName'],'type':_0x3d56c0[_0xbb4f('0x2e')][_0xbb4f('0x2f')]};});_0x13b784['model']=_[_0xbb4f('0x30')](_[_0xbb4f('0x31')](_0x4d4a8,'name'),[_0xbb4f('0x32')]);_0x13b784[_0xbb4f('0x33')]=_[_0xbb4f('0x34')](_0x4cdf0e['query']);_0x13b784['filters']=_[_0xbb4f('0x35')](_0x13b784[_0xbb4f('0x36')],_0x13b784[_0xbb4f('0x33')]);_0x21ab5a[_0xbb4f('0x37')]=_[_0xbb4f('0x35')](_0x13b784['model'],qs[_0xbb4f('0x38')](_0x4cdf0e['query'][_0xbb4f('0x38')]));_0x21ab5a['attributes']=_0x21ab5a[_0xbb4f('0x37')][_0xbb4f('0x39')]?_0x21ab5a[_0xbb4f('0x37')]:_0x13b784[_0xbb4f('0x36')];if(!_0x4cdf0e[_0xbb4f('0x33')][_0xbb4f('0x3a')](_0xbb4f('0x3b'))){_0x21ab5a[_0xbb4f('0x1f')]=qs[_0xbb4f('0x1f')](_0x4cdf0e['query']['limit']);_0x21ab5a['offset']=qs[_0xbb4f('0x1d')](_0x4cdf0e[_0xbb4f('0x33')][_0xbb4f('0x1d')]);}_0x21ab5a[_0xbb4f('0x3c')]=qs['sort'](_0x4cdf0e[_0xbb4f('0x33')][_0xbb4f('0x3d')]);_0x21ab5a[_0xbb4f('0x3e')]=qs[_0xbb4f('0x3f')](_[_0xbb4f('0x40')](_0x4cdf0e[_0xbb4f('0x33')],_0x13b784['filters']),_0x4d4a8);if(_0x4cdf0e[_0xbb4f('0x33')][_0xbb4f('0x41')]){_0x21ab5a[_0xbb4f('0x3e')]=_[_0xbb4f('0x42')](_0x21ab5a[_0xbb4f('0x3e')],{'$or':_['map'](_0x4d4a8,function(_0x4fbcec){if(_0x4fbcec[_0xbb4f('0x2e')]!==_0xbb4f('0x43')){var _0x3990f2={};_0x3990f2[_0x4fbcec['name']]={'$like':'%'+_0x4cdf0e[_0xbb4f('0x33')][_0xbb4f('0x41')]+'%'};return _0x3990f2;}})});}_0x21ab5a=_[_0xbb4f('0x42')]({},_0x21ab5a,_0x4cdf0e['options']);var _0x51dc2d={'where':_0x21ab5a['where']};return db['VoiceRecording']['count'](_0x51dc2d)[_0xbb4f('0x28')](function(_0xe59d9c){_0x1a2a8d[_0xbb4f('0x20')]=_0xe59d9c;if(_0x4cdf0e['query'][_0xbb4f('0x44')]){_0x21ab5a[_0xbb4f('0x45')]=[{'all':!![]}];}return db[_0xbb4f('0x2c')][_0xbb4f('0x46')](_0x21ab5a);})['then'](function(_0x4eb50b){_0x1a2a8d[_0xbb4f('0x47')]=_0x4eb50b;return _0x1a2a8d;})[_0xbb4f('0x28')](respondWithFilteredResult(_0x479aad,_0x21ab5a))['catch'](handleError(_0x479aad,null));};exports[_0xbb4f('0x48')]=function(_0x5edd27,_0x17599b){var _0xc42b0a={'raw':![],'where':{'id':_0x5edd27[_0xbb4f('0x49')]['id']}},_0x2d389b={};_0x2d389b[_0xbb4f('0x36')]=_['keys'](db['VoiceRecording'][_0xbb4f('0x2d')]);_0x2d389b[_0xbb4f('0x33')]=_[_0xbb4f('0x34')](_0x5edd27[_0xbb4f('0x33')]);_0x2d389b['filters']=_[_0xbb4f('0x35')](_0x2d389b['model'],_0x2d389b[_0xbb4f('0x33')]);_0xc42b0a[_0xbb4f('0x37')]=_[_0xbb4f('0x35')](_0x2d389b[_0xbb4f('0x36')],qs[_0xbb4f('0x38')](_0x5edd27[_0xbb4f('0x33')][_0xbb4f('0x38')]));_0xc42b0a[_0xbb4f('0x37')]=_0xc42b0a[_0xbb4f('0x37')][_0xbb4f('0x39')]?_0xc42b0a['attributes']:_0x2d389b[_0xbb4f('0x36')];if(_0x5edd27[_0xbb4f('0x33')][_0xbb4f('0x44')]){_0xc42b0a[_0xbb4f('0x45')]=[{'all':!![]}];}_0xc42b0a=_[_0xbb4f('0x42')]({},_0xc42b0a,_0x5edd27[_0xbb4f('0x4a')]);return db[_0xbb4f('0x2c')][_0xbb4f('0x4b')](_0xc42b0a)[_0xbb4f('0x28')](handleEntityNotFound(_0x17599b,null))[_0xbb4f('0x28')](respondWithResult(_0x17599b,null))['catch'](handleError(_0x17599b,null));};exports['create']=function(_0x39f8b5,_0x5c4c86){return db[_0xbb4f('0x2c')][_0xbb4f('0x4c')](_0x39f8b5[_0xbb4f('0x4d')],{})[_0xbb4f('0x28')](respondWithResult(_0x5c4c86,0xc9))[_0xbb4f('0x4e')](handleError(_0x5c4c86,null));};exports[_0xbb4f('0x26')]=function(_0x17cbe4,_0x113669){if(_0x17cbe4[_0xbb4f('0x4d')]['id']){delete _0x17cbe4[_0xbb4f('0x4d')]['id'];}return db[_0xbb4f('0x2c')][_0xbb4f('0x4b')]({'where':{'id':_0x17cbe4[_0xbb4f('0x49')]['id']}})[_0xbb4f('0x28')](handleEntityNotFound(_0x113669,null))[_0xbb4f('0x28')](saveUpdates(_0x17cbe4[_0xbb4f('0x4d')],null))[_0xbb4f('0x28')](respondWithResult(_0x113669,null))[_0xbb4f('0x4e')](handleError(_0x113669,null));};exports[_0xbb4f('0x4f')]=function(_0x5ebc9c,_0x8f992e){return db['VoiceRecording'][_0xbb4f('0x4f')]()['then'](respondWithResult(_0x8f992e,null))[_0xbb4f('0x4e')](handleError(_0x8f992e,null));};exports[_0xbb4f('0x50')]=function(_0x25c6b8,_0x552eca,_0x3dba56){var _0xb2ca94=require(_0xbb4f('0x51'));var _0xf11406=![];var _0x3a3a40={};if(_0x25c6b8[_0xbb4f('0x33')]['type']&&_0x25c6b8[_0xbb4f('0x33')][_0xbb4f('0x2e')]==='uniqueid'){_0x3a3a40['uniqueid']=_0x25c6b8[_0xbb4f('0x49')]['id'];}else{_0x3a3a40['id']=_0x25c6b8[_0xbb4f('0x49')]['id'];}return db[_0xbb4f('0x2c')]['find']({'where':_0x3a3a40,'attributes':['id',_0xbb4f('0x52')],'raw':!![]})[_0xbb4f('0x28')](handleEntityNotFound(_0x552eca,null))[_0xbb4f('0x28')](function(_0x4535a6){if(_0x4535a6){var _0x56bfe5=_0x4535a6[_0xbb4f('0x52')];var _0x4a90ce=util[_0xbb4f('0x32')](_0xbb4f('0x53'),_0x56bfe5);if(fs[_0xbb4f('0x54')](_0x4a90ce)){_0xf11406=!![];return _0xb2ca94[_0xbb4f('0x55')](_0x4a90ce,_0x56bfe5,config['secrets']['recording'])[_0xbb4f('0x28')](function(){return _0x4535a6;});}return _0x4535a6;}})[_0xbb4f('0x28')](function(_0x17ae40){if(_0x17ae40){var _0xc7a85b=_0x17ae40[_0xbb4f('0x52')];if(!fs[_0xbb4f('0x54')](_0xc7a85b)){throw new db[(_0xbb4f('0x56'))][(_0xbb4f('0x57'))](_0xbb4f('0x58'));}if(_0x17ae40[_0xbb4f('0x59')]){return _0x552eca[_0xbb4f('0x50')](_0xc7a85b,_0x17ae40[_0xbb4f('0x59')]+path['extname'](_0xc7a85b),function(){if(_0xf11406){fs['unlink'](_0xc7a85b);}});}else{return _0x552eca[_0xbb4f('0x50')](_0xc7a85b,function(_0x133a68){if(_0xf11406){fs[_0xbb4f('0x5a')](_0xc7a85b);}});}}})[_0xbb4f('0x4e')](function(_0x40df5d){if(_0x40df5d[_0xbb4f('0x5b')]==='VoiceRecording\x20not\x20found'){_0x552eca[_0xbb4f('0x1a')](0x194)[_0xbb4f('0x5c')](_0xbb4f('0x5d'));}else{return handleError(_0x552eca,null);}});};exports['downloads']=function(_0x1d5b76,_0x524917,_0x59bf9a){var _0x3e7743=require('../../components/encryptor');var _0x18940d=![];var _0x514e22={'$and':[db[_0xbb4f('0x5e')][_0xbb4f('0x3e')](db[_0xbb4f('0x5e')]['fn'](_0xbb4f('0x5f'),db[_0xbb4f('0x5e')][_0xbb4f('0x60')](_0xbb4f('0x61'))),_0x1d5b76[_0xbb4f('0x33')][_0xbb4f('0x62')])]};if(_0x1d5b76[_0xbb4f('0x33')][_0xbb4f('0x2e')]&&_0x1d5b76[_0xbb4f('0x33')][_0xbb4f('0x2e')]==='uniqueid'){_0x514e22[_0xbb4f('0x63')][_0xbb4f('0x64')]({'uniqueid':_0x1d5b76['params']['id']});}else{_0x514e22['$and'][_0xbb4f('0x64')]({'id':_0x1d5b76['params']['id']});}return db[_0xbb4f('0x2c')]['find']({'where':_0x514e22,'attributes':['id',_0xbb4f('0x52')],'raw':!![]})[_0xbb4f('0x28')](handleEntityNotFound(_0x524917,null))[_0xbb4f('0x28')](function(_0x2910bf){if(_0x2910bf){var _0x177457=util[_0xbb4f('0x32')](_0xbb4f('0x53'),_0x2910bf['value']);if(fs[_0xbb4f('0x54')](_0x177457)){_0x18940d=!![];return _0x3e7743[_0xbb4f('0x55')](_0x177457,_0x2910bf[_0xbb4f('0x52')],config[_0xbb4f('0x65')][_0xbb4f('0x66')])[_0xbb4f('0x28')](function(){return _0x2910bf;});}return _0x2910bf;}})[_0xbb4f('0x28')](function(_0x5a6a0f){if(_0x5a6a0f){if(!fs[_0xbb4f('0x54')](_0x5a6a0f[_0xbb4f('0x52')])){throw new db[(_0xbb4f('0x56'))][(_0xbb4f('0x57'))]('VoiceRecording\x20not\x20found');}if(_0x5a6a0f[_0xbb4f('0x59')]){return _0x524917[_0xbb4f('0x50')](_0x5a6a0f[_0xbb4f('0x52')],_0x5a6a0f[_0xbb4f('0x59')]+path['extname'](_0x5a6a0f[_0xbb4f('0x52')]),function(){if(_0x18940d){fs[_0xbb4f('0x5a')](_0x5a6a0f[_0xbb4f('0x52')]);}});}else{return _0x524917[_0xbb4f('0x50')](_0x5a6a0f['value'],function(_0x368bd3){if(_0x18940d){fs[_0xbb4f('0x5a')](_0x5a6a0f['value']);}});}}})[_0xbb4f('0x4e')](handleError(_0x524917,null));};exports[_0xbb4f('0x27')]=function(_0x579d41,_0x2c1595){return db[_0xbb4f('0x2c')][_0xbb4f('0x4b')]({'where':{'id':_0x579d41[_0xbb4f('0x49')]['id']}})[_0xbb4f('0x28')](function(_0x158bea){if(_['isNil'](_0x158bea)){throw new ReferenceError(_0xbb4f('0x67'));}return _0x158bea;})['then'](function(_0x3b50e7){var _0x1c5536=_0x3b50e7[_0xbb4f('0x52')];logger['info'](_0xbb4f('0x68'),_0x1c5536);if(!_[_0xbb4f('0x69')](_0x3b50e7[_0xbb4f('0x52')])&&fs[_0xbb4f('0x54')](_0x1c5536)){logger[_0xbb4f('0x6a')]('File:\x20\x22'+_0x1c5536+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs[_0xbb4f('0x6b')](_0x1c5536);}_0x1c5536=_0x1c5536+_0xbb4f('0x6c');if(!_[_0xbb4f('0x69')](_0x3b50e7[_0xbb4f('0x52')])&&fs[_0xbb4f('0x54')](_0x1c5536)){logger[_0xbb4f('0x6a')](_0xbb4f('0x6d')+_0x1c5536+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs['unlinkSync'](_0x1c5536);}return _0x3b50e7;})[_0xbb4f('0x28')](function(_0x3fcf30){if(!_0x3fcf30)throw new InternalError();return _0x3fcf30[_0xbb4f('0x27')]();})[_0xbb4f('0x28')](function(){_0x2c1595[_0xbb4f('0x1a')](0xcc)['end']();})['catch'](handleError(_0x2c1595,null));};function getBucketslist(_0x40aed0,_0x1babb0,_0x3045f6){return new Promise(function(_0x169fc2,_0xbcff7f){var _0x1d68ed=new AWS['S3']({'accessKeyId':_0x1babb0,'secretAccessKey':_0x40aed0,'region':_0x3045f6});_0x1d68ed[_0xbb4f('0x6e')]({},function(_0x56daa8,_0x25c22a){if(_0x56daa8){return _0xbcff7f(_0x56daa8);}else{return _0x169fc2(_0x25c22a);}});});}function createBucket(_0x800bf8,_0x30c6da,_0x96b46f,_0x50e15c){return new Promise(function(_0x2e20f0,_0x226bfa){var _0x4ae907=new AWS['S3']({'accessKeyId':_0x30c6da,'secretAccessKey':_0x800bf8,'region':_0x96b46f});_0x4ae907[_0xbb4f('0x6f')]({'Bucket':_0x50e15c},function(_0x24d66e,_0xaac51b){if(_0x24d66e){return _0x226bfa(_0x24d66e);}else{return _0x2e20f0(_0xaac51b);}});});}function uploadFile(_0x12a895,_0x1967ac,_0x10d0bf,_0x31a691,_0x1f5033,_0x43983e){return new Promise(function(_0x27927f,_0x1fbd7d){var _0x2f2396=new AWS['S3']({'accessKeyId':_0x1967ac,'secretAccessKey':_0x12a895,'region':_0x10d0bf});_0x2f2396[_0xbb4f('0x70')]({'Bucket':_0x31a691,'Key':_0x1f5033,'Body':_0x43983e},function(_0x32a519,_0x14ccea){if(_0x32a519){return _0x1fbd7d(_0x32a519);}else{return _0x27927f(_0x14ccea);}});});}function startTranscribe(_0x2bcd76,_0x3c3715,_0x2fed5f,_0x556f8d,_0x293953,_0x1b0c16){return new Promise(function(_0x1544cf,_0x3a467e){var _0x42f0aa=new AWS['TranscribeService']({'accessKeyId':_0x3c3715,'secretAccessKey':_0x2bcd76,'region':_0x2fed5f});_0x42f0aa[_0xbb4f('0x71')]({'TranscriptionJobName':_0x556f8d,'LanguageCode':_0x293953,'Media':{'MediaFileUri':_0x1b0c16}},function(_0x19de31,_0x41f65f){if(_0x19de31){return _0x3a467e(_0x19de31);}else{return _0x1544cf(_0x41f65f);}});});}function transcribe(_0x28c482,_0x5168b9,_0x3b1368,_0x17bd59,_0x144e46,_0x2120b4,_0x345a5a){return new Promise(function(_0x201479,_0x4f8fd0){var _0x2626f0={};logger[_0xbb4f('0x6a')](util[_0xbb4f('0x32')]('[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s',_0x28c482,_0x144e46));return uploadFile(_0x5168b9,_0x3b1368,_0x17bd59,_0x144e46,path[_0xbb4f('0x72')](_0x2120b4),fs['readFileSync'](_0x2120b4))['then'](function(_0x518d20){logger[_0xbb4f('0x6a')](util[_0xbb4f('0x32')](_0xbb4f('0x73'),_0x28c482,_0x144e46,_0x518d20[_0xbb4f('0x74')]));_0x2626f0[_0xbb4f('0x75')]=_0x518d20[_0xbb4f('0x76')];_0x2626f0[_0xbb4f('0x77')]=_0x518d20[_0xbb4f('0x74')];logger['info'](util[_0xbb4f('0x32')](_0xbb4f('0x78'),_0x28c482));return startTranscribe(_0x5168b9,_0x3b1368,_0x17bd59,uuidv4(),_0x345a5a,_0x518d20[_0xbb4f('0x74')]);})['then'](function(_0xdf510c){logger[_0xbb4f('0x6a')](util['format'](_0xbb4f('0x79'),_0x28c482,_0xdf510c['TranscriptionJob'][_0xbb4f('0x7a')]));_0x2626f0['transcribeName']=_0xdf510c[_0xbb4f('0x7b')]['TranscriptionJobName'];_0x2626f0['transcribeStatus']=_0xdf510c[_0xbb4f('0x7b')][_0xbb4f('0x7c')];return _0x201479(_0x2626f0);})[_0xbb4f('0x4e')](function(_0x49595d){return _0x4f8fd0(_0x49595d);});});}exports['runTranscribe']=function(_0x452a9f,_0x272205,_0x369ce6){var _0x1da5bb;var _0x146aaf;var _0x7f71f9;var _0x4463ec=require(_0xbb4f('0x51'));return db['VoiceRecording']['findOne']({'where':{'id':_0x452a9f[_0xbb4f('0x49')]['id']}})[_0xbb4f('0x28')](function(_0x367746){if(_0x367746){var _0x11dd8c=util[_0xbb4f('0x32')](_0xbb4f('0x53'),_0x367746[_0xbb4f('0x52')]);if(fs['existsSync'](_0x11dd8c)){cypher=!![];return _0x4463ec[_0xbb4f('0x55')](_0x11dd8c,_0x367746[_0xbb4f('0x52')],config[_0xbb4f('0x65')]['recording'])[_0xbb4f('0x28')](function(){return _0x367746;});}return _0x367746;}})['then'](function(_0x4042b3){if(!_0x4042b3){throw new db['Sequelize'][(_0xbb4f('0x57'))](_0xbb4f('0x7d'));}_0x146aaf=_0x4042b3;return db[_0xbb4f('0x7e')][_0xbb4f('0x7f')]({'where':{'id':0x1}});})[_0xbb4f('0x28')](handleEntityNotFound(_0x272205,null))[_0xbb4f('0x28')](function(_0x25a5ac){if(_0x25a5ac){_0x1da5bb=_0x25a5ac;if(!_0x1da5bb[_0xbb4f('0x80')]||!_0x1da5bb['transcribeAccountId']||!_0x1da5bb[_0xbb4f('0x81')]||!_0x1da5bb[_0xbb4f('0x82')]||!_0x1da5bb[_0xbb4f('0x75')]){throw new db[(_0xbb4f('0x56'))]['ValidationError']('Transcribe\x20not\x20configured');}if(_0x452a9f['body'][_0xbb4f('0x83')]&&(!_0x1da5bb[_0xbb4f('0x84')]||!_0x1da5bb[_0xbb4f('0x85')]||!_0x1da5bb[_0xbb4f('0x86')]||!_0x1da5bb[_0xbb4f('0x82')]||!_0x1da5bb[_0xbb4f('0x75')])){throw new db['Sequelize'][(_0xbb4f('0x57'))](_0xbb4f('0x87'));}return db['CloudProvider']['findOne']({'where':{'id':_0x1da5bb[_0xbb4f('0x88')]}});}})[_0xbb4f('0x28')](function(_0x105062){if(!_0x105062){throw new db[(_0xbb4f('0x56'))][(_0xbb4f('0x57'))](_0xbb4f('0x89'));}if(!_0x105062['data1']||!_0x105062['data2']){throw new db[(_0xbb4f('0x56'))][(_0xbb4f('0x57'))]('Cloud\x20Provider\x20not\x20configured');}_0x7f71f9=_0x105062;return getBucketslist(_0x7f71f9[_0xbb4f('0x8a')],_0x7f71f9[_0xbb4f('0x8b')],_0x1da5bb[_0xbb4f('0x81')]);})[_0xbb4f('0x28')](function(_0x14a87f){if(_0x14a87f&&_0x14a87f[_0xbb4f('0x8c')]){var _0x5a71dc=_[_0xbb4f('0x4b')](_0x14a87f[_0xbb4f('0x8c')],function(_0x295039){return _0x295039[_0xbb4f('0x8d')]===_0x1da5bb[_0xbb4f('0x75')];});if(!_0x5a71dc){logger[_0xbb4f('0x6a')](util[_0xbb4f('0x32')](_0xbb4f('0x8e'),_0x452a9f[_0xbb4f('0x49')]['id'],_0x1da5bb[_0xbb4f('0x75')]));return createBucket(_0x7f71f9[_0xbb4f('0x8a')],_0x7f71f9[_0xbb4f('0x8b')],_0x1da5bb[_0xbb4f('0x81')],_0x1da5bb[_0xbb4f('0x75')]);}logger[_0xbb4f('0x6a')](util[_0xbb4f('0x32')](_0xbb4f('0x8f'),_0x452a9f[_0xbb4f('0x49')]['id'],_0x1da5bb['bucket']));return;}})[_0xbb4f('0x28')](function(_0x4c8c07){if(_0x146aaf['transcribeStatus']===_0xbb4f('0x90')){return transcribe(_0x452a9f[_0xbb4f('0x49')]['id'],_0x7f71f9[_0xbb4f('0x8a')],_0x7f71f9[_0xbb4f('0x8b')],_0x1da5bb[_0xbb4f('0x81')],_0x1da5bb[_0xbb4f('0x75')],_0x146aaf[_0xbb4f('0x52')],_0x1da5bb[_0xbb4f('0x82')]);}else{logger[_0xbb4f('0x6a')](util[_0xbb4f('0x32')](_0xbb4f('0x91'),_0x452a9f[_0xbb4f('0x49')]['id']));return{'transcribeStatus':'IN_PROGRESS'};}})[_0xbb4f('0x28')](function(_0x1baa6d){if(_0x1baa6d){_0x1baa6d['tempSentiment']=_0x452a9f[_0xbb4f('0x4d')][_0xbb4f('0x83')];return _0x146aaf[_0xbb4f('0x92')](_0x1baa6d);}})[_0xbb4f('0x28')](respondWithResult(_0x272205,null))[_0xbb4f('0x4e')](handleError(_0x272205,null));};function writeFile(_0x168e4c,_0x261461){return new Promise(function(_0x444002,_0x200f89){fs['writeFile'](_0x261461,_0x168e4c,function(_0x145dc1,_0x3c8b63){if(_0x145dc1){return _0x200f89(_0x145dc1);}else{return _0x444002(_0x3c8b63);}});});}exports[_0xbb4f('0x93')]=function(_0x2b46ea,_0x461801,_0x5a560c){return db['VoiceRecording']['findOne']({'where':{'id':_0x2b46ea[_0xbb4f('0x49')]['id']}})[_0xbb4f('0x28')](handleEntityNotFound(_0x461801))['then'](function(_0x34b8a3){if(_0x34b8a3&&_0x34b8a3[_0xbb4f('0x94')]){var _0x191536=_0x34b8a3['fileText'];var _0x151751=config[_0xbb4f('0x95')]+_0xbb4f('0x96')+_0x34b8a3['id']+_0xbb4f('0x97');if(fs[_0xbb4f('0x54')](_0x151751)){return _0x151751;}return writeFile(_0x191536,_0x151751)[_0xbb4f('0x28')](function(){return _0x151751;});}else{throw new db[(_0xbb4f('0x56'))][(_0xbb4f('0x57'))](_0xbb4f('0x98'));}})[_0xbb4f('0x28')](function(_0x3a7686){return _0x461801[_0xbb4f('0x50')](_0x3a7686);})[_0xbb4f('0x4e')](handleError(_0x461801));};
\ No newline at end of file