From 5ccd69e6051c433baa91e65bfbf42236648da61b Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Sun, 24 Apr 2022 23:20:22 +0100 Subject: [PATCH] feat: replace delete notif with empty inbox endpoint --- .../v1/users/_userID/notifications/router.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/server/src/server/router/api/v1/users/_userID/notifications/router.ts b/server/src/server/router/api/v1/users/_userID/notifications/router.ts index 646ddc85f..bbab0de19 100644 --- a/server/src/server/router/api/v1/users/_userID/notifications/router.ts +++ b/server/src/server/router/api/v1/users/_userID/notifications/router.ts @@ -63,29 +63,21 @@ router.post("/mark-all-read", async (req, res) => { }); /** - * Delete a notification from your inbox. + * Clear all notifications from your inbox. * - * @name DELETE /api/v1/users/:userID/notifications/:notifID + * @name POST /api/v1/users/:userID/notifications/delete-all */ -router.delete("/:notifID", async (req, res) => { +router.post("/delete-all", async (req, res) => { const user = req[SYMBOL_TachiData]!.requestedUser!; - const isTheirNotif = await db.notifications.findOne({ + const deleted = await db.notifications.remove({ sentTo: user.id, - notifID: req.params.notifID, }); - if (!isTheirNotif) { - return res.status(404).json({ - success: false, - description: `This notification does not exist, is not yours, or was already deleted.`, - }); - } - return res.status(200).json({ success: true, - description: `Deleted notification.`, - body: isTheirNotif, + description: `Deleted ${deleted.deletedCount ?? 0} notification(s).`, + body: {}, }); });