From c84ce18c8c54942682f006fbd237c1383aecb1f2 Mon Sep 17 00:00:00 2001 From: xangelo Date: Mon, 19 Dec 2022 11:22:16 -0500 Subject: [PATCH] add ability to delete feed that belongs to a user --- src/server.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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; }); -- 2.25.1