Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index a0fa25c..de8fa35 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1692=['describe','uniqueid','value','%s.cypher','existsSync','decryptFile','secrets','recording','Sequelize','ValidationError','VoiceRecording\x20not\x20found','filename','download','unlink','message','Not\x20found','../../components/encryptor','sequelize','token','push','$and','extname','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','isNil','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','listBuckets','createBucket','upload','TranscribeService','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','basename','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Bucket','Location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','transcribeName','TranscriptionJob','transcribeStatus','TranscriptionJobStatus','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribeRegion','bucket','Transcribe\x20not\x20configured','sentimentAccountId','sentimentRegion','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','transcribeAccountId','Cloud\x20Provider\x20not\x20available','Cloud\x20Provider\x20not\x20configured','data1','Buckets','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','tempSentiment','runSentiment','updateAttributes','writeFile','downloadTranscribe','fileText','.txt','Transcript\x20not\x20available','eml-format','zip-dir','fast-json-patch','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','crypto','jsforce','desk.js','querystring','papaparse','aws-sdk','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','set','apply','reject','save','update','then','destroy','sendStatus','error','stack','name','index','map','VoiceRecording','rawAttributes','type','key','model','differenceBy','format','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','options','include','rows','params','includeAll','catch','create','body','find'];(function(_0x11005e,_0x20c3d2){var _0x29338f=function(_0x3384e9){while(--_0x3384e9){_0x11005e['push'](_0x11005e['shift']());}};_0x29338f(++_0x20c3d2);}(_0x1692,0xdb));var _0x2169=function(_0x30473d,_0x2bd939){_0x30473d=_0x30473d-0x0;var _0xff6545=_0x1692[_0x30473d];return _0xff6545;};'use strict';var emlformat=require(_0x2169('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x2169('0x1'));var jsonpatch=require(_0x2169('0x2'));var rp=require('request-promise');var moment=require(_0x2169('0x3'));var BPromise=require(_0x2169('0x4'));var Mustache=require('mustache');var util=require(_0x2169('0x5'));var path=require(_0x2169('0x6'));var sox=require(_0x2169('0x7'));var csv=require(_0x2169('0x8'));var ejs=require(_0x2169('0x9'));var fs=require('fs');var fs_extra=require(_0x2169('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x2169('0xb'));var jsforce=require(_0x2169('0xc'));var deskjs=require(_0x2169('0xd'));var toCsv=require(_0x2169('0x8'));var querystring=require(_0x2169('0xe'));var Papa=require(_0x2169('0xf'));var AWS=require(_0x2169('0x10'));var uuidv4=require(_0x2169('0x11'));var Redis=require(_0x2169('0x12'));var authService=require(_0x2169('0x13'));var qs=require(_0x2169('0x14'));var as=require(_0x2169('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x2169('0x16'));var utils=require(_0x2169('0x17'));var config=require(_0x2169('0x18'));var licenseUtil=require(_0x2169('0x19'));var db=require(_0x2169('0x1a'))['db'];function respondWithStatusCode(_0x18c548,_0x37c345){_0x37c345=_0x37c345||0xcc;return function(_0x259c4e){if(_0x259c4e){return _0x18c548['sendStatus'](_0x37c345);}return _0x18c548[_0x2169('0x1b')](_0x37c345)[_0x2169('0x1c')]();};}function respondWithResult(_0x5f2bde,_0xe40366){_0xe40366=_0xe40366||0xc8;return function(_0x56e41c){if(_0x56e41c){return _0x5f2bde[_0x2169('0x1b')](_0xe40366)[_0x2169('0x1d')](_0x56e41c);}};}function respondWithFilteredResult(_0x452751,_0x4eb2ba){return function(_0x50309f){if(_0x50309f){var _0x14098b=typeof _0x4eb2ba[_0x2169('0x1e')]===_0x2169('0x1f')&&typeof _0x4eb2ba[_0x2169('0x20')]==='undefined';var _0x36e576=_0x50309f[_0x2169('0x21')];var _0x496d59=_0x14098b?0x0:_0x4eb2ba['offset'];var _0x49b2c2=_0x14098b?_0x50309f['count']:_0x4eb2ba[_0x2169('0x1e')]+_0x4eb2ba[_0x2169('0x20')];var _0x3c4630;if(_0x49b2c2>=_0x36e576){_0x49b2c2=_0x36e576;_0x3c4630=0xc8;}else{_0x3c4630=0xce;}_0x452751[_0x2169('0x1b')](_0x3c4630);return _0x452751[_0x2169('0x22')]('Content-Range',_0x496d59+'-'+_0x49b2c2+'/'+_0x36e576)[_0x2169('0x1d')](_0x50309f);}return null;};}function patchUpdates(_0x382b18){return function(_0x5dbe59){try{jsonpatch[_0x2169('0x23')](_0x5dbe59,_0x382b18,!![]);}catch(_0x365209){return BPromise[_0x2169('0x24')](_0x365209);}return _0x5dbe59[_0x2169('0x25')]();};}function saveUpdates(_0x4c2b4d,_0x48720d){return function(_0x1a5caf){if(_0x1a5caf){return _0x1a5caf[_0x2169('0x26')](_0x4c2b4d)[_0x2169('0x27')](function(_0x2a4655){return _0x2a4655;});}return null;};}function removeEntity(_0x9da691,_0x64a0e2){return function(_0xffcde1){if(_0xffcde1){return _0xffcde1[_0x2169('0x28')]()[_0x2169('0x27')](function(){_0x9da691[_0x2169('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x440389,_0x84ea0a){return function(_0x2d6490){if(!_0x2d6490){_0x440389[_0x2169('0x29')](0x194);}return _0x2d6490;};}function handleError(_0x30f680,_0x58ebf5){_0x58ebf5=_0x58ebf5||0x1f4;return function(_0x32c21a){logger[_0x2169('0x2a')](_0x32c21a[_0x2169('0x2b')]);if(_0x32c21a[_0x2169('0x2c')]){delete _0x32c21a[_0x2169('0x2c')];}_0x30f680[_0x2169('0x1b')](_0x58ebf5)['send'](_0x32c21a);};}exports[_0x2169('0x2d')]=function(_0xe8b4fc,_0x14a4ad){var _0x2b63cb={},_0x2b57b2={},_0x477eb0={'count':0x0,'rows':[]};var _0x593aa1=_[_0x2169('0x2e')](db[_0x2169('0x2f')][_0x2169('0x30')],function(_0x4a6387){return{'name':_0x4a6387['fieldName'],'type':_0x4a6387[_0x2169('0x31')][_0x2169('0x32')]};});_0x2b57b2[_0x2169('0x33')]=_[_0x2169('0x34')](_[_0x2169('0x2e')](_0x593aa1,'name'),[_0x2169('0x35')]);_0x2b57b2[_0x2169('0x36')]=_[_0x2169('0x37')](_0xe8b4fc['query']);_0x2b57b2[_0x2169('0x38')]=_[_0x2169('0x39')](_0x2b57b2['model'],_0x2b57b2[_0x2169('0x36')]);_0x2b63cb[_0x2169('0x3a')]=_[_0x2169('0x39')](_0x2b57b2[_0x2169('0x33')],qs[_0x2169('0x3b')](_0xe8b4fc[_0x2169('0x36')][_0x2169('0x3b')]));_0x2b63cb[_0x2169('0x3a')]=_0x2b63cb[_0x2169('0x3a')][_0x2169('0x3c')]?_0x2b63cb['attributes']:_0x2b57b2[_0x2169('0x33')];if(!_0xe8b4fc[_0x2169('0x36')][_0x2169('0x3d')](_0x2169('0x3e'))){_0x2b63cb['limit']=qs[_0x2169('0x20')](_0xe8b4fc[_0x2169('0x36')][_0x2169('0x20')]);_0x2b63cb['offset']=qs['offset'](_0xe8b4fc[_0x2169('0x36')][_0x2169('0x1e')]);}_0x2b63cb[_0x2169('0x3f')]=qs[_0x2169('0x40')](_0xe8b4fc[_0x2169('0x36')][_0x2169('0x40')]);_0x2b63cb['where']=qs[_0x2169('0x38')](_['pick'](_0xe8b4fc['query'],_0x2b57b2[_0x2169('0x38')]),_0x593aa1);if(_0xe8b4fc['query']['filter']){_0x2b63cb['where']=_['merge'](_0x2b63cb[_0x2169('0x41')],{'$or':_[_0x2169('0x2e')](_0x593aa1,function(_0x126068){if(_0x126068[_0x2169('0x31')]!=='VIRTUAL'){var _0x8a9c53={};_0x8a9c53[_0x126068['name']]={'$like':'%'+_0xe8b4fc[_0x2169('0x36')][_0x2169('0x42')]+'%'};return _0x8a9c53;}})});}_0x2b63cb=_[_0x2169('0x43')]({},_0x2b63cb,_0xe8b4fc[_0x2169('0x44')]);var _0x404455={'where':_0x2b63cb[_0x2169('0x41')]};return db[_0x2169('0x2f')][_0x2169('0x21')](_0x404455)['then'](function(_0x21cf30){_0x477eb0[_0x2169('0x21')]=_0x21cf30;if(_0xe8b4fc[_0x2169('0x36')]['includeAll']){_0x2b63cb[_0x2169('0x45')]=[{'all':!![]}];}return db[_0x2169('0x2f')]['findAll'](_0x2b63cb);})[_0x2169('0x27')](function(_0x2b3593){_0x477eb0[_0x2169('0x46')]=_0x2b3593;return _0x477eb0;})[_0x2169('0x27')](respondWithFilteredResult(_0x14a4ad,_0x2b63cb))['catch'](handleError(_0x14a4ad,null));};exports['show']=function(_0x4fab67,_0xe7b228){var _0x49804c={'raw':![],'where':{'id':_0x4fab67[_0x2169('0x47')]['id']}},_0x20b6c0={};_0x20b6c0[_0x2169('0x33')]=_[_0x2169('0x37')](db[_0x2169('0x2f')][_0x2169('0x30')]);_0x20b6c0[_0x2169('0x36')]=_[_0x2169('0x37')](_0x4fab67[_0x2169('0x36')]);_0x20b6c0['filters']=_[_0x2169('0x39')](_0x20b6c0['model'],_0x20b6c0[_0x2169('0x36')]);_0x49804c[_0x2169('0x3a')]=_[_0x2169('0x39')](_0x20b6c0[_0x2169('0x33')],qs[_0x2169('0x3b')](_0x4fab67[_0x2169('0x36')][_0x2169('0x3b')]));_0x49804c['attributes']=_0x49804c['attributes'][_0x2169('0x3c')]?_0x49804c[_0x2169('0x3a')]:_0x20b6c0['model'];if(_0x4fab67['query'][_0x2169('0x48')]){_0x49804c['include']=[{'all':!![]}];}_0x49804c=_[_0x2169('0x43')]({},_0x49804c,_0x4fab67['options']);return db[_0x2169('0x2f')]['find'](_0x49804c)[_0x2169('0x27')](handleEntityNotFound(_0xe7b228,null))[_0x2169('0x27')](respondWithResult(_0xe7b228,null))[_0x2169('0x49')](handleError(_0xe7b228,null));};exports[_0x2169('0x4a')]=function(_0x3451c9,_0x4cbf46){return db[_0x2169('0x2f')][_0x2169('0x4a')](_0x3451c9[_0x2169('0x4b')],{})['then'](respondWithResult(_0x4cbf46,0xc9))[_0x2169('0x49')](handleError(_0x4cbf46,null));};exports['update']=function(_0x2e54e9,_0x1ce69f){if(_0x2e54e9[_0x2169('0x4b')]['id']){delete _0x2e54e9[_0x2169('0x4b')]['id'];}return db[_0x2169('0x2f')][_0x2169('0x4c')]({'where':{'id':_0x2e54e9['params']['id']}})['then'](handleEntityNotFound(_0x1ce69f,null))[_0x2169('0x27')](saveUpdates(_0x2e54e9[_0x2169('0x4b')],null))[_0x2169('0x27')](respondWithResult(_0x1ce69f,null))['catch'](handleError(_0x1ce69f,null));};exports[_0x2169('0x4d')]=function(_0x2d18df,_0x36a1d0){return db[_0x2169('0x2f')]['describe']()[_0x2169('0x27')](respondWithResult(_0x36a1d0,null))[_0x2169('0x49')](handleError(_0x36a1d0,null));};exports['download']=function(_0x1898d8,_0x486e5d,_0x50acb2){var _0x5e86ce=require('../../components/encryptor');var _0x4650ef=![];var _0x18572b={};if(_0x1898d8[_0x2169('0x36')][_0x2169('0x31')]&&_0x1898d8[_0x2169('0x36')][_0x2169('0x31')]===_0x2169('0x4e')){_0x18572b['uniqueid']=_0x1898d8[_0x2169('0x47')]['id'];}else{_0x18572b['id']=_0x1898d8[_0x2169('0x47')]['id'];}return db[_0x2169('0x2f')][_0x2169('0x4c')]({'where':_0x18572b,'attributes':['id',_0x2169('0x4f')],'raw':!![]})[_0x2169('0x27')](handleEntityNotFound(_0x486e5d,null))[_0x2169('0x27')](function(_0x588be1){if(_0x588be1){var _0x83d1d4=_0x588be1[_0x2169('0x4f')];var _0x154f35=util[_0x2169('0x35')](_0x2169('0x50'),_0x83d1d4);if(fs[_0x2169('0x51')](_0x154f35)){_0x4650ef=!![];return _0x5e86ce[_0x2169('0x52')](_0x154f35,_0x83d1d4,config[_0x2169('0x53')][_0x2169('0x54')])[_0x2169('0x27')](function(){return _0x588be1;});}return _0x588be1;}})[_0x2169('0x27')](function(_0x56f424){if(_0x56f424){var _0x26393d=_0x56f424['value'];if(!fs['existsSync'](_0x26393d)){throw new db[(_0x2169('0x55'))][(_0x2169('0x56'))](_0x2169('0x57'));}if(_0x56f424[_0x2169('0x58')]){return _0x486e5d[_0x2169('0x59')](_0x26393d,_0x56f424[_0x2169('0x58')]+path['extname'](_0x26393d),function(){if(_0x4650ef){fs[_0x2169('0x5a')](_0x26393d);}});}else{return _0x486e5d[_0x2169('0x59')](_0x26393d,function(_0x116579){if(_0x4650ef){fs[_0x2169('0x5a')](_0x26393d);}});}}})[_0x2169('0x49')](function(_0x10f01e){if(_0x10f01e[_0x2169('0x5b')]==='VoiceRecording\x20not\x20found'){_0x486e5d[_0x2169('0x1b')](0x194)['send'](_0x2169('0x5c'));}else{return handleError(_0x486e5d,null);}});};exports['downloads']=function(_0x67fe01,_0x218dca,_0x17a744){var _0x3f918c=require(_0x2169('0x5d'));var _0x6110a5=![];var _0x25f891={'$and':[db[_0x2169('0x5e')][_0x2169('0x41')](db['sequelize']['fn']('MD5',db[_0x2169('0x5e')]['col']('uniqueid')),_0x67fe01['query'][_0x2169('0x5f')])]};if(_0x67fe01[_0x2169('0x36')][_0x2169('0x31')]&&_0x67fe01[_0x2169('0x36')]['type']===_0x2169('0x4e')){_0x25f891['$and'][_0x2169('0x60')]({'uniqueid':_0x67fe01[_0x2169('0x47')]['id']});}else{_0x25f891[_0x2169('0x61')][_0x2169('0x60')]({'id':_0x67fe01[_0x2169('0x47')]['id']});}return db[_0x2169('0x2f')][_0x2169('0x4c')]({'where':_0x25f891,'attributes':['id',_0x2169('0x4f')],'raw':!![]})['then'](handleEntityNotFound(_0x218dca,null))['then'](function(_0x5c692d){if(_0x5c692d){var _0x4feb28=util[_0x2169('0x35')](_0x2169('0x50'),_0x5c692d['value']);if(fs[_0x2169('0x51')](_0x4feb28)){_0x6110a5=!![];return _0x3f918c[_0x2169('0x52')](_0x4feb28,_0x5c692d[_0x2169('0x4f')],config['secrets'][_0x2169('0x54')])[_0x2169('0x27')](function(){return _0x5c692d;});}return _0x5c692d;}})[_0x2169('0x27')](function(_0x1a921d){if(_0x1a921d){if(!fs[_0x2169('0x51')](_0x1a921d[_0x2169('0x4f')])){throw new db['Sequelize'][(_0x2169('0x56'))]('VoiceRecording\x20not\x20found');}if(_0x1a921d[_0x2169('0x58')]){return _0x218dca[_0x2169('0x59')](_0x1a921d[_0x2169('0x4f')],_0x1a921d[_0x2169('0x58')]+path[_0x2169('0x62')](_0x1a921d[_0x2169('0x4f')]),function(){if(_0x6110a5){fs[_0x2169('0x5a')](_0x1a921d[_0x2169('0x4f')]);}});}else{return _0x218dca[_0x2169('0x59')](_0x1a921d[_0x2169('0x4f')],function(_0x10403f){if(_0x6110a5){fs[_0x2169('0x5a')](_0x1a921d[_0x2169('0x4f')]);}});}}})['catch'](handleError(_0x218dca,null));};exports[_0x2169('0x28')]=function(_0x1f8482,_0x2cd3cc){return db[_0x2169('0x2f')][_0x2169('0x4c')]({'where':{'id':_0x1f8482[_0x2169('0x47')]['id']}})[_0x2169('0x27')](function(_0x14abca){if(_['isNil'](_0x14abca)){throw new ReferenceError(_0x2169('0x63'));}return _0x14abca;})[_0x2169('0x27')](function(_0x1e5c97){var _0x5e3903=_0x1e5c97[_0x2169('0x4f')];logger[_0x2169('0x64')](_0x2169('0x65'),_0x5e3903);if(!_[_0x2169('0x66')](_0x1e5c97[_0x2169('0x4f')])&&fs[_0x2169('0x51')](_0x5e3903)){logger[_0x2169('0x64')](_0x2169('0x67')+_0x5e3903+_0x2169('0x68'));fs['unlinkSync'](_0x5e3903);}_0x5e3903=_0x5e3903+'.cypher';if(!_[_0x2169('0x66')](_0x1e5c97[_0x2169('0x4f')])&&fs[_0x2169('0x51')](_0x5e3903)){logger['info'](_0x2169('0x67')+_0x5e3903+_0x2169('0x68'));fs[_0x2169('0x69')](_0x5e3903);}return _0x1e5c97;})[_0x2169('0x27')](function(_0x4c5325){if(!_0x4c5325)throw new InternalError();return _0x4c5325[_0x2169('0x28')]();})[_0x2169('0x27')](function(){_0x2cd3cc[_0x2169('0x1b')](0xcc)[_0x2169('0x1c')]();})[_0x2169('0x49')](handleError(_0x2cd3cc,null));};function getBucketslist(_0x51efe0,_0x2d789c,_0xb4c374){return new Promise(function(_0x4779cf,_0x11e8d8){var _0x3a7033=new AWS['S3']({'accessKeyId':_0x2d789c,'secretAccessKey':_0x51efe0,'region':_0xb4c374});_0x3a7033[_0x2169('0x6a')]({},function(_0x1b84ad,_0x5776d3){if(_0x1b84ad){return _0x11e8d8(_0x1b84ad);}else{return _0x4779cf(_0x5776d3);}});});}function createBucket(_0x1f69ae,_0x20b24d,_0x1b9f3c,_0x55a9b2){return new Promise(function(_0x498bab,_0x2102d6){var _0x5c21f1=new AWS['S3']({'accessKeyId':_0x20b24d,'secretAccessKey':_0x1f69ae,'region':_0x1b9f3c});_0x5c21f1[_0x2169('0x6b')]({'Bucket':_0x55a9b2},function(_0x3e3bd1,_0x129ceb){if(_0x3e3bd1){return _0x2102d6(_0x3e3bd1);}else{return _0x498bab(_0x129ceb);}});});}function uploadFile(_0x16289f,_0x11fbd3,_0x4d5c9d,_0x109fc0,_0x3d2b22,_0x267ea0){return new Promise(function(_0x2682f,_0xc8bcde){var _0x422597=new AWS['S3']({'accessKeyId':_0x11fbd3,'secretAccessKey':_0x16289f,'region':_0x4d5c9d});_0x422597[_0x2169('0x6c')]({'Bucket':_0x109fc0,'Key':_0x3d2b22,'Body':_0x267ea0},function(_0x4bc4bf,_0x52ff83){if(_0x4bc4bf){return _0xc8bcde(_0x4bc4bf);}else{return _0x2682f(_0x52ff83);}});});}function startTranscribe(_0x38d445,_0x949d55,_0x1d7148,_0x2bf316,_0x3b0710,_0x290a8b){return new Promise(function(_0x592d27,_0x9c2797){var _0x3464eb=new AWS[(_0x2169('0x6d'))]({'accessKeyId':_0x949d55,'secretAccessKey':_0x38d445,'region':_0x1d7148});_0x3464eb['startTranscriptionJob']({'TranscriptionJobName':_0x2bf316,'LanguageCode':_0x3b0710,'Media':{'MediaFileUri':_0x290a8b}},function(_0x28dc7f,_0x50fec5){if(_0x28dc7f){return _0x9c2797(_0x28dc7f);}else{return _0x592d27(_0x50fec5);}});});}function transcribe(_0x127a2b,_0x325bc2,_0x3983ec,_0x4e185d,_0x29b31a,_0x400ec0,_0x1466ba){return new Promise(function(_0x1ba1d1,_0x43f45a){var _0x3b99ad={};logger[_0x2169('0x64')](util['format'](_0x2169('0x6e'),_0x127a2b,_0x29b31a));return uploadFile(_0x325bc2,_0x3983ec,_0x4e185d,_0x29b31a,path[_0x2169('0x6f')](_0x400ec0),fs[_0x2169('0x70')](_0x400ec0))[_0x2169('0x27')](function(_0x26fa5){logger[_0x2169('0x64')](util[_0x2169('0x35')](_0x2169('0x71'),_0x127a2b,_0x29b31a,_0x26fa5['Location']));_0x3b99ad['bucket']=_0x26fa5[_0x2169('0x72')];_0x3b99ad['location']=_0x26fa5[_0x2169('0x73')];logger[_0x2169('0x64')](util['format'](_0x2169('0x74'),_0x127a2b));return startTranscribe(_0x325bc2,_0x3983ec,_0x4e185d,uuidv4(),_0x1466ba,_0x26fa5[_0x2169('0x73')]);})[_0x2169('0x27')](function(_0x242741){logger['info'](util[_0x2169('0x35')](_0x2169('0x75'),_0x127a2b,_0x242741['TranscriptionJob']['TranscriptionJobName']));_0x3b99ad[_0x2169('0x76')]=_0x242741[_0x2169('0x77')]['TranscriptionJobName'];_0x3b99ad[_0x2169('0x78')]=_0x242741['TranscriptionJob'][_0x2169('0x79')];return _0x1ba1d1(_0x3b99ad);})[_0x2169('0x49')](function(_0x5de334){return _0x43f45a(_0x5de334);});});}exports[_0x2169('0x7a')]=function(_0x460f2a,_0x581c58,_0x1d9a1b){var _0x26adbc;var _0x4634d6;var _0xc33bff;var _0x13d26c=require('../../components/encryptor');return db[_0x2169('0x2f')][_0x2169('0x7b')]({'where':{'id':_0x460f2a['params']['id']}})[_0x2169('0x27')](function(_0x1f1870){if(_0x1f1870){var _0x316e03=util['format'](_0x2169('0x50'),_0x1f1870[_0x2169('0x4f')]);if(fs[_0x2169('0x51')](_0x316e03)){cypher=!![];return _0x13d26c['decryptFile'](_0x316e03,_0x1f1870[_0x2169('0x4f')],config[_0x2169('0x53')][_0x2169('0x54')])[_0x2169('0x27')](function(){return _0x1f1870;});}return _0x1f1870;}})[_0x2169('0x27')](function(_0x3150e0){if(!_0x3150e0){throw new db[(_0x2169('0x55'))][(_0x2169('0x56'))](_0x2169('0x7c'));}_0x4634d6=_0x3150e0;return db[_0x2169('0x7d')][_0x2169('0x7b')]({'where':{'id':0x1}});})[_0x2169('0x27')](handleEntityNotFound(_0x581c58,null))[_0x2169('0x27')](function(_0x3e752d){if(_0x3e752d){_0x26adbc=_0x3e752d;if(!_0x26adbc['transcribe']||!_0x26adbc['transcribeAccountId']||!_0x26adbc[_0x2169('0x7e')]||!_0x26adbc['language']||!_0x26adbc[_0x2169('0x7f')]){throw new db[(_0x2169('0x55'))][(_0x2169('0x56'))](_0x2169('0x80'));}if(_0x460f2a[_0x2169('0x4b')]['runSentiment']&&(!_0x26adbc['sentiment']||!_0x26adbc[_0x2169('0x81')]||!_0x26adbc[_0x2169('0x82')]||!_0x26adbc[_0x2169('0x83')]||!_0x26adbc['bucket'])){throw new db[(_0x2169('0x55'))]['ValidationError'](_0x2169('0x84'));}return db[_0x2169('0x85')][_0x2169('0x7b')]({'where':{'id':_0x26adbc[_0x2169('0x86')]}});}})[_0x2169('0x27')](function(_0xa6b8d5){if(!_0xa6b8d5){throw new db[(_0x2169('0x55'))][(_0x2169('0x56'))](_0x2169('0x87'));}if(!_0xa6b8d5['data1']||!_0xa6b8d5['data2']){throw new db['Sequelize'][(_0x2169('0x56'))](_0x2169('0x88'));}_0xc33bff=_0xa6b8d5;return getBucketslist(_0xc33bff[_0x2169('0x89')],_0xc33bff['data2'],_0x26adbc['transcribeRegion']);})[_0x2169('0x27')](function(_0x101302){if(_0x101302&&_0x101302['Buckets']){var _0xe0b46d=_[_0x2169('0x4c')](_0x101302[_0x2169('0x8a')],function(_0x3e894a){return _0x3e894a['Name']===_0x26adbc[_0x2169('0x7f')];});if(!_0xe0b46d){logger[_0x2169('0x64')](util['format']('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available',_0x460f2a[_0x2169('0x47')]['id'],_0x26adbc[_0x2169('0x7f')]));return createBucket(_0xc33bff[_0x2169('0x89')],_0xc33bff['data2'],_0x26adbc[_0x2169('0x7e')],_0x26adbc[_0x2169('0x7f')]);}logger[_0x2169('0x64')](util[_0x2169('0x35')](_0x2169('0x8b'),_0x460f2a[_0x2169('0x47')]['id'],_0x26adbc['bucket']));return;}})[_0x2169('0x27')](function(_0x81e36c){if(_0x4634d6['transcribeStatus']==='NEW'){return transcribe(_0x460f2a[_0x2169('0x47')]['id'],_0xc33bff[_0x2169('0x89')],_0xc33bff['data2'],_0x26adbc[_0x2169('0x7e')],_0x26adbc[_0x2169('0x7f')],_0x4634d6[_0x2169('0x4f')],_0x26adbc[_0x2169('0x83')]);}else{logger[_0x2169('0x64')](util['format']('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x460f2a[_0x2169('0x47')]['id']));return{'transcribeStatus':'IN_PROGRESS'};}})[_0x2169('0x27')](function(_0x23978b){if(_0x23978b){_0x23978b[_0x2169('0x8c')]=_0x460f2a[_0x2169('0x4b')][_0x2169('0x8d')];return _0x4634d6[_0x2169('0x8e')](_0x23978b);}})['then'](respondWithResult(_0x581c58,null))[_0x2169('0x49')](handleError(_0x581c58,null));};function writeFile(_0x33d827,_0x2761d5){return new Promise(function(_0x187309,_0xa8d764){fs[_0x2169('0x8f')](_0x2761d5,_0x33d827,function(_0xb959c1,_0x335362){if(_0xb959c1){return _0xa8d764(_0xb959c1);}else{return _0x187309(_0x335362);}});});}exports[_0x2169('0x90')]=function(_0x37740b,_0x48d49a,_0x40b0b9){return db[_0x2169('0x2f')][_0x2169('0x7b')]({'where':{'id':_0x37740b[_0x2169('0x47')]['id']}})[_0x2169('0x27')](handleEntityNotFound(_0x48d49a))['then'](function(_0x236900){if(_0x236900&&_0x236900[_0x2169('0x91')]){var _0x163762=_0x236900[_0x2169('0x91')];var _0x859a7c=config['root']+'/server/files/transcribes/transcribe_'+_0x236900['id']+_0x2169('0x92');if(fs[_0x2169('0x51')](_0x859a7c)){return _0x859a7c;}return writeFile(_0x163762,_0x859a7c)['then'](function(){return _0x859a7c;});}else{throw new db['Sequelize'][(_0x2169('0x56'))](_0x2169('0x93'));}})[_0x2169('0x27')](function(_0x4445a8){return _0x48d49a[_0x2169('0x59')](_0x4445a8);})['catch'](handleError(_0x48d49a));};
\ No newline at end of file
+var _0xb5fa=['Setting','transcribe','transcribeAccountId','transcribeRegion','Transcribe\x20not\x20configured','runSentiment','sentiment','sentimentAccountId','sentimentRegion','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','data1','data2','Cloud\x20Provider\x20not\x20configured','Buckets','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','updateAttributes','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','Transcript\x20not\x20available','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','aws-sdk','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','sendStatus','end','offset','undefined','limit','count','status','set','json','reject','save','update','then','destroy','error','stack','index','map','rawAttributes','fieldName','type','key','model','differenceBy','name','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','options','VoiceRecording','include','findAll','rows','catch','show','keys','find','create','body','params','describe','uniqueid','value','format','%s.cypher','decryptFile','secrets','recording','existsSync','Sequelize','ValidationError','VoiceRecording\x20not\x20found','filename','download','extname','unlink','message','send','Not\x20found','downloads','../../components/encryptor','sequelize','MD5','col','token','$and','push','isNil','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','.cypher','unlinkSync','upload','TranscribeService','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','basename','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','bucket','Bucket','location','Location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','TranscriptionJob','TranscriptionJobName','transcribeName','transcribeStatus','TranscriptionJobStatus','runTranscribe','findOne','Voice\x20Recording\x20not\x20found'];(function(_0x57936e,_0x590f5b){var _0x441ac3=function(_0x36de9b){while(--_0x36de9b){_0x57936e['push'](_0x57936e['shift']());}};_0x441ac3(++_0x590f5b);}(_0xb5fa,0x15d));var _0xab5f=function(_0x4d3071,_0x35eed6){_0x4d3071=_0x4d3071-0x0;var _0x16a0a0=_0xb5fa[_0x4d3071];return _0x16a0a0;};'use strict';var emlformat=require(_0xab5f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xab5f('0x1'));var jsonpatch=require(_0xab5f('0x2'));var rp=require(_0xab5f('0x3'));var moment=require(_0xab5f('0x4'));var BPromise=require(_0xab5f('0x5'));var Mustache=require(_0xab5f('0x6'));var util=require(_0xab5f('0x7'));var path=require(_0xab5f('0x8'));var sox=require(_0xab5f('0x9'));var csv=require(_0xab5f('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xab5f('0xb'));var _=require(_0xab5f('0xc'));var squel=require(_0xab5f('0xd'));var crypto=require(_0xab5f('0xe'));var jsforce=require(_0xab5f('0xf'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xab5f('0x10'));var Papa=require(_0xab5f('0x11'));var AWS=require(_0xab5f('0x12'));var uuidv4=require(_0xab5f('0x13'));var Redis=require(_0xab5f('0x14'));var authService=require(_0xab5f('0x15'));var qs=require(_0xab5f('0x16'));var as=require(_0xab5f('0x17'));var hardwareService=require(_0xab5f('0x18'));var logger=require(_0xab5f('0x19'))(_0xab5f('0x1a'));var utils=require(_0xab5f('0x1b'));var config=require(_0xab5f('0x1c'));var licenseUtil=require(_0xab5f('0x1d'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x55f6bc,_0x340b64){_0x340b64=_0x340b64||0xcc;return function(_0x68d71e){if(_0x68d71e){return _0x55f6bc[_0xab5f('0x1e')](_0x340b64);}return _0x55f6bc['status'](_0x340b64)[_0xab5f('0x1f')]();};}function respondWithResult(_0x275fd1,_0x1d74a8){_0x1d74a8=_0x1d74a8||0xc8;return function(_0x2f4521){if(_0x2f4521){return _0x275fd1['status'](_0x1d74a8)['json'](_0x2f4521);}};}function respondWithFilteredResult(_0x530258,_0x940260){return function(_0x58fa94){if(_0x58fa94){var _0xa01246=typeof _0x940260[_0xab5f('0x20')]===_0xab5f('0x21')&&typeof _0x940260[_0xab5f('0x22')]===_0xab5f('0x21');var _0x4dc4ec=_0x58fa94[_0xab5f('0x23')];var _0x3569b7=_0xa01246?0x0:_0x940260[_0xab5f('0x20')];var _0xcfaf6c=_0xa01246?_0x58fa94['count']:_0x940260[_0xab5f('0x20')]+_0x940260['limit'];var _0x2fd8a4;if(_0xcfaf6c>=_0x4dc4ec){_0xcfaf6c=_0x4dc4ec;_0x2fd8a4=0xc8;}else{_0x2fd8a4=0xce;}_0x530258[_0xab5f('0x24')](_0x2fd8a4);return _0x530258[_0xab5f('0x25')]('Content-Range',_0x3569b7+'-'+_0xcfaf6c+'/'+_0x4dc4ec)[_0xab5f('0x26')](_0x58fa94);}return null;};}function patchUpdates(_0x4a90a1){return function(_0x4e1213){try{jsonpatch['apply'](_0x4e1213,_0x4a90a1,!![]);}catch(_0x4f9e09){return BPromise[_0xab5f('0x27')](_0x4f9e09);}return _0x4e1213[_0xab5f('0x28')]();};}function saveUpdates(_0x5cc020,_0x5f329e){return function(_0x32a076){if(_0x32a076){return _0x32a076[_0xab5f('0x29')](_0x5cc020)[_0xab5f('0x2a')](function(_0x37e22e){return _0x37e22e;});}return null;};}function removeEntity(_0x261ed0,_0x372c57){return function(_0x37a6d4){if(_0x37a6d4){return _0x37a6d4[_0xab5f('0x2b')]()[_0xab5f('0x2a')](function(){_0x261ed0[_0xab5f('0x24')](0xcc)[_0xab5f('0x1f')]();});}};}function handleEntityNotFound(_0x559e3f,_0x189319){return function(_0xc915b2){if(!_0xc915b2){_0x559e3f['sendStatus'](0x194);}return _0xc915b2;};}function handleError(_0x501769,_0x2a7805){_0x2a7805=_0x2a7805||0x1f4;return function(_0x55e2aa){logger[_0xab5f('0x2c')](_0x55e2aa[_0xab5f('0x2d')]);if(_0x55e2aa['name']){delete _0x55e2aa['name'];}_0x501769[_0xab5f('0x24')](_0x2a7805)['send'](_0x55e2aa);};}exports[_0xab5f('0x2e')]=function(_0x2b5605,_0x5f57d9){var _0x2ca740={},_0x5e443b={},_0x5d29e6={'count':0x0,'rows':[]};var _0x24b4c6=_[_0xab5f('0x2f')](db['VoiceRecording'][_0xab5f('0x30')],function(_0x5c8ed0){return{'name':_0x5c8ed0[_0xab5f('0x31')],'type':_0x5c8ed0[_0xab5f('0x32')][_0xab5f('0x33')]};});_0x5e443b[_0xab5f('0x34')]=_[_0xab5f('0x35')](_['map'](_0x24b4c6,_0xab5f('0x36')),['format']);_0x5e443b[_0xab5f('0x37')]=_['keys'](_0x2b5605[_0xab5f('0x37')]);_0x5e443b[_0xab5f('0x38')]=_[_0xab5f('0x39')](_0x5e443b[_0xab5f('0x34')],_0x5e443b[_0xab5f('0x37')]);_0x2ca740[_0xab5f('0x3a')]=_[_0xab5f('0x39')](_0x5e443b[_0xab5f('0x34')],qs[_0xab5f('0x3b')](_0x2b5605[_0xab5f('0x37')]['fields']));_0x2ca740[_0xab5f('0x3a')]=_0x2ca740[_0xab5f('0x3a')][_0xab5f('0x3c')]?_0x2ca740[_0xab5f('0x3a')]:_0x5e443b[_0xab5f('0x34')];if(!_0x2b5605[_0xab5f('0x37')][_0xab5f('0x3d')](_0xab5f('0x3e'))){_0x2ca740[_0xab5f('0x22')]=qs[_0xab5f('0x22')](_0x2b5605['query'][_0xab5f('0x22')]);_0x2ca740[_0xab5f('0x20')]=qs[_0xab5f('0x20')](_0x2b5605['query']['offset']);}_0x2ca740['order']=qs[_0xab5f('0x3f')](_0x2b5605[_0xab5f('0x37')][_0xab5f('0x3f')]);_0x2ca740[_0xab5f('0x40')]=qs['filters'](_['pick'](_0x2b5605[_0xab5f('0x37')],_0x5e443b['filters']),_0x24b4c6);if(_0x2b5605['query'][_0xab5f('0x41')]){_0x2ca740['where']=_[_0xab5f('0x42')](_0x2ca740[_0xab5f('0x40')],{'$or':_['map'](_0x24b4c6,function(_0x2f7570){if(_0x2f7570['type']!=='VIRTUAL'){var _0x1c3512={};_0x1c3512[_0x2f7570[_0xab5f('0x36')]]={'$like':'%'+_0x2b5605[_0xab5f('0x37')][_0xab5f('0x41')]+'%'};return _0x1c3512;}})});}_0x2ca740=_[_0xab5f('0x42')]({},_0x2ca740,_0x2b5605[_0xab5f('0x43')]);var _0x25a147={'where':_0x2ca740[_0xab5f('0x40')]};return db[_0xab5f('0x44')]['count'](_0x25a147)['then'](function(_0x3a486f){_0x5d29e6[_0xab5f('0x23')]=_0x3a486f;if(_0x2b5605[_0xab5f('0x37')]['includeAll']){_0x2ca740[_0xab5f('0x45')]=[{'all':!![]}];}return db[_0xab5f('0x44')][_0xab5f('0x46')](_0x2ca740);})[_0xab5f('0x2a')](function(_0x2ecbc7){_0x5d29e6[_0xab5f('0x47')]=_0x2ecbc7;return _0x5d29e6;})['then'](respondWithFilteredResult(_0x5f57d9,_0x2ca740))[_0xab5f('0x48')](handleError(_0x5f57d9,null));};exports[_0xab5f('0x49')]=function(_0x4aae89,_0x56c2ff){var _0x54912a={'raw':![],'where':{'id':_0x4aae89['params']['id']}},_0x2646e7={};_0x2646e7[_0xab5f('0x34')]=_[_0xab5f('0x4a')](db[_0xab5f('0x44')][_0xab5f('0x30')]);_0x2646e7['query']=_[_0xab5f('0x4a')](_0x4aae89[_0xab5f('0x37')]);_0x2646e7[_0xab5f('0x38')]=_[_0xab5f('0x39')](_0x2646e7[_0xab5f('0x34')],_0x2646e7[_0xab5f('0x37')]);_0x54912a[_0xab5f('0x3a')]=_[_0xab5f('0x39')](_0x2646e7[_0xab5f('0x34')],qs['fields'](_0x4aae89['query'][_0xab5f('0x3b')]));_0x54912a['attributes']=_0x54912a[_0xab5f('0x3a')][_0xab5f('0x3c')]?_0x54912a[_0xab5f('0x3a')]:_0x2646e7['model'];if(_0x4aae89[_0xab5f('0x37')]['includeAll']){_0x54912a[_0xab5f('0x45')]=[{'all':!![]}];}_0x54912a=_['merge']({},_0x54912a,_0x4aae89[_0xab5f('0x43')]);return db[_0xab5f('0x44')][_0xab5f('0x4b')](_0x54912a)[_0xab5f('0x2a')](handleEntityNotFound(_0x56c2ff,null))[_0xab5f('0x2a')](respondWithResult(_0x56c2ff,null))[_0xab5f('0x48')](handleError(_0x56c2ff,null));};exports['create']=function(_0x3897b4,_0x5d3341){return db[_0xab5f('0x44')][_0xab5f('0x4c')](_0x3897b4[_0xab5f('0x4d')],{})['then'](respondWithResult(_0x5d3341,0xc9))[_0xab5f('0x48')](handleError(_0x5d3341,null));};exports[_0xab5f('0x29')]=function(_0x49260c,_0x321738){if(_0x49260c[_0xab5f('0x4d')]['id']){delete _0x49260c[_0xab5f('0x4d')]['id'];}return db[_0xab5f('0x44')][_0xab5f('0x4b')]({'where':{'id':_0x49260c[_0xab5f('0x4e')]['id']}})[_0xab5f('0x2a')](handleEntityNotFound(_0x321738,null))[_0xab5f('0x2a')](saveUpdates(_0x49260c[_0xab5f('0x4d')],null))[_0xab5f('0x2a')](respondWithResult(_0x321738,null))[_0xab5f('0x48')](handleError(_0x321738,null));};exports[_0xab5f('0x4f')]=function(_0x1d6b00,_0x1346d3){return db['VoiceRecording'][_0xab5f('0x4f')]()[_0xab5f('0x2a')](respondWithResult(_0x1346d3,null))[_0xab5f('0x48')](handleError(_0x1346d3,null));};exports['download']=function(_0x3c01ab,_0x427ae8,_0x5ef0ca){var _0x312e47=require('../../components/encryptor');var _0x499ac8=![];var _0x2b2816={};if(_0x3c01ab[_0xab5f('0x37')][_0xab5f('0x32')]&&_0x3c01ab[_0xab5f('0x37')][_0xab5f('0x32')]===_0xab5f('0x50')){_0x2b2816['uniqueid']=_0x3c01ab[_0xab5f('0x4e')]['id'];}else{_0x2b2816['id']=_0x3c01ab['params']['id'];}return db[_0xab5f('0x44')][_0xab5f('0x4b')]({'where':_0x2b2816,'attributes':['id',_0xab5f('0x51')],'raw':!![]})[_0xab5f('0x2a')](handleEntityNotFound(_0x427ae8,null))[_0xab5f('0x2a')](function(_0x17b9f6){if(_0x17b9f6){var _0x3d195b=_0x17b9f6[_0xab5f('0x51')];var _0x427b86=util[_0xab5f('0x52')](_0xab5f('0x53'),_0x3d195b);if(fs['existsSync'](_0x427b86)){_0x499ac8=!![];return _0x312e47[_0xab5f('0x54')](_0x427b86,_0x3d195b,config[_0xab5f('0x55')][_0xab5f('0x56')])['then'](function(){return _0x17b9f6;});}return _0x17b9f6;}})[_0xab5f('0x2a')](function(_0x49838c){if(_0x49838c){var _0x81801b=_0x49838c[_0xab5f('0x51')];if(!fs[_0xab5f('0x57')](_0x81801b)){throw new db[(_0xab5f('0x58'))][(_0xab5f('0x59'))](_0xab5f('0x5a'));}if(_0x49838c[_0xab5f('0x5b')]){return _0x427ae8[_0xab5f('0x5c')](_0x81801b,_0x49838c[_0xab5f('0x5b')]+path[_0xab5f('0x5d')](_0x81801b),function(){if(_0x499ac8){fs[_0xab5f('0x5e')](_0x81801b);}});}else{return _0x427ae8['download'](_0x81801b,function(_0x129235){if(_0x499ac8){fs['unlink'](_0x81801b);}});}}})[_0xab5f('0x48')](function(_0x2b9d96){if(_0x2b9d96[_0xab5f('0x5f')]===_0xab5f('0x5a')){_0x427ae8[_0xab5f('0x24')](0x194)[_0xab5f('0x60')](_0xab5f('0x61'));}else{return handleError(_0x427ae8,null);}});};exports[_0xab5f('0x62')]=function(_0x3679f0,_0xd6c17,_0x102667){var _0x619fb7=require(_0xab5f('0x63'));var _0x2d4e32=![];var _0x535e69={'$and':[db[_0xab5f('0x64')][_0xab5f('0x40')](db[_0xab5f('0x64')]['fn'](_0xab5f('0x65'),db[_0xab5f('0x64')][_0xab5f('0x66')](_0xab5f('0x50'))),_0x3679f0[_0xab5f('0x37')][_0xab5f('0x67')])]};if(_0x3679f0[_0xab5f('0x37')][_0xab5f('0x32')]&&_0x3679f0[_0xab5f('0x37')][_0xab5f('0x32')]===_0xab5f('0x50')){_0x535e69[_0xab5f('0x68')][_0xab5f('0x69')]({'uniqueid':_0x3679f0[_0xab5f('0x4e')]['id']});}else{_0x535e69[_0xab5f('0x68')][_0xab5f('0x69')]({'id':_0x3679f0[_0xab5f('0x4e')]['id']});}return db[_0xab5f('0x44')][_0xab5f('0x4b')]({'where':_0x535e69,'attributes':['id',_0xab5f('0x51')],'raw':!![]})[_0xab5f('0x2a')](handleEntityNotFound(_0xd6c17,null))['then'](function(_0x9a33b6){if(_0x9a33b6){var _0x5c8822=util[_0xab5f('0x52')](_0xab5f('0x53'),_0x9a33b6[_0xab5f('0x51')]);if(fs[_0xab5f('0x57')](_0x5c8822)){_0x2d4e32=!![];return _0x619fb7['decryptFile'](_0x5c8822,_0x9a33b6[_0xab5f('0x51')],config[_0xab5f('0x55')][_0xab5f('0x56')])['then'](function(){return _0x9a33b6;});}return _0x9a33b6;}})[_0xab5f('0x2a')](function(_0xc4f73a){if(_0xc4f73a){if(!fs[_0xab5f('0x57')](_0xc4f73a[_0xab5f('0x51')])){throw new db[(_0xab5f('0x58'))][(_0xab5f('0x59'))]('VoiceRecording\x20not\x20found');}if(_0xc4f73a[_0xab5f('0x5b')]){return _0xd6c17[_0xab5f('0x5c')](_0xc4f73a[_0xab5f('0x51')],_0xc4f73a[_0xab5f('0x5b')]+path[_0xab5f('0x5d')](_0xc4f73a['value']),function(){if(_0x2d4e32){fs[_0xab5f('0x5e')](_0xc4f73a[_0xab5f('0x51')]);}});}else{return _0xd6c17['download'](_0xc4f73a[_0xab5f('0x51')],function(_0x2171d7){if(_0x2d4e32){fs[_0xab5f('0x5e')](_0xc4f73a[_0xab5f('0x51')]);}});}}})['catch'](handleError(_0xd6c17,null));};exports[_0xab5f('0x2b')]=function(_0x5b4ade,_0x5c5a88){return db[_0xab5f('0x44')]['find']({'where':{'id':_0x5b4ade[_0xab5f('0x4e')]['id']}})[_0xab5f('0x2a')](function(_0xd3c60f){if(_[_0xab5f('0x6a')](_0xd3c60f)){throw new ReferenceError(_0xab5f('0x6b'));}return _0xd3c60f;})[_0xab5f('0x2a')](function(_0x1f1bda){var _0x51a731=_0x1f1bda[_0xab5f('0x51')];logger[_0xab5f('0x6c')](_0xab5f('0x6d'),_0x51a731);if(!_['isNil'](_0x1f1bda[_0xab5f('0x51')])&&fs[_0xab5f('0x57')](_0x51a731)){logger[_0xab5f('0x6c')](_0xab5f('0x6e')+_0x51a731+_0xab5f('0x6f'));fs['unlinkSync'](_0x51a731);}_0x51a731=_0x51a731+_0xab5f('0x70');if(!_['isNil'](_0x1f1bda['value'])&&fs[_0xab5f('0x57')](_0x51a731)){logger[_0xab5f('0x6c')](_0xab5f('0x6e')+_0x51a731+_0xab5f('0x6f'));fs[_0xab5f('0x71')](_0x51a731);}return _0x1f1bda;})[_0xab5f('0x2a')](function(_0x2d4df0){if(!_0x2d4df0)throw new InternalError();return _0x2d4df0['destroy']();})['then'](function(){_0x5c5a88['status'](0xcc)[_0xab5f('0x1f')]();})[_0xab5f('0x48')](handleError(_0x5c5a88,null));};function getBucketslist(_0x33c58d,_0x39c8f3,_0x185e5f){return new Promise(function(_0x1a5bce,_0xc5285d){var _0x2d877d=new AWS['S3']({'accessKeyId':_0x39c8f3,'secretAccessKey':_0x33c58d,'region':_0x185e5f});_0x2d877d['listBuckets']({},function(_0x419380,_0x17e541){if(_0x419380){return _0xc5285d(_0x419380);}else{return _0x1a5bce(_0x17e541);}});});}function createBucket(_0x19d715,_0x10722e,_0x1ffc68,_0x30ac48){return new Promise(function(_0x1acd3a,_0x22cc3c){var _0x5a5c96=new AWS['S3']({'accessKeyId':_0x10722e,'secretAccessKey':_0x19d715,'region':_0x1ffc68});_0x5a5c96['createBucket']({'Bucket':_0x30ac48},function(_0x571bbb,_0x14ae73){if(_0x571bbb){return _0x22cc3c(_0x571bbb);}else{return _0x1acd3a(_0x14ae73);}});});}function uploadFile(_0x518855,_0x19b723,_0x1e212b,_0x43f9a4,_0x24a6f6,_0x3699a4){return new Promise(function(_0x6dd270,_0x4b6843){var _0x44603a=new AWS['S3']({'accessKeyId':_0x19b723,'secretAccessKey':_0x518855,'region':_0x1e212b});_0x44603a[_0xab5f('0x72')]({'Bucket':_0x43f9a4,'Key':_0x24a6f6,'Body':_0x3699a4},function(_0x3cf8a5,_0x4c7ae2){if(_0x3cf8a5){return _0x4b6843(_0x3cf8a5);}else{return _0x6dd270(_0x4c7ae2);}});});}function startTranscribe(_0x2c4fab,_0x265d9a,_0x440b27,_0x2a6a19,_0x2c5a90,_0x127382){return new Promise(function(_0x3ffab7,_0x5d38a8){var _0x3128fd=new AWS[(_0xab5f('0x73'))]({'accessKeyId':_0x265d9a,'secretAccessKey':_0x2c4fab,'region':_0x440b27});_0x3128fd[_0xab5f('0x74')]({'TranscriptionJobName':_0x2a6a19,'LanguageCode':_0x2c5a90,'Media':{'MediaFileUri':_0x127382}},function(_0x281783,_0x37aac3){if(_0x281783){return _0x5d38a8(_0x281783);}else{return _0x3ffab7(_0x37aac3);}});});}function transcribe(_0x2e7ed0,_0x1ea5db,_0x2c3056,_0x1c0966,_0x4058bd,_0x2a2370,_0xa2a2bc){return new Promise(function(_0x4d663d,_0x359f8f){var _0x3816ba={};logger['info'](util[_0xab5f('0x52')](_0xab5f('0x75'),_0x2e7ed0,_0x4058bd));return uploadFile(_0x1ea5db,_0x2c3056,_0x1c0966,_0x4058bd,path[_0xab5f('0x76')](_0x2a2370),fs[_0xab5f('0x77')](_0x2a2370))[_0xab5f('0x2a')](function(_0x72af17){logger['info'](util[_0xab5f('0x52')](_0xab5f('0x78'),_0x2e7ed0,_0x4058bd,_0x72af17['Location']));_0x3816ba[_0xab5f('0x79')]=_0x72af17[_0xab5f('0x7a')];_0x3816ba[_0xab5f('0x7b')]=_0x72af17[_0xab5f('0x7c')];logger['info'](util[_0xab5f('0x52')](_0xab5f('0x7d'),_0x2e7ed0));return startTranscribe(_0x1ea5db,_0x2c3056,_0x1c0966,uuidv4(),_0xa2a2bc,_0x72af17['Location']);})[_0xab5f('0x2a')](function(_0x5e4ac3){logger['info'](util[_0xab5f('0x52')]('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0x2e7ed0,_0x5e4ac3[_0xab5f('0x7e')][_0xab5f('0x7f')]));_0x3816ba[_0xab5f('0x80')]=_0x5e4ac3[_0xab5f('0x7e')][_0xab5f('0x7f')];_0x3816ba[_0xab5f('0x81')]=_0x5e4ac3[_0xab5f('0x7e')][_0xab5f('0x82')];return _0x4d663d(_0x3816ba);})[_0xab5f('0x48')](function(_0x274d75){return _0x359f8f(_0x274d75);});});}exports[_0xab5f('0x83')]=function(_0x25255a,_0x40c69f,_0x5770a9){var _0x1cd0d3;var _0x530d06;var _0x3e3328;var _0x22e26b=require(_0xab5f('0x63'));return db['VoiceRecording'][_0xab5f('0x84')]({'where':{'id':_0x25255a[_0xab5f('0x4e')]['id']}})['then'](function(_0x323177){if(_0x323177){var _0x3208d0=util[_0xab5f('0x52')](_0xab5f('0x53'),_0x323177[_0xab5f('0x51')]);if(fs['existsSync'](_0x3208d0)){cypher=!![];return _0x22e26b[_0xab5f('0x54')](_0x3208d0,_0x323177['value'],config[_0xab5f('0x55')][_0xab5f('0x56')])[_0xab5f('0x2a')](function(){return _0x323177;});}return _0x323177;}})[_0xab5f('0x2a')](function(_0xf4bea0){if(!_0xf4bea0){throw new db[(_0xab5f('0x58'))][(_0xab5f('0x59'))](_0xab5f('0x85'));}_0x530d06=_0xf4bea0;return db[_0xab5f('0x86')][_0xab5f('0x84')]({'where':{'id':0x1}});})[_0xab5f('0x2a')](handleEntityNotFound(_0x40c69f,null))['then'](function(_0x2927eb){if(_0x2927eb){_0x1cd0d3=_0x2927eb;if(!_0x1cd0d3[_0xab5f('0x87')]||!_0x1cd0d3[_0xab5f('0x88')]||!_0x1cd0d3[_0xab5f('0x89')]||!_0x1cd0d3['language']||!_0x1cd0d3[_0xab5f('0x79')]){throw new db['Sequelize'][(_0xab5f('0x59'))](_0xab5f('0x8a'));}if(_0x25255a[_0xab5f('0x4d')][_0xab5f('0x8b')]&&(!_0x1cd0d3[_0xab5f('0x8c')]||!_0x1cd0d3[_0xab5f('0x8d')]||!_0x1cd0d3[_0xab5f('0x8e')]||!_0x1cd0d3[_0xab5f('0x8f')]||!_0x1cd0d3['bucket'])){throw new db['Sequelize'][(_0xab5f('0x59'))](_0xab5f('0x90'));}return db[_0xab5f('0x91')][_0xab5f('0x84')]({'where':{'id':_0x1cd0d3['transcribeAccountId']}});}})['then'](function(_0x32542b){if(!_0x32542b){throw new db[(_0xab5f('0x58'))][(_0xab5f('0x59'))](_0xab5f('0x92'));}if(!_0x32542b[_0xab5f('0x93')]||!_0x32542b[_0xab5f('0x94')]){throw new db[(_0xab5f('0x58'))]['ValidationError'](_0xab5f('0x95'));}_0x3e3328=_0x32542b;return getBucketslist(_0x3e3328[_0xab5f('0x93')],_0x3e3328[_0xab5f('0x94')],_0x1cd0d3['transcribeRegion']);})['then'](function(_0x9223b2){if(_0x9223b2&&_0x9223b2['Buckets']){var _0x40a04b=_[_0xab5f('0x4b')](_0x9223b2[_0xab5f('0x96')],function(_0x1bdca3){return _0x1bdca3[_0xab5f('0x97')]===_0x1cd0d3[_0xab5f('0x79')];});if(!_0x40a04b){logger[_0xab5f('0x6c')](util[_0xab5f('0x52')]('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available',_0x25255a['params']['id'],_0x1cd0d3[_0xab5f('0x79')]));return createBucket(_0x3e3328[_0xab5f('0x93')],_0x3e3328[_0xab5f('0x94')],_0x1cd0d3[_0xab5f('0x89')],_0x1cd0d3['bucket']);}logger['info'](util[_0xab5f('0x52')](_0xab5f('0x98'),_0x25255a['params']['id'],_0x1cd0d3[_0xab5f('0x79')]));return;}})['then'](function(_0x24c2c2){if(_0x530d06[_0xab5f('0x81')]==='NEW'){return transcribe(_0x25255a[_0xab5f('0x4e')]['id'],_0x3e3328[_0xab5f('0x93')],_0x3e3328[_0xab5f('0x94')],_0x1cd0d3['transcribeRegion'],_0x1cd0d3[_0xab5f('0x79')],_0x530d06[_0xab5f('0x51')],_0x1cd0d3['language']);}else{logger[_0xab5f('0x6c')](util[_0xab5f('0x52')](_0xab5f('0x99'),_0x25255a[_0xab5f('0x4e')]['id']));return{'transcribeStatus':_0xab5f('0x9a')};}})[_0xab5f('0x2a')](function(_0x2bf85){if(_0x2bf85){_0x2bf85['tempSentiment']=_0x25255a[_0xab5f('0x4d')][_0xab5f('0x8b')];return _0x530d06[_0xab5f('0x9b')](_0x2bf85);}})[_0xab5f('0x2a')](respondWithResult(_0x40c69f,null))[_0xab5f('0x48')](handleError(_0x40c69f,null));};function writeFile(_0x2fc40b,_0x97657e){return new Promise(function(_0x45b5b5,_0x1bc8ec){fs['writeFile'](_0x97657e,_0x2fc40b,function(_0x2df457,_0xe92a9c){if(_0x2df457){return _0x1bc8ec(_0x2df457);}else{return _0x45b5b5(_0xe92a9c);}});});}exports[_0xab5f('0x9c')]=function(_0x161252,_0x492c68,_0x390108){return db[_0xab5f('0x44')]['findOne']({'where':{'id':_0x161252[_0xab5f('0x4e')]['id']}})[_0xab5f('0x2a')](handleEntityNotFound(_0x492c68))[_0xab5f('0x2a')](function(_0x3c196e){if(_0x3c196e&&_0x3c196e['fileText']){var _0x2efbec=_0x3c196e[_0xab5f('0x9d')];var _0x6a5d96=config[_0xab5f('0x9e')]+_0xab5f('0x9f')+_0x3c196e['id']+'.txt';if(fs[_0xab5f('0x57')](_0x6a5d96)){return _0x6a5d96;}return writeFile(_0x2efbec,_0x6a5d96)[_0xab5f('0x2a')](function(){return _0x6a5d96;});}else{throw new db[(_0xab5f('0x58'))][(_0xab5f('0x59'))](_0xab5f('0xa0'));}})[_0xab5f('0x2a')](function(_0x2867ee){return _0x492c68[_0xab5f('0x5c')](_0x2867ee);})['catch'](handleError(_0x492c68));};
\ No newline at end of file