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=cd348e75f28bb6b8c44be3948d12a5cc23218535;hp=9f8eeb42594a897802559af36c58a0227ed96ada;hb=faf66247a34f64946990a985d2ea3003465969cb;hpb=d63b7445567b65ffdbd50fa8f7ffbfea1304dff9 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 9f8eeb4..cd348e7 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt @@ -1,21 +1,23 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.web.WebInterface -import net.pterodactylus.sone.web.page.FreenetRequest -import net.pterodactylus.util.template.Template -import net.pterodactylus.util.template.TemplateContext +import net.pterodactylus.sone.main.* +import net.pterodactylus.sone.web.* +import net.pterodactylus.sone.web.page.* +import net.pterodactylus.util.template.* +import javax.inject.* /** * Page that lets the user dismiss a notification. */ -class DismissNotificationPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("dismissNotification.html", webInterface, template, "Page.DismissNotification.Title") { +@ToadletPath("dismissNotification.html") +class DismissNotificationPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : + SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.DismissNotification.Title") { - override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { - val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) - val notificationId = freenetRequest.httpRequest.getPartAsStringFailsafe("notification", 36) - webInterface.getNotification(notificationId).orNull()?.takeIf { it.isDismissable }?.dismiss() - throw RedirectException(returnPage) + 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() + redirectTo(returnPage) } }