X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FFollowSonePage.java;h=842863048a1f47c8ef83e982dfdf62a80efd877f;hb=0aa389b2493e19484530698e2ce056372dc2a1e9;hp=0bf84d72db4186193af3f9ecacabb169a7f4804d;hpb=e24e9b763d193832a000bddadc6e7f7c1b0114cd;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 0bf84d7..8428630 100644 --- a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - FollowSonePage.java - Copyright © 2010 David Roden + * Sone - FollowSonePage.java - Copyright © 2010–2013 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 @@ -17,10 +17,14 @@ package net.pterodactylus.sone.web; +import com.google.common.base.Optional; + +import net.pterodactylus.sone.data.LocalSone; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.web.page.Page.Request.Method; +import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.web.Method; /** * This page lets the user follow another Sone. @@ -47,16 +51,19 @@ public class FollowSonePage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); if (request.getMethod() == Method.POST) { String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); - Sone currentSone = getCurrentSone(request.getToadletContext()); + LocalSone currentSone = getCurrentSone(request.getToadletContext()).get(); String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 1200); for (String soneId : soneIds.split("[ ,]+")) { - currentSone.addFriend(soneId); + Optional sone = webInterface.getCore().getSone(soneId); + if (sone.isPresent()) { + webInterface.getCore().followSone(currentSone, soneId); + webInterface.getCore().markSoneKnown(sone.get()); + } } - webInterface.getCore().saveSone(currentSone); throw new RedirectException(returnPage); } }