Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / voiceMusicOnHold / voiceMusicOnHold.controller.js
index ae5de59..4247b5d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc5c5=['status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','then','UserProfileResource','destroy','stack','name','send','index','VoiceMusicOnHold','rawAttributes','fieldName','type','key','map','query','keys','attributes','intersection','fields','length','model','hasOwnProperty','nolimit','sort','where','filters','filter','VIRTUAL','merge','options','include','catch','show','find','update','body','sequelize','transaction','mode','files','directory','join','root','server/files/moh','create','mkdirSync','0777','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','readdirSync','unlinkSync','Sequelize','ValidationError','message','addSound','Sound','findOne','save_name','converted_format','createdAt','server/files/sounds/converted','format','%s.%s','basename','removeSound','id2','getSounds','order','pick','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus'];(function(_0x218994,_0x2cf487){var _0x3f350b=function(_0x2e2065){while(--_0x2e2065){_0x218994['push'](_0x218994['shift']());}};_0x3f350b(++_0x2cf487);}(_0xc5c5,0xc0));var _0x5c5c=function(_0x34c5a0,_0x32ee93){_0x34c5a0=_0x34c5a0-0x0;var _0x5a0494=_0xc5c5[_0x34c5a0];return _0x5a0494;};'use strict';var emlformat=require(_0x5c5c('0x0'));var rimraf=require(_0x5c5c('0x1'));var zipdir=require(_0x5c5c('0x2'));var jsonpatch=require(_0x5c5c('0x3'));var rp=require('request-promise');var moment=require(_0x5c5c('0x4'));var BPromise=require(_0x5c5c('0x5'));var Mustache=require(_0x5c5c('0x6'));var util=require(_0x5c5c('0x7'));var path=require(_0x5c5c('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x5c5c('0x9'));var _=require(_0x5c5c('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x5c5c('0xb'));var deskjs=require(_0x5c5c('0xc'));var toCsv=require('to-csv');var querystring=require(_0x5c5c('0xd'));var Papa=require(_0x5c5c('0xe'));var Redis=require('ioredis');var authService=require(_0x5c5c('0xf'));var qs=require(_0x5c5c('0x10'));var as=require(_0x5c5c('0x11'));var hardwareService=require(_0x5c5c('0x12'));var logger=require(_0x5c5c('0x13'))(_0x5c5c('0x14'));var utils=require(_0x5c5c('0x15'));var config=require(_0x5c5c('0x16'));var licenseUtil=require(_0x5c5c('0x17'));var db=require(_0x5c5c('0x18'))['db'];function respondWithStatusCode(_0x125fda,_0x54a666){_0x54a666=_0x54a666||0xcc;return function(_0x4c9c91){if(_0x4c9c91){return _0x125fda[_0x5c5c('0x19')](_0x54a666);}return _0x125fda[_0x5c5c('0x1a')](_0x54a666)['end']();};}function respondWithResult(_0x22a96b,_0x4e6841){_0x4e6841=_0x4e6841||0xc8;return function(_0x284f8f){if(_0x284f8f){return _0x22a96b[_0x5c5c('0x1a')](_0x4e6841)[_0x5c5c('0x1b')](_0x284f8f);}};}function respondWithFilteredResult(_0x5edbcc,_0x535aca){return function(_0x286c68){if(_0x286c68){var _0x970174=typeof _0x535aca[_0x5c5c('0x1c')]==='undefined'&&typeof _0x535aca['limit']===_0x5c5c('0x1d');var _0x207dfe=_0x286c68[_0x5c5c('0x1e')];var _0x450278=_0x970174?0x0:_0x535aca[_0x5c5c('0x1c')];var _0x53ce2c=_0x970174?_0x286c68[_0x5c5c('0x1e')]:_0x535aca['offset']+_0x535aca[_0x5c5c('0x1f')];var _0x36f218;if(_0x53ce2c>=_0x207dfe){_0x53ce2c=_0x207dfe;_0x36f218=0xc8;}else{_0x36f218=0xce;}_0x5edbcc[_0x5c5c('0x1a')](_0x36f218);return _0x5edbcc[_0x5c5c('0x20')](_0x5c5c('0x21'),_0x450278+'-'+_0x53ce2c+'/'+_0x207dfe)[_0x5c5c('0x1b')](_0x286c68);}return null;};}function patchUpdates(_0x48b42a){return function(_0x112e87){try{jsonpatch[_0x5c5c('0x22')](_0x112e87,_0x48b42a,!![]);}catch(_0x33c061){return BPromise[_0x5c5c('0x23')](_0x33c061);}return _0x112e87[_0x5c5c('0x24')]();};}function saveUpdates(_0x5edc1f,_0x5bd380){return function(_0x117768){if(_0x117768){return _0x117768['update'](_0x5edc1f)[_0x5c5c('0x25')](function(_0x248374){return _0x248374;});}return null;};}function removeEntity(_0x54ca90,_0xae13fe){return function(_0x134707){if(_0x134707){return _0x134707['destroy']()[_0x5c5c('0x25')](function(){var _0x278ebf=_0x134707['get']({'plain':!![]});var _0x423752='MusicOnHolds';return db[_0x5c5c('0x26')][_0x5c5c('0x27')]({'where':{'type':_0x423752,'resourceId':_0x278ebf['id']}})[_0x5c5c('0x25')](function(){return _0x134707;});})['then'](function(){_0x54ca90[_0x5c5c('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5a3207,_0x56b621){return function(_0x1b6244){if(!_0x1b6244){_0x5a3207[_0x5c5c('0x19')](0x194);}return _0x1b6244;};}function handleError(_0x33c5e6,_0x4ce31f){_0x4ce31f=_0x4ce31f||0x1f4;return function(_0x403c98){logger['error'](_0x403c98[_0x5c5c('0x28')]);if(_0x403c98[_0x5c5c('0x29')]){delete _0x403c98['name'];}_0x33c5e6[_0x5c5c('0x1a')](_0x4ce31f)[_0x5c5c('0x2a')](_0x403c98);};}exports[_0x5c5c('0x2b')]=function(_0x387eb4,_0x2db852){var _0x318ed3={},_0x46b9e3={},_0x2aeadc={'count':0x0,'rows':[]};var _0x1f8b7f=_['map'](db[_0x5c5c('0x2c')][_0x5c5c('0x2d')],function(_0x110674){return{'name':_0x110674[_0x5c5c('0x2e')],'type':_0x110674[_0x5c5c('0x2f')][_0x5c5c('0x30')]};});_0x46b9e3['model']=_[_0x5c5c('0x31')](_0x1f8b7f,_0x5c5c('0x29'));_0x46b9e3[_0x5c5c('0x32')]=_[_0x5c5c('0x33')](_0x387eb4[_0x5c5c('0x32')]);_0x46b9e3['filters']=_['intersection'](_0x46b9e3['model'],_0x46b9e3[_0x5c5c('0x32')]);_0x318ed3[_0x5c5c('0x34')]=_[_0x5c5c('0x35')](_0x46b9e3['model'],qs[_0x5c5c('0x36')](_0x387eb4['query'][_0x5c5c('0x36')]));_0x318ed3[_0x5c5c('0x34')]=_0x318ed3[_0x5c5c('0x34')][_0x5c5c('0x37')]?_0x318ed3[_0x5c5c('0x34')]:_0x46b9e3[_0x5c5c('0x38')];if(!_0x387eb4['query'][_0x5c5c('0x39')](_0x5c5c('0x3a'))){_0x318ed3['limit']=qs[_0x5c5c('0x1f')](_0x387eb4[_0x5c5c('0x32')][_0x5c5c('0x1f')]);_0x318ed3[_0x5c5c('0x1c')]=qs[_0x5c5c('0x1c')](_0x387eb4['query']['offset']);}_0x318ed3['order']=qs[_0x5c5c('0x3b')](_0x387eb4[_0x5c5c('0x32')]['sort']);delete _0x387eb4[_0x5c5c('0x32')][_0x5c5c('0x3b')];_0x318ed3[_0x5c5c('0x3c')]=qs[_0x5c5c('0x3d')](_['pick'](_0x387eb4['query'],_0x46b9e3['filters']),_0x1f8b7f);if(_0x387eb4[_0x5c5c('0x32')][_0x5c5c('0x3e')]){_0x318ed3[_0x5c5c('0x3c')]=_['merge'](_0x318ed3[_0x5c5c('0x3c')],{'$or':_[_0x5c5c('0x31')](_0x1f8b7f,function(_0x5673e0){if(_0x5673e0['type']!==_0x5c5c('0x3f')){var _0x573375={};_0x573375[_0x5673e0[_0x5c5c('0x29')]]={'$like':'%'+_0x387eb4['query'][_0x5c5c('0x3e')]+'%'};return _0x573375;}})});}_0x318ed3=_[_0x5c5c('0x40')]({},_0x318ed3,_0x387eb4[_0x5c5c('0x41')]);var _0x575afa={'where':_0x318ed3['where']};return db[_0x5c5c('0x2c')][_0x5c5c('0x1e')](_0x575afa)[_0x5c5c('0x25')](function(_0x922558){_0x2aeadc[_0x5c5c('0x1e')]=_0x922558;if(_0x387eb4[_0x5c5c('0x32')]['includeAll']){_0x318ed3[_0x5c5c('0x42')]=[{'all':!![]}];}return db[_0x5c5c('0x2c')]['findAll'](_0x318ed3);})['then'](function(_0x5bbcf5){_0x2aeadc['rows']=_0x5bbcf5;return _0x2aeadc;})['then'](respondWithFilteredResult(_0x2db852,_0x318ed3))[_0x5c5c('0x43')](handleError(_0x2db852,null));};exports[_0x5c5c('0x44')]=function(_0x21f623,_0x5d30fd){var _0x21bd03={'raw':![],'where':{'id':_0x21f623['params']['id']}},_0x20cc3c={};_0x20cc3c[_0x5c5c('0x38')]=_[_0x5c5c('0x33')](db[_0x5c5c('0x2c')][_0x5c5c('0x2d')]);_0x20cc3c['query']=_[_0x5c5c('0x33')](_0x21f623[_0x5c5c('0x32')]);_0x20cc3c['filters']=_['intersection'](_0x20cc3c[_0x5c5c('0x38')],_0x20cc3c[_0x5c5c('0x32')]);_0x21bd03[_0x5c5c('0x34')]=_[_0x5c5c('0x35')](_0x20cc3c[_0x5c5c('0x38')],qs[_0x5c5c('0x36')](_0x21f623['query'][_0x5c5c('0x36')]));_0x21bd03['attributes']=_0x21bd03['attributes'][_0x5c5c('0x37')]?_0x21bd03[_0x5c5c('0x34')]:_0x20cc3c[_0x5c5c('0x38')];if(_0x21f623['query']['includeAll']){_0x21bd03[_0x5c5c('0x42')]=[{'all':!![]}];}_0x21bd03=_['merge']({},_0x21bd03,_0x21f623[_0x5c5c('0x41')]);return db[_0x5c5c('0x2c')][_0x5c5c('0x45')](_0x21bd03)[_0x5c5c('0x25')](handleEntityNotFound(_0x5d30fd,null))[_0x5c5c('0x25')](respondWithResult(_0x5d30fd,null))['catch'](handleError(_0x5d30fd,null));};exports[_0x5c5c('0x46')]=function(_0x1b308c,_0xdb64df){if(_0x1b308c['body']['id']){delete _0x1b308c[_0x5c5c('0x47')]['id'];}return db[_0x5c5c('0x2c')][_0x5c5c('0x45')]({'where':{'id':_0x1b308c['params']['id']}})[_0x5c5c('0x25')](handleEntityNotFound(_0xdb64df,null))['then'](saveUpdates(_0x1b308c[_0x5c5c('0x47')],null))['then'](respondWithResult(_0xdb64df,null))[_0x5c5c('0x43')](handleError(_0xdb64df,null));};exports['create']=function(_0x1e7115,_0x5f089c,_0xc384ae){return db[_0x5c5c('0x48')][_0x5c5c('0x49')](function(_0x40cb0f){if(_0x1e7115['body'][_0x5c5c('0x4a')]===_0x5c5c('0x4b')){_0x1e7115['body'][_0x5c5c('0x4c')]=path[_0x5c5c('0x4d')](config[_0x5c5c('0x4e')],_0x5c5c('0x4f'),_0x1e7115[_0x5c5c('0x47')]['name']);}return db['VoiceMusicOnHold'][_0x5c5c('0x50')](_0x1e7115[_0x5c5c('0x47')],{'transaction':_0x40cb0f})[_0x5c5c('0x25')](function(_0x5de2e9){if(_0x1e7115[_0x5c5c('0x47')][_0x5c5c('0x4a')]===_0x5c5c('0x4b')){fs[_0x5c5c('0x51')](_0x5de2e9[_0x5c5c('0x4c')],parseInt(_0x5c5c('0x52'),0x8));}var _0x4acc44=_0x1e7115['user'][_0x5c5c('0x53')]({'plain':!![]});if(!_0x4acc44)throw new Error(_0x5c5c('0x54'));if(_0x4acc44[_0x5c5c('0x55')]==='user'){var _0x4cc7d8=_0x5de2e9['get']({'plain':!![]});return db['UserProfileSection'][_0x5c5c('0x45')]({'where':{'name':'MusicOnHolds','userProfileId':_0x4acc44[_0x5c5c('0x56')]},'raw':!![]})[_0x5c5c('0x25')](function(_0x15f51b){if(_0x15f51b&&_0x15f51b['autoAssociation']===0x0){return db[_0x5c5c('0x26')][_0x5c5c('0x50')]({'name':_0x4cc7d8[_0x5c5c('0x29')],'resourceId':_0x4cc7d8['id'],'type':_0x15f51b[_0x5c5c('0x29')],'sectionId':_0x15f51b['id']},{})[_0x5c5c('0x25')](function(){return _0x5de2e9;});}else{return _0x5de2e9;}})[_0x5c5c('0x43')](function(_0x3e5c34){logger['error'](_0x5c5c('0x57'),_0x3e5c34);});}return _0x5de2e9;});})[_0x5c5c('0x25')](respondWithResult(_0x5f089c,0xc9))['catch'](handleError(_0x5f089c,null));};exports[_0x5c5c('0x27')]=function(_0x4b54bd,_0x4ede17,_0x49d12c){var _0x27cd37;return db['VoiceMusicOnHold']['find']({'where':{'id':_0x4b54bd[_0x5c5c('0x58')]['id']}})[_0x5c5c('0x25')](function(_0x50a91b){if(_0x50a91b){return db['sequelize']['transaction'](function(_0x495a58){return _0x50a91b['destroy']({'transaction':_0x495a58,'raw':!![]})['then'](function(_0x389001){if(_0x389001[_0x5c5c('0x4c')]){fs[_0x5c5c('0x59')](_0x389001['directory'])['forEach'](function(_0x3e3878){fs[_0x5c5c('0x5a')](path['join'](_0x389001[_0x5c5c('0x4c')],_0x3e3878));});fs['rmdirSync'](_0x389001[_0x5c5c('0x4c')]);}return _0x389001;});})[_0x5c5c('0x43')](function(_0x1a1880){throw new db[(_0x5c5c('0x5b'))][(_0x5c5c('0x5c'))](_0x1a1880[_0x5c5c('0x5d')]);});}})['then'](handleEntityNotFound(_0x4ede17,null))[_0x5c5c('0x25')](removeEntity(_0x4ede17,null))['catch'](handleError(_0x4ede17,null));};exports[_0x5c5c('0x5e')]=function(_0x49aa6a,_0xfc1910,_0x45323f){return db['sequelize']['transaction'](function(_0x99a5a0){var _0x1e5d99;return db[_0x5c5c('0x2c')][_0x5c5c('0x45')]({'where':{'id':_0x49aa6a[_0x5c5c('0x58')]['id']}})[_0x5c5c('0x25')](function(_0x4485be){if(_0x4485be){_0x1e5d99=_0x4485be;return _0x4485be[_0x5c5c('0x5e')](_0x49aa6a[_0x5c5c('0x47')]['id'],{'transaction':_0x99a5a0});}})[_0x5c5c('0x25')](function(_0x1ef55d){if(_0x1ef55d){return db[_0x5c5c('0x5f')][_0x5c5c('0x60')]({'where':{'id':_0x49aa6a[_0x5c5c('0x47')]['id']},'attributes':['id',_0x5c5c('0x29'),_0x5c5c('0x61'),_0x5c5c('0x62'),_0x5c5c('0x63')],'raw':!![]});}})[_0x5c5c('0x25')](function(_0x293a99){if(_0x293a99){var _0x5ba597=path[_0x5c5c('0x4d')](config[_0x5c5c('0x4e')],_0x5c5c('0x64'),util[_0x5c5c('0x65')](_0x5c5c('0x66'),path[_0x5c5c('0x67')](_0x293a99[_0x5c5c('0x61')],path['extname'](_0x293a99['save_name'])),_0x293a99[_0x5c5c('0x62')]));var _0x160e06=path[_0x5c5c('0x4d')](config[_0x5c5c('0x4e')],_0x5c5c('0x4f'),_0x1e5d99[_0x5c5c('0x29')],util[_0x5c5c('0x65')]('%s.%s',_0x293a99['name'],_0x293a99[_0x5c5c('0x62')]));fs['symlinkSync'](_0x5ba597,_0x160e06);return _0x293a99;}})[_0x5c5c('0x43')](function(_0x3a5327){throw new db[(_0x5c5c('0x5b'))][(_0x5c5c('0x5c'))](_0x3a5327[_0x5c5c('0x5d')]);});})[_0x5c5c('0x25')](handleEntityNotFound(_0xfc1910,null))['then'](respondWithResult(_0xfc1910,0xc9))[_0x5c5c('0x43')](handleError(_0xfc1910,null));};exports[_0x5c5c('0x68')]=function(_0x5efe65,_0x41a0ac,_0x4a69c2){return db[_0x5c5c('0x48')][_0x5c5c('0x49')](function(_0x181166){var _0x43d275;return db[_0x5c5c('0x2c')]['findOne']({'where':{'id':_0x5efe65['params']['id']}})[_0x5c5c('0x25')](handleEntityNotFound(_0x41a0ac,null))[_0x5c5c('0x25')](function(_0x1226a9){if(_0x1226a9){_0x43d275=_0x1226a9;return _0x1226a9[_0x5c5c('0x68')](_0x5efe65[_0x5c5c('0x58')][_0x5c5c('0x69')]);}})['then'](function(_0x2e913c){if(_0x2e913c){return db[_0x5c5c('0x5f')][_0x5c5c('0x60')]({'where':{'id':_0x5efe65[_0x5c5c('0x58')][_0x5c5c('0x69')]},'attributes':['id','name',_0x5c5c('0x61'),'converted_format',_0x5c5c('0x63')],'raw':!![]});}})['then'](function(_0x3224e1){if(_0x3224e1){fs[_0x5c5c('0x5a')](path[_0x5c5c('0x4d')](_0x43d275[_0x5c5c('0x4c')],util['format'](_0x5c5c('0x66'),_0x3224e1[_0x5c5c('0x29')],_0x3224e1[_0x5c5c('0x62')])));return _0x3224e1;}})[_0x5c5c('0x43')](function(_0x40b033){throw new db[(_0x5c5c('0x5b'))][(_0x5c5c('0x5c'))](_0x40b033[_0x5c5c('0x5d')]);});})['then'](handleEntityNotFound(_0x41a0ac,null))['then'](respondWithStatusCode(_0x41a0ac,0xcc))[_0x5c5c('0x43')](handleError(_0x41a0ac,null));};exports[_0x5c5c('0x6a')]=function(_0x115ec4,_0x3f392a,_0x55b84b){var _0x210694={};var _0x2f7b9={};var _0x570ad6;var _0x13a730;return db[_0x5c5c('0x2c')]['findOne']({'where':{'id':_0x115ec4[_0x5c5c('0x58')]['id']}})['then'](handleEntityNotFound(_0x3f392a,null))[_0x5c5c('0x25')](function(_0x31bdcd){if(_0x31bdcd){_0x570ad6=_0x31bdcd;_0x2f7b9[_0x5c5c('0x38')]=_[_0x5c5c('0x33')](db['Sound'][_0x5c5c('0x2d')]);_0x2f7b9[_0x5c5c('0x32')]=_[_0x5c5c('0x33')](_0x115ec4[_0x5c5c('0x32')]);_0x2f7b9['filters']=_[_0x5c5c('0x35')](_0x2f7b9['model'],_0x2f7b9[_0x5c5c('0x32')]);_0x210694[_0x5c5c('0x34')]=_['intersection'](_0x2f7b9[_0x5c5c('0x38')],qs['fields'](_0x115ec4['query'][_0x5c5c('0x36')]));_0x210694[_0x5c5c('0x34')]=_0x210694[_0x5c5c('0x34')][_0x5c5c('0x37')]?_0x210694[_0x5c5c('0x34')]:_0x2f7b9[_0x5c5c('0x38')];_0x210694[_0x5c5c('0x6b')]=qs[_0x5c5c('0x3b')](_0x115ec4[_0x5c5c('0x32')][_0x5c5c('0x3b')]);_0x210694['where']=qs[_0x5c5c('0x3d')](_[_0x5c5c('0x6c')](_0x115ec4[_0x5c5c('0x32')],_0x2f7b9['filters']));if(_0x115ec4['query'][_0x5c5c('0x3e')]){_0x210694[_0x5c5c('0x3c')]=_[_0x5c5c('0x40')](_0x210694[_0x5c5c('0x3c')],{'$or':_[_0x5c5c('0x31')](_0x210694[_0x5c5c('0x34')],function(_0x511996){var _0x324617={};_0x324617[_0x511996]={'$like':'%'+_0x115ec4['query']['filter']+'%'};return _0x324617;})});}_0x210694=_[_0x5c5c('0x40')]({},_0x210694,_0x115ec4['options']);return _0x570ad6[_0x5c5c('0x6a')](_0x210694);}})['then'](function(_0x7d68a5){if(_0x7d68a5){_0x13a730=_0x7d68a5['length'];if(!_0x115ec4[_0x5c5c('0x32')][_0x5c5c('0x39')](_0x5c5c('0x3a'))){_0x210694[_0x5c5c('0x1f')]=qs['limit'](_0x115ec4['query'][_0x5c5c('0x1f')]);_0x210694['offset']=qs['offset'](_0x115ec4[_0x5c5c('0x32')]['offset']);}return _0x570ad6[_0x5c5c('0x6a')](_0x210694);}})['then'](function(_0x25fcfc){if(_0x25fcfc){return _0x25fcfc?{'count':_0x13a730,'rows':_0x25fcfc}:null;}})['then'](respondWithResult(_0x3f392a,null))[_0x5c5c('0x43')](handleError(_0x3f392a,null));};
\ No newline at end of file
+var _0x9b21=['crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','set','apply','reject','save','destroy','then','get','MusicOnHolds','UserProfileResource','error','name','send','index','VoiceMusicOnHold','rawAttributes','fieldName','key','map','keys','query','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filters','pick','filter','merge','type','VIRTUAL','options','include','rows','catch','show','includeAll','find','update','body','create','sequelize','mode','directory','join','root','server/files/moh','files','mkdirSync','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','params','transaction','forEach','rmdirSync','Sequelize','ValidationError','message','addSound','findOne','save_name','converted_format','createdAt','server/files/sounds/converted','format','%s.%s','extname','symlinkSync','removeSound','id2','Sound','unlinkSync','getSounds','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','squel'];(function(_0x1deb03,_0xd05ad8){var _0x189fe7=function(_0x321225){while(--_0x321225){_0x1deb03['push'](_0x1deb03['shift']());}};_0x189fe7(++_0xd05ad8);}(_0x9b21,0x1bf));var _0x19b2=function(_0x45c860,_0x7c441c){_0x45c860=_0x45c860-0x0;var _0x1ef758=_0x9b21[_0x45c860];return _0x1ef758;};'use strict';var emlformat=require(_0x19b2('0x0'));var rimraf=require(_0x19b2('0x1'));var zipdir=require(_0x19b2('0x2'));var jsonpatch=require(_0x19b2('0x3'));var rp=require(_0x19b2('0x4'));var moment=require(_0x19b2('0x5'));var BPromise=require(_0x19b2('0x6'));var Mustache=require(_0x19b2('0x7'));var util=require('util');var path=require(_0x19b2('0x8'));var sox=require(_0x19b2('0x9'));var csv=require(_0x19b2('0xa'));var ejs=require(_0x19b2('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x19b2('0xc'));var crypto=require(_0x19b2('0xd'));var jsforce=require(_0x19b2('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x19b2('0xa'));var querystring=require(_0x19b2('0xf'));var Papa=require(_0x19b2('0x10'));var Redis=require('ioredis');var authService=require(_0x19b2('0x11'));var qs=require(_0x19b2('0x12'));var as=require(_0x19b2('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x19b2('0x14'))(_0x19b2('0x15'));var utils=require(_0x19b2('0x16'));var config=require(_0x19b2('0x17'));var licenseUtil=require(_0x19b2('0x18'));var db=require(_0x19b2('0x19'))['db'];function respondWithStatusCode(_0x4f070e,_0x1cbad8){_0x1cbad8=_0x1cbad8||0xcc;return function(_0x42e470){if(_0x42e470){return _0x4f070e[_0x19b2('0x1a')](_0x1cbad8);}return _0x4f070e['status'](_0x1cbad8)[_0x19b2('0x1b')]();};}function respondWithResult(_0xd88076,_0x18e4c5){_0x18e4c5=_0x18e4c5||0xc8;return function(_0x505b3b){if(_0x505b3b){return _0xd88076[_0x19b2('0x1c')](_0x18e4c5)[_0x19b2('0x1d')](_0x505b3b);}};}function respondWithFilteredResult(_0x4599ff,_0xacbaf){return function(_0x107915){if(_0x107915){var _0x4f5918=typeof _0xacbaf[_0x19b2('0x1e')]===_0x19b2('0x1f')&&typeof _0xacbaf['limit']==='undefined';var _0x3c6a7f=_0x107915['count'];var _0x546f56=_0x4f5918?0x0:_0xacbaf['offset'];var _0x169034=_0x4f5918?_0x107915[_0x19b2('0x20')]:_0xacbaf[_0x19b2('0x1e')]+_0xacbaf['limit'];var _0x4ef3eb;if(_0x169034>=_0x3c6a7f){_0x169034=_0x3c6a7f;_0x4ef3eb=0xc8;}else{_0x4ef3eb=0xce;}_0x4599ff[_0x19b2('0x1c')](_0x4ef3eb);return _0x4599ff[_0x19b2('0x21')]('Content-Range',_0x546f56+'-'+_0x169034+'/'+_0x3c6a7f)[_0x19b2('0x1d')](_0x107915);}return null;};}function patchUpdates(_0xa70ce2){return function(_0x188c65){try{jsonpatch[_0x19b2('0x22')](_0x188c65,_0xa70ce2,!![]);}catch(_0x3b93f1){return BPromise[_0x19b2('0x23')](_0x3b93f1);}return _0x188c65[_0x19b2('0x24')]();};}function saveUpdates(_0x4c584b,_0x536208){return function(_0x30add1){if(_0x30add1){return _0x30add1['update'](_0x4c584b)['then'](function(_0x214e15){return _0x214e15;});}return null;};}function removeEntity(_0x306eee,_0x1c0213){return function(_0x47bd4d){if(_0x47bd4d){return _0x47bd4d[_0x19b2('0x25')]()[_0x19b2('0x26')](function(){var _0x1c1bbe=_0x47bd4d[_0x19b2('0x27')]({'plain':!![]});var _0x1aa2d5=_0x19b2('0x28');return db[_0x19b2('0x29')]['destroy']({'where':{'type':_0x1aa2d5,'resourceId':_0x1c1bbe['id']}})[_0x19b2('0x26')](function(){return _0x47bd4d;});})[_0x19b2('0x26')](function(){_0x306eee['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x1f2de1,_0x2d3fdb){return function(_0x150901){if(!_0x150901){_0x1f2de1[_0x19b2('0x1a')](0x194);}return _0x150901;};}function handleError(_0x1a4dc9,_0x1c35ff){_0x1c35ff=_0x1c35ff||0x1f4;return function(_0x4d66ea){logger[_0x19b2('0x2a')](_0x4d66ea['stack']);if(_0x4d66ea[_0x19b2('0x2b')]){delete _0x4d66ea['name'];}_0x1a4dc9[_0x19b2('0x1c')](_0x1c35ff)[_0x19b2('0x2c')](_0x4d66ea);};}exports[_0x19b2('0x2d')]=function(_0x373da1,_0x2b3a92){var _0x4b23a8={},_0x1a1586={},_0x40bef7={'count':0x0,'rows':[]};var _0xeb1411=_['map'](db[_0x19b2('0x2e')][_0x19b2('0x2f')],function(_0x2897eb){return{'name':_0x2897eb[_0x19b2('0x30')],'type':_0x2897eb['type'][_0x19b2('0x31')]};});_0x1a1586['model']=_[_0x19b2('0x32')](_0xeb1411,_0x19b2('0x2b'));_0x1a1586['query']=_[_0x19b2('0x33')](_0x373da1[_0x19b2('0x34')]);_0x1a1586['filters']=_[_0x19b2('0x35')](_0x1a1586[_0x19b2('0x36')],_0x1a1586[_0x19b2('0x34')]);_0x4b23a8[_0x19b2('0x37')]=_[_0x19b2('0x35')](_0x1a1586[_0x19b2('0x36')],qs[_0x19b2('0x38')](_0x373da1[_0x19b2('0x34')][_0x19b2('0x38')]));_0x4b23a8[_0x19b2('0x37')]=_0x4b23a8[_0x19b2('0x37')][_0x19b2('0x39')]?_0x4b23a8[_0x19b2('0x37')]:_0x1a1586[_0x19b2('0x36')];if(!_0x373da1['query'][_0x19b2('0x3a')](_0x19b2('0x3b'))){_0x4b23a8[_0x19b2('0x3c')]=qs['limit'](_0x373da1['query'][_0x19b2('0x3c')]);_0x4b23a8['offset']=qs[_0x19b2('0x1e')](_0x373da1[_0x19b2('0x34')]['offset']);}_0x4b23a8[_0x19b2('0x3d')]=qs[_0x19b2('0x3e')](_0x373da1[_0x19b2('0x34')]['sort']);delete _0x373da1['query'][_0x19b2('0x3e')];_0x4b23a8[_0x19b2('0x3f')]=qs[_0x19b2('0x40')](_[_0x19b2('0x41')](_0x373da1[_0x19b2('0x34')],_0x1a1586[_0x19b2('0x40')]),_0xeb1411);if(_0x373da1[_0x19b2('0x34')][_0x19b2('0x42')]){_0x4b23a8['where']=_[_0x19b2('0x43')](_0x4b23a8[_0x19b2('0x3f')],{'$or':_[_0x19b2('0x32')](_0xeb1411,function(_0x2751c6){if(_0x2751c6[_0x19b2('0x44')]!==_0x19b2('0x45')){var _0x192507={};_0x192507[_0x2751c6[_0x19b2('0x2b')]]={'$like':'%'+_0x373da1[_0x19b2('0x34')]['filter']+'%'};return _0x192507;}})});}_0x4b23a8=_[_0x19b2('0x43')]({},_0x4b23a8,_0x373da1[_0x19b2('0x46')]);var _0x223768={'where':_0x4b23a8[_0x19b2('0x3f')]};return db['VoiceMusicOnHold'][_0x19b2('0x20')](_0x223768)[_0x19b2('0x26')](function(_0x3ae3e3){_0x40bef7[_0x19b2('0x20')]=_0x3ae3e3;if(_0x373da1[_0x19b2('0x34')]['includeAll']){_0x4b23a8[_0x19b2('0x47')]=[{'all':!![]}];}return db['VoiceMusicOnHold']['findAll'](_0x4b23a8);})[_0x19b2('0x26')](function(_0x51bfd8){_0x40bef7[_0x19b2('0x48')]=_0x51bfd8;return _0x40bef7;})[_0x19b2('0x26')](respondWithFilteredResult(_0x2b3a92,_0x4b23a8))[_0x19b2('0x49')](handleError(_0x2b3a92,null));};exports[_0x19b2('0x4a')]=function(_0x6e15ad,_0x17446d){var _0x316112={'raw':![],'where':{'id':_0x6e15ad['params']['id']}},_0x44b521={};_0x44b521[_0x19b2('0x36')]=_[_0x19b2('0x33')](db['VoiceMusicOnHold']['rawAttributes']);_0x44b521[_0x19b2('0x34')]=_[_0x19b2('0x33')](_0x6e15ad['query']);_0x44b521[_0x19b2('0x40')]=_[_0x19b2('0x35')](_0x44b521[_0x19b2('0x36')],_0x44b521[_0x19b2('0x34')]);_0x316112[_0x19b2('0x37')]=_[_0x19b2('0x35')](_0x44b521[_0x19b2('0x36')],qs[_0x19b2('0x38')](_0x6e15ad['query']['fields']));_0x316112[_0x19b2('0x37')]=_0x316112[_0x19b2('0x37')][_0x19b2('0x39')]?_0x316112['attributes']:_0x44b521[_0x19b2('0x36')];if(_0x6e15ad[_0x19b2('0x34')][_0x19b2('0x4b')]){_0x316112[_0x19b2('0x47')]=[{'all':!![]}];}_0x316112=_[_0x19b2('0x43')]({},_0x316112,_0x6e15ad[_0x19b2('0x46')]);return db['VoiceMusicOnHold'][_0x19b2('0x4c')](_0x316112)[_0x19b2('0x26')](handleEntityNotFound(_0x17446d,null))[_0x19b2('0x26')](respondWithResult(_0x17446d,null))[_0x19b2('0x49')](handleError(_0x17446d,null));};exports[_0x19b2('0x4d')]=function(_0x17e929,_0x22b358){if(_0x17e929[_0x19b2('0x4e')]['id']){delete _0x17e929[_0x19b2('0x4e')]['id'];}return db[_0x19b2('0x2e')]['find']({'where':{'id':_0x17e929['params']['id']}})['then'](handleEntityNotFound(_0x22b358,null))[_0x19b2('0x26')](saveUpdates(_0x17e929['body'],null))[_0x19b2('0x26')](respondWithResult(_0x22b358,null))['catch'](handleError(_0x22b358,null));};exports[_0x19b2('0x4f')]=function(_0x367894,_0x441a06,_0x479f5e){return db[_0x19b2('0x50')]['transaction'](function(_0x5d0a1a){if(_0x367894[_0x19b2('0x4e')][_0x19b2('0x51')]==='files'){_0x367894[_0x19b2('0x4e')][_0x19b2('0x52')]=path[_0x19b2('0x53')](config[_0x19b2('0x54')],_0x19b2('0x55'),_0x367894['body'][_0x19b2('0x2b')]);}return db[_0x19b2('0x2e')][_0x19b2('0x4f')](_0x367894['body'],{'transaction':_0x5d0a1a})[_0x19b2('0x26')](function(_0x3e59d6){if(_0x367894[_0x19b2('0x4e')]['mode']===_0x19b2('0x56')){fs[_0x19b2('0x57')](_0x3e59d6[_0x19b2('0x52')],parseInt('0777',0x8));}var _0x324080=_0x367894[_0x19b2('0x58')][_0x19b2('0x27')]({'plain':!![]});if(!_0x324080)throw new Error(_0x19b2('0x59'));if(_0x324080[_0x19b2('0x5a')]===_0x19b2('0x58')){var _0x5e47ec=_0x3e59d6[_0x19b2('0x27')]({'plain':!![]});return db['UserProfileSection'][_0x19b2('0x4c')]({'where':{'name':_0x19b2('0x28'),'userProfileId':_0x324080[_0x19b2('0x5b')]},'raw':!![]})['then'](function(_0x4dfb38){if(_0x4dfb38&&_0x4dfb38[_0x19b2('0x5c')]===0x0){return db[_0x19b2('0x29')][_0x19b2('0x4f')]({'name':_0x5e47ec['name'],'resourceId':_0x5e47ec['id'],'type':_0x4dfb38[_0x19b2('0x2b')],'sectionId':_0x4dfb38['id']},{})[_0x19b2('0x26')](function(){return _0x3e59d6;});}else{return _0x3e59d6;}})['catch'](function(_0x19b7cd){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x19b7cd);});}return _0x3e59d6;});})[_0x19b2('0x26')](respondWithResult(_0x441a06,0xc9))[_0x19b2('0x49')](handleError(_0x441a06,null));};exports[_0x19b2('0x25')]=function(_0x19df37,_0x367b35,_0x546829){var _0x7cf6d1;return db[_0x19b2('0x2e')]['find']({'where':{'id':_0x19df37[_0x19b2('0x5d')]['id']}})[_0x19b2('0x26')](function(_0x4d4c73){if(_0x4d4c73){return db[_0x19b2('0x50')][_0x19b2('0x5e')](function(_0x468243){return _0x4d4c73['destroy']({'transaction':_0x468243,'raw':!![]})['then'](function(_0x25f8b3){if(_0x25f8b3[_0x19b2('0x52')]){fs['readdirSync'](_0x25f8b3[_0x19b2('0x52')])[_0x19b2('0x5f')](function(_0x2c6801){fs['unlinkSync'](path[_0x19b2('0x53')](_0x25f8b3['directory'],_0x2c6801));});fs[_0x19b2('0x60')](_0x25f8b3[_0x19b2('0x52')]);}return _0x25f8b3;});})[_0x19b2('0x49')](function(_0x27d16d){throw new db[(_0x19b2('0x61'))][(_0x19b2('0x62'))](_0x27d16d[_0x19b2('0x63')]);});}})['then'](handleEntityNotFound(_0x367b35,null))[_0x19b2('0x26')](removeEntity(_0x367b35,null))[_0x19b2('0x49')](handleError(_0x367b35,null));};exports[_0x19b2('0x64')]=function(_0x449be1,_0x4db041,_0x4d0b0a){return db[_0x19b2('0x50')][_0x19b2('0x5e')](function(_0x186be8){var _0x1652de;return db[_0x19b2('0x2e')][_0x19b2('0x4c')]({'where':{'id':_0x449be1[_0x19b2('0x5d')]['id']}})[_0x19b2('0x26')](function(_0x1ffe36){if(_0x1ffe36){_0x1652de=_0x1ffe36;return _0x1ffe36[_0x19b2('0x64')](_0x449be1[_0x19b2('0x4e')]['id'],{'transaction':_0x186be8});}})[_0x19b2('0x26')](function(_0x49755d){if(_0x49755d){return db['Sound'][_0x19b2('0x65')]({'where':{'id':_0x449be1[_0x19b2('0x4e')]['id']},'attributes':['id','name',_0x19b2('0x66'),_0x19b2('0x67'),_0x19b2('0x68')],'raw':!![]});}})[_0x19b2('0x26')](function(_0x444299){if(_0x444299){var _0x4b4baf=path[_0x19b2('0x53')](config['root'],_0x19b2('0x69'),util[_0x19b2('0x6a')](_0x19b2('0x6b'),path['basename'](_0x444299[_0x19b2('0x66')],path[_0x19b2('0x6c')](_0x444299[_0x19b2('0x66')])),_0x444299[_0x19b2('0x67')]));var _0x1d8e1e=path[_0x19b2('0x53')](config['root'],_0x19b2('0x55'),_0x1652de[_0x19b2('0x2b')],util[_0x19b2('0x6a')](_0x19b2('0x6b'),_0x444299['name'],_0x444299['converted_format']));fs[_0x19b2('0x6d')](_0x4b4baf,_0x1d8e1e);return _0x444299;}})[_0x19b2('0x49')](function(_0x590581){throw new db['Sequelize'][(_0x19b2('0x62'))](_0x590581[_0x19b2('0x63')]);});})[_0x19b2('0x26')](handleEntityNotFound(_0x4db041,null))[_0x19b2('0x26')](respondWithResult(_0x4db041,0xc9))['catch'](handleError(_0x4db041,null));};exports['removeSound']=function(_0x4961e1,_0x12d4ff,_0x569126){return db[_0x19b2('0x50')][_0x19b2('0x5e')](function(_0x3f4437){var _0xfbf960;return db[_0x19b2('0x2e')][_0x19b2('0x65')]({'where':{'id':_0x4961e1['params']['id']}})['then'](handleEntityNotFound(_0x12d4ff,null))[_0x19b2('0x26')](function(_0x1d53d9){if(_0x1d53d9){_0xfbf960=_0x1d53d9;return _0x1d53d9[_0x19b2('0x6e')](_0x4961e1[_0x19b2('0x5d')][_0x19b2('0x6f')]);}})[_0x19b2('0x26')](function(_0x37e12e){if(_0x37e12e){return db[_0x19b2('0x70')]['findOne']({'where':{'id':_0x4961e1[_0x19b2('0x5d')][_0x19b2('0x6f')]},'attributes':['id','name',_0x19b2('0x66'),_0x19b2('0x67'),'createdAt'],'raw':!![]});}})['then'](function(_0x3da7e3){if(_0x3da7e3){fs[_0x19b2('0x71')](path['join'](_0xfbf960[_0x19b2('0x52')],util[_0x19b2('0x6a')](_0x19b2('0x6b'),_0x3da7e3[_0x19b2('0x2b')],_0x3da7e3[_0x19b2('0x67')])));return _0x3da7e3;}})['catch'](function(_0x382bd2){throw new db[(_0x19b2('0x61'))][(_0x19b2('0x62'))](_0x382bd2[_0x19b2('0x63')]);});})[_0x19b2('0x26')](handleEntityNotFound(_0x12d4ff,null))['then'](respondWithStatusCode(_0x12d4ff,0xcc))[_0x19b2('0x49')](handleError(_0x12d4ff,null));};exports['getSounds']=function(_0x977ae4,_0x37ca3a,_0x297969){var _0x48f78c={};var _0x2811e5={};var _0x7c7bf;var _0x381bb0;return db['VoiceMusicOnHold'][_0x19b2('0x65')]({'where':{'id':_0x977ae4[_0x19b2('0x5d')]['id']}})['then'](handleEntityNotFound(_0x37ca3a,null))[_0x19b2('0x26')](function(_0x2f0746){if(_0x2f0746){_0x7c7bf=_0x2f0746;_0x2811e5[_0x19b2('0x36')]=_['keys'](db[_0x19b2('0x70')][_0x19b2('0x2f')]);_0x2811e5[_0x19b2('0x34')]=_[_0x19b2('0x33')](_0x977ae4[_0x19b2('0x34')]);_0x2811e5[_0x19b2('0x40')]=_['intersection'](_0x2811e5[_0x19b2('0x36')],_0x2811e5['query']);_0x48f78c['attributes']=_[_0x19b2('0x35')](_0x2811e5['model'],qs[_0x19b2('0x38')](_0x977ae4[_0x19b2('0x34')][_0x19b2('0x38')]));_0x48f78c[_0x19b2('0x37')]=_0x48f78c[_0x19b2('0x37')][_0x19b2('0x39')]?_0x48f78c['attributes']:_0x2811e5['model'];_0x48f78c['order']=qs[_0x19b2('0x3e')](_0x977ae4[_0x19b2('0x34')][_0x19b2('0x3e')]);_0x48f78c[_0x19b2('0x3f')]=qs[_0x19b2('0x40')](_['pick'](_0x977ae4['query'],_0x2811e5[_0x19b2('0x40')]));if(_0x977ae4['query'][_0x19b2('0x42')]){_0x48f78c['where']=_[_0x19b2('0x43')](_0x48f78c[_0x19b2('0x3f')],{'$or':_[_0x19b2('0x32')](_0x48f78c[_0x19b2('0x37')],function(_0x1b397c){var _0x4d65b7={};_0x4d65b7[_0x1b397c]={'$like':'%'+_0x977ae4[_0x19b2('0x34')]['filter']+'%'};return _0x4d65b7;})});}_0x48f78c=_[_0x19b2('0x43')]({},_0x48f78c,_0x977ae4[_0x19b2('0x46')]);return _0x7c7bf[_0x19b2('0x72')](_0x48f78c);}})[_0x19b2('0x26')](function(_0x19d631){if(_0x19d631){_0x381bb0=_0x19d631[_0x19b2('0x39')];if(!_0x977ae4['query']['hasOwnProperty'](_0x19b2('0x3b'))){_0x48f78c[_0x19b2('0x3c')]=qs[_0x19b2('0x3c')](_0x977ae4[_0x19b2('0x34')]['limit']);_0x48f78c[_0x19b2('0x1e')]=qs['offset'](_0x977ae4['query'][_0x19b2('0x1e')]);}return _0x7c7bf[_0x19b2('0x72')](_0x48f78c);}})[_0x19b2('0x26')](function(_0x5284a8){if(_0x5284a8){return _0x5284a8?{'count':_0x381bb0,'rows':_0x5284a8}:null;}})['then'](respondWithResult(_0x37ca3a,null))[_0x19b2('0x49')](handleError(_0x37ca3a,null));};
\ No newline at end of file