Built motion from commit (unavailable).|2.5.27
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index af662a0..e4f71e0 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 _0x3300=['sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','aws-sdk','uuid/v4','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','name','send','index','map','VoiceRecording','rawAttributes','fieldName','key','model','differenceBy','query','keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filters','pick','merge','type','VIRTUAL','filter','options','includeAll','findAll','rows','catch','show','params','include','create','body','describe','download','../../components/encryptor','uniqueid','value','%s.cypher','existsSync','secrets','recording','Sequelize','VoiceRecording\x20not\x20found','filename','extname','unlink','message','Not\x20found','sequelize','col','token','$and','push','find','format','decryptFile','ValidationError','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','isNil','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','.cypher','unlinkSync','listBuckets','createBucket','upload','TranscribeService','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','Bucket','location','TranscriptionJobName','TranscriptionJob','transcribeStatus','TranscriptionJobStatus','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribe','transcribeAccountId','transcribeRegion','language','bucket','Transcribe\x20not\x20configured','sentiment','sentimentAccountId','Sentiment\x20Analysis\x20not\x20configured','Cloud\x20Provider\x20not\x20available','data1','data2','Buckets','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','NEW','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','tempSentiment','runSentiment','writeFile','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','Transcript\x20not\x20available','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','path'];(function(_0x217652,_0x30f44d){var _0x4f03a1=function(_0x23a62a){while(--_0x23a62a){_0x217652['push'](_0x217652['shift']());}};_0x4f03a1(++_0x30f44d);}(_0x3300,0x1c4));var _0x0330=function(_0x55d76f,_0x3ec4e8){_0x55d76f=_0x55d76f-0x0;var _0x27f726=_0x3300[_0x55d76f];return _0x27f726;};'use strict';var emlformat=require(_0x0330('0x0'));var rimraf=require(_0x0330('0x1'));var zipdir=require(_0x0330('0x2'));var jsonpatch=require(_0x0330('0x3'));var rp=require('request-promise');var moment=require(_0x0330('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x0330('0x5'));var util=require('util');var path=require(_0x0330('0x6'));var sox=require(_0x0330('0x7'));var csv=require(_0x0330('0x8'));var ejs=require(_0x0330('0x9'));var fs=require('fs');var fs_extra=require(_0x0330('0xa'));var _=require(_0x0330('0xb'));var squel=require(_0x0330('0xc'));var crypto=require(_0x0330('0xd'));var jsforce=require(_0x0330('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x0330('0xf'));var Papa=require(_0x0330('0x10'));var AWS=require(_0x0330('0x11'));var uuidv4=require(_0x0330('0x12'));var Redis=require(_0x0330('0x13'));var authService=require(_0x0330('0x14'));var qs=require(_0x0330('0x15'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0330('0x16'));var logger=require(_0x0330('0x17'))(_0x0330('0x18'));var utils=require('../../config/utils');var config=require(_0x0330('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x0330('0x1a'))['db'];function respondWithStatusCode(_0x8e7ae0,_0x6cfaa3){_0x6cfaa3=_0x6cfaa3||0xcc;return function(_0x29e1ff){if(_0x29e1ff){return _0x8e7ae0[_0x0330('0x1b')](_0x6cfaa3);}return _0x8e7ae0[_0x0330('0x1c')](_0x6cfaa3)[_0x0330('0x1d')]();};}function respondWithResult(_0x3680a2,_0x55079e){_0x55079e=_0x55079e||0xc8;return function(_0x2f3b2d){if(_0x2f3b2d){return _0x3680a2[_0x0330('0x1c')](_0x55079e)[_0x0330('0x1e')](_0x2f3b2d);}};}function respondWithFilteredResult(_0x32df4d,_0x56b12a){return function(_0x295df5){if(_0x295df5){var _0x25a57b=_0x295df5[_0x0330('0x1f')],_0x40ab76=_0x56b12a[_0x0330('0x20')],_0x5e90ec=_0x56b12a[_0x0330('0x20')]+_0x56b12a[_0x0330('0x21')],_0x28bb2e;if(_0x5e90ec>=_0x25a57b){_0x5e90ec=_0x25a57b;_0x28bb2e=0xc8;}else{_0x28bb2e=0xce;}_0x32df4d[_0x0330('0x1c')](_0x28bb2e);return _0x32df4d[_0x0330('0x22')](_0x0330('0x23'),_0x40ab76+'-'+_0x5e90ec+'/'+_0x25a57b)[_0x0330('0x1e')](_0x295df5);}return null;};}function patchUpdates(_0x244ef1){return function(_0x1a1055){try{jsonpatch[_0x0330('0x24')](_0x1a1055,_0x244ef1,!![]);}catch(_0x35b7ec){return BPromise[_0x0330('0x25')](_0x35b7ec);}return _0x1a1055[_0x0330('0x26')]();};}function saveUpdates(_0x4b0ebe,_0x4106b0){return function(_0x552174){if(_0x552174){return _0x552174[_0x0330('0x27')](_0x4b0ebe)[_0x0330('0x28')](function(_0x3e706f){return _0x3e706f;});}return null;};}function removeEntity(_0x34c737,_0x883789){return function(_0x159bbd){if(_0x159bbd){return _0x159bbd[_0x0330('0x29')]()[_0x0330('0x28')](function(){_0x34c737['status'](0xcc)[_0x0330('0x1d')]();});}};}function handleEntityNotFound(_0x53b105,_0x3bf6c1){return function(_0x2ba29f){if(!_0x2ba29f){_0x53b105[_0x0330('0x1b')](0x194);}return _0x2ba29f;};}function handleError(_0x4b304e,_0x5b6238){_0x5b6238=_0x5b6238||0x1f4;return function(_0x4fcf18){logger['error'](_0x4fcf18['stack']);if(_0x4fcf18[_0x0330('0x2a')]){delete _0x4fcf18[_0x0330('0x2a')];}_0x4b304e[_0x0330('0x1c')](_0x5b6238)[_0x0330('0x2b')](_0x4fcf18);};}exports[_0x0330('0x2c')]=function(_0xc44600,_0xf0f742){var _0x3c1395={},_0xf32343={},_0xcf538a={'count':0x0,'rows':[]};var _0x1e65b7=_[_0x0330('0x2d')](db[_0x0330('0x2e')][_0x0330('0x2f')],function(_0x41baf8){return{'name':_0x41baf8[_0x0330('0x30')],'type':_0x41baf8['type'][_0x0330('0x31')]};});_0xf32343[_0x0330('0x32')]=_[_0x0330('0x33')](_[_0x0330('0x2d')](_0x1e65b7,_0x0330('0x2a')),['format']);_0xf32343[_0x0330('0x34')]=_[_0x0330('0x35')](_0xc44600[_0x0330('0x34')]);_0xf32343['filters']=_[_0x0330('0x36')](_0xf32343['model'],_0xf32343['query']);_0x3c1395[_0x0330('0x37')]=_[_0x0330('0x36')](_0xf32343[_0x0330('0x32')],qs[_0x0330('0x38')](_0xc44600['query'][_0x0330('0x38')]));_0x3c1395[_0x0330('0x37')]=_0x3c1395['attributes'][_0x0330('0x39')]?_0x3c1395['attributes']:_0xf32343[_0x0330('0x32')];if(!_0xc44600[_0x0330('0x34')][_0x0330('0x3a')]('nolimit')){_0x3c1395['limit']=qs[_0x0330('0x21')](_0xc44600[_0x0330('0x34')][_0x0330('0x21')]);_0x3c1395['offset']=qs[_0x0330('0x20')](_0xc44600[_0x0330('0x34')][_0x0330('0x20')]);}_0x3c1395[_0x0330('0x3b')]=qs[_0x0330('0x3c')](_0xc44600[_0x0330('0x34')]['sort']);_0x3c1395[_0x0330('0x3d')]=qs[_0x0330('0x3e')](_[_0x0330('0x3f')](_0xc44600[_0x0330('0x34')],_0xf32343[_0x0330('0x3e')]),_0x1e65b7);if(_0xc44600[_0x0330('0x34')]['filter']){_0x3c1395[_0x0330('0x3d')]=_[_0x0330('0x40')](_0x3c1395[_0x0330('0x3d')],{'$or':_[_0x0330('0x2d')](_0x1e65b7,function(_0x5abd32){if(_0x5abd32[_0x0330('0x41')]!==_0x0330('0x42')){var _0x2c17c2={};_0x2c17c2[_0x5abd32[_0x0330('0x2a')]]={'$like':'%'+_0xc44600[_0x0330('0x34')][_0x0330('0x43')]+'%'};return _0x2c17c2;}})});}_0x3c1395=_['merge']({},_0x3c1395,_0xc44600[_0x0330('0x44')]);var _0x2d9a61={'where':_0x3c1395[_0x0330('0x3d')]};return db[_0x0330('0x2e')]['count'](_0x2d9a61)[_0x0330('0x28')](function(_0x17b7a1){_0xcf538a['count']=_0x17b7a1;if(_0xc44600[_0x0330('0x34')][_0x0330('0x45')]){_0x3c1395['include']=[{'all':!![]}];}return db[_0x0330('0x2e')][_0x0330('0x46')](_0x3c1395);})['then'](function(_0x8f00e2){_0xcf538a[_0x0330('0x47')]=_0x8f00e2;return _0xcf538a;})['then'](respondWithFilteredResult(_0xf0f742,_0x3c1395))[_0x0330('0x48')](handleError(_0xf0f742,null));};exports[_0x0330('0x49')]=function(_0x4497cd,_0x5c1bf3){var _0x54af58={'raw':![],'where':{'id':_0x4497cd[_0x0330('0x4a')]['id']}},_0x2f960d={};_0x2f960d[_0x0330('0x32')]=_[_0x0330('0x35')](db['VoiceRecording'][_0x0330('0x2f')]);_0x2f960d['query']=_['keys'](_0x4497cd[_0x0330('0x34')]);_0x2f960d[_0x0330('0x3e')]=_['intersection'](_0x2f960d[_0x0330('0x32')],_0x2f960d[_0x0330('0x34')]);_0x54af58[_0x0330('0x37')]=_[_0x0330('0x36')](_0x2f960d[_0x0330('0x32')],qs[_0x0330('0x38')](_0x4497cd[_0x0330('0x34')][_0x0330('0x38')]));_0x54af58['attributes']=_0x54af58[_0x0330('0x37')][_0x0330('0x39')]?_0x54af58[_0x0330('0x37')]:_0x2f960d[_0x0330('0x32')];if(_0x4497cd['query']['includeAll']){_0x54af58[_0x0330('0x4b')]=[{'all':!![]}];}_0x54af58=_[_0x0330('0x40')]({},_0x54af58,_0x4497cd[_0x0330('0x44')]);return db['VoiceRecording']['find'](_0x54af58)['then'](handleEntityNotFound(_0x5c1bf3,null))['then'](respondWithResult(_0x5c1bf3,null))[_0x0330('0x48')](handleError(_0x5c1bf3,null));};exports[_0x0330('0x4c')]=function(_0x1245ca,_0x370b00){return db[_0x0330('0x2e')][_0x0330('0x4c')](_0x1245ca[_0x0330('0x4d')],{})['then'](respondWithResult(_0x370b00,0xc9))[_0x0330('0x48')](handleError(_0x370b00,null));};exports[_0x0330('0x27')]=function(_0x171213,_0x2abc6a){if(_0x171213['body']['id']){delete _0x171213['body']['id'];}return db[_0x0330('0x2e')]['find']({'where':{'id':_0x171213['params']['id']}})[_0x0330('0x28')](handleEntityNotFound(_0x2abc6a,null))[_0x0330('0x28')](saveUpdates(_0x171213[_0x0330('0x4d')],null))[_0x0330('0x28')](respondWithResult(_0x2abc6a,null))[_0x0330('0x48')](handleError(_0x2abc6a,null));};exports[_0x0330('0x4e')]=function(_0x1165cb,_0x598c5e){return db[_0x0330('0x2e')][_0x0330('0x4e')]()['then'](respondWithResult(_0x598c5e,null))['catch'](handleError(_0x598c5e,null));};exports[_0x0330('0x4f')]=function(_0x5cc033,_0x305170,_0x90081a){var _0x5f39b2=require(_0x0330('0x50'));var _0x3cc1a4=![];var _0x45f5d3={};if(_0x5cc033[_0x0330('0x34')][_0x0330('0x41')]&&_0x5cc033['query']['type']===_0x0330('0x51')){_0x45f5d3['uniqueid']=_0x5cc033[_0x0330('0x4a')]['id'];}else{_0x45f5d3['id']=_0x5cc033[_0x0330('0x4a')]['id'];}return db['VoiceRecording']['find']({'where':_0x45f5d3,'attributes':['id',_0x0330('0x52')],'raw':!![]})[_0x0330('0x28')](handleEntityNotFound(_0x305170,null))[_0x0330('0x28')](function(_0x26f5cd){if(_0x26f5cd){var _0x5034b5=_0x26f5cd['value'];var _0x48337f=util['format'](_0x0330('0x53'),_0x5034b5);if(fs[_0x0330('0x54')](_0x48337f)){_0x3cc1a4=!![];return _0x5f39b2['decryptFile'](_0x48337f,_0x5034b5,config[_0x0330('0x55')][_0x0330('0x56')])['then'](function(){return _0x26f5cd;});}return _0x26f5cd;}})[_0x0330('0x28')](function(_0x2b3f7c){if(_0x2b3f7c){var _0x3a7fff=_0x2b3f7c[_0x0330('0x52')];if(!fs['existsSync'](_0x3a7fff)){throw new db[(_0x0330('0x57'))]['ValidationError'](_0x0330('0x58'));}if(_0x2b3f7c['filename']){return _0x305170[_0x0330('0x4f')](_0x3a7fff,_0x2b3f7c[_0x0330('0x59')]+path[_0x0330('0x5a')](_0x3a7fff),function(){if(_0x3cc1a4){fs['unlink'](_0x3a7fff);}});}else{return _0x305170[_0x0330('0x4f')](_0x3a7fff,function(_0x569c41){if(_0x3cc1a4){fs[_0x0330('0x5b')](_0x3a7fff);}});}}})[_0x0330('0x48')](function(_0xf17374){if(_0xf17374[_0x0330('0x5c')]===_0x0330('0x58')){_0x305170[_0x0330('0x1c')](0x194)['send'](_0x0330('0x5d'));}else{return handleError(_0x305170,null);}});};exports['downloads']=function(_0x3434d6,_0xd41453,_0x9b7e0a){var _0x5ba4b3=require('../../components/encryptor');var _0x239531=![];var _0x27a44e={'$and':[db[_0x0330('0x5e')][_0x0330('0x3d')](db[_0x0330('0x5e')]['fn']('MD5',db[_0x0330('0x5e')][_0x0330('0x5f')](_0x0330('0x51'))),_0x3434d6[_0x0330('0x34')][_0x0330('0x60')])]};if(_0x3434d6[_0x0330('0x34')]['type']&&_0x3434d6[_0x0330('0x34')][_0x0330('0x41')]===_0x0330('0x51')){_0x27a44e[_0x0330('0x61')][_0x0330('0x62')]({'uniqueid':_0x3434d6[_0x0330('0x4a')]['id']});}else{_0x27a44e[_0x0330('0x61')][_0x0330('0x62')]({'id':_0x3434d6[_0x0330('0x4a')]['id']});}return db[_0x0330('0x2e')][_0x0330('0x63')]({'where':_0x27a44e,'attributes':['id','value'],'raw':!![]})[_0x0330('0x28')](handleEntityNotFound(_0xd41453,null))[_0x0330('0x28')](function(_0x4b2aa){if(_0x4b2aa){var _0x5be870=util[_0x0330('0x64')](_0x0330('0x53'),_0x4b2aa[_0x0330('0x52')]);if(fs['existsSync'](_0x5be870)){_0x239531=!![];return _0x5ba4b3[_0x0330('0x65')](_0x5be870,_0x4b2aa[_0x0330('0x52')],config['secrets']['recording'])[_0x0330('0x28')](function(){return _0x4b2aa;});}return _0x4b2aa;}})['then'](function(_0x1ea30e){if(_0x1ea30e){if(!fs[_0x0330('0x54')](_0x1ea30e[_0x0330('0x52')])){throw new db[(_0x0330('0x57'))][(_0x0330('0x66'))]('VoiceRecording\x20not\x20found');}if(_0x1ea30e[_0x0330('0x59')]){return _0xd41453[_0x0330('0x4f')](_0x1ea30e[_0x0330('0x52')],_0x1ea30e[_0x0330('0x59')]+path[_0x0330('0x5a')](_0x1ea30e[_0x0330('0x52')]),function(){if(_0x239531){fs[_0x0330('0x5b')](_0x1ea30e[_0x0330('0x52')]);}});}else{return _0xd41453[_0x0330('0x4f')](_0x1ea30e['value'],function(_0x4b426c){if(_0x239531){fs[_0x0330('0x5b')](_0x1ea30e['value']);}});}}})[_0x0330('0x48')](handleError(_0xd41453,null));};exports[_0x0330('0x29')]=function(_0x2d8dd7,_0x780957){return db[_0x0330('0x2e')][_0x0330('0x63')]({'where':{'id':_0x2d8dd7['params']['id']}})['then'](function(_0x3ea3d1){if(!_0x3ea3d1)throw new ReferenceError(_0x0330('0x67'));return _0x3ea3d1;})['then'](function(_0x2b6c4a){var _0x275daa=_0x2b6c4a[_0x0330('0x52')];logger[_0x0330('0x68')](_0x0330('0x69'),_0x275daa);if(!_[_0x0330('0x6a')](_0x2b6c4a[_0x0330('0x52')])&&fs[_0x0330('0x54')](_0x275daa)){logger[_0x0330('0x68')](_0x0330('0x6b')+_0x275daa+_0x0330('0x6c'));fs['unlinkSync'](_0x275daa);}_0x275daa=_0x275daa+_0x0330('0x6d');if(!_[_0x0330('0x6a')](_0x2b6c4a[_0x0330('0x52')])&&fs[_0x0330('0x54')](_0x275daa)){logger[_0x0330('0x68')](_0x0330('0x6b')+_0x275daa+_0x0330('0x6c'));fs[_0x0330('0x6e')](_0x275daa);}return _0x2b6c4a;})[_0x0330('0x28')](function(_0x3d1e36){if(!_0x3d1e36)throw new InternalError();return _0x3d1e36[_0x0330('0x29')]();})[_0x0330('0x28')](function(){_0x780957['status'](0xcc)['end']();})[_0x0330('0x48')](handleError(_0x780957,null));};function getBucketslist(_0x1f23d8,_0x164439,_0x2a0d20){return new Promise(function(_0x1f6de6,_0x39a446){var _0x32d071=new AWS['S3']({'accessKeyId':_0x164439,'secretAccessKey':_0x1f23d8,'region':_0x2a0d20});_0x32d071[_0x0330('0x6f')]({},function(_0x587594,_0x198e76){if(_0x587594){return _0x39a446(_0x587594);}else{return _0x1f6de6(_0x198e76);}});});}function createBucket(_0x2a71c0,_0x9fcdf9,_0x4e3967,_0x4c18ad){return new Promise(function(_0x184d19,_0x13cd64){var _0x4b0868=new AWS['S3']({'accessKeyId':_0x9fcdf9,'secretAccessKey':_0x2a71c0,'region':_0x4e3967});_0x4b0868[_0x0330('0x70')]({'Bucket':_0x4c18ad},function(_0x50975f,_0x31180e){if(_0x50975f){return _0x13cd64(_0x50975f);}else{return _0x184d19(_0x31180e);}});});}function uploadFile(_0x673351,_0x1960dd,_0x4408dd,_0x141599,_0x151cb5,_0x5ee4e7){return new Promise(function(_0x208752,_0x3eb468){var _0x525cd7=new AWS['S3']({'accessKeyId':_0x1960dd,'secretAccessKey':_0x673351,'region':_0x4408dd});_0x525cd7[_0x0330('0x71')]({'Bucket':_0x141599,'Key':_0x151cb5,'Body':_0x5ee4e7},function(_0x4d0cd6,_0x2440bb){if(_0x4d0cd6){return _0x3eb468(_0x4d0cd6);}else{return _0x208752(_0x2440bb);}});});}function startTranscribe(_0x54aa39,_0xe60f87,_0x40a4b0,_0x3e7f24,_0x5c10d6,_0x2995c9){return new Promise(function(_0x3155f4,_0x1a19f1){var _0x509298=new AWS[(_0x0330('0x72'))]({'accessKeyId':_0xe60f87,'secretAccessKey':_0x54aa39,'region':_0x40a4b0});_0x509298['startTranscriptionJob']({'TranscriptionJobName':_0x3e7f24,'LanguageCode':_0x5c10d6,'Media':{'MediaFileUri':_0x2995c9}},function(_0x356a8c,_0x5d619e){if(_0x356a8c){return _0x1a19f1(_0x356a8c);}else{return _0x3155f4(_0x5d619e);}});});}function transcribe(_0x373d0a,_0x493481,_0x3d2372,_0x472671,_0x21948a,_0x23efb0,_0x318787){return new Promise(function(_0x5343fb,_0x59b965){var _0x165306={};logger[_0x0330('0x68')](util[_0x0330('0x64')](_0x0330('0x73'),_0x373d0a,_0x21948a));return uploadFile(_0x493481,_0x3d2372,_0x472671,_0x21948a,path['basename'](_0x23efb0),fs[_0x0330('0x74')](_0x23efb0))[_0x0330('0x28')](function(_0x424462){logger[_0x0330('0x68')](util[_0x0330('0x64')](_0x0330('0x75'),_0x373d0a,_0x21948a,_0x424462[_0x0330('0x76')]));_0x165306['bucket']=_0x424462[_0x0330('0x77')];_0x165306[_0x0330('0x78')]=_0x424462[_0x0330('0x76')];logger[_0x0330('0x68')](util[_0x0330('0x64')]('[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request',_0x373d0a));return startTranscribe(_0x493481,_0x3d2372,_0x472671,uuidv4(),_0x318787,_0x424462[_0x0330('0x76')]);})[_0x0330('0x28')](function(_0x291846){logger[_0x0330('0x68')](util['format']('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0x373d0a,_0x291846['TranscriptionJob'][_0x0330('0x79')]));_0x165306['transcribeName']=_0x291846[_0x0330('0x7a')]['TranscriptionJobName'];_0x165306[_0x0330('0x7b')]=_0x291846[_0x0330('0x7a')][_0x0330('0x7c')];return _0x5343fb(_0x165306);})[_0x0330('0x48')](function(_0x17fff8){return _0x59b965(_0x17fff8);});});}exports['runTranscribe']=function(_0x284e08,_0x166d7b,_0x2f19ca){var _0x15e775;var _0x3572b3;var _0x599329;var _0x263f1c=require(_0x0330('0x50'));return db[_0x0330('0x2e')][_0x0330('0x7d')]({'where':{'id':_0x284e08[_0x0330('0x4a')]['id']}})['then'](function(_0x40c64e){if(_0x40c64e){var _0x5edba1=util[_0x0330('0x64')]('%s.cypher',_0x40c64e[_0x0330('0x52')]);if(fs[_0x0330('0x54')](_0x5edba1)){cypher=!![];return _0x263f1c[_0x0330('0x65')](_0x5edba1,_0x40c64e[_0x0330('0x52')],config[_0x0330('0x55')][_0x0330('0x56')])[_0x0330('0x28')](function(){return _0x40c64e;});}return _0x40c64e;}})[_0x0330('0x28')](function(_0x51a730){if(!_0x51a730){throw new db['Sequelize']['ValidationError'](_0x0330('0x7e'));}_0x3572b3=_0x51a730;return db[_0x0330('0x7f')][_0x0330('0x7d')]({'where':{'id':0x1}});})[_0x0330('0x28')](handleEntityNotFound(_0x166d7b,null))[_0x0330('0x28')](function(_0x3a1f27){if(_0x3a1f27){_0x15e775=_0x3a1f27;if(!_0x15e775[_0x0330('0x80')]||!_0x15e775[_0x0330('0x81')]||!_0x15e775[_0x0330('0x82')]||!_0x15e775[_0x0330('0x83')]||!_0x15e775[_0x0330('0x84')]){throw new db['Sequelize']['ValidationError'](_0x0330('0x85'));}if(_0x284e08[_0x0330('0x4d')]['runSentiment']&&(!_0x15e775[_0x0330('0x86')]||!_0x15e775[_0x0330('0x87')]||!_0x15e775['sentimentRegion']||!_0x15e775[_0x0330('0x83')]||!_0x15e775['bucket'])){throw new db['Sequelize'][(_0x0330('0x66'))](_0x0330('0x88'));}return db['CloudProvider'][_0x0330('0x7d')]({'where':{'id':_0x15e775[_0x0330('0x81')]}});}})[_0x0330('0x28')](function(_0x220f2f){if(!_0x220f2f){throw new db[(_0x0330('0x57'))][(_0x0330('0x66'))](_0x0330('0x89'));}if(!_0x220f2f[_0x0330('0x8a')]||!_0x220f2f[_0x0330('0x8b')]){throw new db[(_0x0330('0x57'))][(_0x0330('0x66'))]('Cloud\x20Provider\x20not\x20configured');}_0x599329=_0x220f2f;return getBucketslist(_0x599329[_0x0330('0x8a')],_0x599329[_0x0330('0x8b')],_0x15e775[_0x0330('0x82')]);})[_0x0330('0x28')](function(_0x23403d){if(_0x23403d&&_0x23403d[_0x0330('0x8c')]){var _0x354931=_[_0x0330('0x63')](_0x23403d[_0x0330('0x8c')],function(_0x52479d){return _0x52479d[_0x0330('0x8d')]===_0x15e775[_0x0330('0x84')];});if(!_0x354931){logger['info'](util[_0x0330('0x64')](_0x0330('0x8e'),_0x284e08['params']['id'],_0x15e775[_0x0330('0x84')]));return createBucket(_0x599329[_0x0330('0x8a')],_0x599329[_0x0330('0x8b')],_0x15e775[_0x0330('0x82')],_0x15e775[_0x0330('0x84')]);}logger[_0x0330('0x68')](util['format']('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available',_0x284e08[_0x0330('0x4a')]['id'],_0x15e775[_0x0330('0x84')]));return;}})[_0x0330('0x28')](function(_0x42e724){if(_0x3572b3[_0x0330('0x7b')]===_0x0330('0x8f')){return transcribe(_0x284e08[_0x0330('0x4a')]['id'],_0x599329[_0x0330('0x8a')],_0x599329[_0x0330('0x8b')],_0x15e775['transcribeRegion'],_0x15e775[_0x0330('0x84')],_0x3572b3[_0x0330('0x52')],_0x15e775[_0x0330('0x83')]);}else{logger[_0x0330('0x68')](util[_0x0330('0x64')](_0x0330('0x90'),_0x284e08[_0x0330('0x4a')]['id']));return{'transcribeStatus':'IN_PROGRESS'};}})[_0x0330('0x28')](function(_0x8847aa){if(_0x8847aa){_0x8847aa[_0x0330('0x91')]=_0x284e08[_0x0330('0x4d')][_0x0330('0x92')];return _0x3572b3['updateAttributes'](_0x8847aa);}})[_0x0330('0x28')](respondWithResult(_0x166d7b,null))[_0x0330('0x48')](handleError(_0x166d7b,null));};function writeFile(_0x2f68b1,_0x1074d1){return new Promise(function(_0x4659dd,_0x201713){fs[_0x0330('0x93')](_0x1074d1,_0x2f68b1,function(_0x48d57e,_0x87bf94){if(_0x48d57e){return _0x201713(_0x48d57e);}else{return _0x4659dd(_0x87bf94);}});});}exports[_0x0330('0x94')]=function(_0x5acae3,_0x215ec6,_0x148e3e){return db[_0x0330('0x2e')][_0x0330('0x7d')]({'where':{'id':_0x5acae3['params']['id']}})[_0x0330('0x28')](handleEntityNotFound(_0x215ec6))[_0x0330('0x28')](function(_0x38a3d8){if(_0x38a3d8&&_0x38a3d8[_0x0330('0x95')]){var _0x1d3aa9=_0x38a3d8[_0x0330('0x95')];var _0x3494a5=config[_0x0330('0x96')]+_0x0330('0x97')+_0x38a3d8['id']+'.txt';if(fs['existsSync'](_0x3494a5)){return _0x3494a5;}return writeFile(_0x1d3aa9,_0x3494a5)[_0x0330('0x28')](function(){return _0x3494a5;});}else{throw new db['Sequelize']['ValidationError'](_0x0330('0x98'));}})['then'](function(_0x526b80){return _0x215ec6[_0x0330('0x4f')](_0x526b80);})[_0x0330('0x48')](handleError(_0x215ec6));};
\ No newline at end of file