d8323663b85b8716b8e7078e36118db2cbf42a08
[motion-next.git] / server / api / intFreshdeskField / intFreshdeskField.controller.js
1 const a264_0x2364=['like','catch','offset','name','lodash','params','key','type','order','merge','keys','create','query','limit','end','sendStatus','count','undefined','map','../../config/logger','Content-Range','findOne','send','index','rawAttributes','../../mysqldb','FreshdeskField','pick','then','attributes','update','fields','options','show','length','stack','intersection','where','includeAll','api','sort','model','rows','filters','../../components/parsers/qs','include','nolimit','sequelize','findAll','error','set','status','body','VIRTUAL','json','fieldName'];(function(_0x3dc370,_0x2364ec){const _0x44788d=function(_0x4f4659){while(--_0x4f4659){_0x3dc370['push'](_0x3dc370['shift']());}};_0x44788d(++_0x2364ec);}(a264_0x2364,0xac));const a264_0x4478=function(_0x3dc370,_0x2364ec){_0x3dc370=_0x3dc370-0x0;let _0x44788d=a264_0x2364[_0x3dc370];return _0x44788d;};const _0x5b35b0=a264_0x4478;'use strict';const _=require(_0x5b35b0('0x0')),qs=require(_0x5b35b0('0x28')),logger=require(_0x5b35b0('0xf'))(_0x5b35b0('0x23')),db=require(_0x5b35b0('0x15'))['db'],{Op}=require(_0x5b35b0('0x2b'));function respondWithResult(_0x4f4659,_0x36d23b){return _0x36d23b=_0x36d23b||0xc8,function(_0x40b6df){const _0xfec2f3=a264_0x4478;if(_0x40b6df)return _0x4f4659[_0xfec2f3('0x2f')](_0x36d23b)[_0xfec2f3('0x32')](_0x40b6df);};}function respondWithFilteredResult(_0x4919fa,_0x2d8d35){return function(_0x982802){const _0x121020=a264_0x4478;if(_0x982802){const _0x879ada=_0x982802[_0x121020('0xc')],_0x348451=_0x2d8d35[_0x121020('0x36')];let _0x5b9a0d=_0x2d8d35[_0x121020('0x36')]+_0x2d8d35[_0x121020('0x9')],_0x334772;return _0x5b9a0d>=_0x879ada?(_0x5b9a0d=_0x879ada,_0x334772=0xc8):_0x334772=0xce,_0x4919fa[_0x121020('0x2f')](_0x334772),_0x4919fa[_0x121020('0x2e')](_0x121020('0x10'),_0x348451+'-'+_0x5b9a0d+'/'+_0x879ada)[_0x121020('0x32')](_0x982802);}return null;};}function saveUpdates(_0x3e3468){return function(_0x2ca246){const _0x466379=a264_0x4478;if(_0x2ca246)return _0x2ca246[_0x466379('0x1a')](_0x3e3468)[_0x466379('0x18')](function(_0x24b217){return _0x24b217;});return null;};}function removeEntity(_0x48b9fb){return function(_0x5e55c9){const _0x18b446=a264_0x4478;if(_0x5e55c9)return _0x5e55c9['destroy']()[_0x18b446('0x18')](function(){const _0x52eff0=_0x18b446;_0x48b9fb[_0x52eff0('0x2f')](0xcc)[_0x52eff0('0xa')]();});};}function handleEntityNotFound(_0x3b6ab0){return function(_0x518d35){const _0x2c126d=a264_0x4478;return!_0x518d35&&_0x3b6ab0[_0x2c126d('0xb')](0x194),_0x518d35;};}function handleError(_0x59619a,_0x4a131c){return _0x4a131c=_0x4a131c||0x1f4,function(_0x4023a2){const _0x16a1be=a264_0x4478;logger[_0x16a1be('0x2d')](_0x4023a2[_0x16a1be('0x1f')]),_0x4023a2['name']&&delete _0x4023a2['name'],_0x59619a[_0x16a1be('0x2f')](_0x4a131c)[_0x16a1be('0x12')](_0x4023a2);};}exports[_0x5b35b0('0x13')]=function(_0x11b888,_0x247fc1){const _0x3287d2=_0x5b35b0;let _0x31ff32={};const _0x2b982f={},_0x34bf1d={'count':0x0,'rows':[]},_0x2c14fe=_[_0x3287d2('0xe')](db[_0x3287d2('0x16')][_0x3287d2('0x14')],function(_0x243a2b){const _0x5bd0af=_0x3287d2;return{'name':_0x243a2b[_0x5bd0af('0x33')],'type':_0x243a2b[_0x5bd0af('0x3')][_0x5bd0af('0x2')]};});_0x2b982f[_0x3287d2('0x25')]=_[_0x3287d2('0xe')](_0x2c14fe,_0x3287d2('0x37')),_0x2b982f[_0x3287d2('0x8')]=_[_0x3287d2('0x6')](_0x11b888[_0x3287d2('0x8')]),_0x2b982f[_0x3287d2('0x27')]=_[_0x3287d2('0x20')](_0x2b982f[_0x3287d2('0x25')],_0x2b982f['query']),_0x31ff32[_0x3287d2('0x19')]=_['intersection'](_0x2b982f[_0x3287d2('0x25')],qs[_0x3287d2('0x1b')](_0x11b888[_0x3287d2('0x8')]['fields'])),_0x31ff32[_0x3287d2('0x19')]=_0x31ff32['attributes'][_0x3287d2('0x1e')]?_0x31ff32[_0x3287d2('0x19')]:_0x2b982f[_0x3287d2('0x25')];typeof _0x11b888[_0x3287d2('0x8')][_0x3287d2('0x2a')]===_0x3287d2('0xd')&&(_0x31ff32[_0x3287d2('0x9')]=qs[_0x3287d2('0x9')](_0x11b888[_0x3287d2('0x8')][_0x3287d2('0x9')]),_0x31ff32[_0x3287d2('0x36')]=qs['offset'](_0x11b888[_0x3287d2('0x8')][_0x3287d2('0x36')]));_0x31ff32[_0x3287d2('0x4')]=qs['sort'](_0x11b888[_0x3287d2('0x8')][_0x3287d2('0x24')]),_0x31ff32[_0x3287d2('0x21')]=qs[_0x3287d2('0x27')](_[_0x3287d2('0x17')](_0x11b888['query'],_0x2b982f[_0x3287d2('0x27')]),_0x2c14fe);_0x11b888['query']['filter']&&(_0x31ff32[_0x3287d2('0x21')]=_[_0x3287d2('0x5')](_0x31ff32[_0x3287d2('0x21')],{[Op['or']]:_[_0x3287d2('0xe')](_0x2c14fe,function(_0x282f01){const _0x28a012=_0x3287d2;if(_0x282f01[_0x28a012('0x3')]!==_0x28a012('0x31')){const _0x1e286f={};return _0x1e286f[_0x282f01['name']]={[Op[_0x28a012('0x34')]]:'%'+_0x11b888['query']['filter']+'%'},_0x1e286f;}})}));_0x31ff32=_[_0x3287d2('0x5')]({},_0x31ff32,_0x11b888[_0x3287d2('0x1c')]);const _0x209cb3={'where':_0x31ff32[_0x3287d2('0x21')]};return db['FreshdeskField'][_0x3287d2('0xc')](_0x209cb3)['then'](function(_0x2321e1){const _0xdfd448=_0x3287d2;return _0x34bf1d['count']=_0x2321e1,_0x11b888['query'][_0xdfd448('0x22')]&&(_0x31ff32[_0xdfd448('0x29')]=[{'all':!![]}]),db[_0xdfd448('0x16')][_0xdfd448('0x2c')](_0x31ff32);})['then'](function(_0x3248ac){const _0x371ecc=_0x3287d2;return _0x34bf1d[_0x371ecc('0x26')]=_0x3248ac,_0x34bf1d;})[_0x3287d2('0x18')](respondWithFilteredResult(_0x247fc1,_0x31ff32))['catch'](handleError(_0x247fc1,null));},exports[_0x5b35b0('0x1d')]=function(_0x49e04c,_0x3f4a81){const _0x39496c=_0x5b35b0;let _0x55a2ad={'raw':!![],'where':{'id':_0x49e04c[_0x39496c('0x1')]['id']}};const _0x24632f={};return _0x24632f[_0x39496c('0x25')]=_[_0x39496c('0x6')](db[_0x39496c('0x16')]['rawAttributes']),_0x24632f[_0x39496c('0x8')]=_[_0x39496c('0x6')](_0x49e04c['query']),_0x24632f[_0x39496c('0x27')]=_[_0x39496c('0x20')](_0x24632f['model'],_0x24632f['query']),_0x55a2ad[_0x39496c('0x19')]=_['intersection'](_0x24632f[_0x39496c('0x25')],qs[_0x39496c('0x1b')](_0x49e04c[_0x39496c('0x8')]['fields'])),_0x55a2ad[_0x39496c('0x19')]=_0x55a2ad[_0x39496c('0x19')][_0x39496c('0x1e')]?_0x55a2ad[_0x39496c('0x19')]:_0x24632f[_0x39496c('0x25')],_0x49e04c[_0x39496c('0x8')][_0x39496c('0x22')]&&(_0x55a2ad[_0x39496c('0x29')]=[{'all':!![]}]),_0x55a2ad=_[_0x39496c('0x5')]({},_0x55a2ad,_0x49e04c[_0x39496c('0x1c')]),db['FreshdeskField'][_0x39496c('0x11')](_0x55a2ad)[_0x39496c('0x18')](handleEntityNotFound(_0x3f4a81,null))['then'](respondWithResult(_0x3f4a81,null))[_0x39496c('0x35')](handleError(_0x3f4a81,null));},exports[_0x5b35b0('0x7')]=function(_0x5ef835,_0x313ae7){const _0x14eba8=_0x5b35b0;return db[_0x14eba8('0x16')][_0x14eba8('0x7')](_0x5ef835[_0x14eba8('0x30')],{})['then'](respondWithResult(_0x313ae7,0xc9))[_0x14eba8('0x35')](handleError(_0x313ae7,null));},exports[_0x5b35b0('0x1a')]=function(_0x635745,_0x5e5f06){const _0x498c54=_0x5b35b0;return _0x635745['body']['id']&&delete _0x635745[_0x498c54('0x30')]['id'],db[_0x498c54('0x16')][_0x498c54('0x11')]({'where':{'id':_0x635745['params']['id']}})['then'](handleEntityNotFound(_0x5e5f06,null))['then'](saveUpdates(_0x635745[_0x498c54('0x30')],null))['then'](respondWithResult(_0x5e5f06,null))[_0x498c54('0x35')](handleError(_0x5e5f06,null));},exports['destroy']=function(_0x38ddd0,_0x4e4051){const _0x595dbe=_0x5b35b0;return db[_0x595dbe('0x16')][_0x595dbe('0x11')]({'where':{'id':_0x38ddd0[_0x595dbe('0x1')]['id']}})[_0x595dbe('0x18')](handleEntityNotFound(_0x4e4051,null))[_0x595dbe('0x18')](removeEntity(_0x4e4051,null))[_0x595dbe('0x35')](handleError(_0x4e4051,null));};