10ba0a29f6d98e8fb38200df022d76e06ec37dbf
[motion-next.git] / server / api / voiceCallReport / voiceCallReport.controller.js
1 const a709_0x3d69=['filters','like','end','include','lodash','uniqueid','includeAll','options','count','keys','model','rawAttributes','order','../../components/parsers/qs','stack','show','params','fieldName','destroy','../../config/logger','findOne','filter','body','offset','query','limit','user','update','merge','name','error','intersection','create','attributes','Content-Range','index','sendStatus','sort','User','api','pick','map','status','where','json','describe','type','findAll','rows','then','catch','nolimit','fields','../../mysqldb','send','fullname','VoiceCallReport','length','key','sequelize'];(function(_0x1c5bf4,_0x3d6926){const _0x5646db=function(_0x58f6b3){while(--_0x58f6b3){_0x1c5bf4['push'](_0x1c5bf4['shift']());}};_0x5646db(++_0x3d6926);}(a709_0x3d69,0x124));const a709_0x5646=function(_0x1c5bf4,_0x3d6926){_0x1c5bf4=_0x1c5bf4-0x0;let _0x5646db=a709_0x3d69[_0x1c5bf4];return _0x5646db;};const _0x86a7c7=a709_0x5646;'use strict';const _=require(_0x86a7c7('0xc')),qs=require(_0x86a7c7('0x15')),logger=require(_0x86a7c7('0x1b'))(_0x86a7c7('0x2f')),db=require(_0x86a7c7('0x1'))['db'],{Op}=require(_0x86a7c7('0x7'));function respondWithResult(_0x58f6b3,_0xfa36ef){return _0xfa36ef=_0xfa36ef||0xc8,function(_0xd48ac){const _0x5100dd=a709_0x5646;if(_0xd48ac)return _0x58f6b3[_0x5100dd('0x32')](_0xfa36ef)['json'](_0xd48ac);};}function respondWithFilteredResult(_0x200172,_0x140103){return function(_0x36d884){const _0x473a8d=a709_0x5646;if(_0x36d884){const _0x161bbc=_0x36d884[_0x473a8d('0x10')],_0x5bce97=_0x140103['offset'];let _0xc252b9=_0x140103[_0x473a8d('0x1f')]+_0x140103[_0x473a8d('0x21')],_0x48592c;return _0xc252b9>=_0x161bbc?(_0xc252b9=_0x161bbc,_0x48592c=0xc8):_0x48592c=0xce,_0x200172['status'](_0x48592c),_0x200172['set'](_0x473a8d('0x2a'),_0x5bce97+'-'+_0xc252b9+'/'+_0x161bbc)[_0x473a8d('0x34')](_0x36d884);}return null;};}function saveUpdates(_0x4e42fd){return function(_0x530c84){const _0x1ee586=a709_0x5646;if(_0x530c84)return _0x530c84[_0x1ee586('0x23')](_0x4e42fd)[_0x1ee586('0x39')](function(_0x9d6dec){return _0x9d6dec;});return null;};}function removeEntity(_0x43b876){return function(_0x101cc8){const _0x47ba7b=a709_0x5646;if(_0x101cc8)return _0x101cc8[_0x47ba7b('0x1a')]()['then'](function(){const _0x263401=_0x47ba7b;_0x43b876[_0x263401('0x32')](0xcc)[_0x263401('0xa')]();});};}function handleEntityNotFound(_0x496c23){return function(_0x4244ba){const _0x447f15=a709_0x5646;return!_0x4244ba&&_0x496c23[_0x447f15('0x2c')](0x194),_0x4244ba;};}function handleError(_0x537017,_0x3b12b6){return _0x3b12b6=_0x3b12b6||0x1f4,function(_0x5e36f0){const _0x471e2c=a709_0x5646;logger[_0x471e2c('0x26')](_0x5e36f0[_0x471e2c('0x16')]),_0x5e36f0[_0x471e2c('0x25')]&&delete _0x5e36f0[_0x471e2c('0x25')],_0x537017['status'](_0x3b12b6)[_0x471e2c('0x2')](_0x5e36f0);};}exports[_0x86a7c7('0x2b')]=function(_0x13861e,_0x33b9bd){const _0x5a9e9e=_0x86a7c7;let _0x3f94ef={};const _0x16ae82={},_0x3f5e7c={'count':0x0,'rows':[]},_0x1451be=_['map'](db[_0x5a9e9e('0x4')][_0x5a9e9e('0x13')],function(_0x51e66f){const _0x46c960=_0x5a9e9e;return{'name':_0x51e66f[_0x46c960('0x19')],'type':_0x51e66f['type'][_0x46c960('0x6')]};});_0x16ae82[_0x5a9e9e('0x12')]=_[_0x5a9e9e('0x31')](_0x1451be,'name'),_0x16ae82[_0x5a9e9e('0x20')]=_['keys'](_0x13861e[_0x5a9e9e('0x20')]),_0x16ae82[_0x5a9e9e('0x8')]=_['intersection'](_0x16ae82[_0x5a9e9e('0x12')],_0x16ae82['query']),_0x3f94ef['attributes']=_[_0x5a9e9e('0x27')](_0x16ae82[_0x5a9e9e('0x12')],qs[_0x5a9e9e('0x0')](_0x13861e[_0x5a9e9e('0x20')]['fields'])),_0x3f94ef[_0x5a9e9e('0x29')]=_0x3f94ef[_0x5a9e9e('0x29')]['length']?_0x3f94ef[_0x5a9e9e('0x29')]:_0x16ae82[_0x5a9e9e('0x12')];typeof _0x13861e[_0x5a9e9e('0x20')][_0x5a9e9e('0x3b')]==='undefined'&&(_0x3f94ef[_0x5a9e9e('0x21')]=qs[_0x5a9e9e('0x21')](_0x13861e['query']['limit']),_0x3f94ef['offset']=qs['offset'](_0x13861e[_0x5a9e9e('0x20')]['offset']));_0x3f94ef[_0x5a9e9e('0x14')]=qs[_0x5a9e9e('0x2d')](_0x13861e[_0x5a9e9e('0x20')][_0x5a9e9e('0x2d')]),_0x3f94ef[_0x5a9e9e('0x33')]=qs['filters'](_[_0x5a9e9e('0x30')](_0x13861e[_0x5a9e9e('0x20')],_0x16ae82[_0x5a9e9e('0x8')]),_0x1451be);_0x13861e['query']['filter']&&(_0x3f94ef[_0x5a9e9e('0x33')]=_[_0x5a9e9e('0x24')](_0x3f94ef[_0x5a9e9e('0x33')],{[Op['or']]:_[_0x5a9e9e('0x31')](_0x1451be,function(_0x1419cc){const _0x12841b=_0x5a9e9e;if(_0x1419cc[_0x12841b('0x36')]!=='VIRTUAL'){const _0x1660e0={};return _0x1660e0[_0x1419cc['name']]={[Op[_0x12841b('0x9')]]:'%'+_0x13861e[_0x12841b('0x20')][_0x12841b('0x1d')]+'%'},_0x1660e0;}})}));_0x3f94ef=_[_0x5a9e9e('0x24')]({},_0x3f94ef,_0x13861e[_0x5a9e9e('0xf')]);const _0x3c87c4={'where':_0x3f94ef[_0x5a9e9e('0x33')]};return db[_0x5a9e9e('0x4')]['count'](_0x3c87c4)[_0x5a9e9e('0x39')](function(_0x405170){const _0x3b9f54=_0x5a9e9e;return _0x3f5e7c[_0x3b9f54('0x10')]=_0x405170,_0x13861e['query'][_0x3b9f54('0xe')]&&(_0x3f94ef[_0x3b9f54('0xb')]=[{'attributes':['id',_0x3b9f54('0x25'),_0x3b9f54('0x3'),'alias'],'model':db[_0x3b9f54('0x2e')],'as':'User'}]),db[_0x3b9f54('0x4')][_0x3b9f54('0x37')](_0x3f94ef);})[_0x5a9e9e('0x39')](function(_0x2e84e2){const _0x4c7e7a=_0x5a9e9e;return _0x3f5e7c[_0x4c7e7a('0x38')]=_0x2e84e2,_0x3f5e7c;})[_0x5a9e9e('0x39')](respondWithFilteredResult(_0x33b9bd,_0x3f94ef))['catch'](handleError(_0x33b9bd,null));},exports[_0x86a7c7('0x17')]=function(_0x26dba2,_0xe2a03b){const _0x11b18e=_0x86a7c7;let _0x5b45a3={'raw':!![],'where':{'id':_0x26dba2['params']['id']}};const _0x435c36={};return _0x435c36[_0x11b18e('0x12')]=_['keys'](db[_0x11b18e('0x4')][_0x11b18e('0x13')]),_0x435c36['query']=_[_0x11b18e('0x11')](_0x26dba2[_0x11b18e('0x20')]),_0x435c36[_0x11b18e('0x8')]=_['intersection'](_0x435c36['model'],_0x435c36['query']),_0x5b45a3['attributes']=_['intersection'](_0x435c36[_0x11b18e('0x12')],qs[_0x11b18e('0x0')](_0x26dba2[_0x11b18e('0x20')][_0x11b18e('0x0')])),_0x5b45a3[_0x11b18e('0x29')]=_0x5b45a3[_0x11b18e('0x29')][_0x11b18e('0x5')]?_0x5b45a3[_0x11b18e('0x29')]:_0x435c36['model'],_0x26dba2['query'][_0x11b18e('0xe')]&&(_0x5b45a3[_0x11b18e('0xb')]=[{'all':!![]}]),_0x5b45a3=_[_0x11b18e('0x24')]({},_0x5b45a3,_0x26dba2[_0x11b18e('0xf')]),db[_0x11b18e('0x4')][_0x11b18e('0x1c')](_0x5b45a3)['then'](handleEntityNotFound(_0xe2a03b,null))[_0x11b18e('0x39')](respondWithResult(_0xe2a03b,null))['catch'](handleError(_0xe2a03b,null));},exports[_0x86a7c7('0x28')]=function(_0x575bc9,_0x17993b){const _0x11fca3=_0x86a7c7;return db[_0x11fca3('0x4')][_0x11fca3('0x28')](_0x575bc9[_0x11fca3('0x1e')],{})['then'](respondWithResult(_0x17993b,0xc9))['catch'](handleError(_0x17993b,null));},exports[_0x86a7c7('0x1a')]=function(_0x3f92bb,_0x116fb9){const _0x24b100=_0x86a7c7;return db[_0x24b100('0x4')]['findOne']({'where':{'id':_0x3f92bb['params']['id']}})[_0x24b100('0x39')](handleEntityNotFound(_0x116fb9,null))[_0x24b100('0x39')](removeEntity(_0x116fb9,null))['catch'](handleError(_0x116fb9,null));},exports['describe']=function(_0x383d3d,_0x577441){const _0x57b763=_0x86a7c7;return db[_0x57b763('0x4')][_0x57b763('0x35')]()[_0x57b763('0x39')](respondWithResult(_0x577441,null))[_0x57b763('0x3a')](handleError(_0x577441,null));},exports[_0x86a7c7('0x23')]=function(_0x233871,_0x29f7ef){const _0xd627b6=_0x86a7c7;return _0x233871[_0xd627b6('0x1e')][_0xd627b6('0xd')]&&delete _0x233871[_0xd627b6('0x1e')][_0xd627b6('0xd')],db['VoiceCallReport'][_0xd627b6('0x1c')]({'where':{'uniqueid':_0x233871[_0xd627b6('0x18')]['id'],'UserId':{[Op['or']]:[null,_0x233871[_0xd627b6('0x22')]['id']]}}})['then'](handleEntityNotFound(_0x29f7ef,null))['then'](saveUpdates(_0x233871[_0xd627b6('0x1e')],null))[_0xd627b6('0x39')](respondWithResult(_0x29f7ef,null))[_0xd627b6('0x3a')](handleError(_0x29f7ef,null));};