X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetLikesAjaxPage.kt;h=f0b001270f7cc24dd921341767a87ca8f04250b2;hp=fc2142d3fd8f84e3198e7f633986dce1610c16d4;hb=9fad99acd6c971d6046a117fb5b90e40872415e7;hpb=889b7b47200adb464d44604a812e7bbb1ba89e1f diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt index fc2142d..f0b0012 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt @@ -4,29 +4,30 @@ import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.template.SoneAccessor import net.pterodactylus.sone.utils.jsonArray import net.pterodactylus.sone.utils.jsonObject -import net.pterodactylus.sone.utils.let import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest +import javax.inject.Inject /** * AJAX page that retrieves the number of “likes” a [net.pterodactylus.sone.data.Post] * or [net.pterodactylus.sone.data.PostReply] has. */ -class GetLikesAjaxPage(webInterface: WebInterface) : JsonPage("getLikes.ajax", webInterface) { +class GetLikesAjaxPage @Inject constructor(webInterface: WebInterface) : + JsonPage("getLikes.ajax", webInterface) { - override fun needsFormPassword() = false + override val needsFormPassword = false override fun createJsonObject(request: FreenetRequest) = when (request.parameters["type"]) { "post" -> request.parameters["post"] - .let(webInterface.core::getPost) - ?.let(webInterface.core::getLikes) + ?.let(core::getPost) + ?.let(core::getLikes) ?.toReply() ?: createErrorJsonObject("invalid-post-id") "reply" -> request.parameters["reply"] - .let(webInterface.core::getPostReply) - ?.let(webInterface.core::getLikes) + ?.let(core::getPostReply) + ?.let(core::getLikes) ?.toReply() ?: createErrorJsonObject("invalid-reply-id") else -> createErrorJsonObject("invalid-type")