Built motion from commit be44e1e4d16f8b29d243415b03d27262d8601e0e. Version 3.0.0...
[motion-next.git] / server / api / voiceRecording / voiceRecording.controller.js
1 const a771_0x3591=['params','sentimentAccountId','update','transcribeName','describe','readFileSync','map','attributes','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','col','filters','Setting','transcribeRegion','findOne','File:\x20\x22','undefined','recording','transcribeStatus','ValidationError','merge','options','transcribeAccountId','Sentiment\x20Analysis\x20not\x20configured','VoiceRecording','nolimit','writeFile','json','MD5','includeAll','offset','VoiceRecording\x20not\x20found','unlink','sentimentRegion','downloadTranscribe','Entity\x20not\x20found','tempSentiment','format','length','and','status','language','push','type','TranscriptionJobName','api','uniqueid','Name','../../components/encryptor','sentiment','bucket','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','listBuckets','isNil','download','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','path','data1','where','query','find','body','create','catch','Not\x20found','sequelize','index','count','runTranscribe','Transcribe\x20not\x20configured','fields','uuid','extname','Buckets','transcribe','include','CloudProvider','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','decryptFile','error','%s.cypher','name','limit','then','Sequelize','intersection','.cypher','VIRTUAL','info','value','Content-Range','send','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','/server/files/transcribes/transcribe_','runSentiment','startTranscriptionJob','show','createBucket','data2','.txt','Bucket','model','existsSync','secrets','order','location','TranscriptionJobStatus','keys','../../config/environment','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','TranscribeService','rawAttributes','token','findAll','destroy','lodash','util','TranscriptionJob','filename','sort','unlinkSync'];(function(_0x20dc9e,_0x359171){const _0x96e086=function(_0x2878ed){while(--_0x2878ed){_0x20dc9e['push'](_0x20dc9e['shift']());}};_0x96e086(++_0x359171);}(a771_0x3591,0x186));const a771_0x96e0=function(_0x20dc9e,_0x359171){_0x20dc9e=_0x20dc9e-0x0;let _0x96e086=a771_0x3591[_0x20dc9e];return _0x96e086;};const _0x213fff=a771_0x96e0;'use strict';const util=require(_0x213fff('0x55')),path=require(_0x213fff('0x19')),fs=require('fs'),_=require(_0x213fff('0x54')),AWS=require('aws-sdk'),{v4:uuidv4}=require(_0x213fff('0x28')),qs=require('../../components/parsers/qs'),logger=require('../../config/logger')(_0x213fff('0xe')),config=require(_0x213fff('0x4d')),db=require('../../mysqldb')['db'],{Op}=require(_0x213fff('0x22')),{InternalError}=require('error-middleware/errors');function respondWithResult(_0x2878ed,_0x1534fc){return _0x1534fc=_0x1534fc||0xc8,function(_0x4f4e02){const _0x1da020=a771_0x96e0;if(_0x4f4e02)return _0x2878ed[_0x1da020('0x9')](_0x1534fc)[_0x1da020('0x74')](_0x4f4e02);};}function respondWithFilteredResult(_0x5187ef,_0xc4c93b){return function(_0xc345bd){const _0x5b8227=a771_0x96e0;if(_0xc345bd){const _0x4c5b83=_0xc345bd['count'],_0x21aa86=_0xc4c93b[_0x5b8227('0x77')];let _0x72e60a=_0xc4c93b['offset']+_0xc4c93b[_0x5b8227('0x33')],_0x2498d4;return _0x72e60a>=_0x4c5b83?(_0x72e60a=_0x4c5b83,_0x2498d4=0xc8):_0x2498d4=0xce,_0x5187ef[_0x5b8227('0x9')](_0x2498d4),_0x5187ef['set'](_0x5b8227('0x3b'),_0x21aa86+'-'+_0x72e60a+'/'+_0x4c5b83)[_0x5b8227('0x74')](_0xc345bd);}return null;};}function saveUpdates(_0x238862){return function(_0x1ec74b){const _0x428cff=a771_0x96e0;if(_0x1ec74b)return _0x1ec74b['update'](_0x238862)[_0x428cff('0x34')](function(_0x3abbd1){return _0x3abbd1;});return null;};}function handleEntityNotFound(_0x23f82c){return function(_0x30fb2c){return!_0x30fb2c&&_0x23f82c['sendStatus'](0x194),_0x30fb2c;};}function handleError(_0x430327,_0x16e81c){return _0x16e81c=_0x16e81c||0x1f4,function(_0x1df893){const _0x387367=a771_0x96e0;logger[_0x387367('0x30')](_0x1df893['stack']),_0x1df893['name']&&delete _0x1df893[_0x387367('0x32')],_0x430327[_0x387367('0x9')](_0x16e81c)[_0x387367('0x3c')](_0x1df893);};}exports[_0x213fff('0x23')]=function(_0x3bcf45,_0x3f5fa0){const _0x48ca3d=_0x213fff;let _0x44a092={};const _0x109bb8={},_0xa20b62={'count':0x0,'rows':[]},_0x21d034=_[_0x48ca3d('0x60')](db[_0x48ca3d('0x71')][_0x48ca3d('0x50')],function(_0x3731e8){const _0x246bc2=_0x48ca3d;return{'name':_0x3731e8['fieldName'],'type':_0x3731e8[_0x246bc2('0xc')]['key']};});_0x109bb8[_0x48ca3d('0x46')]=_['differenceBy'](_[_0x48ca3d('0x60')](_0x21d034,'name'),[_0x48ca3d('0x6')]),_0x109bb8[_0x48ca3d('0x1c')]=_[_0x48ca3d('0x4c')](_0x3bcf45['query']),_0x109bb8[_0x48ca3d('0x64')]=_['intersection'](_0x109bb8['model'],_0x109bb8[_0x48ca3d('0x1c')]),_0x44a092['attributes']=_[_0x48ca3d('0x36')](_0x109bb8[_0x48ca3d('0x46')],qs[_0x48ca3d('0x27')](_0x3bcf45['query'][_0x48ca3d('0x27')])),_0x44a092[_0x48ca3d('0x61')]=_0x44a092[_0x48ca3d('0x61')]['length']?_0x44a092[_0x48ca3d('0x61')]:_0x109bb8[_0x48ca3d('0x46')];typeof _0x3bcf45[_0x48ca3d('0x1c')][_0x48ca3d('0x72')]===_0x48ca3d('0x69')&&(_0x44a092['limit']=qs[_0x48ca3d('0x33')](_0x3bcf45[_0x48ca3d('0x1c')][_0x48ca3d('0x33')]),_0x44a092[_0x48ca3d('0x77')]=qs[_0x48ca3d('0x77')](_0x3bcf45['query'][_0x48ca3d('0x77')]));_0x44a092[_0x48ca3d('0x49')]=qs[_0x48ca3d('0x58')](_0x3bcf45[_0x48ca3d('0x1c')][_0x48ca3d('0x58')]),_0x44a092['where']=qs[_0x48ca3d('0x64')](_['pick'](_0x3bcf45[_0x48ca3d('0x1c')],_0x109bb8['filters']),_0x21d034);_0x3bcf45['query']['filter']&&(_0x44a092[_0x48ca3d('0x1b')]=_['merge'](_0x44a092[_0x48ca3d('0x1b')],{[Op['or']]:_['map'](_0x21d034,function(_0x3f8b93){const _0x5d8e89=_0x48ca3d;if(_0x3f8b93[_0x5d8e89('0xc')]!==_0x5d8e89('0x38')){const _0x29fa95={};return _0x29fa95[_0x3f8b93[_0x5d8e89('0x32')]]={[Op['like']]:'%'+_0x3bcf45[_0x5d8e89('0x1c')]['filter']+'%'},_0x29fa95;}})}));_0x44a092=_['merge']({},_0x44a092,_0x3bcf45['options']);const _0x1c787c={'where':_0x44a092[_0x48ca3d('0x1b')]};return db[_0x48ca3d('0x71')][_0x48ca3d('0x24')](_0x1c787c)[_0x48ca3d('0x34')](function(_0x49d5b4){const _0xed51d4=_0x48ca3d;return _0xa20b62[_0xed51d4('0x24')]=_0x49d5b4,_0x3bcf45[_0xed51d4('0x1c')]['includeAll']&&(_0x44a092['include']=[{'all':!![]}]),db[_0xed51d4('0x71')][_0xed51d4('0x52')](_0x44a092);})['then'](function(_0x174815){return _0xa20b62['rows']=_0x174815,_0xa20b62;})[_0x48ca3d('0x34')](respondWithFilteredResult(_0x3f5fa0,_0x44a092))[_0x48ca3d('0x20')](handleError(_0x3f5fa0,null));},exports[_0x213fff('0x41')]=function(_0x793eb,_0x1c6eb9){const _0x16ec01=_0x213fff;let _0x2035f1={'raw':![],'where':{'id':_0x793eb[_0x16ec01('0x5a')]['id']}};const _0x30681d={};return _0x30681d[_0x16ec01('0x46')]=_[_0x16ec01('0x4c')](db[_0x16ec01('0x71')][_0x16ec01('0x50')]),_0x30681d[_0x16ec01('0x1c')]=_[_0x16ec01('0x4c')](_0x793eb['query']),_0x30681d[_0x16ec01('0x64')]=_[_0x16ec01('0x36')](_0x30681d['model'],_0x30681d[_0x16ec01('0x1c')]),_0x2035f1['attributes']=_[_0x16ec01('0x36')](_0x30681d[_0x16ec01('0x46')],qs[_0x16ec01('0x27')](_0x793eb[_0x16ec01('0x1c')][_0x16ec01('0x27')])),_0x2035f1[_0x16ec01('0x61')]=_0x2035f1['attributes'][_0x16ec01('0x7')]?_0x2035f1['attributes']:_0x30681d[_0x16ec01('0x46')],_0x793eb['query'][_0x16ec01('0x76')]&&(_0x2035f1[_0x16ec01('0x2c')]=[{'all':!![]}]),_0x2035f1=_[_0x16ec01('0x6d')]({},_0x2035f1,_0x793eb[_0x16ec01('0x6e')]),db[_0x16ec01('0x71')][_0x16ec01('0x67')](_0x2035f1)[_0x16ec01('0x34')](handleEntityNotFound(_0x1c6eb9,null))[_0x16ec01('0x34')](respondWithResult(_0x1c6eb9,null))['catch'](handleError(_0x1c6eb9,null));},exports[_0x213fff('0x1f')]=function(_0x27808f,_0xea8c40){const _0x23ac6c=_0x213fff;return db[_0x23ac6c('0x71')][_0x23ac6c('0x1f')](_0x27808f[_0x23ac6c('0x1e')],{})[_0x23ac6c('0x34')](respondWithResult(_0xea8c40,0xc9))[_0x23ac6c('0x20')](handleError(_0xea8c40,null));},exports[_0x213fff('0x5c')]=function(_0x296f4e,_0x23fac7){const _0x885369=_0x213fff;return _0x296f4e[_0x885369('0x1e')]['id']&&delete _0x296f4e[_0x885369('0x1e')]['id'],db[_0x885369('0x71')]['findOne']({'where':{'id':_0x296f4e[_0x885369('0x5a')]['id']}})[_0x885369('0x34')](handleEntityNotFound(_0x23fac7,null))[_0x885369('0x34')](saveUpdates(_0x296f4e[_0x885369('0x1e')],null))[_0x885369('0x34')](respondWithResult(_0x23fac7,null))[_0x885369('0x20')](handleError(_0x23fac7,null));},exports[_0x213fff('0x5e')]=function(_0x25d61f,_0xf66fa2){const _0x437d2f=_0x213fff;return db['VoiceRecording']['describe']()[_0x437d2f('0x34')](respondWithResult(_0xf66fa2,null))[_0x437d2f('0x20')](handleError(_0xf66fa2,null));},exports[_0x213fff('0x17')]=function(_0x4b12e6,_0x26cd52){const _0x5d0baa=_0x213fff,_0x1ddd65=require(_0x5d0baa('0x11'));let _0x226519=![];const _0x4e4b77={};return _0x4b12e6[_0x5d0baa('0x1c')]['type']&&_0x4b12e6[_0x5d0baa('0x1c')][_0x5d0baa('0xc')]===_0x5d0baa('0xf')?_0x4e4b77[_0x5d0baa('0xf')]=_0x4b12e6[_0x5d0baa('0x5a')]['id']:_0x4e4b77['id']=_0x4b12e6[_0x5d0baa('0x5a')]['id'],db[_0x5d0baa('0x71')][_0x5d0baa('0x67')]({'where':_0x4e4b77,'attributes':['id',_0x5d0baa('0x3a')],'raw':!![]})['then'](handleEntityNotFound(_0x26cd52,null))[_0x5d0baa('0x34')](function(_0x3b8721){const _0x53a47f=_0x5d0baa;if(_0x3b8721){const _0x4dacbb=_0x3b8721['value'],_0x4bd24d=util['format']('%s.cypher',_0x4dacbb);if(fs['existsSync'](_0x4bd24d))return _0x226519=!![],_0x1ddd65[_0x53a47f('0x2f')](_0x4bd24d,_0x4dacbb,config['secrets'][_0x53a47f('0x6a')])['then'](function(){return _0x3b8721;});return _0x3b8721;}})['then'](function(_0x49121f){const _0x41f4f1=_0x5d0baa;if(_0x49121f){const _0x2b07f4=_0x49121f[_0x41f4f1('0x3a')];if(!fs['existsSync'](_0x2b07f4))throw new db['Sequelize'][(_0x41f4f1('0x6c'))](_0x41f4f1('0x0'));return _0x49121f[_0x41f4f1('0x57')]?_0x26cd52[_0x41f4f1('0x17')](_0x2b07f4,_0x49121f[_0x41f4f1('0x57')]+path[_0x41f4f1('0x29')](_0x2b07f4),function(){_0x226519&&fs['unlink'](_0x2b07f4);}):_0x26cd52[_0x41f4f1('0x17')](_0x2b07f4,function(){_0x226519&&fs['unlink'](_0x2b07f4);});}})[_0x5d0baa('0x20')](function(_0x3d7117){const _0x373d9f=_0x5d0baa;if(_0x3d7117['message']===_0x373d9f('0x0'))_0x26cd52[_0x373d9f('0x9')](0x194)[_0x373d9f('0x3c')](_0x373d9f('0x21'));else return handleError(_0x26cd52,null);});},exports['downloads']=function(_0x89193c,_0x1d546d){const _0x80d602=_0x213fff,_0x230fc9=require('../../components/encryptor');let _0x2aa178=![];const _0x3f58db={[Op[_0x80d602('0x8')]]:[db['sequelize'][_0x80d602('0x1b')](db['sequelize']['fn'](_0x80d602('0x75'),db[_0x80d602('0x22')][_0x80d602('0x63')](_0x80d602('0xf'))),_0x89193c[_0x80d602('0x1c')][_0x80d602('0x51')])]};return _0x89193c[_0x80d602('0x1c')][_0x80d602('0xc')]&&_0x89193c[_0x80d602('0x1c')]['type']===_0x80d602('0xf')?_0x3f58db['$and']['push']({'uniqueid':_0x89193c[_0x80d602('0x5a')]['id']}):_0x3f58db['$and'][_0x80d602('0xb')]({'id':_0x89193c[_0x80d602('0x5a')]['id']}),db[_0x80d602('0x71')][_0x80d602('0x67')]({'where':_0x3f58db,'attributes':['id',_0x80d602('0x3a')],'raw':!![]})['then'](handleEntityNotFound(_0x1d546d,null))[_0x80d602('0x34')](function(_0xda1974){const _0x461b83=_0x80d602;if(_0xda1974){const _0x1511ec=util[_0x461b83('0x6')](_0x461b83('0x31'),_0xda1974[_0x461b83('0x3a')]);if(fs['existsSync'](_0x1511ec))return _0x2aa178=!![],_0x230fc9[_0x461b83('0x2f')](_0x1511ec,_0xda1974['value'],config[_0x461b83('0x48')][_0x461b83('0x6a')])[_0x461b83('0x34')](function(){return _0xda1974;});return _0xda1974;}})[_0x80d602('0x34')](function(_0x5027cc){const _0x2c7e9a=_0x80d602;if(_0x5027cc){if(!fs['existsSync'](_0x5027cc[_0x2c7e9a('0x3a')]))throw new db['Sequelize'][(_0x2c7e9a('0x6c'))]('VoiceRecording\x20not\x20found');return _0x5027cc['filename']?_0x1d546d[_0x2c7e9a('0x17')](_0x5027cc[_0x2c7e9a('0x3a')],_0x5027cc[_0x2c7e9a('0x57')]+path[_0x2c7e9a('0x29')](_0x5027cc[_0x2c7e9a('0x3a')]),function(){const _0x3139b0=_0x2c7e9a;_0x2aa178&&fs[_0x3139b0('0x1')](_0x5027cc[_0x3139b0('0x3a')]);}):_0x1d546d[_0x2c7e9a('0x17')](_0x5027cc['value'],function(){const _0x31b294=_0x2c7e9a;_0x2aa178&&fs[_0x31b294('0x1')](_0x5027cc[_0x31b294('0x3a')]);});}})[_0x80d602('0x20')](handleError(_0x1d546d,null));},exports[_0x213fff('0x53')]=function(_0x1d50ff,_0x4df7bd){const _0x595bd3=_0x213fff;return db['VoiceRecording'][_0x595bd3('0x67')]({'where':{'id':_0x1d50ff['params']['id']}})[_0x595bd3('0x34')](function(_0x3727b2){const _0x416b95=_0x595bd3;if(!_0x3727b2)throw new ReferenceError(_0x416b95('0x4'));return _0x3727b2;})['then'](function(_0x50b08c){const _0x3565b4=_0x595bd3;let _0x433b79=_0x50b08c[_0x3565b4('0x3a')];return logger[_0x3565b4('0x39')]('cancellazione\x20fisica\x20documento\x20%s',_0x433b79),!_[_0x3565b4('0x16')](_0x50b08c[_0x3565b4('0x3a')])&&fs['existsSync'](_0x433b79)&&(logger[_0x3565b4('0x39')]('File:\x20\x22'+_0x433b79+_0x3565b4('0x2e')),fs['unlinkSync'](_0x433b79)),_0x433b79=_0x433b79+_0x3565b4('0x37'),!_[_0x3565b4('0x16')](_0x50b08c[_0x3565b4('0x3a')])&&fs['existsSync'](_0x433b79)&&(logger[_0x3565b4('0x39')](_0x3565b4('0x68')+_0x433b79+_0x3565b4('0x2e')),fs[_0x3565b4('0x59')](_0x433b79)),_0x50b08c;})[_0x595bd3('0x34')](function(_0x37757f){const _0x4eecad=_0x595bd3;if(!_0x37757f)throw new InternalError();return _0x37757f[_0x4eecad('0x53')]();})[_0x595bd3('0x34')](function(){const _0x49394a=_0x595bd3;_0x4df7bd[_0x49394a('0x9')](0xcc)['end']();})['catch'](handleError(_0x4df7bd,null));};function getBucketslist(_0x502a6f,_0x4aa013,_0x4264a4){return new Promise(function(_0x1e6025,_0x59984b){const _0x5e8bbf=a771_0x96e0,_0x13b9d6=new AWS['S3']({'accessKeyId':_0x4aa013,'secretAccessKey':_0x502a6f,'region':_0x4264a4});_0x13b9d6[_0x5e8bbf('0x15')]({},function(_0x4da223,_0x5d2e6c){return _0x4da223?_0x59984b(_0x4da223):_0x1e6025(_0x5d2e6c);});});}function createBucket(_0x5e4733,_0x25c768,_0x10ac4d,_0x21d432){return new Promise(function(_0x2d1bb8,_0x5b035e){const _0x36aae2=a771_0x96e0,_0x1bc531=new AWS['S3']({'accessKeyId':_0x25c768,'secretAccessKey':_0x5e4733,'region':_0x10ac4d});_0x1bc531[_0x36aae2('0x42')]({'Bucket':_0x21d432},function(_0x2f61ef,_0x1a86f5){return _0x2f61ef?_0x5b035e(_0x2f61ef):_0x2d1bb8(_0x1a86f5);});});}function uploadFile(_0x32430b,_0x32726a,_0x36c955,_0x2e12bc,_0x14ca73,_0x56315c){return new Promise(function(_0x5a8dca,_0x36ebda){const _0x1473c3=new AWS['S3']({'accessKeyId':_0x32726a,'secretAccessKey':_0x32430b,'region':_0x36c955});_0x1473c3['upload']({'Bucket':_0x2e12bc,'Key':_0x14ca73,'Body':_0x56315c},function(_0x4c5e0,_0x51b6cd){return _0x4c5e0?_0x36ebda(_0x4c5e0):_0x5a8dca(_0x51b6cd);});});}function startTranscribe(_0x49882f,_0x2a6a82,_0x437772,_0x261cca,_0x55b048,_0x168faf){return new Promise(function(_0x2557de,_0x284dde){const _0xdc7ae4=a771_0x96e0,_0x860c10=new AWS[(_0xdc7ae4('0x4f'))]({'accessKeyId':_0x2a6a82,'secretAccessKey':_0x49882f,'region':_0x437772});_0x860c10[_0xdc7ae4('0x40')]({'TranscriptionJobName':_0x261cca,'LanguageCode':_0x55b048,'Media':{'MediaFileUri':_0x168faf}},function(_0x30c259,_0x4ad850){return _0x30c259?_0x284dde(_0x30c259):_0x2557de(_0x4ad850);});});}function transcribe(_0x489e37,_0x3bcbcb,_0x1f9efa,_0x109257,_0x3f43eb,_0x33e8af,_0x1b0843){return new Promise(function(_0x5c3b53,_0x43ec62){const _0x10839f=a771_0x96e0,_0x45f41b={};return logger[_0x10839f('0x39')](util[_0x10839f('0x6')]('[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s',_0x489e37,_0x3f43eb)),uploadFile(_0x3bcbcb,_0x1f9efa,_0x109257,_0x3f43eb,path['basename'](_0x33e8af),fs[_0x10839f('0x5f')](_0x33e8af))[_0x10839f('0x34')](function(_0x4af968){const _0x403aa6=_0x10839f;return logger[_0x403aa6('0x39')](util['format'](_0x403aa6('0x14'),_0x489e37,_0x3f43eb,_0x4af968['Location'])),_0x45f41b[_0x403aa6('0x13')]=_0x4af968[_0x403aa6('0x45')],_0x45f41b[_0x403aa6('0x4a')]=_0x4af968['Location'],logger[_0x403aa6('0x39')](util['format'](_0x403aa6('0x4e'),_0x489e37)),startTranscribe(_0x3bcbcb,_0x1f9efa,_0x109257,uuidv4(),_0x1b0843,_0x4af968['Location']);})[_0x10839f('0x34')](function(_0x4d49ed){const _0x1679e3=_0x10839f;return logger[_0x1679e3('0x39')](util['format'](_0x1679e3('0x3d'),_0x489e37,_0x4d49ed['TranscriptionJob'][_0x1679e3('0xd')])),_0x45f41b[_0x1679e3('0x5d')]=_0x4d49ed[_0x1679e3('0x56')][_0x1679e3('0xd')],_0x45f41b[_0x1679e3('0x6b')]=_0x4d49ed[_0x1679e3('0x56')][_0x1679e3('0x4b')],_0x5c3b53(_0x45f41b);})['catch'](function(_0x5251c6){return _0x43ec62(_0x5251c6);});});}exports[_0x213fff('0x25')]=function(_0x60a1fc,_0x34d2c0){const _0x3bd70d=_0x213fff;let _0x231e8a,_0xb77b98,_0x2d229e;const _0x264f87=require(_0x3bd70d('0x11'));return db['VoiceRecording'][_0x3bd70d('0x67')]({'where':{'id':_0x60a1fc[_0x3bd70d('0x5a')]['id']}})[_0x3bd70d('0x34')](function(_0x2caf2e){const _0x46691b=_0x3bd70d;if(_0x2caf2e){const _0x3e086c=util['format'](_0x46691b('0x31'),_0x2caf2e[_0x46691b('0x3a')]);if(fs[_0x46691b('0x47')](_0x3e086c))return _0x264f87[_0x46691b('0x2f')](_0x3e086c,_0x2caf2e[_0x46691b('0x3a')],config['secrets']['recording'])[_0x46691b('0x34')](function(){return _0x2caf2e;});return _0x2caf2e;}})[_0x3bd70d('0x34')](function(_0x3185a3){const _0x23b6fa=_0x3bd70d;if(!_0x3185a3)throw new db[(_0x23b6fa('0x35'))][(_0x23b6fa('0x6c'))]('Voice\x20Recording\x20not\x20found');return _0xb77b98=_0x3185a3,db[_0x23b6fa('0x65')][_0x23b6fa('0x67')]({'where':{'id':0x1}});})[_0x3bd70d('0x34')](handleEntityNotFound(_0x34d2c0,null))[_0x3bd70d('0x34')](function(_0x11fa11){const _0x314da8=_0x3bd70d;if(_0x11fa11){_0x231e8a=_0x11fa11;if(!_0x231e8a[_0x314da8('0x2b')]||!_0x231e8a[_0x314da8('0x6f')]||!_0x231e8a[_0x314da8('0x66')]||!_0x231e8a[_0x314da8('0xa')]||!_0x231e8a[_0x314da8('0x13')])throw new db[(_0x314da8('0x35'))][(_0x314da8('0x6c'))](_0x314da8('0x26'));if(_0x60a1fc[_0x314da8('0x1e')]['runSentiment']&&(!_0x231e8a[_0x314da8('0x12')]||!_0x231e8a[_0x314da8('0x5b')]||!_0x231e8a[_0x314da8('0x2')]||!_0x231e8a['language']||!_0x231e8a[_0x314da8('0x13')]))throw new db[(_0x314da8('0x35'))][(_0x314da8('0x6c'))](_0x314da8('0x70'));return db[_0x314da8('0x2d')][_0x314da8('0x67')]({'where':{'id':_0x231e8a['transcribeAccountId']}});}})[_0x3bd70d('0x34')](function(_0xc94308){const _0x2cfac0=_0x3bd70d;if(!_0xc94308)throw new db[(_0x2cfac0('0x35'))]['ValidationError']('Cloud\x20Provider\x20not\x20available');if(!_0xc94308[_0x2cfac0('0x1a')]||!_0xc94308[_0x2cfac0('0x43')])throw new db['Sequelize'][(_0x2cfac0('0x6c'))]('Cloud\x20Provider\x20not\x20configured');return _0x2d229e=_0xc94308,getBucketslist(_0x2d229e['data1'],_0x2d229e['data2'],_0x231e8a[_0x2cfac0('0x66')]);})[_0x3bd70d('0x34')](function(_0x307004){const _0xb074bc=_0x3bd70d;if(_0x307004&&_0x307004[_0xb074bc('0x2a')]){const _0x140945=_[_0xb074bc('0x1d')](_0x307004['Buckets'],function(_0x2922c5){const _0x1f45a2=_0xb074bc;return _0x2922c5[_0x1f45a2('0x10')]===_0x231e8a[_0x1f45a2('0x13')];});if(!_0x140945)return logger[_0xb074bc('0x39')](util['format'](_0xb074bc('0x18'),_0x60a1fc[_0xb074bc('0x5a')]['id'],_0x231e8a['bucket'])),createBucket(_0x2d229e[_0xb074bc('0x1a')],_0x2d229e['data2'],_0x231e8a[_0xb074bc('0x66')],_0x231e8a[_0xb074bc('0x13')]);logger[_0xb074bc('0x39')](util[_0xb074bc('0x6')](_0xb074bc('0x62'),_0x60a1fc[_0xb074bc('0x5a')]['id'],_0x231e8a[_0xb074bc('0x13')]));return;}})['then'](function(){const _0x2866f2=_0x3bd70d;return _0xb77b98[_0x2866f2('0x6b')]==='NEW'?transcribe(_0x60a1fc[_0x2866f2('0x5a')]['id'],_0x2d229e[_0x2866f2('0x1a')],_0x2d229e[_0x2866f2('0x43')],_0x231e8a[_0x2866f2('0x66')],_0x231e8a[_0x2866f2('0x13')],_0xb77b98[_0x2866f2('0x3a')],_0x231e8a['language']):(logger['info'](util[_0x2866f2('0x6')]('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x60a1fc[_0x2866f2('0x5a')]['id'])),{'transcribeStatus':'IN_PROGRESS'});})[_0x3bd70d('0x34')](function(_0x2e0864){const _0x5bac27=_0x3bd70d;if(_0x2e0864)return _0x2e0864[_0x5bac27('0x5')]=_0x60a1fc[_0x5bac27('0x1e')][_0x5bac27('0x3f')],_0xb77b98[_0x5bac27('0x5c')](_0x2e0864);})['then'](respondWithResult(_0x34d2c0,null))[_0x3bd70d('0x20')](handleError(_0x34d2c0,null));};function writeFile(_0x4d121b,_0xf94139){return new Promise(function(_0x4dc02d,_0x58a84a){const _0x982392=a771_0x96e0;fs[_0x982392('0x73')](_0xf94139,_0x4d121b,function(_0x65948f,_0x47f69e){return _0x65948f?_0x58a84a(_0x65948f):_0x4dc02d(_0x47f69e);});});}exports[_0x213fff('0x3')]=function(_0x16252d,_0x321998){const _0x35de6e=_0x213fff;return db[_0x35de6e('0x71')][_0x35de6e('0x67')]({'where':{'id':_0x16252d[_0x35de6e('0x5a')]['id']}})[_0x35de6e('0x34')](handleEntityNotFound(_0x321998))[_0x35de6e('0x34')](function(_0x4a9877){const _0x273fd3=_0x35de6e;if(_0x4a9877&&_0x4a9877['fileText']){const _0x41418e=_0x4a9877['fileText'],_0xdeb644=config['root']+_0x273fd3('0x3e')+_0x4a9877['id']+_0x273fd3('0x44');if(fs[_0x273fd3('0x47')](_0xdeb644))return _0xdeb644;return writeFile(_0x41418e,_0xdeb644)[_0x273fd3('0x34')](function(){return _0xdeb644;});}else throw new db[(_0x273fd3('0x35'))][(_0x273fd3('0x6c'))]('Transcript\x20not\x20available');})['then'](function(_0xa2372d){const _0x1b0f1f=_0x35de6e;return _0x321998[_0x1b0f1f('0x17')](_0xa2372d);})[_0x35de6e('0x20')](handleError(_0x321998));};