Built motion from commit a9fb64cc6defd8fb3a5cc199221f878e91c0e969. Version 3.0.0...
[motion-next.git] / server / api / voiceMusicOnHold / voiceMusicOnHold.controller.js
index deffd9a..eee7c71 100644 (file)
@@ -1 +1 @@
-const a742_0x4747=['save_name','merge','getSounds','limit','VIRTUAL','files','end','server/files/sounds/converted','UserProfileSection','VoiceMusicOnHold','server/files/moh','intersection','options','sequelize','undefined','converted_format','rawAttributes','mode','key','UserProfileResource','send','symlinkSync','autoAssociation','join','index','transaction','basename','0777','body','id2','userProfileId','update','like','message','name','length','MusicOnHolds','stack','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','json','attributes','rmdirSync','extname','findAll','params','sort','%s.%s','pick','removeSound','create','count','addSound','findOne','model','readdirSync','then','root','query','mkdirSync','directory','offset','destroy','map','error','where','sendStatus','Content-Range','lodash','../../mysqldb','fieldName','keys','format','status','fields','../../config/logger','createdAt','util','order','unlinkSync','Sound','get','filters','type','forEach','api','include','filter','includeAll','catch'];(function(_0x2a9bca,_0x47472c){const _0x583752=function(_0xc68ea2){while(--_0xc68ea2){_0x2a9bca['push'](_0x2a9bca['shift']());}};_0x583752(++_0x47472c);}(a742_0x4747,0x12b));const a742_0x5837=function(_0x2a9bca,_0x47472c){_0x2a9bca=_0x2a9bca-0x0;let _0x583752=a742_0x4747[_0x2a9bca];return _0x583752;};const _0x98a29b=a742_0x5837;'use strict';const util=require(_0x98a29b('0x2c')),path=require('path'),fs=require('fs'),_=require(_0x98a29b('0x23')),qs=require('../../components/parsers/qs'),logger=require(_0x98a29b('0x2a'))(_0x98a29b('0x34')),config=require('../../config/environment'),db=require(_0x98a29b('0x24'))['db'],{Op,ValidationError}=require('sequelize');function respondWithStatusCode(_0xc68ea2,_0x33b385){return _0x33b385=_0x33b385||0xcc,function(_0x3608df){const _0x879747=a742_0x5837;if(_0x3608df)return _0xc68ea2[_0x879747('0x21')](_0x33b385);return _0xc68ea2[_0x879747('0x28')](_0x33b385)[_0x879747('0x3f')]();};}function respondWithResult(_0x4792f0,_0x3aff23){return _0x3aff23=_0x3aff23||0xc8,function(_0x2eb7ef){const _0x5424b9=a742_0x5837;if(_0x2eb7ef)return _0x4792f0[_0x5424b9('0x28')](_0x3aff23)[_0x5424b9('0x7')](_0x2eb7ef);};}function respondWithFilteredResult(_0x19eae3,_0xa6080e){return function(_0x440746){const _0x5788fa=a742_0x5837;if(_0x440746){const _0x2ca078=_0x440746['count'],_0x65dbb5=_0xa6080e['offset'];let _0x3d011e=_0xa6080e[_0x5788fa('0x1c')]+_0xa6080e[_0x5788fa('0x3c')],_0x37e63c;return _0x3d011e>=_0x2ca078?(_0x3d011e=_0x2ca078,_0x37e63c=0xc8):_0x37e63c=0xce,_0x19eae3[_0x5788fa('0x28')](_0x37e63c),_0x19eae3['set'](_0x5788fa('0x22'),_0x65dbb5+'-'+_0x3d011e+'/'+_0x2ca078)[_0x5788fa('0x7')](_0x440746);}return null;};}function saveUpdates(_0x10e02b){return function(_0x53b861){const _0x57d67e=a742_0x5837;if(_0x53b861)return _0x53b861[_0x57d67e('0x58')](_0x10e02b)[_0x57d67e('0x17')](function(_0x457bf9){return _0x457bf9;});return null;};}function removeEntity(_0x25441e){return function(_0x3cd97c){const _0x39dffd=a742_0x5837;if(_0x3cd97c)return _0x3cd97c['destroy']()[_0x39dffd('0x17')](function(){const _0xf0a3c=_0x39dffd,_0x1ec47e=_0x3cd97c[_0xf0a3c('0x30')]({'plain':!![]}),_0x1f6372=_0xf0a3c('0x4');return db['UserProfileResource']['destroy']({'where':{'type':_0x1f6372,'resourceId':_0x1ec47e['id']}})[_0xf0a3c('0x17')](function(){return _0x3cd97c;});})[_0x39dffd('0x17')](function(){const _0x3ecda0=_0x39dffd;_0x25441e[_0x3ecda0('0x28')](0xcc)['end']();});};}function handleEntityNotFound(_0x429c5c){return function(_0xcdde95){const _0x1a54af=a742_0x5837;return!_0xcdde95&&_0x429c5c[_0x1a54af('0x21')](0x194),_0xcdde95;};}function handleError(_0x1a599f,_0x24a2fc){return _0x24a2fc=_0x24a2fc||0x1f4,function(_0xfa5233){const _0x38b886=a742_0x5837;logger[_0x38b886('0x1f')](_0xfa5233[_0x38b886('0x5')]),_0xfa5233[_0x38b886('0x2')]&&delete _0xfa5233['name'],_0x1a599f[_0x38b886('0x28')](_0x24a2fc)[_0x38b886('0x4d')](_0xfa5233);};}exports[_0x98a29b('0x51')]=function(_0x339dfe,_0x33eaf4){const _0x415586=_0x98a29b;let _0x37fd6f={};const _0x2ee040={},_0x3e1ffd={'count':0x0,'rows':[]},_0x1c7e94=_[_0x415586('0x1e')](db['VoiceMusicOnHold'][_0x415586('0x49')],function(_0x193469){const _0x2c27ef=_0x415586;return{'name':_0x193469[_0x2c27ef('0x25')],'type':_0x193469[_0x2c27ef('0x32')][_0x2c27ef('0x4b')]};});_0x2ee040[_0x415586('0x15')]=_['map'](_0x1c7e94,_0x415586('0x2')),_0x2ee040[_0x415586('0x19')]=_[_0x415586('0x26')](_0x339dfe[_0x415586('0x19')]),_0x2ee040['filters']=_[_0x415586('0x44')](_0x2ee040[_0x415586('0x15')],_0x2ee040[_0x415586('0x19')]),_0x37fd6f[_0x415586('0x8')]=_[_0x415586('0x44')](_0x2ee040[_0x415586('0x15')],qs[_0x415586('0x29')](_0x339dfe['query'][_0x415586('0x29')])),_0x37fd6f[_0x415586('0x8')]=_0x37fd6f[_0x415586('0x8')][_0x415586('0x3')]?_0x37fd6f[_0x415586('0x8')]:_0x2ee040['model'];typeof _0x339dfe['query']['nolimit']===_0x415586('0x47')&&(_0x37fd6f[_0x415586('0x3c')]=qs[_0x415586('0x3c')](_0x339dfe[_0x415586('0x19')][_0x415586('0x3c')]),_0x37fd6f['offset']=qs[_0x415586('0x1c')](_0x339dfe[_0x415586('0x19')][_0x415586('0x1c')]));_0x37fd6f[_0x415586('0x2d')]=qs[_0x415586('0xd')](_0x339dfe[_0x415586('0x19')][_0x415586('0xd')]),_0x37fd6f[_0x415586('0x20')]=qs[_0x415586('0x31')](_[_0x415586('0xf')](_0x339dfe[_0x415586('0x19')],_0x2ee040[_0x415586('0x31')]),_0x1c7e94);_0x339dfe[_0x415586('0x19')][_0x415586('0x36')]&&(_0x37fd6f[_0x415586('0x20')]=_[_0x415586('0x3a')](_0x37fd6f[_0x415586('0x20')],{[Op['or']]:_[_0x415586('0x1e')](_0x1c7e94,function(_0xaf3f1){const _0x96ccfb=_0x415586;if(_0xaf3f1['type']!==_0x96ccfb('0x3d')){const _0x595241={};return _0x595241[_0xaf3f1[_0x96ccfb('0x2')]]={[Op[_0x96ccfb('0x0')]]:'%'+_0x339dfe[_0x96ccfb('0x19')][_0x96ccfb('0x36')]+'%'},_0x595241;}})}));_0x37fd6f=_['merge']({},_0x37fd6f,_0x339dfe['options']);const _0x2499c5={'where':_0x37fd6f[_0x415586('0x20')]};return db[_0x415586('0x42')][_0x415586('0x12')](_0x2499c5)[_0x415586('0x17')](function(_0x27bde8){const _0x276aa2=_0x415586;return _0x3e1ffd[_0x276aa2('0x12')]=_0x27bde8,_0x339dfe[_0x276aa2('0x19')]['includeAll']&&(_0x37fd6f[_0x276aa2('0x35')]=[{'all':!![]}]),db['VoiceMusicOnHold'][_0x276aa2('0xb')](_0x37fd6f);})[_0x415586('0x17')](function(_0x264e5f){return _0x3e1ffd['rows']=_0x264e5f,_0x3e1ffd;})['then'](respondWithFilteredResult(_0x33eaf4,_0x37fd6f))[_0x415586('0x38')](handleError(_0x33eaf4,null));},exports['show']=function(_0x2c374b,_0x3cc32c){const _0x54f87f=_0x98a29b;let _0x3b10df={'raw':![],'where':{'id':_0x2c374b['params']['id']}};const _0x2b4741={};return _0x2b4741[_0x54f87f('0x15')]=_['keys'](db[_0x54f87f('0x42')][_0x54f87f('0x49')]),_0x2b4741[_0x54f87f('0x19')]=_[_0x54f87f('0x26')](_0x2c374b[_0x54f87f('0x19')]),_0x2b4741[_0x54f87f('0x31')]=_[_0x54f87f('0x44')](_0x2b4741[_0x54f87f('0x15')],_0x2b4741['query']),_0x3b10df[_0x54f87f('0x8')]=_['intersection'](_0x2b4741[_0x54f87f('0x15')],qs['fields'](_0x2c374b['query'][_0x54f87f('0x29')])),_0x3b10df[_0x54f87f('0x8')]=_0x3b10df[_0x54f87f('0x8')][_0x54f87f('0x3')]?_0x3b10df[_0x54f87f('0x8')]:_0x2b4741[_0x54f87f('0x15')],_0x2c374b[_0x54f87f('0x19')][_0x54f87f('0x37')]&&(_0x3b10df['include']=[{'all':!![]}]),_0x3b10df=_['merge']({},_0x3b10df,_0x2c374b[_0x54f87f('0x45')]),db['VoiceMusicOnHold'][_0x54f87f('0x14')](_0x3b10df)[_0x54f87f('0x17')](handleEntityNotFound(_0x3cc32c,null))['then'](respondWithResult(_0x3cc32c,null))[_0x54f87f('0x38')](handleError(_0x3cc32c,null));},exports[_0x98a29b('0x58')]=function(_0x6f3bcc,_0x2a845a){const _0x329588=_0x98a29b;return _0x6f3bcc[_0x329588('0x55')]['id']&&delete _0x6f3bcc['body']['id'],db[_0x329588('0x42')][_0x329588('0x14')]({'where':{'id':_0x6f3bcc[_0x329588('0xc')]['id']}})['then'](handleEntityNotFound(_0x2a845a,null))[_0x329588('0x17')](saveUpdates(_0x6f3bcc[_0x329588('0x55')],null))[_0x329588('0x17')](respondWithResult(_0x2a845a,null))['catch'](handleError(_0x2a845a,null));},exports['create']=function(_0x115679,_0x19cfca){const _0xdce81b=_0x98a29b;return db[_0xdce81b('0x46')][_0xdce81b('0x52')](function(_0x3e2aa6){const _0x4336d8=_0xdce81b;return _0x115679[_0x4336d8('0x55')][_0x4336d8('0x4a')]===_0x4336d8('0x3e')&&(_0x115679[_0x4336d8('0x55')][_0x4336d8('0x1b')]=path[_0x4336d8('0x50')](config[_0x4336d8('0x18')],_0x4336d8('0x43'),_0x115679['body'][_0x4336d8('0x2')])),db[_0x4336d8('0x42')][_0x4336d8('0x11')](_0x115679[_0x4336d8('0x55')],{'transaction':_0x3e2aa6})['then'](function(_0x5bb9fd){const _0x75048=_0x4336d8;_0x115679[_0x75048('0x55')][_0x75048('0x4a')]==='files'&&fs[_0x75048('0x1a')](_0x5bb9fd[_0x75048('0x1b')],parseInt(_0x75048('0x54'),0x8));const _0x232626=_0x115679['user']['get']({'plain':!![]});if(!_0x232626)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x232626['role']==='user'){const _0xd53a45=_0x5bb9fd['get']({'plain':!![]});return db[_0x75048('0x41')][_0x75048('0x14')]({'where':{'name':_0x75048('0x4'),'userProfileId':_0x232626[_0x75048('0x57')]},'raw':!![]})[_0x75048('0x17')](function(_0x121f75){const _0x2f3aac=_0x75048;return _0x121f75&&_0x121f75[_0x2f3aac('0x4f')]===0x0?db[_0x2f3aac('0x4c')][_0x2f3aac('0x11')]({'name':_0xd53a45['name'],'resourceId':_0xd53a45['id'],'type':_0x121f75[_0x2f3aac('0x2')],'sectionId':_0x121f75['id']},{})['then'](function(){return _0x5bb9fd;}):_0x5bb9fd;})[_0x75048('0x38')](function(_0x14813b){const _0x11ddb9=_0x75048;logger[_0x11ddb9('0x1f')](_0x11ddb9('0x6'),_0x14813b);});}return _0x5bb9fd;});})[_0xdce81b('0x17')](respondWithResult(_0x19cfca,0xc9))['catch'](handleError(_0x19cfca,null));},exports['destroy']=function(_0x3c10c1,_0x36dfa7){const _0x52510a=_0x98a29b;return db[_0x52510a('0x42')][_0x52510a('0x14')]({'where':{'id':_0x3c10c1[_0x52510a('0xc')]['id']}})[_0x52510a('0x17')](function(_0x46cbef){const _0x697b9=_0x52510a;if(_0x46cbef)return db[_0x697b9('0x46')][_0x697b9('0x52')](function(_0x3473d9){const _0x4cdf97=_0x697b9;return _0x46cbef[_0x4cdf97('0x1d')]({'transaction':_0x3473d9,'raw':!![]})[_0x4cdf97('0x17')](function(_0x2ef726){const _0x14d02c=_0x4cdf97;return _0x2ef726[_0x14d02c('0x1b')]&&(fs[_0x14d02c('0x16')](_0x2ef726[_0x14d02c('0x1b')])[_0x14d02c('0x33')](function(_0x4e24fb){const _0x11a61c=_0x14d02c;fs[_0x11a61c('0x2e')](path[_0x11a61c('0x50')](_0x2ef726[_0x11a61c('0x1b')],_0x4e24fb));}),fs[_0x14d02c('0x9')](_0x2ef726[_0x14d02c('0x1b')])),_0x2ef726;});})[_0x697b9('0x38')](function(_0x35a1be){const _0x39ae5f=_0x697b9;throw new ValidationError(_0x35a1be[_0x39ae5f('0x1')]);});})[_0x52510a('0x17')](handleEntityNotFound(_0x36dfa7,null))[_0x52510a('0x17')](removeEntity(_0x36dfa7,null))[_0x52510a('0x38')](handleError(_0x36dfa7,null));},exports[_0x98a29b('0x13')]=function(_0x1e6ea7,_0x5c156f){const _0x2e9e8a=_0x98a29b;return db[_0x2e9e8a('0x46')][_0x2e9e8a('0x52')](function(_0x1c11e9){const _0x15cb56=_0x2e9e8a;let _0x32d902;return db[_0x15cb56('0x42')][_0x15cb56('0x14')]({'where':{'id':_0x1e6ea7[_0x15cb56('0xc')]['id']}})['then'](function(_0x40ceb5){const _0x55d318=_0x15cb56;if(_0x40ceb5)return _0x32d902=_0x40ceb5,_0x40ceb5[_0x55d318('0x13')](_0x1e6ea7[_0x55d318('0x55')]['id'],{'transaction':_0x1c11e9});})[_0x15cb56('0x17')](function(_0x3edbd2){const _0x250e7b=_0x15cb56;if(_0x3edbd2)return db[_0x250e7b('0x2f')][_0x250e7b('0x14')]({'where':{'id':_0x1e6ea7[_0x250e7b('0x55')]['id']},'attributes':['id','name',_0x250e7b('0x39'),_0x250e7b('0x48'),'createdAt'],'raw':!![]});})[_0x15cb56('0x17')](function(_0x41f16b){const _0x1654a9=_0x15cb56;if(_0x41f16b){const _0x7827ec=path[_0x1654a9('0x50')](config['root'],_0x1654a9('0x40'),util[_0x1654a9('0x27')]('%s.%s',path[_0x1654a9('0x53')](_0x41f16b[_0x1654a9('0x39')],path[_0x1654a9('0xa')](_0x41f16b[_0x1654a9('0x39')])),_0x41f16b[_0x1654a9('0x48')])),_0x5b8ff5=path[_0x1654a9('0x50')](config[_0x1654a9('0x18')],_0x1654a9('0x43'),_0x32d902[_0x1654a9('0x2')],util[_0x1654a9('0x27')](_0x1654a9('0xe'),_0x41f16b[_0x1654a9('0x2')],_0x41f16b[_0x1654a9('0x48')]));return fs[_0x1654a9('0x4e')](_0x7827ec,_0x5b8ff5),_0x41f16b;}})[_0x15cb56('0x38')](function(_0xcf9253){const _0x249058=_0x15cb56;throw new ValidationError(_0xcf9253[_0x249058('0x1')]);});})['then'](handleEntityNotFound(_0x5c156f,null))[_0x2e9e8a('0x17')](respondWithResult(_0x5c156f,0xc9))[_0x2e9e8a('0x38')](handleError(_0x5c156f,null));},exports['removeSound']=function(_0x18a079,_0x5ddf62){const _0x200cad=_0x98a29b;return db[_0x200cad('0x46')][_0x200cad('0x52')](function(){const _0x2ad53f=_0x200cad;let _0x426dfe;return db[_0x2ad53f('0x42')][_0x2ad53f('0x14')]({'where':{'id':_0x18a079[_0x2ad53f('0xc')]['id']}})[_0x2ad53f('0x17')](handleEntityNotFound(_0x5ddf62,null))[_0x2ad53f('0x17')](function(_0x40f7bc){const _0x594e9e=_0x2ad53f;if(_0x40f7bc)return _0x426dfe=_0x40f7bc,_0x40f7bc[_0x594e9e('0x10')](_0x18a079['params'][_0x594e9e('0x56')]);})[_0x2ad53f('0x17')](function(_0x13e0d3){const _0x33297c=_0x2ad53f;if(_0x13e0d3)return db[_0x33297c('0x2f')]['findOne']({'where':{'id':_0x18a079[_0x33297c('0xc')]['id2']},'attributes':['id',_0x33297c('0x2'),'save_name',_0x33297c('0x48'),_0x33297c('0x2b')],'raw':!![]});})['then'](function(_0x202523){const _0x58803a=_0x2ad53f;if(_0x202523)return fs['unlinkSync'](path[_0x58803a('0x50')](_0x426dfe[_0x58803a('0x1b')],util[_0x58803a('0x27')](_0x58803a('0xe'),_0x202523[_0x58803a('0x2')],_0x202523[_0x58803a('0x48')]))),_0x202523;})[_0x2ad53f('0x38')](function(_0x46b984){throw new ValidationError(_0x46b984['message']);});})[_0x200cad('0x17')](handleEntityNotFound(_0x5ddf62,null))[_0x200cad('0x17')](respondWithStatusCode(_0x5ddf62,0xcc))[_0x200cad('0x38')](handleError(_0x5ddf62,null));},exports['getSounds']=function(_0xda2264,_0x1b3fb4){const _0x4233a1=_0x98a29b;let _0x35741a={};const _0x382252={};let _0x42c585,_0xe44f8d;return db['VoiceMusicOnHold'][_0x4233a1('0x14')]({'where':{'id':_0xda2264['params']['id']}})['then'](handleEntityNotFound(_0x1b3fb4,null))[_0x4233a1('0x17')](function(_0x23b16c){const _0x2904d4=_0x4233a1;if(_0x23b16c)return _0x42c585=_0x23b16c,_0x382252[_0x2904d4('0x15')]=_[_0x2904d4('0x26')](db['Sound'][_0x2904d4('0x49')]),_0x382252['query']=_[_0x2904d4('0x26')](_0xda2264[_0x2904d4('0x19')]),_0x382252['filters']=_[_0x2904d4('0x44')](_0x382252[_0x2904d4('0x15')],_0x382252[_0x2904d4('0x19')]),_0x35741a[_0x2904d4('0x8')]=_['intersection'](_0x382252[_0x2904d4('0x15')],qs[_0x2904d4('0x29')](_0xda2264[_0x2904d4('0x19')]['fields'])),_0x35741a['attributes']=_0x35741a[_0x2904d4('0x8')][_0x2904d4('0x3')]?_0x35741a[_0x2904d4('0x8')]:_0x382252[_0x2904d4('0x15')],_0x35741a[_0x2904d4('0x2d')]=qs[_0x2904d4('0xd')](_0xda2264[_0x2904d4('0x19')][_0x2904d4('0xd')]),_0x35741a['where']=qs[_0x2904d4('0x31')](_[_0x2904d4('0xf')](_0xda2264[_0x2904d4('0x19')],_0x382252[_0x2904d4('0x31')])),_0xda2264[_0x2904d4('0x19')][_0x2904d4('0x36')]&&(_0x35741a[_0x2904d4('0x20')]=_[_0x2904d4('0x3a')](_0x35741a[_0x2904d4('0x20')],{[Op['or']]:_[_0x2904d4('0x1e')](_0x35741a[_0x2904d4('0x8')],function(_0x2252b7){const _0x8daac6=_0x2904d4,_0x7989a7={};return _0x7989a7[_0x2252b7]={[Op[_0x8daac6('0x0')]]:'%'+_0xda2264[_0x8daac6('0x19')]['filter']+'%'},_0x7989a7;})})),_0x35741a=_[_0x2904d4('0x3a')]({},_0x35741a,_0xda2264['options']),_0x42c585[_0x2904d4('0x3b')](_0x35741a);})['then'](function(_0x50b9e7){const _0x32c56a=_0x4233a1;if(_0x50b9e7)return _0xe44f8d=_0x50b9e7['length'],typeof _0xda2264[_0x32c56a('0x19')]['nolimit']==='undefined'&&(_0x35741a['limit']=qs['limit'](_0xda2264['query'][_0x32c56a('0x3c')]),_0x35741a[_0x32c56a('0x1c')]=qs[_0x32c56a('0x1c')](_0xda2264[_0x32c56a('0x19')]['offset'])),_0x42c585['getSounds'](_0x35741a);})[_0x4233a1('0x17')](function(_0x2fd4c1){if(_0x2fd4c1)return _0x2fd4c1?{'count':_0xe44f8d,'rows':_0x2fd4c1}:null;})[_0x4233a1('0x17')](respondWithResult(_0x1b3fb4,null))[_0x4233a1('0x38')](handleError(_0x1b3fb4,null));};
\ No newline at end of file
+const a742_0x4919=['mode','show','create','sendStatus','query','merge','save_name','Unable\x20to\x20retrieve\x20the\x20current\x20user','include','undefined','status','filters','UserProfileResource','key','params','util','createdAt','VIRTUAL','offset','catch','Sound','rawAttributes','basename','map','readdirSync','id2','%s.%s','fields','userProfileId','end','join','model','VoiceMusicOnHold','includeAll','sort','index','nolimit','count','findAll','where','MusicOnHolds','type','symlinkSync','rmdirSync','get','addSound','path','converted_format','error','name','length','keys','message','../../config/logger','stack','user','UserProfileSection','directory','../../config/environment','order','json','unlinkSync','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','server/files/moh','attributes','update','send','removeSound','filter','sequelize','destroy','intersection','limit','role','body','getSounds','format','0777','then','options','root','pick','findOne','fieldName','transaction','files'];(function(_0x47f9b6,_0x4919d6){const _0x321994=function(_0x5d0497){while(--_0x5d0497){_0x47f9b6['push'](_0x47f9b6['shift']());}};_0x321994(++_0x4919d6);}(a742_0x4919,0x83));const a742_0x3219=function(_0x47f9b6,_0x4919d6){_0x47f9b6=_0x47f9b6-0x0;let _0x321994=a742_0x4919[_0x47f9b6];return _0x321994;};const _0x354c60=a742_0x3219;'use strict';const util=require(_0x354c60('0x38')),path=require(_0x354c60('0x1')),fs=require('fs'),_=require('lodash'),qs=require('../../components/parsers/qs'),logger=require(_0x354c60('0x8'))('api'),config=require(_0x354c60('0xd')),db=require('../../mysqldb')['db'],{Op,ValidationError}=require(_0x354c60('0x18'));function respondWithStatusCode(_0x5d0497,_0x3298f9){return _0x3298f9=_0x3298f9||0xcc,function(_0x414505){const _0x4888aa=a742_0x3219;if(_0x414505)return _0x5d0497[_0x4888aa('0x2c')](_0x3298f9);return _0x5d0497['status'](_0x3298f9)[_0x4888aa('0x46')]();};}function respondWithResult(_0x17c985,_0x43fa93){return _0x43fa93=_0x43fa93||0xc8,function(_0x2fbc23){if(_0x2fbc23)return _0x17c985['status'](_0x43fa93)['json'](_0x2fbc23);};}function respondWithFilteredResult(_0x39b9fe,_0x1d0593){return function(_0x34661d){const _0x340b71=a742_0x3219;if(_0x34661d){const _0x3344b3=_0x34661d[_0x340b71('0x4e')],_0x36212f=_0x1d0593[_0x340b71('0x3b')];let _0x5bc816=_0x1d0593['offset']+_0x1d0593[_0x340b71('0x1b')],_0x3aea3a;return _0x5bc816>=_0x3344b3?(_0x5bc816=_0x3344b3,_0x3aea3a=0xc8):_0x3aea3a=0xce,_0x39b9fe['status'](_0x3aea3a),_0x39b9fe['set']('Content-Range',_0x36212f+'-'+_0x5bc816+'/'+_0x3344b3)[_0x340b71('0xf')](_0x34661d);}return null;};}function saveUpdates(_0x223645){return function(_0x351864){const _0x410e1c=a742_0x3219;if(_0x351864)return _0x351864[_0x410e1c('0x14')](_0x223645)[_0x410e1c('0x21')](function(_0xb73f99){return _0xb73f99;});return null;};}function removeEntity(_0x4c3f8e){return function(_0xe0bcc8){const _0x480815=a742_0x3219;if(_0xe0bcc8)return _0xe0bcc8['destroy']()[_0x480815('0x21')](function(){const _0xf1cf37=_0x480815,_0x175403=_0xe0bcc8[_0xf1cf37('0x55')]({'plain':!![]}),_0xf0cf71=_0xf1cf37('0x51');return db[_0xf1cf37('0x35')][_0xf1cf37('0x19')]({'where':{'type':_0xf0cf71,'resourceId':_0x175403['id']}})[_0xf1cf37('0x21')](function(){return _0xe0bcc8;});})[_0x480815('0x21')](function(){_0x4c3f8e['status'](0xcc)['end']();});};}function handleEntityNotFound(_0x13a4da){return function(_0x9b096f){const _0x496b6b=a742_0x3219;return!_0x9b096f&&_0x13a4da[_0x496b6b('0x2c')](0x194),_0x9b096f;};}function handleError(_0x86452a,_0x291b7a){return _0x291b7a=_0x291b7a||0x1f4,function(_0x35630a){const _0x4dac61=a742_0x3219;logger[_0x4dac61('0x3')](_0x35630a[_0x4dac61('0x9')]),_0x35630a[_0x4dac61('0x4')]&&delete _0x35630a[_0x4dac61('0x4')],_0x86452a[_0x4dac61('0x33')](_0x291b7a)[_0x4dac61('0x15')](_0x35630a);};}exports[_0x354c60('0x4c')]=function(_0x462e8f,_0x4af452){const _0x6ecd0d=_0x354c60;let _0x2ab23c={};const _0x4fc24d={},_0x1c8b4f={'count':0x0,'rows':[]},_0x5de56e=_[_0x6ecd0d('0x40')](db['VoiceMusicOnHold']['rawAttributes'],function(_0x5deef1){const _0xef2d6b=_0x6ecd0d;return{'name':_0x5deef1[_0xef2d6b('0x26')],'type':_0x5deef1[_0xef2d6b('0x52')][_0xef2d6b('0x36')]};});_0x4fc24d['model']=_[_0x6ecd0d('0x40')](_0x5de56e,_0x6ecd0d('0x4')),_0x4fc24d[_0x6ecd0d('0x2d')]=_['keys'](_0x462e8f[_0x6ecd0d('0x2d')]),_0x4fc24d[_0x6ecd0d('0x34')]=_[_0x6ecd0d('0x1a')](_0x4fc24d[_0x6ecd0d('0x48')],_0x4fc24d[_0x6ecd0d('0x2d')]),_0x2ab23c[_0x6ecd0d('0x13')]=_['intersection'](_0x4fc24d[_0x6ecd0d('0x48')],qs[_0x6ecd0d('0x44')](_0x462e8f[_0x6ecd0d('0x2d')]['fields'])),_0x2ab23c['attributes']=_0x2ab23c['attributes']['length']?_0x2ab23c[_0x6ecd0d('0x13')]:_0x4fc24d['model'];typeof _0x462e8f['query'][_0x6ecd0d('0x4d')]===_0x6ecd0d('0x32')&&(_0x2ab23c['limit']=qs[_0x6ecd0d('0x1b')](_0x462e8f[_0x6ecd0d('0x2d')][_0x6ecd0d('0x1b')]),_0x2ab23c[_0x6ecd0d('0x3b')]=qs['offset'](_0x462e8f[_0x6ecd0d('0x2d')][_0x6ecd0d('0x3b')]));_0x2ab23c[_0x6ecd0d('0xe')]=qs['sort'](_0x462e8f[_0x6ecd0d('0x2d')]['sort']),_0x2ab23c[_0x6ecd0d('0x50')]=qs[_0x6ecd0d('0x34')](_['pick'](_0x462e8f[_0x6ecd0d('0x2d')],_0x4fc24d[_0x6ecd0d('0x34')]),_0x5de56e);_0x462e8f[_0x6ecd0d('0x2d')]['filter']&&(_0x2ab23c[_0x6ecd0d('0x50')]=_[_0x6ecd0d('0x2e')](_0x2ab23c[_0x6ecd0d('0x50')],{[Op['or']]:_['map'](_0x5de56e,function(_0x319063){const _0x5d774d=_0x6ecd0d;if(_0x319063[_0x5d774d('0x52')]!==_0x5d774d('0x3a')){const _0x57fcd7={};return _0x57fcd7[_0x319063['name']]={[Op['like']]:'%'+_0x462e8f[_0x5d774d('0x2d')][_0x5d774d('0x17')]+'%'},_0x57fcd7;}})}));_0x2ab23c=_[_0x6ecd0d('0x2e')]({},_0x2ab23c,_0x462e8f[_0x6ecd0d('0x22')]);const _0x5ea787={'where':_0x2ab23c[_0x6ecd0d('0x50')]};return db['VoiceMusicOnHold'][_0x6ecd0d('0x4e')](_0x5ea787)[_0x6ecd0d('0x21')](function(_0x10e862){const _0x254863=_0x6ecd0d;return _0x1c8b4f[_0x254863('0x4e')]=_0x10e862,_0x462e8f[_0x254863('0x2d')][_0x254863('0x4a')]&&(_0x2ab23c[_0x254863('0x31')]=[{'all':!![]}]),db['VoiceMusicOnHold'][_0x254863('0x4f')](_0x2ab23c);})[_0x6ecd0d('0x21')](function(_0x5e4a2b){return _0x1c8b4f['rows']=_0x5e4a2b,_0x1c8b4f;})['then'](respondWithFilteredResult(_0x4af452,_0x2ab23c))['catch'](handleError(_0x4af452,null));},exports[_0x354c60('0x2a')]=function(_0x1933b6,_0xbdebba){const _0x628fb0=_0x354c60;let _0x72c72c={'raw':![],'where':{'id':_0x1933b6[_0x628fb0('0x37')]['id']}};const _0x5d5660={};return _0x5d5660['model']=_['keys'](db[_0x628fb0('0x49')][_0x628fb0('0x3e')]),_0x5d5660[_0x628fb0('0x2d')]=_['keys'](_0x1933b6['query']),_0x5d5660[_0x628fb0('0x34')]=_[_0x628fb0('0x1a')](_0x5d5660[_0x628fb0('0x48')],_0x5d5660[_0x628fb0('0x2d')]),_0x72c72c[_0x628fb0('0x13')]=_[_0x628fb0('0x1a')](_0x5d5660[_0x628fb0('0x48')],qs[_0x628fb0('0x44')](_0x1933b6[_0x628fb0('0x2d')][_0x628fb0('0x44')])),_0x72c72c['attributes']=_0x72c72c[_0x628fb0('0x13')][_0x628fb0('0x5')]?_0x72c72c[_0x628fb0('0x13')]:_0x5d5660['model'],_0x1933b6[_0x628fb0('0x2d')]['includeAll']&&(_0x72c72c[_0x628fb0('0x31')]=[{'all':!![]}]),_0x72c72c=_[_0x628fb0('0x2e')]({},_0x72c72c,_0x1933b6[_0x628fb0('0x22')]),db['VoiceMusicOnHold'][_0x628fb0('0x25')](_0x72c72c)[_0x628fb0('0x21')](handleEntityNotFound(_0xbdebba,null))[_0x628fb0('0x21')](respondWithResult(_0xbdebba,null))[_0x628fb0('0x3c')](handleError(_0xbdebba,null));},exports[_0x354c60('0x14')]=function(_0x424b7f,_0x4ad9f3){const _0x2c20f4=_0x354c60;return _0x424b7f[_0x2c20f4('0x1d')]['id']&&delete _0x424b7f[_0x2c20f4('0x1d')]['id'],db[_0x2c20f4('0x49')][_0x2c20f4('0x25')]({'where':{'id':_0x424b7f[_0x2c20f4('0x37')]['id']}})[_0x2c20f4('0x21')](handleEntityNotFound(_0x4ad9f3,null))[_0x2c20f4('0x21')](saveUpdates(_0x424b7f[_0x2c20f4('0x1d')],null))[_0x2c20f4('0x21')](respondWithResult(_0x4ad9f3,null))['catch'](handleError(_0x4ad9f3,null));},exports[_0x354c60('0x2b')]=function(_0x482328,_0x5718e0){const _0x8e2819=_0x354c60;return db[_0x8e2819('0x18')]['transaction'](function(_0x383f92){const _0x1a66b4=_0x8e2819;return _0x482328['body']['mode']===_0x1a66b4('0x28')&&(_0x482328['body'][_0x1a66b4('0xc')]=path[_0x1a66b4('0x47')](config[_0x1a66b4('0x23')],_0x1a66b4('0x12'),_0x482328['body'][_0x1a66b4('0x4')])),db[_0x1a66b4('0x49')][_0x1a66b4('0x2b')](_0x482328[_0x1a66b4('0x1d')],{'transaction':_0x383f92})['then'](function(_0x50e66a){const _0x48f5f5=_0x1a66b4;_0x482328[_0x48f5f5('0x1d')][_0x48f5f5('0x29')]===_0x48f5f5('0x28')&&fs['mkdirSync'](_0x50e66a[_0x48f5f5('0xc')],parseInt(_0x48f5f5('0x20'),0x8));const _0x4b23f7=_0x482328[_0x48f5f5('0xa')][_0x48f5f5('0x55')]({'plain':!![]});if(!_0x4b23f7)throw new Error(_0x48f5f5('0x30'));if(_0x4b23f7[_0x48f5f5('0x1c')]==='user'){const _0xc16e62=_0x50e66a[_0x48f5f5('0x55')]({'plain':!![]});return db[_0x48f5f5('0xb')]['findOne']({'where':{'name':_0x48f5f5('0x51'),'userProfileId':_0x4b23f7[_0x48f5f5('0x45')]},'raw':!![]})[_0x48f5f5('0x21')](function(_0x2da1fc){const _0x1839ef=_0x48f5f5;return _0x2da1fc&&_0x2da1fc['autoAssociation']===0x0?db[_0x1839ef('0x35')][_0x1839ef('0x2b')]({'name':_0xc16e62[_0x1839ef('0x4')],'resourceId':_0xc16e62['id'],'type':_0x2da1fc[_0x1839ef('0x4')],'sectionId':_0x2da1fc['id']},{})[_0x1839ef('0x21')](function(){return _0x50e66a;}):_0x50e66a;})[_0x48f5f5('0x3c')](function(_0x883151){const _0x596753=_0x48f5f5;logger[_0x596753('0x3')](_0x596753('0x11'),_0x883151);});}return _0x50e66a;});})['then'](respondWithResult(_0x5718e0,0xc9))['catch'](handleError(_0x5718e0,null));},exports['destroy']=function(_0x3f762c,_0x4688d8){const _0x1c4a25=_0x354c60;return db[_0x1c4a25('0x49')][_0x1c4a25('0x25')]({'where':{'id':_0x3f762c['params']['id']}})['then'](function(_0x227e4b){const _0x2e9c12=_0x1c4a25;if(_0x227e4b)return db[_0x2e9c12('0x18')][_0x2e9c12('0x27')](function(_0x1abd10){const _0x49aafd=_0x2e9c12;return _0x227e4b['destroy']({'transaction':_0x1abd10,'raw':!![]})[_0x49aafd('0x21')](function(_0x451d0c){const _0x50330c=_0x49aafd;return _0x451d0c[_0x50330c('0xc')]&&(fs[_0x50330c('0x41')](_0x451d0c[_0x50330c('0xc')])['forEach'](function(_0x58436f){const _0x3eac65=_0x50330c;fs[_0x3eac65('0x10')](path[_0x3eac65('0x47')](_0x451d0c['directory'],_0x58436f));}),fs[_0x50330c('0x54')](_0x451d0c[_0x50330c('0xc')])),_0x451d0c;});})[_0x2e9c12('0x3c')](function(_0x241d49){throw new ValidationError(_0x241d49['message']);});})[_0x1c4a25('0x21')](handleEntityNotFound(_0x4688d8,null))[_0x1c4a25('0x21')](removeEntity(_0x4688d8,null))[_0x1c4a25('0x3c')](handleError(_0x4688d8,null));},exports['addSound']=function(_0x2533fd,_0x5cd8c2){const _0x568608=_0x354c60;return db[_0x568608('0x18')][_0x568608('0x27')](function(_0xe2b888){const _0x2424f4=_0x568608;let _0x30701e;return db['VoiceMusicOnHold'][_0x2424f4('0x25')]({'where':{'id':_0x2533fd['params']['id']}})['then'](function(_0x5d9d18){const _0x1e4b1e=_0x2424f4;if(_0x5d9d18)return _0x30701e=_0x5d9d18,_0x5d9d18[_0x1e4b1e('0x0')](_0x2533fd[_0x1e4b1e('0x1d')]['id'],{'transaction':_0xe2b888});})[_0x2424f4('0x21')](function(_0xd77cfc){const _0x2bb449=_0x2424f4;if(_0xd77cfc)return db[_0x2bb449('0x3d')]['findOne']({'where':{'id':_0x2533fd[_0x2bb449('0x1d')]['id']},'attributes':['id',_0x2bb449('0x4'),_0x2bb449('0x2f'),_0x2bb449('0x2'),_0x2bb449('0x39')],'raw':!![]});})[_0x2424f4('0x21')](function(_0x58b20e){const _0x26bfa4=_0x2424f4;if(_0x58b20e){const _0x438908=path['join'](config[_0x26bfa4('0x23')],'server/files/sounds/converted',util[_0x26bfa4('0x1f')](_0x26bfa4('0x43'),path[_0x26bfa4('0x3f')](_0x58b20e['save_name'],path['extname'](_0x58b20e['save_name'])),_0x58b20e[_0x26bfa4('0x2')])),_0x4b28cb=path[_0x26bfa4('0x47')](config['root'],'server/files/moh',_0x30701e[_0x26bfa4('0x4')],util[_0x26bfa4('0x1f')](_0x26bfa4('0x43'),_0x58b20e[_0x26bfa4('0x4')],_0x58b20e[_0x26bfa4('0x2')]));return fs[_0x26bfa4('0x53')](_0x438908,_0x4b28cb),_0x58b20e;}})[_0x2424f4('0x3c')](function(_0x5a115d){throw new ValidationError(_0x5a115d['message']);});})[_0x568608('0x21')](handleEntityNotFound(_0x5cd8c2,null))[_0x568608('0x21')](respondWithResult(_0x5cd8c2,0xc9))['catch'](handleError(_0x5cd8c2,null));},exports[_0x354c60('0x16')]=function(_0x4e0eb1,_0xd1af7){const _0x136fed=_0x354c60;return db[_0x136fed('0x18')][_0x136fed('0x27')](function(){const _0x2b225a=_0x136fed;let _0x2aa187;return db[_0x2b225a('0x49')][_0x2b225a('0x25')]({'where':{'id':_0x4e0eb1[_0x2b225a('0x37')]['id']}})[_0x2b225a('0x21')](handleEntityNotFound(_0xd1af7,null))[_0x2b225a('0x21')](function(_0x1a6276){const _0x7cd3ba=_0x2b225a;if(_0x1a6276)return _0x2aa187=_0x1a6276,_0x1a6276['removeSound'](_0x4e0eb1[_0x7cd3ba('0x37')][_0x7cd3ba('0x42')]);})[_0x2b225a('0x21')](function(_0x3677e9){const _0x247f82=_0x2b225a;if(_0x3677e9)return db[_0x247f82('0x3d')][_0x247f82('0x25')]({'where':{'id':_0x4e0eb1['params']['id2']},'attributes':['id',_0x247f82('0x4'),_0x247f82('0x2f'),'converted_format','createdAt'],'raw':!![]});})[_0x2b225a('0x21')](function(_0xda3070){const _0x44e5d6=_0x2b225a;if(_0xda3070)return fs[_0x44e5d6('0x10')](path[_0x44e5d6('0x47')](_0x2aa187[_0x44e5d6('0xc')],util[_0x44e5d6('0x1f')]('%s.%s',_0xda3070[_0x44e5d6('0x4')],_0xda3070[_0x44e5d6('0x2')]))),_0xda3070;})['catch'](function(_0x51955b){const _0x2475ec=_0x2b225a;throw new ValidationError(_0x51955b[_0x2475ec('0x7')]);});})['then'](handleEntityNotFound(_0xd1af7,null))[_0x136fed('0x21')](respondWithStatusCode(_0xd1af7,0xcc))['catch'](handleError(_0xd1af7,null));},exports[_0x354c60('0x1e')]=function(_0x4bbd29,_0x2427ce){const _0x8f76a3=_0x354c60;let _0x4b4ab7={};const _0x40715f={};let _0x140621,_0x26efc8;return db[_0x8f76a3('0x49')]['findOne']({'where':{'id':_0x4bbd29['params']['id']}})[_0x8f76a3('0x21')](handleEntityNotFound(_0x2427ce,null))[_0x8f76a3('0x21')](function(_0x4523f2){const _0x8c0f1e=_0x8f76a3;if(_0x4523f2)return _0x140621=_0x4523f2,_0x40715f['model']=_[_0x8c0f1e('0x6')](db[_0x8c0f1e('0x3d')]['rawAttributes']),_0x40715f[_0x8c0f1e('0x2d')]=_['keys'](_0x4bbd29[_0x8c0f1e('0x2d')]),_0x40715f['filters']=_[_0x8c0f1e('0x1a')](_0x40715f[_0x8c0f1e('0x48')],_0x40715f['query']),_0x4b4ab7[_0x8c0f1e('0x13')]=_[_0x8c0f1e('0x1a')](_0x40715f[_0x8c0f1e('0x48')],qs[_0x8c0f1e('0x44')](_0x4bbd29[_0x8c0f1e('0x2d')]['fields'])),_0x4b4ab7[_0x8c0f1e('0x13')]=_0x4b4ab7[_0x8c0f1e('0x13')][_0x8c0f1e('0x5')]?_0x4b4ab7[_0x8c0f1e('0x13')]:_0x40715f[_0x8c0f1e('0x48')],_0x4b4ab7[_0x8c0f1e('0xe')]=qs['sort'](_0x4bbd29[_0x8c0f1e('0x2d')][_0x8c0f1e('0x4b')]),_0x4b4ab7[_0x8c0f1e('0x50')]=qs[_0x8c0f1e('0x34')](_[_0x8c0f1e('0x24')](_0x4bbd29[_0x8c0f1e('0x2d')],_0x40715f[_0x8c0f1e('0x34')])),_0x4bbd29[_0x8c0f1e('0x2d')]['filter']&&(_0x4b4ab7['where']=_[_0x8c0f1e('0x2e')](_0x4b4ab7['where'],{[Op['or']]:_['map'](_0x4b4ab7[_0x8c0f1e('0x13')],function(_0x6cf429){const _0x41e4cc=_0x8c0f1e,_0x55e54b={};return _0x55e54b[_0x6cf429]={[Op['like']]:'%'+_0x4bbd29[_0x41e4cc('0x2d')]['filter']+'%'},_0x55e54b;})})),_0x4b4ab7=_[_0x8c0f1e('0x2e')]({},_0x4b4ab7,_0x4bbd29[_0x8c0f1e('0x22')]),_0x140621[_0x8c0f1e('0x1e')](_0x4b4ab7);})[_0x8f76a3('0x21')](function(_0x5eb23d){const _0x2a43b3=_0x8f76a3;if(_0x5eb23d)return _0x26efc8=_0x5eb23d[_0x2a43b3('0x5')],typeof _0x4bbd29[_0x2a43b3('0x2d')]['nolimit']===_0x2a43b3('0x32')&&(_0x4b4ab7[_0x2a43b3('0x1b')]=qs['limit'](_0x4bbd29[_0x2a43b3('0x2d')][_0x2a43b3('0x1b')]),_0x4b4ab7[_0x2a43b3('0x3b')]=qs[_0x2a43b3('0x3b')](_0x4bbd29[_0x2a43b3('0x2d')]['offset'])),_0x140621[_0x2a43b3('0x1e')](_0x4b4ab7);})[_0x8f76a3('0x21')](function(_0xb28bb4){if(_0xb28bb4)return _0xb28bb4?{'count':_0x26efc8,'rows':_0xb28bb4}:null;})[_0x8f76a3('0x21')](respondWithResult(_0x2427ce,null))[_0x8f76a3('0x3c')](handleError(_0x2427ce,null));};
\ No newline at end of file