Built motion from commit (unavailable).|2.5.24
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index 0870210..7483aa1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc2c9=['tempSentiment','writeFile','downloadTranscribe','fileText','root','html-pdf','eml-format','rimraf','zip-dir','moment','util','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','papaparse','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','sendStatus','end','status','offset','limit','set','Content-Range','json','update','then','destroy','error','stack','name','send','map','VoiceRecording','rawAttributes','fieldName','type','key','model','differenceBy','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','count','includeAll','include','findAll','rows','show','params','options','find','catch','create','body','describe','download','uniqueid','value','format','existsSync','secrets','Sequelize','VoiceRecording\x20not\x20found','filename','extname','unlink','message','Not\x20found','../../components/encryptor','sequelize','MD5','col','token','$and','push','%s.cypher','decryptFile','recording','ValidationError','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','.cypher','isNil','upload','TranscribeService','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','Bucket','TranscriptionJob','TranscriptionJobName','transcribeName','transcribeStatus','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribe','transcribeAccountId','transcribeRegion','Transcribe\x20not\x20configured','runSentiment','sentiment','sentimentAccountId','sentimentRegion','language','bucket','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','data1','Cloud\x20Provider\x20not\x20configured','data2','Buckets','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','NEW','IN_PROGRESS'];(function(_0x25feab,_0x30eeb2){var _0x8403fa=function(_0x47a948){while(--_0x47a948){_0x25feab['push'](_0x25feab['shift']());}};_0x8403fa(++_0x30eeb2);}(_0xc2c9,0x1c1));var _0x9c2c=function(_0x30a57e,_0x132a5d){_0x30a57e=_0x30a57e-0x0;var _0x180e83=_0xc2c9[_0x30a57e];return _0x180e83;};'use strict';var pdf=require(_0x9c2c('0x0'));var emlformat=require(_0x9c2c('0x1'));var rimraf=require(_0x9c2c('0x2'));var zipdir=require(_0x9c2c('0x3'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x9c2c('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x9c2c('0x5'));var path=require('path');var sox=require(_0x9c2c('0x6'));var csv=require(_0x9c2c('0x7'));var ejs=require(_0x9c2c('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0x9c2c('0x9'));var crypto=require('crypto');var jsforce=require(_0x9c2c('0xa'));var deskjs=require(_0x9c2c('0xb'));var toCsv=require(_0x9c2c('0x7'));var querystring=require(_0x9c2c('0xc'));var Papa=require(_0x9c2c('0xd'));var AWS=require('aws-sdk');var uuidv4=require(_0x9c2c('0xe'));var Redis=require(_0x9c2c('0xf'));var authService=require(_0x9c2c('0x10'));var qs=require(_0x9c2c('0x11'));var as=require(_0x9c2c('0x12'));var hardwareService=require(_0x9c2c('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0x9c2c('0x14'));var config=require(_0x9c2c('0x15'));var licenseUtil=require(_0x9c2c('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x482eed,_0x47d8b2){_0x47d8b2=_0x47d8b2||0xcc;return function(_0x4ac336){if(_0x4ac336){return _0x482eed[_0x9c2c('0x17')](_0x47d8b2);}return _0x482eed['status'](_0x47d8b2)[_0x9c2c('0x18')]();};}function respondWithResult(_0x1c2e43,_0x28b625){_0x28b625=_0x28b625||0xc8;return function(_0x41bb94){if(_0x41bb94){return _0x1c2e43[_0x9c2c('0x19')](_0x28b625)['json'](_0x41bb94);}};}function respondWithFilteredResult(_0x7b5b94,_0x2c4017){return function(_0x445c59){if(_0x445c59){var _0x4fae70=_0x445c59['count'],_0x530acd=_0x2c4017[_0x9c2c('0x1a')],_0x3319be=_0x2c4017[_0x9c2c('0x1a')]+_0x2c4017[_0x9c2c('0x1b')],_0x3dd0ea;if(_0x3319be>=_0x4fae70){_0x3319be=_0x4fae70;_0x3dd0ea=0xc8;}else{_0x3dd0ea=0xce;}_0x7b5b94[_0x9c2c('0x19')](_0x3dd0ea);return _0x7b5b94[_0x9c2c('0x1c')](_0x9c2c('0x1d'),_0x530acd+'-'+_0x3319be+'/'+_0x4fae70)[_0x9c2c('0x1e')](_0x445c59);}return null;};}function patchUpdates(_0x2264a0){return function(_0xf28049){try{jsonpatch['apply'](_0xf28049,_0x2264a0,!![]);}catch(_0x57d7aa){return BPromise['reject'](_0x57d7aa);}return _0xf28049['save']();};}function saveUpdates(_0x553d03,_0x33d21a){return function(_0x533809){if(_0x533809){return _0x533809[_0x9c2c('0x1f')](_0x553d03)[_0x9c2c('0x20')](function(_0x25a646){return _0x25a646;});}return null;};}function removeEntity(_0x58b8f4,_0x4f5a39){return function(_0x2a8cb9){if(_0x2a8cb9){return _0x2a8cb9[_0x9c2c('0x21')]()['then'](function(){_0x58b8f4[_0x9c2c('0x19')](0xcc)[_0x9c2c('0x18')]();});}};}function handleEntityNotFound(_0xb3a6b7,_0x31beb6){return function(_0x577032){if(!_0x577032){_0xb3a6b7['sendStatus'](0x194);}return _0x577032;};}function handleError(_0x4fcad7,_0x1e229c){_0x1e229c=_0x1e229c||0x1f4;return function(_0x2590d5){logger[_0x9c2c('0x22')](_0x2590d5[_0x9c2c('0x23')]);if(_0x2590d5[_0x9c2c('0x24')]){delete _0x2590d5[_0x9c2c('0x24')];}_0x4fcad7['status'](_0x1e229c)[_0x9c2c('0x25')](_0x2590d5);};}exports['index']=function(_0x43f17b,_0x59eb54){var _0x2da639={},_0x1ef2ed={},_0x2f4952={'count':0x0,'rows':[]};var _0x1e6d06=_[_0x9c2c('0x26')](db[_0x9c2c('0x27')][_0x9c2c('0x28')],function(_0x5a408a){return{'name':_0x5a408a[_0x9c2c('0x29')],'type':_0x5a408a[_0x9c2c('0x2a')][_0x9c2c('0x2b')]};});_0x1ef2ed[_0x9c2c('0x2c')]=_[_0x9c2c('0x2d')](_[_0x9c2c('0x26')](_0x1e6d06,_0x9c2c('0x24')),['format']);_0x1ef2ed[_0x9c2c('0x2e')]=_[_0x9c2c('0x2f')](_0x43f17b['query']);_0x1ef2ed[_0x9c2c('0x30')]=_[_0x9c2c('0x31')](_0x1ef2ed[_0x9c2c('0x2c')],_0x1ef2ed[_0x9c2c('0x2e')]);_0x2da639[_0x9c2c('0x32')]=_[_0x9c2c('0x31')](_0x1ef2ed[_0x9c2c('0x2c')],qs[_0x9c2c('0x33')](_0x43f17b[_0x9c2c('0x2e')][_0x9c2c('0x33')]));_0x2da639[_0x9c2c('0x32')]=_0x2da639[_0x9c2c('0x32')][_0x9c2c('0x34')]?_0x2da639['attributes']:_0x1ef2ed[_0x9c2c('0x2c')];if(!_0x43f17b[_0x9c2c('0x2e')]['hasOwnProperty'](_0x9c2c('0x35'))){_0x2da639[_0x9c2c('0x1b')]=qs[_0x9c2c('0x1b')](_0x43f17b[_0x9c2c('0x2e')]['limit']);_0x2da639['offset']=qs['offset'](_0x43f17b['query'][_0x9c2c('0x1a')]);}_0x2da639[_0x9c2c('0x36')]=qs[_0x9c2c('0x37')](_0x43f17b[_0x9c2c('0x2e')][_0x9c2c('0x37')]);_0x2da639[_0x9c2c('0x38')]=qs[_0x9c2c('0x30')](_[_0x9c2c('0x39')](_0x43f17b[_0x9c2c('0x2e')],_0x1ef2ed[_0x9c2c('0x30')]),_0x1e6d06);if(_0x43f17b['query'][_0x9c2c('0x3a')]){_0x2da639[_0x9c2c('0x38')]=_[_0x9c2c('0x3b')](_0x2da639['where'],{'$or':_[_0x9c2c('0x26')](_0x1e6d06,function(_0x202092){if(_0x202092[_0x9c2c('0x2a')]!=='VIRTUAL'){var _0x10a736={};_0x10a736[_0x202092[_0x9c2c('0x24')]]={'$like':'%'+_0x43f17b[_0x9c2c('0x2e')][_0x9c2c('0x3a')]+'%'};return _0x10a736;}})});}_0x2da639=_[_0x9c2c('0x3b')]({},_0x2da639,_0x43f17b['options']);var _0x473d1c={'where':_0x2da639[_0x9c2c('0x38')]};return db[_0x9c2c('0x27')][_0x9c2c('0x3c')](_0x473d1c)['then'](function(_0xfa4f2f){_0x2f4952[_0x9c2c('0x3c')]=_0xfa4f2f;if(_0x43f17b[_0x9c2c('0x2e')][_0x9c2c('0x3d')]){_0x2da639[_0x9c2c('0x3e')]=[{'all':!![]}];}return db[_0x9c2c('0x27')][_0x9c2c('0x3f')](_0x2da639);})[_0x9c2c('0x20')](function(_0x210ac0){_0x2f4952[_0x9c2c('0x40')]=_0x210ac0;return _0x2f4952;})[_0x9c2c('0x20')](respondWithFilteredResult(_0x59eb54,_0x2da639))['catch'](handleError(_0x59eb54,null));};exports[_0x9c2c('0x41')]=function(_0x47b9dc,_0x23ee06){var _0x365663={'raw':![],'where':{'id':_0x47b9dc[_0x9c2c('0x42')]['id']}},_0x2ee7d6={};_0x2ee7d6[_0x9c2c('0x2c')]=_[_0x9c2c('0x2f')](db[_0x9c2c('0x27')][_0x9c2c('0x28')]);_0x2ee7d6[_0x9c2c('0x2e')]=_[_0x9c2c('0x2f')](_0x47b9dc[_0x9c2c('0x2e')]);_0x2ee7d6[_0x9c2c('0x30')]=_[_0x9c2c('0x31')](_0x2ee7d6[_0x9c2c('0x2c')],_0x2ee7d6[_0x9c2c('0x2e')]);_0x365663['attributes']=_['intersection'](_0x2ee7d6['model'],qs[_0x9c2c('0x33')](_0x47b9dc[_0x9c2c('0x2e')][_0x9c2c('0x33')]));_0x365663[_0x9c2c('0x32')]=_0x365663[_0x9c2c('0x32')][_0x9c2c('0x34')]?_0x365663['attributes']:_0x2ee7d6['model'];if(_0x47b9dc[_0x9c2c('0x2e')][_0x9c2c('0x3d')]){_0x365663[_0x9c2c('0x3e')]=[{'all':!![]}];}_0x365663=_[_0x9c2c('0x3b')]({},_0x365663,_0x47b9dc[_0x9c2c('0x43')]);return db[_0x9c2c('0x27')][_0x9c2c('0x44')](_0x365663)[_0x9c2c('0x20')](handleEntityNotFound(_0x23ee06,null))[_0x9c2c('0x20')](respondWithResult(_0x23ee06,null))[_0x9c2c('0x45')](handleError(_0x23ee06,null));};exports[_0x9c2c('0x46')]=function(_0x2f429a,_0x57a562){return db[_0x9c2c('0x27')][_0x9c2c('0x46')](_0x2f429a['body'],{})[_0x9c2c('0x20')](respondWithResult(_0x57a562,0xc9))[_0x9c2c('0x45')](handleError(_0x57a562,null));};exports[_0x9c2c('0x1f')]=function(_0x1f3a7f,_0x332bde){if(_0x1f3a7f[_0x9c2c('0x47')]['id']){delete _0x1f3a7f['body']['id'];}return db[_0x9c2c('0x27')][_0x9c2c('0x44')]({'where':{'id':_0x1f3a7f[_0x9c2c('0x42')]['id']}})['then'](handleEntityNotFound(_0x332bde,null))[_0x9c2c('0x20')](saveUpdates(_0x1f3a7f['body'],null))[_0x9c2c('0x20')](respondWithResult(_0x332bde,null))['catch'](handleError(_0x332bde,null));};exports[_0x9c2c('0x48')]=function(_0x310756,_0x1b58d9){return db['VoiceRecording'][_0x9c2c('0x48')]()[_0x9c2c('0x20')](respondWithResult(_0x1b58d9,null))[_0x9c2c('0x45')](handleError(_0x1b58d9,null));};exports[_0x9c2c('0x49')]=function(_0x48db68,_0x5db01e,_0x7a2f48){var _0xe753d4=require('../../components/encryptor');var _0x5890c6=![];var _0x58b3eb={};if(_0x48db68[_0x9c2c('0x2e')][_0x9c2c('0x2a')]&&_0x48db68[_0x9c2c('0x2e')]['type']===_0x9c2c('0x4a')){_0x58b3eb[_0x9c2c('0x4a')]=_0x48db68[_0x9c2c('0x42')]['id'];}else{_0x58b3eb['id']=_0x48db68[_0x9c2c('0x42')]['id'];}return db[_0x9c2c('0x27')][_0x9c2c('0x44')]({'where':_0x58b3eb,'attributes':['id',_0x9c2c('0x4b')],'raw':!![]})[_0x9c2c('0x20')](handleEntityNotFound(_0x5db01e,null))[_0x9c2c('0x20')](function(_0xf76976){if(_0xf76976){var _0x11ebaa=_0xf76976[_0x9c2c('0x4b')];var _0x34e248=util[_0x9c2c('0x4c')]('%s.cypher',_0x11ebaa);if(fs[_0x9c2c('0x4d')](_0x34e248)){_0x5890c6=!![];return _0xe753d4['decryptFile'](_0x34e248,_0x11ebaa,config[_0x9c2c('0x4e')]['recording'])[_0x9c2c('0x20')](function(){return _0xf76976;});}return _0xf76976;}})[_0x9c2c('0x20')](function(_0x7dd5ad){if(_0x7dd5ad){var _0x363768=_0x7dd5ad[_0x9c2c('0x4b')];if(!fs[_0x9c2c('0x4d')](_0x363768)){throw new db[(_0x9c2c('0x4f'))]['ValidationError'](_0x9c2c('0x50'));}if(_0x7dd5ad[_0x9c2c('0x51')]){return _0x5db01e[_0x9c2c('0x49')](_0x363768,_0x7dd5ad[_0x9c2c('0x51')]+path[_0x9c2c('0x52')](_0x363768),function(){if(_0x5890c6){fs[_0x9c2c('0x53')](_0x363768);}});}else{return _0x5db01e[_0x9c2c('0x49')](_0x363768,function(_0x29e3aa){if(_0x5890c6){fs[_0x9c2c('0x53')](_0x363768);}});}}})[_0x9c2c('0x45')](function(_0x5a0001){if(_0x5a0001[_0x9c2c('0x54')]==='VoiceRecording\x20not\x20found'){_0x5db01e[_0x9c2c('0x19')](0x194)[_0x9c2c('0x25')](_0x9c2c('0x55'));}else{return handleError(_0x5db01e,null);}});};exports['downloads']=function(_0x39e0ce,_0x59ec29,_0x28e45e){var _0x3666b3=require(_0x9c2c('0x56'));var _0x5d4464=![];var _0x40a054={'$and':[db[_0x9c2c('0x57')][_0x9c2c('0x38')](db[_0x9c2c('0x57')]['fn'](_0x9c2c('0x58'),db['sequelize'][_0x9c2c('0x59')]('uniqueid')),_0x39e0ce['query'][_0x9c2c('0x5a')])]};if(_0x39e0ce[_0x9c2c('0x2e')]['type']&&_0x39e0ce[_0x9c2c('0x2e')][_0x9c2c('0x2a')]===_0x9c2c('0x4a')){_0x40a054[_0x9c2c('0x5b')][_0x9c2c('0x5c')]({'uniqueid':_0x39e0ce[_0x9c2c('0x42')]['id']});}else{_0x40a054[_0x9c2c('0x5b')]['push']({'id':_0x39e0ce['params']['id']});}return db[_0x9c2c('0x27')]['find']({'where':_0x40a054,'attributes':['id',_0x9c2c('0x4b')],'raw':!![]})[_0x9c2c('0x20')](handleEntityNotFound(_0x59ec29,null))[_0x9c2c('0x20')](function(_0x3e5909){if(_0x3e5909){var _0x84aa9d=util[_0x9c2c('0x4c')](_0x9c2c('0x5d'),_0x3e5909[_0x9c2c('0x4b')]);if(fs[_0x9c2c('0x4d')](_0x84aa9d)){_0x5d4464=!![];return _0x3666b3[_0x9c2c('0x5e')](_0x84aa9d,_0x3e5909[_0x9c2c('0x4b')],config[_0x9c2c('0x4e')][_0x9c2c('0x5f')])[_0x9c2c('0x20')](function(){return _0x3e5909;});}return _0x3e5909;}})[_0x9c2c('0x20')](function(_0x358856){if(_0x358856){if(!fs[_0x9c2c('0x4d')](_0x358856[_0x9c2c('0x4b')])){throw new db[(_0x9c2c('0x4f'))][(_0x9c2c('0x60'))](_0x9c2c('0x50'));}if(_0x358856[_0x9c2c('0x51')]){return _0x59ec29[_0x9c2c('0x49')](_0x358856[_0x9c2c('0x4b')],_0x358856[_0x9c2c('0x51')]+path['extname'](_0x358856[_0x9c2c('0x4b')]),function(){if(_0x5d4464){fs[_0x9c2c('0x53')](_0x358856[_0x9c2c('0x4b')]);}});}else{return _0x59ec29[_0x9c2c('0x49')](_0x358856[_0x9c2c('0x4b')],function(_0x19a5ff){if(_0x5d4464){fs[_0x9c2c('0x53')](_0x358856[_0x9c2c('0x4b')]);}});}}})[_0x9c2c('0x45')](handleError(_0x59ec29,null));};exports[_0x9c2c('0x21')]=function(_0x1049fc,_0x4f7d9d){return db[_0x9c2c('0x27')]['find']({'where':{'id':_0x1049fc['params']['id']}})[_0x9c2c('0x20')](function(_0x4b7b85){if(!_0x4b7b85)throw new ReferenceError(_0x9c2c('0x61'));return _0x4b7b85;})[_0x9c2c('0x20')](function(_0x2a0590){var _0x580452=_0x2a0590[_0x9c2c('0x4b')];logger[_0x9c2c('0x62')](_0x9c2c('0x63'),_0x580452);if(!_['isNil'](_0x2a0590[_0x9c2c('0x4b')])&&fs[_0x9c2c('0x4d')](_0x580452)){logger['info'](_0x9c2c('0x64')+_0x580452+_0x9c2c('0x65'));fs[_0x9c2c('0x66')](_0x580452);}_0x580452=_0x580452+_0x9c2c('0x67');if(!_[_0x9c2c('0x68')](_0x2a0590[_0x9c2c('0x4b')])&&fs[_0x9c2c('0x4d')](_0x580452)){logger[_0x9c2c('0x62')](_0x9c2c('0x64')+_0x580452+_0x9c2c('0x65'));fs[_0x9c2c('0x66')](_0x580452);}return _0x2a0590;})[_0x9c2c('0x20')](function(_0x327dfc){if(!_0x327dfc)throw new InternalError();return _0x327dfc[_0x9c2c('0x21')]();})[_0x9c2c('0x20')](function(){_0x4f7d9d[_0x9c2c('0x19')](0xcc)[_0x9c2c('0x18')]();})['catch'](handleError(_0x4f7d9d,null));};function getBucketslist(_0x31fa72,_0x4c389a,_0x2ea085){return new Promise(function(_0x546ac6,_0xbf2339){var _0x48fec4=new AWS['S3']({'accessKeyId':_0x4c389a,'secretAccessKey':_0x31fa72,'region':_0x2ea085});_0x48fec4['listBuckets']({},function(_0x1220a6,_0x2b3ab4){if(_0x1220a6){return _0xbf2339(_0x1220a6);}else{return _0x546ac6(_0x2b3ab4);}});});}function createBucket(_0x3bb771,_0x1a4b72,_0x20fe93,_0x2e3863){return new Promise(function(_0x36a697,_0x539f90){var _0x59dca7=new AWS['S3']({'accessKeyId':_0x1a4b72,'secretAccessKey':_0x3bb771,'region':_0x20fe93});_0x59dca7['createBucket']({'Bucket':_0x2e3863},function(_0x322bce,_0x20a855){if(_0x322bce){return _0x539f90(_0x322bce);}else{return _0x36a697(_0x20a855);}});});}function uploadFile(_0x61ec96,_0x3309bd,_0x595a15,_0x429932,_0x32fa39,_0x24a2f9){return new Promise(function(_0x1f7eba,_0x4e12fa){var _0x508144=new AWS['S3']({'accessKeyId':_0x3309bd,'secretAccessKey':_0x61ec96,'region':_0x595a15});_0x508144[_0x9c2c('0x69')]({'Bucket':_0x429932,'Key':_0x32fa39,'Body':_0x24a2f9},function(_0x2d91c8,_0x5a46e9){if(_0x2d91c8){return _0x4e12fa(_0x2d91c8);}else{return _0x1f7eba(_0x5a46e9);}});});}function startTranscribe(_0x489ba3,_0x5c8195,_0x53b5a1,_0x327e15,_0x24e9f1,_0x46e76e){return new Promise(function(_0x41b221,_0x627f7c){var _0x174914=new AWS[(_0x9c2c('0x6a'))]({'accessKeyId':_0x5c8195,'secretAccessKey':_0x489ba3,'region':_0x53b5a1});_0x174914[_0x9c2c('0x6b')]({'TranscriptionJobName':_0x327e15,'LanguageCode':_0x24e9f1,'Media':{'MediaFileUri':_0x46e76e}},function(_0x50a25c,_0xd21eb1){if(_0x50a25c){return _0x627f7c(_0x50a25c);}else{return _0x41b221(_0xd21eb1);}});});}function transcribe(_0x1c8f1e,_0x59a615,_0x2e7e3c,_0x368880,_0x52c069,_0x3f9397,_0x4be519){return new Promise(function(_0x364504,_0x1553c7){var _0x38620e={};logger[_0x9c2c('0x62')](util[_0x9c2c('0x4c')](_0x9c2c('0x6c'),_0x1c8f1e,_0x52c069));return uploadFile(_0x59a615,_0x2e7e3c,_0x368880,_0x52c069,path['basename'](_0x3f9397),fs[_0x9c2c('0x6d')](_0x3f9397))['then'](function(_0x3f582d){logger[_0x9c2c('0x62')](util[_0x9c2c('0x4c')](_0x9c2c('0x6e'),_0x1c8f1e,_0x52c069,_0x3f582d[_0x9c2c('0x6f')]));_0x38620e['bucket']=_0x3f582d[_0x9c2c('0x70')];_0x38620e['location']=_0x3f582d['Location'];logger[_0x9c2c('0x62')](util[_0x9c2c('0x4c')]('[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request',_0x1c8f1e));return startTranscribe(_0x59a615,_0x2e7e3c,_0x368880,uuidv4(),_0x4be519,_0x3f582d[_0x9c2c('0x6f')]);})[_0x9c2c('0x20')](function(_0x1f3f54){logger[_0x9c2c('0x62')](util['format']('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0x1c8f1e,_0x1f3f54[_0x9c2c('0x71')][_0x9c2c('0x72')]));_0x38620e[_0x9c2c('0x73')]=_0x1f3f54['TranscriptionJob'][_0x9c2c('0x72')];_0x38620e[_0x9c2c('0x74')]=_0x1f3f54[_0x9c2c('0x71')]['TranscriptionJobStatus'];return _0x364504(_0x38620e);})['catch'](function(_0x5bf5e4){return _0x1553c7(_0x5bf5e4);});});}exports[_0x9c2c('0x75')]=function(_0x2df230,_0x39877e,_0x3ddf69){var _0x3ecb18;var _0xcd81e2;var _0x4668fd;var _0x1e931a=require(_0x9c2c('0x56'));return db[_0x9c2c('0x27')][_0x9c2c('0x76')]({'where':{'id':_0x2df230[_0x9c2c('0x42')]['id']}})[_0x9c2c('0x20')](function(_0x380da4){if(_0x380da4){var _0x56c130=util[_0x9c2c('0x4c')](_0x9c2c('0x5d'),_0x380da4[_0x9c2c('0x4b')]);if(fs[_0x9c2c('0x4d')](_0x56c130)){cypher=!![];return _0x1e931a[_0x9c2c('0x5e')](_0x56c130,_0x380da4[_0x9c2c('0x4b')],config[_0x9c2c('0x4e')][_0x9c2c('0x5f')])['then'](function(){return _0x380da4;});}return _0x380da4;}})['then'](function(_0x4d973c){if(!_0x4d973c){throw new db[(_0x9c2c('0x4f'))][(_0x9c2c('0x60'))](_0x9c2c('0x77'));}_0xcd81e2=_0x4d973c;return db[_0x9c2c('0x78')][_0x9c2c('0x76')]({'where':{'id':0x1}});})[_0x9c2c('0x20')](handleEntityNotFound(_0x39877e,null))[_0x9c2c('0x20')](function(_0x4dc45a){if(_0x4dc45a){_0x3ecb18=_0x4dc45a;if(!_0x3ecb18[_0x9c2c('0x79')]||!_0x3ecb18[_0x9c2c('0x7a')]||!_0x3ecb18[_0x9c2c('0x7b')]||!_0x3ecb18['language']||!_0x3ecb18['bucket']){throw new db['Sequelize'][(_0x9c2c('0x60'))](_0x9c2c('0x7c'));}if(_0x2df230[_0x9c2c('0x47')][_0x9c2c('0x7d')]&&(!_0x3ecb18[_0x9c2c('0x7e')]||!_0x3ecb18[_0x9c2c('0x7f')]||!_0x3ecb18[_0x9c2c('0x80')]||!_0x3ecb18[_0x9c2c('0x81')]||!_0x3ecb18[_0x9c2c('0x82')])){throw new db[(_0x9c2c('0x4f'))][(_0x9c2c('0x60'))](_0x9c2c('0x83'));}return db[_0x9c2c('0x84')]['findOne']({'where':{'id':_0x3ecb18[_0x9c2c('0x7a')]}});}})[_0x9c2c('0x20')](function(_0x1f42a6){if(!_0x1f42a6){throw new db[(_0x9c2c('0x4f'))]['ValidationError'](_0x9c2c('0x85'));}if(!_0x1f42a6[_0x9c2c('0x86')]||!_0x1f42a6['data2']){throw new db['Sequelize'][(_0x9c2c('0x60'))](_0x9c2c('0x87'));}_0x4668fd=_0x1f42a6;return getBucketslist(_0x4668fd['data1'],_0x4668fd[_0x9c2c('0x88')],_0x3ecb18[_0x9c2c('0x7b')]);})[_0x9c2c('0x20')](function(_0x2b88d6){if(_0x2b88d6&&_0x2b88d6[_0x9c2c('0x89')]){var _0x56dc43=_[_0x9c2c('0x44')](_0x2b88d6[_0x9c2c('0x89')],function(_0x1ffde4){return _0x1ffde4[_0x9c2c('0x8a')]===_0x3ecb18[_0x9c2c('0x82')];});if(!_0x56dc43){logger[_0x9c2c('0x62')](util[_0x9c2c('0x4c')](_0x9c2c('0x8b'),_0x2df230['params']['id'],_0x3ecb18[_0x9c2c('0x82')]));return createBucket(_0x4668fd[_0x9c2c('0x86')],_0x4668fd[_0x9c2c('0x88')],_0x3ecb18['transcribeRegion'],_0x3ecb18[_0x9c2c('0x82')]);}logger[_0x9c2c('0x62')](util[_0x9c2c('0x4c')](_0x9c2c('0x8c'),_0x2df230[_0x9c2c('0x42')]['id'],_0x3ecb18[_0x9c2c('0x82')]));return;}})[_0x9c2c('0x20')](function(_0x138850){if(_0xcd81e2[_0x9c2c('0x74')]===_0x9c2c('0x8d')){return transcribe(_0x2df230[_0x9c2c('0x42')]['id'],_0x4668fd['data1'],_0x4668fd[_0x9c2c('0x88')],_0x3ecb18[_0x9c2c('0x7b')],_0x3ecb18[_0x9c2c('0x82')],_0xcd81e2[_0x9c2c('0x4b')],_0x3ecb18[_0x9c2c('0x81')]);}else{logger['info'](util[_0x9c2c('0x4c')]('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x2df230[_0x9c2c('0x42')]['id']));return{'transcribeStatus':_0x9c2c('0x8e')};}})['then'](function(_0x23f531){if(_0x23f531){_0x23f531[_0x9c2c('0x8f')]=_0x2df230[_0x9c2c('0x47')]['runSentiment'];return _0xcd81e2['updateAttributes'](_0x23f531);}})['then'](respondWithResult(_0x39877e,null))[_0x9c2c('0x45')](handleError(_0x39877e,null));};function writeFile(_0x159875,_0x5d39a3){return new Promise(function(_0x2b9017,_0x1e3f68){fs[_0x9c2c('0x90')](_0x5d39a3,_0x159875,function(_0x5884d2,_0x3a612c){if(_0x5884d2){return _0x1e3f68(_0x5884d2);}else{return _0x2b9017(_0x3a612c);}});});}exports[_0x9c2c('0x91')]=function(_0x3acc62,_0x32b887,_0x4aea55){return db['VoiceRecording'][_0x9c2c('0x76')]({'where':{'id':_0x3acc62[_0x9c2c('0x42')]['id']}})[_0x9c2c('0x20')](handleEntityNotFound(_0x32b887))[_0x9c2c('0x20')](function(_0x4dd672){if(_0x4dd672&&_0x4dd672['fileText']){var _0x4e9b36=_0x4dd672[_0x9c2c('0x92')];var _0x40dc5a=config[_0x9c2c('0x93')]+'/server/files/transcribes/transcribe_'+_0x4dd672['id']+'.txt';if(fs[_0x9c2c('0x4d')](_0x40dc5a)){return _0x40dc5a;}return writeFile(_0x4e9b36,_0x40dc5a)['then'](function(){return _0x40dc5a;});}else{throw new db[(_0x9c2c('0x4f'))]['ValidationError']('Transcript\x20not\x20available');}})[_0x9c2c('0x20')](function(_0x13c4e4){return _0x32b887[_0x9c2c('0x49')](_0x13c4e4);})[_0x9c2c('0x45')](handleError(_0x32b887));};
\ No newline at end of file
+var _0x5860=['transcribeRegion','language','Sequelize','Transcribe\x20not\x20configured','runSentiment','sentimentAccountId','sentimentRegion','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','findOne','transcribeAccountId','Cloud\x20Provider\x20not\x20available','data1','data2','Cloud\x20Provider\x20not\x20configured','Buckets','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','NEW','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','tempSentiment','updateAttributes','writeFile','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','.txt','Transcript\x20not\x20available','html-pdf','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','aws-sdk','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','count','offset','limit','Content-Range','json','apply','reject','update','then','destroy','error','name','index','map','VoiceRecording','rawAttributes','fieldName','type','key','model','differenceBy','format','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','show','find','create','body','params','describe','download','../../components/encryptor','uniqueid','value','existsSync','decryptFile','recording','ValidationError','VoiceRecording\x20not\x20found','extname','unlink','message','send','Not\x20found','downloads','MD5','token','push','$and','%s.cypher','secrets','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','isNil','File:\x20\x22','unlinkSync','.cypher','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','createBucket','upload','TranscribeService','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','bucket','Bucket','TranscriptionJob','TranscriptionJobName','transcribeName','transcribeStatus','runTranscribe'];(function(_0x1969a7,_0x5a133a){var _0x3d665f=function(_0x39c64b){while(--_0x39c64b){_0x1969a7['push'](_0x1969a7['shift']());}};_0x3d665f(++_0x5a133a);}(_0x5860,0x147));var _0x0586=function(_0x2850c0,_0x1363a7){_0x2850c0=_0x2850c0-0x0;var _0x21e830=_0x5860[_0x2850c0];return _0x21e830;};'use strict';var pdf=require(_0x0586('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x0586('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0586('0x2'));var rp=require(_0x0586('0x3'));var moment=require(_0x0586('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x0586('0x5'));var util=require(_0x0586('0x6'));var path=require(_0x0586('0x7'));var sox=require(_0x0586('0x8'));var csv=require(_0x0586('0x9'));var ejs=require(_0x0586('0xa'));var fs=require('fs');var _=require(_0x0586('0xb'));var squel=require(_0x0586('0xc'));var crypto=require(_0x0586('0xd'));var jsforce=require(_0x0586('0xe'));var deskjs=require(_0x0586('0xf'));var toCsv=require('to-csv');var querystring=require(_0x0586('0x10'));var Papa=require(_0x0586('0x11'));var AWS=require(_0x0586('0x12'));var uuidv4=require('uuid/v4');var Redis=require('ioredis');var authService=require(_0x0586('0x13'));var qs=require(_0x0586('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x0586('0x15'));var utils=require(_0x0586('0x16'));var config=require(_0x0586('0x17'));var licenseUtil=require(_0x0586('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x43af67,_0x210a7f){_0x210a7f=_0x210a7f||0xcc;return function(_0x5bd4b2){if(_0x5bd4b2){return _0x43af67[_0x0586('0x19')](_0x210a7f);}return _0x43af67[_0x0586('0x1a')](_0x210a7f)[_0x0586('0x1b')]();};}function respondWithResult(_0x463cc4,_0x230892){_0x230892=_0x230892||0xc8;return function(_0x3f6c33){if(_0x3f6c33){return _0x463cc4[_0x0586('0x1a')](_0x230892)['json'](_0x3f6c33);}};}function respondWithFilteredResult(_0x39df84,_0x343752){return function(_0x2ed347){if(_0x2ed347){var _0x35dc7e=_0x2ed347[_0x0586('0x1c')],_0x9f320e=_0x343752[_0x0586('0x1d')],_0x5b7446=_0x343752[_0x0586('0x1d')]+_0x343752[_0x0586('0x1e')],_0x433ce2;if(_0x5b7446>=_0x35dc7e){_0x5b7446=_0x35dc7e;_0x433ce2=0xc8;}else{_0x433ce2=0xce;}_0x39df84[_0x0586('0x1a')](_0x433ce2);return _0x39df84['set'](_0x0586('0x1f'),_0x9f320e+'-'+_0x5b7446+'/'+_0x35dc7e)[_0x0586('0x20')](_0x2ed347);}return null;};}function patchUpdates(_0x553c36){return function(_0x542de5){try{jsonpatch[_0x0586('0x21')](_0x542de5,_0x553c36,!![]);}catch(_0xb810fa){return BPromise[_0x0586('0x22')](_0xb810fa);}return _0x542de5['save']();};}function saveUpdates(_0x1125ab,_0x112602){return function(_0x350618){if(_0x350618){return _0x350618[_0x0586('0x23')](_0x1125ab)[_0x0586('0x24')](function(_0x247021){return _0x247021;});}return null;};}function removeEntity(_0x18c9a4,_0x4050af){return function(_0x1dad1e){if(_0x1dad1e){return _0x1dad1e[_0x0586('0x25')]()[_0x0586('0x24')](function(){_0x18c9a4[_0x0586('0x1a')](0xcc)[_0x0586('0x1b')]();});}};}function handleEntityNotFound(_0x56d555,_0x5ef3f5){return function(_0x577665){if(!_0x577665){_0x56d555['sendStatus'](0x194);}return _0x577665;};}function handleError(_0x4aa6d0,_0x4c416f){_0x4c416f=_0x4c416f||0x1f4;return function(_0x392708){logger[_0x0586('0x26')](_0x392708['stack']);if(_0x392708['name']){delete _0x392708[_0x0586('0x27')];}_0x4aa6d0[_0x0586('0x1a')](_0x4c416f)['send'](_0x392708);};}exports[_0x0586('0x28')]=function(_0x4a6fa5,_0x75d233){var _0x51fd67={},_0x1bedb3={},_0x188c43={'count':0x0,'rows':[]};var _0x7157c9=_[_0x0586('0x29')](db[_0x0586('0x2a')][_0x0586('0x2b')],function(_0x313fe4){return{'name':_0x313fe4[_0x0586('0x2c')],'type':_0x313fe4[_0x0586('0x2d')][_0x0586('0x2e')]};});_0x1bedb3[_0x0586('0x2f')]=_[_0x0586('0x30')](_[_0x0586('0x29')](_0x7157c9,_0x0586('0x27')),[_0x0586('0x31')]);_0x1bedb3[_0x0586('0x32')]=_[_0x0586('0x33')](_0x4a6fa5[_0x0586('0x32')]);_0x1bedb3[_0x0586('0x34')]=_[_0x0586('0x35')](_0x1bedb3[_0x0586('0x2f')],_0x1bedb3[_0x0586('0x32')]);_0x51fd67[_0x0586('0x36')]=_['intersection'](_0x1bedb3[_0x0586('0x2f')],qs['fields'](_0x4a6fa5[_0x0586('0x32')][_0x0586('0x37')]));_0x51fd67['attributes']=_0x51fd67[_0x0586('0x36')][_0x0586('0x38')]?_0x51fd67['attributes']:_0x1bedb3[_0x0586('0x2f')];if(!_0x4a6fa5[_0x0586('0x32')]['hasOwnProperty'](_0x0586('0x39'))){_0x51fd67[_0x0586('0x1e')]=qs[_0x0586('0x1e')](_0x4a6fa5[_0x0586('0x32')][_0x0586('0x1e')]);_0x51fd67['offset']=qs[_0x0586('0x1d')](_0x4a6fa5[_0x0586('0x32')]['offset']);}_0x51fd67[_0x0586('0x3a')]=qs[_0x0586('0x3b')](_0x4a6fa5[_0x0586('0x32')][_0x0586('0x3b')]);_0x51fd67[_0x0586('0x3c')]=qs[_0x0586('0x34')](_[_0x0586('0x3d')](_0x4a6fa5[_0x0586('0x32')],_0x1bedb3[_0x0586('0x34')]),_0x7157c9);if(_0x4a6fa5[_0x0586('0x32')][_0x0586('0x3e')]){_0x51fd67['where']=_[_0x0586('0x3f')](_0x51fd67[_0x0586('0x3c')],{'$or':_[_0x0586('0x29')](_0x7157c9,function(_0x583880){if(_0x583880[_0x0586('0x2d')]!==_0x0586('0x40')){var _0x2c5740={};_0x2c5740[_0x583880[_0x0586('0x27')]]={'$like':'%'+_0x4a6fa5[_0x0586('0x32')]['filter']+'%'};return _0x2c5740;}})});}_0x51fd67=_[_0x0586('0x3f')]({},_0x51fd67,_0x4a6fa5[_0x0586('0x41')]);var _0x424ebc={'where':_0x51fd67['where']};return db['VoiceRecording'][_0x0586('0x1c')](_0x424ebc)[_0x0586('0x24')](function(_0x40b8d9){_0x188c43['count']=_0x40b8d9;if(_0x4a6fa5[_0x0586('0x32')][_0x0586('0x42')]){_0x51fd67[_0x0586('0x43')]=[{'all':!![]}];}return db['VoiceRecording'][_0x0586('0x44')](_0x51fd67);})[_0x0586('0x24')](function(_0x4d4fbb){_0x188c43['rows']=_0x4d4fbb;return _0x188c43;})[_0x0586('0x24')](respondWithFilteredResult(_0x75d233,_0x51fd67))[_0x0586('0x45')](handleError(_0x75d233,null));};exports[_0x0586('0x46')]=function(_0xf26637,_0x1229b9){var _0x4828f3={'raw':![],'where':{'id':_0xf26637['params']['id']}},_0x1265d1={};_0x1265d1['model']=_[_0x0586('0x33')](db[_0x0586('0x2a')][_0x0586('0x2b')]);_0x1265d1[_0x0586('0x32')]=_[_0x0586('0x33')](_0xf26637[_0x0586('0x32')]);_0x1265d1[_0x0586('0x34')]=_['intersection'](_0x1265d1['model'],_0x1265d1[_0x0586('0x32')]);_0x4828f3[_0x0586('0x36')]=_[_0x0586('0x35')](_0x1265d1[_0x0586('0x2f')],qs['fields'](_0xf26637[_0x0586('0x32')]['fields']));_0x4828f3['attributes']=_0x4828f3[_0x0586('0x36')][_0x0586('0x38')]?_0x4828f3[_0x0586('0x36')]:_0x1265d1[_0x0586('0x2f')];if(_0xf26637['query']['includeAll']){_0x4828f3[_0x0586('0x43')]=[{'all':!![]}];}_0x4828f3=_[_0x0586('0x3f')]({},_0x4828f3,_0xf26637[_0x0586('0x41')]);return db[_0x0586('0x2a')][_0x0586('0x47')](_0x4828f3)[_0x0586('0x24')](handleEntityNotFound(_0x1229b9,null))['then'](respondWithResult(_0x1229b9,null))[_0x0586('0x45')](handleError(_0x1229b9,null));};exports[_0x0586('0x48')]=function(_0x393b40,_0x1f7061){return db[_0x0586('0x2a')][_0x0586('0x48')](_0x393b40[_0x0586('0x49')],{})['then'](respondWithResult(_0x1f7061,0xc9))[_0x0586('0x45')](handleError(_0x1f7061,null));};exports[_0x0586('0x23')]=function(_0x15875d,_0x5814d1){if(_0x15875d['body']['id']){delete _0x15875d[_0x0586('0x49')]['id'];}return db['VoiceRecording'][_0x0586('0x47')]({'where':{'id':_0x15875d[_0x0586('0x4a')]['id']}})[_0x0586('0x24')](handleEntityNotFound(_0x5814d1,null))['then'](saveUpdates(_0x15875d['body'],null))[_0x0586('0x24')](respondWithResult(_0x5814d1,null))[_0x0586('0x45')](handleError(_0x5814d1,null));};exports[_0x0586('0x4b')]=function(_0x3aa1f8,_0xcdd627){return db['VoiceRecording'][_0x0586('0x4b')]()['then'](respondWithResult(_0xcdd627,null))[_0x0586('0x45')](handleError(_0xcdd627,null));};exports[_0x0586('0x4c')]=function(_0x534555,_0x2c6d78,_0x11f086){var _0x466c6a=require(_0x0586('0x4d'));var _0x30c054=![];var _0x596f6b={};if(_0x534555[_0x0586('0x32')][_0x0586('0x2d')]&&_0x534555[_0x0586('0x32')][_0x0586('0x2d')]===_0x0586('0x4e')){_0x596f6b['uniqueid']=_0x534555['params']['id'];}else{_0x596f6b['id']=_0x534555[_0x0586('0x4a')]['id'];}return db[_0x0586('0x2a')][_0x0586('0x47')]({'where':_0x596f6b,'attributes':['id',_0x0586('0x4f')],'raw':!![]})['then'](handleEntityNotFound(_0x2c6d78,null))[_0x0586('0x24')](function(_0x1edd36){if(_0x1edd36){var _0x943a19=_0x1edd36[_0x0586('0x4f')];var _0x58c4f8=util['format']('%s.cypher',_0x943a19);if(fs[_0x0586('0x50')](_0x58c4f8)){_0x30c054=!![];return _0x466c6a[_0x0586('0x51')](_0x58c4f8,_0x943a19,config['secrets'][_0x0586('0x52')])[_0x0586('0x24')](function(){return _0x1edd36;});}return _0x1edd36;}})[_0x0586('0x24')](function(_0x27fb6b){if(_0x27fb6b){var _0x2c0944=_0x27fb6b[_0x0586('0x4f')];if(!fs[_0x0586('0x50')](_0x2c0944)){throw new db['Sequelize'][(_0x0586('0x53'))](_0x0586('0x54'));}if(_0x27fb6b['filename']){return _0x2c6d78[_0x0586('0x4c')](_0x2c0944,_0x27fb6b['filename']+path[_0x0586('0x55')](_0x2c0944),function(){if(_0x30c054){fs[_0x0586('0x56')](_0x2c0944);}});}else{return _0x2c6d78[_0x0586('0x4c')](_0x2c0944,function(_0x58d74f){if(_0x30c054){fs[_0x0586('0x56')](_0x2c0944);}});}}})[_0x0586('0x45')](function(_0x380fe9){if(_0x380fe9[_0x0586('0x57')]===_0x0586('0x54')){_0x2c6d78['status'](0x194)[_0x0586('0x58')](_0x0586('0x59'));}else{return handleError(_0x2c6d78,null);}});};exports[_0x0586('0x5a')]=function(_0x288424,_0x53b33e,_0x56789d){var _0x1be5d3=require(_0x0586('0x4d'));var _0x31a3c1=![];var _0x460f48={'$and':[db['sequelize']['where'](db['sequelize']['fn'](_0x0586('0x5b'),db['sequelize']['col'](_0x0586('0x4e'))),_0x288424[_0x0586('0x32')][_0x0586('0x5c')])]};if(_0x288424[_0x0586('0x32')][_0x0586('0x2d')]&&_0x288424[_0x0586('0x32')]['type']===_0x0586('0x4e')){_0x460f48['$and'][_0x0586('0x5d')]({'uniqueid':_0x288424[_0x0586('0x4a')]['id']});}else{_0x460f48[_0x0586('0x5e')][_0x0586('0x5d')]({'id':_0x288424[_0x0586('0x4a')]['id']});}return db['VoiceRecording'][_0x0586('0x47')]({'where':_0x460f48,'attributes':['id','value'],'raw':!![]})[_0x0586('0x24')](handleEntityNotFound(_0x53b33e,null))[_0x0586('0x24')](function(_0x535d07){if(_0x535d07){var _0x1f6e62=util[_0x0586('0x31')](_0x0586('0x5f'),_0x535d07['value']);if(fs['existsSync'](_0x1f6e62)){_0x31a3c1=!![];return _0x1be5d3[_0x0586('0x51')](_0x1f6e62,_0x535d07[_0x0586('0x4f')],config[_0x0586('0x60')]['recording'])[_0x0586('0x24')](function(){return _0x535d07;});}return _0x535d07;}})[_0x0586('0x24')](function(_0x50849d){if(_0x50849d){if(!fs[_0x0586('0x50')](_0x50849d[_0x0586('0x4f')])){throw new db['Sequelize'][(_0x0586('0x53'))](_0x0586('0x54'));}if(_0x50849d['filename']){return _0x53b33e['download'](_0x50849d[_0x0586('0x4f')],_0x50849d['filename']+path['extname'](_0x50849d[_0x0586('0x4f')]),function(){if(_0x31a3c1){fs[_0x0586('0x56')](_0x50849d['value']);}});}else{return _0x53b33e[_0x0586('0x4c')](_0x50849d[_0x0586('0x4f')],function(_0x3b0734){if(_0x31a3c1){fs[_0x0586('0x56')](_0x50849d[_0x0586('0x4f')]);}});}}})[_0x0586('0x45')](handleError(_0x53b33e,null));};exports[_0x0586('0x25')]=function(_0x1e9953,_0x4bfd30){return db[_0x0586('0x2a')][_0x0586('0x47')]({'where':{'id':_0x1e9953['params']['id']}})[_0x0586('0x24')](function(_0xccbdd0){if(!_0xccbdd0)throw new ReferenceError(_0x0586('0x61'));return _0xccbdd0;})[_0x0586('0x24')](function(_0x4fd25d){var _0x1f07fd=_0x4fd25d[_0x0586('0x4f')];logger[_0x0586('0x62')](_0x0586('0x63'),_0x1f07fd);if(!_[_0x0586('0x64')](_0x4fd25d[_0x0586('0x4f')])&&fs[_0x0586('0x50')](_0x1f07fd)){logger['info'](_0x0586('0x65')+_0x1f07fd+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs[_0x0586('0x66')](_0x1f07fd);}_0x1f07fd=_0x1f07fd+_0x0586('0x67');if(!_[_0x0586('0x64')](_0x4fd25d[_0x0586('0x4f')])&&fs['existsSync'](_0x1f07fd)){logger[_0x0586('0x62')](_0x0586('0x65')+_0x1f07fd+_0x0586('0x68'));fs[_0x0586('0x66')](_0x1f07fd);}return _0x4fd25d;})[_0x0586('0x24')](function(_0x3e9294){if(!_0x3e9294)throw new InternalError();return _0x3e9294[_0x0586('0x25')]();})[_0x0586('0x24')](function(){_0x4bfd30[_0x0586('0x1a')](0xcc)[_0x0586('0x1b')]();})['catch'](handleError(_0x4bfd30,null));};function getBucketslist(_0x3cd4ee,_0x2ea2f2,_0x56075a){return new Promise(function(_0x545825,_0x32e264){var _0x4761de=new AWS['S3']({'accessKeyId':_0x2ea2f2,'secretAccessKey':_0x3cd4ee,'region':_0x56075a});_0x4761de['listBuckets']({},function(_0xcf7e5b,_0x42389c){if(_0xcf7e5b){return _0x32e264(_0xcf7e5b);}else{return _0x545825(_0x42389c);}});});}function createBucket(_0x585550,_0x2d7bf7,_0x5cc70b,_0x13cdd0){return new Promise(function(_0x4819d7,_0x220382){var _0x5b19e1=new AWS['S3']({'accessKeyId':_0x2d7bf7,'secretAccessKey':_0x585550,'region':_0x5cc70b});_0x5b19e1[_0x0586('0x69')]({'Bucket':_0x13cdd0},function(_0x491732,_0x45ae31){if(_0x491732){return _0x220382(_0x491732);}else{return _0x4819d7(_0x45ae31);}});});}function uploadFile(_0x2d140c,_0x32f6f7,_0x392584,_0x1d7202,_0x4854be,_0x391588){return new Promise(function(_0x290d48,_0x251877){var _0x5c4d8b=new AWS['S3']({'accessKeyId':_0x32f6f7,'secretAccessKey':_0x2d140c,'region':_0x392584});_0x5c4d8b[_0x0586('0x6a')]({'Bucket':_0x1d7202,'Key':_0x4854be,'Body':_0x391588},function(_0x57ce59,_0xa793f6){if(_0x57ce59){return _0x251877(_0x57ce59);}else{return _0x290d48(_0xa793f6);}});});}function startTranscribe(_0x4270c0,_0x5e4839,_0xf9f878,_0x1a726d,_0x5c3327,_0x420360){return new Promise(function(_0x370330,_0x18f305){var _0x6fbaf9=new AWS[(_0x0586('0x6b'))]({'accessKeyId':_0x5e4839,'secretAccessKey':_0x4270c0,'region':_0xf9f878});_0x6fbaf9['startTranscriptionJob']({'TranscriptionJobName':_0x1a726d,'LanguageCode':_0x5c3327,'Media':{'MediaFileUri':_0x420360}},function(_0x19d458,_0x27de1e){if(_0x19d458){return _0x18f305(_0x19d458);}else{return _0x370330(_0x27de1e);}});});}function transcribe(_0x5daf6e,_0xb021c7,_0x4a66db,_0xcf014e,_0x3671d8,_0x55cf69,_0x185d18){return new Promise(function(_0x29641b,_0x586467){var _0x414ddf={};logger[_0x0586('0x62')](util[_0x0586('0x31')]('[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s',_0x5daf6e,_0x3671d8));return uploadFile(_0xb021c7,_0x4a66db,_0xcf014e,_0x3671d8,path['basename'](_0x55cf69),fs['readFileSync'](_0x55cf69))['then'](function(_0x423d11){logger[_0x0586('0x62')](util[_0x0586('0x31')](_0x0586('0x6c'),_0x5daf6e,_0x3671d8,_0x423d11[_0x0586('0x6d')]));_0x414ddf[_0x0586('0x6e')]=_0x423d11[_0x0586('0x6f')];_0x414ddf['location']=_0x423d11[_0x0586('0x6d')];logger[_0x0586('0x62')](util[_0x0586('0x31')]('[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request',_0x5daf6e));return startTranscribe(_0xb021c7,_0x4a66db,_0xcf014e,uuidv4(),_0x185d18,_0x423d11[_0x0586('0x6d')]);})['then'](function(_0x10de5b){logger[_0x0586('0x62')](util[_0x0586('0x31')]('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0x5daf6e,_0x10de5b[_0x0586('0x70')][_0x0586('0x71')]));_0x414ddf[_0x0586('0x72')]=_0x10de5b[_0x0586('0x70')][_0x0586('0x71')];_0x414ddf[_0x0586('0x73')]=_0x10de5b['TranscriptionJob']['TranscriptionJobStatus'];return _0x29641b(_0x414ddf);})[_0x0586('0x45')](function(_0x1dd42f){return _0x586467(_0x1dd42f);});});}exports[_0x0586('0x74')]=function(_0x55d0fe,_0x3d73cd,_0x386216){var _0x2f5a2d;var _0x478405;var _0x450821;var _0xcfc705=require('../../components/encryptor');return db[_0x0586('0x2a')]['findOne']({'where':{'id':_0x55d0fe['params']['id']}})[_0x0586('0x24')](function(_0x4fe788){if(_0x4fe788){var _0x38490a=util[_0x0586('0x31')](_0x0586('0x5f'),_0x4fe788[_0x0586('0x4f')]);if(fs['existsSync'](_0x38490a)){cypher=!![];return _0xcfc705[_0x0586('0x51')](_0x38490a,_0x4fe788['value'],config[_0x0586('0x60')]['recording'])['then'](function(){return _0x4fe788;});}return _0x4fe788;}})[_0x0586('0x24')](function(_0x3c0b31){if(!_0x3c0b31){throw new db['Sequelize'][(_0x0586('0x53'))]('Voice\x20Recording\x20not\x20found');}_0x478405=_0x3c0b31;return db['Setting']['findOne']({'where':{'id':0x1}});})[_0x0586('0x24')](handleEntityNotFound(_0x3d73cd,null))[_0x0586('0x24')](function(_0x1508bc){if(_0x1508bc){_0x2f5a2d=_0x1508bc;if(!_0x2f5a2d['transcribe']||!_0x2f5a2d['transcribeAccountId']||!_0x2f5a2d[_0x0586('0x75')]||!_0x2f5a2d[_0x0586('0x76')]||!_0x2f5a2d['bucket']){throw new db[(_0x0586('0x77'))]['ValidationError'](_0x0586('0x78'));}if(_0x55d0fe['body'][_0x0586('0x79')]&&(!_0x2f5a2d['sentiment']||!_0x2f5a2d[_0x0586('0x7a')]||!_0x2f5a2d[_0x0586('0x7b')]||!_0x2f5a2d[_0x0586('0x76')]||!_0x2f5a2d[_0x0586('0x6e')])){throw new db[(_0x0586('0x77'))][(_0x0586('0x53'))](_0x0586('0x7c'));}return db[_0x0586('0x7d')][_0x0586('0x7e')]({'where':{'id':_0x2f5a2d[_0x0586('0x7f')]}});}})[_0x0586('0x24')](function(_0x1db21f){if(!_0x1db21f){throw new db['Sequelize'][(_0x0586('0x53'))](_0x0586('0x80'));}if(!_0x1db21f[_0x0586('0x81')]||!_0x1db21f[_0x0586('0x82')]){throw new db[(_0x0586('0x77'))][(_0x0586('0x53'))](_0x0586('0x83'));}_0x450821=_0x1db21f;return getBucketslist(_0x450821[_0x0586('0x81')],_0x450821[_0x0586('0x82')],_0x2f5a2d['transcribeRegion']);})[_0x0586('0x24')](function(_0x425672){if(_0x425672&&_0x425672[_0x0586('0x84')]){var _0x4ffc92=_[_0x0586('0x47')](_0x425672['Buckets'],function(_0xb81ffb){return _0xb81ffb[_0x0586('0x85')]===_0x2f5a2d['bucket'];});if(!_0x4ffc92){logger[_0x0586('0x62')](util[_0x0586('0x31')](_0x0586('0x86'),_0x55d0fe['params']['id'],_0x2f5a2d[_0x0586('0x6e')]));return createBucket(_0x450821[_0x0586('0x81')],_0x450821[_0x0586('0x82')],_0x2f5a2d[_0x0586('0x75')],_0x2f5a2d[_0x0586('0x6e')]);}logger[_0x0586('0x62')](util[_0x0586('0x31')](_0x0586('0x87'),_0x55d0fe['params']['id'],_0x2f5a2d[_0x0586('0x6e')]));return;}})[_0x0586('0x24')](function(_0x3eaab6){if(_0x478405[_0x0586('0x73')]===_0x0586('0x88')){return transcribe(_0x55d0fe[_0x0586('0x4a')]['id'],_0x450821[_0x0586('0x81')],_0x450821[_0x0586('0x82')],_0x2f5a2d[_0x0586('0x75')],_0x2f5a2d[_0x0586('0x6e')],_0x478405[_0x0586('0x4f')],_0x2f5a2d[_0x0586('0x76')]);}else{logger['info'](util[_0x0586('0x31')](_0x0586('0x89'),_0x55d0fe[_0x0586('0x4a')]['id']));return{'transcribeStatus':_0x0586('0x8a')};}})[_0x0586('0x24')](function(_0x31970c){if(_0x31970c){_0x31970c[_0x0586('0x8b')]=_0x55d0fe[_0x0586('0x49')]['runSentiment'];return _0x478405[_0x0586('0x8c')](_0x31970c);}})[_0x0586('0x24')](respondWithResult(_0x3d73cd,null))['catch'](handleError(_0x3d73cd,null));};function writeFile(_0x48effa,_0x282439){return new Promise(function(_0x11a60d,_0x5b7486){fs[_0x0586('0x8d')](_0x282439,_0x48effa,function(_0x36013b,_0x489124){if(_0x36013b){return _0x5b7486(_0x36013b);}else{return _0x11a60d(_0x489124);}});});}exports[_0x0586('0x8e')]=function(_0x46a64b,_0x47fefb,_0x57cf99){return db[_0x0586('0x2a')][_0x0586('0x7e')]({'where':{'id':_0x46a64b[_0x0586('0x4a')]['id']}})[_0x0586('0x24')](handleEntityNotFound(_0x47fefb))[_0x0586('0x24')](function(_0x54e32b){if(_0x54e32b&&_0x54e32b[_0x0586('0x8f')]){var _0x3e8e32=_0x54e32b['fileText'];var _0x499128=config[_0x0586('0x90')]+_0x0586('0x91')+_0x54e32b['id']+_0x0586('0x92');if(fs['existsSync'](_0x499128)){return _0x499128;}return writeFile(_0x3e8e32,_0x499128)[_0x0586('0x24')](function(){return _0x499128;});}else{throw new db[(_0x0586('0x77'))][(_0x0586('0x53'))](_0x0586('0x93'));}})[_0x0586('0x24')](function(_0x1b99ef){return _0x47fefb['download'](_0x1b99ef);})[_0x0586('0x45')](handleError(_0x47fefb));};
\ No newline at end of file