X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FCreateReplyAjaxPage.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FCreateReplyAjaxPage.java;h=0000000000000000000000000000000000000000;hb=ec7a80c007d6d759823d6d922e6c680c04d334cd;hp=fe2ae858cd5c30d1441c93d2ca99c4ec8272afbb;hpb=cf4ccc7587da36e4a6ba6aa7c04394280b35e271;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java deleted file mode 100644 index fe2ae85..0000000 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Sone - CreateReplyAjaxPage.java - Copyright © 2010–2016 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.web.ajax; - -import com.google.common.base.Optional; - -import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.PostReply; -import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.text.TextFilter; -import net.pterodactylus.sone.web.WebInterface; -import net.pterodactylus.sone.web.page.FreenetRequest; - -/** - * This AJAX page create a reply. - * - * @author David ‘Bombe’ Roden - */ -public class CreateReplyAjaxPage extends JsonPage { - - /** - * Creates a new “create reply” AJAX page. - * - * @param webInterface - * The Sone web interface - */ - public CreateReplyAjaxPage(WebInterface webInterface) { - super("createReply.ajax", webInterface); - } - - // - // JSONPAGE METHODS - // - - /** - * {@inheritDoc} - */ - @Override - protected JsonReturnObject createJsonObject(FreenetRequest request) { - String postId = request.getHttpRequest().getParam("post"); - String text = request.getHttpRequest().getParam("text").trim(); - String senderId = request.getHttpRequest().getParam("sender"); - Sone sender = webInterface.getCore().getLocalSone(senderId); - if (sender == null) { - sender = getCurrentSone(request.getToadletContext()); - } - Optional post = webInterface.getCore().getPost(postId); - if (!post.isPresent()) { - return createErrorJsonObject("invalid-post-id"); - } - text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text); - PostReply reply = webInterface.getCore().createReply(sender, post.get(), text); - return createSuccessJsonObject().put("reply", reply.getId()).put("sone", sender.getId()); - } - -}