Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index 4b51886..cc8914d 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 _0xb419=['util','path','sox','to-csv','fs-extra','crypto','jsforce','desk.js','papaparse','aws-sdk','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/license/util','../../mysqldb','sendStatus','end','json','offset','undefined','count','limit','Content-Range','apply','reject','save','then','destroy','status','stack','name','send','index','map','VoiceRecording','rawAttributes','fieldName','type','key','model','format','keys','query','filters','intersection','attributes','fields','nolimit','order','sort','where','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','length','merge','create','body','update','describe','download','../../components/encryptor','uniqueid','find','value','%s.cypher','existsSync','decryptFile','secrets','recording','Sequelize','VoiceRecording\x20not\x20found','filename','extname','unlink','message','Not\x20found','downloads','sequelize','token','$and','push','ValidationError','isNil','info','cancellazione\x20fisica\x20documento\x20%s','unlinkSync','.cypher','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','listBuckets','createBucket','upload','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','basename','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','Bucket','location','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','TranscriptionJobName','transcribeName','TranscriptionJob','transcribeStatus','runTranscribe','Voice\x20Recording\x20not\x20found','Setting','findOne','transcribe','transcribeAccountId','transcribeRegion','bucket','Transcribe\x20not\x20configured','sentiment','sentimentAccountId','sentimentRegion','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','data1','data2','Buckets','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','NEW','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','runSentiment','updateAttributes','writeFile','downloadTranscribe','root','/server/files/transcribes/transcribe_','.txt','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache'];(function(_0x3156aa,_0x407b77){var _0x2333b3=function(_0x30e1e8){while(--_0x30e1e8){_0x3156aa['push'](_0x3156aa['shift']());}};_0x2333b3(++_0x407b77);}(_0xb419,0x93));var _0x9b41=function(_0x8efe57,_0x272d80){_0x8efe57=_0x8efe57-0x0;var _0x3c8735=_0xb419[_0x8efe57];return _0x3c8735;};'use strict';var emlformat=require(_0x9b41('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x9b41('0x1'));var jsonpatch=require(_0x9b41('0x2'));var rp=require(_0x9b41('0x3'));var moment=require('moment');var BPromise=require(_0x9b41('0x4'));var Mustache=require(_0x9b41('0x5'));var util=require(_0x9b41('0x6'));var path=require(_0x9b41('0x7'));var sox=require(_0x9b41('0x8'));var csv=require(_0x9b41('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9b41('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x9b41('0xb'));var jsforce=require(_0x9b41('0xc'));var deskjs=require(_0x9b41('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x9b41('0xe'));var AWS=require(_0x9b41('0xf'));var uuidv4=require(_0x9b41('0x10'));var Redis=require(_0x9b41('0x11'));var authService=require(_0x9b41('0x12'));var qs=require(_0x9b41('0x13'));var as=require(_0x9b41('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9b41('0x15'))(_0x9b41('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x9b41('0x17'));var db=require(_0x9b41('0x18'))['db'];function respondWithStatusCode(_0x428cc5,_0x1cf5cb){_0x1cf5cb=_0x1cf5cb||0xcc;return function(_0x8230e8){if(_0x8230e8){return _0x428cc5[_0x9b41('0x19')](_0x1cf5cb);}return _0x428cc5['status'](_0x1cf5cb)[_0x9b41('0x1a')]();};}function respondWithResult(_0xc0e611,_0x115ef0){_0x115ef0=_0x115ef0||0xc8;return function(_0x210edd){if(_0x210edd){return _0xc0e611['status'](_0x115ef0)[_0x9b41('0x1b')](_0x210edd);}};}function respondWithFilteredResult(_0x184556,_0x2f857b){return function(_0x2cca07){if(_0x2cca07){var _0x48626e=typeof _0x2f857b[_0x9b41('0x1c')]===_0x9b41('0x1d')&&typeof _0x2f857b['limit']===_0x9b41('0x1d');var _0x3a94f0=_0x2cca07['count'];var _0x287a41=_0x48626e?0x0:_0x2f857b[_0x9b41('0x1c')];var _0x6a798e=_0x48626e?_0x2cca07[_0x9b41('0x1e')]:_0x2f857b[_0x9b41('0x1c')]+_0x2f857b[_0x9b41('0x1f')];var _0x1ab436;if(_0x6a798e>=_0x3a94f0){_0x6a798e=_0x3a94f0;_0x1ab436=0xc8;}else{_0x1ab436=0xce;}_0x184556['status'](_0x1ab436);return _0x184556['set'](_0x9b41('0x20'),_0x287a41+'-'+_0x6a798e+'/'+_0x3a94f0)[_0x9b41('0x1b')](_0x2cca07);}return null;};}function patchUpdates(_0x2ccd45){return function(_0x36130b){try{jsonpatch[_0x9b41('0x21')](_0x36130b,_0x2ccd45,!![]);}catch(_0x100675){return BPromise[_0x9b41('0x22')](_0x100675);}return _0x36130b[_0x9b41('0x23')]();};}function saveUpdates(_0x5a3dfe,_0x3b831d){return function(_0x294372){if(_0x294372){return _0x294372['update'](_0x5a3dfe)[_0x9b41('0x24')](function(_0x26735a){return _0x26735a;});}return null;};}function removeEntity(_0xa8262,_0x3b15b4){return function(_0x317825){if(_0x317825){return _0x317825[_0x9b41('0x25')]()[_0x9b41('0x24')](function(){_0xa8262[_0x9b41('0x26')](0xcc)[_0x9b41('0x1a')]();});}};}function handleEntityNotFound(_0x235af7,_0x4d4a83){return function(_0x5060d6){if(!_0x5060d6){_0x235af7['sendStatus'](0x194);}return _0x5060d6;};}function handleError(_0x10086b,_0x278ed5){_0x278ed5=_0x278ed5||0x1f4;return function(_0x584669){logger['error'](_0x584669[_0x9b41('0x27')]);if(_0x584669[_0x9b41('0x28')]){delete _0x584669['name'];}_0x10086b[_0x9b41('0x26')](_0x278ed5)[_0x9b41('0x29')](_0x584669);};}exports[_0x9b41('0x2a')]=function(_0xd5a163,_0x124466){var _0x16f0cd={},_0x2b814f={},_0x1d0ac9={'count':0x0,'rows':[]};var _0x59acd7=_[_0x9b41('0x2b')](db[_0x9b41('0x2c')][_0x9b41('0x2d')],function(_0x9c536){return{'name':_0x9c536[_0x9b41('0x2e')],'type':_0x9c536[_0x9b41('0x2f')][_0x9b41('0x30')]};});_0x2b814f[_0x9b41('0x31')]=_['differenceBy'](_[_0x9b41('0x2b')](_0x59acd7,_0x9b41('0x28')),[_0x9b41('0x32')]);_0x2b814f['query']=_[_0x9b41('0x33')](_0xd5a163[_0x9b41('0x34')]);_0x2b814f[_0x9b41('0x35')]=_[_0x9b41('0x36')](_0x2b814f['model'],_0x2b814f[_0x9b41('0x34')]);_0x16f0cd[_0x9b41('0x37')]=_['intersection'](_0x2b814f[_0x9b41('0x31')],qs[_0x9b41('0x38')](_0xd5a163[_0x9b41('0x34')]['fields']));_0x16f0cd[_0x9b41('0x37')]=_0x16f0cd[_0x9b41('0x37')]['length']?_0x16f0cd[_0x9b41('0x37')]:_0x2b814f[_0x9b41('0x31')];if(!_0xd5a163[_0x9b41('0x34')]['hasOwnProperty'](_0x9b41('0x39'))){_0x16f0cd[_0x9b41('0x1f')]=qs[_0x9b41('0x1f')](_0xd5a163[_0x9b41('0x34')][_0x9b41('0x1f')]);_0x16f0cd[_0x9b41('0x1c')]=qs[_0x9b41('0x1c')](_0xd5a163[_0x9b41('0x34')][_0x9b41('0x1c')]);}_0x16f0cd[_0x9b41('0x3a')]=qs[_0x9b41('0x3b')](_0xd5a163[_0x9b41('0x34')][_0x9b41('0x3b')]);_0x16f0cd[_0x9b41('0x3c')]=qs[_0x9b41('0x35')](_['pick'](_0xd5a163[_0x9b41('0x34')],_0x2b814f['filters']),_0x59acd7);if(_0xd5a163[_0x9b41('0x34')]['filter']){_0x16f0cd[_0x9b41('0x3c')]=_['merge'](_0x16f0cd[_0x9b41('0x3c')],{'$or':_[_0x9b41('0x2b')](_0x59acd7,function(_0xd22696){if(_0xd22696[_0x9b41('0x2f')]!==_0x9b41('0x3d')){var _0x17562a={};_0x17562a[_0xd22696[_0x9b41('0x28')]]={'$like':'%'+_0xd5a163[_0x9b41('0x34')][_0x9b41('0x3e')]+'%'};return _0x17562a;}})});}_0x16f0cd=_['merge']({},_0x16f0cd,_0xd5a163[_0x9b41('0x3f')]);var _0x285375={'where':_0x16f0cd[_0x9b41('0x3c')]};return db['VoiceRecording'][_0x9b41('0x1e')](_0x285375)['then'](function(_0x190030){_0x1d0ac9['count']=_0x190030;if(_0xd5a163[_0x9b41('0x34')][_0x9b41('0x40')]){_0x16f0cd[_0x9b41('0x41')]=[{'all':!![]}];}return db[_0x9b41('0x2c')][_0x9b41('0x42')](_0x16f0cd);})[_0x9b41('0x24')](function(_0x4d8e2c){_0x1d0ac9[_0x9b41('0x43')]=_0x4d8e2c;return _0x1d0ac9;})[_0x9b41('0x24')](respondWithFilteredResult(_0x124466,_0x16f0cd))[_0x9b41('0x44')](handleError(_0x124466,null));};exports[_0x9b41('0x45')]=function(_0x34fb54,_0x41bbde){var _0xfac657={'raw':![],'where':{'id':_0x34fb54[_0x9b41('0x46')]['id']}},_0x262705={};_0x262705[_0x9b41('0x31')]=_[_0x9b41('0x33')](db[_0x9b41('0x2c')][_0x9b41('0x2d')]);_0x262705['query']=_[_0x9b41('0x33')](_0x34fb54[_0x9b41('0x34')]);_0x262705['filters']=_[_0x9b41('0x36')](_0x262705[_0x9b41('0x31')],_0x262705[_0x9b41('0x34')]);_0xfac657['attributes']=_['intersection'](_0x262705[_0x9b41('0x31')],qs[_0x9b41('0x38')](_0x34fb54[_0x9b41('0x34')][_0x9b41('0x38')]));_0xfac657[_0x9b41('0x37')]=_0xfac657[_0x9b41('0x37')][_0x9b41('0x47')]?_0xfac657[_0x9b41('0x37')]:_0x262705['model'];if(_0x34fb54[_0x9b41('0x34')][_0x9b41('0x40')]){_0xfac657[_0x9b41('0x41')]=[{'all':!![]}];}_0xfac657=_[_0x9b41('0x48')]({},_0xfac657,_0x34fb54[_0x9b41('0x3f')]);return db[_0x9b41('0x2c')]['find'](_0xfac657)[_0x9b41('0x24')](handleEntityNotFound(_0x41bbde,null))[_0x9b41('0x24')](respondWithResult(_0x41bbde,null))[_0x9b41('0x44')](handleError(_0x41bbde,null));};exports[_0x9b41('0x49')]=function(_0x50887d,_0x4494db){return db[_0x9b41('0x2c')][_0x9b41('0x49')](_0x50887d[_0x9b41('0x4a')],{})['then'](respondWithResult(_0x4494db,0xc9))[_0x9b41('0x44')](handleError(_0x4494db,null));};exports[_0x9b41('0x4b')]=function(_0x371157,_0x589aef){if(_0x371157['body']['id']){delete _0x371157[_0x9b41('0x4a')]['id'];}return db[_0x9b41('0x2c')]['find']({'where':{'id':_0x371157[_0x9b41('0x46')]['id']}})[_0x9b41('0x24')](handleEntityNotFound(_0x589aef,null))[_0x9b41('0x24')](saveUpdates(_0x371157[_0x9b41('0x4a')],null))[_0x9b41('0x24')](respondWithResult(_0x589aef,null))['catch'](handleError(_0x589aef,null));};exports['describe']=function(_0x1ba25c,_0x1022a){return db['VoiceRecording'][_0x9b41('0x4c')]()[_0x9b41('0x24')](respondWithResult(_0x1022a,null))[_0x9b41('0x44')](handleError(_0x1022a,null));};exports[_0x9b41('0x4d')]=function(_0x1ace47,_0x1a388e,_0x57b839){var _0x3c076f=require(_0x9b41('0x4e'));var _0x33ad6d=![];var _0x5a0841={};if(_0x1ace47[_0x9b41('0x34')][_0x9b41('0x2f')]&&_0x1ace47[_0x9b41('0x34')][_0x9b41('0x2f')]===_0x9b41('0x4f')){_0x5a0841['uniqueid']=_0x1ace47[_0x9b41('0x46')]['id'];}else{_0x5a0841['id']=_0x1ace47['params']['id'];}return db[_0x9b41('0x2c')][_0x9b41('0x50')]({'where':_0x5a0841,'attributes':['id',_0x9b41('0x51')],'raw':!![]})['then'](handleEntityNotFound(_0x1a388e,null))[_0x9b41('0x24')](function(_0x4e3118){if(_0x4e3118){var _0x321809=_0x4e3118['value'];var _0x25cac6=util[_0x9b41('0x32')](_0x9b41('0x52'),_0x321809);if(fs[_0x9b41('0x53')](_0x25cac6)){_0x33ad6d=!![];return _0x3c076f[_0x9b41('0x54')](_0x25cac6,_0x321809,config[_0x9b41('0x55')][_0x9b41('0x56')])[_0x9b41('0x24')](function(){return _0x4e3118;});}return _0x4e3118;}})[_0x9b41('0x24')](function(_0x372a8d){if(_0x372a8d){var _0x528b9e=_0x372a8d[_0x9b41('0x51')];if(!fs[_0x9b41('0x53')](_0x528b9e)){throw new db[(_0x9b41('0x57'))]['ValidationError'](_0x9b41('0x58'));}if(_0x372a8d[_0x9b41('0x59')]){return _0x1a388e[_0x9b41('0x4d')](_0x528b9e,_0x372a8d[_0x9b41('0x59')]+path[_0x9b41('0x5a')](_0x528b9e),function(){if(_0x33ad6d){fs[_0x9b41('0x5b')](_0x528b9e);}});}else{return _0x1a388e[_0x9b41('0x4d')](_0x528b9e,function(_0xad124d){if(_0x33ad6d){fs['unlink'](_0x528b9e);}});}}})[_0x9b41('0x44')](function(_0x2f453f){if(_0x2f453f[_0x9b41('0x5c')]===_0x9b41('0x58')){_0x1a388e[_0x9b41('0x26')](0x194)[_0x9b41('0x29')](_0x9b41('0x5d'));}else{return handleError(_0x1a388e,null);}});};exports[_0x9b41('0x5e')]=function(_0x36c2b1,_0x3320a5,_0x1d1ce5){var _0x10fbb2=require('../../components/encryptor');var _0x332a2e=![];var _0x5eb5dd={'$and':[db[_0x9b41('0x5f')]['where'](db[_0x9b41('0x5f')]['fn']('MD5',db[_0x9b41('0x5f')]['col'](_0x9b41('0x4f'))),_0x36c2b1[_0x9b41('0x34')][_0x9b41('0x60')])]};if(_0x36c2b1['query'][_0x9b41('0x2f')]&&_0x36c2b1[_0x9b41('0x34')][_0x9b41('0x2f')]==='uniqueid'){_0x5eb5dd[_0x9b41('0x61')][_0x9b41('0x62')]({'uniqueid':_0x36c2b1[_0x9b41('0x46')]['id']});}else{_0x5eb5dd[_0x9b41('0x61')][_0x9b41('0x62')]({'id':_0x36c2b1[_0x9b41('0x46')]['id']});}return db[_0x9b41('0x2c')][_0x9b41('0x50')]({'where':_0x5eb5dd,'attributes':['id',_0x9b41('0x51')],'raw':!![]})['then'](handleEntityNotFound(_0x3320a5,null))['then'](function(_0x2dcddc){if(_0x2dcddc){var _0x392a4a=util[_0x9b41('0x32')]('%s.cypher',_0x2dcddc['value']);if(fs['existsSync'](_0x392a4a)){_0x332a2e=!![];return _0x10fbb2[_0x9b41('0x54')](_0x392a4a,_0x2dcddc['value'],config[_0x9b41('0x55')][_0x9b41('0x56')])[_0x9b41('0x24')](function(){return _0x2dcddc;});}return _0x2dcddc;}})[_0x9b41('0x24')](function(_0x1de2cd){if(_0x1de2cd){if(!fs['existsSync'](_0x1de2cd[_0x9b41('0x51')])){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))](_0x9b41('0x58'));}if(_0x1de2cd[_0x9b41('0x59')]){return _0x3320a5[_0x9b41('0x4d')](_0x1de2cd[_0x9b41('0x51')],_0x1de2cd['filename']+path[_0x9b41('0x5a')](_0x1de2cd['value']),function(){if(_0x332a2e){fs['unlink'](_0x1de2cd['value']);}});}else{return _0x3320a5[_0x9b41('0x4d')](_0x1de2cd[_0x9b41('0x51')],function(_0x25e254){if(_0x332a2e){fs[_0x9b41('0x5b')](_0x1de2cd[_0x9b41('0x51')]);}});}}})[_0x9b41('0x44')](handleError(_0x3320a5,null));};exports[_0x9b41('0x25')]=function(_0x3a75e7,_0x54a8f8){return db[_0x9b41('0x2c')][_0x9b41('0x50')]({'where':{'id':_0x3a75e7[_0x9b41('0x46')]['id']}})[_0x9b41('0x24')](function(_0x4b8472){if(_[_0x9b41('0x64')](_0x4b8472)){throw new ReferenceError('Entity\x20not\x20found');}return _0x4b8472;})['then'](function(_0x15da20){var _0x3b1b97=_0x15da20[_0x9b41('0x51')];logger[_0x9b41('0x65')](_0x9b41('0x66'),_0x3b1b97);if(!_[_0x9b41('0x64')](_0x15da20[_0x9b41('0x51')])&&fs[_0x9b41('0x53')](_0x3b1b97)){logger['info']('File:\x20\x22'+_0x3b1b97+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs[_0x9b41('0x67')](_0x3b1b97);}_0x3b1b97=_0x3b1b97+_0x9b41('0x68');if(!_[_0x9b41('0x64')](_0x15da20[_0x9b41('0x51')])&&fs[_0x9b41('0x53')](_0x3b1b97)){logger[_0x9b41('0x65')](_0x9b41('0x69')+_0x3b1b97+_0x9b41('0x6a'));fs['unlinkSync'](_0x3b1b97);}return _0x15da20;})[_0x9b41('0x24')](function(_0x330fd3){if(!_0x330fd3)throw new InternalError();return _0x330fd3['destroy']();})['then'](function(){_0x54a8f8[_0x9b41('0x26')](0xcc)[_0x9b41('0x1a')]();})[_0x9b41('0x44')](handleError(_0x54a8f8,null));};function getBucketslist(_0x127ab3,_0x206c53,_0x35e11){return new Promise(function(_0x7335ae,_0x33a9d3){var _0x1f76b3=new AWS['S3']({'accessKeyId':_0x206c53,'secretAccessKey':_0x127ab3,'region':_0x35e11});_0x1f76b3[_0x9b41('0x6b')]({},function(_0xd00add,_0x142444){if(_0xd00add){return _0x33a9d3(_0xd00add);}else{return _0x7335ae(_0x142444);}});});}function createBucket(_0x14294f,_0x3a6c26,_0x3f8ded,_0x19c336){return new Promise(function(_0x61fb62,_0x25e002){var _0x34b234=new AWS['S3']({'accessKeyId':_0x3a6c26,'secretAccessKey':_0x14294f,'region':_0x3f8ded});_0x34b234[_0x9b41('0x6c')]({'Bucket':_0x19c336},function(_0x53e675,_0x234b21){if(_0x53e675){return _0x25e002(_0x53e675);}else{return _0x61fb62(_0x234b21);}});});}function uploadFile(_0x204cad,_0x3cf9b2,_0x2f3160,_0x2c2757,_0x5a3702,_0x337863){return new Promise(function(_0x4aaca9,_0x22d3eb){var _0x154d6c=new AWS['S3']({'accessKeyId':_0x3cf9b2,'secretAccessKey':_0x204cad,'region':_0x2f3160});_0x154d6c[_0x9b41('0x6d')]({'Bucket':_0x2c2757,'Key':_0x5a3702,'Body':_0x337863},function(_0x2c7258,_0x41a53d){if(_0x2c7258){return _0x22d3eb(_0x2c7258);}else{return _0x4aaca9(_0x41a53d);}});});}function startTranscribe(_0xefaea7,_0x2c5d21,_0xab388c,_0x4b4ac1,_0xb3377a,_0xe53b4f){return new Promise(function(_0x448410,_0x3a1343){var _0x2dffda=new AWS['TranscribeService']({'accessKeyId':_0x2c5d21,'secretAccessKey':_0xefaea7,'region':_0xab388c});_0x2dffda[_0x9b41('0x6e')]({'TranscriptionJobName':_0x4b4ac1,'LanguageCode':_0xb3377a,'Media':{'MediaFileUri':_0xe53b4f}},function(_0x2bf85a,_0x2c97e3){if(_0x2bf85a){return _0x3a1343(_0x2bf85a);}else{return _0x448410(_0x2c97e3);}});});}function transcribe(_0x51c62c,_0x3fc641,_0x48c1e8,_0x59f172,_0x3e1d2e,_0x20c663,_0x2e41c7){return new Promise(function(_0x31ce2e,_0x2b835c){var _0x51ad9b={};logger['info'](util[_0x9b41('0x32')](_0x9b41('0x6f'),_0x51c62c,_0x3e1d2e));return uploadFile(_0x3fc641,_0x48c1e8,_0x59f172,_0x3e1d2e,path[_0x9b41('0x70')](_0x20c663),fs[_0x9b41('0x71')](_0x20c663))[_0x9b41('0x24')](function(_0x7e209c){logger[_0x9b41('0x65')](util[_0x9b41('0x32')](_0x9b41('0x72'),_0x51c62c,_0x3e1d2e,_0x7e209c[_0x9b41('0x73')]));_0x51ad9b['bucket']=_0x7e209c[_0x9b41('0x74')];_0x51ad9b[_0x9b41('0x75')]=_0x7e209c[_0x9b41('0x73')];logger[_0x9b41('0x65')](util[_0x9b41('0x32')]('[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request',_0x51c62c));return startTranscribe(_0x3fc641,_0x48c1e8,_0x59f172,uuidv4(),_0x2e41c7,_0x7e209c[_0x9b41('0x73')]);})[_0x9b41('0x24')](function(_0x5c2583){logger['info'](util['format'](_0x9b41('0x76'),_0x51c62c,_0x5c2583['TranscriptionJob'][_0x9b41('0x77')]));_0x51ad9b[_0x9b41('0x78')]=_0x5c2583[_0x9b41('0x79')][_0x9b41('0x77')];_0x51ad9b[_0x9b41('0x7a')]=_0x5c2583['TranscriptionJob']['TranscriptionJobStatus'];return _0x31ce2e(_0x51ad9b);})[_0x9b41('0x44')](function(_0x3b23b5){return _0x2b835c(_0x3b23b5);});});}exports[_0x9b41('0x7b')]=function(_0x8d5bcd,_0x50d774,_0xff954d){var _0x124578;var _0x1f9910;var _0x500da8;var _0x4403ff=require(_0x9b41('0x4e'));return db['VoiceRecording']['findOne']({'where':{'id':_0x8d5bcd[_0x9b41('0x46')]['id']}})['then'](function(_0x4c888b){if(_0x4c888b){var _0x14a274=util[_0x9b41('0x32')](_0x9b41('0x52'),_0x4c888b[_0x9b41('0x51')]);if(fs[_0x9b41('0x53')](_0x14a274)){cypher=!![];return _0x4403ff[_0x9b41('0x54')](_0x14a274,_0x4c888b[_0x9b41('0x51')],config[_0x9b41('0x55')][_0x9b41('0x56')])['then'](function(){return _0x4c888b;});}return _0x4c888b;}})[_0x9b41('0x24')](function(_0x58fb8e){if(!_0x58fb8e){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))](_0x9b41('0x7c'));}_0x1f9910=_0x58fb8e;return db[_0x9b41('0x7d')][_0x9b41('0x7e')]({'where':{'id':0x1}});})['then'](handleEntityNotFound(_0x50d774,null))['then'](function(_0x25ca6c){if(_0x25ca6c){_0x124578=_0x25ca6c;if(!_0x124578[_0x9b41('0x7f')]||!_0x124578[_0x9b41('0x80')]||!_0x124578[_0x9b41('0x81')]||!_0x124578['language']||!_0x124578[_0x9b41('0x82')]){throw new db['Sequelize'][(_0x9b41('0x63'))](_0x9b41('0x83'));}if(_0x8d5bcd[_0x9b41('0x4a')]['runSentiment']&&(!_0x124578[_0x9b41('0x84')]||!_0x124578[_0x9b41('0x85')]||!_0x124578[_0x9b41('0x86')]||!_0x124578[_0x9b41('0x87')]||!_0x124578[_0x9b41('0x82')])){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))](_0x9b41('0x88'));}return db[_0x9b41('0x89')][_0x9b41('0x7e')]({'where':{'id':_0x124578['transcribeAccountId']}});}})['then'](function(_0xb80f7e){if(!_0xb80f7e){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))](_0x9b41('0x8a'));}if(!_0xb80f7e[_0x9b41('0x8b')]||!_0xb80f7e[_0x9b41('0x8c')]){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))]('Cloud\x20Provider\x20not\x20configured');}_0x500da8=_0xb80f7e;return getBucketslist(_0x500da8['data1'],_0x500da8[_0x9b41('0x8c')],_0x124578['transcribeRegion']);})[_0x9b41('0x24')](function(_0x1b6281){if(_0x1b6281&&_0x1b6281[_0x9b41('0x8d')]){var _0x545699=_[_0x9b41('0x50')](_0x1b6281[_0x9b41('0x8d')],function(_0x2dbe36){return _0x2dbe36['Name']===_0x124578['bucket'];});if(!_0x545699){logger['info'](util['format'](_0x9b41('0x8e'),_0x8d5bcd[_0x9b41('0x46')]['id'],_0x124578['bucket']));return createBucket(_0x500da8['data1'],_0x500da8[_0x9b41('0x8c')],_0x124578[_0x9b41('0x81')],_0x124578[_0x9b41('0x82')]);}logger[_0x9b41('0x65')](util['format']('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available',_0x8d5bcd[_0x9b41('0x46')]['id'],_0x124578[_0x9b41('0x82')]));return;}})[_0x9b41('0x24')](function(_0x383223){if(_0x1f9910[_0x9b41('0x7a')]===_0x9b41('0x8f')){return transcribe(_0x8d5bcd['params']['id'],_0x500da8[_0x9b41('0x8b')],_0x500da8[_0x9b41('0x8c')],_0x124578['transcribeRegion'],_0x124578[_0x9b41('0x82')],_0x1f9910[_0x9b41('0x51')],_0x124578[_0x9b41('0x87')]);}else{logger['info'](util[_0x9b41('0x32')](_0x9b41('0x90'),_0x8d5bcd[_0x9b41('0x46')]['id']));return{'transcribeStatus':_0x9b41('0x91')};}})[_0x9b41('0x24')](function(_0xa18222){if(_0xa18222){_0xa18222['tempSentiment']=_0x8d5bcd[_0x9b41('0x4a')][_0x9b41('0x92')];return _0x1f9910[_0x9b41('0x93')](_0xa18222);}})[_0x9b41('0x24')](respondWithResult(_0x50d774,null))['catch'](handleError(_0x50d774,null));};function writeFile(_0x878667,_0x10a4da){return new Promise(function(_0x2ceac6,_0xda080d){fs[_0x9b41('0x94')](_0x10a4da,_0x878667,function(_0x54c6de,_0x7354ac){if(_0x54c6de){return _0xda080d(_0x54c6de);}else{return _0x2ceac6(_0x7354ac);}});});}exports[_0x9b41('0x95')]=function(_0x3cf013,_0x169897,_0x4bafe0){return db['VoiceRecording'][_0x9b41('0x7e')]({'where':{'id':_0x3cf013[_0x9b41('0x46')]['id']}})['then'](handleEntityNotFound(_0x169897))['then'](function(_0x5d600c){if(_0x5d600c&&_0x5d600c['fileText']){var _0x35412b=_0x5d600c['fileText'];var _0x302feb=config[_0x9b41('0x96')]+_0x9b41('0x97')+_0x5d600c['id']+_0x9b41('0x98');if(fs['existsSync'](_0x302feb)){return _0x302feb;}return writeFile(_0x35412b,_0x302feb)[_0x9b41('0x24')](function(){return _0x302feb;});}else{throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))]('Transcript\x20not\x20available');}})[_0x9b41('0x24')](function(_0x4a66bf){return _0x169897[_0x9b41('0x4d')](_0x4a66bf);})[_0x9b41('0x44')](handleError(_0x169897));};
\ No newline at end of file