0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-03 10:32:39 +00:00

Remove undesired properties from brews prior to updating

Clean up tab/spacing in `googleActions.js`
This commit is contained in:
G.Ambatte
2021-08-26 17:21:45 +12:00
parent ceb4667193
commit 4971c40e23
2 changed files with 27 additions and 17 deletions

View File

@@ -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
@@ -154,7 +164,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);
try {