X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FFollowSonePage.java;h=bb90ce00cf99ef9b971a3d91e217d207e9fb73c3;hb=b32a06c6f1b42c17e059b1a5da7069b0ca145996;hp=37297681d588cf531cd5f34d23416c066d526684;hpb=48d8d875299dcbcaf24912c58960b7a1c070d22b;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java index 3729768..bb90ce0 100644 --- a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.web.page.Page.Request.Method; import net.pterodactylus.util.template.Template; /** @@ -34,7 +35,7 @@ public class FollowSonePage extends SoneTemplatePage { * The Sone web interface */ public FollowSonePage(Template template, WebInterface webInterface) { - super("followSone.html", template, "Page.FollowSone.Title", webInterface); + super("followSone.html", template, "Page.FollowSone.Title", webInterface, true); } // @@ -47,25 +48,17 @@ public class FollowSonePage extends SoneTemplatePage { @Override protected void processTemplate(Request request, Template template) throws RedirectException { super.processTemplate(request, template); - String soneId = request.getHttpRequest().getParam("sone"); - Sone currentSone = getCurrentSone(request.getToadletContext()); - Sone sone = webInterface.core().getSone(soneId); - if (!sone.equals(currentSone)) { - currentSone.addFriend(sone); + if (request.getMethod() == Method.POST) { + String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44); + String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64); + Sone currentSone = getCurrentSone(request.getToadletContext()); + Sone sone = webInterface.getCore().getSone(soneId); + if (!sone.equals(currentSone)) { + currentSone.addFriend(sone); + webInterface.getCore().saveSone(currentSone); + } + throw new RedirectException(returnPage); } - throw new RedirectException("viewSone.html?sone=" + soneId); - } - - // - // SONETEMPLATEPAGE METHODS - // - - /** - * {@inheritDoc} - */ - @Override - protected boolean requiresLogin() { - return true; } }