Don’t check for Sones but for their IDs.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / UnfollowSonePage.java
index 6a9466d..396e263 100644 (file)
@@ -35,7 +35,7 @@ public class UnfollowSonePage extends SoneTemplatePage {
         *            The Sone web interface
         */
        public UnfollowSonePage(Template template, WebInterface webInterface) {
-               super("unfollowSone.html", template, "Page.UnfollowSone.Title", webInterface);
+               super("unfollowSone.html", template, "Page.UnfollowSone.Title", webInterface, true);
        }
 
        //
@@ -49,27 +49,13 @@ public class UnfollowSonePage extends SoneTemplatePage {
        protected void processTemplate(Request request, Template template) throws RedirectException {
                super.processTemplate(request, template);
                if (request.getMethod() == Method.POST) {
-                       String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 36);
+                       String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
                        Sone currentSone = getCurrentSone(request.getToadletContext());
-                       Sone sone = webInterface.core().getSone(soneId);
-                       if (!sone.equals(currentSone)) {
-                               currentSone.removeFriend(sone);
-                       }
+                       currentSone.removeFriend(soneId);
+                       webInterface.getCore().saveSone(currentSone);
                        throw new RedirectException(returnPage);
                }
        }
 
-       //
-       // SONETEMPLATEPAGE METHODS
-       //
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected boolean requiresLogin() {
-               return true;
-       }
-
 }