add ability to delete feed that belongs to a user master
authorxangelo <git@xangelo.ca>
Mon, 19 Dec 2022 16:22:16 +0000 (11:22 -0500)
committerxangelo <git@xangelo.ca>
Mon, 19 Dec 2022 16:22:16 +0000 (11:22 -0500)
src/server.ts

index 3b76b918032992c0e2c2e2914ab99cc04ebd49fd..e9915d3947216e6188c5ba58ff4c6c84a85c919b 100644 (file)
@@ -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;
 });