Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index af662a0..cc8914d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbf4c=['include','findAll','rows','catch','params','options','find','create','body','describe','download','../../components/encryptor','uniqueid','value','%s.cypher','existsSync','decryptFile','secrets','Sequelize','ValidationError','filename','extname','unlink','message','downloads','sequelize','col','token','$and','push','recording','VoiceRecording\x20not\x20found','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','isNil','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','.cypher','unlinkSync','listBuckets','createBucket','upload','TranscribeService','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','bucket','Bucket','location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','TranscriptionJob','TranscriptionJobName','transcribeName','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribe','transcribeAccountId','Transcribe\x20not\x20configured','sentimentAccountId','sentimentRegion','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','data2','Cloud\x20Provider\x20not\x20configured','data1','transcribeRegion','Buckets','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','transcribeStatus','NEW','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','tempSentiment','updateAttributes','writeFile','downloadTranscribe','fileText','/server/files/transcribes/transcribe_','.txt','Transcript\x20not\x20available','eml-format','zip-dir','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','uuid/v4','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','reject','save','update','destroy','then','error','stack','name','send','map','VoiceRecording','rawAttributes','fieldName','type','key','model','differenceBy','format','query','keys','filters','intersection','attributes','fields','length','order','sort','where','pick','filter','VIRTUAL','merge','includeAll'];(function(_0x297fd3,_0x115406){var _0x2af381=function(_0x1dd31b){while(--_0x1dd31b){_0x297fd3['push'](_0x297fd3['shift']());}};_0x2af381(++_0x115406);}(_0xbf4c,0xf2));var _0xcbf4=function(_0x3c302e,_0x2a353c){_0x3c302e=_0x3c302e-0x0;var _0x7bf43c=_0xbf4c[_0x3c302e];return _0x7bf43c;};'use strict';var emlformat=require(_0xcbf4('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xcbf4('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xcbf4('0x2'));var moment=require(_0xcbf4('0x3'));var BPromise=require(_0xcbf4('0x4'));var Mustache=require(_0xcbf4('0x5'));var util=require('util');var path=require('path');var sox=require(_0xcbf4('0x6'));var csv=require(_0xcbf4('0x7'));var ejs=require(_0xcbf4('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xcbf4('0x9'));var squel=require(_0xcbf4('0xa'));var crypto=require(_0xcbf4('0xb'));var jsforce=require(_0xcbf4('0xc'));var deskjs=require(_0xcbf4('0xd'));var toCsv=require(_0xcbf4('0x7'));var querystring=require('querystring');var Papa=require(_0xcbf4('0xe'));var AWS=require('aws-sdk');var uuidv4=require(_0xcbf4('0xf'));var Redis=require('ioredis');var authService=require(_0xcbf4('0x10'));var qs=require(_0xcbf4('0x11'));var as=require(_0xcbf4('0x12'));var hardwareService=require(_0xcbf4('0x13'));var logger=require(_0xcbf4('0x14'))('api');var utils=require('../../config/utils');var config=require(_0xcbf4('0x15'));var licenseUtil=require(_0xcbf4('0x16'));var db=require(_0xcbf4('0x17'))['db'];function respondWithStatusCode(_0x26657b,_0x194271){_0x194271=_0x194271||0xcc;return function(_0x4811c6){if(_0x4811c6){return _0x26657b[_0xcbf4('0x18')](_0x194271);}return _0x26657b[_0xcbf4('0x19')](_0x194271)[_0xcbf4('0x1a')]();};}function respondWithResult(_0xbdba3c,_0x18b0ac){_0x18b0ac=_0x18b0ac||0xc8;return function(_0x486b12){if(_0x486b12){return _0xbdba3c[_0xcbf4('0x19')](_0x18b0ac)[_0xcbf4('0x1b')](_0x486b12);}};}function respondWithFilteredResult(_0x2a444a,_0x3aed83){return function(_0x2e2d8e){if(_0x2e2d8e){var _0x37a013=_0x2e2d8e[_0xcbf4('0x1c')],_0x1eeb04=_0x3aed83[_0xcbf4('0x1d')],_0x544b9c=_0x3aed83[_0xcbf4('0x1d')]+_0x3aed83[_0xcbf4('0x1e')],_0x3a4642;if(_0x544b9c>=_0x37a013){_0x544b9c=_0x37a013;_0x3a4642=0xc8;}else{_0x3a4642=0xce;}_0x2a444a[_0xcbf4('0x19')](_0x3a4642);return _0x2a444a['set'](_0xcbf4('0x1f'),_0x1eeb04+'-'+_0x544b9c+'/'+_0x37a013)[_0xcbf4('0x1b')](_0x2e2d8e);}return null;};}function patchUpdates(_0x8c371d){return function(_0x574a64){try{jsonpatch[_0xcbf4('0x20')](_0x574a64,_0x8c371d,!![]);}catch(_0x5081ee){return BPromise[_0xcbf4('0x21')](_0x5081ee);}return _0x574a64[_0xcbf4('0x22')]();};}function saveUpdates(_0x2de2de,_0x43eb6d){return function(_0x1f6d57){if(_0x1f6d57){return _0x1f6d57[_0xcbf4('0x23')](_0x2de2de)['then'](function(_0x24874a){return _0x24874a;});}return null;};}function removeEntity(_0x4ffe7e,_0x1dfc13){return function(_0x11ab4e){if(_0x11ab4e){return _0x11ab4e[_0xcbf4('0x24')]()[_0xcbf4('0x25')](function(){_0x4ffe7e[_0xcbf4('0x19')](0xcc)[_0xcbf4('0x1a')]();});}};}function handleEntityNotFound(_0x578190,_0x20bf7c){return function(_0xdf68e5){if(!_0xdf68e5){_0x578190[_0xcbf4('0x18')](0x194);}return _0xdf68e5;};}function handleError(_0x4b6bf4,_0x222a53){_0x222a53=_0x222a53||0x1f4;return function(_0x36a76f){logger[_0xcbf4('0x26')](_0x36a76f[_0xcbf4('0x27')]);if(_0x36a76f[_0xcbf4('0x28')]){delete _0x36a76f[_0xcbf4('0x28')];}_0x4b6bf4[_0xcbf4('0x19')](_0x222a53)[_0xcbf4('0x29')](_0x36a76f);};}exports['index']=function(_0x561d05,_0x47ad3b){var _0x5add34={},_0x18292b={},_0x1cc7f2={'count':0x0,'rows':[]};var _0x389747=_[_0xcbf4('0x2a')](db[_0xcbf4('0x2b')][_0xcbf4('0x2c')],function(_0x18de87){return{'name':_0x18de87[_0xcbf4('0x2d')],'type':_0x18de87[_0xcbf4('0x2e')][_0xcbf4('0x2f')]};});_0x18292b[_0xcbf4('0x30')]=_[_0xcbf4('0x31')](_['map'](_0x389747,_0xcbf4('0x28')),[_0xcbf4('0x32')]);_0x18292b[_0xcbf4('0x33')]=_[_0xcbf4('0x34')](_0x561d05[_0xcbf4('0x33')]);_0x18292b[_0xcbf4('0x35')]=_[_0xcbf4('0x36')](_0x18292b[_0xcbf4('0x30')],_0x18292b[_0xcbf4('0x33')]);_0x5add34[_0xcbf4('0x37')]=_[_0xcbf4('0x36')](_0x18292b[_0xcbf4('0x30')],qs[_0xcbf4('0x38')](_0x561d05['query'][_0xcbf4('0x38')]));_0x5add34[_0xcbf4('0x37')]=_0x5add34['attributes'][_0xcbf4('0x39')]?_0x5add34[_0xcbf4('0x37')]:_0x18292b[_0xcbf4('0x30')];if(!_0x561d05[_0xcbf4('0x33')]['hasOwnProperty']('nolimit')){_0x5add34[_0xcbf4('0x1e')]=qs['limit'](_0x561d05[_0xcbf4('0x33')]['limit']);_0x5add34[_0xcbf4('0x1d')]=qs['offset'](_0x561d05[_0xcbf4('0x33')][_0xcbf4('0x1d')]);}_0x5add34[_0xcbf4('0x3a')]=qs[_0xcbf4('0x3b')](_0x561d05[_0xcbf4('0x33')]['sort']);_0x5add34[_0xcbf4('0x3c')]=qs[_0xcbf4('0x35')](_[_0xcbf4('0x3d')](_0x561d05['query'],_0x18292b[_0xcbf4('0x35')]),_0x389747);if(_0x561d05['query'][_0xcbf4('0x3e')]){_0x5add34['where']=_['merge'](_0x5add34['where'],{'$or':_[_0xcbf4('0x2a')](_0x389747,function(_0x5c0b83){if(_0x5c0b83['type']!==_0xcbf4('0x3f')){var _0x3585eb={};_0x3585eb[_0x5c0b83[_0xcbf4('0x28')]]={'$like':'%'+_0x561d05['query']['filter']+'%'};return _0x3585eb;}})});}_0x5add34=_[_0xcbf4('0x40')]({},_0x5add34,_0x561d05['options']);var _0x25b4d8={'where':_0x5add34[_0xcbf4('0x3c')]};return db[_0xcbf4('0x2b')]['count'](_0x25b4d8)[_0xcbf4('0x25')](function(_0x68937a){_0x1cc7f2[_0xcbf4('0x1c')]=_0x68937a;if(_0x561d05[_0xcbf4('0x33')][_0xcbf4('0x41')]){_0x5add34[_0xcbf4('0x42')]=[{'all':!![]}];}return db[_0xcbf4('0x2b')][_0xcbf4('0x43')](_0x5add34);})[_0xcbf4('0x25')](function(_0x59f882){_0x1cc7f2[_0xcbf4('0x44')]=_0x59f882;return _0x1cc7f2;})[_0xcbf4('0x25')](respondWithFilteredResult(_0x47ad3b,_0x5add34))[_0xcbf4('0x45')](handleError(_0x47ad3b,null));};exports['show']=function(_0x53879d,_0x54b19b){var _0x4a4d3a={'raw':![],'where':{'id':_0x53879d[_0xcbf4('0x46')]['id']}},_0x9fb395={};_0x9fb395[_0xcbf4('0x30')]=_[_0xcbf4('0x34')](db[_0xcbf4('0x2b')]['rawAttributes']);_0x9fb395[_0xcbf4('0x33')]=_[_0xcbf4('0x34')](_0x53879d['query']);_0x9fb395[_0xcbf4('0x35')]=_[_0xcbf4('0x36')](_0x9fb395['model'],_0x9fb395['query']);_0x4a4d3a[_0xcbf4('0x37')]=_[_0xcbf4('0x36')](_0x9fb395[_0xcbf4('0x30')],qs[_0xcbf4('0x38')](_0x53879d[_0xcbf4('0x33')][_0xcbf4('0x38')]));_0x4a4d3a[_0xcbf4('0x37')]=_0x4a4d3a['attributes']['length']?_0x4a4d3a[_0xcbf4('0x37')]:_0x9fb395[_0xcbf4('0x30')];if(_0x53879d['query'][_0xcbf4('0x41')]){_0x4a4d3a['include']=[{'all':!![]}];}_0x4a4d3a=_[_0xcbf4('0x40')]({},_0x4a4d3a,_0x53879d[_0xcbf4('0x47')]);return db[_0xcbf4('0x2b')][_0xcbf4('0x48')](_0x4a4d3a)['then'](handleEntityNotFound(_0x54b19b,null))[_0xcbf4('0x25')](respondWithResult(_0x54b19b,null))[_0xcbf4('0x45')](handleError(_0x54b19b,null));};exports[_0xcbf4('0x49')]=function(_0x59b514,_0xffbf10){return db[_0xcbf4('0x2b')][_0xcbf4('0x49')](_0x59b514[_0xcbf4('0x4a')],{})['then'](respondWithResult(_0xffbf10,0xc9))[_0xcbf4('0x45')](handleError(_0xffbf10,null));};exports['update']=function(_0x10a5bd,_0x57d460){if(_0x10a5bd[_0xcbf4('0x4a')]['id']){delete _0x10a5bd[_0xcbf4('0x4a')]['id'];}return db[_0xcbf4('0x2b')][_0xcbf4('0x48')]({'where':{'id':_0x10a5bd[_0xcbf4('0x46')]['id']}})['then'](handleEntityNotFound(_0x57d460,null))[_0xcbf4('0x25')](saveUpdates(_0x10a5bd[_0xcbf4('0x4a')],null))[_0xcbf4('0x25')](respondWithResult(_0x57d460,null))[_0xcbf4('0x45')](handleError(_0x57d460,null));};exports[_0xcbf4('0x4b')]=function(_0x17107d,_0x4fb4ee){return db[_0xcbf4('0x2b')][_0xcbf4('0x4b')]()[_0xcbf4('0x25')](respondWithResult(_0x4fb4ee,null))[_0xcbf4('0x45')](handleError(_0x4fb4ee,null));};exports[_0xcbf4('0x4c')]=function(_0x24236e,_0x5d9220,_0x47f619){var _0xc4c60a=require(_0xcbf4('0x4d'));var _0x498f2f=![];var _0x31707a={};if(_0x24236e[_0xcbf4('0x33')][_0xcbf4('0x2e')]&&_0x24236e['query'][_0xcbf4('0x2e')]===_0xcbf4('0x4e')){_0x31707a['uniqueid']=_0x24236e[_0xcbf4('0x46')]['id'];}else{_0x31707a['id']=_0x24236e['params']['id'];}return db[_0xcbf4('0x2b')][_0xcbf4('0x48')]({'where':_0x31707a,'attributes':['id',_0xcbf4('0x4f')],'raw':!![]})[_0xcbf4('0x25')](handleEntityNotFound(_0x5d9220,null))[_0xcbf4('0x25')](function(_0x3660a9){if(_0x3660a9){var _0x5ab494=_0x3660a9['value'];var _0x27ca12=util[_0xcbf4('0x32')](_0xcbf4('0x50'),_0x5ab494);if(fs[_0xcbf4('0x51')](_0x27ca12)){_0x498f2f=!![];return _0xc4c60a[_0xcbf4('0x52')](_0x27ca12,_0x5ab494,config[_0xcbf4('0x53')]['recording'])[_0xcbf4('0x25')](function(){return _0x3660a9;});}return _0x3660a9;}})[_0xcbf4('0x25')](function(_0xc428e0){if(_0xc428e0){var _0x10da1b=_0xc428e0['value'];if(!fs[_0xcbf4('0x51')](_0x10da1b)){throw new db[(_0xcbf4('0x54'))][(_0xcbf4('0x55'))]('VoiceRecording\x20not\x20found');}if(_0xc428e0[_0xcbf4('0x56')]){return _0x5d9220[_0xcbf4('0x4c')](_0x10da1b,_0xc428e0['filename']+path[_0xcbf4('0x57')](_0x10da1b),function(){if(_0x498f2f){fs[_0xcbf4('0x58')](_0x10da1b);}});}else{return _0x5d9220[_0xcbf4('0x4c')](_0x10da1b,function(_0x54638a){if(_0x498f2f){fs['unlink'](_0x10da1b);}});}}})['catch'](function(_0x409549){if(_0x409549[_0xcbf4('0x59')]==='VoiceRecording\x20not\x20found'){_0x5d9220['status'](0x194)[_0xcbf4('0x29')]('Not\x20found');}else{return handleError(_0x5d9220,null);}});};exports[_0xcbf4('0x5a')]=function(_0x5885d6,_0x5d0d2f,_0x1525d7){var _0x388e36=require(_0xcbf4('0x4d'));var _0x37636a=![];var _0x3a95e2={'$and':[db[_0xcbf4('0x5b')][_0xcbf4('0x3c')](db[_0xcbf4('0x5b')]['fn']('MD5',db[_0xcbf4('0x5b')][_0xcbf4('0x5c')](_0xcbf4('0x4e'))),_0x5885d6[_0xcbf4('0x33')][_0xcbf4('0x5d')])]};if(_0x5885d6[_0xcbf4('0x33')][_0xcbf4('0x2e')]&&_0x5885d6[_0xcbf4('0x33')]['type']==='uniqueid'){_0x3a95e2[_0xcbf4('0x5e')][_0xcbf4('0x5f')]({'uniqueid':_0x5885d6[_0xcbf4('0x46')]['id']});}else{_0x3a95e2[_0xcbf4('0x5e')]['push']({'id':_0x5885d6[_0xcbf4('0x46')]['id']});}return db[_0xcbf4('0x2b')]['find']({'where':_0x3a95e2,'attributes':['id','value'],'raw':!![]})[_0xcbf4('0x25')](handleEntityNotFound(_0x5d0d2f,null))[_0xcbf4('0x25')](function(_0x107fcd){if(_0x107fcd){var _0x52797b=util['format'](_0xcbf4('0x50'),_0x107fcd[_0xcbf4('0x4f')]);if(fs[_0xcbf4('0x51')](_0x52797b)){_0x37636a=!![];return _0x388e36['decryptFile'](_0x52797b,_0x107fcd[_0xcbf4('0x4f')],config[_0xcbf4('0x53')][_0xcbf4('0x60')])['then'](function(){return _0x107fcd;});}return _0x107fcd;}})['then'](function(_0x595dd1){if(_0x595dd1){if(!fs[_0xcbf4('0x51')](_0x595dd1['value'])){throw new db[(_0xcbf4('0x54'))][(_0xcbf4('0x55'))](_0xcbf4('0x61'));}if(_0x595dd1[_0xcbf4('0x56')]){return _0x5d0d2f[_0xcbf4('0x4c')](_0x595dd1[_0xcbf4('0x4f')],_0x595dd1[_0xcbf4('0x56')]+path[_0xcbf4('0x57')](_0x595dd1[_0xcbf4('0x4f')]),function(){if(_0x37636a){fs[_0xcbf4('0x58')](_0x595dd1[_0xcbf4('0x4f')]);}});}else{return _0x5d0d2f[_0xcbf4('0x4c')](_0x595dd1[_0xcbf4('0x4f')],function(_0x206758){if(_0x37636a){fs['unlink'](_0x595dd1[_0xcbf4('0x4f')]);}});}}})['catch'](handleError(_0x5d0d2f,null));};exports[_0xcbf4('0x24')]=function(_0x4ddc87,_0x47f295){return db['VoiceRecording'][_0xcbf4('0x48')]({'where':{'id':_0x4ddc87[_0xcbf4('0x46')]['id']}})[_0xcbf4('0x25')](function(_0x395308){if(!_0x395308)throw new ReferenceError(_0xcbf4('0x62'));return _0x395308;})['then'](function(_0x5c2f83){var _0x37d0ff=_0x5c2f83[_0xcbf4('0x4f')];logger[_0xcbf4('0x63')](_0xcbf4('0x64'),_0x37d0ff);if(!_[_0xcbf4('0x65')](_0x5c2f83['value'])&&fs[_0xcbf4('0x51')](_0x37d0ff)){logger[_0xcbf4('0x63')](_0xcbf4('0x66')+_0x37d0ff+_0xcbf4('0x67'));fs['unlinkSync'](_0x37d0ff);}_0x37d0ff=_0x37d0ff+_0xcbf4('0x68');if(!_[_0xcbf4('0x65')](_0x5c2f83[_0xcbf4('0x4f')])&&fs[_0xcbf4('0x51')](_0x37d0ff)){logger[_0xcbf4('0x63')]('File:\x20\x22'+_0x37d0ff+_0xcbf4('0x67'));fs[_0xcbf4('0x69')](_0x37d0ff);}return _0x5c2f83;})['then'](function(_0x2d756d){if(!_0x2d756d)throw new InternalError();return _0x2d756d['destroy']();})[_0xcbf4('0x25')](function(){_0x47f295[_0xcbf4('0x19')](0xcc)[_0xcbf4('0x1a')]();})[_0xcbf4('0x45')](handleError(_0x47f295,null));};function getBucketslist(_0x21be4d,_0x2ce763,_0x40d6b8){return new Promise(function(_0x8d50a9,_0x56ca39){var _0x238b3e=new AWS['S3']({'accessKeyId':_0x2ce763,'secretAccessKey':_0x21be4d,'region':_0x40d6b8});_0x238b3e[_0xcbf4('0x6a')]({},function(_0x5b6f86,_0x570868){if(_0x5b6f86){return _0x56ca39(_0x5b6f86);}else{return _0x8d50a9(_0x570868);}});});}function createBucket(_0x42127c,_0x50e543,_0x30dae1,_0x22e0fb){return new Promise(function(_0x3f9eaa,_0x583334){var _0x463d55=new AWS['S3']({'accessKeyId':_0x50e543,'secretAccessKey':_0x42127c,'region':_0x30dae1});_0x463d55[_0xcbf4('0x6b')]({'Bucket':_0x22e0fb},function(_0x16ac30,_0x470384){if(_0x16ac30){return _0x583334(_0x16ac30);}else{return _0x3f9eaa(_0x470384);}});});}function uploadFile(_0x5e9f1b,_0x4f2673,_0xa4d101,_0x2d31be,_0x46ee12,_0x26be43){return new Promise(function(_0x44e450,_0x1ed488){var _0x360d00=new AWS['S3']({'accessKeyId':_0x4f2673,'secretAccessKey':_0x5e9f1b,'region':_0xa4d101});_0x360d00[_0xcbf4('0x6c')]({'Bucket':_0x2d31be,'Key':_0x46ee12,'Body':_0x26be43},function(_0xf50fd4,_0xdd68a3){if(_0xf50fd4){return _0x1ed488(_0xf50fd4);}else{return _0x44e450(_0xdd68a3);}});});}function startTranscribe(_0x52168e,_0x1ae7c6,_0x481cf1,_0x5bfb3f,_0x302eea,_0x20ee75){return new Promise(function(_0x2e5dee,_0x54cb52){var _0x468b96=new AWS[(_0xcbf4('0x6d'))]({'accessKeyId':_0x1ae7c6,'secretAccessKey':_0x52168e,'region':_0x481cf1});_0x468b96[_0xcbf4('0x6e')]({'TranscriptionJobName':_0x5bfb3f,'LanguageCode':_0x302eea,'Media':{'MediaFileUri':_0x20ee75}},function(_0x15876b,_0x6b8239){if(_0x15876b){return _0x54cb52(_0x15876b);}else{return _0x2e5dee(_0x6b8239);}});});}function transcribe(_0x4c9d31,_0x20e034,_0x591b51,_0x2d9d1f,_0x545a1c,_0x50c39c,_0x20d315){return new Promise(function(_0x4b557a,_0x122be3){var _0xe14235={};logger[_0xcbf4('0x63')](util[_0xcbf4('0x32')](_0xcbf4('0x6f'),_0x4c9d31,_0x545a1c));return uploadFile(_0x20e034,_0x591b51,_0x2d9d1f,_0x545a1c,path['basename'](_0x50c39c),fs[_0xcbf4('0x70')](_0x50c39c))['then'](function(_0x156f7c){logger[_0xcbf4('0x63')](util[_0xcbf4('0x32')](_0xcbf4('0x71'),_0x4c9d31,_0x545a1c,_0x156f7c[_0xcbf4('0x72')]));_0xe14235[_0xcbf4('0x73')]=_0x156f7c[_0xcbf4('0x74')];_0xe14235[_0xcbf4('0x75')]=_0x156f7c[_0xcbf4('0x72')];logger[_0xcbf4('0x63')](util[_0xcbf4('0x32')](_0xcbf4('0x76'),_0x4c9d31));return startTranscribe(_0x20e034,_0x591b51,_0x2d9d1f,uuidv4(),_0x20d315,_0x156f7c[_0xcbf4('0x72')]);})[_0xcbf4('0x25')](function(_0x42dc64){logger[_0xcbf4('0x63')](util[_0xcbf4('0x32')](_0xcbf4('0x77'),_0x4c9d31,_0x42dc64[_0xcbf4('0x78')][_0xcbf4('0x79')]));_0xe14235[_0xcbf4('0x7a')]=_0x42dc64[_0xcbf4('0x78')][_0xcbf4('0x79')];_0xe14235['transcribeStatus']=_0x42dc64[_0xcbf4('0x78')]['TranscriptionJobStatus'];return _0x4b557a(_0xe14235);})[_0xcbf4('0x45')](function(_0x32c2ea){return _0x122be3(_0x32c2ea);});});}exports[_0xcbf4('0x7b')]=function(_0xb9a7a2,_0x55f7fb,_0x309c60){var _0x197351;var _0x3fd6b7;var _0x52b8fd;var _0x5249fd=require('../../components/encryptor');return db[_0xcbf4('0x2b')][_0xcbf4('0x7c')]({'where':{'id':_0xb9a7a2['params']['id']}})[_0xcbf4('0x25')](function(_0x228af4){if(_0x228af4){var _0xcc5c1d=util['format'](_0xcbf4('0x50'),_0x228af4[_0xcbf4('0x4f')]);if(fs[_0xcbf4('0x51')](_0xcc5c1d)){cypher=!![];return _0x5249fd[_0xcbf4('0x52')](_0xcc5c1d,_0x228af4[_0xcbf4('0x4f')],config[_0xcbf4('0x53')][_0xcbf4('0x60')])['then'](function(){return _0x228af4;});}return _0x228af4;}})['then'](function(_0x19fd3b){if(!_0x19fd3b){throw new db[(_0xcbf4('0x54'))][(_0xcbf4('0x55'))](_0xcbf4('0x7d'));}_0x3fd6b7=_0x19fd3b;return db[_0xcbf4('0x7e')][_0xcbf4('0x7c')]({'where':{'id':0x1}});})['then'](handleEntityNotFound(_0x55f7fb,null))[_0xcbf4('0x25')](function(_0x46e599){if(_0x46e599){_0x197351=_0x46e599;if(!_0x197351[_0xcbf4('0x7f')]||!_0x197351[_0xcbf4('0x80')]||!_0x197351['transcribeRegion']||!_0x197351['language']||!_0x197351[_0xcbf4('0x73')]){throw new db[(_0xcbf4('0x54'))][(_0xcbf4('0x55'))](_0xcbf4('0x81'));}if(_0xb9a7a2[_0xcbf4('0x4a')]['runSentiment']&&(!_0x197351['sentiment']||!_0x197351[_0xcbf4('0x82')]||!_0x197351[_0xcbf4('0x83')]||!_0x197351[_0xcbf4('0x84')]||!_0x197351['bucket'])){throw new db[(_0xcbf4('0x54'))][(_0xcbf4('0x55'))](_0xcbf4('0x85'));}return db[_0xcbf4('0x86')][_0xcbf4('0x7c')]({'where':{'id':_0x197351[_0xcbf4('0x80')]}});}})[_0xcbf4('0x25')](function(_0x17d69e){if(!_0x17d69e){throw new db[(_0xcbf4('0x54'))][(_0xcbf4('0x55'))](_0xcbf4('0x87'));}if(!_0x17d69e['data1']||!_0x17d69e[_0xcbf4('0x88')]){throw new db[(_0xcbf4('0x54'))][(_0xcbf4('0x55'))](_0xcbf4('0x89'));}_0x52b8fd=_0x17d69e;return getBucketslist(_0x52b8fd[_0xcbf4('0x8a')],_0x52b8fd['data2'],_0x197351[_0xcbf4('0x8b')]);})[_0xcbf4('0x25')](function(_0x34fd3e){if(_0x34fd3e&&_0x34fd3e['Buckets']){var _0x2f92b5=_[_0xcbf4('0x48')](_0x34fd3e[_0xcbf4('0x8c')],function(_0x4cec2c){return _0x4cec2c[_0xcbf4('0x8d')]===_0x197351[_0xcbf4('0x73')];});if(!_0x2f92b5){logger[_0xcbf4('0x63')](util[_0xcbf4('0x32')]('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available',_0xb9a7a2[_0xcbf4('0x46')]['id'],_0x197351[_0xcbf4('0x73')]));return createBucket(_0x52b8fd['data1'],_0x52b8fd[_0xcbf4('0x88')],_0x197351['transcribeRegion'],_0x197351[_0xcbf4('0x73')]);}logger[_0xcbf4('0x63')](util['format'](_0xcbf4('0x8e'),_0xb9a7a2['params']['id'],_0x197351[_0xcbf4('0x73')]));return;}})[_0xcbf4('0x25')](function(_0x102822){if(_0x3fd6b7[_0xcbf4('0x8f')]===_0xcbf4('0x90')){return transcribe(_0xb9a7a2['params']['id'],_0x52b8fd[_0xcbf4('0x8a')],_0x52b8fd[_0xcbf4('0x88')],_0x197351[_0xcbf4('0x8b')],_0x197351['bucket'],_0x3fd6b7[_0xcbf4('0x4f')],_0x197351[_0xcbf4('0x84')]);}else{logger[_0xcbf4('0x63')](util['format'](_0xcbf4('0x91'),_0xb9a7a2[_0xcbf4('0x46')]['id']));return{'transcribeStatus':'IN_PROGRESS'};}})[_0xcbf4('0x25')](function(_0x17f196){if(_0x17f196){_0x17f196[_0xcbf4('0x92')]=_0xb9a7a2[_0xcbf4('0x4a')]['runSentiment'];return _0x3fd6b7[_0xcbf4('0x93')](_0x17f196);}})[_0xcbf4('0x25')](respondWithResult(_0x55f7fb,null))[_0xcbf4('0x45')](handleError(_0x55f7fb,null));};function writeFile(_0x1bcd7d,_0x13e563){return new Promise(function(_0x4f1c04,_0x3632c4){fs[_0xcbf4('0x94')](_0x13e563,_0x1bcd7d,function(_0x247072,_0x220542){if(_0x247072){return _0x3632c4(_0x247072);}else{return _0x4f1c04(_0x220542);}});});}exports[_0xcbf4('0x95')]=function(_0x46d1e8,_0x3a930e,_0x541e7a){return db[_0xcbf4('0x2b')][_0xcbf4('0x7c')]({'where':{'id':_0x46d1e8[_0xcbf4('0x46')]['id']}})[_0xcbf4('0x25')](handleEntityNotFound(_0x3a930e))[_0xcbf4('0x25')](function(_0x2cce43){if(_0x2cce43&&_0x2cce43['fileText']){var _0xc48f0b=_0x2cce43[_0xcbf4('0x96')];var _0x878564=config['root']+_0xcbf4('0x97')+_0x2cce43['id']+_0xcbf4('0x98');if(fs[_0xcbf4('0x51')](_0x878564)){return _0x878564;}return writeFile(_0xc48f0b,_0x878564)['then'](function(){return _0x878564;});}else{throw new db[(_0xcbf4('0x54'))][(_0xcbf4('0x55'))](_0xcbf4('0x99'));}})[_0xcbf4('0x25')](function(_0x2c0519){return _0x3a930e[_0xcbf4('0x4c')](_0x2c0519);})[_0xcbf4('0x45')](handleError(_0x3a930e));};
\ 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