Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index 4b51886..10fbcc5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfc21=['transcribeStatus','NEW','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','runSentiment','writeFile','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','.txt','Transcript\x20not\x20available','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','ejs','squel','desk.js','to-csv','querystring','papaparse','aws-sdk','uuid/v4','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','end','status','json','offset','limit','Content-Range','apply','reject','save','destroy','then','error','stack','name','send','map','VoiceRecording','rawAttributes','fieldName','type','key','differenceBy','format','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','filter','where','VIRTUAL','merge','options','count','include','rows','catch','show','params','model','includeAll','find','create','body','update','describe','download','../../components/encryptor','uniqueid','value','%s.cypher','existsSync','decryptFile','recording','Sequelize','ValidationError','VoiceRecording\x20not\x20found','filename','unlink','Not\x20found','sequelize','MD5','col','push','$and','secrets','extname','Entity\x20not\x20found','cancellazione\x20fisica\x20documento\x20%s','info','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','.cypher','listBuckets','TranscribeService','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','basename','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','TranscriptionJob','TranscriptionJobName','transcribeName','TranscriptionJobStatus','runTranscribe','findOne','Setting','transcribe','transcribeAccountId','transcribeRegion','bucket','sentiment','sentimentAccountId','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','data1','data2','Cloud\x20Provider\x20not\x20configured','Buckets','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available'];(function(_0x1d1779,_0x284147){var _0x2377e9=function(_0x299f6f){while(--_0x299f6f){_0x1d1779['push'](_0x1d1779['shift']());}};_0x2377e9(++_0x284147);}(_0xfc21,0x1c8));var _0x1fc2=function(_0x3b380d,_0x4bf247){_0x3b380d=_0x3b380d-0x0;var _0x54502b=_0xfc21[_0x3b380d];return _0x54502b;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x1fc2('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x1fc2('0x1'));var jsonpatch=require(_0x1fc2('0x2'));var rp=require(_0x1fc2('0x3'));var moment=require(_0x1fc2('0x4'));var BPromise=require(_0x1fc2('0x5'));var Mustache=require(_0x1fc2('0x6'));var util=require(_0x1fc2('0x7'));var path=require(_0x1fc2('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x1fc2('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x1fc2('0xa'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x1fc2('0xb'));var toCsv=require(_0x1fc2('0xc'));var querystring=require(_0x1fc2('0xd'));var Papa=require(_0x1fc2('0xe'));var AWS=require(_0x1fc2('0xf'));var uuidv4=require(_0x1fc2('0x10'));var Redis=require('ioredis');var authService=require(_0x1fc2('0x11'));var qs=require(_0x1fc2('0x12'));var as=require(_0x1fc2('0x13'));var hardwareService=require(_0x1fc2('0x14'));var logger=require(_0x1fc2('0x15'))(_0x1fc2('0x16'));var utils=require(_0x1fc2('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x1fc2('0x18'));var db=require(_0x1fc2('0x19'))['db'];function respondWithStatusCode(_0x42d898,_0x330dec){_0x330dec=_0x330dec||0xcc;return function(_0x2305e5){if(_0x2305e5){return _0x42d898['sendStatus'](_0x330dec);}return _0x42d898['status'](_0x330dec)[_0x1fc2('0x1a')]();};}function respondWithResult(_0x357bb5,_0x1027de){_0x1027de=_0x1027de||0xc8;return function(_0x3ed2a4){if(_0x3ed2a4){return _0x357bb5[_0x1fc2('0x1b')](_0x1027de)[_0x1fc2('0x1c')](_0x3ed2a4);}};}function respondWithFilteredResult(_0x2dc6d2,_0x2b2b56){return function(_0x37772f){if(_0x37772f){var _0x92eea8=_0x37772f['count'],_0x161f64=_0x2b2b56[_0x1fc2('0x1d')],_0x3415cd=_0x2b2b56[_0x1fc2('0x1d')]+_0x2b2b56[_0x1fc2('0x1e')],_0x29044f;if(_0x3415cd>=_0x92eea8){_0x3415cd=_0x92eea8;_0x29044f=0xc8;}else{_0x29044f=0xce;}_0x2dc6d2[_0x1fc2('0x1b')](_0x29044f);return _0x2dc6d2['set'](_0x1fc2('0x1f'),_0x161f64+'-'+_0x3415cd+'/'+_0x92eea8)[_0x1fc2('0x1c')](_0x37772f);}return null;};}function patchUpdates(_0x6fd59){return function(_0x5b059c){try{jsonpatch[_0x1fc2('0x20')](_0x5b059c,_0x6fd59,!![]);}catch(_0x53c926){return BPromise[_0x1fc2('0x21')](_0x53c926);}return _0x5b059c[_0x1fc2('0x22')]();};}function saveUpdates(_0x587e8e,_0x2290c6){return function(_0x4b3e3f){if(_0x4b3e3f){return _0x4b3e3f['update'](_0x587e8e)['then'](function(_0x5eb6a4){return _0x5eb6a4;});}return null;};}function removeEntity(_0x493937,_0xd99402){return function(_0x224efd){if(_0x224efd){return _0x224efd[_0x1fc2('0x23')]()[_0x1fc2('0x24')](function(){_0x493937[_0x1fc2('0x1b')](0xcc)[_0x1fc2('0x1a')]();});}};}function handleEntityNotFound(_0x2c432b,_0x228691){return function(_0x156e27){if(!_0x156e27){_0x2c432b['sendStatus'](0x194);}return _0x156e27;};}function handleError(_0x2e60b9,_0x5c35c7){_0x5c35c7=_0x5c35c7||0x1f4;return function(_0x242463){logger[_0x1fc2('0x25')](_0x242463[_0x1fc2('0x26')]);if(_0x242463['name']){delete _0x242463[_0x1fc2('0x27')];}_0x2e60b9['status'](_0x5c35c7)[_0x1fc2('0x28')](_0x242463);};}exports['index']=function(_0x5a2025,_0x36c7f1){var _0xe32b14={},_0x2114a1={},_0x17635f={'count':0x0,'rows':[]};var _0x4b7332=_[_0x1fc2('0x29')](db[_0x1fc2('0x2a')][_0x1fc2('0x2b')],function(_0x201371){return{'name':_0x201371[_0x1fc2('0x2c')],'type':_0x201371[_0x1fc2('0x2d')][_0x1fc2('0x2e')]};});_0x2114a1['model']=_[_0x1fc2('0x2f')](_[_0x1fc2('0x29')](_0x4b7332,_0x1fc2('0x27')),[_0x1fc2('0x30')]);_0x2114a1[_0x1fc2('0x31')]=_[_0x1fc2('0x32')](_0x5a2025[_0x1fc2('0x31')]);_0x2114a1[_0x1fc2('0x33')]=_[_0x1fc2('0x34')](_0x2114a1['model'],_0x2114a1[_0x1fc2('0x31')]);_0xe32b14[_0x1fc2('0x35')]=_[_0x1fc2('0x34')](_0x2114a1['model'],qs[_0x1fc2('0x36')](_0x5a2025[_0x1fc2('0x31')][_0x1fc2('0x36')]));_0xe32b14[_0x1fc2('0x35')]=_0xe32b14[_0x1fc2('0x35')][_0x1fc2('0x37')]?_0xe32b14[_0x1fc2('0x35')]:_0x2114a1['model'];if(!_0x5a2025[_0x1fc2('0x31')][_0x1fc2('0x38')](_0x1fc2('0x39'))){_0xe32b14[_0x1fc2('0x1e')]=qs[_0x1fc2('0x1e')](_0x5a2025[_0x1fc2('0x31')][_0x1fc2('0x1e')]);_0xe32b14[_0x1fc2('0x1d')]=qs[_0x1fc2('0x1d')](_0x5a2025[_0x1fc2('0x31')]['offset']);}_0xe32b14['order']=qs[_0x1fc2('0x3a')](_0x5a2025['query'][_0x1fc2('0x3a')]);_0xe32b14['where']=qs[_0x1fc2('0x33')](_['pick'](_0x5a2025[_0x1fc2('0x31')],_0x2114a1[_0x1fc2('0x33')]),_0x4b7332);if(_0x5a2025['query'][_0x1fc2('0x3b')]){_0xe32b14['where']=_['merge'](_0xe32b14[_0x1fc2('0x3c')],{'$or':_['map'](_0x4b7332,function(_0x4d20a1){if(_0x4d20a1[_0x1fc2('0x2d')]!==_0x1fc2('0x3d')){var _0xd8a9c1={};_0xd8a9c1[_0x4d20a1[_0x1fc2('0x27')]]={'$like':'%'+_0x5a2025['query'][_0x1fc2('0x3b')]+'%'};return _0xd8a9c1;}})});}_0xe32b14=_[_0x1fc2('0x3e')]({},_0xe32b14,_0x5a2025[_0x1fc2('0x3f')]);var _0x2b9d2e={'where':_0xe32b14[_0x1fc2('0x3c')]};return db[_0x1fc2('0x2a')][_0x1fc2('0x40')](_0x2b9d2e)[_0x1fc2('0x24')](function(_0x441bfd){_0x17635f[_0x1fc2('0x40')]=_0x441bfd;if(_0x5a2025['query']['includeAll']){_0xe32b14[_0x1fc2('0x41')]=[{'all':!![]}];}return db['VoiceRecording']['findAll'](_0xe32b14);})[_0x1fc2('0x24')](function(_0x356685){_0x17635f[_0x1fc2('0x42')]=_0x356685;return _0x17635f;})['then'](respondWithFilteredResult(_0x36c7f1,_0xe32b14))[_0x1fc2('0x43')](handleError(_0x36c7f1,null));};exports[_0x1fc2('0x44')]=function(_0x14a7ed,_0x177664){var _0x165d4d={'raw':![],'where':{'id':_0x14a7ed[_0x1fc2('0x45')]['id']}},_0x5bc826={};_0x5bc826[_0x1fc2('0x46')]=_['keys'](db[_0x1fc2('0x2a')][_0x1fc2('0x2b')]);_0x5bc826[_0x1fc2('0x31')]=_[_0x1fc2('0x32')](_0x14a7ed['query']);_0x5bc826[_0x1fc2('0x33')]=_[_0x1fc2('0x34')](_0x5bc826[_0x1fc2('0x46')],_0x5bc826[_0x1fc2('0x31')]);_0x165d4d[_0x1fc2('0x35')]=_[_0x1fc2('0x34')](_0x5bc826['model'],qs[_0x1fc2('0x36')](_0x14a7ed[_0x1fc2('0x31')][_0x1fc2('0x36')]));_0x165d4d[_0x1fc2('0x35')]=_0x165d4d['attributes']['length']?_0x165d4d[_0x1fc2('0x35')]:_0x5bc826[_0x1fc2('0x46')];if(_0x14a7ed[_0x1fc2('0x31')][_0x1fc2('0x47')]){_0x165d4d[_0x1fc2('0x41')]=[{'all':!![]}];}_0x165d4d=_[_0x1fc2('0x3e')]({},_0x165d4d,_0x14a7ed[_0x1fc2('0x3f')]);return db['VoiceRecording'][_0x1fc2('0x48')](_0x165d4d)['then'](handleEntityNotFound(_0x177664,null))[_0x1fc2('0x24')](respondWithResult(_0x177664,null))[_0x1fc2('0x43')](handleError(_0x177664,null));};exports['create']=function(_0x34b7bf,_0x3fbb76){return db['VoiceRecording'][_0x1fc2('0x49')](_0x34b7bf[_0x1fc2('0x4a')],{})[_0x1fc2('0x24')](respondWithResult(_0x3fbb76,0xc9))[_0x1fc2('0x43')](handleError(_0x3fbb76,null));};exports[_0x1fc2('0x4b')]=function(_0x1add6f,_0x2678c3){if(_0x1add6f[_0x1fc2('0x4a')]['id']){delete _0x1add6f['body']['id'];}return db[_0x1fc2('0x2a')][_0x1fc2('0x48')]({'where':{'id':_0x1add6f[_0x1fc2('0x45')]['id']}})['then'](handleEntityNotFound(_0x2678c3,null))[_0x1fc2('0x24')](saveUpdates(_0x1add6f[_0x1fc2('0x4a')],null))[_0x1fc2('0x24')](respondWithResult(_0x2678c3,null))[_0x1fc2('0x43')](handleError(_0x2678c3,null));};exports[_0x1fc2('0x4c')]=function(_0x14c449,_0x3a3719){return db[_0x1fc2('0x2a')]['describe']()[_0x1fc2('0x24')](respondWithResult(_0x3a3719,null))[_0x1fc2('0x43')](handleError(_0x3a3719,null));};exports[_0x1fc2('0x4d')]=function(_0x3a2b19,_0x59d511,_0x41f040){var _0x2daf78=require(_0x1fc2('0x4e'));var _0x19dd9f=![];var _0x5bdbf5={};if(_0x3a2b19[_0x1fc2('0x31')]['type']&&_0x3a2b19['query'][_0x1fc2('0x2d')]==='uniqueid'){_0x5bdbf5[_0x1fc2('0x4f')]=_0x3a2b19[_0x1fc2('0x45')]['id'];}else{_0x5bdbf5['id']=_0x3a2b19[_0x1fc2('0x45')]['id'];}return db[_0x1fc2('0x2a')]['find']({'where':_0x5bdbf5,'attributes':['id',_0x1fc2('0x50')],'raw':!![]})[_0x1fc2('0x24')](handleEntityNotFound(_0x59d511,null))[_0x1fc2('0x24')](function(_0x6aad40){if(_0x6aad40){var _0x50e6b5=_0x6aad40[_0x1fc2('0x50')];var _0x2c8fd8=util[_0x1fc2('0x30')](_0x1fc2('0x51'),_0x50e6b5);if(fs[_0x1fc2('0x52')](_0x2c8fd8)){_0x19dd9f=!![];return _0x2daf78[_0x1fc2('0x53')](_0x2c8fd8,_0x50e6b5,config['secrets'][_0x1fc2('0x54')])[_0x1fc2('0x24')](function(){return _0x6aad40;});}return _0x6aad40;}})[_0x1fc2('0x24')](function(_0x5a0a74){if(_0x5a0a74){var _0x51c275=_0x5a0a74[_0x1fc2('0x50')];if(!fs['existsSync'](_0x51c275)){throw new db[(_0x1fc2('0x55'))][(_0x1fc2('0x56'))](_0x1fc2('0x57'));}if(_0x5a0a74[_0x1fc2('0x58')]){return _0x59d511['download'](_0x51c275,_0x5a0a74[_0x1fc2('0x58')]+path['extname'](_0x51c275),function(){if(_0x19dd9f){fs[_0x1fc2('0x59')](_0x51c275);}});}else{return _0x59d511['download'](_0x51c275,function(_0x57cd95){if(_0x19dd9f){fs[_0x1fc2('0x59')](_0x51c275);}});}}})[_0x1fc2('0x43')](function(_0x108196){if(_0x108196['message']===_0x1fc2('0x57')){_0x59d511['status'](0x194)['send'](_0x1fc2('0x5a'));}else{return handleError(_0x59d511,null);}});};exports['downloads']=function(_0x3ee21f,_0x45d50b,_0x2b506f){var _0x11a3e1=require(_0x1fc2('0x4e'));var _0x317e3d=![];var _0x1c9f88={'$and':[db[_0x1fc2('0x5b')][_0x1fc2('0x3c')](db[_0x1fc2('0x5b')]['fn'](_0x1fc2('0x5c'),db['sequelize'][_0x1fc2('0x5d')]('uniqueid')),_0x3ee21f[_0x1fc2('0x31')]['token'])]};if(_0x3ee21f[_0x1fc2('0x31')][_0x1fc2('0x2d')]&&_0x3ee21f[_0x1fc2('0x31')][_0x1fc2('0x2d')]===_0x1fc2('0x4f')){_0x1c9f88['$and'][_0x1fc2('0x5e')]({'uniqueid':_0x3ee21f[_0x1fc2('0x45')]['id']});}else{_0x1c9f88[_0x1fc2('0x5f')][_0x1fc2('0x5e')]({'id':_0x3ee21f[_0x1fc2('0x45')]['id']});}return db[_0x1fc2('0x2a')][_0x1fc2('0x48')]({'where':_0x1c9f88,'attributes':['id',_0x1fc2('0x50')],'raw':!![]})['then'](handleEntityNotFound(_0x45d50b,null))[_0x1fc2('0x24')](function(_0xa3fe24){if(_0xa3fe24){var _0x30a904=util[_0x1fc2('0x30')]('%s.cypher',_0xa3fe24[_0x1fc2('0x50')]);if(fs['existsSync'](_0x30a904)){_0x317e3d=!![];return _0x11a3e1['decryptFile'](_0x30a904,_0xa3fe24['value'],config[_0x1fc2('0x60')][_0x1fc2('0x54')])[_0x1fc2('0x24')](function(){return _0xa3fe24;});}return _0xa3fe24;}})[_0x1fc2('0x24')](function(_0x34aaf7){if(_0x34aaf7){if(!fs[_0x1fc2('0x52')](_0x34aaf7[_0x1fc2('0x50')])){throw new db[(_0x1fc2('0x55'))][(_0x1fc2('0x56'))](_0x1fc2('0x57'));}if(_0x34aaf7[_0x1fc2('0x58')]){return _0x45d50b['download'](_0x34aaf7[_0x1fc2('0x50')],_0x34aaf7[_0x1fc2('0x58')]+path[_0x1fc2('0x61')](_0x34aaf7[_0x1fc2('0x50')]),function(){if(_0x317e3d){fs[_0x1fc2('0x59')](_0x34aaf7[_0x1fc2('0x50')]);}});}else{return _0x45d50b[_0x1fc2('0x4d')](_0x34aaf7['value'],function(_0x4b3a3b){if(_0x317e3d){fs['unlink'](_0x34aaf7[_0x1fc2('0x50')]);}});}}})['catch'](handleError(_0x45d50b,null));};exports[_0x1fc2('0x23')]=function(_0x2e0d86,_0x5319ea){return db[_0x1fc2('0x2a')][_0x1fc2('0x48')]({'where':{'id':_0x2e0d86['params']['id']}})[_0x1fc2('0x24')](function(_0x1dfc1b){if(!_0x1dfc1b)throw new ReferenceError(_0x1fc2('0x62'));return _0x1dfc1b;})[_0x1fc2('0x24')](function(_0x2e3c82){var _0x5c9840=_0x2e3c82[_0x1fc2('0x50')];logger['info'](_0x1fc2('0x63'),_0x5c9840);if(!_['isNil'](_0x2e3c82[_0x1fc2('0x50')])&&fs[_0x1fc2('0x52')](_0x5c9840)){logger[_0x1fc2('0x64')](_0x1fc2('0x65')+_0x5c9840+_0x1fc2('0x66'));fs[_0x1fc2('0x67')](_0x5c9840);}_0x5c9840=_0x5c9840+_0x1fc2('0x68');if(!_['isNil'](_0x2e3c82[_0x1fc2('0x50')])&&fs['existsSync'](_0x5c9840)){logger['info']('File:\x20\x22'+_0x5c9840+_0x1fc2('0x66'));fs['unlinkSync'](_0x5c9840);}return _0x2e3c82;})[_0x1fc2('0x24')](function(_0x5d3ebf){if(!_0x5d3ebf)throw new InternalError();return _0x5d3ebf[_0x1fc2('0x23')]();})[_0x1fc2('0x24')](function(){_0x5319ea[_0x1fc2('0x1b')](0xcc)['end']();})[_0x1fc2('0x43')](handleError(_0x5319ea,null));};function getBucketslist(_0x190dd9,_0x18ab1a,_0x297b28){return new Promise(function(_0xf32ef6,_0x33436e){var _0x4f3c7=new AWS['S3']({'accessKeyId':_0x18ab1a,'secretAccessKey':_0x190dd9,'region':_0x297b28});_0x4f3c7[_0x1fc2('0x69')]({},function(_0x5887e6,_0x33ae99){if(_0x5887e6){return _0x33436e(_0x5887e6);}else{return _0xf32ef6(_0x33ae99);}});});}function createBucket(_0x35e32c,_0x24a6ff,_0x1b1d24,_0x3aeb63){return new Promise(function(_0x56685d,_0xeffc1a){var _0x2312b2=new AWS['S3']({'accessKeyId':_0x24a6ff,'secretAccessKey':_0x35e32c,'region':_0x1b1d24});_0x2312b2['createBucket']({'Bucket':_0x3aeb63},function(_0x28f3a7,_0x3014ac){if(_0x28f3a7){return _0xeffc1a(_0x28f3a7);}else{return _0x56685d(_0x3014ac);}});});}function uploadFile(_0x3df819,_0x2da61d,_0x4f0f86,_0x2e9357,_0x51897c,_0x23af6d){return new Promise(function(_0x49f13d,_0x5ada5b){var _0x3d8a12=new AWS['S3']({'accessKeyId':_0x2da61d,'secretAccessKey':_0x3df819,'region':_0x4f0f86});_0x3d8a12['upload']({'Bucket':_0x2e9357,'Key':_0x51897c,'Body':_0x23af6d},function(_0x48006a,_0x3ef37c){if(_0x48006a){return _0x5ada5b(_0x48006a);}else{return _0x49f13d(_0x3ef37c);}});});}function startTranscribe(_0x32c064,_0x394b33,_0x48ec37,_0x3e2e7d,_0x2ff573,_0x1a9866){return new Promise(function(_0x38f141,_0x3e9c49){var _0x35fa7c=new AWS[(_0x1fc2('0x6a'))]({'accessKeyId':_0x394b33,'secretAccessKey':_0x32c064,'region':_0x48ec37});_0x35fa7c['startTranscriptionJob']({'TranscriptionJobName':_0x3e2e7d,'LanguageCode':_0x2ff573,'Media':{'MediaFileUri':_0x1a9866}},function(_0x5679b5,_0x23ba77){if(_0x5679b5){return _0x3e9c49(_0x5679b5);}else{return _0x38f141(_0x23ba77);}});});}function transcribe(_0x1ee1c3,_0x19ac89,_0x525e17,_0x3ee5f9,_0xe785c3,_0x1961fc,_0x5cde00){return new Promise(function(_0x31c415,_0x5b5056){var _0x4475e3={};logger[_0x1fc2('0x64')](util[_0x1fc2('0x30')](_0x1fc2('0x6b'),_0x1ee1c3,_0xe785c3));return uploadFile(_0x19ac89,_0x525e17,_0x3ee5f9,_0xe785c3,path[_0x1fc2('0x6c')](_0x1961fc),fs[_0x1fc2('0x6d')](_0x1961fc))[_0x1fc2('0x24')](function(_0x186217){logger[_0x1fc2('0x64')](util[_0x1fc2('0x30')](_0x1fc2('0x6e'),_0x1ee1c3,_0xe785c3,_0x186217[_0x1fc2('0x6f')]));_0x4475e3['bucket']=_0x186217['Bucket'];_0x4475e3[_0x1fc2('0x70')]=_0x186217[_0x1fc2('0x6f')];logger[_0x1fc2('0x64')](util[_0x1fc2('0x30')](_0x1fc2('0x71'),_0x1ee1c3));return startTranscribe(_0x19ac89,_0x525e17,_0x3ee5f9,uuidv4(),_0x5cde00,_0x186217[_0x1fc2('0x6f')]);})[_0x1fc2('0x24')](function(_0x8c7279){logger[_0x1fc2('0x64')](util[_0x1fc2('0x30')]('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0x1ee1c3,_0x8c7279[_0x1fc2('0x72')][_0x1fc2('0x73')]));_0x4475e3[_0x1fc2('0x74')]=_0x8c7279[_0x1fc2('0x72')]['TranscriptionJobName'];_0x4475e3['transcribeStatus']=_0x8c7279[_0x1fc2('0x72')][_0x1fc2('0x75')];return _0x31c415(_0x4475e3);})['catch'](function(_0x4abea1){return _0x5b5056(_0x4abea1);});});}exports[_0x1fc2('0x76')]=function(_0x425ca6,_0x3defa,_0x151ca4){var _0x2a8b61;var _0x2cf0c2;var _0x5699c5;var _0x2ab9bf=require(_0x1fc2('0x4e'));return db[_0x1fc2('0x2a')][_0x1fc2('0x77')]({'where':{'id':_0x425ca6[_0x1fc2('0x45')]['id']}})[_0x1fc2('0x24')](function(_0x46989e){if(_0x46989e){var _0x5e50f9=util[_0x1fc2('0x30')](_0x1fc2('0x51'),_0x46989e[_0x1fc2('0x50')]);if(fs['existsSync'](_0x5e50f9)){cypher=!![];return _0x2ab9bf['decryptFile'](_0x5e50f9,_0x46989e[_0x1fc2('0x50')],config[_0x1fc2('0x60')][_0x1fc2('0x54')])[_0x1fc2('0x24')](function(){return _0x46989e;});}return _0x46989e;}})['then'](function(_0x4bab7d){if(!_0x4bab7d){throw new db['Sequelize'][(_0x1fc2('0x56'))]('Voice\x20Recording\x20not\x20found');}_0x2cf0c2=_0x4bab7d;return db[_0x1fc2('0x78')]['findOne']({'where':{'id':0x1}});})['then'](handleEntityNotFound(_0x3defa,null))[_0x1fc2('0x24')](function(_0x747a0d){if(_0x747a0d){_0x2a8b61=_0x747a0d;if(!_0x2a8b61[_0x1fc2('0x79')]||!_0x2a8b61[_0x1fc2('0x7a')]||!_0x2a8b61[_0x1fc2('0x7b')]||!_0x2a8b61['language']||!_0x2a8b61[_0x1fc2('0x7c')]){throw new db[(_0x1fc2('0x55'))][(_0x1fc2('0x56'))]('Transcribe\x20not\x20configured');}if(_0x425ca6[_0x1fc2('0x4a')]['runSentiment']&&(!_0x2a8b61[_0x1fc2('0x7d')]||!_0x2a8b61[_0x1fc2('0x7e')]||!_0x2a8b61['sentimentRegion']||!_0x2a8b61[_0x1fc2('0x7f')]||!_0x2a8b61[_0x1fc2('0x7c')])){throw new db['Sequelize'][(_0x1fc2('0x56'))](_0x1fc2('0x80'));}return db[_0x1fc2('0x81')][_0x1fc2('0x77')]({'where':{'id':_0x2a8b61['transcribeAccountId']}});}})[_0x1fc2('0x24')](function(_0x3c131b){if(!_0x3c131b){throw new db[(_0x1fc2('0x55'))][(_0x1fc2('0x56'))]('Cloud\x20Provider\x20not\x20available');}if(!_0x3c131b[_0x1fc2('0x82')]||!_0x3c131b[_0x1fc2('0x83')]){throw new db['Sequelize'][(_0x1fc2('0x56'))](_0x1fc2('0x84'));}_0x5699c5=_0x3c131b;return getBucketslist(_0x5699c5[_0x1fc2('0x82')],_0x5699c5['data2'],_0x2a8b61['transcribeRegion']);})[_0x1fc2('0x24')](function(_0x3e6978){if(_0x3e6978&&_0x3e6978[_0x1fc2('0x85')]){var _0x50545f=_[_0x1fc2('0x48')](_0x3e6978[_0x1fc2('0x85')],function(_0x11873b){return _0x11873b['Name']===_0x2a8b61[_0x1fc2('0x7c')];});if(!_0x50545f){logger[_0x1fc2('0x64')](util[_0x1fc2('0x30')](_0x1fc2('0x86'),_0x425ca6[_0x1fc2('0x45')]['id'],_0x2a8b61[_0x1fc2('0x7c')]));return createBucket(_0x5699c5[_0x1fc2('0x82')],_0x5699c5['data2'],_0x2a8b61['transcribeRegion'],_0x2a8b61['bucket']);}logger[_0x1fc2('0x64')](util[_0x1fc2('0x30')](_0x1fc2('0x87'),_0x425ca6['params']['id'],_0x2a8b61[_0x1fc2('0x7c')]));return;}})[_0x1fc2('0x24')](function(_0x494ce5){if(_0x2cf0c2[_0x1fc2('0x88')]===_0x1fc2('0x89')){return transcribe(_0x425ca6[_0x1fc2('0x45')]['id'],_0x5699c5['data1'],_0x5699c5[_0x1fc2('0x83')],_0x2a8b61['transcribeRegion'],_0x2a8b61[_0x1fc2('0x7c')],_0x2cf0c2[_0x1fc2('0x50')],_0x2a8b61[_0x1fc2('0x7f')]);}else{logger[_0x1fc2('0x64')](util['format'](_0x1fc2('0x8a'),_0x425ca6['params']['id']));return{'transcribeStatus':_0x1fc2('0x8b')};}})[_0x1fc2('0x24')](function(_0xad9a71){if(_0xad9a71){_0xad9a71['tempSentiment']=_0x425ca6[_0x1fc2('0x4a')][_0x1fc2('0x8c')];return _0x2cf0c2['updateAttributes'](_0xad9a71);}})[_0x1fc2('0x24')](respondWithResult(_0x3defa,null))[_0x1fc2('0x43')](handleError(_0x3defa,null));};function writeFile(_0xdd8cfe,_0x1220d1){return new Promise(function(_0x389285,_0x4ff745){fs[_0x1fc2('0x8d')](_0x1220d1,_0xdd8cfe,function(_0x30d199,_0x526c40){if(_0x30d199){return _0x4ff745(_0x30d199);}else{return _0x389285(_0x526c40);}});});}exports[_0x1fc2('0x8e')]=function(_0x56173a,_0x32f523,_0x484ad9){return db['VoiceRecording'][_0x1fc2('0x77')]({'where':{'id':_0x56173a['params']['id']}})[_0x1fc2('0x24')](handleEntityNotFound(_0x32f523))[_0x1fc2('0x24')](function(_0x4d1c38){if(_0x4d1c38&&_0x4d1c38['fileText']){var _0x547351=_0x4d1c38[_0x1fc2('0x8f')];var _0x1e5905=config[_0x1fc2('0x90')]+_0x1fc2('0x91')+_0x4d1c38['id']+_0x1fc2('0x92');if(fs['existsSync'](_0x1e5905)){return _0x1e5905;}return writeFile(_0x547351,_0x1e5905)[_0x1fc2('0x24')](function(){return _0x1e5905;});}else{throw new db[(_0x1fc2('0x55'))]['ValidationError'](_0x1fc2('0x93'));}})['then'](function(_0x7cac6c){return _0x32f523['download'](_0x7cac6c);})['catch'](handleError(_0x32f523));};
\ No newline at end of file
+var _0xfa9b=['ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','apply','reject','save','update','then','error','stack','name','send','index','map','VoiceRecording','rawAttributes','fieldName','type','key','model','format','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','sort','where','pick','filter','merge','options','includeAll','findAll','catch','show','params','create','body','find','describe','download','../../components/encryptor','uniqueid','value','%s.cypher','existsSync','decryptFile','secrets','recording','Sequelize','filename','extname','unlink','message','VoiceRecording\x20not\x20found','Not\x20found','downloads','sequelize','MD5','col','token','$and','push','ValidationError','destroy','Entity\x20not\x20found','cancellazione\x20fisica\x20documento\x20%s','isNil','File:\x20\x22','unlinkSync','.cypher','info','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','listBuckets','TranscribeService','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','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','TranscriptionJobName','transcribeStatus','TranscriptionJobStatus','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribe','transcribeAccountId','transcribeRegion','language','Transcribe\x20not\x20configured','runSentiment','sentimentAccountId','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','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','tempSentiment','updateAttributes','writeFile','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','.txt','Transcript\x20not\x20available','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','path','to-csv'];(function(_0xfae23b,_0x2be4ba){var _0x200640=function(_0x4ae258){while(--_0x4ae258){_0xfae23b['push'](_0xfae23b['shift']());}};_0x200640(++_0x2be4ba);}(_0xfa9b,0x1cf));var _0xbfa9=function(_0x4fc4a2,_0x16dff5){_0x4fc4a2=_0x4fc4a2-0x0;var _0x4c9a55=_0xfa9b[_0x4fc4a2];return _0x4c9a55;};'use strict';var emlformat=require(_0xbfa9('0x0'));var rimraf=require(_0xbfa9('0x1'));var zipdir=require(_0xbfa9('0x2'));var jsonpatch=require(_0xbfa9('0x3'));var rp=require(_0xbfa9('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xbfa9('0x5'));var util=require('util');var path=require(_0xbfa9('0x6'));var sox=require('sox');var csv=require(_0xbfa9('0x7'));var ejs=require(_0xbfa9('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xbfa9('0x9'));var squel=require(_0xbfa9('0xa'));var crypto=require(_0xbfa9('0xb'));var jsforce=require(_0xbfa9('0xc'));var deskjs=require(_0xbfa9('0xd'));var toCsv=require(_0xbfa9('0x7'));var querystring=require(_0xbfa9('0xe'));var Papa=require(_0xbfa9('0xf'));var AWS=require('aws-sdk');var uuidv4=require(_0xbfa9('0x10'));var Redis=require(_0xbfa9('0x11'));var authService=require(_0xbfa9('0x12'));var qs=require(_0xbfa9('0x13'));var as=require(_0xbfa9('0x14'));var hardwareService=require(_0xbfa9('0x15'));var logger=require(_0xbfa9('0x16'))(_0xbfa9('0x17'));var utils=require(_0xbfa9('0x18'));var config=require(_0xbfa9('0x19'));var licenseUtil=require(_0xbfa9('0x1a'));var db=require(_0xbfa9('0x1b'))['db'];function respondWithStatusCode(_0x1ec7b7,_0x12d4ca){_0x12d4ca=_0x12d4ca||0xcc;return function(_0x21e698){if(_0x21e698){return _0x1ec7b7[_0xbfa9('0x1c')](_0x12d4ca);}return _0x1ec7b7[_0xbfa9('0x1d')](_0x12d4ca)[_0xbfa9('0x1e')]();};}function respondWithResult(_0x55ed56,_0x281459){_0x281459=_0x281459||0xc8;return function(_0x2628a7){if(_0x2628a7){return _0x55ed56['status'](_0x281459)[_0xbfa9('0x1f')](_0x2628a7);}};}function respondWithFilteredResult(_0x5573ed,_0x491fb5){return function(_0xa98bb5){if(_0xa98bb5){var _0x429fed=typeof _0x491fb5['offset']===_0xbfa9('0x20')&&typeof _0x491fb5[_0xbfa9('0x21')]===_0xbfa9('0x20');var _0xab0e7=_0xa98bb5[_0xbfa9('0x22')];var _0x23ef9a=_0x429fed?0x0:_0x491fb5[_0xbfa9('0x23')];var _0x35d7ab=_0x429fed?_0xa98bb5['count']:_0x491fb5['offset']+_0x491fb5[_0xbfa9('0x21')];var _0x228282;if(_0x35d7ab>=_0xab0e7){_0x35d7ab=_0xab0e7;_0x228282=0xc8;}else{_0x228282=0xce;}_0x5573ed[_0xbfa9('0x1d')](_0x228282);return _0x5573ed['set']('Content-Range',_0x23ef9a+'-'+_0x35d7ab+'/'+_0xab0e7)[_0xbfa9('0x1f')](_0xa98bb5);}return null;};}function patchUpdates(_0x4022f7){return function(_0x8f1a7d){try{jsonpatch[_0xbfa9('0x24')](_0x8f1a7d,_0x4022f7,!![]);}catch(_0x5b73b5){return BPromise[_0xbfa9('0x25')](_0x5b73b5);}return _0x8f1a7d[_0xbfa9('0x26')]();};}function saveUpdates(_0x4e8ba4,_0x42185c){return function(_0x54861e){if(_0x54861e){return _0x54861e[_0xbfa9('0x27')](_0x4e8ba4)[_0xbfa9('0x28')](function(_0x30322b){return _0x30322b;});}return null;};}function removeEntity(_0x475f8e,_0x540def){return function(_0x134aec){if(_0x134aec){return _0x134aec['destroy']()[_0xbfa9('0x28')](function(){_0x475f8e['status'](0xcc)[_0xbfa9('0x1e')]();});}};}function handleEntityNotFound(_0x5874fa,_0x28ce70){return function(_0x5a9e62){if(!_0x5a9e62){_0x5874fa[_0xbfa9('0x1c')](0x194);}return _0x5a9e62;};}function handleError(_0x1c0950,_0x41968b){_0x41968b=_0x41968b||0x1f4;return function(_0xad0c00){logger[_0xbfa9('0x29')](_0xad0c00[_0xbfa9('0x2a')]);if(_0xad0c00['name']){delete _0xad0c00[_0xbfa9('0x2b')];}_0x1c0950[_0xbfa9('0x1d')](_0x41968b)[_0xbfa9('0x2c')](_0xad0c00);};}exports[_0xbfa9('0x2d')]=function(_0x34c817,_0xecc4be){var _0x8b8bce={},_0xa7d71={},_0x2e890f={'count':0x0,'rows':[]};var _0x107cda=_[_0xbfa9('0x2e')](db[_0xbfa9('0x2f')][_0xbfa9('0x30')],function(_0x2b1a3b){return{'name':_0x2b1a3b[_0xbfa9('0x31')],'type':_0x2b1a3b[_0xbfa9('0x32')][_0xbfa9('0x33')]};});_0xa7d71[_0xbfa9('0x34')]=_['differenceBy'](_[_0xbfa9('0x2e')](_0x107cda,_0xbfa9('0x2b')),[_0xbfa9('0x35')]);_0xa7d71[_0xbfa9('0x36')]=_[_0xbfa9('0x37')](_0x34c817['query']);_0xa7d71[_0xbfa9('0x38')]=_[_0xbfa9('0x39')](_0xa7d71[_0xbfa9('0x34')],_0xa7d71[_0xbfa9('0x36')]);_0x8b8bce[_0xbfa9('0x3a')]=_[_0xbfa9('0x39')](_0xa7d71[_0xbfa9('0x34')],qs[_0xbfa9('0x3b')](_0x34c817[_0xbfa9('0x36')][_0xbfa9('0x3b')]));_0x8b8bce['attributes']=_0x8b8bce[_0xbfa9('0x3a')][_0xbfa9('0x3c')]?_0x8b8bce[_0xbfa9('0x3a')]:_0xa7d71[_0xbfa9('0x34')];if(!_0x34c817[_0xbfa9('0x36')][_0xbfa9('0x3d')]('nolimit')){_0x8b8bce[_0xbfa9('0x21')]=qs['limit'](_0x34c817['query'][_0xbfa9('0x21')]);_0x8b8bce['offset']=qs[_0xbfa9('0x23')](_0x34c817[_0xbfa9('0x36')][_0xbfa9('0x23')]);}_0x8b8bce['order']=qs[_0xbfa9('0x3e')](_0x34c817[_0xbfa9('0x36')][_0xbfa9('0x3e')]);_0x8b8bce[_0xbfa9('0x3f')]=qs['filters'](_[_0xbfa9('0x40')](_0x34c817[_0xbfa9('0x36')],_0xa7d71[_0xbfa9('0x38')]),_0x107cda);if(_0x34c817[_0xbfa9('0x36')][_0xbfa9('0x41')]){_0x8b8bce[_0xbfa9('0x3f')]=_['merge'](_0x8b8bce['where'],{'$or':_[_0xbfa9('0x2e')](_0x107cda,function(_0x34c369){if(_0x34c369[_0xbfa9('0x32')]!=='VIRTUAL'){var _0x4c6912={};_0x4c6912[_0x34c369[_0xbfa9('0x2b')]]={'$like':'%'+_0x34c817[_0xbfa9('0x36')]['filter']+'%'};return _0x4c6912;}})});}_0x8b8bce=_[_0xbfa9('0x42')]({},_0x8b8bce,_0x34c817[_0xbfa9('0x43')]);var _0x287d7a={'where':_0x8b8bce[_0xbfa9('0x3f')]};return db[_0xbfa9('0x2f')]['count'](_0x287d7a)[_0xbfa9('0x28')](function(_0x2e8341){_0x2e890f[_0xbfa9('0x22')]=_0x2e8341;if(_0x34c817[_0xbfa9('0x36')][_0xbfa9('0x44')]){_0x8b8bce['include']=[{'all':!![]}];}return db[_0xbfa9('0x2f')][_0xbfa9('0x45')](_0x8b8bce);})[_0xbfa9('0x28')](function(_0x3f66b4){_0x2e890f['rows']=_0x3f66b4;return _0x2e890f;})[_0xbfa9('0x28')](respondWithFilteredResult(_0xecc4be,_0x8b8bce))[_0xbfa9('0x46')](handleError(_0xecc4be,null));};exports[_0xbfa9('0x47')]=function(_0xdee9b1,_0x3c4cf2){var _0x3c767e={'raw':![],'where':{'id':_0xdee9b1[_0xbfa9('0x48')]['id']}},_0x273c8a={};_0x273c8a[_0xbfa9('0x34')]=_[_0xbfa9('0x37')](db['VoiceRecording']['rawAttributes']);_0x273c8a[_0xbfa9('0x36')]=_[_0xbfa9('0x37')](_0xdee9b1['query']);_0x273c8a[_0xbfa9('0x38')]=_['intersection'](_0x273c8a[_0xbfa9('0x34')],_0x273c8a['query']);_0x3c767e[_0xbfa9('0x3a')]=_[_0xbfa9('0x39')](_0x273c8a[_0xbfa9('0x34')],qs['fields'](_0xdee9b1['query'][_0xbfa9('0x3b')]));_0x3c767e[_0xbfa9('0x3a')]=_0x3c767e[_0xbfa9('0x3a')]['length']?_0x3c767e[_0xbfa9('0x3a')]:_0x273c8a[_0xbfa9('0x34')];if(_0xdee9b1[_0xbfa9('0x36')][_0xbfa9('0x44')]){_0x3c767e['include']=[{'all':!![]}];}_0x3c767e=_[_0xbfa9('0x42')]({},_0x3c767e,_0xdee9b1[_0xbfa9('0x43')]);return db[_0xbfa9('0x2f')]['find'](_0x3c767e)['then'](handleEntityNotFound(_0x3c4cf2,null))[_0xbfa9('0x28')](respondWithResult(_0x3c4cf2,null))[_0xbfa9('0x46')](handleError(_0x3c4cf2,null));};exports[_0xbfa9('0x49')]=function(_0x32c92c,_0xb0d9ab){return db[_0xbfa9('0x2f')][_0xbfa9('0x49')](_0x32c92c['body'],{})[_0xbfa9('0x28')](respondWithResult(_0xb0d9ab,0xc9))[_0xbfa9('0x46')](handleError(_0xb0d9ab,null));};exports[_0xbfa9('0x27')]=function(_0x44bfb1,_0x5280e0){if(_0x44bfb1[_0xbfa9('0x4a')]['id']){delete _0x44bfb1[_0xbfa9('0x4a')]['id'];}return db[_0xbfa9('0x2f')][_0xbfa9('0x4b')]({'where':{'id':_0x44bfb1[_0xbfa9('0x48')]['id']}})['then'](handleEntityNotFound(_0x5280e0,null))[_0xbfa9('0x28')](saveUpdates(_0x44bfb1['body'],null))[_0xbfa9('0x28')](respondWithResult(_0x5280e0,null))[_0xbfa9('0x46')](handleError(_0x5280e0,null));};exports[_0xbfa9('0x4c')]=function(_0x4dbf54,_0x192662){return db['VoiceRecording'][_0xbfa9('0x4c')]()['then'](respondWithResult(_0x192662,null))[_0xbfa9('0x46')](handleError(_0x192662,null));};exports[_0xbfa9('0x4d')]=function(_0x2b2048,_0x3ce28f,_0x10b8af){var _0x1b3369=require(_0xbfa9('0x4e'));var _0x302bd8=![];var _0x4b8839={};if(_0x2b2048['query'][_0xbfa9('0x32')]&&_0x2b2048[_0xbfa9('0x36')][_0xbfa9('0x32')]===_0xbfa9('0x4f')){_0x4b8839['uniqueid']=_0x2b2048[_0xbfa9('0x48')]['id'];}else{_0x4b8839['id']=_0x2b2048['params']['id'];}return db['VoiceRecording'][_0xbfa9('0x4b')]({'where':_0x4b8839,'attributes':['id',_0xbfa9('0x50')],'raw':!![]})[_0xbfa9('0x28')](handleEntityNotFound(_0x3ce28f,null))[_0xbfa9('0x28')](function(_0x51fd65){if(_0x51fd65){var _0x2848f8=_0x51fd65['value'];var _0x31bc2e=util[_0xbfa9('0x35')](_0xbfa9('0x51'),_0x2848f8);if(fs[_0xbfa9('0x52')](_0x31bc2e)){_0x302bd8=!![];return _0x1b3369[_0xbfa9('0x53')](_0x31bc2e,_0x2848f8,config[_0xbfa9('0x54')][_0xbfa9('0x55')])[_0xbfa9('0x28')](function(){return _0x51fd65;});}return _0x51fd65;}})['then'](function(_0x500953){if(_0x500953){var _0x3cc316=_0x500953[_0xbfa9('0x50')];if(!fs[_0xbfa9('0x52')](_0x3cc316)){throw new db[(_0xbfa9('0x56'))]['ValidationError']('VoiceRecording\x20not\x20found');}if(_0x500953[_0xbfa9('0x57')]){return _0x3ce28f['download'](_0x3cc316,_0x500953[_0xbfa9('0x57')]+path[_0xbfa9('0x58')](_0x3cc316),function(){if(_0x302bd8){fs['unlink'](_0x3cc316);}});}else{return _0x3ce28f[_0xbfa9('0x4d')](_0x3cc316,function(_0x47e9a6){if(_0x302bd8){fs[_0xbfa9('0x59')](_0x3cc316);}});}}})['catch'](function(_0xd0f05){if(_0xd0f05[_0xbfa9('0x5a')]===_0xbfa9('0x5b')){_0x3ce28f[_0xbfa9('0x1d')](0x194)['send'](_0xbfa9('0x5c'));}else{return handleError(_0x3ce28f,null);}});};exports[_0xbfa9('0x5d')]=function(_0x5d1cbe,_0x23a4f2,_0x4afa00){var _0x1d70f4=require(_0xbfa9('0x4e'));var _0x5f3914=![];var _0x145d86={'$and':[db[_0xbfa9('0x5e')]['where'](db[_0xbfa9('0x5e')]['fn'](_0xbfa9('0x5f'),db[_0xbfa9('0x5e')][_0xbfa9('0x60')](_0xbfa9('0x4f'))),_0x5d1cbe[_0xbfa9('0x36')][_0xbfa9('0x61')])]};if(_0x5d1cbe[_0xbfa9('0x36')][_0xbfa9('0x32')]&&_0x5d1cbe[_0xbfa9('0x36')][_0xbfa9('0x32')]==='uniqueid'){_0x145d86[_0xbfa9('0x62')][_0xbfa9('0x63')]({'uniqueid':_0x5d1cbe[_0xbfa9('0x48')]['id']});}else{_0x145d86[_0xbfa9('0x62')]['push']({'id':_0x5d1cbe[_0xbfa9('0x48')]['id']});}return db[_0xbfa9('0x2f')][_0xbfa9('0x4b')]({'where':_0x145d86,'attributes':['id',_0xbfa9('0x50')],'raw':!![]})[_0xbfa9('0x28')](handleEntityNotFound(_0x23a4f2,null))[_0xbfa9('0x28')](function(_0x256ebd){if(_0x256ebd){var _0x57a09b=util[_0xbfa9('0x35')](_0xbfa9('0x51'),_0x256ebd[_0xbfa9('0x50')]);if(fs[_0xbfa9('0x52')](_0x57a09b)){_0x5f3914=!![];return _0x1d70f4[_0xbfa9('0x53')](_0x57a09b,_0x256ebd[_0xbfa9('0x50')],config[_0xbfa9('0x54')]['recording'])[_0xbfa9('0x28')](function(){return _0x256ebd;});}return _0x256ebd;}})[_0xbfa9('0x28')](function(_0x3edf25){if(_0x3edf25){if(!fs[_0xbfa9('0x52')](_0x3edf25[_0xbfa9('0x50')])){throw new db['Sequelize'][(_0xbfa9('0x64'))](_0xbfa9('0x5b'));}if(_0x3edf25[_0xbfa9('0x57')]){return _0x23a4f2[_0xbfa9('0x4d')](_0x3edf25[_0xbfa9('0x50')],_0x3edf25[_0xbfa9('0x57')]+path[_0xbfa9('0x58')](_0x3edf25[_0xbfa9('0x50')]),function(){if(_0x5f3914){fs[_0xbfa9('0x59')](_0x3edf25['value']);}});}else{return _0x23a4f2[_0xbfa9('0x4d')](_0x3edf25[_0xbfa9('0x50')],function(_0x41cb92){if(_0x5f3914){fs[_0xbfa9('0x59')](_0x3edf25[_0xbfa9('0x50')]);}});}}})[_0xbfa9('0x46')](handleError(_0x23a4f2,null));};exports[_0xbfa9('0x65')]=function(_0x4bfb20,_0x3d8cec){return db[_0xbfa9('0x2f')][_0xbfa9('0x4b')]({'where':{'id':_0x4bfb20[_0xbfa9('0x48')]['id']}})[_0xbfa9('0x28')](function(_0x121efe){if(_['isNil'](_0x121efe)){throw new ReferenceError(_0xbfa9('0x66'));}return _0x121efe;})[_0xbfa9('0x28')](function(_0x33e287){var _0x32a530=_0x33e287['value'];logger['info'](_0xbfa9('0x67'),_0x32a530);if(!_[_0xbfa9('0x68')](_0x33e287['value'])&&fs['existsSync'](_0x32a530)){logger['info'](_0xbfa9('0x69')+_0x32a530+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs[_0xbfa9('0x6a')](_0x32a530);}_0x32a530=_0x32a530+_0xbfa9('0x6b');if(!_[_0xbfa9('0x68')](_0x33e287['value'])&&fs['existsSync'](_0x32a530)){logger[_0xbfa9('0x6c')](_0xbfa9('0x69')+_0x32a530+_0xbfa9('0x6d'));fs['unlinkSync'](_0x32a530);}return _0x33e287;})[_0xbfa9('0x28')](function(_0x123c33){if(!_0x123c33)throw new InternalError();return _0x123c33[_0xbfa9('0x65')]();})[_0xbfa9('0x28')](function(){_0x3d8cec[_0xbfa9('0x1d')](0xcc)[_0xbfa9('0x1e')]();})['catch'](handleError(_0x3d8cec,null));};function getBucketslist(_0x1b4f43,_0x377534,_0x23f521){return new Promise(function(_0x2e9374,_0x2fd388){var _0x2dfa54=new AWS['S3']({'accessKeyId':_0x377534,'secretAccessKey':_0x1b4f43,'region':_0x23f521});_0x2dfa54[_0xbfa9('0x6e')]({},function(_0x54428e,_0x2e11ff){if(_0x54428e){return _0x2fd388(_0x54428e);}else{return _0x2e9374(_0x2e11ff);}});});}function createBucket(_0xb3167d,_0x59b333,_0x4da6c4,_0xcb9d){return new Promise(function(_0x2222f2,_0x4ff38d){var _0x2d2dae=new AWS['S3']({'accessKeyId':_0x59b333,'secretAccessKey':_0xb3167d,'region':_0x4da6c4});_0x2d2dae['createBucket']({'Bucket':_0xcb9d},function(_0x37a502,_0x2e0a7d){if(_0x37a502){return _0x4ff38d(_0x37a502);}else{return _0x2222f2(_0x2e0a7d);}});});}function uploadFile(_0x3b84cc,_0x2eb317,_0x86e124,_0x1135c2,_0x1569e4,_0x43b77a){return new Promise(function(_0x1da84a,_0x1606d1){var _0x37b976=new AWS['S3']({'accessKeyId':_0x2eb317,'secretAccessKey':_0x3b84cc,'region':_0x86e124});_0x37b976['upload']({'Bucket':_0x1135c2,'Key':_0x1569e4,'Body':_0x43b77a},function(_0x1de8a7,_0x5a7d6d){if(_0x1de8a7){return _0x1606d1(_0x1de8a7);}else{return _0x1da84a(_0x5a7d6d);}});});}function startTranscribe(_0x4f6d50,_0x57c4bb,_0x236d38,_0x274933,_0x42e519,_0x1de62a){return new Promise(function(_0x3203fa,_0x26f252){var _0x95457e=new AWS[(_0xbfa9('0x6f'))]({'accessKeyId':_0x57c4bb,'secretAccessKey':_0x4f6d50,'region':_0x236d38});_0x95457e['startTranscriptionJob']({'TranscriptionJobName':_0x274933,'LanguageCode':_0x42e519,'Media':{'MediaFileUri':_0x1de62a}},function(_0xae7717,_0x407dc3){if(_0xae7717){return _0x26f252(_0xae7717);}else{return _0x3203fa(_0x407dc3);}});});}function transcribe(_0x37cce9,_0x189791,_0x1767be,_0x440c6a,_0x5b78a4,_0x513d1e,_0x1a4147){return new Promise(function(_0x98639f,_0x461714){var _0x5d0c7d={};logger['info'](util['format'](_0xbfa9('0x70'),_0x37cce9,_0x5b78a4));return uploadFile(_0x189791,_0x1767be,_0x440c6a,_0x5b78a4,path['basename'](_0x513d1e),fs[_0xbfa9('0x71')](_0x513d1e))[_0xbfa9('0x28')](function(_0x4de757){logger[_0xbfa9('0x6c')](util[_0xbfa9('0x35')](_0xbfa9('0x72'),_0x37cce9,_0x5b78a4,_0x4de757[_0xbfa9('0x73')]));_0x5d0c7d[_0xbfa9('0x74')]=_0x4de757[_0xbfa9('0x75')];_0x5d0c7d[_0xbfa9('0x76')]=_0x4de757[_0xbfa9('0x73')];logger[_0xbfa9('0x6c')](util['format'](_0xbfa9('0x77'),_0x37cce9));return startTranscribe(_0x189791,_0x1767be,_0x440c6a,uuidv4(),_0x1a4147,_0x4de757['Location']);})['then'](function(_0x269529){logger['info'](util['format'](_0xbfa9('0x78'),_0x37cce9,_0x269529['TranscriptionJob']['TranscriptionJobName']));_0x5d0c7d['transcribeName']=_0x269529['TranscriptionJob'][_0xbfa9('0x79')];_0x5d0c7d[_0xbfa9('0x7a')]=_0x269529['TranscriptionJob'][_0xbfa9('0x7b')];return _0x98639f(_0x5d0c7d);})[_0xbfa9('0x46')](function(_0x905660){return _0x461714(_0x905660);});});}exports[_0xbfa9('0x7c')]=function(_0x316197,_0x300e1e,_0x2493a5){var _0x51dfca;var _0x4121c5;var _0x55e9f3;var _0x1c7d54=require(_0xbfa9('0x4e'));return db[_0xbfa9('0x2f')][_0xbfa9('0x7d')]({'where':{'id':_0x316197[_0xbfa9('0x48')]['id']}})[_0xbfa9('0x28')](function(_0x529ce5){if(_0x529ce5){var _0x58e948=util[_0xbfa9('0x35')]('%s.cypher',_0x529ce5['value']);if(fs[_0xbfa9('0x52')](_0x58e948)){cypher=!![];return _0x1c7d54[_0xbfa9('0x53')](_0x58e948,_0x529ce5[_0xbfa9('0x50')],config['secrets']['recording'])[_0xbfa9('0x28')](function(){return _0x529ce5;});}return _0x529ce5;}})[_0xbfa9('0x28')](function(_0x1364ef){if(!_0x1364ef){throw new db[(_0xbfa9('0x56'))][(_0xbfa9('0x64'))](_0xbfa9('0x7e'));}_0x4121c5=_0x1364ef;return db[_0xbfa9('0x7f')][_0xbfa9('0x7d')]({'where':{'id':0x1}});})[_0xbfa9('0x28')](handleEntityNotFound(_0x300e1e,null))['then'](function(_0x3a3156){if(_0x3a3156){_0x51dfca=_0x3a3156;if(!_0x51dfca[_0xbfa9('0x80')]||!_0x51dfca[_0xbfa9('0x81')]||!_0x51dfca[_0xbfa9('0x82')]||!_0x51dfca[_0xbfa9('0x83')]||!_0x51dfca[_0xbfa9('0x74')]){throw new db[(_0xbfa9('0x56'))][(_0xbfa9('0x64'))](_0xbfa9('0x84'));}if(_0x316197[_0xbfa9('0x4a')][_0xbfa9('0x85')]&&(!_0x51dfca['sentiment']||!_0x51dfca[_0xbfa9('0x86')]||!_0x51dfca['sentimentRegion']||!_0x51dfca[_0xbfa9('0x83')]||!_0x51dfca[_0xbfa9('0x74')])){throw new db[(_0xbfa9('0x56'))]['ValidationError'](_0xbfa9('0x87'));}return db[_0xbfa9('0x88')][_0xbfa9('0x7d')]({'where':{'id':_0x51dfca[_0xbfa9('0x81')]}});}})['then'](function(_0x7ec95e){if(!_0x7ec95e){throw new db['Sequelize'][(_0xbfa9('0x64'))](_0xbfa9('0x89'));}if(!_0x7ec95e[_0xbfa9('0x8a')]||!_0x7ec95e['data2']){throw new db[(_0xbfa9('0x56'))][(_0xbfa9('0x64'))](_0xbfa9('0x8b'));}_0x55e9f3=_0x7ec95e;return getBucketslist(_0x55e9f3[_0xbfa9('0x8a')],_0x55e9f3[_0xbfa9('0x8c')],_0x51dfca[_0xbfa9('0x82')]);})[_0xbfa9('0x28')](function(_0x30275c){if(_0x30275c&&_0x30275c[_0xbfa9('0x8d')]){var _0x444e11=_[_0xbfa9('0x4b')](_0x30275c['Buckets'],function(_0x3f2e7c){return _0x3f2e7c[_0xbfa9('0x8e')]===_0x51dfca[_0xbfa9('0x74')];});if(!_0x444e11){logger[_0xbfa9('0x6c')](util[_0xbfa9('0x35')](_0xbfa9('0x8f'),_0x316197[_0xbfa9('0x48')]['id'],_0x51dfca['bucket']));return createBucket(_0x55e9f3[_0xbfa9('0x8a')],_0x55e9f3[_0xbfa9('0x8c')],_0x51dfca['transcribeRegion'],_0x51dfca['bucket']);}logger['info'](util[_0xbfa9('0x35')](_0xbfa9('0x90'),_0x316197[_0xbfa9('0x48')]['id'],_0x51dfca[_0xbfa9('0x74')]));return;}})[_0xbfa9('0x28')](function(_0x42c256){if(_0x4121c5[_0xbfa9('0x7a')]===_0xbfa9('0x91')){return transcribe(_0x316197[_0xbfa9('0x48')]['id'],_0x55e9f3[_0xbfa9('0x8a')],_0x55e9f3[_0xbfa9('0x8c')],_0x51dfca[_0xbfa9('0x82')],_0x51dfca[_0xbfa9('0x74')],_0x4121c5[_0xbfa9('0x50')],_0x51dfca[_0xbfa9('0x83')]);}else{logger[_0xbfa9('0x6c')](util[_0xbfa9('0x35')](_0xbfa9('0x92'),_0x316197[_0xbfa9('0x48')]['id']));return{'transcribeStatus':_0xbfa9('0x93')};}})[_0xbfa9('0x28')](function(_0x1b504d){if(_0x1b504d){_0x1b504d[_0xbfa9('0x94')]=_0x316197['body'][_0xbfa9('0x85')];return _0x4121c5[_0xbfa9('0x95')](_0x1b504d);}})[_0xbfa9('0x28')](respondWithResult(_0x300e1e,null))[_0xbfa9('0x46')](handleError(_0x300e1e,null));};function writeFile(_0xc830d7,_0x4377c7){return new Promise(function(_0x573c79,_0x4b71d4){fs[_0xbfa9('0x96')](_0x4377c7,_0xc830d7,function(_0x1d0505,_0x5c04c6){if(_0x1d0505){return _0x4b71d4(_0x1d0505);}else{return _0x573c79(_0x5c04c6);}});});}exports[_0xbfa9('0x97')]=function(_0x97d29,_0xef6207,_0xfe3898){return db[_0xbfa9('0x2f')][_0xbfa9('0x7d')]({'where':{'id':_0x97d29['params']['id']}})['then'](handleEntityNotFound(_0xef6207))['then'](function(_0x1b7508){if(_0x1b7508&&_0x1b7508[_0xbfa9('0x98')]){var _0xc9325a=_0x1b7508[_0xbfa9('0x98')];var _0x1c9316=config[_0xbfa9('0x99')]+_0xbfa9('0x9a')+_0x1b7508['id']+_0xbfa9('0x9b');if(fs[_0xbfa9('0x52')](_0x1c9316)){return _0x1c9316;}return writeFile(_0xc9325a,_0x1c9316)[_0xbfa9('0x28')](function(){return _0x1c9316;});}else{throw new db[(_0xbfa9('0x56'))][(_0xbfa9('0x64'))](_0xbfa9('0x9c'));}})[_0xbfa9('0x28')](function(_0x509d10){return _0xef6207[_0xbfa9('0x4d')](_0x509d10);})['catch'](handleError(_0xef6207));};
\ No newline at end of file