X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetTimesAjaxPage.kt;h=233cf75b7b6ca1c2b92317a7ebe7a91932f19d18;hp=9310786e51f402cdbb05fcb27eb2f6fccc515f7c;hb=fd852f7aee78ea04fb49920e698500c71321c6d4;hpb=4af98a3470ba214fb452b0f0d908b707811fa496 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt index 9310786..233cf75 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt @@ -3,17 +3,17 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.freenet.L10nFilter import net.pterodactylus.sone.text.TimeTextConverter 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 java.text.SimpleDateFormat import java.util.TimeZone +import javax.inject.Inject /** * Ajax page that returns a formatted, relative timestamp for replies or posts. */ -class GetTimesAjaxPage(webInterface: WebInterface, +class GetTimesAjaxPage @Inject constructor(webInterface: WebInterface, private val timeTextConverter: TimeTextConverter, private val l10nFilter: L10nFilter, timeZone: TimeZone) : JsonPage("getTimes.ajax", webInterface) { @@ -22,13 +22,13 @@ class GetTimesAjaxPage(webInterface: WebInterface, this.timeZone = timeZone } - override fun needsFormPassword() = false - override fun requiresLogin() = false + override val needsFormPassword = false + override val requiresLogin = false override fun createJsonObject(request: FreenetRequest) = createSuccessJsonObject().apply { - put("postTimes", request.parameters["posts"]!!.idsToJson { webInterface.core.getPost(it)?.let { it.id to it.time } }) - put("replyTimes", request.parameters["replies"]!!.idsToJson { webInterface.core.getPostReply(it)?.let { it.id to it.time } }) + put("postTimes", request.parameters["posts"]!!.idsToJson { core.getPost(it)?.let { it.id to it.time } }) + put("replyTimes", request.parameters["replies"]!!.idsToJson { core.getPostReply(it)?.let { it.id to it.time } }) } private fun String.idsToJson(transform: (String) -> Pair?) = @@ -43,7 +43,7 @@ class GetTimesAjaxPage(webInterface: WebInterface, "tooltip" to synchronized(dateTimeFormatter) { dateTimeFormatter.format(time) }) - }.forEach { this@jsonObject.put(it.first, it.second) } + }.forEach { this@jsonObject.set(it.first, it.second) } } }