Built motion from commit ded33658aad58fc8de845a8299a9db59a88cc353. Version 3.0.0...
[motion-next.git] / server / api / voiceMusicOnHold / voiceMusicOnHold.controller.js
index 485faaf..dd1caee 100644 (file)
@@ -1 +1 @@
-const a742_0x151b=['../../components/parsers/qs','destroy','findOne','save_name','options','limit','join','getSounds','create','unlinkSync','mkdirSync','then','autoAssociation','MusicOnHolds','converted_format','directory','include','model','UserProfileSection','addSound','sendStatus','merge','keys','VoiceMusicOnHold','filters','nolimit','name','root','error','rawAttributes','like','length','stack','UserProfileResource','userProfileId','rmdirSync','path','rows','where','message','%s.%s','symlinkSync','lodash','id2','transaction','Sound','update','get','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Unable\x20to\x20retrieve\x20the\x20current\x20user','end','role','Content-Range','createdAt','util','user','key','server/files/moh','filter','json','mode','includeAll','fields','api','removeSound','catch','status','count','attributes','set','intersection','params','body','format','sequelize','offset','basename','undefined','sort','map','query'];(function(_0x22ce5d,_0x151b0a){const _0x3f468b=function(_0x4beb88){while(--_0x4beb88){_0x22ce5d['push'](_0x22ce5d['shift']());}};_0x3f468b(++_0x151b0a);}(a742_0x151b,0x1a6));const a742_0x3f46=function(_0x22ce5d,_0x151b0a){_0x22ce5d=_0x22ce5d-0x0;let _0x3f468b=a742_0x151b[_0x22ce5d];return _0x3f468b;};const _0x21cb13=a742_0x3f46;'use strict';const util=require(_0x21cb13('0x25')),path=require(_0x21cb13('0x13')),fs=require('fs'),_=require(_0x21cb13('0x19')),qs=require(_0x21cb13('0x40')),logger=require('../../config/logger')(_0x21cb13('0x2e')),config=require('../../config/environment'),db=require('../../mysqldb')['db'],{Op,ValidationError}=require(_0x21cb13('0x39'));function respondWithStatusCode(_0x4beb88,_0x5d9918){return _0x5d9918=_0x5d9918||0xcc,function(_0x2cbba4){const _0x208f96=a742_0x3f46;if(_0x2cbba4)return _0x4beb88[_0x208f96('0x3')](_0x5d9918);return _0x4beb88[_0x208f96('0x31')](_0x5d9918)[_0x208f96('0x21')]();};}function respondWithResult(_0x17c9f0,_0x249266){return _0x249266=_0x249266||0xc8,function(_0x4bea0d){const _0x2cd9cd=a742_0x3f46;if(_0x4bea0d)return _0x17c9f0[_0x2cd9cd('0x31')](_0x249266)[_0x2cd9cd('0x2a')](_0x4bea0d);};}function respondWithFilteredResult(_0x129f6c,_0x30ea1b){return function(_0x3477b4){const _0x176227=a742_0x3f46;if(_0x3477b4){const _0x1d4190=_0x3477b4[_0x176227('0x32')],_0x3ed40e=_0x30ea1b[_0x176227('0x3a')];let _0x5db0d8=_0x30ea1b[_0x176227('0x3a')]+_0x30ea1b['limit'],_0x5986e6;return _0x5db0d8>=_0x1d4190?(_0x5db0d8=_0x1d4190,_0x5986e6=0xc8):_0x5986e6=0xce,_0x129f6c['status'](_0x5986e6),_0x129f6c[_0x176227('0x34')](_0x176227('0x23'),_0x3ed40e+'-'+_0x5db0d8+'/'+_0x1d4190)[_0x176227('0x2a')](_0x3477b4);}return null;};}function saveUpdates(_0x3684bf){return function(_0x1d3284){const _0x531f7c=a742_0x3f46;if(_0x1d3284)return _0x1d3284['update'](_0x3684bf)[_0x531f7c('0x4b')](function(_0x4a957f){return _0x4a957f;});return null;};}function removeEntity(_0x1c08b7){return function(_0x3ac210){const _0x41a4f5=a742_0x3f46;if(_0x3ac210)return _0x3ac210[_0x41a4f5('0x41')]()[_0x41a4f5('0x4b')](function(){const _0x584c0d=_0x41a4f5,_0x3af300=_0x3ac210[_0x584c0d('0x1e')]({'plain':!![]}),_0x2db939=_0x584c0d('0x4d');return db['UserProfileResource'][_0x584c0d('0x41')]({'where':{'type':_0x2db939,'resourceId':_0x3af300['id']}})['then'](function(){return _0x3ac210;});})[_0x41a4f5('0x4b')](function(){const _0x275150=_0x41a4f5;_0x1c08b7[_0x275150('0x31')](0xcc)[_0x275150('0x21')]();});};}function handleEntityNotFound(_0x1488a2){return function(_0x324001){const _0xb9149e=a742_0x3f46;return!_0x324001&&_0x1488a2[_0xb9149e('0x3')](0x194),_0x324001;};}function handleError(_0x4eb731,_0x2af1ea){return _0x2af1ea=_0x2af1ea||0x1f4,function(_0x2742ac){const _0x1a7140=a742_0x3f46;logger['error'](_0x2742ac[_0x1a7140('0xf')]),_0x2742ac[_0x1a7140('0x9')]&&delete _0x2742ac[_0x1a7140('0x9')],_0x4eb731[_0x1a7140('0x31')](_0x2af1ea)['send'](_0x2742ac);};}exports['index']=function(_0x25d685,_0x3e7093){const _0x41fd27=_0x21cb13;let _0x36f77c={};const _0x49aa46={},_0x2ceb7a={'count':0x0,'rows':[]},_0x30d5b3=_[_0x41fd27('0x3e')](db['VoiceMusicOnHold'][_0x41fd27('0xc')],function(_0x2d5964){const _0x43f80a=_0x41fd27;return{'name':_0x2d5964['fieldName'],'type':_0x2d5964['type'][_0x43f80a('0x27')]};});_0x49aa46['model']=_[_0x41fd27('0x3e')](_0x30d5b3,_0x41fd27('0x9')),_0x49aa46['query']=_[_0x41fd27('0x5')](_0x25d685[_0x41fd27('0x3f')]),_0x49aa46[_0x41fd27('0x7')]=_[_0x41fd27('0x35')](_0x49aa46[_0x41fd27('0x0')],_0x49aa46[_0x41fd27('0x3f')]),_0x36f77c[_0x41fd27('0x33')]=_[_0x41fd27('0x35')](_0x49aa46[_0x41fd27('0x0')],qs['fields'](_0x25d685[_0x41fd27('0x3f')]['fields'])),_0x36f77c[_0x41fd27('0x33')]=_0x36f77c[_0x41fd27('0x33')][_0x41fd27('0xe')]?_0x36f77c[_0x41fd27('0x33')]:_0x49aa46[_0x41fd27('0x0')];typeof _0x25d685[_0x41fd27('0x3f')][_0x41fd27('0x8')]===_0x41fd27('0x3c')&&(_0x36f77c['limit']=qs[_0x41fd27('0x45')](_0x25d685[_0x41fd27('0x3f')][_0x41fd27('0x45')]),_0x36f77c['offset']=qs['offset'](_0x25d685[_0x41fd27('0x3f')]['offset']));_0x36f77c['order']=qs['sort'](_0x25d685['query'][_0x41fd27('0x3d')]),_0x36f77c[_0x41fd27('0x15')]=qs[_0x41fd27('0x7')](_['pick'](_0x25d685[_0x41fd27('0x3f')],_0x49aa46[_0x41fd27('0x7')]),_0x30d5b3);_0x25d685[_0x41fd27('0x3f')][_0x41fd27('0x29')]&&(_0x36f77c[_0x41fd27('0x15')]=_[_0x41fd27('0x4')](_0x36f77c[_0x41fd27('0x15')],{[Op['or']]:_[_0x41fd27('0x3e')](_0x30d5b3,function(_0x34cbfd){const _0x111b7f=_0x41fd27;if(_0x34cbfd['type']!=='VIRTUAL'){const _0x124a6d={};return _0x124a6d[_0x34cbfd[_0x111b7f('0x9')]]={[Op[_0x111b7f('0xd')]]:'%'+_0x25d685['query']['filter']+'%'},_0x124a6d;}})}));_0x36f77c=_[_0x41fd27('0x4')]({},_0x36f77c,_0x25d685[_0x41fd27('0x44')]);const _0x5d8ffd={'where':_0x36f77c[_0x41fd27('0x15')]};return db[_0x41fd27('0x6')]['count'](_0x5d8ffd)[_0x41fd27('0x4b')](function(_0x597230){const _0x44c843=_0x41fd27;return _0x2ceb7a[_0x44c843('0x32')]=_0x597230,_0x25d685[_0x44c843('0x3f')][_0x44c843('0x2c')]&&(_0x36f77c[_0x44c843('0x50')]=[{'all':!![]}]),db[_0x44c843('0x6')]['findAll'](_0x36f77c);})[_0x41fd27('0x4b')](function(_0x2cc5fc){const _0x9bf640=_0x41fd27;return _0x2ceb7a[_0x9bf640('0x14')]=_0x2cc5fc,_0x2ceb7a;})[_0x41fd27('0x4b')](respondWithFilteredResult(_0x3e7093,_0x36f77c))['catch'](handleError(_0x3e7093,null));},exports['show']=function(_0x1b9762,_0x4f5159){const _0x418007=_0x21cb13;let _0x14cc46={'raw':![],'where':{'id':_0x1b9762[_0x418007('0x36')]['id']}};const _0x2ee389={};return _0x2ee389[_0x418007('0x0')]=_['keys'](db[_0x418007('0x6')]['rawAttributes']),_0x2ee389['query']=_['keys'](_0x1b9762[_0x418007('0x3f')]),_0x2ee389[_0x418007('0x7')]=_[_0x418007('0x35')](_0x2ee389['model'],_0x2ee389['query']),_0x14cc46[_0x418007('0x33')]=_['intersection'](_0x2ee389['model'],qs[_0x418007('0x2d')](_0x1b9762[_0x418007('0x3f')][_0x418007('0x2d')])),_0x14cc46[_0x418007('0x33')]=_0x14cc46['attributes'][_0x418007('0xe')]?_0x14cc46['attributes']:_0x2ee389['model'],_0x1b9762['query'][_0x418007('0x2c')]&&(_0x14cc46[_0x418007('0x50')]=[{'all':!![]}]),_0x14cc46=_['merge']({},_0x14cc46,_0x1b9762[_0x418007('0x44')]),db[_0x418007('0x6')][_0x418007('0x42')](_0x14cc46)[_0x418007('0x4b')](handleEntityNotFound(_0x4f5159,null))['then'](respondWithResult(_0x4f5159,null))['catch'](handleError(_0x4f5159,null));},exports[_0x21cb13('0x1d')]=function(_0x193843,_0x1e20d0){const _0x242627=_0x21cb13;return _0x193843['body']['id']&&delete _0x193843[_0x242627('0x37')]['id'],db['VoiceMusicOnHold']['findOne']({'where':{'id':_0x193843[_0x242627('0x36')]['id']}})[_0x242627('0x4b')](handleEntityNotFound(_0x1e20d0,null))['then'](saveUpdates(_0x193843['body'],null))['then'](respondWithResult(_0x1e20d0,null))[_0x242627('0x30')](handleError(_0x1e20d0,null));},exports[_0x21cb13('0x48')]=function(_0x57dc37,_0x206a3c){const _0x380534=_0x21cb13;return db['sequelize'][_0x380534('0x1b')](function(_0x63a93e){const _0x48094b=_0x380534;return _0x57dc37[_0x48094b('0x37')]['mode']==='files'&&(_0x57dc37[_0x48094b('0x37')][_0x48094b('0x4f')]=path[_0x48094b('0x46')](config[_0x48094b('0xa')],_0x48094b('0x28'),_0x57dc37[_0x48094b('0x37')][_0x48094b('0x9')])),db['VoiceMusicOnHold'][_0x48094b('0x48')](_0x57dc37[_0x48094b('0x37')],{'transaction':_0x63a93e})[_0x48094b('0x4b')](function(_0x16c7f9){const _0x16a699=_0x48094b;_0x57dc37[_0x16a699('0x37')][_0x16a699('0x2b')]==='files'&&fs[_0x16a699('0x4a')](_0x16c7f9[_0x16a699('0x4f')],parseInt('0777',0x8));const _0x469d88=_0x57dc37[_0x16a699('0x26')][_0x16a699('0x1e')]({'plain':!![]});if(!_0x469d88)throw new Error(_0x16a699('0x20'));if(_0x469d88[_0x16a699('0x22')]===_0x16a699('0x26')){const _0x5c39c8=_0x16c7f9[_0x16a699('0x1e')]({'plain':!![]});return db[_0x16a699('0x1')]['findOne']({'where':{'name':_0x16a699('0x4d'),'userProfileId':_0x469d88[_0x16a699('0x11')]},'raw':!![]})['then'](function(_0x59ab01){const _0x299882=_0x16a699;return _0x59ab01&&_0x59ab01[_0x299882('0x4c')]===0x0?db[_0x299882('0x10')][_0x299882('0x48')]({'name':_0x5c39c8['name'],'resourceId':_0x5c39c8['id'],'type':_0x59ab01[_0x299882('0x9')],'sectionId':_0x59ab01['id']},{})[_0x299882('0x4b')](function(){return _0x16c7f9;}):_0x16c7f9;})[_0x16a699('0x30')](function(_0x21fd8e){const _0x2e50b2=_0x16a699;logger[_0x2e50b2('0xb')](_0x2e50b2('0x1f'),_0x21fd8e);});}return _0x16c7f9;});})[_0x380534('0x4b')](respondWithResult(_0x206a3c,0xc9))[_0x380534('0x30')](handleError(_0x206a3c,null));},exports[_0x21cb13('0x41')]=function(_0x39222c,_0x4681eb){const _0x50fba8=_0x21cb13;return db[_0x50fba8('0x6')][_0x50fba8('0x42')]({'where':{'id':_0x39222c[_0x50fba8('0x36')]['id']}})['then'](function(_0x4d8cf2){const _0x2c064b=_0x50fba8;if(_0x4d8cf2)return db[_0x2c064b('0x39')][_0x2c064b('0x1b')](function(_0x3c5922){const _0x5a2764=_0x2c064b;return _0x4d8cf2[_0x5a2764('0x41')]({'transaction':_0x3c5922,'raw':!![]})[_0x5a2764('0x4b')](function(_0x3060af){const _0x1ec8c9=_0x5a2764;return _0x3060af[_0x1ec8c9('0x4f')]&&(fs['readdirSync'](_0x3060af[_0x1ec8c9('0x4f')])['forEach'](function(_0x13d5ab){const _0x3bb30d=_0x1ec8c9;fs[_0x3bb30d('0x49')](path['join'](_0x3060af[_0x3bb30d('0x4f')],_0x13d5ab));}),fs[_0x1ec8c9('0x12')](_0x3060af[_0x1ec8c9('0x4f')])),_0x3060af;});})[_0x2c064b('0x30')](function(_0xfeb197){const _0xae6a9a=_0x2c064b;throw new ValidationError(_0xfeb197[_0xae6a9a('0x16')]);});})[_0x50fba8('0x4b')](handleEntityNotFound(_0x4681eb,null))[_0x50fba8('0x4b')](removeEntity(_0x4681eb,null))[_0x50fba8('0x30')](handleError(_0x4681eb,null));},exports['addSound']=function(_0x28e80b,_0x1fabbf){const _0x418e0f=_0x21cb13;return db[_0x418e0f('0x39')][_0x418e0f('0x1b')](function(_0x73ff9e){const _0x5d9a79=_0x418e0f;let _0x1be6d7;return db[_0x5d9a79('0x6')][_0x5d9a79('0x42')]({'where':{'id':_0x28e80b[_0x5d9a79('0x36')]['id']}})[_0x5d9a79('0x4b')](function(_0x19fb81){const _0x49f686=_0x5d9a79;if(_0x19fb81)return _0x1be6d7=_0x19fb81,_0x19fb81[_0x49f686('0x2')](_0x28e80b[_0x49f686('0x37')]['id'],{'transaction':_0x73ff9e});})['then'](function(_0x16471f){const _0x1d492a=_0x5d9a79;if(_0x16471f)return db['Sound'][_0x1d492a('0x42')]({'where':{'id':_0x28e80b[_0x1d492a('0x37')]['id']},'attributes':['id','name','save_name','converted_format',_0x1d492a('0x24')],'raw':!![]});})[_0x5d9a79('0x4b')](function(_0x26cbc2){const _0x34ecda=_0x5d9a79;if(_0x26cbc2){const _0x16823a=path[_0x34ecda('0x46')](config[_0x34ecda('0xa')],'server/files/sounds/converted',util['format']('%s.%s',path[_0x34ecda('0x3b')](_0x26cbc2[_0x34ecda('0x43')],path['extname'](_0x26cbc2[_0x34ecda('0x43')])),_0x26cbc2[_0x34ecda('0x4e')])),_0x14b603=path['join'](config[_0x34ecda('0xa')],_0x34ecda('0x28'),_0x1be6d7['name'],util[_0x34ecda('0x38')](_0x34ecda('0x17'),_0x26cbc2[_0x34ecda('0x9')],_0x26cbc2[_0x34ecda('0x4e')]));return fs[_0x34ecda('0x18')](_0x16823a,_0x14b603),_0x26cbc2;}})[_0x5d9a79('0x30')](function(_0x1ea02b){const _0x185a7a=_0x5d9a79;throw new ValidationError(_0x1ea02b[_0x185a7a('0x16')]);});})[_0x418e0f('0x4b')](handleEntityNotFound(_0x1fabbf,null))['then'](respondWithResult(_0x1fabbf,0xc9))['catch'](handleError(_0x1fabbf,null));},exports[_0x21cb13('0x2f')]=function(_0x43acd6,_0x28d361){const _0x561d78=_0x21cb13;return db[_0x561d78('0x39')][_0x561d78('0x1b')](function(){const _0x10ec49=_0x561d78;let _0x457920;return db[_0x10ec49('0x6')]['findOne']({'where':{'id':_0x43acd6['params']['id']}})[_0x10ec49('0x4b')](handleEntityNotFound(_0x28d361,null))[_0x10ec49('0x4b')](function(_0x151553){const _0x18bd99=_0x10ec49;if(_0x151553)return _0x457920=_0x151553,_0x151553[_0x18bd99('0x2f')](_0x43acd6['params'][_0x18bd99('0x1a')]);})[_0x10ec49('0x4b')](function(_0xcb62a3){const _0x5ab6e5=_0x10ec49;if(_0xcb62a3)return db[_0x5ab6e5('0x1c')][_0x5ab6e5('0x42')]({'where':{'id':_0x43acd6['params'][_0x5ab6e5('0x1a')]},'attributes':['id',_0x5ab6e5('0x9'),_0x5ab6e5('0x43'),'converted_format',_0x5ab6e5('0x24')],'raw':!![]});})[_0x10ec49('0x4b')](function(_0x8645c0){const _0x262a43=_0x10ec49;if(_0x8645c0)return fs[_0x262a43('0x49')](path[_0x262a43('0x46')](_0x457920[_0x262a43('0x4f')],util[_0x262a43('0x38')](_0x262a43('0x17'),_0x8645c0[_0x262a43('0x9')],_0x8645c0[_0x262a43('0x4e')]))),_0x8645c0;})[_0x10ec49('0x30')](function(_0x4eb561){const _0x4bb625=_0x10ec49;throw new ValidationError(_0x4eb561[_0x4bb625('0x16')]);});})['then'](handleEntityNotFound(_0x28d361,null))[_0x561d78('0x4b')](respondWithStatusCode(_0x28d361,0xcc))[_0x561d78('0x30')](handleError(_0x28d361,null));},exports[_0x21cb13('0x47')]=function(_0x20d693,_0x5c62d1){const _0x2bef27=_0x21cb13;let _0x36cffa={};const _0x141f15={};let _0xb48ec7,_0x2294ce;return db['VoiceMusicOnHold'][_0x2bef27('0x42')]({'where':{'id':_0x20d693[_0x2bef27('0x36')]['id']}})[_0x2bef27('0x4b')](handleEntityNotFound(_0x5c62d1,null))[_0x2bef27('0x4b')](function(_0x50f316){const _0x119698=_0x2bef27;if(_0x50f316)return _0xb48ec7=_0x50f316,_0x141f15[_0x119698('0x0')]=_[_0x119698('0x5')](db[_0x119698('0x1c')]['rawAttributes']),_0x141f15[_0x119698('0x3f')]=_['keys'](_0x20d693['query']),_0x141f15[_0x119698('0x7')]=_[_0x119698('0x35')](_0x141f15[_0x119698('0x0')],_0x141f15[_0x119698('0x3f')]),_0x36cffa[_0x119698('0x33')]=_[_0x119698('0x35')](_0x141f15[_0x119698('0x0')],qs['fields'](_0x20d693['query']['fields'])),_0x36cffa[_0x119698('0x33')]=_0x36cffa[_0x119698('0x33')][_0x119698('0xe')]?_0x36cffa[_0x119698('0x33')]:_0x141f15[_0x119698('0x0')],_0x36cffa['order']=qs[_0x119698('0x3d')](_0x20d693[_0x119698('0x3f')][_0x119698('0x3d')]),_0x36cffa[_0x119698('0x15')]=qs[_0x119698('0x7')](_['pick'](_0x20d693[_0x119698('0x3f')],_0x141f15[_0x119698('0x7')])),_0x20d693[_0x119698('0x3f')][_0x119698('0x29')]&&(_0x36cffa[_0x119698('0x15')]=_['merge'](_0x36cffa[_0x119698('0x15')],{[Op['or']]:_[_0x119698('0x3e')](_0x36cffa[_0x119698('0x33')],function(_0xf0379a){const _0x146a96=_0x119698,_0x362d97={};return _0x362d97[_0xf0379a]={[Op[_0x146a96('0xd')]]:'%'+_0x20d693['query'][_0x146a96('0x29')]+'%'},_0x362d97;})})),_0x36cffa=_[_0x119698('0x4')]({},_0x36cffa,_0x20d693['options']),_0xb48ec7[_0x119698('0x47')](_0x36cffa);})[_0x2bef27('0x4b')](function(_0x5b680f){const _0x422776=_0x2bef27;if(_0x5b680f)return _0x2294ce=_0x5b680f['length'],typeof _0x20d693[_0x422776('0x3f')][_0x422776('0x8')]===_0x422776('0x3c')&&(_0x36cffa[_0x422776('0x45')]=qs['limit'](_0x20d693[_0x422776('0x3f')]['limit']),_0x36cffa[_0x422776('0x3a')]=qs['offset'](_0x20d693[_0x422776('0x3f')]['offset'])),_0xb48ec7[_0x422776('0x47')](_0x36cffa);})[_0x2bef27('0x4b')](function(_0x5cd827){if(_0x5cd827)return _0x5cd827?{'count':_0x2294ce,'rows':_0x5cd827}:null;})[_0x2bef27('0x4b')](respondWithResult(_0x5c62d1,null))[_0x2bef27('0x30')](handleError(_0x5c62d1,null));};
\ No newline at end of file
+const a742_0xdec1=['sort','count','UserProfileResource','server/files/moh','lodash','show','autoAssociation','order','fields','intersection','root','error','status','stack','fieldName','VoiceMusicOnHold','readdirSync','server/files/sounds/converted','query','include','filters','attributes','nolimit','unlinkSync','message','name','length','Sound','path','offset','map','UserProfileSection','0777','extname','join','getSounds','sendStatus','createdAt','directory','format','pick','then','body','role','undefined','like','keys','rawAttributes','key','index','filter','includeAll','findOne','symlinkSync','send','removeSound','findAll','type','converted_format','set','files','api','addSound','create','mkdirSync','merge','Content-Range','destroy','params','util','limit','user','json','forEach','get','sequelize','where','options','transaction','MusicOnHolds','%s.%s','save_name','catch','end','rmdirSync','VIRTUAL','model','update','id2'];(function(_0x55bb1e,_0xdec1f1){const _0x335301=function(_0x5a019d){while(--_0x5a019d){_0x55bb1e['push'](_0x55bb1e['shift']());}};_0x335301(++_0xdec1f1);}(a742_0xdec1,0x1cd));const a742_0x3353=function(_0x55bb1e,_0xdec1f1){_0x55bb1e=_0x55bb1e-0x0;let _0x335301=a742_0xdec1[_0x55bb1e];return _0x335301;};const _0x3bbf63=a742_0x3353;'use strict';const util=require(_0x3bbf63('0x35')),path=require(_0x3bbf63('0xc')),fs=require('fs'),_=require(_0x3bbf63('0x4d')),qs=require('../../components/parsers/qs'),logger=require('../../config/logger')(_0x3bbf63('0x2d')),config=require('../../config/environment'),db=require('../../mysqldb')['db'],{Op,ValidationError}=require(_0x3bbf63('0x3b'));function respondWithStatusCode(_0x5a019d,_0x599193){return _0x599193=_0x599193||0xcc,function(_0x47a952){const _0x519c5e=a742_0x3353;if(_0x47a952)return _0x5a019d[_0x519c5e('0x14')](_0x599193);return _0x5a019d[_0x519c5e('0x55')](_0x599193)['end']();};}function respondWithResult(_0x1dbb0b,_0x12f86f){return _0x12f86f=_0x12f86f||0xc8,function(_0x226e47){const _0x55cd49=a742_0x3353;if(_0x226e47)return _0x1dbb0b['status'](_0x12f86f)[_0x55cd49('0x38')](_0x226e47);};}function respondWithFilteredResult(_0x49e1c0,_0x226a2e){return function(_0xe6e3f4){const _0x723f48=a742_0x3353;if(_0xe6e3f4){const _0x4cab84=_0xe6e3f4[_0x723f48('0x4a')],_0x2ad222=_0x226a2e[_0x723f48('0xd')];let _0x4ac073=_0x226a2e[_0x723f48('0xd')]+_0x226a2e['limit'],_0x1f9efe;return _0x4ac073>=_0x4cab84?(_0x4ac073=_0x4cab84,_0x1f9efe=0xc8):_0x1f9efe=0xce,_0x49e1c0[_0x723f48('0x55')](_0x1f9efe),_0x49e1c0[_0x723f48('0x2b')](_0x723f48('0x32'),_0x2ad222+'-'+_0x4ac073+'/'+_0x4cab84)[_0x723f48('0x38')](_0xe6e3f4);}return null;};}function saveUpdates(_0x30ec14){return function(_0x2d459a){const _0x17424c=a742_0x3353;if(_0x2d459a)return _0x2d459a[_0x17424c('0x47')](_0x30ec14)[_0x17424c('0x19')](function(_0x32f2bc){return _0x32f2bc;});return null;};}function removeEntity(_0x43e89b){return function(_0x2aafaf){const _0x44c7de=a742_0x3353;if(_0x2aafaf)return _0x2aafaf[_0x44c7de('0x33')]()[_0x44c7de('0x19')](function(){const _0x1391e6=_0x44c7de,_0x4aedb2=_0x2aafaf['get']({'plain':!![]}),_0x1ed0e3=_0x1391e6('0x3f');return db[_0x1391e6('0x4b')]['destroy']({'where':{'type':_0x1ed0e3,'resourceId':_0x4aedb2['id']}})[_0x1391e6('0x19')](function(){return _0x2aafaf;});})['then'](function(){const _0x5e0597=_0x44c7de;_0x43e89b['status'](0xcc)[_0x5e0597('0x43')]();});};}function handleEntityNotFound(_0x2c7e15){return function(_0x194cb7){const _0x1911cd=a742_0x3353;return!_0x194cb7&&_0x2c7e15[_0x1911cd('0x14')](0x194),_0x194cb7;};}function handleError(_0x31a952,_0xde9e6){return _0xde9e6=_0xde9e6||0x1f4,function(_0xda3273){const _0x3c48de=a742_0x3353;logger[_0x3c48de('0x54')](_0xda3273[_0x3c48de('0x56')]),_0xda3273[_0x3c48de('0x9')]&&delete _0xda3273[_0x3c48de('0x9')],_0x31a952[_0x3c48de('0x55')](_0xde9e6)[_0x3c48de('0x26')](_0xda3273);};}exports[_0x3bbf63('0x21')]=function(_0x434658,_0x2a943e){const _0x2f6e03=_0x3bbf63;let _0x591b47={};const _0x416c42={},_0x109589={'count':0x0,'rows':[]},_0x44ce2c=_[_0x2f6e03('0xe')](db[_0x2f6e03('0x58')]['rawAttributes'],function(_0x16e019){const _0x1fac86=_0x2f6e03;return{'name':_0x16e019[_0x1fac86('0x57')],'type':_0x16e019[_0x1fac86('0x29')][_0x1fac86('0x20')]};});_0x416c42[_0x2f6e03('0x46')]=_[_0x2f6e03('0xe')](_0x44ce2c,_0x2f6e03('0x9')),_0x416c42[_0x2f6e03('0x2')]=_[_0x2f6e03('0x1e')](_0x434658['query']),_0x416c42[_0x2f6e03('0x4')]=_['intersection'](_0x416c42['model'],_0x416c42[_0x2f6e03('0x2')]),_0x591b47[_0x2f6e03('0x5')]=_[_0x2f6e03('0x52')](_0x416c42[_0x2f6e03('0x46')],qs['fields'](_0x434658[_0x2f6e03('0x2')][_0x2f6e03('0x51')])),_0x591b47[_0x2f6e03('0x5')]=_0x591b47[_0x2f6e03('0x5')][_0x2f6e03('0xa')]?_0x591b47[_0x2f6e03('0x5')]:_0x416c42['model'];typeof _0x434658['query'][_0x2f6e03('0x6')]===_0x2f6e03('0x1c')&&(_0x591b47[_0x2f6e03('0x36')]=qs['limit'](_0x434658[_0x2f6e03('0x2')][_0x2f6e03('0x36')]),_0x591b47[_0x2f6e03('0xd')]=qs[_0x2f6e03('0xd')](_0x434658[_0x2f6e03('0x2')]['offset']));_0x591b47[_0x2f6e03('0x50')]=qs[_0x2f6e03('0x49')](_0x434658[_0x2f6e03('0x2')][_0x2f6e03('0x49')]),_0x591b47[_0x2f6e03('0x3c')]=qs[_0x2f6e03('0x4')](_[_0x2f6e03('0x18')](_0x434658[_0x2f6e03('0x2')],_0x416c42[_0x2f6e03('0x4')]),_0x44ce2c);_0x434658[_0x2f6e03('0x2')][_0x2f6e03('0x22')]&&(_0x591b47[_0x2f6e03('0x3c')]=_[_0x2f6e03('0x31')](_0x591b47[_0x2f6e03('0x3c')],{[Op['or']]:_[_0x2f6e03('0xe')](_0x44ce2c,function(_0x3e40f3){const _0x530fda=_0x2f6e03;if(_0x3e40f3[_0x530fda('0x29')]!==_0x530fda('0x45')){const _0x15e510={};return _0x15e510[_0x3e40f3[_0x530fda('0x9')]]={[Op[_0x530fda('0x1d')]]:'%'+_0x434658[_0x530fda('0x2')][_0x530fda('0x22')]+'%'},_0x15e510;}})}));_0x591b47=_[_0x2f6e03('0x31')]({},_0x591b47,_0x434658[_0x2f6e03('0x3d')]);const _0x4bf382={'where':_0x591b47[_0x2f6e03('0x3c')]};return db['VoiceMusicOnHold'][_0x2f6e03('0x4a')](_0x4bf382)[_0x2f6e03('0x19')](function(_0x31ea86){const _0x20a887=_0x2f6e03;return _0x109589[_0x20a887('0x4a')]=_0x31ea86,_0x434658[_0x20a887('0x2')][_0x20a887('0x23')]&&(_0x591b47[_0x20a887('0x3')]=[{'all':!![]}]),db[_0x20a887('0x58')][_0x20a887('0x28')](_0x591b47);})[_0x2f6e03('0x19')](function(_0x43d2ee){return _0x109589['rows']=_0x43d2ee,_0x109589;})[_0x2f6e03('0x19')](respondWithFilteredResult(_0x2a943e,_0x591b47))['catch'](handleError(_0x2a943e,null));},exports[_0x3bbf63('0x4e')]=function(_0x362f2b,_0x597030){const _0x5fe4e6=_0x3bbf63;let _0x1b362c={'raw':![],'where':{'id':_0x362f2b['params']['id']}};const _0x398977={};return _0x398977[_0x5fe4e6('0x46')]=_[_0x5fe4e6('0x1e')](db['VoiceMusicOnHold'][_0x5fe4e6('0x1f')]),_0x398977[_0x5fe4e6('0x2')]=_[_0x5fe4e6('0x1e')](_0x362f2b[_0x5fe4e6('0x2')]),_0x398977[_0x5fe4e6('0x4')]=_[_0x5fe4e6('0x52')](_0x398977[_0x5fe4e6('0x46')],_0x398977[_0x5fe4e6('0x2')]),_0x1b362c[_0x5fe4e6('0x5')]=_[_0x5fe4e6('0x52')](_0x398977['model'],qs[_0x5fe4e6('0x51')](_0x362f2b[_0x5fe4e6('0x2')]['fields'])),_0x1b362c[_0x5fe4e6('0x5')]=_0x1b362c['attributes']['length']?_0x1b362c[_0x5fe4e6('0x5')]:_0x398977[_0x5fe4e6('0x46')],_0x362f2b[_0x5fe4e6('0x2')][_0x5fe4e6('0x23')]&&(_0x1b362c[_0x5fe4e6('0x3')]=[{'all':!![]}]),_0x1b362c=_['merge']({},_0x1b362c,_0x362f2b[_0x5fe4e6('0x3d')]),db[_0x5fe4e6('0x58')][_0x5fe4e6('0x24')](_0x1b362c)['then'](handleEntityNotFound(_0x597030,null))[_0x5fe4e6('0x19')](respondWithResult(_0x597030,null))['catch'](handleError(_0x597030,null));},exports[_0x3bbf63('0x47')]=function(_0x97989e,_0x27546d){const _0x52fc49=_0x3bbf63;return _0x97989e[_0x52fc49('0x1a')]['id']&&delete _0x97989e['body']['id'],db[_0x52fc49('0x58')]['findOne']({'where':{'id':_0x97989e[_0x52fc49('0x34')]['id']}})['then'](handleEntityNotFound(_0x27546d,null))['then'](saveUpdates(_0x97989e[_0x52fc49('0x1a')],null))[_0x52fc49('0x19')](respondWithResult(_0x27546d,null))['catch'](handleError(_0x27546d,null));},exports[_0x3bbf63('0x2f')]=function(_0x4db143,_0x24e843){const _0x4d1ad2=_0x3bbf63;return db[_0x4d1ad2('0x3b')][_0x4d1ad2('0x3e')](function(_0x53b5e9){const _0x5ab225=_0x4d1ad2;return _0x4db143[_0x5ab225('0x1a')]['mode']===_0x5ab225('0x2c')&&(_0x4db143[_0x5ab225('0x1a')][_0x5ab225('0x16')]=path['join'](config[_0x5ab225('0x53')],_0x5ab225('0x4c'),_0x4db143[_0x5ab225('0x1a')][_0x5ab225('0x9')])),db[_0x5ab225('0x58')][_0x5ab225('0x2f')](_0x4db143['body'],{'transaction':_0x53b5e9})[_0x5ab225('0x19')](function(_0x188aba){const _0x32259c=_0x5ab225;_0x4db143[_0x32259c('0x1a')]['mode']===_0x32259c('0x2c')&&fs[_0x32259c('0x30')](_0x188aba[_0x32259c('0x16')],parseInt(_0x32259c('0x10'),0x8));const _0x1b03de=_0x4db143[_0x32259c('0x37')][_0x32259c('0x3a')]({'plain':!![]});if(!_0x1b03de)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1b03de[_0x32259c('0x1b')]===_0x32259c('0x37')){const _0x16314f=_0x188aba[_0x32259c('0x3a')]({'plain':!![]});return db[_0x32259c('0xf')]['findOne']({'where':{'name':'MusicOnHolds','userProfileId':_0x1b03de['userProfileId']},'raw':!![]})[_0x32259c('0x19')](function(_0xce65d){const _0x261d40=_0x32259c;return _0xce65d&&_0xce65d[_0x261d40('0x4f')]===0x0?db['UserProfileResource']['create']({'name':_0x16314f[_0x261d40('0x9')],'resourceId':_0x16314f['id'],'type':_0xce65d[_0x261d40('0x9')],'sectionId':_0xce65d['id']},{})[_0x261d40('0x19')](function(){return _0x188aba;}):_0x188aba;})[_0x32259c('0x42')](function(_0x1e9d83){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1e9d83);});}return _0x188aba;});})['then'](respondWithResult(_0x24e843,0xc9))[_0x4d1ad2('0x42')](handleError(_0x24e843,null));},exports[_0x3bbf63('0x33')]=function(_0x35bfaf,_0xa7b218){const _0x15a080=_0x3bbf63;return db[_0x15a080('0x58')][_0x15a080('0x24')]({'where':{'id':_0x35bfaf['params']['id']}})[_0x15a080('0x19')](function(_0x1a5042){const _0x435777=_0x15a080;if(_0x1a5042)return db[_0x435777('0x3b')][_0x435777('0x3e')](function(_0x51cdfc){const _0x1c6c05=_0x435777;return _0x1a5042[_0x1c6c05('0x33')]({'transaction':_0x51cdfc,'raw':!![]})['then'](function(_0x5cb74a){const _0x320e78=_0x1c6c05;return _0x5cb74a[_0x320e78('0x16')]&&(fs[_0x320e78('0x0')](_0x5cb74a['directory'])[_0x320e78('0x39')](function(_0x181514){const _0x9a028d=_0x320e78;fs[_0x9a028d('0x7')](path[_0x9a028d('0x12')](_0x5cb74a[_0x9a028d('0x16')],_0x181514));}),fs[_0x320e78('0x44')](_0x5cb74a[_0x320e78('0x16')])),_0x5cb74a;});})[_0x435777('0x42')](function(_0x3e4788){throw new ValidationError(_0x3e4788['message']);});})[_0x15a080('0x19')](handleEntityNotFound(_0xa7b218,null))[_0x15a080('0x19')](removeEntity(_0xa7b218,null))[_0x15a080('0x42')](handleError(_0xa7b218,null));},exports[_0x3bbf63('0x2e')]=function(_0xd5af15,_0xe07caa){const _0x4daef1=_0x3bbf63;return db['sequelize'][_0x4daef1('0x3e')](function(_0x2b3d1f){const _0x27c16e=_0x4daef1;let _0x52431e;return db[_0x27c16e('0x58')][_0x27c16e('0x24')]({'where':{'id':_0xd5af15[_0x27c16e('0x34')]['id']}})[_0x27c16e('0x19')](function(_0x47b2c0){const _0x35c200=_0x27c16e;if(_0x47b2c0)return _0x52431e=_0x47b2c0,_0x47b2c0[_0x35c200('0x2e')](_0xd5af15['body']['id'],{'transaction':_0x2b3d1f});})[_0x27c16e('0x19')](function(_0x11a683){const _0x572f43=_0x27c16e;if(_0x11a683)return db[_0x572f43('0xb')][_0x572f43('0x24')]({'where':{'id':_0xd5af15[_0x572f43('0x1a')]['id']},'attributes':['id',_0x572f43('0x9'),_0x572f43('0x41'),_0x572f43('0x2a'),_0x572f43('0x15')],'raw':!![]});})[_0x27c16e('0x19')](function(_0x10ca99){const _0x45a7d1=_0x27c16e;if(_0x10ca99){const _0x53c22d=path[_0x45a7d1('0x12')](config[_0x45a7d1('0x53')],_0x45a7d1('0x1'),util['format'](_0x45a7d1('0x40'),path['basename'](_0x10ca99['save_name'],path[_0x45a7d1('0x11')](_0x10ca99[_0x45a7d1('0x41')])),_0x10ca99['converted_format'])),_0x523bc0=path[_0x45a7d1('0x12')](config[_0x45a7d1('0x53')],_0x45a7d1('0x4c'),_0x52431e[_0x45a7d1('0x9')],util[_0x45a7d1('0x17')]('%s.%s',_0x10ca99[_0x45a7d1('0x9')],_0x10ca99[_0x45a7d1('0x2a')]));return fs[_0x45a7d1('0x25')](_0x53c22d,_0x523bc0),_0x10ca99;}})[_0x27c16e('0x42')](function(_0x90db9a){const _0x5ba133=_0x27c16e;throw new ValidationError(_0x90db9a[_0x5ba133('0x8')]);});})[_0x4daef1('0x19')](handleEntityNotFound(_0xe07caa,null))[_0x4daef1('0x19')](respondWithResult(_0xe07caa,0xc9))[_0x4daef1('0x42')](handleError(_0xe07caa,null));},exports[_0x3bbf63('0x27')]=function(_0x1a5a12,_0x2109e8){const _0x590645=_0x3bbf63;return db['sequelize'][_0x590645('0x3e')](function(){const _0x5c211b=_0x590645;let _0x59e281;return db[_0x5c211b('0x58')]['findOne']({'where':{'id':_0x1a5a12[_0x5c211b('0x34')]['id']}})['then'](handleEntityNotFound(_0x2109e8,null))[_0x5c211b('0x19')](function(_0x296eea){const _0x566d89=_0x5c211b;if(_0x296eea)return _0x59e281=_0x296eea,_0x296eea['removeSound'](_0x1a5a12[_0x566d89('0x34')][_0x566d89('0x48')]);})[_0x5c211b('0x19')](function(_0x4c7df0){const _0x1c56eb=_0x5c211b;if(_0x4c7df0)return db[_0x1c56eb('0xb')][_0x1c56eb('0x24')]({'where':{'id':_0x1a5a12[_0x1c56eb('0x34')][_0x1c56eb('0x48')]},'attributes':['id',_0x1c56eb('0x9'),_0x1c56eb('0x41'),'converted_format',_0x1c56eb('0x15')],'raw':!![]});})[_0x5c211b('0x19')](function(_0x8bd11f){const _0x2db9ab=_0x5c211b;if(_0x8bd11f)return fs[_0x2db9ab('0x7')](path['join'](_0x59e281[_0x2db9ab('0x16')],util['format']('%s.%s',_0x8bd11f['name'],_0x8bd11f[_0x2db9ab('0x2a')]))),_0x8bd11f;})[_0x5c211b('0x42')](function(_0x3e3548){throw new ValidationError(_0x3e3548['message']);});})[_0x590645('0x19')](handleEntityNotFound(_0x2109e8,null))[_0x590645('0x19')](respondWithStatusCode(_0x2109e8,0xcc))[_0x590645('0x42')](handleError(_0x2109e8,null));},exports[_0x3bbf63('0x13')]=function(_0x108be5,_0x2b673b){const _0x24fac0=_0x3bbf63;let _0x5156a1={};const _0x1792f2={};let _0x210ec6,_0x141093;return db[_0x24fac0('0x58')][_0x24fac0('0x24')]({'where':{'id':_0x108be5['params']['id']}})[_0x24fac0('0x19')](handleEntityNotFound(_0x2b673b,null))['then'](function(_0x45d023){const _0x22009a=_0x24fac0;if(_0x45d023)return _0x210ec6=_0x45d023,_0x1792f2['model']=_[_0x22009a('0x1e')](db[_0x22009a('0xb')]['rawAttributes']),_0x1792f2[_0x22009a('0x2')]=_[_0x22009a('0x1e')](_0x108be5['query']),_0x1792f2[_0x22009a('0x4')]=_[_0x22009a('0x52')](_0x1792f2['model'],_0x1792f2['query']),_0x5156a1['attributes']=_[_0x22009a('0x52')](_0x1792f2[_0x22009a('0x46')],qs[_0x22009a('0x51')](_0x108be5[_0x22009a('0x2')]['fields'])),_0x5156a1[_0x22009a('0x5')]=_0x5156a1[_0x22009a('0x5')][_0x22009a('0xa')]?_0x5156a1[_0x22009a('0x5')]:_0x1792f2[_0x22009a('0x46')],_0x5156a1['order']=qs[_0x22009a('0x49')](_0x108be5[_0x22009a('0x2')][_0x22009a('0x49')]),_0x5156a1[_0x22009a('0x3c')]=qs[_0x22009a('0x4')](_[_0x22009a('0x18')](_0x108be5['query'],_0x1792f2[_0x22009a('0x4')])),_0x108be5[_0x22009a('0x2')][_0x22009a('0x22')]&&(_0x5156a1[_0x22009a('0x3c')]=_['merge'](_0x5156a1['where'],{[Op['or']]:_['map'](_0x5156a1['attributes'],function(_0x43313d){const _0x5da130=_0x22009a,_0x24782b={};return _0x24782b[_0x43313d]={[Op[_0x5da130('0x1d')]]:'%'+_0x108be5[_0x5da130('0x2')][_0x5da130('0x22')]+'%'},_0x24782b;})})),_0x5156a1=_['merge']({},_0x5156a1,_0x108be5[_0x22009a('0x3d')]),_0x210ec6[_0x22009a('0x13')](_0x5156a1);})[_0x24fac0('0x19')](function(_0x728e4e){const _0x5af97f=_0x24fac0;if(_0x728e4e)return _0x141093=_0x728e4e[_0x5af97f('0xa')],typeof _0x108be5[_0x5af97f('0x2')][_0x5af97f('0x6')]===_0x5af97f('0x1c')&&(_0x5156a1[_0x5af97f('0x36')]=qs[_0x5af97f('0x36')](_0x108be5['query'][_0x5af97f('0x36')]),_0x5156a1[_0x5af97f('0xd')]=qs['offset'](_0x108be5[_0x5af97f('0x2')][_0x5af97f('0xd')])),_0x210ec6[_0x5af97f('0x13')](_0x5156a1);})[_0x24fac0('0x19')](function(_0x3a1ed8){if(_0x3a1ed8)return _0x3a1ed8?{'count':_0x141093,'rows':_0x3a1ed8}:null;})['then'](respondWithResult(_0x2b673b,null))[_0x24fac0('0x42')](handleError(_0x2b673b,null));};
\ No newline at end of file