0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 08:52:38 +00:00

reworked to be simpler

This commit is contained in:
Víctor Losada Hernández
2025-07-23 19:52:05 +02:00
parent 0ddca82c86
commit 2bcd317a4c
4 changed files with 8 additions and 78 deletions

View File

@@ -460,28 +460,6 @@ const api = {
res.status(200).send(saved);
},
deleteAuthor : async (req, res)=>{
try {
await api.getBrew('edit')(req, res, ()=>{});
} catch (err) {
throw { name: 'deleteAuthor Error', message: err, status: 500, brewId: brew._id };
}
let brew = req.brew;
const account = req.account;
const author = req.params.author;
const isOwner = account && (brew.authors[0] === account.username);
if(brew._id && isOwner) {
brew = _.assign(await HomebrewModel.findOne({ _id: brew._id }), brew);
brew.authors = _.pull(brew.authors, author);
brew.markModified('authors'); //Mongo will not properly update arrays without markModified()
await brew.save().catch((err)=>{
throw { name: 'deleteAuthor Error', message: err, status: 500, HBErrorCode: '08', brewId: brew._id };
});
}
res.status(204).send();
},
deleteGoogleBrew : async (account, id, editId, res)=>{
const auth = await GoogleActions.authCheck(account, res);
await GoogleActions.deleteGoogleBrew(auth, id, editId);
@@ -553,7 +531,6 @@ router.post('/api', checkClientVersion, asyncHandler(api.newBrew));
router.put('/api/:id', checkClientVersion, asyncHandler(api.getBrew('edit', false)), asyncHandler(api.updateBrew));
router.put('/api/update/:id', checkClientVersion, asyncHandler(api.getBrew('edit', false)), asyncHandler(api.updateBrew));
router.delete('/api/:id', checkClientVersion, asyncHandler(api.deleteBrew));
router.put('/api/prune/:id/:author', checkClientVersion, asyncHandler(api.deleteAuthor));
router.get('/api/remove/:id', checkClientVersion, asyncHandler(api.deleteBrew));
router.get('/api/theme/:renderer/:id', asyncHandler(api.getThemeBundle));