X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetLikesAjaxPage.kt;h=f0b001270f7cc24dd921341767a87ca8f04250b2;hb=7afd66a21244e757b6b49ba96bb3989bc55a2abf;hp=12e8309dd192df9f89e4e1b52ab10b37d872cd96;hpb=85b7420f3492af4e5591f62ad673309a76de7e04;p=Sone.git 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 12e8309..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,28 +4,29 @@ 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(core::getPost) + ?.let(core::getPost) ?.let(core::getLikes) ?.toReply() ?: createErrorJsonObject("invalid-post-id") "reply" -> request.parameters["reply"] - .let(core::getPostReply) + ?.let(core::getPostReply) ?.let(core::getLikes) ?.toReply() ?: createErrorJsonObject("invalid-reply-id")