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=ef4a0db52b7b843d9d4450a2e775ea0994229b9a;hp=96fb7e42cf9f95bce386a0117be92b41f940d949;hb=ca45de0dcbd2e361ab630bbee1d47ff6cf34d97c;hpb=4a74200598acbc920892740918d2d2637c80fd1f 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 96fb7e4..ef4a0db 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt @@ -3,20 +3,21 @@ 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 net.pterodactylus.sone.web.page.* 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, +@ToadletPath("getTimes.ajax") +class GetTimesAjaxPage @Inject constructor(webInterface: WebInterface, private val timeTextConverter: TimeTextConverter, private val l10nFilter: L10nFilter, - timeZone: TimeZone) : JsonPage("getTimes.ajax", webInterface) { + timeZone: TimeZone) : JsonPage(webInterface) { private val dateTimeFormatter = SimpleDateFormat("MMM d, yyyy, HH:mm:ss").apply { this.timeZone = timeZone @@ -27,7 +28,7 @@ class GetTimesAjaxPage(webInterface: WebInterface, override fun createJsonObject(request: FreenetRequest) = createSuccessJsonObject().apply { - put("postTimes", request.parameters["posts"]!!.idsToJson { core.getPost(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 } }) }