Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index 90ca57f..0f2af01 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x054f=['[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','transcribeStatus','IN_PROGRESS','tempSentiment','updateAttributes','writeFile','fileText','root','/server/files/transcribes/transcribe_','.txt','Transcript\x20not\x20available','rimraf','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','undefined','limit','count','offset','Content-Range','apply','save','update','then','destroy','end','stack','name','send','index','map','VoiceRecording','rawAttributes','fieldName','key','model','query','keys','filters','attributes','fields','length','nolimit','order','sort','where','pick','merge','type','VIRTUAL','filter','options','includeAll','findAll','rows','catch','params','intersection','include','find','create','body','describe','download','../../components/encryptor','uniqueid','value','%s.cypher','existsSync','decryptFile','secrets','recording','Sequelize','filename','extname','unlink','message','VoiceRecording\x20not\x20found','sequelize','MD5','col','token','push','ValidationError','info','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','isNil','File:\x20\x22','listBuckets','createBucket','TranscribeService','format','basename','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','bucket','Bucket','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','TranscriptionJob','TranscriptionJobName','transcribeName','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','transcribe','transcribeAccountId','transcribeRegion','Transcribe\x20not\x20configured','sentiment','sentimentAccountId','sentimentRegion','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','data1','data2','Cloud\x20Provider\x20not\x20configured','Name'];(function(_0x21b293,_0x352a44){var _0xd73e84=function(_0x16916b){while(--_0x16916b){_0x21b293['push'](_0x21b293['shift']());}};_0xd73e84(++_0x352a44);}(_0x054f,0x9d));var _0xf054=function(_0x5d08de,_0x44e601){_0x5d08de=_0x5d08de-0x0;var _0x5a2fae=_0x054f[_0x5d08de];return _0x5a2fae;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf054('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf054('0x1'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf054('0x2'));var Mustache=require(_0xf054('0x3'));var util=require(_0xf054('0x4'));var path=require(_0xf054('0x5'));var sox=require(_0xf054('0x6'));var csv=require(_0xf054('0x7'));var ejs=require(_0xf054('0x8'));var fs=require('fs');var fs_extra=require(_0xf054('0x9'));var _=require('lodash');var squel=require(_0xf054('0xa'));var crypto=require(_0xf054('0xb'));var jsforce=require(_0xf054('0xc'));var deskjs=require(_0xf054('0xd'));var toCsv=require(_0xf054('0x7'));var querystring=require(_0xf054('0xe'));var Papa=require('papaparse');var AWS=require('aws-sdk');var uuidv4=require(_0xf054('0xf'));var Redis=require(_0xf054('0x10'));var authService=require(_0xf054('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xf054('0x12'));var hardwareService=require(_0xf054('0x13'));var logger=require(_0xf054('0x14'))('api');var utils=require(_0xf054('0x15'));var config=require(_0xf054('0x16'));var licenseUtil=require(_0xf054('0x17'));var db=require(_0xf054('0x18'))['db'];function respondWithStatusCode(_0x40e14b,_0x2eee94){_0x2eee94=_0x2eee94||0xcc;return function(_0x4c52e9){if(_0x4c52e9){return _0x40e14b[_0xf054('0x19')](_0x2eee94);}return _0x40e14b[_0xf054('0x1a')](_0x2eee94)['end']();};}function respondWithResult(_0x2dbf11,_0x27e4fb){_0x27e4fb=_0x27e4fb||0xc8;return function(_0x47e3f4){if(_0x47e3f4){return _0x2dbf11[_0xf054('0x1a')](_0x27e4fb)[_0xf054('0x1b')](_0x47e3f4);}};}function respondWithFilteredResult(_0x56fd0c,_0x1587de){return function(_0xd8ed90){if(_0xd8ed90){var _0x5f4b39=typeof _0x1587de['offset']===_0xf054('0x1c')&&typeof _0x1587de[_0xf054('0x1d')]===_0xf054('0x1c');var _0x49dd81=_0xd8ed90[_0xf054('0x1e')];var _0x1ea90c=_0x5f4b39?0x0:_0x1587de[_0xf054('0x1f')];var _0x306549=_0x5f4b39?_0xd8ed90['count']:_0x1587de[_0xf054('0x1f')]+_0x1587de[_0xf054('0x1d')];var _0x332d20;if(_0x306549>=_0x49dd81){_0x306549=_0x49dd81;_0x332d20=0xc8;}else{_0x332d20=0xce;}_0x56fd0c['status'](_0x332d20);return _0x56fd0c['set'](_0xf054('0x20'),_0x1ea90c+'-'+_0x306549+'/'+_0x49dd81)[_0xf054('0x1b')](_0xd8ed90);}return null;};}function patchUpdates(_0x47791a){return function(_0x7c083){try{jsonpatch[_0xf054('0x21')](_0x7c083,_0x47791a,!![]);}catch(_0x281a94){return BPromise['reject'](_0x281a94);}return _0x7c083[_0xf054('0x22')]();};}function saveUpdates(_0x2e00cb,_0x1e341b){return function(_0x1bf2d0){if(_0x1bf2d0){return _0x1bf2d0[_0xf054('0x23')](_0x2e00cb)[_0xf054('0x24')](function(_0x4c7349){return _0x4c7349;});}return null;};}function removeEntity(_0x598d4f,_0x5d4623){return function(_0x359d59){if(_0x359d59){return _0x359d59[_0xf054('0x25')]()[_0xf054('0x24')](function(){_0x598d4f[_0xf054('0x1a')](0xcc)[_0xf054('0x26')]();});}};}function handleEntityNotFound(_0x437b78,_0x10e631){return function(_0x15817f){if(!_0x15817f){_0x437b78[_0xf054('0x19')](0x194);}return _0x15817f;};}function handleError(_0x13a309,_0x1877de){_0x1877de=_0x1877de||0x1f4;return function(_0x569db1){logger['error'](_0x569db1[_0xf054('0x27')]);if(_0x569db1[_0xf054('0x28')]){delete _0x569db1['name'];}_0x13a309[_0xf054('0x1a')](_0x1877de)[_0xf054('0x29')](_0x569db1);};}exports[_0xf054('0x2a')]=function(_0x197b7d,_0x7c372c){var _0x2df765={},_0xa50096={},_0x16ca4b={'count':0x0,'rows':[]};var _0x4af5fe=_[_0xf054('0x2b')](db[_0xf054('0x2c')][_0xf054('0x2d')],function(_0x25cff6){return{'name':_0x25cff6[_0xf054('0x2e')],'type':_0x25cff6['type'][_0xf054('0x2f')]};});_0xa50096[_0xf054('0x30')]=_['differenceBy'](_['map'](_0x4af5fe,_0xf054('0x28')),['format']);_0xa50096[_0xf054('0x31')]=_[_0xf054('0x32')](_0x197b7d[_0xf054('0x31')]);_0xa50096[_0xf054('0x33')]=_['intersection'](_0xa50096[_0xf054('0x30')],_0xa50096['query']);_0x2df765[_0xf054('0x34')]=_['intersection'](_0xa50096[_0xf054('0x30')],qs['fields'](_0x197b7d[_0xf054('0x31')][_0xf054('0x35')]));_0x2df765[_0xf054('0x34')]=_0x2df765[_0xf054('0x34')][_0xf054('0x36')]?_0x2df765[_0xf054('0x34')]:_0xa50096[_0xf054('0x30')];if(!_0x197b7d['query']['hasOwnProperty'](_0xf054('0x37'))){_0x2df765[_0xf054('0x1d')]=qs['limit'](_0x197b7d[_0xf054('0x31')][_0xf054('0x1d')]);_0x2df765['offset']=qs[_0xf054('0x1f')](_0x197b7d[_0xf054('0x31')][_0xf054('0x1f')]);}_0x2df765[_0xf054('0x38')]=qs[_0xf054('0x39')](_0x197b7d[_0xf054('0x31')]['sort']);_0x2df765[_0xf054('0x3a')]=qs[_0xf054('0x33')](_[_0xf054('0x3b')](_0x197b7d[_0xf054('0x31')],_0xa50096[_0xf054('0x33')]),_0x4af5fe);if(_0x197b7d[_0xf054('0x31')]['filter']){_0x2df765[_0xf054('0x3a')]=_[_0xf054('0x3c')](_0x2df765['where'],{'$or':_[_0xf054('0x2b')](_0x4af5fe,function(_0x47c1c9){if(_0x47c1c9[_0xf054('0x3d')]!==_0xf054('0x3e')){var _0x5b6e2e={};_0x5b6e2e[_0x47c1c9[_0xf054('0x28')]]={'$like':'%'+_0x197b7d[_0xf054('0x31')][_0xf054('0x3f')]+'%'};return _0x5b6e2e;}})});}_0x2df765=_[_0xf054('0x3c')]({},_0x2df765,_0x197b7d[_0xf054('0x40')]);var _0x5b9e1d={'where':_0x2df765[_0xf054('0x3a')]};return db[_0xf054('0x2c')][_0xf054('0x1e')](_0x5b9e1d)[_0xf054('0x24')](function(_0x2265bf){_0x16ca4b[_0xf054('0x1e')]=_0x2265bf;if(_0x197b7d['query'][_0xf054('0x41')]){_0x2df765['include']=[{'all':!![]}];}return db['VoiceRecording'][_0xf054('0x42')](_0x2df765);})[_0xf054('0x24')](function(_0x2a1ff1){_0x16ca4b[_0xf054('0x43')]=_0x2a1ff1;return _0x16ca4b;})[_0xf054('0x24')](respondWithFilteredResult(_0x7c372c,_0x2df765))[_0xf054('0x44')](handleError(_0x7c372c,null));};exports['show']=function(_0x31c3cb,_0x292ff3){var _0x5989e5={'raw':![],'where':{'id':_0x31c3cb[_0xf054('0x45')]['id']}},_0x3e54e6={};_0x3e54e6['model']=_[_0xf054('0x32')](db[_0xf054('0x2c')][_0xf054('0x2d')]);_0x3e54e6['query']=_[_0xf054('0x32')](_0x31c3cb[_0xf054('0x31')]);_0x3e54e6['filters']=_[_0xf054('0x46')](_0x3e54e6['model'],_0x3e54e6[_0xf054('0x31')]);_0x5989e5['attributes']=_[_0xf054('0x46')](_0x3e54e6[_0xf054('0x30')],qs[_0xf054('0x35')](_0x31c3cb[_0xf054('0x31')][_0xf054('0x35')]));_0x5989e5[_0xf054('0x34')]=_0x5989e5[_0xf054('0x34')][_0xf054('0x36')]?_0x5989e5['attributes']:_0x3e54e6[_0xf054('0x30')];if(_0x31c3cb[_0xf054('0x31')][_0xf054('0x41')]){_0x5989e5[_0xf054('0x47')]=[{'all':!![]}];}_0x5989e5=_[_0xf054('0x3c')]({},_0x5989e5,_0x31c3cb[_0xf054('0x40')]);return db[_0xf054('0x2c')][_0xf054('0x48')](_0x5989e5)['then'](handleEntityNotFound(_0x292ff3,null))['then'](respondWithResult(_0x292ff3,null))[_0xf054('0x44')](handleError(_0x292ff3,null));};exports[_0xf054('0x49')]=function(_0x5a5ea0,_0x3ad366){return db[_0xf054('0x2c')][_0xf054('0x49')](_0x5a5ea0[_0xf054('0x4a')],{})[_0xf054('0x24')](respondWithResult(_0x3ad366,0xc9))[_0xf054('0x44')](handleError(_0x3ad366,null));};exports[_0xf054('0x23')]=function(_0x3aa7c4,_0x13e04e){if(_0x3aa7c4['body']['id']){delete _0x3aa7c4[_0xf054('0x4a')]['id'];}return db['VoiceRecording'][_0xf054('0x48')]({'where':{'id':_0x3aa7c4[_0xf054('0x45')]['id']}})['then'](handleEntityNotFound(_0x13e04e,null))[_0xf054('0x24')](saveUpdates(_0x3aa7c4['body'],null))[_0xf054('0x24')](respondWithResult(_0x13e04e,null))[_0xf054('0x44')](handleError(_0x13e04e,null));};exports[_0xf054('0x4b')]=function(_0x3a509b,_0x3d5eb5){return db[_0xf054('0x2c')]['describe']()[_0xf054('0x24')](respondWithResult(_0x3d5eb5,null))[_0xf054('0x44')](handleError(_0x3d5eb5,null));};exports[_0xf054('0x4c')]=function(_0x178bf5,_0x364469,_0x17fc5d){var _0x3bae3c=require(_0xf054('0x4d'));var _0x3ef352=![];var _0xda1b2a={};if(_0x178bf5[_0xf054('0x31')]['type']&&_0x178bf5[_0xf054('0x31')][_0xf054('0x3d')]===_0xf054('0x4e')){_0xda1b2a[_0xf054('0x4e')]=_0x178bf5[_0xf054('0x45')]['id'];}else{_0xda1b2a['id']=_0x178bf5[_0xf054('0x45')]['id'];}return db['VoiceRecording']['find']({'where':_0xda1b2a,'attributes':['id',_0xf054('0x4f')],'raw':!![]})['then'](handleEntityNotFound(_0x364469,null))['then'](function(_0x75f135){if(_0x75f135){var _0x546de2=_0x75f135[_0xf054('0x4f')];var _0x3f047a=util['format'](_0xf054('0x50'),_0x546de2);if(fs[_0xf054('0x51')](_0x3f047a)){_0x3ef352=!![];return _0x3bae3c[_0xf054('0x52')](_0x3f047a,_0x546de2,config[_0xf054('0x53')][_0xf054('0x54')])['then'](function(){return _0x75f135;});}return _0x75f135;}})[_0xf054('0x24')](function(_0x4a4116){if(_0x4a4116){var _0x1d68d2=_0x4a4116[_0xf054('0x4f')];if(!fs[_0xf054('0x51')](_0x1d68d2)){throw new db[(_0xf054('0x55'))]['ValidationError']('VoiceRecording\x20not\x20found');}if(_0x4a4116[_0xf054('0x56')]){return _0x364469[_0xf054('0x4c')](_0x1d68d2,_0x4a4116[_0xf054('0x56')]+path[_0xf054('0x57')](_0x1d68d2),function(){if(_0x3ef352){fs[_0xf054('0x58')](_0x1d68d2);}});}else{return _0x364469[_0xf054('0x4c')](_0x1d68d2,function(_0xf65447){if(_0x3ef352){fs[_0xf054('0x58')](_0x1d68d2);}});}}})['catch'](function(_0x523364){if(_0x523364[_0xf054('0x59')]===_0xf054('0x5a')){_0x364469['status'](0x194)['send']('Not\x20found');}else{return handleError(_0x364469,null);}});};exports['downloads']=function(_0x3b0c88,_0x1419c1,_0x5e6c7e){var _0x4d78c4=require('../../components/encryptor');var _0x45385c=![];var _0x2b31b5={'$and':[db[_0xf054('0x5b')][_0xf054('0x3a')](db[_0xf054('0x5b')]['fn'](_0xf054('0x5c'),db[_0xf054('0x5b')][_0xf054('0x5d')](_0xf054('0x4e'))),_0x3b0c88[_0xf054('0x31')][_0xf054('0x5e')])]};if(_0x3b0c88[_0xf054('0x31')][_0xf054('0x3d')]&&_0x3b0c88[_0xf054('0x31')][_0xf054('0x3d')]===_0xf054('0x4e')){_0x2b31b5['$and'][_0xf054('0x5f')]({'uniqueid':_0x3b0c88[_0xf054('0x45')]['id']});}else{_0x2b31b5['$and'][_0xf054('0x5f')]({'id':_0x3b0c88[_0xf054('0x45')]['id']});}return db[_0xf054('0x2c')][_0xf054('0x48')]({'where':_0x2b31b5,'attributes':['id',_0xf054('0x4f')],'raw':!![]})['then'](handleEntityNotFound(_0x1419c1,null))[_0xf054('0x24')](function(_0x4c2356){if(_0x4c2356){var _0x1a1efe=util['format'](_0xf054('0x50'),_0x4c2356[_0xf054('0x4f')]);if(fs[_0xf054('0x51')](_0x1a1efe)){_0x45385c=!![];return _0x4d78c4[_0xf054('0x52')](_0x1a1efe,_0x4c2356[_0xf054('0x4f')],config[_0xf054('0x53')][_0xf054('0x54')])[_0xf054('0x24')](function(){return _0x4c2356;});}return _0x4c2356;}})[_0xf054('0x24')](function(_0x4967d1){if(_0x4967d1){if(!fs[_0xf054('0x51')](_0x4967d1['value'])){throw new db[(_0xf054('0x55'))][(_0xf054('0x60'))](_0xf054('0x5a'));}if(_0x4967d1[_0xf054('0x56')]){return _0x1419c1[_0xf054('0x4c')](_0x4967d1['value'],_0x4967d1[_0xf054('0x56')]+path[_0xf054('0x57')](_0x4967d1[_0xf054('0x4f')]),function(){if(_0x45385c){fs[_0xf054('0x58')](_0x4967d1[_0xf054('0x4f')]);}});}else{return _0x1419c1[_0xf054('0x4c')](_0x4967d1[_0xf054('0x4f')],function(_0x13129e){if(_0x45385c){fs['unlink'](_0x4967d1[_0xf054('0x4f')]);}});}}})[_0xf054('0x44')](handleError(_0x1419c1,null));};exports[_0xf054('0x25')]=function(_0x331dde,_0x40c2e2){return db[_0xf054('0x2c')]['find']({'where':{'id':_0x331dde['params']['id']}})[_0xf054('0x24')](function(_0x55a077){if(_['isNil'](_0x55a077)){throw new ReferenceError('Entity\x20not\x20found');}return _0x55a077;})[_0xf054('0x24')](function(_0x3f67eb){var _0x349dde=_0x3f67eb[_0xf054('0x4f')];logger['info']('cancellazione\x20fisica\x20documento\x20%s',_0x349dde);if(!_['isNil'](_0x3f67eb[_0xf054('0x4f')])&&fs[_0xf054('0x51')](_0x349dde)){logger[_0xf054('0x61')]('File:\x20\x22'+_0x349dde+_0xf054('0x62'));fs[_0xf054('0x63')](_0x349dde);}_0x349dde=_0x349dde+'.cypher';if(!_[_0xf054('0x64')](_0x3f67eb['value'])&&fs[_0xf054('0x51')](_0x349dde)){logger['info'](_0xf054('0x65')+_0x349dde+_0xf054('0x62'));fs['unlinkSync'](_0x349dde);}return _0x3f67eb;})[_0xf054('0x24')](function(_0x56456f){if(!_0x56456f)throw new InternalError();return _0x56456f[_0xf054('0x25')]();})[_0xf054('0x24')](function(){_0x40c2e2[_0xf054('0x1a')](0xcc)['end']();})[_0xf054('0x44')](handleError(_0x40c2e2,null));};function getBucketslist(_0x29c1d0,_0x443611,_0x5d7f88){return new Promise(function(_0x27d7ab,_0x1af28e){var _0x32f5b6=new AWS['S3']({'accessKeyId':_0x443611,'secretAccessKey':_0x29c1d0,'region':_0x5d7f88});_0x32f5b6[_0xf054('0x66')]({},function(_0x39cda6,_0xb1f969){if(_0x39cda6){return _0x1af28e(_0x39cda6);}else{return _0x27d7ab(_0xb1f969);}});});}function createBucket(_0x129537,_0x1a5e08,_0x5b8cc6,_0x2133a5){return new Promise(function(_0x5bf143,_0x424836){var _0x52c102=new AWS['S3']({'accessKeyId':_0x1a5e08,'secretAccessKey':_0x129537,'region':_0x5b8cc6});_0x52c102[_0xf054('0x67')]({'Bucket':_0x2133a5},function(_0x28b49e,_0x57b6ad){if(_0x28b49e){return _0x424836(_0x28b49e);}else{return _0x5bf143(_0x57b6ad);}});});}function uploadFile(_0x1c0df8,_0x3e1691,_0x51be99,_0x8318d6,_0x3ca404,_0x1a1457){return new Promise(function(_0x9cc12f,_0x100816){var _0x28d6be=new AWS['S3']({'accessKeyId':_0x3e1691,'secretAccessKey':_0x1c0df8,'region':_0x51be99});_0x28d6be['upload']({'Bucket':_0x8318d6,'Key':_0x3ca404,'Body':_0x1a1457},function(_0x321e46,_0x1c9cc0){if(_0x321e46){return _0x100816(_0x321e46);}else{return _0x9cc12f(_0x1c9cc0);}});});}function startTranscribe(_0x5eed48,_0x1554f8,_0x8b0b83,_0x396432,_0x40de65,_0x3a7fee){return new Promise(function(_0x1fdf87,_0x5db0d8){var _0x2b45f7=new AWS[(_0xf054('0x68'))]({'accessKeyId':_0x1554f8,'secretAccessKey':_0x5eed48,'region':_0x8b0b83});_0x2b45f7['startTranscriptionJob']({'TranscriptionJobName':_0x396432,'LanguageCode':_0x40de65,'Media':{'MediaFileUri':_0x3a7fee}},function(_0x86dfaa,_0x358564){if(_0x86dfaa){return _0x5db0d8(_0x86dfaa);}else{return _0x1fdf87(_0x358564);}});});}function transcribe(_0x32ff8e,_0x50ea15,_0x761057,_0x3bd143,_0x5ef071,_0x45d560,_0x2bff62){return new Promise(function(_0x354204,_0x574606){var _0x3d5b39={};logger[_0xf054('0x61')](util[_0xf054('0x69')]('[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s',_0x32ff8e,_0x5ef071));return uploadFile(_0x50ea15,_0x761057,_0x3bd143,_0x5ef071,path[_0xf054('0x6a')](_0x45d560),fs[_0xf054('0x6b')](_0x45d560))[_0xf054('0x24')](function(_0x3d4687){logger[_0xf054('0x61')](util[_0xf054('0x69')](_0xf054('0x6c'),_0x32ff8e,_0x5ef071,_0x3d4687[_0xf054('0x6d')]));_0x3d5b39[_0xf054('0x6e')]=_0x3d4687[_0xf054('0x6f')];_0x3d5b39['location']=_0x3d4687[_0xf054('0x6d')];logger[_0xf054('0x61')](util[_0xf054('0x69')]('[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request',_0x32ff8e));return startTranscribe(_0x50ea15,_0x761057,_0x3bd143,uuidv4(),_0x2bff62,_0x3d4687[_0xf054('0x6d')]);})[_0xf054('0x24')](function(_0x132df0){logger[_0xf054('0x61')](util[_0xf054('0x69')](_0xf054('0x70'),_0x32ff8e,_0x132df0[_0xf054('0x71')][_0xf054('0x72')]));_0x3d5b39[_0xf054('0x73')]=_0x132df0[_0xf054('0x71')][_0xf054('0x72')];_0x3d5b39['transcribeStatus']=_0x132df0['TranscriptionJob']['TranscriptionJobStatus'];return _0x354204(_0x3d5b39);})[_0xf054('0x44')](function(_0x149924){return _0x574606(_0x149924);});});}exports[_0xf054('0x74')]=function(_0x21bda6,_0x58eb6f,_0x34b96c){var _0x48634c;var _0x25746b;var _0x14b8ed;var _0x3a5637=require(_0xf054('0x4d'));return db[_0xf054('0x2c')][_0xf054('0x75')]({'where':{'id':_0x21bda6[_0xf054('0x45')]['id']}})['then'](function(_0x3fcf90){if(_0x3fcf90){var _0x13c485=util[_0xf054('0x69')](_0xf054('0x50'),_0x3fcf90[_0xf054('0x4f')]);if(fs['existsSync'](_0x13c485)){cypher=!![];return _0x3a5637[_0xf054('0x52')](_0x13c485,_0x3fcf90[_0xf054('0x4f')],config[_0xf054('0x53')][_0xf054('0x54')])[_0xf054('0x24')](function(){return _0x3fcf90;});}return _0x3fcf90;}})[_0xf054('0x24')](function(_0x23b6dd){if(!_0x23b6dd){throw new db['Sequelize'][(_0xf054('0x60'))](_0xf054('0x76'));}_0x25746b=_0x23b6dd;return db['Setting'][_0xf054('0x75')]({'where':{'id':0x1}});})[_0xf054('0x24')](handleEntityNotFound(_0x58eb6f,null))[_0xf054('0x24')](function(_0xa0119c){if(_0xa0119c){_0x48634c=_0xa0119c;if(!_0x48634c[_0xf054('0x77')]||!_0x48634c[_0xf054('0x78')]||!_0x48634c[_0xf054('0x79')]||!_0x48634c['language']||!_0x48634c[_0xf054('0x6e')]){throw new db[(_0xf054('0x55'))]['ValidationError'](_0xf054('0x7a'));}if(_0x21bda6['body']['runSentiment']&&(!_0x48634c[_0xf054('0x7b')]||!_0x48634c[_0xf054('0x7c')]||!_0x48634c[_0xf054('0x7d')]||!_0x48634c[_0xf054('0x7e')]||!_0x48634c['bucket'])){throw new db[(_0xf054('0x55'))][(_0xf054('0x60'))](_0xf054('0x7f'));}return db[_0xf054('0x80')]['findOne']({'where':{'id':_0x48634c['transcribeAccountId']}});}})[_0xf054('0x24')](function(_0xfdef1e){if(!_0xfdef1e){throw new db['Sequelize'][(_0xf054('0x60'))]('Cloud\x20Provider\x20not\x20available');}if(!_0xfdef1e[_0xf054('0x81')]||!_0xfdef1e[_0xf054('0x82')]){throw new db['Sequelize'][(_0xf054('0x60'))](_0xf054('0x83'));}_0x14b8ed=_0xfdef1e;return getBucketslist(_0x14b8ed[_0xf054('0x81')],_0x14b8ed['data2'],_0x48634c['transcribeRegion']);})[_0xf054('0x24')](function(_0x4fa971){if(_0x4fa971&&_0x4fa971['Buckets']){var _0x5251b3=_[_0xf054('0x48')](_0x4fa971['Buckets'],function(_0xd7f1d3){return _0xd7f1d3[_0xf054('0x84')]===_0x48634c[_0xf054('0x6e')];});if(!_0x5251b3){logger[_0xf054('0x61')](util[_0xf054('0x69')](_0xf054('0x85'),_0x21bda6[_0xf054('0x45')]['id'],_0x48634c['bucket']));return createBucket(_0x14b8ed[_0xf054('0x81')],_0x14b8ed['data2'],_0x48634c['transcribeRegion'],_0x48634c[_0xf054('0x6e')]);}logger[_0xf054('0x61')](util[_0xf054('0x69')](_0xf054('0x86'),_0x21bda6[_0xf054('0x45')]['id'],_0x48634c[_0xf054('0x6e')]));return;}})[_0xf054('0x24')](function(_0x540e7f){if(_0x25746b[_0xf054('0x87')]==='NEW'){return transcribe(_0x21bda6['params']['id'],_0x14b8ed[_0xf054('0x81')],_0x14b8ed[_0xf054('0x82')],_0x48634c[_0xf054('0x79')],_0x48634c[_0xf054('0x6e')],_0x25746b[_0xf054('0x4f')],_0x48634c['language']);}else{logger[_0xf054('0x61')](util[_0xf054('0x69')]('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x21bda6[_0xf054('0x45')]['id']));return{'transcribeStatus':_0xf054('0x88')};}})['then'](function(_0x5e619b){if(_0x5e619b){_0x5e619b[_0xf054('0x89')]=_0x21bda6[_0xf054('0x4a')]['runSentiment'];return _0x25746b[_0xf054('0x8a')](_0x5e619b);}})['then'](respondWithResult(_0x58eb6f,null))[_0xf054('0x44')](handleError(_0x58eb6f,null));};function writeFile(_0x23f1d4,_0x58dd3f){return new Promise(function(_0xbf316b,_0x5c499b){fs[_0xf054('0x8b')](_0x58dd3f,_0x23f1d4,function(_0x5758d7,_0x4241a6){if(_0x5758d7){return _0x5c499b(_0x5758d7);}else{return _0xbf316b(_0x4241a6);}});});}exports['downloadTranscribe']=function(_0x5ac6f0,_0x3d2014,_0x2bb5f5){return db[_0xf054('0x2c')][_0xf054('0x75')]({'where':{'id':_0x5ac6f0['params']['id']}})[_0xf054('0x24')](handleEntityNotFound(_0x3d2014))[_0xf054('0x24')](function(_0xc4b86b){if(_0xc4b86b&&_0xc4b86b['fileText']){var _0x2d7a96=_0xc4b86b[_0xf054('0x8c')];var _0x1264e6=config[_0xf054('0x8d')]+_0xf054('0x8e')+_0xc4b86b['id']+_0xf054('0x8f');if(fs[_0xf054('0x51')](_0x1264e6)){return _0x1264e6;}return writeFile(_0x2d7a96,_0x1264e6)['then'](function(){return _0x1264e6;});}else{throw new db['Sequelize'][(_0xf054('0x60'))](_0xf054('0x90'));}})[_0xf054('0x24')](function(_0x5b9d2d){return _0x3d2014[_0xf054('0x4c')](_0x5b9d2d);})['catch'](handleError(_0x3d2014));};
\ No newline at end of file
+var _0xfd78=['token','$and','push','%s.cypher','info','cancellazione\x20fisica\x20documento\x20%s','isNil','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','.cypher','listBuckets','createBucket','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)','Location','bucket','Bucket','location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','TranscriptionJob','TranscriptionJobName','transcribeStatus','TranscriptionJobStatus','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribe','transcribeAccountId','transcribeRegion','Transcribe\x20not\x20configured','runSentiment','sentiment','sentimentAccountId','sentimentRegion','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','data2','data1','Buckets','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','NEW','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','tempSentiment','updateAttributes','writeFile','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','.txt','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','fs-extra','lodash','squel','querystring','papaparse','aws-sdk','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','undefined','limit','count','offset','apply','update','then','destroy','sendStatus','error','name','send','index','map','VoiceRecording','rawAttributes','type','model','format','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','body','find','describe','../../components/encryptor','uniqueid','value','existsSync','decryptFile','secrets','recording','Sequelize','ValidationError','filename','extname','unlink','download','message','VoiceRecording\x20not\x20found','Not\x20found','downloads','sequelize','MD5','col'];(function(_0x21a9d9,_0x4d5ac8){var _0x46adce=function(_0xfdd336){while(--_0xfdd336){_0x21a9d9['push'](_0x21a9d9['shift']());}};_0x46adce(++_0x4d5ac8);}(_0xfd78,0xd6));var _0x8fd7=function(_0x2ee008,_0x2eb506){_0x2ee008=_0x2ee008-0x0;var _0x11d6b9=_0xfd78[_0x2ee008];return _0x11d6b9;};'use strict';var emlformat=require(_0x8fd7('0x0'));var rimraf=require(_0x8fd7('0x1'));var zipdir=require(_0x8fd7('0x2'));var jsonpatch=require(_0x8fd7('0x3'));var rp=require(_0x8fd7('0x4'));var moment=require(_0x8fd7('0x5'));var BPromise=require(_0x8fd7('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0x8fd7('0x7'));var sox=require(_0x8fd7('0x8'));var csv=require(_0x8fd7('0x9'));var ejs=require(_0x8fd7('0xa'));var fs=require('fs');var fs_extra=require(_0x8fd7('0xb'));var _=require(_0x8fd7('0xc'));var squel=require(_0x8fd7('0xd'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x8fd7('0xe'));var Papa=require(_0x8fd7('0xf'));var AWS=require(_0x8fd7('0x10'));var uuidv4=require('uuid/v4');var Redis=require('ioredis');var authService=require(_0x8fd7('0x11'));var qs=require(_0x8fd7('0x12'));var as=require(_0x8fd7('0x13'));var hardwareService=require(_0x8fd7('0x14'));var logger=require('../../config/logger')(_0x8fd7('0x15'));var utils=require(_0x8fd7('0x16'));var config=require(_0x8fd7('0x17'));var licenseUtil=require(_0x8fd7('0x18'));var db=require(_0x8fd7('0x19'))['db'];function respondWithStatusCode(_0x4c755f,_0x155ef5){_0x155ef5=_0x155ef5||0xcc;return function(_0x5403c7){if(_0x5403c7){return _0x4c755f['sendStatus'](_0x155ef5);}return _0x4c755f[_0x8fd7('0x1a')](_0x155ef5)[_0x8fd7('0x1b')]();};}function respondWithResult(_0x1a7914,_0x286632){_0x286632=_0x286632||0xc8;return function(_0x5372f5){if(_0x5372f5){return _0x1a7914[_0x8fd7('0x1a')](_0x286632)[_0x8fd7('0x1c')](_0x5372f5);}};}function respondWithFilteredResult(_0x101036,_0x13fdda){return function(_0x1db638){if(_0x1db638){var _0x4feff0=typeof _0x13fdda['offset']===_0x8fd7('0x1d')&&typeof _0x13fdda[_0x8fd7('0x1e')]==='undefined';var _0x4a76de=_0x1db638[_0x8fd7('0x1f')];var _0x31a047=_0x4feff0?0x0:_0x13fdda[_0x8fd7('0x20')];var _0xceb78a=_0x4feff0?_0x1db638[_0x8fd7('0x1f')]:_0x13fdda[_0x8fd7('0x20')]+_0x13fdda[_0x8fd7('0x1e')];var _0x23b623;if(_0xceb78a>=_0x4a76de){_0xceb78a=_0x4a76de;_0x23b623=0xc8;}else{_0x23b623=0xce;}_0x101036[_0x8fd7('0x1a')](_0x23b623);return _0x101036['set']('Content-Range',_0x31a047+'-'+_0xceb78a+'/'+_0x4a76de)[_0x8fd7('0x1c')](_0x1db638);}return null;};}function patchUpdates(_0x519498){return function(_0x9b244b){try{jsonpatch[_0x8fd7('0x21')](_0x9b244b,_0x519498,!![]);}catch(_0x50045b){return BPromise['reject'](_0x50045b);}return _0x9b244b['save']();};}function saveUpdates(_0x413d5d,_0x261ea1){return function(_0xb94c5a){if(_0xb94c5a){return _0xb94c5a[_0x8fd7('0x22')](_0x413d5d)[_0x8fd7('0x23')](function(_0x438f3e){return _0x438f3e;});}return null;};}function removeEntity(_0x4a6701,_0x1fee90){return function(_0x58b0bc){if(_0x58b0bc){return _0x58b0bc[_0x8fd7('0x24')]()['then'](function(){_0x4a6701[_0x8fd7('0x1a')](0xcc)[_0x8fd7('0x1b')]();});}};}function handleEntityNotFound(_0x2eb123,_0x40fab0){return function(_0x18e3e9){if(!_0x18e3e9){_0x2eb123[_0x8fd7('0x25')](0x194);}return _0x18e3e9;};}function handleError(_0x5a8830,_0xd2b5ad){_0xd2b5ad=_0xd2b5ad||0x1f4;return function(_0x4813fe){logger[_0x8fd7('0x26')](_0x4813fe['stack']);if(_0x4813fe[_0x8fd7('0x27')]){delete _0x4813fe['name'];}_0x5a8830[_0x8fd7('0x1a')](_0xd2b5ad)[_0x8fd7('0x28')](_0x4813fe);};}exports[_0x8fd7('0x29')]=function(_0xb4441f,_0x5bbf94){var _0x1bcc10={},_0x518e12={},_0xc99617={'count':0x0,'rows':[]};var _0x3078b8=_[_0x8fd7('0x2a')](db[_0x8fd7('0x2b')][_0x8fd7('0x2c')],function(_0x459121){return{'name':_0x459121['fieldName'],'type':_0x459121[_0x8fd7('0x2d')]['key']};});_0x518e12[_0x8fd7('0x2e')]=_['differenceBy'](_[_0x8fd7('0x2a')](_0x3078b8,_0x8fd7('0x27')),[_0x8fd7('0x2f')]);_0x518e12[_0x8fd7('0x30')]=_[_0x8fd7('0x31')](_0xb4441f[_0x8fd7('0x30')]);_0x518e12[_0x8fd7('0x32')]=_[_0x8fd7('0x33')](_0x518e12[_0x8fd7('0x2e')],_0x518e12[_0x8fd7('0x30')]);_0x1bcc10[_0x8fd7('0x34')]=_[_0x8fd7('0x33')](_0x518e12[_0x8fd7('0x2e')],qs[_0x8fd7('0x35')](_0xb4441f[_0x8fd7('0x30')]['fields']));_0x1bcc10[_0x8fd7('0x34')]=_0x1bcc10[_0x8fd7('0x34')][_0x8fd7('0x36')]?_0x1bcc10['attributes']:_0x518e12[_0x8fd7('0x2e')];if(!_0xb4441f[_0x8fd7('0x30')]['hasOwnProperty'](_0x8fd7('0x37'))){_0x1bcc10[_0x8fd7('0x1e')]=qs[_0x8fd7('0x1e')](_0xb4441f[_0x8fd7('0x30')][_0x8fd7('0x1e')]);_0x1bcc10[_0x8fd7('0x20')]=qs['offset'](_0xb4441f[_0x8fd7('0x30')][_0x8fd7('0x20')]);}_0x1bcc10[_0x8fd7('0x38')]=qs['sort'](_0xb4441f['query'][_0x8fd7('0x39')]);_0x1bcc10[_0x8fd7('0x3a')]=qs['filters'](_[_0x8fd7('0x3b')](_0xb4441f['query'],_0x518e12[_0x8fd7('0x32')]),_0x3078b8);if(_0xb4441f[_0x8fd7('0x30')][_0x8fd7('0x3c')]){_0x1bcc10[_0x8fd7('0x3a')]=_[_0x8fd7('0x3d')](_0x1bcc10[_0x8fd7('0x3a')],{'$or':_[_0x8fd7('0x2a')](_0x3078b8,function(_0x296ae5){if(_0x296ae5[_0x8fd7('0x2d')]!==_0x8fd7('0x3e')){var _0x534488={};_0x534488[_0x296ae5[_0x8fd7('0x27')]]={'$like':'%'+_0xb4441f[_0x8fd7('0x30')][_0x8fd7('0x3c')]+'%'};return _0x534488;}})});}_0x1bcc10=_[_0x8fd7('0x3d')]({},_0x1bcc10,_0xb4441f[_0x8fd7('0x3f')]);var _0x31fa56={'where':_0x1bcc10['where']};return db[_0x8fd7('0x2b')][_0x8fd7('0x1f')](_0x31fa56)[_0x8fd7('0x23')](function(_0x5bedba){_0xc99617[_0x8fd7('0x1f')]=_0x5bedba;if(_0xb4441f[_0x8fd7('0x30')][_0x8fd7('0x40')]){_0x1bcc10[_0x8fd7('0x41')]=[{'all':!![]}];}return db['VoiceRecording'][_0x8fd7('0x42')](_0x1bcc10);})[_0x8fd7('0x23')](function(_0x7a31db){_0xc99617[_0x8fd7('0x43')]=_0x7a31db;return _0xc99617;})[_0x8fd7('0x23')](respondWithFilteredResult(_0x5bbf94,_0x1bcc10))[_0x8fd7('0x44')](handleError(_0x5bbf94,null));};exports[_0x8fd7('0x45')]=function(_0x2ab70e,_0x5820c1){var _0x48b694={'raw':![],'where':{'id':_0x2ab70e[_0x8fd7('0x46')]['id']}},_0x3163e6={};_0x3163e6[_0x8fd7('0x2e')]=_[_0x8fd7('0x31')](db[_0x8fd7('0x2b')][_0x8fd7('0x2c')]);_0x3163e6['query']=_['keys'](_0x2ab70e[_0x8fd7('0x30')]);_0x3163e6['filters']=_[_0x8fd7('0x33')](_0x3163e6['model'],_0x3163e6[_0x8fd7('0x30')]);_0x48b694['attributes']=_[_0x8fd7('0x33')](_0x3163e6[_0x8fd7('0x2e')],qs[_0x8fd7('0x35')](_0x2ab70e[_0x8fd7('0x30')][_0x8fd7('0x35')]));_0x48b694[_0x8fd7('0x34')]=_0x48b694[_0x8fd7('0x34')][_0x8fd7('0x36')]?_0x48b694[_0x8fd7('0x34')]:_0x3163e6[_0x8fd7('0x2e')];if(_0x2ab70e['query']['includeAll']){_0x48b694[_0x8fd7('0x41')]=[{'all':!![]}];}_0x48b694=_[_0x8fd7('0x3d')]({},_0x48b694,_0x2ab70e[_0x8fd7('0x3f')]);return db[_0x8fd7('0x2b')]['find'](_0x48b694)[_0x8fd7('0x23')](handleEntityNotFound(_0x5820c1,null))['then'](respondWithResult(_0x5820c1,null))['catch'](handleError(_0x5820c1,null));};exports['create']=function(_0x46d41e,_0x2dc5d1){return db[_0x8fd7('0x2b')]['create'](_0x46d41e[_0x8fd7('0x47')],{})[_0x8fd7('0x23')](respondWithResult(_0x2dc5d1,0xc9))['catch'](handleError(_0x2dc5d1,null));};exports['update']=function(_0x72112c,_0x40ee96){if(_0x72112c[_0x8fd7('0x47')]['id']){delete _0x72112c[_0x8fd7('0x47')]['id'];}return db[_0x8fd7('0x2b')][_0x8fd7('0x48')]({'where':{'id':_0x72112c['params']['id']}})[_0x8fd7('0x23')](handleEntityNotFound(_0x40ee96,null))['then'](saveUpdates(_0x72112c[_0x8fd7('0x47')],null))[_0x8fd7('0x23')](respondWithResult(_0x40ee96,null))['catch'](handleError(_0x40ee96,null));};exports[_0x8fd7('0x49')]=function(_0x449c80,_0x2cb89e){return db[_0x8fd7('0x2b')][_0x8fd7('0x49')]()[_0x8fd7('0x23')](respondWithResult(_0x2cb89e,null))['catch'](handleError(_0x2cb89e,null));};exports['download']=function(_0x2696ac,_0x519e9f,_0x18f083){var _0x237195=require(_0x8fd7('0x4a'));var _0x428305=![];var _0x10be6b={};if(_0x2696ac[_0x8fd7('0x30')]['type']&&_0x2696ac[_0x8fd7('0x30')][_0x8fd7('0x2d')]===_0x8fd7('0x4b')){_0x10be6b[_0x8fd7('0x4b')]=_0x2696ac[_0x8fd7('0x46')]['id'];}else{_0x10be6b['id']=_0x2696ac[_0x8fd7('0x46')]['id'];}return db[_0x8fd7('0x2b')][_0x8fd7('0x48')]({'where':_0x10be6b,'attributes':['id','value'],'raw':!![]})[_0x8fd7('0x23')](handleEntityNotFound(_0x519e9f,null))[_0x8fd7('0x23')](function(_0xca5a50){if(_0xca5a50){var _0x19e20d=_0xca5a50[_0x8fd7('0x4c')];var _0x1ed581=util[_0x8fd7('0x2f')]('%s.cypher',_0x19e20d);if(fs[_0x8fd7('0x4d')](_0x1ed581)){_0x428305=!![];return _0x237195[_0x8fd7('0x4e')](_0x1ed581,_0x19e20d,config[_0x8fd7('0x4f')][_0x8fd7('0x50')])[_0x8fd7('0x23')](function(){return _0xca5a50;});}return _0xca5a50;}})['then'](function(_0x39e66b){if(_0x39e66b){var _0x192b6d=_0x39e66b[_0x8fd7('0x4c')];if(!fs[_0x8fd7('0x4d')](_0x192b6d)){throw new db[(_0x8fd7('0x51'))][(_0x8fd7('0x52'))]('VoiceRecording\x20not\x20found');}if(_0x39e66b[_0x8fd7('0x53')]){return _0x519e9f['download'](_0x192b6d,_0x39e66b[_0x8fd7('0x53')]+path[_0x8fd7('0x54')](_0x192b6d),function(){if(_0x428305){fs[_0x8fd7('0x55')](_0x192b6d);}});}else{return _0x519e9f[_0x8fd7('0x56')](_0x192b6d,function(_0x3e3cf7){if(_0x428305){fs[_0x8fd7('0x55')](_0x192b6d);}});}}})['catch'](function(_0x362295){if(_0x362295[_0x8fd7('0x57')]===_0x8fd7('0x58')){_0x519e9f[_0x8fd7('0x1a')](0x194)[_0x8fd7('0x28')](_0x8fd7('0x59'));}else{return handleError(_0x519e9f,null);}});};exports[_0x8fd7('0x5a')]=function(_0x235b6e,_0x33d9d0,_0x45ad0c){var _0x1d13fc=require(_0x8fd7('0x4a'));var _0x245d40=![];var _0x4de2c3={'$and':[db['sequelize']['where'](db[_0x8fd7('0x5b')]['fn'](_0x8fd7('0x5c'),db[_0x8fd7('0x5b')][_0x8fd7('0x5d')](_0x8fd7('0x4b'))),_0x235b6e[_0x8fd7('0x30')][_0x8fd7('0x5e')])]};if(_0x235b6e[_0x8fd7('0x30')][_0x8fd7('0x2d')]&&_0x235b6e[_0x8fd7('0x30')][_0x8fd7('0x2d')]===_0x8fd7('0x4b')){_0x4de2c3[_0x8fd7('0x5f')][_0x8fd7('0x60')]({'uniqueid':_0x235b6e[_0x8fd7('0x46')]['id']});}else{_0x4de2c3['$and']['push']({'id':_0x235b6e['params']['id']});}return db[_0x8fd7('0x2b')][_0x8fd7('0x48')]({'where':_0x4de2c3,'attributes':['id',_0x8fd7('0x4c')],'raw':!![]})['then'](handleEntityNotFound(_0x33d9d0,null))[_0x8fd7('0x23')](function(_0x4729dc){if(_0x4729dc){var _0xdff81a=util[_0x8fd7('0x2f')](_0x8fd7('0x61'),_0x4729dc[_0x8fd7('0x4c')]);if(fs[_0x8fd7('0x4d')](_0xdff81a)){_0x245d40=!![];return _0x1d13fc[_0x8fd7('0x4e')](_0xdff81a,_0x4729dc[_0x8fd7('0x4c')],config[_0x8fd7('0x4f')][_0x8fd7('0x50')])['then'](function(){return _0x4729dc;});}return _0x4729dc;}})[_0x8fd7('0x23')](function(_0x30303d){if(_0x30303d){if(!fs[_0x8fd7('0x4d')](_0x30303d[_0x8fd7('0x4c')])){throw new db[(_0x8fd7('0x51'))][(_0x8fd7('0x52'))]('VoiceRecording\x20not\x20found');}if(_0x30303d['filename']){return _0x33d9d0[_0x8fd7('0x56')](_0x30303d[_0x8fd7('0x4c')],_0x30303d[_0x8fd7('0x53')]+path[_0x8fd7('0x54')](_0x30303d[_0x8fd7('0x4c')]),function(){if(_0x245d40){fs[_0x8fd7('0x55')](_0x30303d[_0x8fd7('0x4c')]);}});}else{return _0x33d9d0[_0x8fd7('0x56')](_0x30303d[_0x8fd7('0x4c')],function(_0x2053d3){if(_0x245d40){fs[_0x8fd7('0x55')](_0x30303d[_0x8fd7('0x4c')]);}});}}})[_0x8fd7('0x44')](handleError(_0x33d9d0,null));};exports[_0x8fd7('0x24')]=function(_0x14d20c,_0x41fced){return db[_0x8fd7('0x2b')][_0x8fd7('0x48')]({'where':{'id':_0x14d20c[_0x8fd7('0x46')]['id']}})['then'](function(_0x1a8213){if(_['isNil'](_0x1a8213)){throw new ReferenceError('Entity\x20not\x20found');}return _0x1a8213;})[_0x8fd7('0x23')](function(_0x2d60d9){var _0x151c18=_0x2d60d9[_0x8fd7('0x4c')];logger[_0x8fd7('0x62')](_0x8fd7('0x63'),_0x151c18);if(!_[_0x8fd7('0x64')](_0x2d60d9['value'])&&fs['existsSync'](_0x151c18)){logger[_0x8fd7('0x62')](_0x8fd7('0x65')+_0x151c18+_0x8fd7('0x66'));fs[_0x8fd7('0x67')](_0x151c18);}_0x151c18=_0x151c18+_0x8fd7('0x68');if(!_['isNil'](_0x2d60d9[_0x8fd7('0x4c')])&&fs['existsSync'](_0x151c18)){logger['info'](_0x8fd7('0x65')+_0x151c18+_0x8fd7('0x66'));fs['unlinkSync'](_0x151c18);}return _0x2d60d9;})[_0x8fd7('0x23')](function(_0x358780){if(!_0x358780)throw new InternalError();return _0x358780['destroy']();})[_0x8fd7('0x23')](function(){_0x41fced[_0x8fd7('0x1a')](0xcc)['end']();})['catch'](handleError(_0x41fced,null));};function getBucketslist(_0x31bbac,_0x395d61,_0x5c056f){return new Promise(function(_0x3b9a2a,_0x2e42e3){var _0x89e926=new AWS['S3']({'accessKeyId':_0x395d61,'secretAccessKey':_0x31bbac,'region':_0x5c056f});_0x89e926[_0x8fd7('0x69')]({},function(_0x40e0e0,_0x893282){if(_0x40e0e0){return _0x2e42e3(_0x40e0e0);}else{return _0x3b9a2a(_0x893282);}});});}function createBucket(_0x8fbd0c,_0x492d01,_0x1f73df,_0x19963a){return new Promise(function(_0xde0b90,_0x168aae){var _0x3d6c57=new AWS['S3']({'accessKeyId':_0x492d01,'secretAccessKey':_0x8fbd0c,'region':_0x1f73df});_0x3d6c57[_0x8fd7('0x6a')]({'Bucket':_0x19963a},function(_0x280a97,_0x4d67d2){if(_0x280a97){return _0x168aae(_0x280a97);}else{return _0xde0b90(_0x4d67d2);}});});}function uploadFile(_0x5c1a44,_0x1554b0,_0x257d69,_0x25dfaa,_0x24f10d,_0x41ceab){return new Promise(function(_0x4a821d,_0x741068){var _0x4403d3=new AWS['S3']({'accessKeyId':_0x1554b0,'secretAccessKey':_0x5c1a44,'region':_0x257d69});_0x4403d3[_0x8fd7('0x6b')]({'Bucket':_0x25dfaa,'Key':_0x24f10d,'Body':_0x41ceab},function(_0x374116,_0xe533f7){if(_0x374116){return _0x741068(_0x374116);}else{return _0x4a821d(_0xe533f7);}});});}function startTranscribe(_0x7c97c6,_0x24d4de,_0x1874f8,_0x55a2ef,_0x5c0db4,_0x5843dc){return new Promise(function(_0x819119,_0x10a194){var _0x1ca330=new AWS[(_0x8fd7('0x6c'))]({'accessKeyId':_0x24d4de,'secretAccessKey':_0x7c97c6,'region':_0x1874f8});_0x1ca330[_0x8fd7('0x6d')]({'TranscriptionJobName':_0x55a2ef,'LanguageCode':_0x5c0db4,'Media':{'MediaFileUri':_0x5843dc}},function(_0x3f792b,_0x299a69){if(_0x3f792b){return _0x10a194(_0x3f792b);}else{return _0x819119(_0x299a69);}});});}function transcribe(_0x121008,_0x453a68,_0x40bad3,_0x87d967,_0x1869b1,_0x2d59c2,_0x102124){return new Promise(function(_0x4737de,_0x78dc0a){var _0x3e1066={};logger[_0x8fd7('0x62')](util['format'](_0x8fd7('0x6e'),_0x121008,_0x1869b1));return uploadFile(_0x453a68,_0x40bad3,_0x87d967,_0x1869b1,path[_0x8fd7('0x6f')](_0x2d59c2),fs[_0x8fd7('0x70')](_0x2d59c2))[_0x8fd7('0x23')](function(_0x5ecf8a){logger['info'](util['format'](_0x8fd7('0x71'),_0x121008,_0x1869b1,_0x5ecf8a[_0x8fd7('0x72')]));_0x3e1066[_0x8fd7('0x73')]=_0x5ecf8a[_0x8fd7('0x74')];_0x3e1066[_0x8fd7('0x75')]=_0x5ecf8a[_0x8fd7('0x72')];logger[_0x8fd7('0x62')](util['format'](_0x8fd7('0x76'),_0x121008));return startTranscribe(_0x453a68,_0x40bad3,_0x87d967,uuidv4(),_0x102124,_0x5ecf8a[_0x8fd7('0x72')]);})[_0x8fd7('0x23')](function(_0x23044d){logger['info'](util['format']('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0x121008,_0x23044d[_0x8fd7('0x77')]['TranscriptionJobName']));_0x3e1066['transcribeName']=_0x23044d['TranscriptionJob'][_0x8fd7('0x78')];_0x3e1066[_0x8fd7('0x79')]=_0x23044d[_0x8fd7('0x77')][_0x8fd7('0x7a')];return _0x4737de(_0x3e1066);})['catch'](function(_0x4569fa){return _0x78dc0a(_0x4569fa);});});}exports[_0x8fd7('0x7b')]=function(_0x5896da,_0x3e5d74,_0x3dbcd4){var _0x2d5ef1;var _0x2c06a0;var _0x34eaf3;var _0x30ce4f=require('../../components/encryptor');return db[_0x8fd7('0x2b')][_0x8fd7('0x7c')]({'where':{'id':_0x5896da[_0x8fd7('0x46')]['id']}})[_0x8fd7('0x23')](function(_0x1d7928){if(_0x1d7928){var _0x3db0ae=util[_0x8fd7('0x2f')](_0x8fd7('0x61'),_0x1d7928[_0x8fd7('0x4c')]);if(fs['existsSync'](_0x3db0ae)){cypher=!![];return _0x30ce4f[_0x8fd7('0x4e')](_0x3db0ae,_0x1d7928[_0x8fd7('0x4c')],config[_0x8fd7('0x4f')][_0x8fd7('0x50')])['then'](function(){return _0x1d7928;});}return _0x1d7928;}})[_0x8fd7('0x23')](function(_0x52c7f2){if(!_0x52c7f2){throw new db[(_0x8fd7('0x51'))][(_0x8fd7('0x52'))](_0x8fd7('0x7d'));}_0x2c06a0=_0x52c7f2;return db[_0x8fd7('0x7e')]['findOne']({'where':{'id':0x1}});})[_0x8fd7('0x23')](handleEntityNotFound(_0x3e5d74,null))[_0x8fd7('0x23')](function(_0x57990c){if(_0x57990c){_0x2d5ef1=_0x57990c;if(!_0x2d5ef1[_0x8fd7('0x7f')]||!_0x2d5ef1[_0x8fd7('0x80')]||!_0x2d5ef1[_0x8fd7('0x81')]||!_0x2d5ef1['language']||!_0x2d5ef1[_0x8fd7('0x73')]){throw new db['Sequelize'][(_0x8fd7('0x52'))](_0x8fd7('0x82'));}if(_0x5896da[_0x8fd7('0x47')][_0x8fd7('0x83')]&&(!_0x2d5ef1[_0x8fd7('0x84')]||!_0x2d5ef1[_0x8fd7('0x85')]||!_0x2d5ef1[_0x8fd7('0x86')]||!_0x2d5ef1[_0x8fd7('0x87')]||!_0x2d5ef1[_0x8fd7('0x73')])){throw new db['Sequelize'][(_0x8fd7('0x52'))](_0x8fd7('0x88'));}return db[_0x8fd7('0x89')][_0x8fd7('0x7c')]({'where':{'id':_0x2d5ef1[_0x8fd7('0x80')]}});}})['then'](function(_0x1c2704){if(!_0x1c2704){throw new db[(_0x8fd7('0x51'))][(_0x8fd7('0x52'))]('Cloud\x20Provider\x20not\x20available');}if(!_0x1c2704['data1']||!_0x1c2704[_0x8fd7('0x8a')]){throw new db[(_0x8fd7('0x51'))]['ValidationError']('Cloud\x20Provider\x20not\x20configured');}_0x34eaf3=_0x1c2704;return getBucketslist(_0x34eaf3[_0x8fd7('0x8b')],_0x34eaf3['data2'],_0x2d5ef1[_0x8fd7('0x81')]);})[_0x8fd7('0x23')](function(_0x20a74e){if(_0x20a74e&&_0x20a74e[_0x8fd7('0x8c')]){var _0x6c914b=_[_0x8fd7('0x48')](_0x20a74e['Buckets'],function(_0x455a2b){return _0x455a2b['Name']===_0x2d5ef1[_0x8fd7('0x73')];});if(!_0x6c914b){logger['info'](util['format'](_0x8fd7('0x8d'),_0x5896da[_0x8fd7('0x46')]['id'],_0x2d5ef1[_0x8fd7('0x73')]));return createBucket(_0x34eaf3[_0x8fd7('0x8b')],_0x34eaf3[_0x8fd7('0x8a')],_0x2d5ef1[_0x8fd7('0x81')],_0x2d5ef1['bucket']);}logger[_0x8fd7('0x62')](util[_0x8fd7('0x2f')](_0x8fd7('0x8e'),_0x5896da[_0x8fd7('0x46')]['id'],_0x2d5ef1[_0x8fd7('0x73')]));return;}})[_0x8fd7('0x23')](function(_0x11465c){if(_0x2c06a0[_0x8fd7('0x79')]===_0x8fd7('0x8f')){return transcribe(_0x5896da['params']['id'],_0x34eaf3['data1'],_0x34eaf3[_0x8fd7('0x8a')],_0x2d5ef1[_0x8fd7('0x81')],_0x2d5ef1[_0x8fd7('0x73')],_0x2c06a0[_0x8fd7('0x4c')],_0x2d5ef1['language']);}else{logger[_0x8fd7('0x62')](util[_0x8fd7('0x2f')](_0x8fd7('0x90'),_0x5896da[_0x8fd7('0x46')]['id']));return{'transcribeStatus':_0x8fd7('0x91')};}})[_0x8fd7('0x23')](function(_0x1b8655){if(_0x1b8655){_0x1b8655[_0x8fd7('0x92')]=_0x5896da[_0x8fd7('0x47')][_0x8fd7('0x83')];return _0x2c06a0[_0x8fd7('0x93')](_0x1b8655);}})[_0x8fd7('0x23')](respondWithResult(_0x3e5d74,null))[_0x8fd7('0x44')](handleError(_0x3e5d74,null));};function writeFile(_0x5d6aeb,_0x36bc78){return new Promise(function(_0x3fc5e8,_0x36ad22){fs[_0x8fd7('0x94')](_0x36bc78,_0x5d6aeb,function(_0x5ed0ba,_0x44870d){if(_0x5ed0ba){return _0x36ad22(_0x5ed0ba);}else{return _0x3fc5e8(_0x44870d);}});});}exports[_0x8fd7('0x95')]=function(_0x47df84,_0x31c390,_0x2762c6){return db['VoiceRecording'][_0x8fd7('0x7c')]({'where':{'id':_0x47df84[_0x8fd7('0x46')]['id']}})[_0x8fd7('0x23')](handleEntityNotFound(_0x31c390))[_0x8fd7('0x23')](function(_0x37b58b){if(_0x37b58b&&_0x37b58b['fileText']){var _0x2c9b05=_0x37b58b[_0x8fd7('0x96')];var _0x405f2f=config[_0x8fd7('0x97')]+_0x8fd7('0x98')+_0x37b58b['id']+_0x8fd7('0x99');if(fs[_0x8fd7('0x4d')](_0x405f2f)){return _0x405f2f;}return writeFile(_0x2c9b05,_0x405f2f)['then'](function(){return _0x405f2f;});}else{throw new db['Sequelize'][(_0x8fd7('0x52'))]('Transcript\x20not\x20available');}})[_0x8fd7('0x23')](function(_0x1618b1){return _0x31c390['download'](_0x1618b1);})['catch'](handleError(_0x31c390));};
\ No newline at end of file