X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FCreatePostAjaxPage.kt;h=28af3e320e947f954032ccb890eba8ca86c35d44;hp=868e990ff8d5985684643f3d180e99e7b18687f7;hb=04709e23f38e9d447337682ba27201da5dc19bd9;hpb=6f1f26e3998cfef155b0cf59152827accea70d30 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt index 868e990..28af3e3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt @@ -1,19 +1,17 @@ package net.pterodactylus.sone.web.ajax -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.text.TextFilter -import net.pterodactylus.sone.utils.asOptional -import net.pterodactylus.sone.utils.emptyToNull -import net.pterodactylus.sone.utils.headers -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.data.* +import net.pterodactylus.sone.text.* +import net.pterodactylus.sone.utils.* +import net.pterodactylus.sone.web.* +import net.pterodactylus.sone.web.page.* +import javax.inject.* /** * AJAX handler that creates a new post. */ -class CreatePostAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("createPost.ajax", webInterface) { +@ToadletPath("createPost.ajax") +class CreatePostAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) { override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["text"].emptyToNull @@ -21,7 +19,7 @@ class CreatePostAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("createP ?.let { text -> val sender = request.parameters["sender"].emptyToNull?.let(core::getSone) ?: currentSone val recipient = request.parameters["recipient"]?.let(core::getSone) - core.createPost(sender, recipient.asOptional(), text).let { post -> + core.createPost(sender, recipient, text).let { post -> createSuccessJsonObject().apply { put("postId", post.id) put("sone", sender.id)