Merge branch 'message-recipient'
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / CreatePostAjaxPage.java
index 0d553cc..1e45a60 100644 (file)
@@ -36,7 +36,7 @@ public class CreatePostAjaxPage extends JsonPage {
         *            The Sone web interface
         */
        public CreatePostAjaxPage(WebInterface webInterface) {
-               super("ajax/createPost.ajax", webInterface);
+               super("createPost.ajax", webInterface);
        }
 
        /**
@@ -48,11 +48,13 @@ 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 text = request.getHttpRequest().getParam("text");
                if ((text == null) || (text.trim().length() == 0)) {
                        return createErrorJsonObject("text-required");
                }
-               Post newPost = webInterface.getCore().createPost(sone, text);
+               Post newPost = webInterface.getCore().createPost(sone, recipient, text);
                return createSuccessJsonObject().put("postId", newPost.getId());
        }