From 987577fae28d1b71183040aad2f5aee0ed077c9f Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 26 Nov 2024 11:55:02 -0800 Subject: [PATCH] notifications: Don't error when dismissing missing notifications Fixes: #2468. - Two browser tabs could be loaded with the interface and the same notification could be dismissed twice. When dismissing the notification for the second time, we currently throw a 404 error. Instead silently ignore the error. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/views.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plinth/views.py b/plinth/views.py index b2ee60e67..84fdca4b5 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -568,9 +568,8 @@ def notification_dismiss(request, id): """Dismiss a notification.""" from .notification import Notification notes = Notification.list(key=id, user=request.user) - if not notes: - raise Http404 - - notes[0].dismiss() + if notes: + # If a notification is not found, no need to dismiss it. + notes[0].dismiss() return HttpResponseRedirect(_get_redirect_url_from_param(request))