Merge branch 'release-0.8.5'
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / UnfollowSoneAjaxPage.java
index 26f1a11..3d984b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - UnfollowSoneAjaxPage.java - Copyright © 2010 David Roden
+ * Sone - UnfollowSoneAjaxPage.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
@@ -45,15 +45,14 @@ public class UnfollowSoneAjaxPage extends JsonPage {
        @Override
        protected JsonObject createJsonObject(FreenetRequest request) {
                String soneId = request.getHttpRequest().getParam("sone");
-               if (!webInterface.getCore().hasSone(soneId)) {
+               if (!webInterface.getCore().getSone(soneId).isPresent()) {
                        return createErrorJsonObject("invalid-sone-id");
                }
                Sone currentSone = getCurrentSone(request.getToadletContext());
                if (currentSone == null) {
                        return createErrorJsonObject("auth-required");
                }
-               currentSone.removeFriend(soneId);
-               webInterface.getCore().touchConfiguration();
+               webInterface.getCore().unfollowSone(currentSone, soneId);
                return createSuccessJsonObject();
        }