Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index e090989..cc8914d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1f01=['Transcribe\x20not\x20configured','runSentiment','sentiment','sentimentAccountId','sentimentRegion','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','transcribeAccountId','Cloud\x20Provider\x20not\x20available','data2','Cloud\x20Provider\x20not\x20configured','data1','Buckets','Name','NEW','tempSentiment','updateAttributes','writeFile','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','end','status','json','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','sendStatus','error','stack','name','send','index','VoiceRecording','fieldName','type','key','map','format','query','keys','filters','intersection','attributes','model','fields','length','nolimit','order','sort','pick','filter','merge','where','count','findAll','show','params','includeAll','include','options','find','create','catch','body','describe','download','uniqueid','value','%s.cypher','existsSync','decryptFile','secrets','ValidationError','VoiceRecording\x20not\x20found','filename','extname','unlink','message','Not\x20found','downloads','../../components/encryptor','sequelize','MD5','col','token','$and','push','recording','Sequelize','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','isNil','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','.cypher','listBuckets','createBucket','upload','TranscribeService','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','bucket','Bucket','location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','TranscriptionJob','TranscriptionJobName','transcribeName','transcribeStatus','TranscriptionJobStatus','findOne','Voice\x20Recording\x20not\x20found','transcribeRegion','language'];(function(_0x4d18a9,_0x820ca4){var _0x582cb5=function(_0x33cdc8){while(--_0x33cdc8){_0x4d18a9['push'](_0x4d18a9['shift']());}};_0x582cb5(++_0x820ca4);}(_0x1f01,0xae));var _0x11f0=function(_0x57ee8c,_0xe42849){_0x57ee8c=_0x57ee8c-0x0;var _0x3a2322=_0x1f01[_0x57ee8c];return _0x3a2322;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x11f0('0x0'));var rimraf=require(_0x11f0('0x1'));var zipdir=require(_0x11f0('0x2'));var jsonpatch=require(_0x11f0('0x3'));var rp=require(_0x11f0('0x4'));var moment=require(_0x11f0('0x5'));var BPromise=require(_0x11f0('0x6'));var Mustache=require(_0x11f0('0x7'));var util=require('util');var path=require(_0x11f0('0x8'));var sox=require(_0x11f0('0x9'));var csv=require('to-csv');var ejs=require(_0x11f0('0xa'));var fs=require('fs');var _=require(_0x11f0('0xb'));var squel=require(_0x11f0('0xc'));var crypto=require(_0x11f0('0xd'));var jsforce=require(_0x11f0('0xe'));var deskjs=require(_0x11f0('0xf'));var toCsv=require(_0x11f0('0x10'));var querystring=require('querystring');var Papa=require(_0x11f0('0x11'));var AWS=require('aws-sdk');var uuidv4=require(_0x11f0('0x12'));var Redis=require(_0x11f0('0x13'));var authService=require(_0x11f0('0x14'));var qs=require('../../components/parsers/qs');var as=require(_0x11f0('0x15'));var hardwareService=require(_0x11f0('0x16'));var logger=require(_0x11f0('0x17'))(_0x11f0('0x18'));var utils=require(_0x11f0('0x19'));var config=require(_0x11f0('0x1a'));var licenseUtil=require(_0x11f0('0x1b'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xe2b1ba,_0x58fa9f){_0x58fa9f=_0x58fa9f||0xcc;return function(_0x1a8d25){if(_0x1a8d25){return _0xe2b1ba['sendStatus'](_0x58fa9f);}return _0xe2b1ba['status'](_0x58fa9f)[_0x11f0('0x1c')]();};}function respondWithResult(_0x2cbc02,_0x1d39b3){_0x1d39b3=_0x1d39b3||0xc8;return function(_0x34288d){if(_0x34288d){return _0x2cbc02[_0x11f0('0x1d')](_0x1d39b3)[_0x11f0('0x1e')](_0x34288d);}};}function respondWithFilteredResult(_0x561117,_0x3359fb){return function(_0x36e558){if(_0x36e558){var _0x2514e3=_0x36e558['count'],_0x4b4535=_0x3359fb[_0x11f0('0x1f')],_0x33dd0e=_0x3359fb[_0x11f0('0x1f')]+_0x3359fb[_0x11f0('0x20')],_0x4a19dc;if(_0x33dd0e>=_0x2514e3){_0x33dd0e=_0x2514e3;_0x4a19dc=0xc8;}else{_0x4a19dc=0xce;}_0x561117[_0x11f0('0x1d')](_0x4a19dc);return _0x561117[_0x11f0('0x21')](_0x11f0('0x22'),_0x4b4535+'-'+_0x33dd0e+'/'+_0x2514e3)[_0x11f0('0x1e')](_0x36e558);}return null;};}function patchUpdates(_0x4ce094){return function(_0x18f1b8){try{jsonpatch[_0x11f0('0x23')](_0x18f1b8,_0x4ce094,!![]);}catch(_0x30ebd0){return BPromise[_0x11f0('0x24')](_0x30ebd0);}return _0x18f1b8[_0x11f0('0x25')]();};}function saveUpdates(_0x9a34ad,_0xc5608c){return function(_0x55f237){if(_0x55f237){return _0x55f237[_0x11f0('0x26')](_0x9a34ad)[_0x11f0('0x27')](function(_0x224e60){return _0x224e60;});}return null;};}function removeEntity(_0x343e96,_0x48bf22){return function(_0xf9551c){if(_0xf9551c){return _0xf9551c[_0x11f0('0x28')]()[_0x11f0('0x27')](function(){_0x343e96['status'](0xcc)[_0x11f0('0x1c')]();});}};}function handleEntityNotFound(_0x26187b,_0x1ee36b){return function(_0x560d12){if(!_0x560d12){_0x26187b[_0x11f0('0x29')](0x194);}return _0x560d12;};}function handleError(_0x5e1e03,_0x4353e0){_0x4353e0=_0x4353e0||0x1f4;return function(_0x372cbc){logger[_0x11f0('0x2a')](_0x372cbc[_0x11f0('0x2b')]);if(_0x372cbc[_0x11f0('0x2c')]){delete _0x372cbc['name'];}_0x5e1e03[_0x11f0('0x1d')](_0x4353e0)[_0x11f0('0x2d')](_0x372cbc);};}exports[_0x11f0('0x2e')]=function(_0xa91e03,_0x39c010){var _0xfb0a14={},_0x25d0a0={},_0x1fca8e={'count':0x0,'rows':[]};var _0x234dce=_['map'](db[_0x11f0('0x2f')]['rawAttributes'],function(_0x4d0477){return{'name':_0x4d0477[_0x11f0('0x30')],'type':_0x4d0477[_0x11f0('0x31')][_0x11f0('0x32')]};});_0x25d0a0['model']=_['differenceBy'](_[_0x11f0('0x33')](_0x234dce,'name'),[_0x11f0('0x34')]);_0x25d0a0[_0x11f0('0x35')]=_[_0x11f0('0x36')](_0xa91e03[_0x11f0('0x35')]);_0x25d0a0[_0x11f0('0x37')]=_[_0x11f0('0x38')](_0x25d0a0['model'],_0x25d0a0['query']);_0xfb0a14[_0x11f0('0x39')]=_[_0x11f0('0x38')](_0x25d0a0[_0x11f0('0x3a')],qs['fields'](_0xa91e03[_0x11f0('0x35')][_0x11f0('0x3b')]));_0xfb0a14[_0x11f0('0x39')]=_0xfb0a14[_0x11f0('0x39')][_0x11f0('0x3c')]?_0xfb0a14[_0x11f0('0x39')]:_0x25d0a0[_0x11f0('0x3a')];if(!_0xa91e03['query']['hasOwnProperty'](_0x11f0('0x3d'))){_0xfb0a14['limit']=qs['limit'](_0xa91e03[_0x11f0('0x35')]['limit']);_0xfb0a14[_0x11f0('0x1f')]=qs[_0x11f0('0x1f')](_0xa91e03[_0x11f0('0x35')][_0x11f0('0x1f')]);}_0xfb0a14[_0x11f0('0x3e')]=qs[_0x11f0('0x3f')](_0xa91e03['query'][_0x11f0('0x3f')]);_0xfb0a14['where']=qs[_0x11f0('0x37')](_[_0x11f0('0x40')](_0xa91e03[_0x11f0('0x35')],_0x25d0a0[_0x11f0('0x37')]),_0x234dce);if(_0xa91e03[_0x11f0('0x35')][_0x11f0('0x41')]){_0xfb0a14['where']=_[_0x11f0('0x42')](_0xfb0a14[_0x11f0('0x43')],{'$or':_[_0x11f0('0x33')](_0x234dce,function(_0xff872a){if(_0xff872a[_0x11f0('0x31')]!=='VIRTUAL'){var _0x2d00a0={};_0x2d00a0[_0xff872a[_0x11f0('0x2c')]]={'$like':'%'+_0xa91e03[_0x11f0('0x35')][_0x11f0('0x41')]+'%'};return _0x2d00a0;}})});}_0xfb0a14=_[_0x11f0('0x42')]({},_0xfb0a14,_0xa91e03['options']);var _0xe5840b={'where':_0xfb0a14[_0x11f0('0x43')]};return db[_0x11f0('0x2f')]['count'](_0xe5840b)[_0x11f0('0x27')](function(_0x54e11a){_0x1fca8e[_0x11f0('0x44')]=_0x54e11a;if(_0xa91e03['query']['includeAll']){_0xfb0a14['include']=[{'all':!![]}];}return db[_0x11f0('0x2f')][_0x11f0('0x45')](_0xfb0a14);})[_0x11f0('0x27')](function(_0x73bf7b){_0x1fca8e['rows']=_0x73bf7b;return _0x1fca8e;})[_0x11f0('0x27')](respondWithFilteredResult(_0x39c010,_0xfb0a14))['catch'](handleError(_0x39c010,null));};exports[_0x11f0('0x46')]=function(_0x29ec3e,_0x275237){var _0x21569f={'raw':![],'where':{'id':_0x29ec3e[_0x11f0('0x47')]['id']}},_0x2ac3dc={};_0x2ac3dc[_0x11f0('0x3a')]=_['keys'](db['VoiceRecording']['rawAttributes']);_0x2ac3dc[_0x11f0('0x35')]=_[_0x11f0('0x36')](_0x29ec3e[_0x11f0('0x35')]);_0x2ac3dc['filters']=_['intersection'](_0x2ac3dc[_0x11f0('0x3a')],_0x2ac3dc['query']);_0x21569f[_0x11f0('0x39')]=_[_0x11f0('0x38')](_0x2ac3dc[_0x11f0('0x3a')],qs['fields'](_0x29ec3e['query']['fields']));_0x21569f['attributes']=_0x21569f['attributes'][_0x11f0('0x3c')]?_0x21569f[_0x11f0('0x39')]:_0x2ac3dc['model'];if(_0x29ec3e[_0x11f0('0x35')][_0x11f0('0x48')]){_0x21569f[_0x11f0('0x49')]=[{'all':!![]}];}_0x21569f=_[_0x11f0('0x42')]({},_0x21569f,_0x29ec3e[_0x11f0('0x4a')]);return db[_0x11f0('0x2f')][_0x11f0('0x4b')](_0x21569f)[_0x11f0('0x27')](handleEntityNotFound(_0x275237,null))[_0x11f0('0x27')](respondWithResult(_0x275237,null))['catch'](handleError(_0x275237,null));};exports[_0x11f0('0x4c')]=function(_0x4af68d,_0x246efe){return db['VoiceRecording']['create'](_0x4af68d['body'],{})[_0x11f0('0x27')](respondWithResult(_0x246efe,0xc9))[_0x11f0('0x4d')](handleError(_0x246efe,null));};exports[_0x11f0('0x26')]=function(_0x182b5c,_0xf568a8){if(_0x182b5c['body']['id']){delete _0x182b5c[_0x11f0('0x4e')]['id'];}return db[_0x11f0('0x2f')][_0x11f0('0x4b')]({'where':{'id':_0x182b5c[_0x11f0('0x47')]['id']}})[_0x11f0('0x27')](handleEntityNotFound(_0xf568a8,null))[_0x11f0('0x27')](saveUpdates(_0x182b5c['body'],null))[_0x11f0('0x27')](respondWithResult(_0xf568a8,null))[_0x11f0('0x4d')](handleError(_0xf568a8,null));};exports['describe']=function(_0x79d137,_0x15e6f6){return db[_0x11f0('0x2f')][_0x11f0('0x4f')]()['then'](respondWithResult(_0x15e6f6,null))[_0x11f0('0x4d')](handleError(_0x15e6f6,null));};exports[_0x11f0('0x50')]=function(_0x329ccd,_0x4cd850,_0xf22ffc){var _0x391020=require('../../components/encryptor');var _0x136c43=![];var _0x3abc97={};if(_0x329ccd[_0x11f0('0x35')][_0x11f0('0x31')]&&_0x329ccd[_0x11f0('0x35')]['type']===_0x11f0('0x51')){_0x3abc97[_0x11f0('0x51')]=_0x329ccd['params']['id'];}else{_0x3abc97['id']=_0x329ccd[_0x11f0('0x47')]['id'];}return db['VoiceRecording']['find']({'where':_0x3abc97,'attributes':['id','value'],'raw':!![]})[_0x11f0('0x27')](handleEntityNotFound(_0x4cd850,null))[_0x11f0('0x27')](function(_0x20c969){if(_0x20c969){var _0x3295b0=_0x20c969[_0x11f0('0x52')];var _0x2ee59b=util['format'](_0x11f0('0x53'),_0x3295b0);if(fs[_0x11f0('0x54')](_0x2ee59b)){_0x136c43=!![];return _0x391020[_0x11f0('0x55')](_0x2ee59b,_0x3295b0,config[_0x11f0('0x56')]['recording'])[_0x11f0('0x27')](function(){return _0x20c969;});}return _0x20c969;}})[_0x11f0('0x27')](function(_0x1bd9ce){if(_0x1bd9ce){var _0x4496e1=_0x1bd9ce['value'];if(!fs[_0x11f0('0x54')](_0x4496e1)){throw new db['Sequelize'][(_0x11f0('0x57'))](_0x11f0('0x58'));}if(_0x1bd9ce[_0x11f0('0x59')]){return _0x4cd850[_0x11f0('0x50')](_0x4496e1,_0x1bd9ce[_0x11f0('0x59')]+path[_0x11f0('0x5a')](_0x4496e1),function(){if(_0x136c43){fs[_0x11f0('0x5b')](_0x4496e1);}});}else{return _0x4cd850[_0x11f0('0x50')](_0x4496e1,function(_0xb3051d){if(_0x136c43){fs[_0x11f0('0x5b')](_0x4496e1);}});}}})[_0x11f0('0x4d')](function(_0x29d51c){if(_0x29d51c[_0x11f0('0x5c')]===_0x11f0('0x58')){_0x4cd850['status'](0x194)[_0x11f0('0x2d')](_0x11f0('0x5d'));}else{return handleError(_0x4cd850,null);}});};exports[_0x11f0('0x5e')]=function(_0x52f856,_0x1f24e6,_0x4e39a1){var _0x17d11c=require(_0x11f0('0x5f'));var _0x7cc4fd=![];var _0x4cbced={'$and':[db[_0x11f0('0x60')]['where'](db[_0x11f0('0x60')]['fn'](_0x11f0('0x61'),db[_0x11f0('0x60')][_0x11f0('0x62')](_0x11f0('0x51'))),_0x52f856[_0x11f0('0x35')][_0x11f0('0x63')])]};if(_0x52f856[_0x11f0('0x35')][_0x11f0('0x31')]&&_0x52f856['query'][_0x11f0('0x31')]===_0x11f0('0x51')){_0x4cbced[_0x11f0('0x64')]['push']({'uniqueid':_0x52f856[_0x11f0('0x47')]['id']});}else{_0x4cbced[_0x11f0('0x64')][_0x11f0('0x65')]({'id':_0x52f856[_0x11f0('0x47')]['id']});}return db['VoiceRecording'][_0x11f0('0x4b')]({'where':_0x4cbced,'attributes':['id',_0x11f0('0x52')],'raw':!![]})[_0x11f0('0x27')](handleEntityNotFound(_0x1f24e6,null))[_0x11f0('0x27')](function(_0xc0a09d){if(_0xc0a09d){var _0x13113c=util['format'](_0x11f0('0x53'),_0xc0a09d[_0x11f0('0x52')]);if(fs[_0x11f0('0x54')](_0x13113c)){_0x7cc4fd=!![];return _0x17d11c[_0x11f0('0x55')](_0x13113c,_0xc0a09d[_0x11f0('0x52')],config[_0x11f0('0x56')][_0x11f0('0x66')])['then'](function(){return _0xc0a09d;});}return _0xc0a09d;}})[_0x11f0('0x27')](function(_0x4856cb){if(_0x4856cb){if(!fs['existsSync'](_0x4856cb[_0x11f0('0x52')])){throw new db[(_0x11f0('0x67'))][(_0x11f0('0x57'))](_0x11f0('0x58'));}if(_0x4856cb['filename']){return _0x1f24e6['download'](_0x4856cb[_0x11f0('0x52')],_0x4856cb['filename']+path[_0x11f0('0x5a')](_0x4856cb[_0x11f0('0x52')]),function(){if(_0x7cc4fd){fs[_0x11f0('0x5b')](_0x4856cb['value']);}});}else{return _0x1f24e6['download'](_0x4856cb[_0x11f0('0x52')],function(_0x998b6e){if(_0x7cc4fd){fs[_0x11f0('0x5b')](_0x4856cb['value']);}});}}})['catch'](handleError(_0x1f24e6,null));};exports[_0x11f0('0x28')]=function(_0x61f33c,_0x1b5954){return db[_0x11f0('0x2f')]['find']({'where':{'id':_0x61f33c[_0x11f0('0x47')]['id']}})[_0x11f0('0x27')](function(_0x450891){if(!_0x450891)throw new ReferenceError(_0x11f0('0x68'));return _0x450891;})[_0x11f0('0x27')](function(_0x352af2){var _0x41a073=_0x352af2[_0x11f0('0x52')];logger[_0x11f0('0x69')](_0x11f0('0x6a'),_0x41a073);if(!_[_0x11f0('0x6b')](_0x352af2[_0x11f0('0x52')])&&fs['existsSync'](_0x41a073)){logger[_0x11f0('0x69')]('File:\x20\x22'+_0x41a073+_0x11f0('0x6c'));fs[_0x11f0('0x6d')](_0x41a073);}_0x41a073=_0x41a073+_0x11f0('0x6e');if(!_[_0x11f0('0x6b')](_0x352af2[_0x11f0('0x52')])&&fs[_0x11f0('0x54')](_0x41a073)){logger[_0x11f0('0x69')]('File:\x20\x22'+_0x41a073+_0x11f0('0x6c'));fs[_0x11f0('0x6d')](_0x41a073);}return _0x352af2;})[_0x11f0('0x27')](function(_0x130518){if(!_0x130518)throw new InternalError();return _0x130518[_0x11f0('0x28')]();})[_0x11f0('0x27')](function(){_0x1b5954[_0x11f0('0x1d')](0xcc)['end']();})['catch'](handleError(_0x1b5954,null));};function getBucketslist(_0x514549,_0x1074ef,_0x15a9e4){return new Promise(function(_0x331c9d,_0x15dfff){var _0x5bceac=new AWS['S3']({'accessKeyId':_0x1074ef,'secretAccessKey':_0x514549,'region':_0x15a9e4});_0x5bceac[_0x11f0('0x6f')]({},function(_0x483c42,_0x5522eb){if(_0x483c42){return _0x15dfff(_0x483c42);}else{return _0x331c9d(_0x5522eb);}});});}function createBucket(_0x30df2c,_0x570daf,_0x40920b,_0x1b7192){return new Promise(function(_0x39791d,_0x490532){var _0xe7bdd8=new AWS['S3']({'accessKeyId':_0x570daf,'secretAccessKey':_0x30df2c,'region':_0x40920b});_0xe7bdd8[_0x11f0('0x70')]({'Bucket':_0x1b7192},function(_0x43d48a,_0x36aacb){if(_0x43d48a){return _0x490532(_0x43d48a);}else{return _0x39791d(_0x36aacb);}});});}function uploadFile(_0x35cf68,_0x3fd199,_0x391575,_0xcfeb44,_0x539119,_0x47e25d){return new Promise(function(_0x4b7f44,_0x12fd38){var _0x25dadf=new AWS['S3']({'accessKeyId':_0x3fd199,'secretAccessKey':_0x35cf68,'region':_0x391575});_0x25dadf[_0x11f0('0x71')]({'Bucket':_0xcfeb44,'Key':_0x539119,'Body':_0x47e25d},function(_0x31cefb,_0x3ca72c){if(_0x31cefb){return _0x12fd38(_0x31cefb);}else{return _0x4b7f44(_0x3ca72c);}});});}function startTranscribe(_0x464f9c,_0x1c058e,_0x35893f,_0x286447,_0x59e6eb,_0x5cf4f0){return new Promise(function(_0x6569a6,_0x152efe){var _0x3e8cb4=new AWS[(_0x11f0('0x72'))]({'accessKeyId':_0x1c058e,'secretAccessKey':_0x464f9c,'region':_0x35893f});_0x3e8cb4['startTranscriptionJob']({'TranscriptionJobName':_0x286447,'LanguageCode':_0x59e6eb,'Media':{'MediaFileUri':_0x5cf4f0}},function(_0x50dd24,_0x82b3b6){if(_0x50dd24){return _0x152efe(_0x50dd24);}else{return _0x6569a6(_0x82b3b6);}});});}function transcribe(_0xda4f4f,_0x13ecf7,_0x273996,_0x98746f,_0x2cae63,_0x1b370c,_0x3104cf){return new Promise(function(_0x27ae9a,_0x1d70a1){var _0x24ec0d={};logger[_0x11f0('0x69')](util[_0x11f0('0x34')]('[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s',_0xda4f4f,_0x2cae63));return uploadFile(_0x13ecf7,_0x273996,_0x98746f,_0x2cae63,path['basename'](_0x1b370c),fs['readFileSync'](_0x1b370c))['then'](function(_0x190bb2){logger['info'](util[_0x11f0('0x34')](_0x11f0('0x73'),_0xda4f4f,_0x2cae63,_0x190bb2[_0x11f0('0x74')]));_0x24ec0d[_0x11f0('0x75')]=_0x190bb2[_0x11f0('0x76')];_0x24ec0d[_0x11f0('0x77')]=_0x190bb2[_0x11f0('0x74')];logger[_0x11f0('0x69')](util['format'](_0x11f0('0x78'),_0xda4f4f));return startTranscribe(_0x13ecf7,_0x273996,_0x98746f,uuidv4(),_0x3104cf,_0x190bb2[_0x11f0('0x74')]);})[_0x11f0('0x27')](function(_0x2576fa){logger[_0x11f0('0x69')](util['format']('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0xda4f4f,_0x2576fa[_0x11f0('0x79')][_0x11f0('0x7a')]));_0x24ec0d[_0x11f0('0x7b')]=_0x2576fa[_0x11f0('0x79')][_0x11f0('0x7a')];_0x24ec0d[_0x11f0('0x7c')]=_0x2576fa['TranscriptionJob'][_0x11f0('0x7d')];return _0x27ae9a(_0x24ec0d);})[_0x11f0('0x4d')](function(_0x1cec79){return _0x1d70a1(_0x1cec79);});});}exports['runTranscribe']=function(_0x177935,_0x5f518c,_0xef651b){var _0x4699fa;var _0x35ac24;var _0x17c93f;var _0x590b6a=require(_0x11f0('0x5f'));return db[_0x11f0('0x2f')][_0x11f0('0x7e')]({'where':{'id':_0x177935[_0x11f0('0x47')]['id']}})['then'](function(_0x32c068){if(_0x32c068){var _0x3157d=util[_0x11f0('0x34')](_0x11f0('0x53'),_0x32c068[_0x11f0('0x52')]);if(fs['existsSync'](_0x3157d)){cypher=!![];return _0x590b6a[_0x11f0('0x55')](_0x3157d,_0x32c068['value'],config['secrets'][_0x11f0('0x66')])['then'](function(){return _0x32c068;});}return _0x32c068;}})['then'](function(_0x57965d){if(!_0x57965d){throw new db[(_0x11f0('0x67'))][(_0x11f0('0x57'))](_0x11f0('0x7f'));}_0x35ac24=_0x57965d;return db['Setting']['findOne']({'where':{'id':0x1}});})[_0x11f0('0x27')](handleEntityNotFound(_0x5f518c,null))[_0x11f0('0x27')](function(_0x589c2a){if(_0x589c2a){_0x4699fa=_0x589c2a;if(!_0x4699fa['transcribe']||!_0x4699fa['transcribeAccountId']||!_0x4699fa[_0x11f0('0x80')]||!_0x4699fa[_0x11f0('0x81')]||!_0x4699fa[_0x11f0('0x75')]){throw new db[(_0x11f0('0x67'))][(_0x11f0('0x57'))](_0x11f0('0x82'));}if(_0x177935[_0x11f0('0x4e')][_0x11f0('0x83')]&&(!_0x4699fa[_0x11f0('0x84')]||!_0x4699fa[_0x11f0('0x85')]||!_0x4699fa[_0x11f0('0x86')]||!_0x4699fa[_0x11f0('0x81')]||!_0x4699fa[_0x11f0('0x75')])){throw new db[(_0x11f0('0x67'))][(_0x11f0('0x57'))](_0x11f0('0x87'));}return db[_0x11f0('0x88')]['findOne']({'where':{'id':_0x4699fa[_0x11f0('0x89')]}});}})[_0x11f0('0x27')](function(_0x2e7739){if(!_0x2e7739){throw new db[(_0x11f0('0x67'))][(_0x11f0('0x57'))](_0x11f0('0x8a'));}if(!_0x2e7739['data1']||!_0x2e7739[_0x11f0('0x8b')]){throw new db[(_0x11f0('0x67'))][(_0x11f0('0x57'))](_0x11f0('0x8c'));}_0x17c93f=_0x2e7739;return getBucketslist(_0x17c93f[_0x11f0('0x8d')],_0x17c93f[_0x11f0('0x8b')],_0x4699fa[_0x11f0('0x80')]);})[_0x11f0('0x27')](function(_0x5c45f2){if(_0x5c45f2&&_0x5c45f2[_0x11f0('0x8e')]){var _0xd036c6=_['find'](_0x5c45f2['Buckets'],function(_0x408fe5){return _0x408fe5[_0x11f0('0x8f')]===_0x4699fa['bucket'];});if(!_0xd036c6){logger[_0x11f0('0x69')](util['format']('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available',_0x177935[_0x11f0('0x47')]['id'],_0x4699fa[_0x11f0('0x75')]));return createBucket(_0x17c93f['data1'],_0x17c93f['data2'],_0x4699fa[_0x11f0('0x80')],_0x4699fa[_0x11f0('0x75')]);}logger[_0x11f0('0x69')](util[_0x11f0('0x34')]('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available',_0x177935[_0x11f0('0x47')]['id'],_0x4699fa[_0x11f0('0x75')]));return;}})[_0x11f0('0x27')](function(_0x2a8268){if(_0x35ac24[_0x11f0('0x7c')]===_0x11f0('0x90')){return transcribe(_0x177935[_0x11f0('0x47')]['id'],_0x17c93f[_0x11f0('0x8d')],_0x17c93f[_0x11f0('0x8b')],_0x4699fa[_0x11f0('0x80')],_0x4699fa[_0x11f0('0x75')],_0x35ac24[_0x11f0('0x52')],_0x4699fa['language']);}else{logger[_0x11f0('0x69')](util[_0x11f0('0x34')]('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x177935[_0x11f0('0x47')]['id']));return{'transcribeStatus':'IN_PROGRESS'};}})['then'](function(_0x587892){if(_0x587892){_0x587892[_0x11f0('0x91')]=_0x177935[_0x11f0('0x4e')][_0x11f0('0x83')];return _0x35ac24[_0x11f0('0x92')](_0x587892);}})[_0x11f0('0x27')](respondWithResult(_0x5f518c,null))[_0x11f0('0x4d')](handleError(_0x5f518c,null));};function writeFile(_0x14690c,_0x28e1cf){return new Promise(function(_0x33230f,_0xe397d3){fs[_0x11f0('0x93')](_0x28e1cf,_0x14690c,function(_0x17a3fe,_0x46ea64){if(_0x17a3fe){return _0xe397d3(_0x17a3fe);}else{return _0x33230f(_0x46ea64);}});});}exports[_0x11f0('0x94')]=function(_0x5b966b,_0x2871b4,_0x2437d5){return db['VoiceRecording'][_0x11f0('0x7e')]({'where':{'id':_0x5b966b[_0x11f0('0x47')]['id']}})[_0x11f0('0x27')](handleEntityNotFound(_0x2871b4))[_0x11f0('0x27')](function(_0x506ad5){if(_0x506ad5&&_0x506ad5[_0x11f0('0x95')]){var _0x4021f4=_0x506ad5[_0x11f0('0x95')];var _0x137d11=config[_0x11f0('0x96')]+_0x11f0('0x97')+_0x506ad5['id']+'.txt';if(fs['existsSync'](_0x137d11)){return _0x137d11;}return writeFile(_0x4021f4,_0x137d11)[_0x11f0('0x27')](function(){return _0x137d11;});}else{throw new db['Sequelize'][(_0x11f0('0x57'))]('Transcript\x20not\x20available');}})['then'](function(_0x13621b){return _0x2871b4[_0x11f0('0x50')](_0x13621b);})[_0x11f0('0x4d')](handleError(_0x2871b4));};
\ No newline at end of file
+var _0xb419=['util','path','sox','to-csv','fs-extra','crypto','jsforce','desk.js','papaparse','aws-sdk','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/license/util','../../mysqldb','sendStatus','end','json','offset','undefined','count','limit','Content-Range','apply','reject','save','then','destroy','status','stack','name','send','index','map','VoiceRecording','rawAttributes','fieldName','type','key','model','format','keys','query','filters','intersection','attributes','fields','nolimit','order','sort','where','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','length','merge','create','body','update','describe','download','../../components/encryptor','uniqueid','find','value','%s.cypher','existsSync','decryptFile','secrets','recording','Sequelize','VoiceRecording\x20not\x20found','filename','extname','unlink','message','Not\x20found','downloads','sequelize','token','$and','push','ValidationError','isNil','info','cancellazione\x20fisica\x20documento\x20%s','unlinkSync','.cypher','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','listBuckets','createBucket','upload','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','basename','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','Bucket','location','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','TranscriptionJobName','transcribeName','TranscriptionJob','transcribeStatus','runTranscribe','Voice\x20Recording\x20not\x20found','Setting','findOne','transcribe','transcribeAccountId','transcribeRegion','bucket','Transcribe\x20not\x20configured','sentiment','sentimentAccountId','sentimentRegion','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','data1','data2','Buckets','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','NEW','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','runSentiment','updateAttributes','writeFile','downloadTranscribe','root','/server/files/transcribes/transcribe_','.txt','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache'];(function(_0x3156aa,_0x407b77){var _0x2333b3=function(_0x30e1e8){while(--_0x30e1e8){_0x3156aa['push'](_0x3156aa['shift']());}};_0x2333b3(++_0x407b77);}(_0xb419,0x93));var _0x9b41=function(_0x8efe57,_0x272d80){_0x8efe57=_0x8efe57-0x0;var _0x3c8735=_0xb419[_0x8efe57];return _0x3c8735;};'use strict';var emlformat=require(_0x9b41('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x9b41('0x1'));var jsonpatch=require(_0x9b41('0x2'));var rp=require(_0x9b41('0x3'));var moment=require('moment');var BPromise=require(_0x9b41('0x4'));var Mustache=require(_0x9b41('0x5'));var util=require(_0x9b41('0x6'));var path=require(_0x9b41('0x7'));var sox=require(_0x9b41('0x8'));var csv=require(_0x9b41('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9b41('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x9b41('0xb'));var jsforce=require(_0x9b41('0xc'));var deskjs=require(_0x9b41('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x9b41('0xe'));var AWS=require(_0x9b41('0xf'));var uuidv4=require(_0x9b41('0x10'));var Redis=require(_0x9b41('0x11'));var authService=require(_0x9b41('0x12'));var qs=require(_0x9b41('0x13'));var as=require(_0x9b41('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9b41('0x15'))(_0x9b41('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x9b41('0x17'));var db=require(_0x9b41('0x18'))['db'];function respondWithStatusCode(_0x428cc5,_0x1cf5cb){_0x1cf5cb=_0x1cf5cb||0xcc;return function(_0x8230e8){if(_0x8230e8){return _0x428cc5[_0x9b41('0x19')](_0x1cf5cb);}return _0x428cc5['status'](_0x1cf5cb)[_0x9b41('0x1a')]();};}function respondWithResult(_0xc0e611,_0x115ef0){_0x115ef0=_0x115ef0||0xc8;return function(_0x210edd){if(_0x210edd){return _0xc0e611['status'](_0x115ef0)[_0x9b41('0x1b')](_0x210edd);}};}function respondWithFilteredResult(_0x184556,_0x2f857b){return function(_0x2cca07){if(_0x2cca07){var _0x48626e=typeof _0x2f857b[_0x9b41('0x1c')]===_0x9b41('0x1d')&&typeof _0x2f857b['limit']===_0x9b41('0x1d');var _0x3a94f0=_0x2cca07['count'];var _0x287a41=_0x48626e?0x0:_0x2f857b[_0x9b41('0x1c')];var _0x6a798e=_0x48626e?_0x2cca07[_0x9b41('0x1e')]:_0x2f857b[_0x9b41('0x1c')]+_0x2f857b[_0x9b41('0x1f')];var _0x1ab436;if(_0x6a798e>=_0x3a94f0){_0x6a798e=_0x3a94f0;_0x1ab436=0xc8;}else{_0x1ab436=0xce;}_0x184556['status'](_0x1ab436);return _0x184556['set'](_0x9b41('0x20'),_0x287a41+'-'+_0x6a798e+'/'+_0x3a94f0)[_0x9b41('0x1b')](_0x2cca07);}return null;};}function patchUpdates(_0x2ccd45){return function(_0x36130b){try{jsonpatch[_0x9b41('0x21')](_0x36130b,_0x2ccd45,!![]);}catch(_0x100675){return BPromise[_0x9b41('0x22')](_0x100675);}return _0x36130b[_0x9b41('0x23')]();};}function saveUpdates(_0x5a3dfe,_0x3b831d){return function(_0x294372){if(_0x294372){return _0x294372['update'](_0x5a3dfe)[_0x9b41('0x24')](function(_0x26735a){return _0x26735a;});}return null;};}function removeEntity(_0xa8262,_0x3b15b4){return function(_0x317825){if(_0x317825){return _0x317825[_0x9b41('0x25')]()[_0x9b41('0x24')](function(){_0xa8262[_0x9b41('0x26')](0xcc)[_0x9b41('0x1a')]();});}};}function handleEntityNotFound(_0x235af7,_0x4d4a83){return function(_0x5060d6){if(!_0x5060d6){_0x235af7['sendStatus'](0x194);}return _0x5060d6;};}function handleError(_0x10086b,_0x278ed5){_0x278ed5=_0x278ed5||0x1f4;return function(_0x584669){logger['error'](_0x584669[_0x9b41('0x27')]);if(_0x584669[_0x9b41('0x28')]){delete _0x584669['name'];}_0x10086b[_0x9b41('0x26')](_0x278ed5)[_0x9b41('0x29')](_0x584669);};}exports[_0x9b41('0x2a')]=function(_0xd5a163,_0x124466){var _0x16f0cd={},_0x2b814f={},_0x1d0ac9={'count':0x0,'rows':[]};var _0x59acd7=_[_0x9b41('0x2b')](db[_0x9b41('0x2c')][_0x9b41('0x2d')],function(_0x9c536){return{'name':_0x9c536[_0x9b41('0x2e')],'type':_0x9c536[_0x9b41('0x2f')][_0x9b41('0x30')]};});_0x2b814f[_0x9b41('0x31')]=_['differenceBy'](_[_0x9b41('0x2b')](_0x59acd7,_0x9b41('0x28')),[_0x9b41('0x32')]);_0x2b814f['query']=_[_0x9b41('0x33')](_0xd5a163[_0x9b41('0x34')]);_0x2b814f[_0x9b41('0x35')]=_[_0x9b41('0x36')](_0x2b814f['model'],_0x2b814f[_0x9b41('0x34')]);_0x16f0cd[_0x9b41('0x37')]=_['intersection'](_0x2b814f[_0x9b41('0x31')],qs[_0x9b41('0x38')](_0xd5a163[_0x9b41('0x34')]['fields']));_0x16f0cd[_0x9b41('0x37')]=_0x16f0cd[_0x9b41('0x37')]['length']?_0x16f0cd[_0x9b41('0x37')]:_0x2b814f[_0x9b41('0x31')];if(!_0xd5a163[_0x9b41('0x34')]['hasOwnProperty'](_0x9b41('0x39'))){_0x16f0cd[_0x9b41('0x1f')]=qs[_0x9b41('0x1f')](_0xd5a163[_0x9b41('0x34')][_0x9b41('0x1f')]);_0x16f0cd[_0x9b41('0x1c')]=qs[_0x9b41('0x1c')](_0xd5a163[_0x9b41('0x34')][_0x9b41('0x1c')]);}_0x16f0cd[_0x9b41('0x3a')]=qs[_0x9b41('0x3b')](_0xd5a163[_0x9b41('0x34')][_0x9b41('0x3b')]);_0x16f0cd[_0x9b41('0x3c')]=qs[_0x9b41('0x35')](_['pick'](_0xd5a163[_0x9b41('0x34')],_0x2b814f['filters']),_0x59acd7);if(_0xd5a163[_0x9b41('0x34')]['filter']){_0x16f0cd[_0x9b41('0x3c')]=_['merge'](_0x16f0cd[_0x9b41('0x3c')],{'$or':_[_0x9b41('0x2b')](_0x59acd7,function(_0xd22696){if(_0xd22696[_0x9b41('0x2f')]!==_0x9b41('0x3d')){var _0x17562a={};_0x17562a[_0xd22696[_0x9b41('0x28')]]={'$like':'%'+_0xd5a163[_0x9b41('0x34')][_0x9b41('0x3e')]+'%'};return _0x17562a;}})});}_0x16f0cd=_['merge']({},_0x16f0cd,_0xd5a163[_0x9b41('0x3f')]);var _0x285375={'where':_0x16f0cd[_0x9b41('0x3c')]};return db['VoiceRecording'][_0x9b41('0x1e')](_0x285375)['then'](function(_0x190030){_0x1d0ac9['count']=_0x190030;if(_0xd5a163[_0x9b41('0x34')][_0x9b41('0x40')]){_0x16f0cd[_0x9b41('0x41')]=[{'all':!![]}];}return db[_0x9b41('0x2c')][_0x9b41('0x42')](_0x16f0cd);})[_0x9b41('0x24')](function(_0x4d8e2c){_0x1d0ac9[_0x9b41('0x43')]=_0x4d8e2c;return _0x1d0ac9;})[_0x9b41('0x24')](respondWithFilteredResult(_0x124466,_0x16f0cd))[_0x9b41('0x44')](handleError(_0x124466,null));};exports[_0x9b41('0x45')]=function(_0x34fb54,_0x41bbde){var _0xfac657={'raw':![],'where':{'id':_0x34fb54[_0x9b41('0x46')]['id']}},_0x262705={};_0x262705[_0x9b41('0x31')]=_[_0x9b41('0x33')](db[_0x9b41('0x2c')][_0x9b41('0x2d')]);_0x262705['query']=_[_0x9b41('0x33')](_0x34fb54[_0x9b41('0x34')]);_0x262705['filters']=_[_0x9b41('0x36')](_0x262705[_0x9b41('0x31')],_0x262705[_0x9b41('0x34')]);_0xfac657['attributes']=_['intersection'](_0x262705[_0x9b41('0x31')],qs[_0x9b41('0x38')](_0x34fb54[_0x9b41('0x34')][_0x9b41('0x38')]));_0xfac657[_0x9b41('0x37')]=_0xfac657[_0x9b41('0x37')][_0x9b41('0x47')]?_0xfac657[_0x9b41('0x37')]:_0x262705['model'];if(_0x34fb54[_0x9b41('0x34')][_0x9b41('0x40')]){_0xfac657[_0x9b41('0x41')]=[{'all':!![]}];}_0xfac657=_[_0x9b41('0x48')]({},_0xfac657,_0x34fb54[_0x9b41('0x3f')]);return db[_0x9b41('0x2c')]['find'](_0xfac657)[_0x9b41('0x24')](handleEntityNotFound(_0x41bbde,null))[_0x9b41('0x24')](respondWithResult(_0x41bbde,null))[_0x9b41('0x44')](handleError(_0x41bbde,null));};exports[_0x9b41('0x49')]=function(_0x50887d,_0x4494db){return db[_0x9b41('0x2c')][_0x9b41('0x49')](_0x50887d[_0x9b41('0x4a')],{})['then'](respondWithResult(_0x4494db,0xc9))[_0x9b41('0x44')](handleError(_0x4494db,null));};exports[_0x9b41('0x4b')]=function(_0x371157,_0x589aef){if(_0x371157['body']['id']){delete _0x371157[_0x9b41('0x4a')]['id'];}return db[_0x9b41('0x2c')]['find']({'where':{'id':_0x371157[_0x9b41('0x46')]['id']}})[_0x9b41('0x24')](handleEntityNotFound(_0x589aef,null))[_0x9b41('0x24')](saveUpdates(_0x371157[_0x9b41('0x4a')],null))[_0x9b41('0x24')](respondWithResult(_0x589aef,null))['catch'](handleError(_0x589aef,null));};exports['describe']=function(_0x1ba25c,_0x1022a){return db['VoiceRecording'][_0x9b41('0x4c')]()[_0x9b41('0x24')](respondWithResult(_0x1022a,null))[_0x9b41('0x44')](handleError(_0x1022a,null));};exports[_0x9b41('0x4d')]=function(_0x1ace47,_0x1a388e,_0x57b839){var _0x3c076f=require(_0x9b41('0x4e'));var _0x33ad6d=![];var _0x5a0841={};if(_0x1ace47[_0x9b41('0x34')][_0x9b41('0x2f')]&&_0x1ace47[_0x9b41('0x34')][_0x9b41('0x2f')]===_0x9b41('0x4f')){_0x5a0841['uniqueid']=_0x1ace47[_0x9b41('0x46')]['id'];}else{_0x5a0841['id']=_0x1ace47['params']['id'];}return db[_0x9b41('0x2c')][_0x9b41('0x50')]({'where':_0x5a0841,'attributes':['id',_0x9b41('0x51')],'raw':!![]})['then'](handleEntityNotFound(_0x1a388e,null))[_0x9b41('0x24')](function(_0x4e3118){if(_0x4e3118){var _0x321809=_0x4e3118['value'];var _0x25cac6=util[_0x9b41('0x32')](_0x9b41('0x52'),_0x321809);if(fs[_0x9b41('0x53')](_0x25cac6)){_0x33ad6d=!![];return _0x3c076f[_0x9b41('0x54')](_0x25cac6,_0x321809,config[_0x9b41('0x55')][_0x9b41('0x56')])[_0x9b41('0x24')](function(){return _0x4e3118;});}return _0x4e3118;}})[_0x9b41('0x24')](function(_0x372a8d){if(_0x372a8d){var _0x528b9e=_0x372a8d[_0x9b41('0x51')];if(!fs[_0x9b41('0x53')](_0x528b9e)){throw new db[(_0x9b41('0x57'))]['ValidationError'](_0x9b41('0x58'));}if(_0x372a8d[_0x9b41('0x59')]){return _0x1a388e[_0x9b41('0x4d')](_0x528b9e,_0x372a8d[_0x9b41('0x59')]+path[_0x9b41('0x5a')](_0x528b9e),function(){if(_0x33ad6d){fs[_0x9b41('0x5b')](_0x528b9e);}});}else{return _0x1a388e[_0x9b41('0x4d')](_0x528b9e,function(_0xad124d){if(_0x33ad6d){fs['unlink'](_0x528b9e);}});}}})[_0x9b41('0x44')](function(_0x2f453f){if(_0x2f453f[_0x9b41('0x5c')]===_0x9b41('0x58')){_0x1a388e[_0x9b41('0x26')](0x194)[_0x9b41('0x29')](_0x9b41('0x5d'));}else{return handleError(_0x1a388e,null);}});};exports[_0x9b41('0x5e')]=function(_0x36c2b1,_0x3320a5,_0x1d1ce5){var _0x10fbb2=require('../../components/encryptor');var _0x332a2e=![];var _0x5eb5dd={'$and':[db[_0x9b41('0x5f')]['where'](db[_0x9b41('0x5f')]['fn']('MD5',db[_0x9b41('0x5f')]['col'](_0x9b41('0x4f'))),_0x36c2b1[_0x9b41('0x34')][_0x9b41('0x60')])]};if(_0x36c2b1['query'][_0x9b41('0x2f')]&&_0x36c2b1[_0x9b41('0x34')][_0x9b41('0x2f')]==='uniqueid'){_0x5eb5dd[_0x9b41('0x61')][_0x9b41('0x62')]({'uniqueid':_0x36c2b1[_0x9b41('0x46')]['id']});}else{_0x5eb5dd[_0x9b41('0x61')][_0x9b41('0x62')]({'id':_0x36c2b1[_0x9b41('0x46')]['id']});}return db[_0x9b41('0x2c')][_0x9b41('0x50')]({'where':_0x5eb5dd,'attributes':['id',_0x9b41('0x51')],'raw':!![]})['then'](handleEntityNotFound(_0x3320a5,null))['then'](function(_0x2dcddc){if(_0x2dcddc){var _0x392a4a=util[_0x9b41('0x32')]('%s.cypher',_0x2dcddc['value']);if(fs['existsSync'](_0x392a4a)){_0x332a2e=!![];return _0x10fbb2[_0x9b41('0x54')](_0x392a4a,_0x2dcddc['value'],config[_0x9b41('0x55')][_0x9b41('0x56')])[_0x9b41('0x24')](function(){return _0x2dcddc;});}return _0x2dcddc;}})[_0x9b41('0x24')](function(_0x1de2cd){if(_0x1de2cd){if(!fs['existsSync'](_0x1de2cd[_0x9b41('0x51')])){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))](_0x9b41('0x58'));}if(_0x1de2cd[_0x9b41('0x59')]){return _0x3320a5[_0x9b41('0x4d')](_0x1de2cd[_0x9b41('0x51')],_0x1de2cd['filename']+path[_0x9b41('0x5a')](_0x1de2cd['value']),function(){if(_0x332a2e){fs['unlink'](_0x1de2cd['value']);}});}else{return _0x3320a5[_0x9b41('0x4d')](_0x1de2cd[_0x9b41('0x51')],function(_0x25e254){if(_0x332a2e){fs[_0x9b41('0x5b')](_0x1de2cd[_0x9b41('0x51')]);}});}}})[_0x9b41('0x44')](handleError(_0x3320a5,null));};exports[_0x9b41('0x25')]=function(_0x3a75e7,_0x54a8f8){return db[_0x9b41('0x2c')][_0x9b41('0x50')]({'where':{'id':_0x3a75e7[_0x9b41('0x46')]['id']}})[_0x9b41('0x24')](function(_0x4b8472){if(_[_0x9b41('0x64')](_0x4b8472)){throw new ReferenceError('Entity\x20not\x20found');}return _0x4b8472;})['then'](function(_0x15da20){var _0x3b1b97=_0x15da20[_0x9b41('0x51')];logger[_0x9b41('0x65')](_0x9b41('0x66'),_0x3b1b97);if(!_[_0x9b41('0x64')](_0x15da20[_0x9b41('0x51')])&&fs[_0x9b41('0x53')](_0x3b1b97)){logger['info']('File:\x20\x22'+_0x3b1b97+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione');fs[_0x9b41('0x67')](_0x3b1b97);}_0x3b1b97=_0x3b1b97+_0x9b41('0x68');if(!_[_0x9b41('0x64')](_0x15da20[_0x9b41('0x51')])&&fs[_0x9b41('0x53')](_0x3b1b97)){logger[_0x9b41('0x65')](_0x9b41('0x69')+_0x3b1b97+_0x9b41('0x6a'));fs['unlinkSync'](_0x3b1b97);}return _0x15da20;})[_0x9b41('0x24')](function(_0x330fd3){if(!_0x330fd3)throw new InternalError();return _0x330fd3['destroy']();})['then'](function(){_0x54a8f8[_0x9b41('0x26')](0xcc)[_0x9b41('0x1a')]();})[_0x9b41('0x44')](handleError(_0x54a8f8,null));};function getBucketslist(_0x127ab3,_0x206c53,_0x35e11){return new Promise(function(_0x7335ae,_0x33a9d3){var _0x1f76b3=new AWS['S3']({'accessKeyId':_0x206c53,'secretAccessKey':_0x127ab3,'region':_0x35e11});_0x1f76b3[_0x9b41('0x6b')]({},function(_0xd00add,_0x142444){if(_0xd00add){return _0x33a9d3(_0xd00add);}else{return _0x7335ae(_0x142444);}});});}function createBucket(_0x14294f,_0x3a6c26,_0x3f8ded,_0x19c336){return new Promise(function(_0x61fb62,_0x25e002){var _0x34b234=new AWS['S3']({'accessKeyId':_0x3a6c26,'secretAccessKey':_0x14294f,'region':_0x3f8ded});_0x34b234[_0x9b41('0x6c')]({'Bucket':_0x19c336},function(_0x53e675,_0x234b21){if(_0x53e675){return _0x25e002(_0x53e675);}else{return _0x61fb62(_0x234b21);}});});}function uploadFile(_0x204cad,_0x3cf9b2,_0x2f3160,_0x2c2757,_0x5a3702,_0x337863){return new Promise(function(_0x4aaca9,_0x22d3eb){var _0x154d6c=new AWS['S3']({'accessKeyId':_0x3cf9b2,'secretAccessKey':_0x204cad,'region':_0x2f3160});_0x154d6c[_0x9b41('0x6d')]({'Bucket':_0x2c2757,'Key':_0x5a3702,'Body':_0x337863},function(_0x2c7258,_0x41a53d){if(_0x2c7258){return _0x22d3eb(_0x2c7258);}else{return _0x4aaca9(_0x41a53d);}});});}function startTranscribe(_0xefaea7,_0x2c5d21,_0xab388c,_0x4b4ac1,_0xb3377a,_0xe53b4f){return new Promise(function(_0x448410,_0x3a1343){var _0x2dffda=new AWS['TranscribeService']({'accessKeyId':_0x2c5d21,'secretAccessKey':_0xefaea7,'region':_0xab388c});_0x2dffda[_0x9b41('0x6e')]({'TranscriptionJobName':_0x4b4ac1,'LanguageCode':_0xb3377a,'Media':{'MediaFileUri':_0xe53b4f}},function(_0x2bf85a,_0x2c97e3){if(_0x2bf85a){return _0x3a1343(_0x2bf85a);}else{return _0x448410(_0x2c97e3);}});});}function transcribe(_0x51c62c,_0x3fc641,_0x48c1e8,_0x59f172,_0x3e1d2e,_0x20c663,_0x2e41c7){return new Promise(function(_0x31ce2e,_0x2b835c){var _0x51ad9b={};logger['info'](util[_0x9b41('0x32')](_0x9b41('0x6f'),_0x51c62c,_0x3e1d2e));return uploadFile(_0x3fc641,_0x48c1e8,_0x59f172,_0x3e1d2e,path[_0x9b41('0x70')](_0x20c663),fs[_0x9b41('0x71')](_0x20c663))[_0x9b41('0x24')](function(_0x7e209c){logger[_0x9b41('0x65')](util[_0x9b41('0x32')](_0x9b41('0x72'),_0x51c62c,_0x3e1d2e,_0x7e209c[_0x9b41('0x73')]));_0x51ad9b['bucket']=_0x7e209c[_0x9b41('0x74')];_0x51ad9b[_0x9b41('0x75')]=_0x7e209c[_0x9b41('0x73')];logger[_0x9b41('0x65')](util[_0x9b41('0x32')]('[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request',_0x51c62c));return startTranscribe(_0x3fc641,_0x48c1e8,_0x59f172,uuidv4(),_0x2e41c7,_0x7e209c[_0x9b41('0x73')]);})[_0x9b41('0x24')](function(_0x5c2583){logger['info'](util['format'](_0x9b41('0x76'),_0x51c62c,_0x5c2583['TranscriptionJob'][_0x9b41('0x77')]));_0x51ad9b[_0x9b41('0x78')]=_0x5c2583[_0x9b41('0x79')][_0x9b41('0x77')];_0x51ad9b[_0x9b41('0x7a')]=_0x5c2583['TranscriptionJob']['TranscriptionJobStatus'];return _0x31ce2e(_0x51ad9b);})[_0x9b41('0x44')](function(_0x3b23b5){return _0x2b835c(_0x3b23b5);});});}exports[_0x9b41('0x7b')]=function(_0x8d5bcd,_0x50d774,_0xff954d){var _0x124578;var _0x1f9910;var _0x500da8;var _0x4403ff=require(_0x9b41('0x4e'));return db['VoiceRecording']['findOne']({'where':{'id':_0x8d5bcd[_0x9b41('0x46')]['id']}})['then'](function(_0x4c888b){if(_0x4c888b){var _0x14a274=util[_0x9b41('0x32')](_0x9b41('0x52'),_0x4c888b[_0x9b41('0x51')]);if(fs[_0x9b41('0x53')](_0x14a274)){cypher=!![];return _0x4403ff[_0x9b41('0x54')](_0x14a274,_0x4c888b[_0x9b41('0x51')],config[_0x9b41('0x55')][_0x9b41('0x56')])['then'](function(){return _0x4c888b;});}return _0x4c888b;}})[_0x9b41('0x24')](function(_0x58fb8e){if(!_0x58fb8e){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))](_0x9b41('0x7c'));}_0x1f9910=_0x58fb8e;return db[_0x9b41('0x7d')][_0x9b41('0x7e')]({'where':{'id':0x1}});})['then'](handleEntityNotFound(_0x50d774,null))['then'](function(_0x25ca6c){if(_0x25ca6c){_0x124578=_0x25ca6c;if(!_0x124578[_0x9b41('0x7f')]||!_0x124578[_0x9b41('0x80')]||!_0x124578[_0x9b41('0x81')]||!_0x124578['language']||!_0x124578[_0x9b41('0x82')]){throw new db['Sequelize'][(_0x9b41('0x63'))](_0x9b41('0x83'));}if(_0x8d5bcd[_0x9b41('0x4a')]['runSentiment']&&(!_0x124578[_0x9b41('0x84')]||!_0x124578[_0x9b41('0x85')]||!_0x124578[_0x9b41('0x86')]||!_0x124578[_0x9b41('0x87')]||!_0x124578[_0x9b41('0x82')])){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))](_0x9b41('0x88'));}return db[_0x9b41('0x89')][_0x9b41('0x7e')]({'where':{'id':_0x124578['transcribeAccountId']}});}})['then'](function(_0xb80f7e){if(!_0xb80f7e){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))](_0x9b41('0x8a'));}if(!_0xb80f7e[_0x9b41('0x8b')]||!_0xb80f7e[_0x9b41('0x8c')]){throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))]('Cloud\x20Provider\x20not\x20configured');}_0x500da8=_0xb80f7e;return getBucketslist(_0x500da8['data1'],_0x500da8[_0x9b41('0x8c')],_0x124578['transcribeRegion']);})[_0x9b41('0x24')](function(_0x1b6281){if(_0x1b6281&&_0x1b6281[_0x9b41('0x8d')]){var _0x545699=_[_0x9b41('0x50')](_0x1b6281[_0x9b41('0x8d')],function(_0x2dbe36){return _0x2dbe36['Name']===_0x124578['bucket'];});if(!_0x545699){logger['info'](util['format'](_0x9b41('0x8e'),_0x8d5bcd[_0x9b41('0x46')]['id'],_0x124578['bucket']));return createBucket(_0x500da8['data1'],_0x500da8[_0x9b41('0x8c')],_0x124578[_0x9b41('0x81')],_0x124578[_0x9b41('0x82')]);}logger[_0x9b41('0x65')](util['format']('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available',_0x8d5bcd[_0x9b41('0x46')]['id'],_0x124578[_0x9b41('0x82')]));return;}})[_0x9b41('0x24')](function(_0x383223){if(_0x1f9910[_0x9b41('0x7a')]===_0x9b41('0x8f')){return transcribe(_0x8d5bcd['params']['id'],_0x500da8[_0x9b41('0x8b')],_0x500da8[_0x9b41('0x8c')],_0x124578['transcribeRegion'],_0x124578[_0x9b41('0x82')],_0x1f9910[_0x9b41('0x51')],_0x124578[_0x9b41('0x87')]);}else{logger['info'](util[_0x9b41('0x32')](_0x9b41('0x90'),_0x8d5bcd[_0x9b41('0x46')]['id']));return{'transcribeStatus':_0x9b41('0x91')};}})[_0x9b41('0x24')](function(_0xa18222){if(_0xa18222){_0xa18222['tempSentiment']=_0x8d5bcd[_0x9b41('0x4a')][_0x9b41('0x92')];return _0x1f9910[_0x9b41('0x93')](_0xa18222);}})[_0x9b41('0x24')](respondWithResult(_0x50d774,null))['catch'](handleError(_0x50d774,null));};function writeFile(_0x878667,_0x10a4da){return new Promise(function(_0x2ceac6,_0xda080d){fs[_0x9b41('0x94')](_0x10a4da,_0x878667,function(_0x54c6de,_0x7354ac){if(_0x54c6de){return _0xda080d(_0x54c6de);}else{return _0x2ceac6(_0x7354ac);}});});}exports[_0x9b41('0x95')]=function(_0x3cf013,_0x169897,_0x4bafe0){return db['VoiceRecording'][_0x9b41('0x7e')]({'where':{'id':_0x3cf013[_0x9b41('0x46')]['id']}})['then'](handleEntityNotFound(_0x169897))['then'](function(_0x5d600c){if(_0x5d600c&&_0x5d600c['fileText']){var _0x35412b=_0x5d600c['fileText'];var _0x302feb=config[_0x9b41('0x96')]+_0x9b41('0x97')+_0x5d600c['id']+_0x9b41('0x98');if(fs['existsSync'](_0x302feb)){return _0x302feb;}return writeFile(_0x35412b,_0x302feb)[_0x9b41('0x24')](function(){return _0x302feb;});}else{throw new db[(_0x9b41('0x57'))][(_0x9b41('0x63'))]('Transcript\x20not\x20available');}})[_0x9b41('0x24')](function(_0x4a66bf){return _0x169897[_0x9b41('0x4d')](_0x4a66bf);})[_0x9b41('0x44')](handleError(_0x169897));};
\ No newline at end of file