Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / voiceRecording / voiceRecording.controller.js
index 6cb086e..d9c0f17 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4de2=['TranscriptionJobStatus','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','transcribe','transcribeAccountId','transcribeRegion','language','Transcribe\x20not\x20configured','sentiment','sentimentAccountId','sentimentRegion','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','Cloud\x20Provider\x20not\x20configured','data1','data2','Buckets','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','NEW','IN_PROGRESS','runSentiment','updateAttributes','root','/server/files/transcribes/transcribe_','.txt','Transcript\x20not\x20available','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','querystring','papaparse','aws-sdk','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','limit','undefined','count','set','apply','reject','save','update','then','destroy','end','error','stack','name','send','index','map','rawAttributes','fieldName','key','differenceBy','format','query','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','type','VIRTUAL','filter','merge','options','VoiceRecording','include','findAll','rows','catch','show','params','keys','intersection','includeAll','find','create','body','describe','download','../../components/encryptor','uniqueid','value','existsSync','decryptFile','recording','Sequelize','VoiceRecording\x20not\x20found','extname','unlink','message','Not\x20found','downloads','sequelize','MD5','$and','push','secrets','ValidationError','filename','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','isNil','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','.cypher','File:\x20\x22','listBuckets','createBucket','upload','TranscribeService','startTranscriptionJob','readFileSync','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','bucket','location','TranscriptionJob','TranscriptionJobName','transcribeStatus'];(function(_0x4a7836,_0x35cea2){var _0x54425b=function(_0x5940f2){while(--_0x5940f2){_0x4a7836['push'](_0x4a7836['shift']());}};_0x54425b(++_0x35cea2);}(_0x4de2,0x152));var _0x24de=function(_0x3485f8,_0x1b66cf){_0x3485f8=_0x3485f8-0x0;var _0x1fbba7=_0x4de2[_0x3485f8];return _0x1fbba7;};'use strict';var emlformat=require(_0x24de('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x24de('0x1'));var jsonpatch=require(_0x24de('0x2'));var rp=require(_0x24de('0x3'));var moment=require(_0x24de('0x4'));var BPromise=require(_0x24de('0x5'));var Mustache=require('mustache');var util=require(_0x24de('0x6'));var path=require(_0x24de('0x7'));var sox=require(_0x24de('0x8'));var csv=require(_0x24de('0x9'));var ejs=require(_0x24de('0xa'));var fs=require('fs');var fs_extra=require(_0x24de('0xb'));var _=require(_0x24de('0xc'));var squel=require(_0x24de('0xd'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x24de('0x9'));var querystring=require(_0x24de('0xe'));var Papa=require(_0x24de('0xf'));var AWS=require(_0x24de('0x10'));var uuidv4=require('uuid/v4');var Redis=require(_0x24de('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x24de('0x12'));var as=require(_0x24de('0x13'));var hardwareService=require(_0x24de('0x14'));var logger=require(_0x24de('0x15'))(_0x24de('0x16'));var utils=require('../../config/utils');var config=require(_0x24de('0x17'));var licenseUtil=require(_0x24de('0x18'));var db=require(_0x24de('0x19'))['db'];function respondWithStatusCode(_0x2ae67e,_0x128bea){_0x128bea=_0x128bea||0xcc;return function(_0x44906b){if(_0x44906b){return _0x2ae67e[_0x24de('0x1a')](_0x128bea);}return _0x2ae67e[_0x24de('0x1b')](_0x128bea)['end']();};}function respondWithResult(_0x4113af,_0x5b3133){_0x5b3133=_0x5b3133||0xc8;return function(_0xe042e0){if(_0xe042e0){return _0x4113af['status'](_0x5b3133)[_0x24de('0x1c')](_0xe042e0);}};}function respondWithFilteredResult(_0x3cc51e,_0x48ae47){return function(_0x99aeaf){if(_0x99aeaf){var _0x58b1a2=typeof _0x48ae47[_0x24de('0x1d')]==='undefined'&&typeof _0x48ae47[_0x24de('0x1e')]===_0x24de('0x1f');var _0xd88d91=_0x99aeaf[_0x24de('0x20')];var _0x38d6e0=_0x58b1a2?0x0:_0x48ae47[_0x24de('0x1d')];var _0x147bae=_0x58b1a2?_0x99aeaf['count']:_0x48ae47['offset']+_0x48ae47[_0x24de('0x1e')];var _0x561bc5;if(_0x147bae>=_0xd88d91){_0x147bae=_0xd88d91;_0x561bc5=0xc8;}else{_0x561bc5=0xce;}_0x3cc51e[_0x24de('0x1b')](_0x561bc5);return _0x3cc51e[_0x24de('0x21')]('Content-Range',_0x38d6e0+'-'+_0x147bae+'/'+_0xd88d91)[_0x24de('0x1c')](_0x99aeaf);}return null;};}function patchUpdates(_0x77935a){return function(_0xe988ab){try{jsonpatch[_0x24de('0x22')](_0xe988ab,_0x77935a,!![]);}catch(_0xb88e24){return BPromise[_0x24de('0x23')](_0xb88e24);}return _0xe988ab[_0x24de('0x24')]();};}function saveUpdates(_0x417c55,_0x4eeec8){return function(_0x2cf11b){if(_0x2cf11b){return _0x2cf11b[_0x24de('0x25')](_0x417c55)[_0x24de('0x26')](function(_0x3b0f2f){return _0x3b0f2f;});}return null;};}function removeEntity(_0x2ca813,_0x2da1b3){return function(_0x493d8e){if(_0x493d8e){return _0x493d8e[_0x24de('0x27')]()[_0x24de('0x26')](function(){_0x2ca813[_0x24de('0x1b')](0xcc)[_0x24de('0x28')]();});}};}function handleEntityNotFound(_0x37b37e,_0xae6cfa){return function(_0x25f50d){if(!_0x25f50d){_0x37b37e['sendStatus'](0x194);}return _0x25f50d;};}function handleError(_0x579ea3,_0x432a79){_0x432a79=_0x432a79||0x1f4;return function(_0x32822f){logger[_0x24de('0x29')](_0x32822f[_0x24de('0x2a')]);if(_0x32822f[_0x24de('0x2b')]){delete _0x32822f[_0x24de('0x2b')];}_0x579ea3['status'](_0x432a79)[_0x24de('0x2c')](_0x32822f);};}exports[_0x24de('0x2d')]=function(_0x456ca7,_0x51e786){var _0x5919dc={},_0x2cdbab={},_0x1c2034={'count':0x0,'rows':[]};var _0x537bab=_[_0x24de('0x2e')](db['VoiceRecording'][_0x24de('0x2f')],function(_0x492b7c){return{'name':_0x492b7c[_0x24de('0x30')],'type':_0x492b7c['type'][_0x24de('0x31')]};});_0x2cdbab['model']=_[_0x24de('0x32')](_['map'](_0x537bab,_0x24de('0x2b')),[_0x24de('0x33')]);_0x2cdbab[_0x24de('0x34')]=_['keys'](_0x456ca7[_0x24de('0x34')]);_0x2cdbab['filters']=_['intersection'](_0x2cdbab[_0x24de('0x35')],_0x2cdbab[_0x24de('0x34')]);_0x5919dc[_0x24de('0x36')]=_['intersection'](_0x2cdbab['model'],qs[_0x24de('0x37')](_0x456ca7[_0x24de('0x34')][_0x24de('0x37')]));_0x5919dc[_0x24de('0x36')]=_0x5919dc[_0x24de('0x36')][_0x24de('0x38')]?_0x5919dc[_0x24de('0x36')]:_0x2cdbab[_0x24de('0x35')];if(!_0x456ca7[_0x24de('0x34')][_0x24de('0x39')](_0x24de('0x3a'))){_0x5919dc[_0x24de('0x1e')]=qs[_0x24de('0x1e')](_0x456ca7['query'][_0x24de('0x1e')]);_0x5919dc['offset']=qs[_0x24de('0x1d')](_0x456ca7['query'][_0x24de('0x1d')]);}_0x5919dc[_0x24de('0x3b')]=qs[_0x24de('0x3c')](_0x456ca7['query'][_0x24de('0x3c')]);_0x5919dc[_0x24de('0x3d')]=qs[_0x24de('0x3e')](_['pick'](_0x456ca7[_0x24de('0x34')],_0x2cdbab['filters']),_0x537bab);if(_0x456ca7[_0x24de('0x34')]['filter']){_0x5919dc[_0x24de('0x3d')]=_['merge'](_0x5919dc[_0x24de('0x3d')],{'$or':_['map'](_0x537bab,function(_0xa6f9f7){if(_0xa6f9f7[_0x24de('0x3f')]!==_0x24de('0x40')){var _0x514caa={};_0x514caa[_0xa6f9f7[_0x24de('0x2b')]]={'$like':'%'+_0x456ca7[_0x24de('0x34')][_0x24de('0x41')]+'%'};return _0x514caa;}})});}_0x5919dc=_[_0x24de('0x42')]({},_0x5919dc,_0x456ca7[_0x24de('0x43')]);var _0x3dea28={'where':_0x5919dc[_0x24de('0x3d')]};return db[_0x24de('0x44')][_0x24de('0x20')](_0x3dea28)[_0x24de('0x26')](function(_0x29b51b){_0x1c2034[_0x24de('0x20')]=_0x29b51b;if(_0x456ca7[_0x24de('0x34')]['includeAll']){_0x5919dc[_0x24de('0x45')]=[{'all':!![]}];}return db[_0x24de('0x44')][_0x24de('0x46')](_0x5919dc);})['then'](function(_0x12b836){_0x1c2034[_0x24de('0x47')]=_0x12b836;return _0x1c2034;})['then'](respondWithFilteredResult(_0x51e786,_0x5919dc))[_0x24de('0x48')](handleError(_0x51e786,null));};exports[_0x24de('0x49')]=function(_0x3ba086,_0x18e052){var _0x251f89={'raw':![],'where':{'id':_0x3ba086[_0x24de('0x4a')]['id']}},_0x423f05={};_0x423f05['model']=_[_0x24de('0x4b')](db[_0x24de('0x44')][_0x24de('0x2f')]);_0x423f05[_0x24de('0x34')]=_[_0x24de('0x4b')](_0x3ba086[_0x24de('0x34')]);_0x423f05['filters']=_[_0x24de('0x4c')](_0x423f05[_0x24de('0x35')],_0x423f05[_0x24de('0x34')]);_0x251f89[_0x24de('0x36')]=_[_0x24de('0x4c')](_0x423f05[_0x24de('0x35')],qs['fields'](_0x3ba086[_0x24de('0x34')][_0x24de('0x37')]));_0x251f89['attributes']=_0x251f89[_0x24de('0x36')]['length']?_0x251f89[_0x24de('0x36')]:_0x423f05[_0x24de('0x35')];if(_0x3ba086[_0x24de('0x34')][_0x24de('0x4d')]){_0x251f89['include']=[{'all':!![]}];}_0x251f89=_[_0x24de('0x42')]({},_0x251f89,_0x3ba086[_0x24de('0x43')]);return db['VoiceRecording'][_0x24de('0x4e')](_0x251f89)[_0x24de('0x26')](handleEntityNotFound(_0x18e052,null))[_0x24de('0x26')](respondWithResult(_0x18e052,null))[_0x24de('0x48')](handleError(_0x18e052,null));};exports[_0x24de('0x4f')]=function(_0x16817f,_0x229419){return db['VoiceRecording']['create'](_0x16817f[_0x24de('0x50')],{})[_0x24de('0x26')](respondWithResult(_0x229419,0xc9))[_0x24de('0x48')](handleError(_0x229419,null));};exports[_0x24de('0x25')]=function(_0x1b414f,_0x46d0de){if(_0x1b414f[_0x24de('0x50')]['id']){delete _0x1b414f['body']['id'];}return db[_0x24de('0x44')][_0x24de('0x4e')]({'where':{'id':_0x1b414f[_0x24de('0x4a')]['id']}})[_0x24de('0x26')](handleEntityNotFound(_0x46d0de,null))[_0x24de('0x26')](saveUpdates(_0x1b414f['body'],null))[_0x24de('0x26')](respondWithResult(_0x46d0de,null))['catch'](handleError(_0x46d0de,null));};exports['describe']=function(_0x198b7b,_0x5456cc){return db['VoiceRecording'][_0x24de('0x51')]()[_0x24de('0x26')](respondWithResult(_0x5456cc,null))[_0x24de('0x48')](handleError(_0x5456cc,null));};exports[_0x24de('0x52')]=function(_0x57a597,_0x58b0fd,_0x29ef7b){var _0xe3e0ed=require(_0x24de('0x53'));var _0x4a53a6=![];var _0x55d46a={};if(_0x57a597[_0x24de('0x34')][_0x24de('0x3f')]&&_0x57a597[_0x24de('0x34')]['type']===_0x24de('0x54')){_0x55d46a['uniqueid']=_0x57a597[_0x24de('0x4a')]['id'];}else{_0x55d46a['id']=_0x57a597[_0x24de('0x4a')]['id'];}return db[_0x24de('0x44')]['find']({'where':_0x55d46a,'attributes':['id',_0x24de('0x55')],'raw':!![]})[_0x24de('0x26')](handleEntityNotFound(_0x58b0fd,null))['then'](function(_0x42be41){if(_0x42be41){var _0x2d155b=_0x42be41['value'];var _0x583411=util[_0x24de('0x33')]('%s.cypher',_0x2d155b);if(fs[_0x24de('0x56')](_0x583411)){_0x4a53a6=!![];return _0xe3e0ed[_0x24de('0x57')](_0x583411,_0x2d155b,config['secrets'][_0x24de('0x58')])[_0x24de('0x26')](function(){return _0x42be41;});}return _0x42be41;}})[_0x24de('0x26')](function(_0x3763bf){if(_0x3763bf){var _0x1267cd=_0x3763bf['value'];if(!fs[_0x24de('0x56')](_0x1267cd)){throw new db[(_0x24de('0x59'))]['ValidationError'](_0x24de('0x5a'));}if(_0x3763bf['filename']){return _0x58b0fd[_0x24de('0x52')](_0x1267cd,_0x3763bf['filename']+path[_0x24de('0x5b')](_0x1267cd),function(){if(_0x4a53a6){fs[_0x24de('0x5c')](_0x1267cd);}});}else{return _0x58b0fd[_0x24de('0x52')](_0x1267cd,function(_0x22cbe4){if(_0x4a53a6){fs['unlink'](_0x1267cd);}});}}})[_0x24de('0x48')](function(_0x37f213){if(_0x37f213[_0x24de('0x5d')]===_0x24de('0x5a')){_0x58b0fd[_0x24de('0x1b')](0x194)[_0x24de('0x2c')](_0x24de('0x5e'));}else{return handleError(_0x58b0fd,null);}});};exports[_0x24de('0x5f')]=function(_0x365109,_0x49992a,_0x5c0371){var _0x1a727e=require(_0x24de('0x53'));var _0x30fb7a=![];var _0xdafdff={'$and':[db[_0x24de('0x60')][_0x24de('0x3d')](db[_0x24de('0x60')]['fn'](_0x24de('0x61'),db[_0x24de('0x60')]['col']('uniqueid')),_0x365109[_0x24de('0x34')]['token'])]};if(_0x365109[_0x24de('0x34')][_0x24de('0x3f')]&&_0x365109[_0x24de('0x34')][_0x24de('0x3f')]===_0x24de('0x54')){_0xdafdff[_0x24de('0x62')][_0x24de('0x63')]({'uniqueid':_0x365109[_0x24de('0x4a')]['id']});}else{_0xdafdff[_0x24de('0x62')][_0x24de('0x63')]({'id':_0x365109[_0x24de('0x4a')]['id']});}return db[_0x24de('0x44')]['find']({'where':_0xdafdff,'attributes':['id','value'],'raw':!![]})[_0x24de('0x26')](handleEntityNotFound(_0x49992a,null))['then'](function(_0x5bd7e7){if(_0x5bd7e7){var _0xfbc9ba=util['format']('%s.cypher',_0x5bd7e7[_0x24de('0x55')]);if(fs[_0x24de('0x56')](_0xfbc9ba)){_0x30fb7a=!![];return _0x1a727e[_0x24de('0x57')](_0xfbc9ba,_0x5bd7e7[_0x24de('0x55')],config[_0x24de('0x64')][_0x24de('0x58')])[_0x24de('0x26')](function(){return _0x5bd7e7;});}return _0x5bd7e7;}})[_0x24de('0x26')](function(_0x4ad7ac){if(_0x4ad7ac){if(!fs[_0x24de('0x56')](_0x4ad7ac[_0x24de('0x55')])){throw new db['Sequelize'][(_0x24de('0x65'))](_0x24de('0x5a'));}if(_0x4ad7ac['filename']){return _0x49992a['download'](_0x4ad7ac[_0x24de('0x55')],_0x4ad7ac[_0x24de('0x66')]+path['extname'](_0x4ad7ac[_0x24de('0x55')]),function(){if(_0x30fb7a){fs[_0x24de('0x5c')](_0x4ad7ac['value']);}});}else{return _0x49992a[_0x24de('0x52')](_0x4ad7ac[_0x24de('0x55')],function(_0x5cbc3b){if(_0x30fb7a){fs[_0x24de('0x5c')](_0x4ad7ac['value']);}});}}})[_0x24de('0x48')](handleError(_0x49992a,null));};exports[_0x24de('0x27')]=function(_0x278c06,_0x400665){return db[_0x24de('0x44')][_0x24de('0x4e')]({'where':{'id':_0x278c06['params']['id']}})['then'](function(_0x44a931){if(_['isNil'](_0x44a931)){throw new ReferenceError(_0x24de('0x67'));}return _0x44a931;})[_0x24de('0x26')](function(_0x3364a6){var _0x19c58c=_0x3364a6[_0x24de('0x55')];logger[_0x24de('0x68')](_0x24de('0x69'),_0x19c58c);if(!_[_0x24de('0x6a')](_0x3364a6[_0x24de('0x55')])&&fs[_0x24de('0x56')](_0x19c58c)){logger['info']('File:\x20\x22'+_0x19c58c+_0x24de('0x6b'));fs[_0x24de('0x6c')](_0x19c58c);}_0x19c58c=_0x19c58c+_0x24de('0x6d');if(!_['isNil'](_0x3364a6[_0x24de('0x55')])&&fs[_0x24de('0x56')](_0x19c58c)){logger[_0x24de('0x68')](_0x24de('0x6e')+_0x19c58c+_0x24de('0x6b'));fs[_0x24de('0x6c')](_0x19c58c);}return _0x3364a6;})['then'](function(_0x1d81ab){if(!_0x1d81ab)throw new InternalError();return _0x1d81ab[_0x24de('0x27')]();})[_0x24de('0x26')](function(){_0x400665[_0x24de('0x1b')](0xcc)['end']();})[_0x24de('0x48')](handleError(_0x400665,null));};function getBucketslist(_0x392af8,_0x206f22,_0x294d63){return new Promise(function(_0x59c73d,_0x4ad01d){var _0x3a0cc1=new AWS['S3']({'accessKeyId':_0x206f22,'secretAccessKey':_0x392af8,'region':_0x294d63});_0x3a0cc1[_0x24de('0x6f')]({},function(_0x361f45,_0x54bc78){if(_0x361f45){return _0x4ad01d(_0x361f45);}else{return _0x59c73d(_0x54bc78);}});});}function createBucket(_0x15bee5,_0x1186c3,_0x2da65e,_0x7d445e){return new Promise(function(_0x3c141c,_0x55807f){var _0x5a19d3=new AWS['S3']({'accessKeyId':_0x1186c3,'secretAccessKey':_0x15bee5,'region':_0x2da65e});_0x5a19d3[_0x24de('0x70')]({'Bucket':_0x7d445e},function(_0x1d0424,_0x22721d){if(_0x1d0424){return _0x55807f(_0x1d0424);}else{return _0x3c141c(_0x22721d);}});});}function uploadFile(_0x21f73e,_0x54e6ba,_0x2127ee,_0x520353,_0x3654e7,_0x311603){return new Promise(function(_0x493979,_0x31bf42){var _0x372d2d=new AWS['S3']({'accessKeyId':_0x54e6ba,'secretAccessKey':_0x21f73e,'region':_0x2127ee});_0x372d2d[_0x24de('0x71')]({'Bucket':_0x520353,'Key':_0x3654e7,'Body':_0x311603},function(_0x22fcbe,_0x4b488d){if(_0x22fcbe){return _0x31bf42(_0x22fcbe);}else{return _0x493979(_0x4b488d);}});});}function startTranscribe(_0x229316,_0x2527ac,_0x1e5e95,_0x2c62db,_0x1a4728,_0x579957){return new Promise(function(_0x5676fb,_0x2c588f){var _0x1bdc44=new AWS[(_0x24de('0x72'))]({'accessKeyId':_0x2527ac,'secretAccessKey':_0x229316,'region':_0x1e5e95});_0x1bdc44[_0x24de('0x73')]({'TranscriptionJobName':_0x2c62db,'LanguageCode':_0x1a4728,'Media':{'MediaFileUri':_0x579957}},function(_0xcda26c,_0x3e0afb){if(_0xcda26c){return _0x2c588f(_0xcda26c);}else{return _0x5676fb(_0x3e0afb);}});});}function transcribe(_0xe6e4d1,_0x2618ee,_0x59aa17,_0x162599,_0x2b474b,_0x271750,_0x2c0e69){return new Promise(function(_0x2b5300,_0x18c200){var _0x2af05e={};logger[_0x24de('0x68')](util[_0x24de('0x33')]('[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s',_0xe6e4d1,_0x2b474b));return uploadFile(_0x2618ee,_0x59aa17,_0x162599,_0x2b474b,path['basename'](_0x271750),fs[_0x24de('0x74')](_0x271750))[_0x24de('0x26')](function(_0x13940a){logger[_0x24de('0x68')](util['format'](_0x24de('0x75'),_0xe6e4d1,_0x2b474b,_0x13940a[_0x24de('0x76')]));_0x2af05e[_0x24de('0x77')]=_0x13940a['Bucket'];_0x2af05e[_0x24de('0x78')]=_0x13940a[_0x24de('0x76')];logger['info'](util[_0x24de('0x33')]('[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request',_0xe6e4d1));return startTranscribe(_0x2618ee,_0x59aa17,_0x162599,uuidv4(),_0x2c0e69,_0x13940a['Location']);})[_0x24de('0x26')](function(_0x269f3){logger[_0x24de('0x68')](util['format']('[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created',_0xe6e4d1,_0x269f3[_0x24de('0x79')][_0x24de('0x7a')]));_0x2af05e['transcribeName']=_0x269f3[_0x24de('0x79')]['TranscriptionJobName'];_0x2af05e[_0x24de('0x7b')]=_0x269f3['TranscriptionJob'][_0x24de('0x7c')];return _0x2b5300(_0x2af05e);})['catch'](function(_0x2a387e){return _0x18c200(_0x2a387e);});});}exports[_0x24de('0x7d')]=function(_0x4d0966,_0x19d945,_0x23b3b8){var _0x30ad16;var _0x5be054;var _0x26c218;var _0x42398a=require(_0x24de('0x53'));return db[_0x24de('0x44')][_0x24de('0x7e')]({'where':{'id':_0x4d0966[_0x24de('0x4a')]['id']}})[_0x24de('0x26')](function(_0x308f2a){if(_0x308f2a){var _0x2c1405=util['format']('%s.cypher',_0x308f2a[_0x24de('0x55')]);if(fs['existsSync'](_0x2c1405)){cypher=!![];return _0x42398a[_0x24de('0x57')](_0x2c1405,_0x308f2a[_0x24de('0x55')],config[_0x24de('0x64')][_0x24de('0x58')])[_0x24de('0x26')](function(){return _0x308f2a;});}return _0x308f2a;}})[_0x24de('0x26')](function(_0x52d5a4){if(!_0x52d5a4){throw new db[(_0x24de('0x59'))][(_0x24de('0x65'))](_0x24de('0x7f'));}_0x5be054=_0x52d5a4;return db['Setting'][_0x24de('0x7e')]({'where':{'id':0x1}});})[_0x24de('0x26')](handleEntityNotFound(_0x19d945,null))[_0x24de('0x26')](function(_0x2836bf){if(_0x2836bf){_0x30ad16=_0x2836bf;if(!_0x30ad16[_0x24de('0x80')]||!_0x30ad16[_0x24de('0x81')]||!_0x30ad16[_0x24de('0x82')]||!_0x30ad16[_0x24de('0x83')]||!_0x30ad16[_0x24de('0x77')]){throw new db[(_0x24de('0x59'))][(_0x24de('0x65'))](_0x24de('0x84'));}if(_0x4d0966[_0x24de('0x50')]['runSentiment']&&(!_0x30ad16[_0x24de('0x85')]||!_0x30ad16[_0x24de('0x86')]||!_0x30ad16[_0x24de('0x87')]||!_0x30ad16[_0x24de('0x83')]||!_0x30ad16[_0x24de('0x77')])){throw new db[(_0x24de('0x59'))][(_0x24de('0x65'))](_0x24de('0x88'));}return db[_0x24de('0x89')][_0x24de('0x7e')]({'where':{'id':_0x30ad16['transcribeAccountId']}});}})[_0x24de('0x26')](function(_0x205c71){if(!_0x205c71){throw new db[(_0x24de('0x59'))]['ValidationError'](_0x24de('0x8a'));}if(!_0x205c71['data1']||!_0x205c71['data2']){throw new db[(_0x24de('0x59'))][(_0x24de('0x65'))](_0x24de('0x8b'));}_0x26c218=_0x205c71;return getBucketslist(_0x26c218[_0x24de('0x8c')],_0x26c218[_0x24de('0x8d')],_0x30ad16[_0x24de('0x82')]);})[_0x24de('0x26')](function(_0x177535){if(_0x177535&&_0x177535[_0x24de('0x8e')]){var _0x11580a=_['find'](_0x177535['Buckets'],function(_0x307768){return _0x307768[_0x24de('0x8f')]===_0x30ad16[_0x24de('0x77')];});if(!_0x11580a){logger[_0x24de('0x68')](util[_0x24de('0x33')](_0x24de('0x90'),_0x4d0966[_0x24de('0x4a')]['id'],_0x30ad16['bucket']));return createBucket(_0x26c218[_0x24de('0x8c')],_0x26c218[_0x24de('0x8d')],_0x30ad16[_0x24de('0x82')],_0x30ad16['bucket']);}logger[_0x24de('0x68')](util[_0x24de('0x33')](_0x24de('0x91'),_0x4d0966['params']['id'],_0x30ad16[_0x24de('0x77')]));return;}})[_0x24de('0x26')](function(_0x2d7a11){if(_0x5be054['transcribeStatus']===_0x24de('0x92')){return transcribe(_0x4d0966[_0x24de('0x4a')]['id'],_0x26c218[_0x24de('0x8c')],_0x26c218['data2'],_0x30ad16[_0x24de('0x82')],_0x30ad16['bucket'],_0x5be054[_0x24de('0x55')],_0x30ad16[_0x24de('0x83')]);}else{logger[_0x24de('0x68')](util[_0x24de('0x33')]('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x4d0966[_0x24de('0x4a')]['id']));return{'transcribeStatus':_0x24de('0x93')};}})[_0x24de('0x26')](function(_0x2a36ae){if(_0x2a36ae){_0x2a36ae['tempSentiment']=_0x4d0966[_0x24de('0x50')][_0x24de('0x94')];return _0x5be054[_0x24de('0x95')](_0x2a36ae);}})[_0x24de('0x26')](respondWithResult(_0x19d945,null))['catch'](handleError(_0x19d945,null));};function writeFile(_0x25f7db,_0x2154ac){return new Promise(function(_0x2c5286,_0x3ecfcd){fs['writeFile'](_0x2154ac,_0x25f7db,function(_0x3454b5,_0x29b10b){if(_0x3454b5){return _0x3ecfcd(_0x3454b5);}else{return _0x2c5286(_0x29b10b);}});});}exports['downloadTranscribe']=function(_0x206dbc,_0x30621a,_0x5af2f1){return db['VoiceRecording']['findOne']({'where':{'id':_0x206dbc[_0x24de('0x4a')]['id']}})['then'](handleEntityNotFound(_0x30621a))[_0x24de('0x26')](function(_0x139a32){if(_0x139a32&&_0x139a32['fileText']){var _0x24431c=_0x139a32['fileText'];var _0x41b671=config[_0x24de('0x96')]+_0x24de('0x97')+_0x139a32['id']+_0x24de('0x98');if(fs[_0x24de('0x56')](_0x41b671)){return _0x41b671;}return writeFile(_0x24431c,_0x41b671)[_0x24de('0x26')](function(){return _0x41b671;});}else{throw new db[(_0x24de('0x59'))][(_0x24de('0x65'))](_0x24de('0x99'));}})['then'](function(_0xa6991d){return _0x30621a[_0x24de('0x52')](_0xa6991d);})['catch'](handleError(_0x30621a));};
\ No newline at end of file
+var _0x0fc5=['[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','Location','Bucket','location','[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','TranscriptionJob','transcribeName','TranscriptionJobName','transcribeStatus','TranscriptionJobStatus','runTranscribe','findOne','Voice\x20Recording\x20not\x20found','Setting','transcribeAccountId','transcribeRegion','language','Transcribe\x20not\x20configured','runSentiment','sentimentAccountId','sentimentRegion','CloudProvider','data1','Cloud\x20Provider\x20not\x20configured','data2','Buckets','bucket','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available','NEW','IN_PROGRESS','tempSentiment','updateAttributes','writeFile','downloadTranscribe','fileText','/server/files/transcribes/transcribe_','.txt','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','desk.js','querystring','papaparse','uuid/v4','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','status','json','undefined','count','offset','limit','set','apply','save','update','then','destroy','end','sendStatus','name','send','index','map','VoiceRecording','rawAttributes','fieldName','type','key','model','differenceBy','format','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','merge','where','includeAll','include','catch','params','keys','create','body','describe','download','../../components/encryptor','uniqueid','find','value','%s.cypher','existsSync','decryptFile','secrets','recording','Sequelize','ValidationError','filename','extname','unlink','Not\x20found','sequelize','MD5','col','token','$and','push','VoiceRecording\x20not\x20found','Entity\x20not\x20found','info','cancellazione\x20fisica\x20documento\x20%s','isNil','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','.cypher','listBuckets','createBucket','TranscribeService','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','readFileSync'];(function(_0x582ccd,_0xa9ab43){var _0x11545d=function(_0x4010fa){while(--_0x4010fa){_0x582ccd['push'](_0x582ccd['shift']());}};_0x11545d(++_0xa9ab43);}(_0x0fc5,0xbd));var _0x50fc=function(_0x279df8,_0x58ac13){_0x279df8=_0x279df8-0x0;var _0x180824=_0x0fc5[_0x279df8];return _0x180824;};'use strict';var emlformat=require(_0x50fc('0x0'));var rimraf=require(_0x50fc('0x1'));var zipdir=require(_0x50fc('0x2'));var jsonpatch=require(_0x50fc('0x3'));var rp=require(_0x50fc('0x4'));var moment=require('moment');var BPromise=require(_0x50fc('0x5'));var Mustache=require('mustache');var util=require(_0x50fc('0x6'));var path=require(_0x50fc('0x7'));var sox=require(_0x50fc('0x8'));var csv=require(_0x50fc('0x9'));var ejs=require(_0x50fc('0xa'));var fs=require('fs');var fs_extra=require(_0x50fc('0xb'));var _=require(_0x50fc('0xc'));var squel=require('squel');var crypto=require(_0x50fc('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x50fc('0xe'));var toCsv=require(_0x50fc('0x9'));var querystring=require(_0x50fc('0xf'));var Papa=require(_0x50fc('0x10'));var AWS=require('aws-sdk');var uuidv4=require(_0x50fc('0x11'));var Redis=require('ioredis');var authService=require(_0x50fc('0x12'));var qs=require(_0x50fc('0x13'));var as=require(_0x50fc('0x14'));var hardwareService=require(_0x50fc('0x15'));var logger=require(_0x50fc('0x16'))('api');var utils=require(_0x50fc('0x17'));var config=require(_0x50fc('0x18'));var licenseUtil=require(_0x50fc('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x58d21d,_0x1b2a15){_0x1b2a15=_0x1b2a15||0xcc;return function(_0x16e5f2){if(_0x16e5f2){return _0x58d21d['sendStatus'](_0x1b2a15);}return _0x58d21d[_0x50fc('0x1a')](_0x1b2a15)['end']();};}function respondWithResult(_0x3dbf3e,_0x3075fc){_0x3075fc=_0x3075fc||0xc8;return function(_0x2369fa){if(_0x2369fa){return _0x3dbf3e['status'](_0x3075fc)[_0x50fc('0x1b')](_0x2369fa);}};}function respondWithFilteredResult(_0x3512a9,_0xbf6599){return function(_0xf0e0ba){if(_0xf0e0ba){var _0x1da3fb=typeof _0xbf6599['offset']===_0x50fc('0x1c')&&typeof _0xbf6599['limit']===_0x50fc('0x1c');var _0x26e498=_0xf0e0ba[_0x50fc('0x1d')];var _0x2e892a=_0x1da3fb?0x0:_0xbf6599[_0x50fc('0x1e')];var _0x511874=_0x1da3fb?_0xf0e0ba['count']:_0xbf6599[_0x50fc('0x1e')]+_0xbf6599[_0x50fc('0x1f')];var _0x1a2d04;if(_0x511874>=_0x26e498){_0x511874=_0x26e498;_0x1a2d04=0xc8;}else{_0x1a2d04=0xce;}_0x3512a9[_0x50fc('0x1a')](_0x1a2d04);return _0x3512a9[_0x50fc('0x20')]('Content-Range',_0x2e892a+'-'+_0x511874+'/'+_0x26e498)['json'](_0xf0e0ba);}return null;};}function patchUpdates(_0x32c2be){return function(_0x343f14){try{jsonpatch[_0x50fc('0x21')](_0x343f14,_0x32c2be,!![]);}catch(_0x564b34){return BPromise['reject'](_0x564b34);}return _0x343f14[_0x50fc('0x22')]();};}function saveUpdates(_0xced0d9,_0x438a34){return function(_0x30b7a3){if(_0x30b7a3){return _0x30b7a3[_0x50fc('0x23')](_0xced0d9)[_0x50fc('0x24')](function(_0x37c94f){return _0x37c94f;});}return null;};}function removeEntity(_0x3b8348,_0x2149dc){return function(_0x12d6f2){if(_0x12d6f2){return _0x12d6f2[_0x50fc('0x25')]()[_0x50fc('0x24')](function(){_0x3b8348[_0x50fc('0x1a')](0xcc)[_0x50fc('0x26')]();});}};}function handleEntityNotFound(_0x2812ae,_0x4726db){return function(_0xb98671){if(!_0xb98671){_0x2812ae[_0x50fc('0x27')](0x194);}return _0xb98671;};}function handleError(_0x563a3e,_0x54fa9b){_0x54fa9b=_0x54fa9b||0x1f4;return function(_0x140c0f){logger['error'](_0x140c0f['stack']);if(_0x140c0f[_0x50fc('0x28')]){delete _0x140c0f[_0x50fc('0x28')];}_0x563a3e[_0x50fc('0x1a')](_0x54fa9b)[_0x50fc('0x29')](_0x140c0f);};}exports[_0x50fc('0x2a')]=function(_0x344c60,_0x39a44d){var _0x3b44da={},_0x2122b5={},_0xfbce23={'count':0x0,'rows':[]};var _0x1449b5=_[_0x50fc('0x2b')](db[_0x50fc('0x2c')][_0x50fc('0x2d')],function(_0x234bc1){return{'name':_0x234bc1[_0x50fc('0x2e')],'type':_0x234bc1[_0x50fc('0x2f')][_0x50fc('0x30')]};});_0x2122b5[_0x50fc('0x31')]=_[_0x50fc('0x32')](_['map'](_0x1449b5,_0x50fc('0x28')),[_0x50fc('0x33')]);_0x2122b5['query']=_['keys'](_0x344c60[_0x50fc('0x34')]);_0x2122b5[_0x50fc('0x35')]=_[_0x50fc('0x36')](_0x2122b5[_0x50fc('0x31')],_0x2122b5[_0x50fc('0x34')]);_0x3b44da['attributes']=_[_0x50fc('0x36')](_0x2122b5[_0x50fc('0x31')],qs[_0x50fc('0x37')](_0x344c60['query'][_0x50fc('0x37')]));_0x3b44da[_0x50fc('0x38')]=_0x3b44da[_0x50fc('0x38')][_0x50fc('0x39')]?_0x3b44da[_0x50fc('0x38')]:_0x2122b5['model'];if(!_0x344c60[_0x50fc('0x34')][_0x50fc('0x3a')](_0x50fc('0x3b'))){_0x3b44da[_0x50fc('0x1f')]=qs[_0x50fc('0x1f')](_0x344c60['query'][_0x50fc('0x1f')]);_0x3b44da[_0x50fc('0x1e')]=qs[_0x50fc('0x1e')](_0x344c60[_0x50fc('0x34')][_0x50fc('0x1e')]);}_0x3b44da[_0x50fc('0x3c')]=qs['sort'](_0x344c60[_0x50fc('0x34')][_0x50fc('0x3d')]);_0x3b44da['where']=qs[_0x50fc('0x35')](_[_0x50fc('0x3e')](_0x344c60[_0x50fc('0x34')],_0x2122b5[_0x50fc('0x35')]),_0x1449b5);if(_0x344c60[_0x50fc('0x34')][_0x50fc('0x3f')]){_0x3b44da['where']=_[_0x50fc('0x40')](_0x3b44da[_0x50fc('0x41')],{'$or':_[_0x50fc('0x2b')](_0x1449b5,function(_0x404c15){if(_0x404c15['type']!=='VIRTUAL'){var _0x3a2770={};_0x3a2770[_0x404c15['name']]={'$like':'%'+_0x344c60['query'][_0x50fc('0x3f')]+'%'};return _0x3a2770;}})});}_0x3b44da=_['merge']({},_0x3b44da,_0x344c60['options']);var _0x2e3887={'where':_0x3b44da[_0x50fc('0x41')]};return db[_0x50fc('0x2c')][_0x50fc('0x1d')](_0x2e3887)[_0x50fc('0x24')](function(_0xb204ef){_0xfbce23[_0x50fc('0x1d')]=_0xb204ef;if(_0x344c60['query'][_0x50fc('0x42')]){_0x3b44da[_0x50fc('0x43')]=[{'all':!![]}];}return db[_0x50fc('0x2c')]['findAll'](_0x3b44da);})[_0x50fc('0x24')](function(_0xc042eb){_0xfbce23['rows']=_0xc042eb;return _0xfbce23;})[_0x50fc('0x24')](respondWithFilteredResult(_0x39a44d,_0x3b44da))[_0x50fc('0x44')](handleError(_0x39a44d,null));};exports['show']=function(_0x40a72c,_0x5348a9){var _0x39118a={'raw':![],'where':{'id':_0x40a72c[_0x50fc('0x45')]['id']}},_0x31a082={};_0x31a082[_0x50fc('0x31')]=_[_0x50fc('0x46')](db[_0x50fc('0x2c')][_0x50fc('0x2d')]);_0x31a082[_0x50fc('0x34')]=_[_0x50fc('0x46')](_0x40a72c[_0x50fc('0x34')]);_0x31a082['filters']=_['intersection'](_0x31a082[_0x50fc('0x31')],_0x31a082[_0x50fc('0x34')]);_0x39118a[_0x50fc('0x38')]=_[_0x50fc('0x36')](_0x31a082['model'],qs[_0x50fc('0x37')](_0x40a72c[_0x50fc('0x34')][_0x50fc('0x37')]));_0x39118a[_0x50fc('0x38')]=_0x39118a['attributes'][_0x50fc('0x39')]?_0x39118a[_0x50fc('0x38')]:_0x31a082['model'];if(_0x40a72c[_0x50fc('0x34')][_0x50fc('0x42')]){_0x39118a[_0x50fc('0x43')]=[{'all':!![]}];}_0x39118a=_['merge']({},_0x39118a,_0x40a72c['options']);return db[_0x50fc('0x2c')]['find'](_0x39118a)[_0x50fc('0x24')](handleEntityNotFound(_0x5348a9,null))[_0x50fc('0x24')](respondWithResult(_0x5348a9,null))[_0x50fc('0x44')](handleError(_0x5348a9,null));};exports[_0x50fc('0x47')]=function(_0x27bba3,_0x339578){return db['VoiceRecording'][_0x50fc('0x47')](_0x27bba3['body'],{})[_0x50fc('0x24')](respondWithResult(_0x339578,0xc9))[_0x50fc('0x44')](handleError(_0x339578,null));};exports['update']=function(_0x4ab890,_0x282d36){if(_0x4ab890[_0x50fc('0x48')]['id']){delete _0x4ab890[_0x50fc('0x48')]['id'];}return db[_0x50fc('0x2c')]['find']({'where':{'id':_0x4ab890[_0x50fc('0x45')]['id']}})['then'](handleEntityNotFound(_0x282d36,null))[_0x50fc('0x24')](saveUpdates(_0x4ab890['body'],null))['then'](respondWithResult(_0x282d36,null))['catch'](handleError(_0x282d36,null));};exports[_0x50fc('0x49')]=function(_0x2cb24b,_0x7ce0c){return db[_0x50fc('0x2c')]['describe']()[_0x50fc('0x24')](respondWithResult(_0x7ce0c,null))[_0x50fc('0x44')](handleError(_0x7ce0c,null));};exports[_0x50fc('0x4a')]=function(_0x1d94c5,_0x3e47d7,_0x37339f){var _0x4e3764=require(_0x50fc('0x4b'));var _0x3b34e2=![];var _0x518682={};if(_0x1d94c5['query'][_0x50fc('0x2f')]&&_0x1d94c5['query']['type']===_0x50fc('0x4c')){_0x518682['uniqueid']=_0x1d94c5[_0x50fc('0x45')]['id'];}else{_0x518682['id']=_0x1d94c5[_0x50fc('0x45')]['id'];}return db[_0x50fc('0x2c')][_0x50fc('0x4d')]({'where':_0x518682,'attributes':['id','value'],'raw':!![]})[_0x50fc('0x24')](handleEntityNotFound(_0x3e47d7,null))['then'](function(_0x5bccaf){if(_0x5bccaf){var _0x1bc167=_0x5bccaf[_0x50fc('0x4e')];var _0x1af93a=util[_0x50fc('0x33')](_0x50fc('0x4f'),_0x1bc167);if(fs[_0x50fc('0x50')](_0x1af93a)){_0x3b34e2=!![];return _0x4e3764[_0x50fc('0x51')](_0x1af93a,_0x1bc167,config[_0x50fc('0x52')][_0x50fc('0x53')])['then'](function(){return _0x5bccaf;});}return _0x5bccaf;}})[_0x50fc('0x24')](function(_0x27f71a){if(_0x27f71a){var _0x3ea04a=_0x27f71a[_0x50fc('0x4e')];if(!fs[_0x50fc('0x50')](_0x3ea04a)){throw new db[(_0x50fc('0x54'))][(_0x50fc('0x55'))]('VoiceRecording\x20not\x20found');}if(_0x27f71a[_0x50fc('0x56')]){return _0x3e47d7[_0x50fc('0x4a')](_0x3ea04a,_0x27f71a[_0x50fc('0x56')]+path[_0x50fc('0x57')](_0x3ea04a),function(){if(_0x3b34e2){fs[_0x50fc('0x58')](_0x3ea04a);}});}else{return _0x3e47d7[_0x50fc('0x4a')](_0x3ea04a,function(_0x2c75c0){if(_0x3b34e2){fs[_0x50fc('0x58')](_0x3ea04a);}});}}})[_0x50fc('0x44')](function(_0x322d8c){if(_0x322d8c['message']==='VoiceRecording\x20not\x20found'){_0x3e47d7[_0x50fc('0x1a')](0x194)[_0x50fc('0x29')](_0x50fc('0x59'));}else{return handleError(_0x3e47d7,null);}});};exports['downloads']=function(_0x5ee4b8,_0x1f5c40,_0x37aaf0){var _0x2889ce=require(_0x50fc('0x4b'));var _0x12118d=![];var _0x1bd282={'$and':[db[_0x50fc('0x5a')][_0x50fc('0x41')](db[_0x50fc('0x5a')]['fn'](_0x50fc('0x5b'),db[_0x50fc('0x5a')][_0x50fc('0x5c')](_0x50fc('0x4c'))),_0x5ee4b8[_0x50fc('0x34')][_0x50fc('0x5d')])]};if(_0x5ee4b8[_0x50fc('0x34')][_0x50fc('0x2f')]&&_0x5ee4b8[_0x50fc('0x34')][_0x50fc('0x2f')]===_0x50fc('0x4c')){_0x1bd282[_0x50fc('0x5e')][_0x50fc('0x5f')]({'uniqueid':_0x5ee4b8[_0x50fc('0x45')]['id']});}else{_0x1bd282[_0x50fc('0x5e')][_0x50fc('0x5f')]({'id':_0x5ee4b8['params']['id']});}return db[_0x50fc('0x2c')][_0x50fc('0x4d')]({'where':_0x1bd282,'attributes':['id',_0x50fc('0x4e')],'raw':!![]})[_0x50fc('0x24')](handleEntityNotFound(_0x1f5c40,null))[_0x50fc('0x24')](function(_0x587040){if(_0x587040){var _0x352ba2=util[_0x50fc('0x33')](_0x50fc('0x4f'),_0x587040[_0x50fc('0x4e')]);if(fs['existsSync'](_0x352ba2)){_0x12118d=!![];return _0x2889ce[_0x50fc('0x51')](_0x352ba2,_0x587040['value'],config[_0x50fc('0x52')][_0x50fc('0x53')])['then'](function(){return _0x587040;});}return _0x587040;}})[_0x50fc('0x24')](function(_0x51e9fe){if(_0x51e9fe){if(!fs[_0x50fc('0x50')](_0x51e9fe[_0x50fc('0x4e')])){throw new db[(_0x50fc('0x54'))]['ValidationError'](_0x50fc('0x60'));}if(_0x51e9fe[_0x50fc('0x56')]){return _0x1f5c40[_0x50fc('0x4a')](_0x51e9fe['value'],_0x51e9fe[_0x50fc('0x56')]+path[_0x50fc('0x57')](_0x51e9fe[_0x50fc('0x4e')]),function(){if(_0x12118d){fs['unlink'](_0x51e9fe[_0x50fc('0x4e')]);}});}else{return _0x1f5c40[_0x50fc('0x4a')](_0x51e9fe[_0x50fc('0x4e')],function(_0x269152){if(_0x12118d){fs[_0x50fc('0x58')](_0x51e9fe[_0x50fc('0x4e')]);}});}}})[_0x50fc('0x44')](handleError(_0x1f5c40,null));};exports[_0x50fc('0x25')]=function(_0x1834dd,_0xc97c77){return db[_0x50fc('0x2c')][_0x50fc('0x4d')]({'where':{'id':_0x1834dd[_0x50fc('0x45')]['id']}})[_0x50fc('0x24')](function(_0x284481){if(_['isNil'](_0x284481)){throw new ReferenceError(_0x50fc('0x61'));}return _0x284481;})[_0x50fc('0x24')](function(_0x5cfb3a){var _0x4f8f7=_0x5cfb3a[_0x50fc('0x4e')];logger[_0x50fc('0x62')](_0x50fc('0x63'),_0x4f8f7);if(!_[_0x50fc('0x64')](_0x5cfb3a[_0x50fc('0x4e')])&&fs['existsSync'](_0x4f8f7)){logger[_0x50fc('0x62')](_0x50fc('0x65')+_0x4f8f7+_0x50fc('0x66'));fs[_0x50fc('0x67')](_0x4f8f7);}_0x4f8f7=_0x4f8f7+_0x50fc('0x68');if(!_[_0x50fc('0x64')](_0x5cfb3a[_0x50fc('0x4e')])&&fs[_0x50fc('0x50')](_0x4f8f7)){logger['info'](_0x50fc('0x65')+_0x4f8f7+_0x50fc('0x66'));fs[_0x50fc('0x67')](_0x4f8f7);}return _0x5cfb3a;})[_0x50fc('0x24')](function(_0x204886){if(!_0x204886)throw new InternalError();return _0x204886[_0x50fc('0x25')]();})[_0x50fc('0x24')](function(){_0xc97c77[_0x50fc('0x1a')](0xcc)[_0x50fc('0x26')]();})[_0x50fc('0x44')](handleError(_0xc97c77,null));};function getBucketslist(_0x1205d3,_0x195746,_0x50c995){return new Promise(function(_0x5e3f81,_0x484d2b){var _0x47f4d9=new AWS['S3']({'accessKeyId':_0x195746,'secretAccessKey':_0x1205d3,'region':_0x50c995});_0x47f4d9[_0x50fc('0x69')]({},function(_0x296eba,_0x22072b){if(_0x296eba){return _0x484d2b(_0x296eba);}else{return _0x5e3f81(_0x22072b);}});});}function createBucket(_0x3b3e04,_0x5c1299,_0x40c7a3,_0x1cbcb8){return new Promise(function(_0x204033,_0x408808){var _0x3063c8=new AWS['S3']({'accessKeyId':_0x5c1299,'secretAccessKey':_0x3b3e04,'region':_0x40c7a3});_0x3063c8[_0x50fc('0x6a')]({'Bucket':_0x1cbcb8},function(_0x2a06b9,_0x189b2f){if(_0x2a06b9){return _0x408808(_0x2a06b9);}else{return _0x204033(_0x189b2f);}});});}function uploadFile(_0x50aa51,_0x115f5b,_0x31de38,_0x116c5d,_0x2c35a2,_0x1123b3){return new Promise(function(_0x181b31,_0x18b81f){var _0x3dd043=new AWS['S3']({'accessKeyId':_0x115f5b,'secretAccessKey':_0x50aa51,'region':_0x31de38});_0x3dd043['upload']({'Bucket':_0x116c5d,'Key':_0x2c35a2,'Body':_0x1123b3},function(_0x2b78b4,_0x4c6bd4){if(_0x2b78b4){return _0x18b81f(_0x2b78b4);}else{return _0x181b31(_0x4c6bd4);}});});}function startTranscribe(_0x8d1b8f,_0x203829,_0x3ecf18,_0x5ec359,_0x1ac9d2,_0x13b12a){return new Promise(function(_0x325aa7,_0x403541){var _0x1090d6=new AWS[(_0x50fc('0x6b'))]({'accessKeyId':_0x203829,'secretAccessKey':_0x8d1b8f,'region':_0x3ecf18});_0x1090d6[_0x50fc('0x6c')]({'TranscriptionJobName':_0x5ec359,'LanguageCode':_0x1ac9d2,'Media':{'MediaFileUri':_0x13b12a}},function(_0x473375,_0x10fd6b){if(_0x473375){return _0x403541(_0x473375);}else{return _0x325aa7(_0x10fd6b);}});});}function transcribe(_0x37945a,_0xbc923e,_0x18eb5e,_0x58a68d,_0x7f2dc,_0x3d6a9b,_0x6acb4d){return new Promise(function(_0x4ca4b8,_0x2b0c81){var _0x385890={};logger['info'](util['format'](_0x50fc('0x6d'),_0x37945a,_0x7f2dc));return uploadFile(_0xbc923e,_0x18eb5e,_0x58a68d,_0x7f2dc,path['basename'](_0x3d6a9b),fs[_0x50fc('0x6e')](_0x3d6a9b))[_0x50fc('0x24')](function(_0x5d6401){logger[_0x50fc('0x62')](util[_0x50fc('0x33')](_0x50fc('0x6f'),_0x37945a,_0x7f2dc,_0x5d6401[_0x50fc('0x70')]));_0x385890['bucket']=_0x5d6401[_0x50fc('0x71')];_0x385890[_0x50fc('0x72')]=_0x5d6401['Location'];logger[_0x50fc('0x62')](util['format'](_0x50fc('0x73'),_0x37945a));return startTranscribe(_0xbc923e,_0x18eb5e,_0x58a68d,uuidv4(),_0x6acb4d,_0x5d6401['Location']);})[_0x50fc('0x24')](function(_0x29248c){logger['info'](util[_0x50fc('0x33')](_0x50fc('0x74'),_0x37945a,_0x29248c[_0x50fc('0x75')]['TranscriptionJobName']));_0x385890[_0x50fc('0x76')]=_0x29248c[_0x50fc('0x75')][_0x50fc('0x77')];_0x385890[_0x50fc('0x78')]=_0x29248c[_0x50fc('0x75')][_0x50fc('0x79')];return _0x4ca4b8(_0x385890);})[_0x50fc('0x44')](function(_0x2822ce){return _0x2b0c81(_0x2822ce);});});}exports[_0x50fc('0x7a')]=function(_0x4f96dd,_0x4928a9,_0x4ad369){var _0x34306e;var _0x416919;var _0x2b7807;var _0x263904=require(_0x50fc('0x4b'));return db[_0x50fc('0x2c')][_0x50fc('0x7b')]({'where':{'id':_0x4f96dd[_0x50fc('0x45')]['id']}})['then'](function(_0x14ff98){if(_0x14ff98){var _0x3e8461=util[_0x50fc('0x33')](_0x50fc('0x4f'),_0x14ff98[_0x50fc('0x4e')]);if(fs['existsSync'](_0x3e8461)){cypher=!![];return _0x263904[_0x50fc('0x51')](_0x3e8461,_0x14ff98[_0x50fc('0x4e')],config[_0x50fc('0x52')]['recording'])[_0x50fc('0x24')](function(){return _0x14ff98;});}return _0x14ff98;}})['then'](function(_0x53f351){if(!_0x53f351){throw new db[(_0x50fc('0x54'))]['ValidationError'](_0x50fc('0x7c'));}_0x416919=_0x53f351;return db[_0x50fc('0x7d')][_0x50fc('0x7b')]({'where':{'id':0x1}});})[_0x50fc('0x24')](handleEntityNotFound(_0x4928a9,null))[_0x50fc('0x24')](function(_0x47dd24){if(_0x47dd24){_0x34306e=_0x47dd24;if(!_0x34306e['transcribe']||!_0x34306e[_0x50fc('0x7e')]||!_0x34306e[_0x50fc('0x7f')]||!_0x34306e[_0x50fc('0x80')]||!_0x34306e['bucket']){throw new db[(_0x50fc('0x54'))]['ValidationError'](_0x50fc('0x81'));}if(_0x4f96dd['body'][_0x50fc('0x82')]&&(!_0x34306e['sentiment']||!_0x34306e[_0x50fc('0x83')]||!_0x34306e[_0x50fc('0x84')]||!_0x34306e[_0x50fc('0x80')]||!_0x34306e['bucket'])){throw new db[(_0x50fc('0x54'))][(_0x50fc('0x55'))]('Sentiment\x20Analysis\x20not\x20configured');}return db[_0x50fc('0x85')][_0x50fc('0x7b')]({'where':{'id':_0x34306e[_0x50fc('0x7e')]}});}})[_0x50fc('0x24')](function(_0x3bca5b){if(!_0x3bca5b){throw new db['Sequelize'][(_0x50fc('0x55'))]('Cloud\x20Provider\x20not\x20available');}if(!_0x3bca5b[_0x50fc('0x86')]||!_0x3bca5b['data2']){throw new db[(_0x50fc('0x54'))]['ValidationError'](_0x50fc('0x87'));}_0x2b7807=_0x3bca5b;return getBucketslist(_0x2b7807[_0x50fc('0x86')],_0x2b7807[_0x50fc('0x88')],_0x34306e[_0x50fc('0x7f')]);})[_0x50fc('0x24')](function(_0x1f240c){if(_0x1f240c&&_0x1f240c[_0x50fc('0x89')]){var _0x52522e=_[_0x50fc('0x4d')](_0x1f240c['Buckets'],function(_0x210df6){return _0x210df6['Name']===_0x34306e[_0x50fc('0x8a')];});if(!_0x52522e){logger[_0x50fc('0x62')](util[_0x50fc('0x33')](_0x50fc('0x8b'),_0x4f96dd[_0x50fc('0x45')]['id'],_0x34306e[_0x50fc('0x8a')]));return createBucket(_0x2b7807[_0x50fc('0x86')],_0x2b7807['data2'],_0x34306e['transcribeRegion'],_0x34306e[_0x50fc('0x8a')]);}logger[_0x50fc('0x62')](util[_0x50fc('0x33')](_0x50fc('0x8c'),_0x4f96dd[_0x50fc('0x45')]['id'],_0x34306e[_0x50fc('0x8a')]));return;}})[_0x50fc('0x24')](function(_0x4f916c){if(_0x416919[_0x50fc('0x78')]===_0x50fc('0x8d')){return transcribe(_0x4f96dd['params']['id'],_0x2b7807['data1'],_0x2b7807[_0x50fc('0x88')],_0x34306e['transcribeRegion'],_0x34306e['bucket'],_0x416919['value'],_0x34306e[_0x50fc('0x80')]);}else{logger['info'](util[_0x50fc('0x33')]('[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested',_0x4f96dd[_0x50fc('0x45')]['id']));return{'transcribeStatus':_0x50fc('0x8e')};}})[_0x50fc('0x24')](function(_0x4f4558){if(_0x4f4558){_0x4f4558[_0x50fc('0x8f')]=_0x4f96dd['body']['runSentiment'];return _0x416919[_0x50fc('0x90')](_0x4f4558);}})[_0x50fc('0x24')](respondWithResult(_0x4928a9,null))[_0x50fc('0x44')](handleError(_0x4928a9,null));};function writeFile(_0xae351b,_0x156d80){return new Promise(function(_0x4926b5,_0x44e7f7){fs[_0x50fc('0x91')](_0x156d80,_0xae351b,function(_0x13fc04,_0x4e825d){if(_0x13fc04){return _0x44e7f7(_0x13fc04);}else{return _0x4926b5(_0x4e825d);}});});}exports[_0x50fc('0x92')]=function(_0xf7265b,_0x145cac,_0x2ca733){return db[_0x50fc('0x2c')]['findOne']({'where':{'id':_0xf7265b[_0x50fc('0x45')]['id']}})['then'](handleEntityNotFound(_0x145cac))['then'](function(_0x42f3ce){if(_0x42f3ce&&_0x42f3ce[_0x50fc('0x93')]){var _0x48098e=_0x42f3ce[_0x50fc('0x93')];var _0x44ef14=config['root']+_0x50fc('0x94')+_0x42f3ce['id']+_0x50fc('0x95');if(fs[_0x50fc('0x50')](_0x44ef14)){return _0x44ef14;}return writeFile(_0x48098e,_0x44ef14)[_0x50fc('0x24')](function(){return _0x44ef14;});}else{throw new db[(_0x50fc('0x54'))][(_0x50fc('0x55'))]('Transcript\x20not\x20available');}})[_0x50fc('0x24')](function(_0x381d92){return _0x145cac['download'](_0x381d92);})[_0x50fc('0x44')](handleError(_0x145cac));};
\ No newline at end of file