X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDismissNotificationPage.kt;h=ae0cfe0291f7be0fa528d7bd850d3d68bfb4394d;hp=4c2472a8e1b7561c5475909f0c6293d36a7cfcdb;hb=c28013c8a4bcb9776a1e2d82ffd6c4c8297ffb62;hpb=5ba707d40f9d2a20094aaabc21647aeec1feed46 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt index 4c2472a..ae0cfe0 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt @@ -1,20 +1,21 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.web.WebInterface -import net.pterodactylus.sone.web.page.FreenetRequest +import net.pterodactylus.sone.web.page.* import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * Page that lets the user dismiss a notification. */ -class DismissNotificationPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("dismissNotification.html", template, "Page.DismissNotification.Title", webInterface) { +class DismissNotificationPage @Inject constructor(template: Template, webInterface: WebInterface): + SoneTemplatePage("dismissNotification.html", webInterface, template, "Page.DismissNotification.Title") { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256) - val notificationId = request.httpRequest.getPartAsStringFailsafe("notification", 36) - webInterface.getNotification(notificationId).orNull()?.takeIf { it.isDismissable }?.dismiss() + override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) { + val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) + val notificationId = soneRequest.httpRequest.getPartAsStringFailsafe("notification", 36) + soneRequest.webInterface.getNotification(notificationId).orNull()?.takeIf { it.isDismissable }?.dismiss() throw RedirectException(returnPage) }