mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-01 19:32:42 +00:00
Remove undesired properties from brews prior to updating
Clean up tab/spacing in `googleActions.js`
This commit is contained in:
@@ -61,10 +61,20 @@ const newBrew = (req, res)=>{
|
||||
});
|
||||
};
|
||||
|
||||
const cleanBrew = (brew)=>{
|
||||
// Remove undesired properties
|
||||
const undesiredPropertyNames=['views', 'lastViewed'];
|
||||
for (const undesiredProperty of undesiredPropertyNames) {
|
||||
delete brew[undesiredProperty];
|
||||
};
|
||||
return brew;
|
||||
};
|
||||
|
||||
const updateBrew = (req, res)=>{
|
||||
HomebrewModel.get({ editId: req.params.id })
|
||||
.then((brew)=>{
|
||||
brew = _.merge(brew, req.body);
|
||||
const updateBrew = cleanBrew(req.body);
|
||||
brew = _.merge(brew, updateBrew);
|
||||
brew.text = mergeBrewText(brew.text, brew.style);
|
||||
|
||||
// Compress brew text to binary before saving
|
||||
@@ -151,7 +161,7 @@ const updateGoogleBrew = async (req, res, next)=>{
|
||||
|
||||
try { oAuth2Client = GoogleActions.authCheck(req.account, res); } catch (err) { return res.status(err.status).send(err.message); }
|
||||
|
||||
const brew = req.body;
|
||||
const brew = cleanBrew(req.body);
|
||||
brew.text = mergeBrewText(brew.text, brew.style);
|
||||
|
||||
const updatedBrew = await GoogleActions.updateGoogleBrew(oAuth2Client, brew);
|
||||
|
||||
Reference in New Issue
Block a user