1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.text.*
5 import net.pterodactylus.sone.utils.*
6 import net.pterodactylus.sone.web.*
7 import net.pterodactylus.sone.web.page.*
11 * This AJAX page create a reply.
13 @ToadletPath("createReply.ajax")
14 class CreateReplyAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
16 override fun createJsonObject(currentSone: Sone, request: FreenetRequest): JsonReturnObject =
17 request.parameters["post"].emptyToNull
20 val text = TextFilter.filter(request.headers["Host"], request.parameters["text"])
21 val sender = request.parameters["sender"].let(core::getLocalSone) ?: currentSone
22 val reply = core.createReply(sender, post, text)
23 createSuccessJsonObject().apply {
24 put("reply", reply.id)
25 put("sone", sender.id)
28 ?: createErrorJsonObject("invalid-post-id")