f72130e4818877abad2b81851245403d313ea8a3
[motion-next.git] / server / api / chatApplication / chatApplication.controller.js
1 const a55_0x4e15=['includeAll','../../config/logger','sendStatus','api','findOne','show','catch','ChatApplication','model','end','query','intersection','../../components/parsers/qs','params','stack','include','error','destroy','attributes','status','../../mysqldb','body','then','update','fields','json'];(function(_0x2702fd,_0x4e15b7){const _0xc489b1=function(_0x156685){while(--_0x156685){_0x2702fd['push'](_0x2702fd['shift']());}};_0xc489b1(++_0x4e15b7);}(a55_0x4e15,0x1b3));const a55_0xc489=function(_0x2702fd,_0x4e15b7){_0x2702fd=_0x2702fd-0x0;let _0xc489b1=a55_0x4e15[_0x2702fd];return _0xc489b1;};const _0xc4b39d=a55_0xc489;'use strict';const _=require('lodash'),qs=require(_0xc4b39d('0x13')),logger=require(_0xc4b39d('0x8'))(_0xc4b39d('0xa')),db=require(_0xc4b39d('0x1'))['db'];function respondWithResult(_0x156685,_0x59039c){return _0x59039c=_0x59039c||0xc8,function(_0x4d6bd1){const _0x2ed8da=a55_0xc489;if(_0x4d6bd1)return _0x156685[_0x2ed8da('0x0')](_0x59039c)[_0x2ed8da('0x6')](_0x4d6bd1);};}function saveUpdates(_0x4fb92a){return function(_0x510136){const _0x3a58cc=a55_0xc489;if(_0x510136)return _0x510136[_0x3a58cc('0x4')](_0x4fb92a)[_0x3a58cc('0x3')](function(_0x264a18){return _0x264a18;});return null;};}function removeEntity(_0x20a56f){return function(_0x2ac1ab){const _0x124467=a55_0xc489;if(_0x2ac1ab)return _0x2ac1ab['destroy']()[_0x124467('0x3')](function(){const _0x30880c=_0x124467;_0x20a56f[_0x30880c('0x0')](0xcc)[_0x30880c('0x10')]();});};}function handleEntityNotFound(_0x38b731){return function(_0xa0d85a){const _0x472825=a55_0xc489;return!_0xa0d85a&&_0x38b731[_0x472825('0x9')](0x194),_0xa0d85a;};}function handleError(_0xea916a,_0x3fd54b){return _0x3fd54b=_0x3fd54b||0x1f4,function(_0xf6c548){const _0xff499=a55_0xc489;logger[_0xff499('0x17')](_0xf6c548[_0xff499('0x15')]),_0xf6c548['name']&&delete _0xf6c548['name'],_0xea916a[_0xff499('0x0')](_0x3fd54b)['send'](_0xf6c548);};}exports[_0xc4b39d('0xc')]=function(_0x197bf0,_0x21a5e0){const _0x391e5e=_0xc4b39d;let _0x267743={'raw':!![],'where':{'id':_0x197bf0['params']['id']}};const _0x2fa6e5={};return _0x2fa6e5[_0x391e5e('0xf')]=_['keys'](db['ChatApplication']['rawAttributes']),_0x2fa6e5[_0x391e5e('0x11')]=_['keys'](_0x197bf0['query']),_0x2fa6e5['filters']=_[_0x391e5e('0x12')](_0x2fa6e5['model'],_0x2fa6e5['query']),_0x267743[_0x391e5e('0x19')]=_[_0x391e5e('0x12')](_0x2fa6e5[_0x391e5e('0xf')],qs['fields'](_0x197bf0['query'][_0x391e5e('0x5')])),_0x267743[_0x391e5e('0x19')]=_0x267743[_0x391e5e('0x19')]['length']?_0x267743[_0x391e5e('0x19')]:_0x2fa6e5[_0x391e5e('0xf')],_0x197bf0[_0x391e5e('0x11')][_0x391e5e('0x7')]&&(_0x267743[_0x391e5e('0x16')]=[{'all':!![]}]),_0x267743=_['merge']({},_0x267743,_0x197bf0['options']),db[_0x391e5e('0xe')][_0x391e5e('0xb')](_0x267743)[_0x391e5e('0x3')](handleEntityNotFound(_0x21a5e0,null))[_0x391e5e('0x3')](respondWithResult(_0x21a5e0,null))[_0x391e5e('0xd')](handleError(_0x21a5e0,null));},exports['update']=function(_0x1d1cee,_0x17ff01){const _0x3d3eda=_0xc4b39d;return _0x1d1cee[_0x3d3eda('0x2')]['id']&&delete _0x1d1cee['body']['id'],db[_0x3d3eda('0xe')][_0x3d3eda('0xb')]({'where':{'id':_0x1d1cee[_0x3d3eda('0x14')]['id']}})[_0x3d3eda('0x3')](handleEntityNotFound(_0x17ff01,null))[_0x3d3eda('0x3')](saveUpdates(_0x1d1cee[_0x3d3eda('0x2')],null))[_0x3d3eda('0x3')](respondWithResult(_0x17ff01,null))['catch'](handleError(_0x17ff01,null));},exports[_0xc4b39d('0x18')]=function(_0x2acfce,_0x2c913b){const _0x4d4349=_0xc4b39d;return db[_0x4d4349('0xe')][_0x4d4349('0xb')]({'where':{'id':_0x2acfce[_0x4d4349('0x14')]['id']}})[_0x4d4349('0x3')](handleEntityNotFound(_0x2c913b,null))[_0x4d4349('0x3')](removeEntity(_0x2c913b,null))['catch'](handleError(_0x2c913b,null));};