e83e846f553ebab4468d9b0824cfdc978894a98d
[motion-next.git] / server / api / voiceMailMessage / voiceMailMessage.controller.js
1 const a738_0x1b3c=['msg_id','query','order','catch','type','offset','rows','attachment','pick','json','send','api','VoiceMailMessage\x20not\x20found','fields','model','include','like','params','../../components/parsers/qs','lodash','VoiceMailMessage','count','rawAttributes','set','findOne','end','Content-Range','create','intersection','../../mysqldb','name','sendStatus','limit','options','length','status','key','destroy','where','show','recording','merge','sequelize','then','findAll','keys','from','includeAll','sort','update','filters','map','attributes','filter','attachment;\x20filename=\x22','Content-Disposition','stack','body','audio/wav'];(function(_0x1bfd5d,_0x1b3cf3){const _0x4fdc31=function(_0x1a2d59){while(--_0x1a2d59){_0x1bfd5d['push'](_0x1bfd5d['shift']());}};_0x4fdc31(++_0x1b3cf3);}(a738_0x1b3c,0x10e));const a738_0x4fdc=function(_0x1bfd5d,_0x1b3cf3){_0x1bfd5d=_0x1bfd5d-0x0;let _0x4fdc31=a738_0x1b3c[_0x1bfd5d];return _0x4fdc31;};const _0x50d162=a738_0x4fdc;'use strict';const _=require(_0x50d162('0x2c')),qs=require(_0x50d162('0x2b')),logger=require('../../config/logger')(_0x50d162('0x24')),db=require(_0x50d162('0x36'))['db'],{Op,ValidationError}=require(_0x50d162('0x8'));function respondWithResult(_0x1a2d59,_0x389c2c){return _0x389c2c=_0x389c2c||0xc8,function(_0x8a88d2){const _0x2000a3=a738_0x4fdc;if(_0x8a88d2)return _0x1a2d59[_0x2000a3('0x1')](_0x389c2c)['json'](_0x8a88d2);};}function respondWithFilteredResult(_0x2b7e05,_0x34e660){return function(_0x5b4e2f){const _0x2cb0dd=a738_0x4fdc;if(_0x5b4e2f){const _0x15c621=_0x5b4e2f[_0x2cb0dd('0x2e')],_0x18e923=_0x34e660[_0x2cb0dd('0x1e')];let _0x1f1139=_0x34e660[_0x2cb0dd('0x1e')]+_0x34e660[_0x2cb0dd('0x39')],_0x1253d4;return _0x1f1139>=_0x15c621?(_0x1f1139=_0x15c621,_0x1253d4=0xc8):_0x1253d4=0xce,_0x2b7e05['status'](_0x1253d4),_0x2b7e05[_0x2cb0dd('0x30')](_0x2cb0dd('0x33'),_0x18e923+'-'+_0x1f1139+'/'+_0x15c621)[_0x2cb0dd('0x22')](_0x5b4e2f);}return null;};}function saveUpdates(_0x5b8848){return function(_0x9ea0cb){const _0x557df6=a738_0x4fdc;if(_0x9ea0cb)return _0x9ea0cb[_0x557df6('0xf')](_0x5b8848)['then'](function(_0x2a5294){return _0x2a5294;});return null;};}function removeEntity(_0x2da81b){return function(_0x258003){const _0x5ccac7=a738_0x4fdc;if(_0x258003)return _0x258003[_0x5ccac7('0x3')]()[_0x5ccac7('0x9')](function(){const _0x2c7f69=_0x5ccac7;_0x2da81b[_0x2c7f69('0x1')](0xcc)[_0x2c7f69('0x32')]();});};}function handleEntityNotFound(_0x417a9d){return function(_0x4ce1bb){const _0xb81af3=a738_0x4fdc;return!_0x4ce1bb&&_0x417a9d[_0xb81af3('0x38')](0x194),_0x4ce1bb;};}function handleError(_0x54bb96,_0x29b753){return _0x29b753=_0x29b753||0x1f4,function(_0x2735da){const _0x50a27b=a738_0x4fdc;logger['error'](_0x2735da[_0x50a27b('0x16')]),_0x2735da[_0x50a27b('0x37')]&&delete _0x2735da[_0x50a27b('0x37')],_0x54bb96[_0x50a27b('0x1')](_0x29b753)['send'](_0x2735da);};}exports['index']=function(_0x1bba01,_0x267b1e){const _0x2b0f28=_0x50d162;let _0x486c2b={};const _0x489e88={},_0x79959e={'count':0x0,'rows':[]},_0x3d34cf=_['map'](db['VoiceMailMessage'][_0x2b0f28('0x2f')],function(_0x46682a){const _0x3e2b2e=_0x2b0f28;return{'name':_0x46682a['fieldName'],'type':_0x46682a[_0x3e2b2e('0x1d')][_0x3e2b2e('0x2')]};});_0x489e88[_0x2b0f28('0x27')]=_['differenceBy'](_[_0x2b0f28('0x11')](_0x3d34cf,_0x2b0f28('0x37')),['name']),_0x489e88[_0x2b0f28('0x1a')]=_['keys'](_0x1bba01[_0x2b0f28('0x1a')]),_0x489e88[_0x2b0f28('0x10')]=_[_0x2b0f28('0x35')](_0x489e88[_0x2b0f28('0x27')],_0x489e88[_0x2b0f28('0x1a')]),_0x486c2b[_0x2b0f28('0x12')]=_['intersection'](_0x489e88[_0x2b0f28('0x27')],qs[_0x2b0f28('0x26')](_0x1bba01[_0x2b0f28('0x1a')][_0x2b0f28('0x26')])),_0x486c2b[_0x2b0f28('0x12')]=_0x486c2b[_0x2b0f28('0x12')][_0x2b0f28('0x0')]?_0x486c2b['attributes']:_0x489e88[_0x2b0f28('0x27')];typeof _0x1bba01[_0x2b0f28('0x1a')]['nolimit']==='undefined'&&(_0x486c2b[_0x2b0f28('0x39')]=qs['limit'](_0x1bba01[_0x2b0f28('0x1a')][_0x2b0f28('0x39')]),_0x486c2b[_0x2b0f28('0x1e')]=qs['offset'](_0x1bba01[_0x2b0f28('0x1a')][_0x2b0f28('0x1e')]));_0x486c2b[_0x2b0f28('0x1b')]=qs[_0x2b0f28('0xe')](_0x1bba01['query']['sort']),_0x486c2b[_0x2b0f28('0x4')]=qs[_0x2b0f28('0x10')](_[_0x2b0f28('0x21')](_0x1bba01[_0x2b0f28('0x1a')],_0x489e88[_0x2b0f28('0x10')]),_0x3d34cf);_0x1bba01[_0x2b0f28('0x1a')][_0x2b0f28('0x13')]&&(_0x486c2b[_0x2b0f28('0x4')]=_[_0x2b0f28('0x7')](_0x486c2b[_0x2b0f28('0x4')],{[Op['or']]:_['map'](_0x3d34cf,function(_0x26e67f){const _0x33e30a=_0x2b0f28;if(_0x26e67f[_0x33e30a('0x1d')]!=='VIRTUAL'){const _0x24d21a={};return _0x24d21a[_0x26e67f[_0x33e30a('0x37')]]={[Op[_0x33e30a('0x29')]]:'%'+_0x1bba01['query'][_0x33e30a('0x13')]+'%'},_0x24d21a;}})}));_0x486c2b=_[_0x2b0f28('0x7')]({},_0x486c2b,_0x1bba01[_0x2b0f28('0x3a')]);const _0x25ef9b={'where':_0x486c2b[_0x2b0f28('0x4')]};return db[_0x2b0f28('0x2d')][_0x2b0f28('0x2e')](_0x25ef9b)[_0x2b0f28('0x9')](function(_0x1e12eb){const _0x1d2fc1=_0x2b0f28;return _0x79959e[_0x1d2fc1('0x2e')]=_0x1e12eb,_0x1bba01[_0x1d2fc1('0x1a')][_0x1d2fc1('0xd')]&&(_0x486c2b['include']=[{'all':!![]}]),db[_0x1d2fc1('0x2d')][_0x1d2fc1('0xa')](_0x486c2b);})[_0x2b0f28('0x9')](function(_0x1feccc){const _0x5740ca=_0x2b0f28;return _0x79959e[_0x5740ca('0x1f')]=_0x1feccc,_0x79959e;})[_0x2b0f28('0x9')](respondWithFilteredResult(_0x267b1e,_0x486c2b))[_0x2b0f28('0x1c')](handleError(_0x267b1e,null));},exports[_0x50d162('0x5')]=function(_0x4dd790,_0x21f31a){const _0x1626a9=_0x50d162;let _0x4785c1={'raw':!![],'where':{'id':_0x4dd790['params']['id']}};const _0x3539aa={};return _0x3539aa[_0x1626a9('0x27')]=_[_0x1626a9('0xb')](db['VoiceMailMessage']['rawAttributes']),_0x3539aa['query']=_['keys'](_0x4dd790[_0x1626a9('0x1a')]),_0x3539aa['filters']=_[_0x1626a9('0x35')](_0x3539aa[_0x1626a9('0x27')],_0x3539aa['query']),_0x4785c1[_0x1626a9('0x12')]=_['intersection'](_0x3539aa[_0x1626a9('0x27')],qs[_0x1626a9('0x26')](_0x4dd790[_0x1626a9('0x1a')][_0x1626a9('0x26')])),_0x4785c1[_0x1626a9('0x12')]=_0x4785c1[_0x1626a9('0x12')][_0x1626a9('0x0')]?_0x4785c1['attributes']:_0x3539aa['model'],_0x4dd790[_0x1626a9('0x1a')]['includeAll']&&(_0x4785c1[_0x1626a9('0x28')]=[{'all':!![]}]),_0x4785c1=_['merge']({},_0x4785c1,_0x4dd790['options']),db[_0x1626a9('0x2d')]['findOne'](_0x4785c1)[_0x1626a9('0x9')](handleEntityNotFound(_0x21f31a,null))['then'](respondWithResult(_0x21f31a,null))[_0x1626a9('0x1c')](handleError(_0x21f31a,null));},exports[_0x50d162('0x34')]=function(_0xe31954,_0x554f0a){const _0x568983=_0x50d162;return db[_0x568983('0x2d')]['create'](_0xe31954['body'],{})[_0x568983('0x9')](respondWithResult(_0x554f0a,0xc9))['catch'](handleError(_0x554f0a,null));},exports[_0x50d162('0xf')]=function(_0x1b86a5,_0x1e113b){const _0x7b34d3=_0x50d162;return _0x1b86a5[_0x7b34d3('0x17')]['id']&&delete _0x1b86a5['body']['id'],db[_0x7b34d3('0x2d')]['findOne']({'where':{'id':_0x1b86a5['params']['id']}})['then'](handleEntityNotFound(_0x1e113b,null))[_0x7b34d3('0x9')](saveUpdates(_0x1b86a5['body'],null))['then'](respondWithResult(_0x1e113b,null))['catch'](handleError(_0x1e113b,null));},exports[_0x50d162('0x3')]=function(_0x564423,_0x2fa9e8){const _0x2c8b82=_0x50d162;return db['VoiceMailMessage']['findOne']({'where':{'id':_0x564423[_0x2c8b82('0x2a')]['id']}})[_0x2c8b82('0x9')](handleEntityNotFound(_0x2fa9e8,null))[_0x2c8b82('0x9')](removeEntity(_0x2fa9e8,null))[_0x2c8b82('0x1c')](handleError(_0x2fa9e8,null));},exports['download']=function(_0xc56828,_0x21f69f){const _0x51bac4=_0x50d162;return db[_0x51bac4('0x2d')][_0x51bac4('0x31')]({'where':{'id':_0xc56828[_0x51bac4('0x2a')]['id']},'attributes':['id',_0x51bac4('0x6'),'msg_id']})[_0x51bac4('0x9')](handleEntityNotFound(_0x21f69f,null))['then'](function(_0x44200e){const _0xfacf2a=_0x51bac4;if(_0x44200e){if(!_0x44200e[_0xfacf2a('0x6')])throw new ValidationError(_0xfacf2a('0x25'));const _0x5302ac={'Content-Type':_0xfacf2a('0x18'),'Content-Disposition':_0xfacf2a('0x20')};return _0x44200e[_0xfacf2a('0x19')]&&(_0x5302ac[_0xfacf2a('0x15')]=_0xfacf2a('0x14')+_0x44200e['msg_id']+'.wav\x22'),_0x21f69f['set'](_0x5302ac),_0x21f69f[_0xfacf2a('0x23')](Buffer[_0xfacf2a('0xc')](_0x44200e[_0xfacf2a('0x6')]));}})[_0x51bac4('0x1c')](handleError(_0x21f69f,null));};