X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FFollowSonePage.java;h=ca29fc94f05a692c9703a1eeb75249dc5da72ee1;hb=53a71d1d6b91e4d56af49a06f2e06bc4d11bf3eb;hp=143e0bacaf8e35dee0054d93dd8a6f8464eb668d;hpb=45f92ec63dbf8134d92ceed67294faa38117b195;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 143e0ba..ca29fc9 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,6 +17,8 @@ package net.pterodactylus.sone.web; +import com.google.common.base.Optional; + import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; @@ -52,12 +54,15 @@ public class FollowSonePage extends SoneTemplatePage { super.processTemplate(request, templateContext); if (request.getMethod() == Method.POST) { String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); - Sone currentSone = getCurrentSone(request.getToadletContext()); + Sone 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().touchConfiguration(); throw new RedirectException(returnPage); } }