f5a490bc451ff9e73daa0238af3e44ad8c1f3ea7
[motion-next.git] / server / api / voiceMailMessage / voiceMailMessage.controller.js
1 const a738_0x33a0=['set','length','send','destroy','where','include','limit','merge','rawAttributes','attributes','filters','name','VIRTUAL','create','VoiceMailMessage\x20not\x20found','params','model','fieldName','attachment;\x20filename=\x22','../../config/logger','then','options','update','like','VoiceMailMessage','download','offset','pick','findOne','Content-Range','msg_id','filter','catch','key','sequelize','count','keys','fields','type','status','differenceBy','from','intersection','query','includeAll','stack','rows','body','../../components/parsers/qs','json','end','index','../../mysqldb','.wav\x22','map','order','recording'];(function(_0x2afe89,_0x33a02a){const _0x4ead81=function(_0x5ae4d4){while(--_0x5ae4d4){_0x2afe89['push'](_0x2afe89['shift']());}};_0x4ead81(++_0x33a02a);}(a738_0x33a0,0x78));const a738_0x4ead=function(_0x2afe89,_0x33a02a){_0x2afe89=_0x2afe89-0x0;let _0x4ead81=a738_0x33a0[_0x2afe89];return _0x4ead81;};const _0x4cf434=a738_0x4ead;'use strict';const _=require('lodash'),qs=require(_0x4cf434('0x2a')),logger=require(_0x4cf434('0xd'))('api'),db=require(_0x4cf434('0x2e'))['db'],{Op,ValidationError}=require(_0x4cf434('0x1c'));function respondWithResult(_0x5ae4d4,_0x2d97d7){return _0x2d97d7=_0x2d97d7||0xc8,function(_0x30673f){const _0x27604c=a738_0x4ead;if(_0x30673f)return _0x5ae4d4['status'](_0x2d97d7)[_0x27604c('0x2b')](_0x30673f);};}function respondWithFilteredResult(_0x5a73d1,_0x55e72a){return function(_0x3a7646){const _0x52c3a3=a738_0x4ead;if(_0x3a7646){const _0x58defc=_0x3a7646['count'],_0xf6fd18=_0x55e72a['offset'];let _0x3e2526=_0x55e72a['offset']+_0x55e72a[_0x52c3a3('0x0')],_0x52e849;return _0x3e2526>=_0x58defc?(_0x3e2526=_0x58defc,_0x52e849=0xc8):_0x52e849=0xce,_0x5a73d1[_0x52c3a3('0x21')](_0x52e849),_0x5a73d1[_0x52c3a3('0x33')](_0x52c3a3('0x17'),_0xf6fd18+'-'+_0x3e2526+'/'+_0x58defc)[_0x52c3a3('0x2b')](_0x3a7646);}return null;};}function saveUpdates(_0x45ca7d){return function(_0x4e2858){const _0x28583b=a738_0x4ead;if(_0x4e2858)return _0x4e2858[_0x28583b('0x10')](_0x45ca7d)['then'](function(_0x39fd6c){return _0x39fd6c;});return null;};}function removeEntity(_0xbea64c){return function(_0x49d316){const _0x514a9a=a738_0x4ead;if(_0x49d316)return _0x49d316[_0x514a9a('0x36')]()['then'](function(){const _0x53b426=_0x514a9a;_0xbea64c[_0x53b426('0x21')](0xcc)[_0x53b426('0x2c')]();});};}function handleEntityNotFound(_0x1f4984){return function(_0x59126d){return!_0x59126d&&_0x1f4984['sendStatus'](0x194),_0x59126d;};}function handleError(_0x41d2ed,_0x2cf78d){return _0x2cf78d=_0x2cf78d||0x1f4,function(_0x453177){const _0x3f54e7=a738_0x4ead;logger['error'](_0x453177[_0x3f54e7('0x27')]),_0x453177[_0x3f54e7('0x5')]&&delete _0x453177[_0x3f54e7('0x5')],_0x41d2ed[_0x3f54e7('0x21')](_0x2cf78d)[_0x3f54e7('0x35')](_0x453177);};}exports[_0x4cf434('0x2d')]=function(_0x356c62,_0x252278){const _0x4aa65b=_0x4cf434;let _0x530aa2={};const _0x403cb9={},_0x3f048e={'count':0x0,'rows':[]},_0x3d94d6=_[_0x4aa65b('0x30')](db['VoiceMailMessage'][_0x4aa65b('0x2')],function(_0x244cf7){const _0x341b07=_0x4aa65b;return{'name':_0x244cf7[_0x341b07('0xb')],'type':_0x244cf7['type'][_0x341b07('0x1b')]};});_0x403cb9[_0x4aa65b('0xa')]=_[_0x4aa65b('0x22')](_[_0x4aa65b('0x30')](_0x3d94d6,_0x4aa65b('0x5')),[_0x4aa65b('0x5')]),_0x403cb9[_0x4aa65b('0x25')]=_[_0x4aa65b('0x1e')](_0x356c62[_0x4aa65b('0x25')]),_0x403cb9[_0x4aa65b('0x4')]=_[_0x4aa65b('0x24')](_0x403cb9['model'],_0x403cb9['query']),_0x530aa2['attributes']=_[_0x4aa65b('0x24')](_0x403cb9[_0x4aa65b('0xa')],qs[_0x4aa65b('0x1f')](_0x356c62['query'][_0x4aa65b('0x1f')])),_0x530aa2[_0x4aa65b('0x3')]=_0x530aa2[_0x4aa65b('0x3')][_0x4aa65b('0x34')]?_0x530aa2['attributes']:_0x403cb9[_0x4aa65b('0xa')];typeof _0x356c62[_0x4aa65b('0x25')]['nolimit']==='undefined'&&(_0x530aa2[_0x4aa65b('0x0')]=qs[_0x4aa65b('0x0')](_0x356c62[_0x4aa65b('0x25')][_0x4aa65b('0x0')]),_0x530aa2[_0x4aa65b('0x14')]=qs[_0x4aa65b('0x14')](_0x356c62['query'][_0x4aa65b('0x14')]));_0x530aa2[_0x4aa65b('0x31')]=qs['sort'](_0x356c62[_0x4aa65b('0x25')]['sort']),_0x530aa2[_0x4aa65b('0x37')]=qs[_0x4aa65b('0x4')](_[_0x4aa65b('0x15')](_0x356c62[_0x4aa65b('0x25')],_0x403cb9['filters']),_0x3d94d6);_0x356c62[_0x4aa65b('0x25')][_0x4aa65b('0x19')]&&(_0x530aa2['where']=_[_0x4aa65b('0x1')](_0x530aa2[_0x4aa65b('0x37')],{[Op['or']]:_[_0x4aa65b('0x30')](_0x3d94d6,function(_0x595f67){const _0x39a5b5=_0x4aa65b;if(_0x595f67[_0x39a5b5('0x20')]!==_0x39a5b5('0x6')){const _0x586c19={};return _0x586c19[_0x595f67[_0x39a5b5('0x5')]]={[Op[_0x39a5b5('0x11')]]:'%'+_0x356c62[_0x39a5b5('0x25')][_0x39a5b5('0x19')]+'%'},_0x586c19;}})}));_0x530aa2=_[_0x4aa65b('0x1')]({},_0x530aa2,_0x356c62[_0x4aa65b('0xf')]);const _0x432d50={'where':_0x530aa2[_0x4aa65b('0x37')]};return db[_0x4aa65b('0x12')][_0x4aa65b('0x1d')](_0x432d50)[_0x4aa65b('0xe')](function(_0x57a156){const _0x153d01=_0x4aa65b;return _0x3f048e[_0x153d01('0x1d')]=_0x57a156,_0x356c62[_0x153d01('0x25')][_0x153d01('0x26')]&&(_0x530aa2[_0x153d01('0x38')]=[{'all':!![]}]),db[_0x153d01('0x12')]['findAll'](_0x530aa2);})[_0x4aa65b('0xe')](function(_0xa4dcc8){const _0x55e4e3=_0x4aa65b;return _0x3f048e[_0x55e4e3('0x28')]=_0xa4dcc8,_0x3f048e;})[_0x4aa65b('0xe')](respondWithFilteredResult(_0x252278,_0x530aa2))[_0x4aa65b('0x1a')](handleError(_0x252278,null));},exports['show']=function(_0x3b5c9e,_0x21f2e5){const _0x22d402=_0x4cf434;let _0x16135a={'raw':!![],'where':{'id':_0x3b5c9e['params']['id']}};const _0x4f4f01={};return _0x4f4f01[_0x22d402('0xa')]=_[_0x22d402('0x1e')](db[_0x22d402('0x12')][_0x22d402('0x2')]),_0x4f4f01['query']=_[_0x22d402('0x1e')](_0x3b5c9e[_0x22d402('0x25')]),_0x4f4f01[_0x22d402('0x4')]=_[_0x22d402('0x24')](_0x4f4f01[_0x22d402('0xa')],_0x4f4f01[_0x22d402('0x25')]),_0x16135a[_0x22d402('0x3')]=_[_0x22d402('0x24')](_0x4f4f01[_0x22d402('0xa')],qs[_0x22d402('0x1f')](_0x3b5c9e['query']['fields'])),_0x16135a[_0x22d402('0x3')]=_0x16135a[_0x22d402('0x3')]['length']?_0x16135a[_0x22d402('0x3')]:_0x4f4f01[_0x22d402('0xa')],_0x3b5c9e[_0x22d402('0x25')][_0x22d402('0x26')]&&(_0x16135a[_0x22d402('0x38')]=[{'all':!![]}]),_0x16135a=_[_0x22d402('0x1')]({},_0x16135a,_0x3b5c9e['options']),db[_0x22d402('0x12')][_0x22d402('0x16')](_0x16135a)[_0x22d402('0xe')](handleEntityNotFound(_0x21f2e5,null))['then'](respondWithResult(_0x21f2e5,null))[_0x22d402('0x1a')](handleError(_0x21f2e5,null));},exports['create']=function(_0x975317,_0x33ec44){const _0x163b74=_0x4cf434;return db[_0x163b74('0x12')][_0x163b74('0x7')](_0x975317['body'],{})['then'](respondWithResult(_0x33ec44,0xc9))[_0x163b74('0x1a')](handleError(_0x33ec44,null));},exports[_0x4cf434('0x10')]=function(_0x530f6b,_0xf5d97b){const _0x3a4595=_0x4cf434;return _0x530f6b['body']['id']&&delete _0x530f6b[_0x3a4595('0x29')]['id'],db[_0x3a4595('0x12')][_0x3a4595('0x16')]({'where':{'id':_0x530f6b[_0x3a4595('0x9')]['id']}})[_0x3a4595('0xe')](handleEntityNotFound(_0xf5d97b,null))[_0x3a4595('0xe')](saveUpdates(_0x530f6b['body'],null))['then'](respondWithResult(_0xf5d97b,null))[_0x3a4595('0x1a')](handleError(_0xf5d97b,null));},exports['destroy']=function(_0x77f1a3,_0x4f4241){const _0x2cafea=_0x4cf434;return db['VoiceMailMessage'][_0x2cafea('0x16')]({'where':{'id':_0x77f1a3[_0x2cafea('0x9')]['id']}})['then'](handleEntityNotFound(_0x4f4241,null))['then'](removeEntity(_0x4f4241,null))['catch'](handleError(_0x4f4241,null));},exports[_0x4cf434('0x13')]=function(_0x274058,_0x58bc22){const _0x1baf68=_0x4cf434;return db[_0x1baf68('0x12')][_0x1baf68('0x16')]({'where':{'id':_0x274058[_0x1baf68('0x9')]['id']},'attributes':['id','recording',_0x1baf68('0x18')]})['then'](handleEntityNotFound(_0x58bc22,null))[_0x1baf68('0xe')](function(_0x4fbdc0){const _0x1d7cb5=_0x1baf68;if(_0x4fbdc0){if(!_0x4fbdc0[_0x1d7cb5('0x32')])throw new ValidationError(_0x1d7cb5('0x8'));const _0x41e5f0={'Content-Type':'audio/wav','Content-Disposition':'attachment'};return _0x4fbdc0[_0x1d7cb5('0x18')]&&(_0x41e5f0['Content-Disposition']=_0x1d7cb5('0xc')+_0x4fbdc0['msg_id']+_0x1d7cb5('0x2f')),_0x58bc22['set'](_0x41e5f0),_0x58bc22[_0x1d7cb5('0x35')](Buffer[_0x1d7cb5('0x23')](_0x4fbdc0['recording']));}})[_0x1baf68('0x1a')](handleError(_0x58bc22,null));};