X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FCreatePostAjaxPage.java;h=0fc123632616ec5f88b63b42125dc412f236c168;hb=b72db16cd16e8bfbaadc44604bdff3f49a1aff51;hp=9b9224992a9c7a4a85d2e2b5fa71455b7f963b1f;hpb=8454806e48890675178c1b4b6cbe4bb9c42b68a3;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java index 9b92249..0fc1236 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.util.json.JsonObject; @@ -48,12 +49,20 @@ public class CreatePostAjaxPage extends JsonPage { if (sone == null) { return createErrorJsonObject("auth-required"); } + String recipientId = request.getHttpRequest().getParam("recipient"); + Sone recipient = webInterface.getCore().getSone(recipientId, false); + String senderId = request.getHttpRequest().getParam("sender"); + Sone sender = webInterface.getCore().getLocalSone(senderId, false); + if (sender == null) { + sender = sone; + } String text = request.getHttpRequest().getParam("text"); if ((text == null) || (text.trim().length() == 0)) { return createErrorJsonObject("text-required"); } - Post newPost = webInterface.getCore().createPost(sone, text); - return createSuccessJsonObject().put("postId", newPost.getId()); + text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text); + Post newPost = webInterface.getCore().createPost(sender, recipient, text); + return createSuccessJsonObject().put("postId", newPost.getId()).put("sone", sender.getId()).put("recipient", (newPost.getRecipient() != null) ? newPost.getRecipient().getId() : null); } }