X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FUnlikePage.kt;h=4e03b762d942608f65fe1a1c27ec217128ce33b4;hb=ee696855c54413c28fe790f6c7c140bee5773be0;hp=42e552e569ee1f8522002d36d444cf8cb0fcbbce;hpb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt index 42e552e..4e03b76 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt @@ -1,23 +1,25 @@ package net.pterodactylus.sone.web.pages +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.isPOST import net.pterodactylus.sone.utils.parameters 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 javax.inject.Inject /** * Page that lets the user unlike a [net.pterodactylus.sone.data.Post] or [net.pterodactylus.sone.data.Reply]. */ -class UnlikePage(template: Template, webInterface: WebInterface): - SoneTemplatePage("unlike.html", template, "Page.Unlike.Title", webInterface, true) { +class UnlikePage @Inject constructor(template: Template, webInterface: WebInterface): + LoggedInPage("unlike.html", template, "Page.Unlike.Title", webInterface) { - override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { when (freenetRequest.parameters["type"]) { - "post" -> getCurrentSone(freenetRequest.toadletContext)!!.removeLikedPostId(freenetRequest.parameters["post"]!!) - "reply" -> getCurrentSone(freenetRequest.toadletContext)!!.removeLikedReplyId(freenetRequest.parameters["reply"]!!) + "post" -> currentSone.removeLikedPostId(freenetRequest.parameters["post"]!!) + "reply" -> currentSone.removeLikedReplyId(freenetRequest.parameters["reply"]!!) } throw RedirectException(freenetRequest.parameters["returnPage", 256]) }