From: xangelo Date: Mon, 19 Dec 2022 16:22:16 +0000 (-0500) Subject: add ability to delete feed that belongs to a user X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=rss-reader.git add ability to delete feed that belongs to a user --- diff --git a/src/server.ts b/src/server.ts index 3b76b91..e9915d3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -307,10 +307,14 @@ apiGet('/accounts/:account_id/feeds/:feed_id/items/:item_id',{auth: true}, asyn `; }); -apiDelete('/feeds/:feed_id',{auth: true}, async (req, res) => { - const id = req.params.feed_id; +apiDelete('/accounts/:account_id/feeds/:feed_id',{auth: true}, async (req, res) => { + const { feed_id, account_id } = req.params; + if(!query.isFeedOwnedBy(account_id, feed_id)) { + throw new Error('Invalid feed'); + } - query.deleteFeed.run(id); + query.deleteFeed.run(feed_id); + console.log(`Deleting feed ${feed_id}`); res.setHeader('HX-Trigger', 'newFeed'); return; });