Move all AJAX handlers to the same directory as the HTML handlers.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / CreateReplyAjaxPage.java
index c297bb3..0181ff2 100644 (file)
@@ -37,7 +37,7 @@ public class CreateReplyAjaxPage extends JsonPage {
         *            The Sone web interface
         */
        public CreateReplyAjaxPage(WebInterface webInterface) {
-               super("ajax/createReply.ajax", webInterface);
+               super("createReply.ajax", webInterface);
        }
 
        //
@@ -53,14 +53,14 @@ public class CreateReplyAjaxPage extends JsonPage {
                String text = request.getHttpRequest().getParam("text").trim();
                Sone currentSone = getCurrentSone(request.getToadletContext());
                if (currentSone == null) {
-                       return new JsonObject().put("success", false).put("error", "auth-required");
+                       return createErrorJsonObject("auth-required");
                }
                Post post = webInterface.getCore().getPost(postId);
                if ((post == null) || (post.getSone() == null)) {
-                       return new JsonObject().put("success", false).put("error", "invalid-post-id");
+                       return createErrorJsonObject("invalid-post-id");
                }
                Reply reply = webInterface.getCore().createReply(currentSone, post, text);
-               return new JsonObject().put("success", true).put("reply", reply.getId());
+               return createSuccessJsonObject().put("reply", reply.getId());
        }
 
 }