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 <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2024-11-26 11:55:02 -08:00 committed by Veiko Aasa
parent 536721df19
commit 987577fae2
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -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))