From b0d9014a0059ea6f62bfe6e4123ca86faa3a7062 Mon Sep 17 00:00:00 2001 From: ClaraCrazy Date: Sat, 28 Sep 2024 02:16:58 +0200 Subject: [PATCH] Add "Wipe Inbox" button --- infrastructure/web/routes/inbox.js | 19 +++++++++++++++++++ infrastructure/web/views/inbox.twig | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/infrastructure/web/routes/inbox.js b/infrastructure/web/routes/inbox.js index 0c1eb19..6ef25f6 100644 --- a/infrastructure/web/routes/inbox.js +++ b/infrastructure/web/routes/inbox.js @@ -61,6 +61,25 @@ router.get( } ) +router.get( + '^/:address/delete-all', + sanitizeAddress, + async (req, res, next) => { + try { + const mailProcessingService = req.app.get('mailProcessingService') + const mailSummaries = await mailProcessingService.getMailSummaries(req.params.address) + for (mail in mailSummaries) { + await mailProcessingService.deleteSpecificEmail(req.params.address, mailSummaries[mail].uid) + } + res.redirect(`/inbox/${req.params.address}`) + } catch (error) { + console.error('error while deleting email', error) + next(error) + } + } +) + + router.get( '^/:address/:uid/delete', sanitizeAddress, diff --git a/infrastructure/web/views/inbox.twig b/infrastructure/web/views/inbox.twig index 06b5489..d0a7efb 100644 --- a/infrastructure/web/views/inbox.twig +++ b/infrastructure/web/views/inbox.twig @@ -7,7 +7,12 @@ }); -
Logout
+
+ + Wipe Inbox
+ + Logout +

{{ address }}

{% for mail in mailSummaries %}